Search in sources :

Example 1 with TimestampSymbol

use of com.cinchapi.ccl.grammar.TimestampSymbol 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)

Aggregations

ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)1 ParenthesisSymbol (com.cinchapi.ccl.grammar.ParenthesisSymbol)1 Symbol (com.cinchapi.ccl.grammar.Symbol)1 TimestampSymbol (com.cinchapi.ccl.grammar.TimestampSymbol)1 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)1