Search in sources :

Example 6 with Symbol

use of com.cinchapi.ccl.grammar.Symbol 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 7 with Symbol

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

Example 8 with Symbol

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

the class ConcourseCompilerTest method testGroupSingleBetween.

@Test
public void testGroupSingleBetween() {
    String key = TestData.getString();
    Operator operator = Operator.BETWEEN;
    Object value = TestData.getObject();
    Object value1 = TestData.getObject();
    Criteria criteria = Criteria.where().key(key).operator(operator).value(value).value(value1).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);
    Assert.assertEquals(exp.values().get(1).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) Test(org.junit.Test)

Example 9 with Symbol

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

the class ConcourseCompilerTest method testGroupAnd.

@Test
public void testGroupAnd() {
    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).and().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.AND);
    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)

Example 10 with Symbol

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

the class ConcourseCompilerTest method testGroupSyntaxException.

@Test(expected = SyntaxException.class)
public void testGroupSyntaxException() {
    List<Symbol> symbols = Lists.<Symbol>newArrayList(new KeySymbol("foo"), new KeySymbol("bar"));
    Parsing.groupExpressions(symbols);
}
Also used : KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) 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) Test(org.junit.Test)

Aggregations

Symbol (com.cinchapi.ccl.grammar.Symbol)12 ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)11 ParenthesisSymbol (com.cinchapi.ccl.grammar.ParenthesisSymbol)9 KeySymbol (com.cinchapi.ccl.grammar.KeySymbol)8 Test (org.junit.Test)8 ConjunctionSymbol (com.cinchapi.ccl.grammar.ConjunctionSymbol)6 OperatorSymbol (com.cinchapi.ccl.grammar.OperatorSymbol)6 PostfixNotationSymbol (com.cinchapi.ccl.grammar.PostfixNotationSymbol)6 ValueSymbol (com.cinchapi.ccl.grammar.ValueSymbol)6 Operator (com.cinchapi.concourse.thrift.Operator)5 TimestampSymbol (com.cinchapi.ccl.grammar.TimestampSymbol)3 Timestamp (com.cinchapi.concourse.Timestamp)3 NavigationKeySymbol (com.cinchapi.ccl.grammar.NavigationKeySymbol)2 FunctionValueSymbol (com.cinchapi.ccl.grammar.FunctionValueSymbol)1 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)1 Function (com.cinchapi.ccl.type.Function)1 IndexFunction (com.cinchapi.ccl.type.function.IndexFunction)1 KeyConditionFunction (com.cinchapi.ccl.type.function.KeyConditionFunction)1 KeyRecordsFunction (com.cinchapi.ccl.type.function.KeyRecordsFunction)1 TemporalFunction (com.cinchapi.ccl.type.function.TemporalFunction)1