Search in sources :

Example 51 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class IndexStatsQueryingInCollectionsAndArraysTest method addIndex.

private static void addIndex(IMap map, String attribute, boolean ordered) {
    IndexConfig config = new IndexConfig(ordered ? IndexType.SORTED : IndexType.HASH, attribute).setName(attribute);
    map.addIndex(config);
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig)

Example 52 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class MapIndexBackupTest method createNode.

private HazelcastInstance createNode(TestHazelcastInstanceFactory instanceFactory) {
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig("book");
    mapConfig.addIndexConfig(new IndexConfig(IndexType.HASH, "author"));
    mapConfig.addIndexConfig(new IndexConfig(IndexType.SORTED, "year"));
    mapConfig.setMapStoreConfig(new MapStoreConfig().setImplementation(new BookMapLoader()));
    mapConfig.setBackupCount(1);
    return instanceFactory.newHazelcastInstance(config);
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 53 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class RecordStoreTest method testRecordStoreReset.

private IMap<Object, Object> testRecordStoreReset() {
    String mapName = randomName();
    Config config = new Config();
    MapConfig mapConfig = config.getMapConfig(mapName);
    IndexConfig indexConfig = new IndexConfig(IndexType.HASH, "name");
    mapConfig.addIndexConfig(indexConfig);
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Object, Object> map = hazelcastInstance.getMap(mapName);
    int key = 1;
    map.put(key, new SampleTestObjects.Employee("tom", 24, true, 10));
    DefaultRecordStore defaultRecordStore = getRecordStore(map, key);
    defaultRecordStore.reset();
    assertNull(map.get(key));
    return map;
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) MapConfig(com.hazelcast.config.MapConfig) SampleTestObjects(com.hazelcast.query.SampleTestObjects) MapConfig(com.hazelcast.config.MapConfig) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore)

Example 54 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class ExpiryAndLockTest method locked_keys_are_reachable_over_index_after_they_expired.

@Test
public void locked_keys_are_reachable_over_index_after_they_expired() {
    Config config = getConfig();
    config.getMapConfig("default").setTimeToLiveSeconds(2).addIndexConfig(new IndexConfig(IndexType.SORTED, "this"));
    HazelcastInstance node = createHazelcastInstance(config);
    IMap<Integer, Integer> indexedMap = node.getMap("indexed");
    int keyCount = 1_000;
    for (int i = 0; i < keyCount; i++) {
        indexedMap.set(i, i);
        indexedMap.lock(i);
    }
    assertTrueAllTheTime(() -> {
        Set<Map.Entry<Integer, Integer>> entries = indexedMap.entrySet(Predicates.sql("this >= 0"));
        int entrySetSize = CollectionUtil.isEmpty(entries) ? 0 : entries.size();
        assertEquals(keyCount, entrySetSize);
    }, 5);
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 55 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class IndexTest method testRemoveEnumIndex.

@Test
public void testRemoveEnumIndex() {
    IndexConfig config = IndexUtils.createTestIndexConfig(IndexType.HASH, "favoriteCity");
    Indexes is = Indexes.newBuilder(ss, copyBehavior, DEFAULT_IN_MEMORY_FORMAT).build();
    is.addOrGetIndex(config);
    Data key = ss.toData(1);
    Data value = ss.toData(new SerializableWithEnum(SerializableWithEnum.City.ISTANBUL));
    is.putEntry(new QueryEntry(ss, key, value, newExtractor()), null, Index.OperationSource.USER);
    assertNotNull(is.getIndex(config.getName()));
    Record record = recordFactory.newRecord(key, value);
    is.removeEntry(key, Records.getValueOrCachedValue(record, ss), Index.OperationSource.USER);
    assertEquals(0, is.getIndex(config.getName()).getRecords(SerializableWithEnum.City.ISTANBUL).size());
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) TestUtil.toData(com.hazelcast.instance.impl.TestUtil.toData) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

IndexConfig (com.hazelcast.config.IndexConfig)130 Test (org.junit.Test)49 QuickTest (com.hazelcast.test.annotation.QuickTest)45 Config (com.hazelcast.config.Config)42 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)38 MapConfig (com.hazelcast.config.MapConfig)34 HazelcastInstance (com.hazelcast.core.HazelcastInstance)29 ArrayList (java.util.ArrayList)16 Before (org.junit.Before)13 MapStoreConfig (com.hazelcast.config.MapStoreConfig)12 InternalIndex (com.hazelcast.query.impl.InternalIndex)12 AttributeConfig (com.hazelcast.config.AttributeConfig)9 MapContainer (com.hazelcast.map.impl.MapContainer)9 IndexRangeFilter (com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter)9 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)8 Node (org.w3c.dom.Node)8 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)7 IMap (com.hazelcast.map.IMap)7 Indexes (com.hazelcast.query.impl.Indexes)7 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)7