use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.
the class DefaultQueryCache method addIndex.
@Override
public void addIndex(IndexConfig config) {
checkNotNull(config, "Index config cannot be null.");
assert indexes.isGlobal();
IndexConfig config0 = getNormalizedIndexConfig(config);
indexes.addOrGetIndex(config0);
InternalSerializationService serializationService = context.getSerializationService();
CachedQueryEntry<?, ?> newEntry = new CachedQueryEntry<>(serializationService, extractors);
Set<Map.Entry<Object, QueryCacheRecord>> entries = recordStore.entrySet();
for (Map.Entry<Object, QueryCacheRecord> entry : entries) {
Object queryCacheKey = entry.getKey();
QueryCacheRecord record = entry.getValue();
Object value = record.getValue();
Data keyData = toData(queryCacheKey);
QueryEntry queryable = new QueryEntry(serializationService, keyData, value, extractors);
newEntry.init(keyData, value);
indexes.putEntry(newEntry, null, queryable, Index.OperationSource.USER);
}
}
use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method canPassFilter.
private boolean canPassFilter(LocalEntryEventData localEntryEventData, EventFilter filter) {
if (filter == null || filter instanceof TrueEventFilter) {
return true;
}
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
SerializationService serializationService = nodeEngine.getSerializationService();
Data keyData = localEntryEventData.getKeyData();
Object value = getValueOrOldValue(localEntryEventData);
QueryableEntry entry = new QueryEntry((InternalSerializationService) serializationService, keyData, value, Extractors.empty());
return filter.eval(entry);
}
use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.
the class DefaultQueryCache method addIndex.
@Override
public void addIndex(String attribute, boolean ordered) {
getIndexes().addOrGetIndex(attribute, ordered);
InternalSerializationService serializationService = context.getSerializationService();
Set<Map.Entry<Data, QueryCacheRecord>> entries = recordStore.entrySet();
for (Map.Entry<Data, QueryCacheRecord> entry : entries) {
Data keyData = entry.getKey();
QueryCacheRecord record = entry.getValue();
Object value = record.getValue();
QueryEntry queryable = new QueryEntry(serializationService, keyData, value, Extractors.empty());
indexes.saveEntryIndex(queryable, null);
}
}
use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.
the class DefaultQueryCacheRecordStore method saveIndex.
private void saveIndex(Data keyData, QueryCacheRecord currentRecord, QueryCacheRecord oldRecord) {
if (indexes.hasIndex()) {
Object currentValue = currentRecord.getValue();
QueryEntry queryEntry = new QueryEntry(serializationService, keyData, currentValue, Extractors.empty());
Object oldValue = oldRecord == null ? null : oldRecord.getValue();
indexes.saveEntryIndex(queryEntry, oldValue);
}
}
use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.
the class ClientPagingPredicateTest method pagingPredicateWithEmployeeObjectTest.
private List<Employee> pagingPredicateWithEmployeeObjectTest(IMap<Integer, Employee> map, Predicate<Integer, Employee> predicate, int pageSize) {
PagingPredicate<Integer, Employee> pagingPredicate = new PagingPredicate<Integer, Employee>(predicate, pageSize);
Set<Map.Entry<Integer, Employee>> set;
List<Employee> results = new ArrayList<Employee>();
do {
set = map.entrySet(pagingPredicate);
for (Map.Entry<Integer, Employee> entry : set) {
Employee e = entry.getValue();
QueryEntry qe = new QueryEntry((InternalSerializationService) serializationService, serializationService.toData(e.getId()), e, Extractors.empty());
assertTrue(predicate.apply(qe));
results.add(e);
}
pagingPredicate.nextPage();
} while (!set.isEmpty());
return results;
}
Aggregations