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")));
}
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());
}
Aggregations