use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class CriteriaTest method testTimestampPinningSomeTimestamps.
@Test
public void testTimestampPinningSomeTimestamps() {
Criteria criteria = Criteria.where().key("name").operator(Operator.EQUALS).value("Jeff Nelson").and().group(Criteria.where().key("company").operator(Operator.EQUALS).value("Cinchapi").at(Timestamp.now()).or().key("company").operator(Operator.EQUALS).value("Blavity")).build();
Timestamp timestamp = Timestamp.now();
criteria = criteria.at(timestamp);
List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
symbols.forEach((symbol) -> {
if (symbol instanceof ExpressionSymbol) {
ExpressionSymbol expression = (ExpressionSymbol) symbol;
Assert.assertEquals(expression.raw().timestamp(), timestamp.getMicros());
}
});
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class CriteriaTest method testTimestampPinning.
@Test
public void testTimestampPinning() {
Criteria criteria = Criteria.where().key("name").operator(Operator.EQUALS).value("Jeff Nelson").and().group(Criteria.where().key("company").operator(Operator.EQUALS).value("Cinchapi").or().key("company").operator(Operator.EQUALS).value("Blavity")).build();
Timestamp timestamp = Timestamp.now();
criteria = criteria.at(timestamp);
List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
symbols.forEach((symbol) -> {
if (symbol instanceof ExpressionSymbol) {
ExpressionSymbol expression = (ExpressionSymbol) symbol;
Assert.assertEquals(expression.raw().timestamp(), timestamp.getMicros());
}
});
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol 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;
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testParseCclValueWithoutQuotesAnd.
@Test
public void testParseCclValueWithoutQuotesAnd() {
String ccl = "name = jeff nelson and favorite_player != Lebron James";
Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
Assert.assertEquals(3, symbols.size());
for (int i = 0; i < 2; ++i) {
ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
Assert.assertTrue(expr.values().get(0).value().toString().contains(" "));
}
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testParseCclValueAndTimestampPhraseWithoutQuotesAnd.
@Test
public void testParseCclValueAndTimestampPhraseWithoutQuotesAnd() {
String ccl = "name = jeff nelson on last christmas day and favorite_player != Lebron James during last week";
Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
Assert.assertEquals(3, symbols.size());
for (int i = 0; i < 2; ++i) {
ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
Assert.assertTrue(expr.values().get(0).value().toString().contains(" "));
// this means a
Assert.assertNotEquals(0, expr.raw().timestamp());
// timestamp was
// parsed
}
}
Aggregations