use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method sumKeyCclTime.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public TObject sumKeyCclTime(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);
Number sum = Operations.sumKeyRecordsAtomic(key, records, timestamp, atomic);
return Convert.javaToThrift(sum);
});
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method getCriteriaTimeOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getCriteriaTimeOrderPage(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<SortableTable<TObject>> supplier = () -> SortableTable.singleValued(new LinkedHashMap<>());
return AtomicOperations.supplyWithRetry(store, atomic -> Operations.getAstOptionalAtomic(atomic, ast, timestamp, Orders.from(order), Pages.from(page), supplier));
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class FinderTest method testOrConjunction.
@Test
public void testOrConjunction() {
Queue store = new Queue(16);
store.insert(Write.add("name", Convert.javaToThrift("jeff"), 1));
store.insert(Write.add("company", Convert.javaToThrift("Cinchapi"), 1));
store.insert(Write.add("age", Convert.javaToThrift(100), 1));
store.insert(Write.add("name", Convert.javaToThrift("jeff"), 2));
store.insert(Write.add("company", Convert.javaToThrift("Blavity"), 2));
store.insert(Write.add("age", Convert.javaToThrift(100), 2));
store.insert(Write.add("name", Convert.javaToThrift("ashleah"), 3));
store.insert(Write.add("company", Convert.javaToThrift("ARMN Inc."), 3));
store.insert(Write.add("age", Convert.javaToThrift(50), 3));
String ccl = "name = jeff or age < 75";
AbstractSyntaxTree ast = ConcourseCompiler.get().parse(ccl);
Finder visitor = Finder.instance();
Set<Long> result = ast.accept(visitor, store);
Assert.assertEquals(Sets.newHashSet(1L, 2L, 3L), result);
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree 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.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method selectKeysCclTimeOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCclTimeOrderPage(List<String> keys, String ccl, long timestamp, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeysAstOptionalAtomic(atomic, keys, ast, timestamp, Orders.from(order), Pages.from(page), supplier));
}
Aggregations