Search in sources :

Example 6 with ExpressionSymbol

use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testReproGH_113.

@Test
public void testReproGH_113() {
    String ccl = "location = \"Atlanta (HQ)\"";
    Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
    Assert.assertEquals(1, symbols.size());
    ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
    Assert.assertEquals("Atlanta (HQ)", expr.raw().values().get(0));
}
Also used : PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 7 with ExpressionSymbol

use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testParseCclValueAndTimestampPhraseWithoutQuotes.

@Test
public void testParseCclValueAndTimestampPhraseWithoutQuotes() {
    String ccl = "name = jeff nelson on last christmas day";
    Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
    ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
    Assert.assertEquals("jeff nelson", expr.values().get(0).value());
    // this means a
    Assert.assertNotEquals(0, expr.raw().timestamp());
// timestamp was
// parsed
}
Also used : PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 8 with ExpressionSymbol

use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testGroupSingle.

@Test
public void testGroupSingle() {
    String key = TestData.getString();
    Operator operator = Operator.EQUALS;
    Object value = TestData.getObject();
    Criteria criteria = Criteria.where().key(key).operator(operator).value(value).build();
    List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
    ExpressionSymbol exp = (ExpressionSymbol) symbols.get(0);
    Assert.assertEquals(1, symbols.size());
    Assert.assertEquals(exp.raw().key(), key);
    Assert.assertEquals(exp.raw().operator(), operator);
    Assert.assertEquals(exp.values().get(0).value(), value);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 9 with ExpressionSymbol

use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testGroupSub.

@Test
public void testGroupSub() {
    String key0 = TestData.getString();
    Operator operator0 = Operator.EQUALS;
    Object value0 = TestData.getObject();
    String key1 = TestData.getString();
    Operator operator1 = Operator.GREATER_THAN;
    Object value1 = TestData.getObject();
    String key2 = TestData.getString();
    Operator operator2 = Operator.LESS_THAN;
    Object value2 = TestData.getObject();
    Criteria criteria = Criteria.where().key(key0).operator(operator0).value(value0).and().group(Criteria.where().key(key1).operator(operator1).value(value1).or().key(key2).operator(operator2).value(value2).build()).build();
    List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
    ExpressionSymbol exp0 = (ExpressionSymbol) symbols.get(0);
    ConjunctionSymbol sym1 = (ConjunctionSymbol) symbols.get(1);
    ParenthesisSymbol sym2 = (ParenthesisSymbol) symbols.get(2);
    ExpressionSymbol exp3 = (ExpressionSymbol) symbols.get(3);
    ConjunctionSymbol sym4 = (ConjunctionSymbol) symbols.get(4);
    ExpressionSymbol exp5 = (ExpressionSymbol) symbols.get(5);
    ParenthesisSymbol sym6 = (ParenthesisSymbol) symbols.get(6);
    Assert.assertEquals(7, symbols.size());
    Assert.assertEquals(exp0.raw().key(), key0);
    Assert.assertEquals(exp0.raw().operator(), operator0);
    Assert.assertEquals(exp0.values().get(0).value(), value0);
    Assert.assertEquals(ConjunctionSymbol.AND, sym1);
    Assert.assertEquals(ParenthesisSymbol.LEFT, sym2);
    Assert.assertEquals(exp3.raw().key(), key1);
    Assert.assertEquals(exp3.raw().operator(), operator1);
    Assert.assertEquals(exp3.values().get(0).value(), value1);
    Assert.assertEquals(ConjunctionSymbol.OR, sym4);
    Assert.assertEquals(exp5.raw().key(), key2);
    Assert.assertEquals(exp5.raw().operator(), operator2);
    Assert.assertEquals(exp5.values().get(0).value(), value2);
    Assert.assertEquals(ParenthesisSymbol.RIGHT, sym6);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) Test(org.junit.Test)

Example 10 with ExpressionSymbol

use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testGroupOr.

@Test
public void testGroupOr() {
    String key0 = TestData.getString();
    Operator operator0 = Operator.EQUALS;
    Object value0 = TestData.getObject();
    String key1 = TestData.getString();
    Operator operator1 = Operator.GREATER_THAN;
    Object value1 = TestData.getObject();
    Criteria criteria = Criteria.where().key(key0).operator(operator0).value(value0).or().key(key1).operator(operator1).value(value1).build();
    List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
    ExpressionSymbol exp0 = (ExpressionSymbol) symbols.get(0);
    ConjunctionSymbol sym = (ConjunctionSymbol) symbols.get(1);
    ExpressionSymbol exp1 = (ExpressionSymbol) symbols.get(2);
    Assert.assertEquals(3, symbols.size());
    Assert.assertEquals(exp0.raw().key(), key0);
    Assert.assertEquals(exp0.raw().operator(), operator0);
    Assert.assertEquals(exp0.values().get(0).value(), value0);
    Assert.assertEquals(sym, ConjunctionSymbol.OR);
    Assert.assertEquals(exp1.raw().key(), key1);
    Assert.assertEquals(exp1.raw().operator(), operator1);
    Assert.assertEquals(exp1.values().get(0).value(), value1);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) Test(org.junit.Test)

Aggregations

ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)21 Test (org.junit.Test)19 PostfixNotationSymbol (com.cinchapi.ccl.grammar.PostfixNotationSymbol)17 KeySymbol (com.cinchapi.ccl.grammar.KeySymbol)9 Symbol (com.cinchapi.ccl.grammar.Symbol)8 OperatorSymbol (com.cinchapi.ccl.grammar.OperatorSymbol)7 ValueSymbol (com.cinchapi.ccl.grammar.ValueSymbol)7 ParenthesisSymbol (com.cinchapi.ccl.grammar.ParenthesisSymbol)6 Operator (com.cinchapi.concourse.thrift.Operator)6 ConjunctionSymbol (com.cinchapi.ccl.grammar.ConjunctionSymbol)5 NavigationKeySymbol (com.cinchapi.ccl.grammar.NavigationKeySymbol)2 Timestamp (com.cinchapi.concourse.Timestamp)2 TimestampSymbol (com.cinchapi.ccl.grammar.TimestampSymbol)1 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)1 Store (com.cinchapi.concourse.server.storage.Store)1 TObject (com.cinchapi.concourse.thrift.TObject)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1