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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations