use of com.cinchapi.concourse.server.ops.InsufficientAtomicityException 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.server.ops.InsufficientAtomicityException 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.ops.InsufficientAtomicityException in project concourse by cinchapi.
the class ConcourseServer method selectKeyRecord.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<TObject> selectKeyRecord(String key, long record, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<TObject>> function = $store -> Stores.select($store, key, record);
try {
return function.apply(store);
} catch (InsufficientAtomicityException e) {
return AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
}
use of com.cinchapi.concourse.server.ops.InsufficientAtomicityException in project concourse by cinchapi.
the class ConcourseServer method findCcl.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCcl(String ccl, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
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.ops.InsufficientAtomicityException in project concourse by cinchapi.
the class ConcourseServer method findKeyOperatorValuesPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesPage(String key, Operator operator, List<TObject> values, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
TObject[] tValues = values.toArray(Array.containing());
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> Stores.find($store, key, operator, tValues);
Set<Long> records;
try {
records = function.apply(store);
} catch (InsufficientAtomicityException e) {
records = AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
return Paging.page(records, Pages.from(page));
}
Aggregations