Field field = checkFieldInAllSchemas(fieldName);
commonFields.add(Field.cloneField(field,fieldName));
}
this.commonSchema = new Schema("common", commonFields);
this.specificSchemas = new ArrayList<Schema>();
List<List<Field>> specificFieldsBySource = new ArrayList<List<Field>>();
for(int schemaId = 0; schemaId < mrConfig.getNumIntermediateSchemas(); schemaId++) {
Criteria specificCriteria = mrConfig.getSpecificOrderBys().get(schemaId);
List<Field> specificFields = new ArrayList<Field>();
if(specificCriteria != null) {
for(SortElement sortElement : specificCriteria.getElements()) {
String fieldName = sortElement.getName();
Field field = checkFieldInSchema(fieldName, schemaId);
specificFields.add(Field.cloneField(field,fieldName));
}
}
specificFieldsBySource.add(specificFields);
}
for(int i = 0; i < mrConfig.getNumIntermediateSchemas(); i++) {
Schema sourceSchema = mrConfig.getIntermediateSchema(i);
List<Field> specificFields = specificFieldsBySource.get(i);
for(Field field : sourceSchema.getFields()) {
Map<String,String> sourceAliases = mrConfig.getFieldAliases(sourceSchema.getName());
if(!containsField(field.getName(),commonSchema.getFields(),sourceAliases)
&& !containsField(field.getName(), specificFields,sourceAliases)) {
specificFields.add(field);
}
}
this.specificSchemas.add(new Schema("specific", specificFields));
}
this.specificSchemas = Collections.unmodifiableList(this.specificSchemas);
}