Search in sources :

Example 6 with Match

use of com.apple.foundationdb.record.query.QueryToKeyMatcher.Match in project fdb-record-layer by FoundationDB.

the class QueryToKeyMatcherTest method testSingleFieldEquality.

@Test
public void testSingleFieldEquality() {
    final QueryToKeyMatcher matcher = new QueryToKeyMatcher(queryField("a").equalsValue(7));
    Match match = matcher.matchesSatisfyingQuery(keyField("a"));
    assertEquals(MatchType.EQUALITY, match.getType());
    assertEquals(Key.Evaluated.scalar(7), match.getEquality());
    match = matcher.matchesSatisfyingQuery(concatenateFields("a", "b"));
    assertEquals(MatchType.EQUALITY, match.getType());
    assertEquals(Key.Evaluated.scalar(7), match.getEquality());
    assertNoMatch(matcher.matchesSatisfyingQuery(keyField("b")));
    assertNoMatch(matcher.matchesSatisfyingQuery(keyField("a", FanType.FanOut)));
    assertNoMatch(matcher.matchesSatisfyingQuery(keyField("a", FanType.Concatenate)));
    assertNoMatch(matcher.matchesSatisfyingQuery(keyField("b").nest("a")));
    assertNoMatch(matcher.matchesSatisfyingQuery(keyField("a").nest("b")));
    assertNoMatch(matcher.matchesSatisfyingQuery(concatenateFields("b", "a")));
}
Also used : Match(com.apple.foundationdb.record.query.QueryToKeyMatcher.Match) Test(org.junit.jupiter.api.Test)

Example 7 with Match

use of com.apple.foundationdb.record.query.QueryToKeyMatcher.Match in project fdb-record-layer by FoundationDB.

the class QueryToKeyMatcherTest method testMatchWithQueryableExpression.

@Test
public void testMatchWithQueryableExpression() {
    final QueryableKeyExpression key = (QueryableKeyExpression) function("nada", concatenateFields("f1", "f2", "f3"));
    final QueryToKeyMatcher matcher = new QueryToKeyMatcher(Query.keyExpression(key).equalsValue("hello!"));
    Match match = matcher.matchesSatisfyingQuery(key);
    assertEquals(MatchType.EQUALITY, match.getType());
    assertEquals(Key.Evaluated.scalar("hello!"), match.getEquality());
}
Also used : QueryableKeyExpression(com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression) Match(com.apple.foundationdb.record.query.QueryToKeyMatcher.Match) Test(org.junit.jupiter.api.Test)

Aggregations

Match (com.apple.foundationdb.record.query.QueryToKeyMatcher.Match)7 Test (org.junit.jupiter.api.Test)7 QueryableKeyExpression (com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression)1