Search in sources :

Example 1 with Index

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);
    }
}
Also used : Index(com.hazelcast.query.impl.Index) Indexes(com.hazelcast.query.impl.Indexes)

Example 2 with Index

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;
}
Also used : Index(com.hazelcast.query.impl.Index) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) Predicate(com.hazelcast.query.Predicate)

Example 3 with Index

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;
}
Also used : Index(com.hazelcast.query.impl.Index) QueryContext(com.hazelcast.query.impl.QueryContext)

Example 4 with Index

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);
}
Also used : IndexImpl(com.hazelcast.query.impl.IndexImpl) Index(com.hazelcast.query.impl.Index) QueryContext(com.hazelcast.query.impl.QueryContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with Index

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);
    }
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Index(com.hazelcast.query.impl.Index) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Aggregations

Index (com.hazelcast.query.impl.Index)7 Indexes (com.hazelcast.query.impl.Indexes)2 QueryContext (com.hazelcast.query.impl.QueryContext)2 TypeConverter (com.hazelcast.core.TypeConverter)1 Record (com.hazelcast.map.impl.record.Record)1 Data (com.hazelcast.nio.serialization.Data)1 Predicate (com.hazelcast.query.Predicate)1 ComparisonType (com.hazelcast.query.impl.ComparisonType)1 FalsePredicate (com.hazelcast.query.impl.FalsePredicate)1 IndexImpl (com.hazelcast.query.impl.IndexImpl)1 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)1 SerializationService (com.hazelcast.spi.serialization.SerializationService)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1