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();
}
}
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();
}
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();
}
}
Aggregations