use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method findOrInsertCclJson.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long findOrInsertCclJson(String ccl, String json, AccessToken creds, TransactionToken transaction, String environment) throws TException {
List<Multimap<String, Object>> objects = Lists.newArrayList(Convert.jsonToJava(json));
AtomicSupport store = getStore(transaction, environment);
Set<Long> records = Sets.newLinkedHashSet();
AtomicOperations.executeWithRetry(store, (atomic) -> {
records.clear();
AbstractSyntaxTree ast;
if (objects.size() == 1) {
// CON-321: Support local resolution when the data blob is a
// single object
ast = compiler.parse(ccl, objects.get(0));
} else {
ast = compiler.parse(ccl);
}
Operations.findOrInsertAtomic(records, objects, ast, atomic);
});
if (records.size() == 1) {
return Iterables.getOnlyElement(records);
} else {
throw new DuplicateEntryException(AnyStrings.joinWithSpace("Found", records.size(), "records that match", ccl));
}
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method getCriteriaOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getCriteriaOrderPage(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<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.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method selectKeyCriteriaTimeOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Set<TObject>> selectKeyCriteriaTimeOrderPage(String key, TCriteria criteria, long timestamp, 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.selectKeyAstOptionalAtomic(atomic, key, ast, timestamp, Orders.from(order), Pages.from(page), supplier));
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method getCriteriaTimePage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getCriteriaTimePage(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<TObject>> supplier = () -> SortableTable.singleValued(new LinkedHashMap<>());
return Operations.getAstOptionalAtomic(store, ast, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method countKeyCriteria.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public long countKeyCriteria(String key, TCriteria criteria, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
return AtomicOperations.supplyWithRetry(store, (atomic) -> {
Set<Long> records = ast.accept(Finder.instance(), atomic);
return Operations.countKeyRecordsAtomic(key, records, Time.NONE, atomic);
});
}
Aggregations