use of com.hazelcast.query.impl.InternalIndex in project hazelcast by hazelcast.
the class AttributeCanonicalizationTest method checkIndex.
private void checkIndex(Indexes indexes, IndexType indexType, String[] attributes, String[] expAttributes) {
IndexConfig config = new IndexConfig().setType(indexType);
for (String attribute : attributes) {
config.addAttribute(attribute);
}
IndexConfig normalizedConfig = IndexUtils.validateAndNormalize("map", config);
StringBuilder expName = new StringBuilder("map");
if (indexType == IndexType.SORTED) {
expName.append("_sorted");
} else {
expName.append("_hash");
}
for (int i = 0; i < expAttributes.length; i++) {
String expAttribute = expAttributes[i];
String attribute = normalizedConfig.getAttributes().get(i);
assertEquals(expAttribute, attribute);
expName.append("_").append(expAttribute);
}
assertEquals(expName.toString(), normalizedConfig.getName());
InternalIndex index = indexes.addOrGetIndex(normalizedConfig);
assertEquals(normalizedConfig.getName(), index.getName());
assertNotNull(indexes.getIndex(normalizedConfig.getName()));
}
use of com.hazelcast.query.impl.InternalIndex in project hazelcast by hazelcast.
the class IndexCreateTest method checkIndex.
private void checkIndex(IndexConfig... indexConfigs) {
List<HazelcastInstanceProxy> members = handler.initialize(hazelcastFactory, indexConfigs);
for (HazelcastInstanceProxy member : members) {
MapService service = member.getOriginal().node.nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(MAP_NAME);
Indexes indexes = mapContainer.getIndexes();
assertEquals(indexConfigs.length, indexes.getIndexes().length);
for (IndexConfig indexConfig : indexConfigs) {
String expectedName = getExpectedName(indexConfig);
InternalIndex index = indexes.getIndex(expectedName);
assertNotNull("Index not found: " + expectedName, index);
assertEquals(type == IndexType.SORTED, index.isOrdered());
assertEquals(type, index.getConfig().getType());
assertEquals(indexConfig.getAttributes().size(), index.getComponents().length);
for (int i = 0; i < indexConfig.getAttributes().size(); i++) {
String expAttributeName = indexConfig.getAttributes().get(i);
String componentName = index.getComponents()[i];
assertEquals(IndexUtils.canonicalizeAttribute(expAttributeName), componentName);
}
}
}
}
Aggregations