use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class ClientAggregatorsSpecTest method getMapWithNodeCount.
@Override
protected <K, V> IMap<K, V> getMapWithNodeCount(int nodeCount, boolean parallelAccumulation, boolean useIndex) {
if (nodeCount < 1) {
throw new IllegalArgumentException("node count < 1");
}
MapConfig mapConfig = new MapConfig().setName("aggr").setInMemoryFormat(inMemoryFormat);
if (useIndex) {
mapConfig.addIndexConfig(new IndexConfig(IndexConfig.DEFAULT_TYPE, "fieldWeCanQuery"));
}
Config config = new Config().setProperty(PARTITION_COUNT.getName(), String.valueOf(nodeCount)).setProperty(AGGREGATION_ACCUMULATION_PARALLEL_EVALUATION.getName(), String.valueOf(parallelAccumulation)).addMapConfig(mapConfig);
factory = new TestHazelcastFactory();
for (int i = 0; i < nodeCount; i++) {
factory.newHazelcastInstance(config);
}
HazelcastInstance instance = factory.newHazelcastClient();
return instance.getMap("aggr");
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class YamlMemberDomConfigProcessor method mapIndexesHandle.
@Override
protected void mapIndexesHandle(Node n, MapConfig mapConfig) {
for (Node indexNode : childElements(n)) {
IndexConfig indexConfig = IndexUtils.getIndexConfigFromYaml(indexNode, domLevel3, strict);
mapConfig.addIndexConfig(indexConfig);
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class DynamicConfigYamlGenerator method getIndexConfigsAsList.
private static List<Map<String, Object>> getIndexConfigsAsList(List<IndexConfig> indexConfigs) {
if (indexConfigs == null || indexConfigs.isEmpty()) {
return null;
}
List<Map<String, Object>> indexConfigsAsList = new LinkedList<>();
for (IndexConfig indexConfig : indexConfigs) {
Map<String, Object> indexConfigAsMap = new LinkedHashMap<>();
addNonNullToMap(indexConfigAsMap, "name", indexConfig.getName());
addNonNullToMap(indexConfigAsMap, "type", indexConfig.getType().name());
addNonNullToMap(indexConfigAsMap, "attributes", indexConfig.getAttributes());
if (indexConfig.getType() == IndexType.BITMAP) {
Map<String, Object> bitmapIndexOptionsAsMap = new LinkedHashMap<>();
addNonNullToMap(bitmapIndexOptionsAsMap, "unique-key", indexConfig.getBitmapIndexOptions().getUniqueKey());
addNonNullToMap(bitmapIndexOptionsAsMap, "unique-key-transformation", indexConfig.getBitmapIndexOptions().getUniqueKeyTransformation().name());
indexConfigAsMap.put("bitmap-index-options", bitmapIndexOptionsAsMap);
}
addNonNullToList(indexConfigsAsList, indexConfigAsMap);
}
return indexConfigsAsList;
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class SqlSplitBrainTest method test_indexScan.
@Test
public // test for https://github.com/hazelcast/hazelcast/issues/19472
void test_indexScan() throws InterruptedException {
Thread[] threads = new Thread[2];
AtomicBoolean done = new AtomicBoolean();
AtomicInteger numQueries = new AtomicInteger();
Consumer<HazelcastInstance[]> beforeSplit = instances -> {
IMap<Integer, Integer> m = instances[0].getMap("m");
for (int i = 0; i < 10_000; i++) {
m.put(i, i);
}
m.addIndex(new IndexConfig().addAttribute("this"));
SqlTestSupport.createMapping(instances[0], "m", Integer.class, Integer.class);
for (int i = 0, threadsLength = threads.length; i < threadsLength; i++) {
HazelcastInstance inst = createHazelcastClient();
threads[i] = new Thread(() -> {
int numQueriesLocal = 0;
while (!done.get()) {
try {
// noinspection StatementWithEmptyBody
for (SqlRow ignored : inst.getSql().execute("select * from m where this>100 and this<1000")) {
// do nothing
}
} catch (Throwable e) {
logger.info(e);
}
numQueriesLocal++;
}
numQueries.addAndGet(numQueriesLocal);
});
threads[i].start();
sleepSeconds(1);
}
};
testSplitBrain(1, 1, beforeSplit, null, null);
done.set(true);
boolean stuck = false;
for (Thread t : threads) {
t.join(5000);
if (t.isAlive()) {
logger.info("thread " + t + " stuck");
stuck = true;
}
}
logger.info("num queries executed: " + numQueries.get());
if (stuck) {
fail("some threads were stuck");
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class IndexInFilterIterationTest method check.
private void check(IndexType indexType) {
HazelcastInstance instance = factory.newHazelcastInstance(getConfig());
IMap<Integer, Value> map = instance.getMap(MAP_NAME);
map.addIndex(new IndexConfig().setName(INDEX_NAME).setType(indexType).addAttribute("value1"));
InternalIndex index = getIndex(instance);
ExpressionEvalContext evalContext = createExpressionEvalContext();
map.put(1, new Value(null));
map.put(2, new Value(0));
map.put(3, new Value(1));
// No values from both filters
checkIterator(indexType, descendingDirection, in(equals(2), equals(3)).getEntries(index, descendingDirection, evalContext));
checkIterator(indexType, descendingDirection, in(equals(3), equals(2)).getEntries(index, descendingDirection, evalContext));
// No values from one filter
checkIterator(indexType, descendingDirection, in(equals(1), equals(2)).getEntries(index, descendingDirection, evalContext), 3);
checkIterator(indexType, descendingDirection, in(equals(2), equals(1)).getEntries(index, descendingDirection, evalContext), 3);
checkIterator(indexType, descendingDirection, in(equals(null, true), equals(2)).getEntries(index, descendingDirection, evalContext), 1);
checkIterator(indexType, descendingDirection, in(equals(2), equals(null, true)).getEntries(index, descendingDirection, evalContext), 1);
// Values from both filters
checkIterator(indexType, descendingDirection, in(equals(0), equals(1)).getEntries(index, descendingDirection, evalContext), 2, 3);
checkIterator(indexType, descendingDirection, in(equals(1), equals(0)).getEntries(index, descendingDirection, evalContext), 2, 3);
checkIterator(indexType, descendingDirection, in(equals(null, true), equals(0)).getEntries(index, descendingDirection, evalContext), 1, 2);
checkIterator(indexType, descendingDirection, in(equals(0), equals(null, true)).getEntries(index, descendingDirection, evalContext), 1, 2);
// One distinct value
checkIterator(indexType, descendingDirection, in(equals(0), equals(0)).getEntries(index, descendingDirection, evalContext), 2);
checkIterator(indexType, descendingDirection, in(equals(null, true), equals(null, true)).getEntries(index, descendingDirection, evalContext), 1);
// One null value
checkIterator(indexType, descendingDirection, in(equals(0), equals(null, false)).getEntries(index, descendingDirection, evalContext), 2);
checkIterator(indexType, descendingDirection, in(equals(null, false), equals(0)).getEntries(index, descendingDirection, evalContext), 2);
checkIterator(indexType, descendingDirection, in(equals(null, false), equals(null, true)).getEntries(index, descendingDirection, evalContext), 1);
checkIterator(indexType, descendingDirection, in(equals(null, true), equals(null, false)).getEntries(index, descendingDirection, evalContext), 1);
// Two null values
checkIterator(indexType, descendingDirection, in(equals(null, false), equals(null, false)).getEntries(index, descendingDirection, evalContext));
}
Aggregations