Search in sources :

Example 21 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class BuiltCriteria method at.

/**
 * Return this {@link Criteria} with each expression (e.g. {key} {operator}
 * {values}) pinned to the specified {@code timestamp}.
 *
 * <strong>NOTE:</strong> Any timestamps that are pinned to any expressions
 * within this Criteria will be replaced by the specified {@code timestamp}.
 *
 * @param timestamp the {@link Timestamp} to which the returned
 *            {@link Criteria} is pinned
 *
 * @return this {@link Criteria} pinned to {@code timestamp}
 */
public Criteria at(Timestamp timestamp) {
    AbstractSyntaxTree ast = ConcourseCompiler.get().parse(ccl());
    List<Symbol> symbols = Parsing.groupExpressions(ConcourseCompiler.get().tokenize(ast));
    TimestampSymbol ts = new TimestampSymbol(timestamp.getMicros());
    symbols.forEach((symbol) -> {
        if (symbol instanceof ExpressionSymbol) {
            ExpressionSymbol expression = (ExpressionSymbol) symbol;
            expression.timestamp(ts);
        }
    });
    BuiltCriteria criteria = new BuiltCriteria();
    symbols = Parsing.ungroupExpressions(symbols);
    criteria.symbols = symbols;
    return criteria;
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) TimestampSymbol(com.cinchapi.ccl.grammar.TimestampSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) TimestampSymbol(com.cinchapi.ccl.grammar.TimestampSymbol)

Example 22 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method selectKeysCriteriaTimePage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCriteriaTimePage(List<String> keys, 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<Set<TObject>>> supplier = () -> emptySortableResultDataset();
    return Operations.selectKeysAstOptionalAtomic(store, keys, ast, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 23 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method averageKeyCcl.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public TObject averageKeyCcl(String key, String ccl, 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 average = Operations.avgKeyRecordsAtomic(key, records, Time.NONE, atomic);
        return Convert.javaToThrift(average);
    });
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 24 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree 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);
    });
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 25 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree 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));
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Aggregations

AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)113 TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)104 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)104 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)104 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)102 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)62 TObject (com.cinchapi.concourse.thrift.TObject)57 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)56 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)50 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)42 Set (java.util.Set)42 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)40 InsufficientAtomicityException (com.cinchapi.concourse.server.ops.InsufficientAtomicityException)39 NaturalLanguage (com.cinchapi.ccl.util.NaturalLanguage)38 AnyStrings (com.cinchapi.common.base.AnyStrings)38 Array (com.cinchapi.common.base.Array)38 CheckedExceptions (com.cinchapi.common.base.CheckedExceptions)38 Reflection (com.cinchapi.common.reflect.Reflection)38 Constants (com.cinchapi.concourse.Constants)38 Link (com.cinchapi.concourse.Link)38