Search in sources :

Example 96 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class StoreTest method addRecords.

/**
 * Add {@code key} as a value that satisfies {@code operator} relative to
 * {@code min}.
 *
 * @param key
 * @param min
 * @param operator
 * @return the records added
 */
private Set<Long> addRecords(String key, Object min, Operator operator) {
    Set<Long> records = getRecords();
    int count = 0;
    for (long record : records) {
        Object n = null;
        while (n == null || (operator == Operator.GREATER_THAN && Objects.isLessThanOrEqualTo(n, min)) || (operator == Operator.GREATER_THAN_OR_EQUALS && Objects.isLessThan(n, min)) || (operator == Operator.LESS_THAN && Objects.isGreaterThanOrEqualTo(n, min)) || (operator == Operator.LESS_THAN_OR_EQUALS && Objects.isGreaterThan(n, min)) || (operator == Operator.NOT_EQUALS && Objects.isEqualTo(n, min)) || (operator == Operator.EQUALS && !Objects.isEqualTo(n, min))) {
            n = operator == Operator.EQUALS ? min : TestData.getObject();
        }
        TObject value = Convert.javaToThrift(n);
        add(key, value, record);
        Variables.register(operator + "_write_" + count, key + " AS " + value + " IN " + record);
        count++;
    }
    return records;
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) TObject(com.cinchapi.concourse.thrift.TObject)

Example 97 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class StoreTest method testFetchAfterAddMulti.

@Test
public void testFetchAfterAddMulti() {
    String key = TestData.getSimpleString();
    long record = TestData.getLong();
    Set<TObject> values = getValues();
    for (TObject value : values) {
        add(key, value, record);
    }
    Assert.assertEquals(values, store.select(key, record));
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 98 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class StoreTest method testBrowseRecordWithTime.

@Test
public void testBrowseRecordWithTime() {
    Multimap<String, TObject> data = Variables.register("data", HashMultimap.<String, TObject>create());
    long record = TestData.getLong();
    for (String key : getKeys()) {
        for (int i = 0; i < TestData.getScaleCount() % 4; i++) {
            TObject value = TestData.getTObject();
            if (!data.containsEntry(key, value)) {
                data.put(key, value);
                add(key, value, record);
            }
        }
    }
    long timestamp = Time.now();
    for (String key : getKeys()) {
        for (int i = 0; i < TestData.getScaleCount() % 4; i++) {
            TObject value = TestData.getTObject();
            if (!store.verify(key, value, record)) {
                add(key, value, record);
            }
        }
    }
    Assert.assertEquals(data.asMap(), store.select(record, timestamp));
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 99 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class StoreTest method testBrowseKey.

// TODO test audit
@Test
public void testBrowseKey() {
    Multimap<TObject, Long> data = Variables.register("data", TreeMultimap.<TObject, Long>create());
    String key = TestData.getSimpleString();
    for (TObject value : getValues()) {
        for (int i = 0; i < TestData.getScaleCount() % 4; i++) {
            long record = TestData.getLong();
            if (!data.containsEntry(value, record)) {
                data.put(value, record);
                add(key, value, record);
            }
        }
    }
    Assert.assertEquals(data.asMap(), store.browse(key));
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 100 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class StoreTest method testVerifyAfterAddAndRemove.

@Test
public void testVerifyAfterAddAndRemove() {
    String key = TestData.getSimpleString();
    TObject value = TestData.getTObject();
    long record = TestData.getLong();
    add(key, value, record);
    remove(key, value, record);
    Assert.assertFalse(store.verify(key, value, record));
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) 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