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