in modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItCriteriaQueryTest.java [253:392]
public <T> void testKeyValueView(CriteriaQuerySource<T> view, Function<T, Entry<Tuple, Tuple>> mapper) {
Matcher<Tuple> personKey0 = tupleValue("id", is(0));
Matcher<Tuple> person0 = allOf(tupleValue("name", Matchers.nullValue()), tupleValue("salary", is(0.0d)),
tupleValue("hash", is("hash0".getBytes())));
Matcher<Tuple> personKey1 = tupleValue("id", is(1));
Matcher<Tuple> person1 = allOf(tupleValue("name", is("name1")), tupleValue("salary", is(10.0d)),
tupleValue("hash", is("hash1".getBytes())));
Matcher<Tuple> personKey2 = tupleValue("id", is(2));
Matcher<Tuple> person2 = allOf(tupleValue("name", is("name2")), tupleValue("salary", is(20.0d)),
tupleValue("hash", is("hash2".getBytes())));
try (Cursor<T> cur = view.query(null, null)) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(3),
hasEntry(personKey0, person0),
hasEntry(personKey1, person1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", equalTo(2)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("hash", equalTo("hash2".getBytes())))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", notEqualTo(2)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey0, person0),
hasEntry(personKey1, person1)
));
}
try (Cursor<T> cur = view.query(null, columnValue("hash", notEqualTo("hash2".getBytes())))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey0, person0),
hasEntry(personKey1, person1)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", greaterThan(1)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", greaterThanOrEqualTo(1)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey1, person1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", lessThan(1)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey0, person0)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", lessThanOrEqualTo(1)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey0, person0),
hasEntry(personKey1, person1)
));
}
try (Cursor<T> cur = view.query(null, columnValue("name", nullValue()))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey0, person0)
));
}
try (Cursor<T> cur = view.query(null, columnValue("name", notNullValue()))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey1, person1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", in(1, 2)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey1, person1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("id", notIn(1, 2)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey0, person0)
));
}
try (Cursor<T> cur = view.query(null, columnValue("hash", in("hash1".getBytes(), "hash2".getBytes())))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(2),
hasEntry(personKey1, person1),
hasEntry(personKey2, person2)
));
}
try (Cursor<T> cur = view.query(null, columnValue("hash", in((byte[]) null)))) {
assertThat(mapToTupleMap(cur, mapper), anEmptyMap());
}
try (Cursor<T> cur = view.query(null, columnValue("hash", notIn("hash1".getBytes(), "hash2".getBytes())))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(1),
hasEntry(personKey0, person0)
));
}
try (Cursor<T> cur = view.query(null, columnValue("hash", notIn((byte[]) null)))) {
assertThat(mapToTupleMap(cur, mapper), allOf(
aMapWithSize(3),
hasEntry(personKey0, person0),
hasEntry(personKey1, person1),
hasEntry(personKey2, person2)
));
}
}