Search in sources :

Example 46 with TObject

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

the class ConcourseServer method selectKeysCriteriaTimePage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCriteriaTimePage(List<String> keys, TCriteria criteria, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(criteria);
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
    return Operations.selectKeysAstOptionalAtomic(store, keys, ast, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 47 with TObject

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

the class ConcourseServer method findKeyOperatorValuesOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesOrderPage(String key, Operator operator, List<TObject> values, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    TObject[] tValues = values.toArray(Array.containing());
    AtomicSupport store = getStore(transaction, environment);
    return AtomicOperations.supplyWithRetry(store, atomic -> {
        SortableSet<Set<TObject>> records = SortableSet.of(Stores.find(atomic, key, operator, tValues));
        records.sort(Sorting.byValues(Orders.from(order), atomic));
        return Paging.page(records, Pages.from(page));
    });
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) SortableSet(com.cinchapi.concourse.data.sort.SortableSet) Set(java.util.Set) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 48 with TObject

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

the class ConcourseServer method selectKeyCriteriaOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Set<TObject>> selectKeyCriteriaOrderPage(String key, TCriteria criteria, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(criteria);
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableColumn<Set<TObject>>> supplier = () -> SortableColumn.multiValued(key, new LinkedHashMap<>());
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeyAstAtomic(atomic, key, ast, Orders.from(order), Pages.from(page), supplier));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) 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 49 with TObject

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

the class ConcourseServer method selectKeyCriteriaTimePage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Set<TObject>> selectKeyCriteriaTimePage(String key, TCriteria criteria, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(criteria);
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableColumn<Set<TObject>>> supplier = () -> SortableColumn.multiValued(key, new LinkedHashMap<>());
    return Operations.selectKeyAstOptionalAtomic(store, key, ast, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) 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 50 with TObject

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

the class ConcourseServer method diffKeyStartEnd.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<TObject, Map<Diff, Set<Long>>> diffKeyStartEnd(String key, long start, long end, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    AtomicReference<Map<TObject, Set<Long>>> startData = new AtomicReference<>(null);
    AtomicReference<Map<TObject, Set<Long>>> endData = new AtomicReference<>(null);
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        startData.set(store.browse(key, start));
        endData.set(store.browse(key, end));
    });
    Set<TObject> startValues = startData.get().keySet();
    Set<TObject> endValues = endData.get().keySet();
    Set<TObject> xor = Sets.symmetricDifference(startValues, endValues);
    Set<TObject> intersection = startValues.size() < endValues.size() ? Sets.intersection(startValues, endValues) : Sets.intersection(endValues, startValues);
    Map<TObject, Map<Diff, Set<Long>>> result = TMaps.newLinkedHashMapWithCapacity(xor.size() + intersection.size());
    for (TObject value : xor) {
        Map<Diff, Set<Long>> entry = Maps.newHashMapWithExpectedSize(1);
        if (!startValues.contains(value)) {
            entry.put(Diff.ADDED, endData.get().get(value));
        } else {
            entry.put(Diff.REMOVED, endData.get().get(value));
        }
        result.put(value, entry);
    }
    for (TObject value : intersection) {
        Set<Long> startRecords = startData.get().get(value);
        Set<Long> endRecords = endData.get().get(value);
        Set<Long> xorRecords = Sets.symmetricDifference(startRecords, endRecords);
        if (!xorRecords.isEmpty()) {
            Set<Long> added = Sets.newHashSetWithExpectedSize(xorRecords.size());
            Set<Long> removed = Sets.newHashSetWithExpectedSize(xorRecords.size());
            for (Long record : xorRecords) {
                if (!startRecords.contains(record)) {
                    added.add(record);
                } else {
                    removed.add(record);
                }
            }
            Map<Diff, Set<Long>> entry = Maps.newHashMapWithExpectedSize(2);
            if (!added.isEmpty()) {
                entry.put(Diff.ADDED, added);
            }
            if (!removed.isEmpty()) {
                entry.put(Diff.REMOVED, removed);
            }
            result.put(value, entry);
        }
    }
    return result;
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) SortableSet(com.cinchapi.concourse.data.sort.SortableSet) Set(java.util.Set) Diff(com.cinchapi.concourse.thrift.Diff) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) AtomicReference(java.util.concurrent.atomic.AtomicReference) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

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