Search in sources :

Example 41 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions 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 42 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method addKeyValueRecords.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public Map<Long, Boolean> addKeyValueRecords(String key, TObject value, List<Long> records, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    Map<Long, Boolean> result = Maps.newLinkedHashMap();
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        for (long record : records) {
            result.put(record, atomic.add(key, value, record));
        }
    });
    return result;
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 43 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions 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)

Example 44 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method selectKeysRecordsTimePage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysRecordsTimePage(List<String> keys, List<Long> records, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
    return Operations.selectKeysRecordsOptionalAtomic(store, keys, records, timestamp, Orders.from(NO_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) 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 45 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method getKeyRecordsTimePage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, TObject> getKeyRecordsTimePage(String key, List<Long> records, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableColumn<TObject>> supplier = () -> SortableColumn.singleValued(key, new LinkedHashMap<>(records.size()));
    return Operations.getKeyRecordsOptionalAtomic(store, key, records, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
Also used : 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)

Aggregations

TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)180 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)180 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)179 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)157 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)120 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)96 TObject (com.cinchapi.concourse.thrift.TObject)96 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)87 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)76 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)73 Set (java.util.Set)73 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)72 Map (java.util.Map)58 NonBlockingHashMap (org.cliffc.high_scale_lib.NonBlockingHashMap)58 AtomicStateException (com.cinchapi.concourse.server.storage.AtomicStateException)57 TransactionStateException (com.cinchapi.concourse.server.storage.TransactionStateException)57 Diff (com.cinchapi.concourse.thrift.Diff)57 TransactionException (com.cinchapi.concourse.thrift.TransactionException)57 AtomicReference (java.util.concurrent.atomic.AtomicReference)57 AtomicOperation (com.cinchapi.concourse.server.storage.AtomicOperation)56