Search in sources :

Example 21 with DataOutput

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

the class ManagementLogger method sendCacheEviction.

public void sendCacheEviction(Set<TitanSchemaVertex> updatedTypes, Set<Callable<Boolean>> updatedTypeTriggers, Set<String> openInstances) {
    Preconditions.checkArgument(!openInstances.isEmpty());
    long evictionId = evictionTriggerCounter.incrementAndGet();
    evictionTriggerMap.put(evictionId, new EvictionTrigger(evictionId, updatedTypeTriggers, openInstances));
    DataOutput out = graph.getDataSerializer().getDataOutput(128);
    out.writeObjectNotNull(MgmtLogType.CACHED_TYPE_EVICTION);
    VariableLong.writePositive(out, evictionId);
    VariableLong.writePositive(out, updatedTypes.size());
    for (TitanSchemaVertex type : updatedTypes) {
        assert type.hasId();
        VariableLong.writePositive(out, type.longId());
    }
    sysLog.add(out.getStaticBuffer());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) TitanSchemaVertex(com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex)

Example 22 with DataOutput

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

the class ParameterSerializer method write.

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

Example 23 with DataOutput

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

the class StandardTransactionIdSerializer method write.

@Override
public void write(WriteBuffer buffer, StandardTransactionId attribute) {
    DataOutput out = (DataOutput) buffer;
    out.writeObjectNotNull(attribute.getInstanceId());
    out.writeObjectNotNull(attribute.getTransactionId());
    out.writeObjectNotNull(attribute.getTransactionTime());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)

Example 24 with DataOutput

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

the class IndexSerializer method getIndexKey.

private final StaticBuffer getIndexKey(CompositeIndexType index, Object[] values) {
    DataOutput out = serializer.getDataOutput(8 * DEFAULT_OBJECT_BYTELEN + 8);
    VariableLong.writePositive(out, index.getID());
    IndexField[] fields = index.getFieldKeys();
    Preconditions.checkArgument(fields.length > 0 && fields.length == values.length);
    for (int i = 0; i < fields.length; i++) {
        IndexField f = fields[i];
        Object value = values[i];
        Preconditions.checkNotNull(value);
        if (AttributeUtil.hasGenericDataType(f.getFieldKey())) {
            out.writeClassAndObject(value);
        } else {
            assert value.getClass().equals(f.getFieldKey().dataType()) : value.getClass() + " - " + f.getFieldKey().dataType();
            out.writeObjectNotNull(value);
        }
    }
    StaticBuffer key = out.getStaticBuffer();
    if (hashKeys)
        key = HashingUtil.hashPrefixKey(hashLength, key);
    return key;
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)

Example 25 with DataOutput

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

the class IndexSerializer method getIndexEntry.

private final Entry getIndexEntry(CompositeIndexType index, RecordEntry[] record, TitanElement element) {
    DataOutput out = serializer.getDataOutput(1 + 8 + 8 * record.length + 4 * 8);
    out.putByte(FIRST_INDEX_COLUMN_BYTE);
    if (index.getCardinality() != Cardinality.SINGLE) {
        VariableLong.writePositive(out, element.longId());
        if (index.getCardinality() != Cardinality.SET) {
            for (RecordEntry re : record) {
                VariableLong.writePositive(out, re.relationId);
            }
        }
    }
    int valuePosition = out.getPosition();
    if (element instanceof TitanVertex) {
        VariableLong.writePositive(out, element.longId());
    } else {
        assert element instanceof TitanRelation;
        RelationIdentifier rid = (RelationIdentifier) element.id();
        long[] longs = rid.getLongRepresentation();
        Preconditions.checkArgument(longs.length == 3 || longs.length == 4);
        for (int i = 0; i < longs.length; i++) VariableLong.writePositive(out, longs[i]);
    }
    return new StaticArrayEntry(out.getStaticBuffer(), valuePosition);
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) RelationIdentifier(com.thinkaurelius.titan.graphdb.relations.RelationIdentifier) StaticArrayEntry(com.thinkaurelius.titan.diskstorage.util.StaticArrayEntry)

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