Search in sources :

Example 21 with InternalIndex

use of com.hazelcast.query.impl.InternalIndex in project hazelcast by hazelcast.

the class AttributeCanonicalizationTest method checkIndex.

private void checkIndex(Indexes indexes, IndexType indexType, String[] attributes, String[] expAttributes) {
    IndexConfig config = new IndexConfig().setType(indexType);
    for (String attribute : attributes) {
        config.addAttribute(attribute);
    }
    IndexConfig normalizedConfig = IndexUtils.validateAndNormalize("map", config);
    StringBuilder expName = new StringBuilder("map");
    if (indexType == IndexType.SORTED) {
        expName.append("_sorted");
    } else {
        expName.append("_hash");
    }
    for (int i = 0; i < expAttributes.length; i++) {
        String expAttribute = expAttributes[i];
        String attribute = normalizedConfig.getAttributes().get(i);
        assertEquals(expAttribute, attribute);
        expName.append("_").append(expAttribute);
    }
    assertEquals(expName.toString(), normalizedConfig.getName());
    InternalIndex index = indexes.addOrGetIndex(normalizedConfig);
    assertEquals(normalizedConfig.getName(), index.getName());
    assertNotNull(indexes.getIndex(normalizedConfig.getName()));
}
Also used : InternalIndex(com.hazelcast.query.impl.InternalIndex) IndexConfig(com.hazelcast.config.IndexConfig)

Example 22 with InternalIndex

use of com.hazelcast.query.impl.InternalIndex in project hazelcast by hazelcast.

the class IndexCreateTest method checkIndex.

private void checkIndex(IndexConfig... indexConfigs) {
    List<HazelcastInstanceProxy> members = handler.initialize(hazelcastFactory, indexConfigs);
    for (HazelcastInstanceProxy member : members) {
        MapService service = member.getOriginal().node.nodeEngine.getService(MapService.SERVICE_NAME);
        MapServiceContext mapServiceContext = service.getMapServiceContext();
        MapContainer mapContainer = mapServiceContext.getMapContainer(MAP_NAME);
        Indexes indexes = mapContainer.getIndexes();
        assertEquals(indexConfigs.length, indexes.getIndexes().length);
        for (IndexConfig indexConfig : indexConfigs) {
            String expectedName = getExpectedName(indexConfig);
            InternalIndex index = indexes.getIndex(expectedName);
            assertNotNull("Index not found: " + expectedName, index);
            assertEquals(type == IndexType.SORTED, index.isOrdered());
            assertEquals(type, index.getConfig().getType());
            assertEquals(indexConfig.getAttributes().size(), index.getComponents().length);
            for (int i = 0; i < indexConfig.getAttributes().size(); i++) {
                String expAttributeName = indexConfig.getAttributes().get(i);
                String componentName = index.getComponents()[i];
                assertEquals(IndexUtils.canonicalizeAttribute(expAttributeName), componentName);
            }
        }
    }
}
Also used : InternalIndex(com.hazelcast.query.impl.InternalIndex) IndexConfig(com.hazelcast.config.IndexConfig) MapService(com.hazelcast.map.impl.MapService) Indexes(com.hazelcast.query.impl.Indexes) HazelcastInstanceProxy(com.hazelcast.instance.impl.HazelcastInstanceProxy) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Aggregations

InternalIndex (com.hazelcast.query.impl.InternalIndex)22 IndexConfig (com.hazelcast.config.IndexConfig)11 HazelcastInstance (com.hazelcast.core.HazelcastInstance)9 Indexes (com.hazelcast.query.impl.Indexes)9 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 IndexRangeFilter (com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter)4 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 CacheDeserializedValues (com.hazelcast.config.CacheDeserializedValues)2 MapContainer (com.hazelcast.map.impl.MapContainer)2 Record (com.hazelcast.map.impl.record.Record)2 Predicate (com.hazelcast.query.Predicate)2 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)2 IndexEqualsFilter (com.hazelcast.sql.impl.exec.scan.index.IndexEqualsFilter)2 HazelcastInstanceProxy (com.hazelcast.instance.impl.HazelcastInstanceProxy)1 LocalRecordStoreStats (com.hazelcast.internal.monitor.LocalRecordStoreStats)1 OnDemandIndexStats (com.hazelcast.internal.monitor.impl.OnDemandIndexStats)1