Search in sources :

Example 1 with ReflectionMarshallerFactory

use of org.apache.ignite.internal.schema.marshaller.reflection.ReflectionMarshallerFactory in project ignite-3 by apache.

the class SerializerBenchmarkTest method init.

/**
 * Initialize.
 */
@Setup
public void init() {
    long seed = System.currentTimeMillis();
    rnd = new Random(seed);
    final Class<?> valClass;
    Thread.currentThread().setContextClassLoader(new DynamicClassLoader(AsmMarshallerGenerator.getClassLoader()));
    if (fieldsCount == 0) {
        valClass = Long.class;
        objectFactory = (Factory<Object>) rnd::nextLong;
    } else {
        valClass = createGeneratedObjectClass(fieldsCount, long.class);
        objectFactory = new ObjectFactory<>(valClass);
    }
    schema = new SchemaDescriptor(1, new Column[] { new Column("key", INT64, true) }, mapFieldsToColumns(valClass));
    KvMarshaller<?, ?> marshaller = ("Java".equals(serializerName)) ? new ReflectionMarshallerFactory().create(schema, Long.class, valClass) : new AsmMarshallerGenerator().create(schema, Long.class, valClass);
    this.marshaller = (KvMarshaller<Object, Object>) marshaller;
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Random(java.util.Random) Column(org.apache.ignite.internal.schema.Column) ReflectionMarshallerFactory(org.apache.ignite.internal.schema.marshaller.reflection.ReflectionMarshallerFactory) AsmMarshallerGenerator(org.apache.ignite.internal.schema.marshaller.asm.AsmMarshallerGenerator) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 Random (java.util.Random)1 Column (org.apache.ignite.internal.schema.Column)1 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)1 AsmMarshallerGenerator (org.apache.ignite.internal.schema.marshaller.asm.AsmMarshallerGenerator)1 ReflectionMarshallerFactory (org.apache.ignite.internal.schema.marshaller.reflection.ReflectionMarshallerFactory)1 Setup (org.openjdk.jmh.annotations.Setup)1