}
private parquet.schema.Type[] convertChildren(Iterator<SchemaElement> schema, int childrenCount) {
parquet.schema.Type[] result = new parquet.schema.Type[childrenCount];
for (int i = 0; i < result.length; i++) {
SchemaElement schemaElement = schema.next();
if ((!schemaElement.isSetType() && !schemaElement.isSetNum_children())
|| (schemaElement.isSetType() && schemaElement.isSetNum_children())) {
throw new RuntimeException("bad element " + schemaElement);
}
Repetition repetition = fromParquetRepetition(schemaElement.getRepetition_type());
String name = schemaElement.getName();
OriginalType originalType = null;
if (schemaElement.isSetConverted_type()) {
originalType = getOriginalType(schemaElement.converted_type);
}
// Create Parquet Type.
if (schemaElement.type != null) {
if (schemaElement.isSetType_length()) {
result[i] = new PrimitiveType(
repetition,
getPrimitive(schemaElement.getType()),
schemaElement.type_length,
name,
originalType);
} else {
result[i] = new PrimitiveType(
repetition,
getPrimitive(schemaElement.getType()),
name,
originalType);
}
} else {
result[i] = new GroupType(
repetition,
name,
originalType,
convertChildren(schema, schemaElement.getNum_children()));
}
}
return result;
}