Search in sources :

Example 26 with DataOutput

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

the class TransactionLogHeader method serializeSecondary.

public StaticBuffer serializeSecondary(Serializer serializer, LogTxStatus status, Map<String, Throwable> indexFailures, boolean userLogSuccess) {
    Preconditions.checkArgument(status == LogTxStatus.SECONDARY_SUCCESS || status == LogTxStatus.SECONDARY_FAILURE);
    DataOutput out = serializeHeader(serializer, 30, status);
    if (status == LogTxStatus.SECONDARY_FAILURE) {
        out.putBoolean(userLogSuccess);
        out.putInt(indexFailures.size());
        for (String index : indexFailures.keySet()) {
            assert StringUtils.isNotBlank(index);
            out.writeObjectNotNull(index);
        }
    } else
        assert userLogSuccess && indexFailures.isEmpty();
    return out.getStaticBuffer();
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)

Example 27 with DataOutput

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

the class TransactionLogHeader method serializeUserLog.

public StaticBuffer serializeUserLog(Serializer serializer, Entry sourceTxEntry, StandardTransactionId sourceTxId) {
    Preconditions.checkArgument(sourceTxEntry != null && sourceTxEntry.status == LogTxStatus.PRECOMMIT && sourceTxEntry.header.transactionId == sourceTxId.getTransactionId());
    StaticBuffer sourceContent = sourceTxEntry.content;
    Preconditions.checkArgument(sourceContent != null && sourceContent.length() > 0);
    EnumMap<LogTxMeta, Object> meta = new EnumMap<LogTxMeta, Object>(LogTxMeta.class);
    meta.put(LogTxMeta.SOURCE_TRANSACTION, sourceTxId);
    DataOutput out = serializeHeader(serializer, 50 + sourceContent.length(), LogTxStatus.USER_LOG, meta);
    out.putBytes(sourceContent);
    return out.getStaticBuffer();
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer)

Example 28 with DataOutput

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

the class TransactionLogHeader method serializePrimary.

public StaticBuffer serializePrimary(Serializer serializer, LogTxStatus status) {
    Preconditions.checkArgument(status == LogTxStatus.PRIMARY_SUCCESS || status == LogTxStatus.COMPLETE_SUCCESS);
    DataOutput out = serializeHeader(serializer, 30, status);
    return out.getStaticBuffer();
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)

Example 29 with DataOutput

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

the class SerializerTest method enumSerializeTest.

@Test
public void enumSerializeTest() {
    serialize.registerClass(1, TEnum.class, new TEnumSerializer());
    DataOutput out = serialize.getDataOutput(128);
    out.writeObjectNotNull(TEnum.TWO);
    out.writeObjectNotNull(TEnum.THREE);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    if (printStats)
        log.debug(bufferStats(b));
    assertEquals(TEnum.TWO, serialize.readObjectNotNull(b, TEnum.class));
    assertEquals(TEnum.THREE, serialize.readObjectNotNull(b, TEnum.class));
    assertFalse(b.hasRemaining());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test)

Example 30 with DataOutput

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

the class SerializerTest method classSerialization.

@Test
public void classSerialization() {
    DataOutput out = serialize.getDataOutput(128);
    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)

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