return result;
}
}
if (sds.size() > 0) {
SchemaDescriptor sd = sds.get(0);
Schema schema = sd.getSchema();
//
// Step 1. Figure out the hierarchical labels from the Schema.
// These are the fields we'll grab from each tuple.
//
// Doing so entails "unrolling" the schemas that contain unions.
// That is, translating such schemas into a set of union-free schemas.
//
List<List<List<DataField>>> perSchemaTupleLists = new ArrayList<List<List<DataField>>>();
List<List<List<DataField>>> dataOrderTupleLists = new ArrayList<List<List<DataField>>>();
List<Integer> schemaOrder = new ArrayList<Integer>();
List<SchemaPair> schemaFrequency = new ArrayList<SchemaPair>();
int numRows = 0;
TreeMap<String, Schema> uniqueUnrolledSchemas = new TreeMap<String, Schema>();
for (Iterator it = sd.getIterator(); it.hasNext(); ) {
GenericData.Record gr = (GenericData.Record) it.next();
List<Schema> grSchemas = SchemaUtils.unrollUnionsWithData(schema, gr, false);
if (grSchemas != null) {
for (Schema grs: grSchemas) {
if (uniqueUnrolledSchemas.get(grs.toString()) == null) {
uniqueUnrolledSchemas.put(grs.toString(), grs);
}
}
}
if (numRows >= MAX_ROWS) {
break;
}
numRows++;
}
List<Schema> allSchemas = new ArrayList(uniqueUnrolledSchemas.values());
List<List<String>> schemaLabelLists = new ArrayList<List<String>>();
for (int i = 0; i < allSchemas.size(); i++) {
Schema s1 = allSchemas.get(i);
schemaLabelLists.add(SchemaUtils.flattenNames(s1));
perSchemaTupleLists.add(new ArrayList<List<DataField>>());
schemaFrequency.add(new SchemaPair(i, 0));
}
//
// Step 2. Build the set of rows for display. One row per tuple.
//
numRows = 0;
boolean incompleteFileScan = false;
int lastBestIdx = -1;
boolean hasMoreRows = false;
for (Iterator it = sd.getIterator(); it.hasNext(); ) {
GenericData.Record gr = (GenericData.Record) it.next();
if (numRows >= MAX_ROWS) {
hasMoreRows = true;
incompleteFileScan = true;
break;