use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class QueryAdvancedTest method testMapWithIndexAfterShutDown.
@Test
public void testMapWithIndexAfterShutDown() {
Config config = getConfig();
String mapName = "default";
config.getMapConfig(mapName).addIndexConfig(new IndexConfig(IndexType.HASH, "typeName"));
HazelcastInstance[] instances = createHazelcastInstanceFactory(3).newInstances(config);
final IMap<Integer, ValueType> map = instances[0].getMap(mapName);
final int sampleSize1 = 100;
final int sampleSize2 = 30;
int totalSize = sampleSize1 + sampleSize2;
for (int i = 0; i < sampleSize1; i++) {
map.put(i, new ValueType("type" + i));
}
for (int i = sampleSize1; i < totalSize; i++) {
map.put(i, new ValueType("typex"));
}
Collection typexValues = map.values(Predicates.sql("typeName = typex"));
assertEquals(sampleSize2, typexValues.size());
instances[1].shutdown();
assertEquals(totalSize, map.size());
assertTrueEventually(() -> {
final Collection values = map.values(Predicates.sql("typeName = typex"));
assertEquals(sampleSize2, values.size());
});
instances[2].shutdown();
assertEquals(totalSize, map.size());
assertTrueEventually(() -> {
final Collection values = map.values(Predicates.sql("typeName = typex"));
assertEquals(sampleSize2, values.size());
});
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapKeySetTest method setup.
@Before
public void setup() {
Config config = regularInstanceConfig();
config.setProperty(QueryEngineImpl.DISABLE_MIGRATION_FALLBACK.getName(), "true");
config.getMapConfig("indexed").addIndexConfig(new IndexConfig(IndexType.SORTED, "this"));
instance = createHazelcastInstance(config);
map = instance.getMap(randomName());
serializationService = getSerializationService(instance);
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testMigration.
// This test has different requirements, therefore depends on local variables.
// Before and After actions are dismissed.
@Test
public void testMigration() {
HazelcastInstance instance = new CustomTestInstanceFactory().newHazelcastInstance(config);
PartitionIdSet partitions = getLocalPartitions(instance);
List<Person> people = new ArrayList<>(Arrays.asList(new Person("person1", 45, null), new Person("person2", 39, null), new Person("person3", 60, null), new Person("person4", 45, null), new Person("person5", 43, null)));
IMap<String, Person> map = instance.getMap(mapName);
map.addIndex(new IndexConfig(IndexType.SORTED, "age").setName(orderedIndexName));
insertIntoMap(map, people);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(10, true, 100, true, false, null);
MapOperationProvider operationProvider = getOperationProvider(map);
MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 10);
Address address = instance.getCluster().getLocalMember().getAddress();
OperationServiceImpl operationService = getOperationService(instance);
try {
InvocationFuture<MapFetchIndexOperationResult> future = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).invoke();
future.get();
} catch (Exception e) {
assertInstanceOf(MissingPartitionException.class, e.getCause());
} finally {
instance.shutdown();
}
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class QueryBasicTest method testQueryPortableObjectWithIndex.
@Test
public void testQueryPortableObjectWithIndex() {
String name = randomMapName();
Config config = getConfig();
config.addMapConfig(new MapConfig(name).addIndexConfig(new IndexConfig(IndexType.SORTED, "timestamp")));
testQueryUsingPortableObject(config, name);
}
use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.
the class QueryBasicTest method testOptionalUnorderedIndexQuerying.
@Test
public void testOptionalUnorderedIndexQuerying() {
String name = randomMapName();
Config config = smallInstanceConfig();
config.getMapConfig(name).addIndexConfig(new IndexConfig(IndexType.HASH, "attribute"));
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, ObjectWithOptional<Integer>> map = instance.getMap(name);
for (int i = 0; i < 10; ++i) {
map.put(i, new ObjectWithOptional<>(i % 2 == 0 ? i : null));
}
Set<Integer> result = map.keySet(Predicates.equal("attribute", null));
assertEqualSets(result, 1, 3, 5, 7, 9);
assertEquals(1, map.getLocalMapStats().getIndexedQueryCount());
result = map.keySet(Predicates.notEqual("attribute", null));
assertEqualSets(result, 0, 2, 4, 6, 8);
assertEquals(1, map.getLocalMapStats().getIndexedQueryCount());
result = map.keySet(Predicates.greaterThan("attribute", 4));
assertEqualSets(result, 6, 8);
assertEquals(2, map.getLocalMapStats().getIndexedQueryCount());
}
Aggregations