use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class WriteEvent method deserialize.
@Override
public void deserialize(Buffer buffer) {
key = buffer.readUTF8();
com.cinchapi.concourse.thrift.Type ttype = com.cinchapi.concourse.thrift.Type.values()[buffer.readByte()];
byte[] valueData = new byte[buffer.readInt()];
buffer.read(valueData);
value = new TObject(ByteBuffer.wrap(valueData), ttype);
record = buffer.readLong();
type = Type.values()[buffer.readByte()];
timestamp = buffer.readLong();
environment = buffer.readUTF8();
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class AtomicOperationTest method testNoDeadlockIfAddToKeyAsValueBeforeFindingEqKeyAndValue.
@Test
public void testNoDeadlockIfAddToKeyAsValueBeforeFindingEqKeyAndValue() {
long record = TestData.getLong();
String key = "foo";
TObject value = Convert.javaToThrift("bar");
add(key, value, record);
store.find(key, Operator.EQUALS, value);
Assert.assertTrue(((AtomicOperation) store).commit());
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class AtomicOperationTest method testNoDeadLockIfFindEqOnKeyBeforeAddingToKey.
@Test
public void testNoDeadLockIfFindEqOnKeyBeforeAddingToKey() {
String key = "ipeds_id";
TObject value = Convert.javaToThrift(1);
long record = Time.now();
AtomicOperation operation = (AtomicOperation) store;
operation.find(key, Operator.EQUALS, value);
operation.add(key, value, record);
Assert.assertTrue(operation.commit());
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class BufferedStoreTest method testFetchBuffered.
@Test
public void testFetchBuffered() {
List<Data> data = generateTestData();
insertData(data);
Data d = Variables.register("d", data.get(TestData.getScaleCount() % data.size()));
Set<TObject> values = Sets.newHashSet();
Iterator<Data> it = data.iterator();
while (it.hasNext()) {
Data _d = it.next();
if (_d.record == d.record && _d.key.equals(d.key)) {
if (_d.type == Action.ADD) {
Assert.assertTrue(values.add(_d.value));
} else {
Assert.assertTrue(values.remove(_d.value));
}
}
}
Assert.assertEquals(values, store.select(d.key, d.record));
}
use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.
the class BufferedStoreTest method testDescribeBuffered.
@Test
public void testDescribeBuffered() {
List<Data> data = generateTestData();
insertData(data);
Data d = data.get(TestData.getScaleCount() % data.size());
Map<String, Set<TObject>> ktv = Maps.newHashMap();
Iterator<Data> it = data.iterator();
while (it.hasNext()) {
Data _d = it.next();
if (_d.record == d.record) {
Set<TObject> values = ktv.get(_d.key);
if (values == null) {
values = Sets.newHashSet();
ktv.put(_d.key, values);
}
if (_d.type == Action.ADD) {
Assert.assertTrue(values.add(_d.value));
} else {
Assert.assertTrue(values.remove(_d.value));
}
}
}
Set<String> keys = Sets.newHashSet();
Iterator<String> it2 = ktv.keySet().iterator();
while (it2.hasNext()) {
String key = it2.next();
if (!ktv.get(key).isEmpty()) {
keys.add(key);
}
}
Assert.assertEquals(keys, store.describe(d.record));
}
Aggregations