Search in sources :

Example 61 with TObject

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

the class ConcourseServer method selectKeyRecordsTimeOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Set<TObject>> selectKeyRecordsTimeOrderPage(String key, List<Long> records, long timestamp, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableColumn<Set<TObject>>> supplier = () -> SortableColumn.multiValued(key, new LinkedHashMap<>(records.size()));
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeyRecordsOptionalAtomic(atomic, key, records, timestamp, Orders.from(order), Pages.from(page), supplier));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableColumn(com.cinchapi.concourse.data.sort.SortableColumn) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 62 with TObject

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

the class TObjectResultDatasetTest method testInsert.

@Test
public void testInsert() {
    Map<String, Map<Object, Set<Long>>> expected = new HashMap<String, Map<Object, Set<Long>>>();
    int count = Random.getScaleCount();
    for (int i = 0; i < count; i++) {
        String key = Random.getString();
        Map<Object, Set<Long>> value = expected.get(key);
        if (value == null) {
            value = new HashMap<Object, Set<Long>>();
        }
        TObject subkey = Convert.javaToThrift(Random.getObject());
        Set<Long> subvalue = value.get(subkey);
        if (subvalue == null) {
            subvalue = new HashSet<Long>();
        }
        Long element = Random.getLong();
        subvalue.add(element);
        value.put(subkey, subvalue);
        expected.put(key, value);
        dataset.insert(element, key, subkey);
    }
    Assert.assertEquals(expected, dataset.invert());
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) TObject(com.cinchapi.concourse.thrift.TObject) Map(java.util.Map) HashMap(java.util.HashMap) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 63 with TObject

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

the class PluginSerializerTest method testSerializeTObject.

@Test
public void testSerializeTObject() {
    TObject expected = Convert.javaToThrift(Random.getObject());
    ByteBuffer buffer = serializer.serialize(expected);
    TObject actual = serializer.deserialize(buffer);
    Assert.assertEquals(expected, actual);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 64 with TObject

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

the class PluginSerializerTest method testSerializeComplexTObject.

@Test
public void testSerializeComplexTObject() {
    int count = Random.getScaleCount();
    List<TObject> list = Lists.newArrayListWithCapacity(count);
    for (int i = 0; i < count; ++i) {
        list.add(Convert.javaToThrift(Random.getObject()));
    }
    ComplexTObject expected = ComplexTObject.fromJavaObject(list);
    ByteBuffer buffer = serializer.serialize(expected);
    ComplexTObject actual = serializer.deserialize(buffer);
    Assert.assertEquals(expected, actual);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 65 with TObject

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

the class PluginSerializerTest method testSerializeDataset.

@Test
public void testSerializeDataset() {
    Dataset<Long, String, TObject> expected = new TObjectResultDataset();
    Set<Long> records = Sets.newLinkedHashSet();
    for (int i = 0; i < Random.getScaleCount(); ++i) {
        records.add(Random.getLong());
    }
    Set<String> keys = Sets.newLinkedHashSet();
    for (int i = 0; i < Math.min(Random.getScaleCount(), records.size()); ++i) {
        keys.add(Random.getSimpleString());
    }
    records.forEach((record) -> {
        keys.forEach((key) -> {
            expected.insert(record, key, Convert.javaToThrift(Random.getObject()));
        });
    });
    ByteBuffer buffer = serializer.serialize(expected);
    Dataset<Long, String, TObject> actual = serializer.deserialize(buffer);
    Assert.assertEquals(expected, actual);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) TObjectResultDataset(com.cinchapi.concourse.server.plugin.data.TObjectResultDataset) ByteBuffer(java.nio.ByteBuffer) 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