use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class SqlOrderByTest method checkSelectWithOrderBy.
protected void checkSelectWithOrderBy(List<String> indexAttrs, List<String> orderFields, List<Boolean> orderDirections) {
IMap<Object, AbstractPojo> map = getTarget().getMap(mapName());
IndexConfig indexConfig = new IndexConfig().setName("Index_" + randomName()).setType(SORTED);
for (String indexAttr : indexAttrs) {
indexConfig.addAttribute(indexAttr);
}
if (indexAttrs.size() > 0) {
map.addIndex(indexConfig);
}
assertEquals(DATA_SET_SIZE, map.size());
StringBuilder orders = new StringBuilder();
for (int i = 0; i < orderFields.size(); ++i) {
String orderField = orderFields.get(i);
Boolean descending = orderDirections.get(i);
orders.append(orderField);
if (descending != null) {
orders.append(descending ? " DESC " : " ASC ");
}
if (i < orderFields.size() - 1) {
orders.append(", ");
}
}
String sql = sqlWithOrderBy(orders.toString());
assertSqlResultOrdered(sql, orderFields, orderDirections, map.size());
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class QueryCacheConfigHolder method of.
public static QueryCacheConfigHolder of(QueryCacheConfig config, SerializationService serializationService) {
QueryCacheConfigHolder holder = new QueryCacheConfigHolder();
holder.setBatchSize(config.getBatchSize());
holder.setBufferSize(config.getBufferSize());
holder.setCoalesce(config.isCoalesce());
holder.setDelaySeconds(config.getDelaySeconds());
holder.setEvictionConfigHolder(EvictionConfigHolder.of(config.getEvictionConfig(), serializationService));
holder.setIncludeValue(config.isIncludeValue());
holder.setInMemoryFormat(config.getInMemoryFormat().toString());
holder.setName(config.getName());
if (config.getIndexConfigs() != null && !config.getIndexConfigs().isEmpty()) {
List<IndexConfig> indexConfigs = new ArrayList<>(config.getIndexConfigs().size());
for (IndexConfig indexConfig : config.getIndexConfigs()) {
indexConfigs.add(new IndexConfig(indexConfig));
}
holder.setIndexConfigs(indexConfigs);
}
if (config.getEntryListenerConfigs() != null && !config.getEntryListenerConfigs().isEmpty()) {
List<ListenerConfigHolder> listenerConfigHolders = new ArrayList<>(config.getEntryListenerConfigs().size());
for (EntryListenerConfig listenerConfig : config.getEntryListenerConfigs()) {
listenerConfigHolders.add(ListenerConfigHolder.of(listenerConfig, serializationService));
}
holder.setListenerConfigs(listenerConfigHolders);
}
holder.setPredicateConfigHolder(PredicateConfigHolder.of(config.getPredicateConfig(), serializationService));
holder.setPopulate(config.isPopulate());
holder.setSerializeKeys(config.isSerializeKeys());
return holder;
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapReplicationStateHolder method applyState.
@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:methodlength", "checkstyle:cyclomaticcomplexity", "checkstyle:nestedifdepth" })
void applyState() {
ThreadUtil.assertRunningOnPartitionThread();
applyIndexesState();
if (!isNullOrEmpty(data)) {
for (Map.Entry<String, List> dataEntry : data.entrySet()) {
String mapName = dataEntry.getKey();
List keyRecordExpiry = dataEntry.getValue();
RecordStore recordStore = operation.getRecordStore(mapName);
recordStore.beforeOperation();
try {
initializeRecordStore(mapName, recordStore);
recordStore.setPreMigrationLoadedStatus(loaded.get(mapName));
MapContainer mapContainer = recordStore.getMapContainer();
PartitionContainer partitionContainer = recordStore.getMapContainer().getMapServiceContext().getPartitionContainer(operation.getPartitionId());
for (Map.Entry<String, IndexConfig> indexDefinition : mapContainer.getIndexDefinitions().entrySet()) {
Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
indexes.addOrGetIndex(indexDefinition.getValue());
}
final Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
final boolean populateIndexes = indexesMustBePopulated(indexes, operation);
InternalIndex[] indexesSnapshot = null;
if (populateIndexes) {
// defensively clear possible stale leftovers in non-global indexes from
// the previous failed promotion attempt
indexesSnapshot = indexes.getIndexes();
Indexes.beginPartitionUpdate(indexesSnapshot);
indexes.clearAll();
}
long nowInMillis = Clock.currentTimeMillis();
forEachReplicatedRecord(keyRecordExpiry, mapContainer, recordStore, populateIndexes, nowInMillis);
if (populateIndexes) {
Indexes.markPartitionAsIndexed(partitionContainer.getPartitionId(), indexesSnapshot);
}
} finally {
recordStore.afterOperation();
}
}
}
for (Map.Entry<String, LocalRecordStoreStats> statsEntry : recordStoreStatsPerMapName.entrySet()) {
String mapName = statsEntry.getKey();
LocalRecordStoreStats stats = statsEntry.getValue();
RecordStore recordStore = operation.getRecordStore(mapName);
recordStore.setStats(stats);
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapChunk method applyIndexStateBefore.
private void applyIndexStateBefore(RecordStore recordStore) {
MapContainer mapContainer = recordStore.getMapContainer();
PartitionContainer partitionContainer = mapContainer.getMapServiceContext().getPartitionContainer(getPartitionId());
for (Map.Entry<String, IndexConfig> indexDefinition : mapContainer.getIndexDefinitions().entrySet()) {
Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
indexes.addOrGetIndex(indexDefinition.getValue());
}
Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
boolean populateIndexes = indexesMustBePopulated(indexes);
if (populateIndexes) {
// defensively clear possible stale
// leftovers in non-global indexes from
// the previous failed promotion attempt
Indexes.beginPartitionUpdate(indexes.getIndexes());
indexes.clearAll();
}
}
use of com.hazelcast.config.IndexConfig 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;
}
Aggregations