use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class IndexUtils method getIndexConfigFromYaml.
public static IndexConfig getIndexConfigFromYaml(Node indexNode, boolean domLevel3, boolean strict) {
NamedNodeMap attrs = indexNode.getAttributes();
String name = getTextContent(attrs.getNamedItem("name"), domLevel3);
if (name.isEmpty()) {
name = null;
}
String typeStr = getTextContent(attrs.getNamedItem("type"), domLevel3);
if (typeStr.isEmpty()) {
typeStr = IndexConfig.DEFAULT_TYPE.name();
}
IndexType type = getIndexTypeFromXmlName(typeStr);
IndexConfig res = new IndexConfig().setName(name).setType(type);
Node attributesNode = attrs.getNamedItem("attributes");
for (Node attributeNode : childElements(attributesNode)) {
String attribute = attributeNode.getNodeValue();
res.addAttribute(attribute);
}
if (type == IndexType.BITMAP) {
Node optionsNode = childElementWithName(indexNode, "bitmap-index-options", strict);
if (optionsNode != null) {
Node uniqueKeyNode = childElementWithName(optionsNode, "unique-key", strict);
String uniqueKeyText = getTextContent(uniqueKeyNode, domLevel3);
String uniqueKey = isNullOrEmpty(uniqueKeyText) ? BitmapIndexOptions.DEFAULT_UNIQUE_KEY : uniqueKeyText;
Node uniqueKeyTransformationNode = childElementWithName(optionsNode, "unique-key-transformation", strict);
String uniqueKeyTransformationText = getTextContent(uniqueKeyTransformationNode, domLevel3);
UniqueKeyTransformation uniqueKeyTransformation = isNullOrEmpty(uniqueKeyTransformationText) ? BitmapIndexOptions.DEFAULT_UNIQUE_KEY_TRANSFORMATION : UniqueKeyTransformation.fromName(uniqueKeyTransformationText);
res.getBitmapIndexOptions().setUniqueKey(uniqueKey);
res.getBitmapIndexOptions().setUniqueKeyTransformation(uniqueKeyTransformation);
}
}
return res;
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapIndexInfo method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
mapName = in.readString();
int size = in.readInt();
for (int i = 0; i < size; i++) {
IndexConfig indexConfig = in.readObject();
indexConfigs.add(indexConfig);
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class AggregatorsSpecTest method getMapWithNodeCount.
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 = getConfig().setProperty(PARTITION_COUNT.getName(), String.valueOf(nodeCount)).setProperty(AGGREGATION_ACCUMULATION_PARALLEL_EVALUATION.getName(), String.valueOf(parallelAccumulation)).addMapConfig(mapConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
HazelcastInstance instance = factory.newInstances(config)[0];
return instance.getMap("aggr");
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class AbstractClientConfigBuilderTest method testQueryCacheFullConfig.
@Test
public void testQueryCacheFullConfig() throws Exception {
QueryCacheConfig queryCacheClassPredicateConfig = fullClientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-class-name-predicate");
QueryCacheConfig queryCacheSqlPredicateConfig = fullClientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-sql-predicate");
EntryListenerConfig entryListenerConfig = queryCacheClassPredicateConfig.getEntryListenerConfigs().get(0);
assertEquals("query-cache-class-name-predicate", queryCacheClassPredicateConfig.getName());
assertTrue(entryListenerConfig.isIncludeValue());
assertFalse(entryListenerConfig.isLocal());
assertEquals("com.hazelcast.examples.EntryListener", entryListenerConfig.getClassName());
assertTrue(queryCacheClassPredicateConfig.isIncludeValue());
assertEquals(1, queryCacheClassPredicateConfig.getBatchSize());
assertEquals(16, queryCacheClassPredicateConfig.getBufferSize());
assertEquals(0, queryCacheClassPredicateConfig.getDelaySeconds());
EvictionConfig evictionConfig = queryCacheClassPredicateConfig.getEvictionConfig();
assertEquals(EvictionPolicy.LRU, evictionConfig.getEvictionPolicy());
assertEquals(MaxSizePolicy.ENTRY_COUNT, evictionConfig.getMaxSizePolicy());
assertEquals(10000, evictionConfig.getSize());
assertEquals("com.hazelcast.examples.MyEvictionComparator", evictionConfig.getComparatorClassName());
assertEquals(InMemoryFormat.BINARY, queryCacheClassPredicateConfig.getInMemoryFormat());
assertFalse(queryCacheClassPredicateConfig.isCoalesce());
assertTrue(queryCacheClassPredicateConfig.isPopulate());
assertFalse(queryCacheClassPredicateConfig.isSerializeKeys());
for (IndexConfig indexConfig : queryCacheClassPredicateConfig.getIndexConfigs()) {
assertEquals("name", indexConfig.getAttributes().get(0));
assertFalse(indexConfig.getType() == IndexType.SORTED);
}
assertEquals("com.hazelcast.examples.ExamplePredicate", queryCacheClassPredicateConfig.getPredicateConfig().getClassName());
assertEquals("query-cache-sql-predicate", queryCacheSqlPredicateConfig.getName());
assertEquals("%age=40", queryCacheSqlPredicateConfig.getPredicateConfig().getSql());
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class QueryCache method addIndex.
/**
* @see IMap#addIndex(IndexType, String...)
*/
default void addIndex(IndexType type, String... attributes) {
IndexConfig config = IndexUtils.createIndexConfig(type, attributes);
addIndex(config);
}
Aggregations