use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class QueryRunnerTest method verifyIndexedQueryFailureWhileMigratingInFlight.
@Test
public void verifyIndexedQueryFailureWhileMigratingInFlight() {
map.addIndex(IndexType.HASH, "this");
Predicate predicate = new EqualPredicate("this", value) {
@Override
public Set<QueryableEntry> filter(QueryContext queryContext) {
// start a new migration while executing an indexed query
mapService.beforeMigration(new PartitionMigrationEvent(MigrationEndpoint.SOURCE, partitionId, 0, 1, UUID.randomUUID()));
return super.filter(queryContext);
}
};
Query query = Query.of().mapName(map.getName()).predicate(predicate).iterationType(IterationType.ENTRY).partitionIdSet(SetUtil.allPartitionIds(instance.getPartitionService().getPartitions().size())).build();
QueryResult result = (QueryResult) queryRunner.runIndexOrPartitionScanQueryOnOwnedPartitions(query);
assertNull(result.getPartitionIds());
}
use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class LikePredicateTest method likePredicateIsNotIndexed_whenPercentWildcardIsEscaped.
@Test
public void likePredicateIsNotIndexed_whenPercentWildcardIsEscaped() {
QueryContext queryContext = mock(QueryContext.class);
when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.SORTED));
assertFalse(new LikePredicate("this", "sub\\%").isIndexed(queryContext));
assertFalse(new LikePredicate("this", "sub\\\\\\%").isIndexed(queryContext));
assertFalse(new LikePredicate("this", "sub\\%string\\%").isIndexed(queryContext));
assertFalse(new LikePredicate("this", "sub\\str\\%").isIndexed(queryContext));
}
use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class LikePredicateTest method likePredicateIsNotIndexed_whenUnderscoreWildcardIsUsed.
@Test
public void likePredicateIsNotIndexed_whenUnderscoreWildcardIsUsed() {
QueryContext queryContext = mock(QueryContext.class);
when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.SORTED));
assertFalse(new LikePredicate("this", "string_").isIndexed(queryContext));
}
Aggregations