Search in sources :

Example 71 with TObject

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();
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject)

Example 72 with TObject

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());
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) Test(org.junit.Test)

Example 73 with TObject

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());
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) Test(org.junit.Test)

Example 74 with TObject

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));
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) TestData(com.cinchapi.concourse.util.TestData) Test(org.junit.Test)

Example 75 with TObject

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));
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) Set(java.util.Set) TestData(com.cinchapi.concourse.util.TestData) Test(org.junit.Test)

Aggregations

TObject (com.cinchapi.concourse.thrift.TObject)242 Test (org.junit.Test)100 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)98 Set (java.util.Set)98 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)96 TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)91 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)91 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)88 Map (java.util.Map)76 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)72 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)71 Store (com.cinchapi.concourse.server.storage.Store)66 Order (com.cinchapi.concourse.lang.sort.Order)63 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)61 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)60 ByteBuffer (java.nio.ByteBuffer)60 Operator (com.cinchapi.concourse.thrift.Operator)59 Entry (java.util.Map.Entry)59 Convert (com.cinchapi.concourse.util.Convert)57 Sets (com.google.common.collect.Sets)57