use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class LargeDataFileDetectionLocalTest method main.
// NOTE: This is designed to be run locally in an IDE or the command line
// where the heap size can be set sufficiently large
public static void main(String... args) throws SegmentLoadingException {
String directory = FileOps.tempDir("test");
Segment segment = Segment.create();
Assert.assertTrue(FileSystem.ls(Paths.get(directory)).count() == 0);
String str = FileOps.read(Resources.getAbsolutePath("/long-string.txt"));
TObject value = Convert.javaToThrift(Tag.create(str));
int expected = 0;
while (segment.table().length() <= Integer.MAX_VALUE) {
System.out.println(segment.table().length());
segment.acquire(Write.add(Random.getSimpleString(), value, 1));
++expected;
}
System.out.println(segment.table().length() + " vs " + Integer.MAX_VALUE);
Path file = Paths.get(directory).resolve(UUID.randomUUID().toString());
segment.transfer(file);
System.out.println(file);
Assert.assertTrue(FileSystem.ls(Paths.get(directory)).count() > 0);
segment = Segment.load(file);
long actual = segment.writes().count();
System.out.println("Expected " + expected + " revisions and there are actually " + actual);
Assert.assertEquals(expected, actual);
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class WriteTest method testEqualsDiffType.
@Test
public void testEqualsDiffType() {
String key = TestData.getString();
TObject value = TestData.getTObject();
long record = TestData.getLong();
Assert.assertEquals(Write.add(key, value, record), Write.remove(key, value, record));
Assert.assertEquals(Write.add(key, value, record), Write.notStorable(key, value, record));
Assert.assertEquals(Write.remove(key, value, record), Write.notStorable(key, value, record));
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class WriteTest method testHashSameType.
@Test
public void testHashSameType() {
String key = TestData.getString();
TObject value = TestData.getTObject();
long record = TestData.getLong();
long version = CommitVersions.next();
Write w1 = Write.add(key, value, record).rewrite(version);
Write w2 = Write.add(key, value, record).rewrite(version);
Assert.assertEquals(w1.hash(), w2.hash());
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class LazyTrackingTObjectResultDataset method deserialize.
@Override
public void deserialize(Buffer buffer) {
while (buffer.hasRemaining()) {
long entity = buffer.readLong();
int entries = buffer.readInt();
for (int h = 0; h < entries; ++h) {
String attribute = buffer.readUTF8();
int values = buffer.readInt();
for (int i = 0; i < values; ++i) {
TObject value = deserializeValue(buffer);
insert(entity, attribute, value);
}
}
}
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class ObjectResultDataset method deserializeValue.
@Override
protected Object deserializeValue(Buffer buffer) {
Type type = Type.values()[buffer.readByte()];
int length = buffer.readInt();
byte[] data = new byte[length];
buffer.read(data);
TObject value = new TObject(ByteBuffer.wrap(data), type);
return Convert.thriftToJava(value);
}
Aggregations