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);
}
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);
}
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;
}
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);
}
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());
}
Aggregations