use of com.hazelcast.query.impl.Index in project hazelcast by hazelcast.
the class PostJoinMapOperation method addMapIndex.
public void addMapIndex(MapContainer mapContainer) {
final Indexes indexes = mapContainer.getIndexes();
if (indexes.hasIndex()) {
MapIndexInfo mapIndexInfo = new MapIndexInfo(mapContainer.getName());
for (Index index : indexes.getIndexes()) {
mapIndexInfo.addIndexInfo(index.getAttributeName(), index.isOrdered());
}
indexInfoList.add(mapIndexInfo);
}
}
use of com.hazelcast.query.impl.Index in project hazelcast by hazelcast.
the class BetweenVisitor method findCandidatesAndGroupByAttribute.
/**
* Find GreaterLessPredicates with equal flag set to true and group them by attribute name
*/
private InternalListMultiMap<String, GreaterLessPredicate> findCandidatesAndGroupByAttribute(Predicate[] predicates, Indexes indexService) {
InternalListMultiMap<String, GreaterLessPredicate> candidates = null;
for (Predicate predicate : predicates) {
if (!(predicate instanceof GreaterLessPredicate)) {
continue;
}
GreaterLessPredicate greaterLessPredicate = (GreaterLessPredicate) predicate;
if (!(greaterLessPredicate.equal)) {
continue;
}
String attributeName = greaterLessPredicate.attributeName;
Index index = indexService.getIndex(attributeName);
if (index == null || index.getConverter() == null) {
continue;
}
candidates = addIntoCandidates(greaterLessPredicate, candidates);
}
return candidates;
}
use of com.hazelcast.query.impl.Index in project hazelcast by hazelcast.
the class NotEqualPredicateTest method newMockContextWithIndex.
private QueryContext newMockContextWithIndex(String indexedFieldName) {
QueryContext queryContext = mock(QueryContext.class);
Index mockIndex = mock(Index.class);
when(queryContext.getIndex(indexedFieldName)).thenReturn(mockIndex);
return queryContext;
}
use of com.hazelcast.query.impl.Index in project hazelcast by hazelcast.
the class PredicatesTest method testNotEqualsPredicateDoesNotUseIndex.
@Test
public void testNotEqualsPredicateDoesNotUseIndex() {
Index dummyIndex = new IndexImpl("foo", false, ss, Extractors.empty());
QueryContext mockQueryContext = mock(QueryContext.class);
when(mockQueryContext.getIndex(anyString())).thenReturn(dummyIndex);
NotEqualPredicate p = new NotEqualPredicate("foo", "bar");
boolean indexed = p.isIndexed(mockQueryContext);
assertFalse(indexed);
}
use of com.hazelcast.query.impl.Index 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);
}
}
Aggregations