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);
}
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();
}
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();
}
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();
}
Aggregations