use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method getKeyCclPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, TObject> getKeyCclPage(String key, String ccl, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
try {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
SortableColumn<TObject> result = SortableColumn.singleValued(key, Maps.newLinkedHashMap());
AtomicOperations.executeWithRetry(store, atomic -> Operations.getKeyAstAtomic(key, ast, Time.NONE, result, records -> Paging.paginate(records, Pages.from(page)), null, atomic));
return result;
} catch (Exception e) {
throw new ParseException(e.getMessage());
}
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method selectKeyCclOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Set<TObject>> selectKeyCclOrder(String key, String ccl, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
try {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
SortableColumn<Set<TObject>> result = SortableColumn.multiValued(key, Maps.newLinkedHashMap());
AtomicOperations.executeWithRetry(store, atomic -> Operations.selectKeyAstAtomic(key, ast, Time.NONE, result, null, $result -> $result.sort(Sorting.byValues(Orders.from(order), atomic)), atomic));
return result;
} catch (Exception e) {
throw new ParseException(e.getMessage());
}
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method getKeyCclTimeOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, TObject> getKeyCclTimeOrder(String key, String ccl, long timestamp, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
try {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
SortableColumn<TObject> result = SortableColumn.singleValued(key, Maps.newLinkedHashMap());
AtomicOperations.executeWithRetry(store, atomic -> Operations.getKeyAstAtomic(key, ast, timestamp, result, null, $result -> $result.sort(Sorting.byValue(Orders.from(order), atomic), timestamp), atomic));
return result;
} catch (Exception e) {
throw new ParseException(e.getMessage());
}
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class ConcourseServer method selectKeysCclTimeOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCclTimeOrder(List<String> keys, String ccl, long timestamp, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
try {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
SortableTable<Set<TObject>> result = emptySortableResultDataset();
AtomicOperations.executeWithRetry(store, atomic -> Operations.selectKeysAstAtomic(keys, ast, timestamp, result, null, $result -> $result.sort(Sorting.byValues(Orders.from(order), atomic), timestamp), atomic));
return result;
} catch (Exception e) {
throw new ParseException(e.getMessage());
}
}
use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.
the class Finder method visit.
@Override
public Set<Long> visit(ConjunctionTree tree, Object... data) {
if (tree.root() == ConjunctionSymbol.AND) {
Set<Long> a;
AbstractSyntaxTree bTree;
// if its result set is empty
if (!tree.left().isLeaf() && tree.right().isLeaf()) {
a = tree.right().accept(this, data);
bTree = tree.left();
} else {
a = tree.left().accept(this, data);
bTree = tree.right();
}
if (a.isEmpty()) {
// is done to the second branch
return Collections.emptySet();
} else {
Set<Long> b = bTree.accept(this, data);
Set<Long> results = TSets.intersection(a, b);
return results;
}
} else {
Set<Long> left = tree.left().accept(this, data);
Set<Long> right = tree.right().accept(this, data);
Set<Long> results = TSets.union(left, right);
return results;
}
}
Aggregations