Search in sources :

Example 1 with TClass2Serializer

use of org.janusgraph.graphdb.serializer.attributes.TClass2Serializer in project janusgraph by JanusGraph.

the class SerializerTest method parallelDeserialization.

@Test
public void parallelDeserialization() throws InterruptedException {
    serialize.registerClass(1, TClass2.class, new TClass2Serializer());
    final long value = 8;
    final String str = "123456";
    final TClass2 c = new TClass2("abcdefg", 333);
    DataOutput out = serialize.getDataOutput(128);
    out.putLong(value);
    out.writeClassAndObject(value);
    out.writeObject(c, TClass2.class);
    out.writeObjectNotNull(str);
    final StaticBuffer b = out.getStaticBuffer();
    int numThreads = 4;
    Thread[] threads = new Thread[numThreads];
    for (int i = 0; i < numThreads; i++) {
        threads[i] = new Thread(() -> {
            for (int j = 0; j < 100000; j++) {
                ReadBuffer buffer = b.asReadBuffer();
                assertEquals(8, buffer.getLong());
                assertEquals(value, (long) serialize.readClassAndObject(buffer));
                assertEquals(c, serialize.readObject(buffer, TClass2.class));
                assertEquals(str, serialize.readObjectNotNull(buffer, String.class));
            }
        });
        threads[i].start();
    }
    for (int i = 0; i < numThreads; i++) {
        threads[i].join();
    }
}
Also used : TClass2(org.janusgraph.graphdb.serializer.attributes.TClass2) DataOutput(org.janusgraph.graphdb.database.serialize.DataOutput) ReadBuffer(org.janusgraph.diskstorage.ReadBuffer) TClass2Serializer(org.janusgraph.graphdb.serializer.attributes.TClass2Serializer) StaticBuffer(org.janusgraph.diskstorage.StaticBuffer) Test(org.junit.jupiter.api.Test)

Example 2 with TClass2Serializer

use of org.janusgraph.graphdb.serializer.attributes.TClass2Serializer in project janusgraph by JanusGraph.

the class SerializerTest method objectWriteReadTest.

@Test
public void objectWriteReadTest() {
    serialize.registerClass(2, TClass1.class, new TClass1Serializer());
    serialize.registerClass(80342, TClass2.class, new TClass2Serializer());
    serialize.registerClass(999, TEnum.class, new TEnumSerializer());
    objectWriteRead();
}
Also used : TClass2Serializer(org.janusgraph.graphdb.serializer.attributes.TClass2Serializer) TEnumSerializer(org.janusgraph.graphdb.serializer.attributes.TEnumSerializer) TClass1Serializer(org.janusgraph.graphdb.serializer.attributes.TClass1Serializer) Test(org.junit.jupiter.api.Test)

Example 3 with TClass2Serializer

use of org.janusgraph.graphdb.serializer.attributes.TClass2Serializer in project janusgraph by JanusGraph.

the class SerializerSpeedTest method performanceTestObjectSerialization.

@RepeatedTest(10)
public void performanceTestObjectSerialization() {
    serialize.registerClass(2, TClass1.class, new TClass1Serializer());
    serialize.registerClass(80342, TClass2.class, new TClass2Serializer());
    serialize.registerClass(999, TEnum.class, new TEnumSerializer());
    int runs = 1000000;
    for (int i = 0; i < runs; i++) {
        objectWriteRead();
    }
}
Also used : TClass2Serializer(org.janusgraph.graphdb.serializer.attributes.TClass2Serializer) TEnumSerializer(org.janusgraph.graphdb.serializer.attributes.TEnumSerializer) TClass1Serializer(org.janusgraph.graphdb.serializer.attributes.TClass1Serializer) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Aggregations

TClass2Serializer (org.janusgraph.graphdb.serializer.attributes.TClass2Serializer)3 TClass1Serializer (org.janusgraph.graphdb.serializer.attributes.TClass1Serializer)2 TEnumSerializer (org.janusgraph.graphdb.serializer.attributes.TEnumSerializer)2 Test (org.junit.jupiter.api.Test)2 ReadBuffer (org.janusgraph.diskstorage.ReadBuffer)1 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)1 DataOutput (org.janusgraph.graphdb.database.serialize.DataOutput)1 TClass2 (org.janusgraph.graphdb.serializer.attributes.TClass2)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1