use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class AddIndexOperation method run.
@Override
public void run() throws Exception {
Indexes indexes = mapContainer.getIndexes();
Index index = indexes.addOrGetIndex(attributeName, ordered);
final long now = getNow();
final Iterator<Record> iterator = recordStore.iterator(now, false);
SerializationService serializationService = getNodeEngine().getSerializationService();
while (iterator.hasNext()) {
final Record record = iterator.next();
Data key = record.getKey();
Object value = Records.getValueOrCachedValue(record, serializationService);
QueryableEntry queryEntry = mapContainer.newQueryEntry(key, value);
index.saveEntryIndex(queryEntry, null);
}
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class MapMigrationAwareService method migrateIndex.
private void migrateIndex(PartitionMigrationEvent event) {
final long now = getNow();
final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId());
for (RecordStore recordStore : container.getMaps().values()) {
final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());
final Indexes indexes = mapContainer.getIndexes();
if (!indexes.hasIndex()) {
continue;
}
final Iterator<Record> iterator = recordStore.iterator(now, false);
while (iterator.hasNext()) {
Record record = iterator.next();
Data key = record.getKey();
if (event.getMigrationEndpoint() == SOURCE) {
assert event.getNewReplicaIndex() != 0 : "Invalid migration event: " + event;
Object value = Records.getValueOrCachedValue(record, serializationService);
indexes.removeEntryIndex(key, value);
} else if (event.getNewReplicaIndex() == 0) {
Object value = Records.getValueOrCachedValue(record, serializationService);
if (value != null) {
QueryableEntry queryEntry = mapContainer.newQueryEntry(record.getKey(), value);
indexes.saveEntryIndex(queryEntry, null);
}
}
}
}
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class CallerRunsPartitionScanExecutorTest method execute_success.
@Test
public void execute_success() throws Exception {
PartitionScanRunner runner = mock(PartitionScanRunner.class);
CallerRunsPartitionScanExecutor executor = new CallerRunsPartitionScanExecutor(runner);
Predicate predicate = Predicates.equal("attribute", 1);
Collection<QueryableEntry> result = executor.execute("Map", predicate, asList(1, 2, 3));
assertEquals(0, result.size());
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class ParallelPartitionScanExecutorTest method execute_success.
@Test
public void execute_success() throws Exception {
PartitionScanRunner runner = mock(PartitionScanRunner.class);
ParallelPartitionScanExecutor executor = executor(runner);
Predicate predicate = Predicates.equal("attribute", 1);
List<QueryableEntry> result = executor.execute("Map", predicate, asList(1, 2, 3));
assertEquals(0, result.size());
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class QueryEventFilterTest method testEval_givenFilterContainsKey_whenKeyOfEntryIsEqualAndPredicacteIsMatching_thenReturnTrue.
@Test
public void testEval_givenFilterContainsKey_whenKeyOfEntryIsEqualAndPredicacteIsMatching_thenReturnTrue() {
//given
Data key1 = serializationService.toData("key1");
Predicate predicate = TruePredicate.INSTANCE;
QueryEventFilter filter = new QueryEventFilter(true, key1, predicate);
//when
Data key2 = serializationService.toData("key1");
QueryableEntry entry = mockEntryWithKeyData(key2);
//then
boolean result = filter.eval(entry);
assertTrue(result);
}
Aggregations