Search in sources :

Example 21 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class SerializerTest method longWriteTest.

@Test
public void longWriteTest() {
    // 26 chars
    String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int no = 100;
    DataOutput out = serialize.getDataOutput(128, true);
    for (int i = 0; i < no; i++) {
        String str = base + (i + 1);
        out.writeObjectNotNull(str);
    }
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    if (printStats)
        log.debug(bufferStats(b));
    for (int i = 0; i < no; i++) {
        String str = base + (i + 1);
        String read = serialize.readObjectNotNull(b, String.class);
        assertEquals(str, read);
    }
    assertFalse(b.hasRemaining());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test) PerformanceTest(com.thinkaurelius.titan.testutil.PerformanceTest)

Example 22 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class SerializerTest method largeWriteTest.

@Test
public void largeWriteTest() {
    // 26 chars
    String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    String str = "";
    for (int i = 0; i < 100; i++) str += base;
    DataOutput out = serialize.getDataOutput(128, true);
    out.writeObjectNotNull(str);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    if (printStats)
        log.debug(bufferStats(b));
    assertEquals(str, serialize.readObjectNotNull(b, String.class));
    assertFalse(b.hasRemaining());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test) PerformanceTest(com.thinkaurelius.titan.testutil.PerformanceTest)

Example 23 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class SerializerTest method classSerialization.

@Test
public void classSerialization() {
    DataOutput out = serialize.getDataOutput(128, true);
    out.writeObjectNotNull(Boolean.class);
    out.writeObjectNotNull(Byte.class);
    out.writeObjectNotNull(Double.class);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    assertEquals(Boolean.class, serialize.readObjectNotNull(b, Class.class));
    assertEquals(Byte.class, serialize.readObjectNotNull(b, Class.class));
    assertEquals(Double.class, serialize.readObjectNotNull(b, Class.class));
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test) PerformanceTest(com.thinkaurelius.titan.testutil.PerformanceTest)

Example 24 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class SerializerTest method enumSerializeTest.

@Test
public void enumSerializeTest() {
    DataOutput out = serialize.getDataOutput(128, true);
    out.writeObjectNotNull(TestEnum.Two);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    if (printStats)
        log.debug(bufferStats(b));
    assertEquals(TestEnum.Two, serialize.readObjectNotNull(b, TestEnum.class));
    assertFalse(b.hasRemaining());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test) PerformanceTest(com.thinkaurelius.titan.testutil.PerformanceTest)

Aggregations

ReadBuffer (com.thinkaurelius.titan.diskstorage.ReadBuffer)24 DataOutput (com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)15 Test (org.junit.Test)15 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)11 PerformanceTest (com.thinkaurelius.titan.testutil.PerformanceTest)8 WriteBuffer (com.thinkaurelius.titan.diskstorage.WriteBuffer)4 WriteByteBuffer (com.thinkaurelius.titan.diskstorage.util.WriteByteBuffer)4 RelationType (com.thinkaurelius.titan.graphdb.internal.RelationType)2 EdgeDirection (com.thinkaurelius.titan.graphdb.relations.EdgeDirection)2 RelationCache (com.thinkaurelius.titan.graphdb.relations.RelationCache)2 Instant (java.time.Instant)2 LongObjectHashMap (com.carrotsearch.hppc.LongObjectHashMap)1 LongObjectOpenHashMap (com.carrotsearch.hppc.LongObjectOpenHashMap)1 EntryMetaData (com.thinkaurelius.titan.diskstorage.EntryMetaData)1 StaticArrayBuffer (com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer)1 StaticByteBuffer (com.thinkaurelius.titan.diskstorage.util.StaticByteBuffer)1 RelationTypeParse (com.thinkaurelius.titan.graphdb.database.idhandling.IDHandler.RelationTypeParse)1 Serializer (com.thinkaurelius.titan.graphdb.database.serialize.Serializer)1 KryoSerializer (com.thinkaurelius.titan.graphdb.database.serialize.kryo.KryoSerializer)1 InternalType (com.thinkaurelius.titan.graphdb.internal.InternalType)1