}
if (expr instanceof BasicTableExpr)
{
BasicTable.Reader reader = new BasicTable.Reader(((BasicTableExpr) expr).getPath(), conf);
SortInfo mySortInfo = reader.getSortInfo();
reader.close();
if (mySortInfo == null)
throw new IOException("The table is not sorted");
if (comparatorName == null)
// cheat the equals method's comparator comparison
comparatorName = mySortInfo.getComparator();
if (sortcolumns != null && !mySortInfo.equals(sortcolumns, comparatorName))
{
throw new IOException("The table is not properly sorted");
}
setSorted(conf);
} else {
List<LeafTableInfo> leaves = expr.getLeafTables(null);
for (Iterator<LeafTableInfo> it = leaves.iterator(); it.hasNext(); )
{
LeafTableInfo leaf = it.next();
BasicTable.Reader reader = new BasicTable.Reader(leaf.getPath(), conf);
SortInfo mySortInfo = reader.getSortInfo();
reader.close();
if (mySortInfo == null)
throw new IOException("The table is not sorted");
if (comparatorName == null)
comparatorName = mySortInfo.getComparator(); // use the first table's comparator as comparison base
if (sortcolumns == null)
{
sortcolumns = mySortInfo.getSortColumnNames();
comparatorName = mySortInfo.getComparator();
} else {
if (!mySortInfo.equals(sortcolumns, comparatorName))
{
throw new IOException("The table is not properly sorted");
}
}
}