use of com.cinchapi.concourse.data.sort.SortableSet in project concourse by cinchapi.
the class ConcourseServer method findCclOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCclOrder(String ccl, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
try {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
return AtomicOperations.supplyWithRetry(store, (atomic) -> {
SortableSet<Set<TObject>> records = SortableSet.of(ast.accept(Finder.instance(), atomic));
records.sort(Sorting.byValues(Orders.from(order), store));
return records;
});
} catch (Exception e) {
throw new ParseException(e.getMessage());
}
}
use of com.cinchapi.concourse.data.sort.SortableSet in project concourse by cinchapi.
the class ConcourseServer method findKeyOperatorValuesTimeOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesTimeOrder(String key, Operator operator, List<TObject> values, long timestamp, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
TObject[] tValues = values.toArray(Array.containing());
AtomicSupport store = getStore(transaction, environment);
Function<Store, SortableSet<Set<TObject>>> function = $store -> {
SortableSet<Set<TObject>> $records = SortableSet.of(Stores.find($store, timestamp, key, operator, tValues));
// NOTE: The #timestamp is not considered when sorting because it is
// a component of criteria evaluation and no data is being selected.
$records.sort(Sorting.byValues(Orders.from(order), store));
return $records;
};
SortableSet<Set<TObject>> records = null;
boolean isAtomic = order != NO_ORDER;
while (records == null) {
try {
if (isAtomic) {
records = AtomicOperations.<SortableSet<Set<TObject>>>supplyWithRetry(store, atomic -> function.apply(atomic));
} else {
records = function.apply(store);
}
} catch (InsufficientAtomicityException e) {
isAtomic = true;
}
}
return records;
}
use of com.cinchapi.concourse.data.sort.SortableSet in project concourse by cinchapi.
the class ConcourseServer method findCriteriaOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCriteriaOrder(TCriteria criteria, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
return AtomicOperations.supplyWithRetry(store, (atomic) -> {
SortableSet<Set<TObject>> records = SortableSet.of(ast.accept(Finder.instance(), atomic));
records.sort(Sorting.byValues(Orders.from(order), store));
return records;
});
}
use of com.cinchapi.concourse.data.sort.SortableSet 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.data.sort.SortableSet in project concourse by cinchapi.
the class ConcourseServer method findCclOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCclOrderPage(String ccl, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
return AtomicOperations.supplyWithRetry(store, atomic -> {
SortableSet<Set<TObject>> records = SortableSet.of(ast.accept(Finder.instance(), atomic));
records.sort(Sorting.byValues(Orders.from(order), store));
return Paging.page(records, Pages.from(page));
});
}
Aggregations