Integer schemaId = tupleMRConfig.getSchemaIdByName(schemaName);
if (schemaId == null){
throw new IOException("Schema '" + tuple.getSchema() +"' is not a valid intermediate schema");
}
if (inputSchemaValidation){
Schema expectedSchema = tupleMRConfig.getIntermediateSchema(schemaId);
if (!expectedSchema.equals(tuple.getSchema())){
throw new IOException("Tuple '"+tuple + "' " +
"contains not expected schema." +
"Expected schema '"+ expectedSchema + " and actual: " + tuple.getSchema());
}
}
int[] commonTranslation = serInfo.getCommonSchemaIndexTranslation(schemaId);
// Serialize common
tupleSerializer.write(commonSchema, tuple, commonTranslation, serInfo.getCommonSchemaSerializers());
// Serialize schema id
WritableUtils.writeVInt(tupleSerializer.getOut(), schemaId);
// Serialize rest of the fields
Schema specificSchema = serInfo.getSpecificSchema(schemaId);
int[] specificTranslation = serInfo
.getSpecificSchemaIndexTranslation(schemaId);
tupleSerializer.write(specificSchema, tuple, specificTranslation, serInfo.getSpecificSchemaSerializers().get(schemaId));
}