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