SerializationInfo { private Field checkFieldInAllSchemas(String name) throws TupleMRException { Field field = null; for (int i = 0; i < mrConfig.getIntermediateSchemas().size(); i++) { Field fieldInSource = checkFieldInSchema(name, i); if (field == null) { field = fieldInSource; } else if (field.getType() != fieldInSource.getType() || field.getObjectClass() != fieldInSource.getObjectClass()) { throw new TupleMRException("The type for field '" + name + "' is not the same in all the sources"); } else if (fieldInSource.isNullable()) { field = fieldInSource; } } return field; } SerializationInfo(TupleMRConfig tupleMRConfig); List<int[]> getPartitionFieldsIndexes(); int[] getFieldsToPartition(int schemaId); int[] getCommonSchemaIndexTranslation(int schemaId); int[] getSpecificSchemaIndexTranslation(int schemaId); int[] getGroupSchemaIndexTranslation(int schemaId); List<Serializer[]> getSpecificSchemaSerializers(); List<Deserializer[]> getSpecificSchemaDeserializers(); Serializer[] getCommonSchemaSerializers(); Deserializer[] getCommonSchemaDeserializers(); Serializer[] getGroupSchemaSerializers(); Deserializer[] getGroupSchemaDeserializers(); static Serializer[] getSerializers(Schema schema, Configuration conf); static Deserializer[] getDeserializers(Schema readSchema, Schema targetSchema, Configuration conf); Schema getCommonSchema(); Schema getSpecificSchema(int schemaId); List<Schema> getSpecificSchemas(); Schema getGroupSchema();  }
@Test public void testCheckFieldInAllSchemas() throws TupleMRException { TupleMRConfigBuilder b = new TupleMRConfigBuilder(); b.addIntermediateSchema(new Schema("schema1", Fields .parse("ax:int,bx:string,cx:string"))); b.addIntermediateSchema(new Schema("schema2", Fields .parse("ay:int,cy:string,by:string"))); b.addIntermediateSchema(new Schema("schema3", Fields .parse("a:int?,c:string,b:string?"))); { Aliases aliases1 = new Aliases(); aliases1.add("a", "ax"); aliases1.add("b", "bx"); aliases1.add("c", "cx"); b.setFieldAliases("schema1", aliases1); } { Aliases aliases2 = new Aliases(); aliases2.add("a", "ay"); aliases2.add("b", "by"); aliases2.add("c", "cy"); b.setFieldAliases("schema2", aliases2); } b.setGroupByFields("b", "c"); OrderBy commonOrderBy = new OrderBy(); commonOrderBy.add("b", Order.ASC); commonOrderBy.add("c", Order.DESC); commonOrderBy.addSchemaOrder(Order.DESC); commonOrderBy.add("a", Order.DESC); b.setOrderBy(commonOrderBy); TupleMRConfig config = b.buildConf(); SerializationInfo serInfo = config.getSerializationInfo(); Schema common = serInfo.getCommonSchema(); System.out.println(common); Schema.Field field = common.getField(0); assertEquals("b", field.getName()); Assert.assertTrue(field.isNullable()); field = common.getField(1); assertEquals("c", field.getName()); assertFalse(field.isNullable()); int count = 0; for (Schema schema : serInfo.getSpecificSchemas()) { assertEquals("a", schema.getField(0).getName()); if (count == 2) { assertEquals(true, schema.getField(0).isNullable()); } else { assertEquals(false, schema.getField(0).isNullable()); } count++; } }