Search in sources :

Example 6 with DataOutput

use of com.thinkaurelius.titan.graphdb.database.serialize.DataOutput in project titan by thinkaurelius.

the class KCVSLog method getMarkerColumn.

/**
     * ###################################
     *  Getting/setting Log Settings
     * ###################################
     */
private StaticBuffer getMarkerColumn(int partitionId, int bucketId) {
    DataOutput out = manager.serializer.getDataOutput(1 + 4 + 4);
    out.putByte(MARKER_PREFIX);
    out.putInt(partitionId);
    out.putInt(bucketId);
    return out.getStaticBuffer();
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)

Example 7 with DataOutput

use of com.thinkaurelius.titan.graphdb.database.serialize.DataOutput in project titan by thinkaurelius.

the class ManagementSystem method commit.

@Override
public synchronized void commit() {
    ensureOpen();
    //Commit config changes
    if (transactionalConfig.hasMutations()) {
        DataOutput out = graph.getDataSerializer().getDataOutput(128);
        out.writeObjectNotNull(MgmtLogType.CONFIG_MUTATION);
        transactionalConfig.logMutations(out);
        sysLog.add(out.getStaticBuffer());
    }
    transactionalConfig.commit();
    //Commit underlying transaction
    transaction.commit();
    //Communicate schema changes
    if (!updatedTypes.isEmpty()) {
        mgmtLogger.sendCacheEviction(updatedTypes, updatedTypeTriggers, getOpenInstancesInternal());
        for (TitanSchemaVertex schemaVertex : updatedTypes) {
            schemaCache.expireSchemaElement(schemaVertex.longId());
        }
    }
    if (graphShutdownRequired)
        graph.close();
    close();
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) TitanSchemaVertex(com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex)

Example 8 with DataOutput

use of com.thinkaurelius.titan.graphdb.database.serialize.DataOutput in project titan by thinkaurelius.

the class TypeDefinitionDescriptionSerializer method write.

@Override
public void write(WriteBuffer buffer, TypeDefinitionDescription attribute) {
    DataOutput out = (DataOutput) buffer;
    out.writeObjectNotNull(attribute.getCategory());
    out.writeClassAndObject(attribute.getModifier());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)

Example 9 with DataOutput

use of com.thinkaurelius.titan.graphdb.database.serialize.DataOutput in project titan by thinkaurelius.

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(Long.valueOf(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(new Runnable() {

            @Override
            public void run() {
                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 : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer) Test(org.junit.Test)

Example 10 with DataOutput

use of com.thinkaurelius.titan.graphdb.database.serialize.DataOutput in project titan by thinkaurelius.

the class SerializerTest method comparableStringSerialization.

@Test
public void comparableStringSerialization() {
    //Characters
    DataOutput out = serialize.getDataOutput(((int) Character.MAX_VALUE) * 2 + 8);
    for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) {
        out.writeObjectNotNull(Character.valueOf(c));
    }
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) {
        assertEquals(c, serialize.readObjectNotNull(b, Character.class).charValue());
    }
    //String
    for (int t = 0; t < 10000; t++) {
        DataOutput out1 = serialize.getDataOutput(32 + 5);
        DataOutput out2 = serialize.getDataOutput(32 + 5);
        String s1 = RandomGenerator.randomString(1, 32);
        String s2 = RandomGenerator.randomString(1, 32);
        out1.writeObjectByteOrder(s1, String.class);
        out2.writeObjectByteOrder(s2, String.class);
        StaticBuffer b1 = out1.getStaticBuffer();
        StaticBuffer b2 = out2.getStaticBuffer();
        assertEquals(s1, serialize.readObjectByteOrder(b1.asReadBuffer(), String.class));
        assertEquals(s2, serialize.readObjectByteOrder(b2.asReadBuffer(), String.class));
        assertEquals(s1 + " vs " + s2, Integer.signum(s1.compareTo(s2)), Integer.signum(b1.compareTo(b2)));
    }
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer) Test(org.junit.Test)

Aggregations

DataOutput (com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)34 ReadBuffer (com.thinkaurelius.titan.diskstorage.ReadBuffer)12 Test (org.junit.Test)11 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)8 StaticArrayEntry (com.thinkaurelius.titan.diskstorage.util.StaticArrayEntry)2 DirectionID (com.thinkaurelius.titan.graphdb.database.idhandling.IDHandler.DirectionID)2 ImplicitKey (com.thinkaurelius.titan.graphdb.types.system.ImplicitKey)2 TitanSchemaVertex (com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex)2 LoggerFactory (org.slf4j.LoggerFactory)2 LongArrayList (com.carrotsearch.hppc.LongArrayList)1 LongHashSet (com.carrotsearch.hppc.LongHashSet)1 LongSet (com.carrotsearch.hppc.LongSet)1 WriteBuffer (com.thinkaurelius.titan.diskstorage.WriteBuffer)1 SliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)1 WriteByteBuffer (com.thinkaurelius.titan.diskstorage.util.WriteByteBuffer)1 IDHandler (com.thinkaurelius.titan.graphdb.database.idhandling.IDHandler)1 Serializer (com.thinkaurelius.titan.graphdb.database.serialize.Serializer)1 StandardSerializer (com.thinkaurelius.titan.graphdb.database.serialize.StandardSerializer)1 RelationCategory (com.thinkaurelius.titan.graphdb.internal.RelationCategory)1 EdgeDirection (com.thinkaurelius.titan.graphdb.relations.EdgeDirection)1