@Override
public Class<DatumWriter<?>> load(CacheKey key) throws Exception {
ClassDefinition classDef = new DatumWriterGenerator().generate(key.getType(), key.getSchema());
ClassLoader typeClassloader = ClassLoaders.getClassLoader(key.getType());
ByteCodeClassLoader classloader = classloaders.get(key.getType());
if (classloader == null) {
classloader = new ByteCodeClassLoader(typeClassloader);
classloaders.put(key.getType(), classloader);
}
return (Class<DatumWriter<?>>) classloader.addClass(classDef, key.getType().getRawType())
.loadClass(classDef.getClassName());
}