Search in sources :

Example 6 with IndexType

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

the class IndexUtils method getIndexConfigFromXml.

public static IndexConfig getIndexConfigFromXml(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);
    IndexType type = getIndexTypeFromXmlName(typeStr);
    IndexConfig res = new IndexConfig().setName(name).setType(type);
    for (Node attributesNode : childElements(indexNode)) {
        if ("attributes".equals(cleanNodeName(attributesNode))) {
            for (Node attributeNode : childElements(attributesNode)) {
                if ("attribute".equals(cleanNodeName(attributeNode))) {
                    String attribute = getTextContent(attributeNode, domLevel3);
                    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;
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) IndexConfig(com.hazelcast.config.IndexConfig) Node(org.w3c.dom.Node) IndexType(com.hazelcast.config.IndexType) UniqueKeyTransformation(com.hazelcast.config.BitmapIndexOptions.UniqueKeyTransformation)

Example 7 with IndexType

use of com.hazelcast.config.IndexType 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;
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) IndexConfig(com.hazelcast.config.IndexConfig) Node(org.w3c.dom.Node) IndexType(com.hazelcast.config.IndexType) UniqueKeyTransformation(com.hazelcast.config.BitmapIndexOptions.UniqueKeyTransformation)

Example 8 with IndexType

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

the class IndexCreateTest method parameters.

@Parameterized.Parameters(name = "Executing: {0}, {1}")
public static Collection<Object[]> parameters() {
    List<Object[]> res = new ArrayList<>();
    for (IndexType type : IndexType.values()) {
        res.add(new Object[] { new StaticMapMemberHandler(), type });
        res.add(new Object[] { new DynamicMapMemberHandler(), type });
        res.add(new Object[] { new DynamicIndexMemberHandler(), type });
        res.add(new Object[] { new DynamicMapClientHandler(), type });
        res.add(new Object[] { new DynamicIndexClientHandler(), type });
    }
    return res;
}
Also used : ArrayList(java.util.ArrayList) IndexType(com.hazelcast.config.IndexType)

Aggregations

IndexType (com.hazelcast.config.IndexType)8 IndexConfig (com.hazelcast.config.IndexConfig)3 UniqueKeyTransformation (com.hazelcast.config.BitmapIndexOptions.UniqueKeyTransformation)2 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 ArrayList (java.util.ArrayList)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 Node (org.w3c.dom.Node)2 TestUtil.toData (com.hazelcast.instance.impl.TestUtil.toData)1 Data (com.hazelcast.internal.serialization.Data)1 Util.getNodeEngine (com.hazelcast.jet.impl.util.Util.getNodeEngine)1 SqlConnectorCache (com.hazelcast.jet.sql.impl.connector.SqlConnectorCache)1 OptimizerTestSupport (com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport)1 FullScanLogicalRel (com.hazelcast.jet.sql.impl.opt.logical.FullScanLogicalRel)1 FullScanPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel)1 IndexScanMapPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel)1 HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)1 TableResolverImpl (com.hazelcast.jet.sql.impl.schema.TableResolverImpl)1 TablesStorage (com.hazelcast.jet.sql.impl.schema.TablesStorage)1