Search in sources :

Example 21 with ReadBuffer

use of org.janusgraph.diskstorage.ReadBuffer in project janusgraph by JanusGraph.

the class SerializerTestCommon method objectWriteRead.

protected void objectWriteRead() {
    TClass1 t1 = new TClass1(3245234223423433123L, 0.333f);
    TClass2 t2 = new TClass2("This is a test", 4234234);
    TEnum t3 = TEnum.THREE;
    TEnum t4 = TEnum.TWO;
    DataOutput out = serialize.getDataOutput(128);
    out.writeObjectNotNull(t1);
    out.writeClassAndObject(t2);
    out.writeObject(t3, TEnum.class);
    out.writeClassAndObject(t4);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    assertEquals(t1, serialize.readObjectNotNull(b, TClass1.class));
    assertEquals(t2, serialize.readClassAndObject(b));
    assertEquals(t3, serialize.readObject(b, TEnum.class));
    assertEquals(t4, serialize.readClassAndObject(b));
    assertFalse(b.hasRemaining());
}
Also used : DataOutput(org.janusgraph.graphdb.database.serialize.DataOutput) ReadBuffer(org.janusgraph.diskstorage.ReadBuffer)

Aggregations

ReadBuffer (org.janusgraph.diskstorage.ReadBuffer)21 Test (org.junit.Test)15 DataOutput (org.janusgraph.graphdb.database.serialize.DataOutput)14 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)9 WriteBuffer (org.janusgraph.diskstorage.WriteBuffer)4 WriteByteBuffer (org.janusgraph.diskstorage.util.WriteByteBuffer)4 Instant (java.time.Instant)2 Serializer (org.janusgraph.graphdb.database.serialize.Serializer)2 LoggerFactory (org.slf4j.LoggerFactory)2 LongObjectHashMap (com.carrotsearch.hppc.LongObjectHashMap)1 Preconditions (com.google.common.base.Preconditions)1 Map (java.util.Map)1 Random (java.util.Random)1 StopWatch (org.apache.commons.lang.time.StopWatch)1 Direction (org.apache.tinkerpop.gremlin.structure.Direction)1 EntryMetaData (org.janusgraph.diskstorage.EntryMetaData)1 StaticArrayBuffer (org.janusgraph.diskstorage.util.StaticArrayBuffer)1 IDHandler (org.janusgraph.graphdb.database.idhandling.IDHandler)1 RelationTypeParse (org.janusgraph.graphdb.database.idhandling.IDHandler.RelationTypeParse)1 VariableLong (org.janusgraph.graphdb.database.idhandling.VariableLong)1