use of voldemort.serialization.avro.AvroGenericSerializer in project voldemort by voldemort.
the class AvroStoreBuilderMapper method configure.
@Override
public void configure(JobConf conf) {
super.setConf(conf);
this.mapper.configure(conf);
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new StringReader(conf.get("stores.xml")));
if (storeDefs.size() != 1)
throw new IllegalStateException("Expected to find only a single store, but found multiple!");
this.storeDef = storeDefs.get(0);
keySerializerDefinition = getStoreDef().getKeySerializer();
valueSerializerDefinition = getStoreDef().getValueSerializer();
try {
keyField = conf.get(VoldemortBuildAndPushJob.AVRO_KEY_FIELD);
valField = conf.get(VoldemortBuildAndPushJob.AVRO_VALUE_FIELD);
keySchema = conf.get(AVRO_KEY_SCHEMA);
valSchema = conf.get(AVRO_VALUE_SCHEMA);
if (keySerializerDefinition.getName().equals(DefaultSerializerFactory.AVRO_GENERIC_TYPE_NAME)) {
keySerializer = new AvroGenericSerializer(keySchema);
valueSerializer = new AvroGenericSerializer(valSchema);
} else {
if (keySerializerDefinition.hasVersion()) {
Map<Integer, String> versions = new HashMap<Integer, String>();
for (Map.Entry<Integer, String> entry : keySerializerDefinition.getAllSchemaInfoVersions().entrySet()) versions.put(entry.getKey(), entry.getValue());
keySerializer = new AvroVersionedGenericSerializer(versions);
} else
keySerializer = new AvroVersionedGenericSerializer(keySerializerDefinition.getCurrentSchemaInfo());
if (valueSerializerDefinition.hasVersion()) {
Map<Integer, String> versions = new HashMap<Integer, String>();
for (Map.Entry<Integer, String> entry : valueSerializerDefinition.getAllSchemaInfoVersions().entrySet()) versions.put(entry.getKey(), entry.getValue());
valueSerializer = new AvroVersionedGenericSerializer(versions);
} else
valueSerializer = new AvroVersionedGenericSerializer(valueSerializerDefinition.getCurrentSchemaInfo());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations