use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.
the class ConcourseServer method countKeyCclTime.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public long countKeyCclTime(String key, String ccl, long timestamp, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
return AtomicOperations.supplyWithRetry(store, (atomic) -> {
Set<Long> records = ast.accept(Finder.instance(), atomic);
return Operations.countKeyRecordsAtomic(key, records, timestamp, atomic);
});
}
use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.
the class ConcourseServer method addKeyValue.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long addKeyValue(String key, TObject value, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
return AtomicOperations.supplyWithRetry(store, (atomic) -> {
long record = Time.now();
Operations.addIfEmptyAtomic(key, value, record, atomic);
return record;
});
}
use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.
the class ConcourseServer method getCclOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getCclOrderPage(String ccl, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
Supplier<SortableTable<TObject>> supplier = () -> SortableTable.singleValued(new LinkedHashMap<>());
return AtomicOperations.supplyWithRetry(store, atomic -> Operations.getAstAtomic(atomic, ast, Orders.from(order), Pages.from(page), supplier));
}
use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.
the class ConcourseServer method insertJsonRecord.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public boolean insertJsonRecord(String json, long record, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
try {
Multimap<String, Object> data = Convert.jsonToJava(json);
AtomicOperation atomic = store.startAtomicOperation();
List<DeferredWrite> deferred = Lists.newArrayList();
return Operations.insertAtomic(data, record, atomic, deferred) && Operations.insertDeferredAtomic(deferred, atomic) && atomic.commit(CommitVersions.next());
} catch (TransactionStateException e) {
throw new TransactionException();
} catch (AtomicStateException e) {
return false;
}
}
use of com.cinchapi.concourse.server.storage.AtomicSupport 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));
}
Aggregations