use of com.cinchapi.concourse.server.aop.VerifyReadPermission 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));
}
use of com.cinchapi.concourse.server.aop.VerifyReadPermission in project concourse by cinchapi.
the class ConcourseServer method findCriteria.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCriteria(TCriteria criteria, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> ast.accept(Finder.instance(), $store);
try {
return function.apply(store);
} catch (InsufficientAtomicityException e) {
return AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
}
use of com.cinchapi.concourse.server.aop.VerifyReadPermission 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);
}
use of com.cinchapi.concourse.server.aop.VerifyReadPermission 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;
}
use of com.cinchapi.concourse.server.aop.VerifyReadPermission 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);
}
Aggregations