use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class IndexUtils method generateXml.
public static void generateXml(ConfigXmlGenerator.XmlGenerator gen, List<IndexConfig> indexConfigs) {
if (indexConfigs.isEmpty()) {
return;
}
gen.open("indexes");
for (IndexConfig indexCfg : indexConfigs) {
if (indexCfg.getName() != null) {
gen.open("index", "name", indexCfg.getName(), "type", indexCfg.getType().name());
} else {
gen.open("index", "type", indexCfg.getType().name());
}
gen.open("attributes");
for (String attribute : indexCfg.getAttributes()) {
gen.node("attribute", attribute);
}
gen.close();
if (indexCfg.getType() == IndexType.BITMAP) {
BitmapIndexOptions bitmapIndexOptions = indexCfg.getBitmapIndexOptions();
gen.open("bitmap-index-options");
gen.node("unique-key", bitmapIndexOptions.getUniqueKey());
gen.node("unique-key-transformation", bitmapIndexOptions.getUniqueKeyTransformation());
gen.close();
}
gen.close();
}
gen.close();
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class IndexUtils method createIndexConfig.
/**
* Create simple index definition with the given attributes
*
* @param type Index type.
* @param attributes Attribute names.
* @return Index definition.
*/
public static IndexConfig createIndexConfig(IndexType type, String... attributes) {
IndexConfig res = new IndexConfig();
res.setType(type);
checkNotNull(attributes, "Index attributes cannot be null.");
for (String attribute : attributes) {
res.addAttribute(attribute);
}
return res;
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class IndexUtils method buildNormalizedConfig.
private static IndexConfig buildNormalizedConfig(String mapName, IndexType indexType, String indexName, List<String> normalizedAttributeNames) {
IndexConfig newConfig = new IndexConfig().setType(indexType);
StringBuilder nameBuilder = indexName == null ? new StringBuilder(mapName + "_" + getIndexTypeName(indexType)) : null;
for (String normalizedAttributeName : normalizedAttributeNames) {
newConfig.addAttribute(normalizedAttributeName);
if (nameBuilder != null) {
nameBuilder.append("_").append(normalizedAttributeName);
}
}
if (nameBuilder != null) {
indexName = nameBuilder.toString();
}
newConfig.setName(indexName);
return newConfig;
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapIndexInfo method writeData.
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeString(mapName);
out.writeInt(indexConfigs.size());
for (IndexConfig indexConfig : indexConfigs) {
out.writeObject(indexConfig);
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapTableUtils method getPartitionedMapIndexes.
public static List<MapTableIndex> getPartitionedMapIndexes(MapContainer mapContainer, List<TableField> fields) {
Map<QueryPath, Integer> pathToOrdinalMap = mapPathsToOrdinals(fields);
if (mapContainer.getIndexes() == null) {
return Collections.emptyList();
}
InternalIndex[] indexes = mapContainer.getIndexes().getIndexes();
if (indexes == null || indexes.length == 0) {
return Collections.emptyList();
}
List<MapTableIndex> res = new ArrayList<>(indexes.length);
for (Index index : indexes) {
IndexConfig indexConfig = index.getConfig();
List<QueryDataType> resolvedFieldConverterTypes = indexConverterToSqlTypes(index.getConverter());
List<String> indexAttributes = indexConfig.getAttributes();
List<Integer> indexFieldOrdinals = new ArrayList<>(indexAttributes.size());
List<QueryDataType> indexFieldConverterTypes = new ArrayList<>(indexAttributes.size());
String[] components = index.getComponents();
for (int i = 0; i < indexAttributes.size(); i++) {
String attribute = indexAttributes.get(i);
QueryPath attributePath = QueryPath.create(attribute);
Integer ordinal = pathToOrdinalMap.get(attributePath);
if (ordinal == null) {
// No mapping for the field. Stop.
break;
}
if (i >= resolvedFieldConverterTypes.size()) {
// No more resolved converters. Stop.
break;
}
QueryDataType fieldType = fields.get(ordinal).getType();
QueryDataType converterType = resolvedFieldConverterTypes.get(i);
if (!isCompatibleForIndexRequest(fieldType, converterType)) {
// Field and converter types are not compatible (e.g. INT vs VARCHAR).
break;
}
indexFieldOrdinals.add(ordinal);
indexFieldConverterTypes.add(converterType);
}
MapTableIndex index0 = new MapTableIndex(indexConfig.getName(), indexConfig.getType(), components.length, indexFieldOrdinals, indexFieldConverterTypes);
res.add(index0);
}
return res;
}
Aggregations