Search in sources :

Example 6 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)

Example 7 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)

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