use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapEntrySetTest method whenSelectingPartitionSubset.
@Test
public void whenSelectingPartitionSubset() {
PartitionIdSet partitionSubset = new PartitionIdSet(4, asList(1, 3));
Set<String> matchingKeys = new HashSet<>();
for (int i = 0; i < 5; i++) {
String key = generateKeyForPartition(instance, i);
map.put(key, key);
if (partitionSubset.contains(i)) {
matchingKeys.add(key);
}
}
Set<Entry<String, String>> result = ((MapProxyImpl<String, String>) map).entrySet(Predicates.alwaysTrue(), partitionSubset);
assertEquals(2, result.size());
for (String key : matchingKeys) {
assertResultContains(result, key, key);
}
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapValuesTest method whenSelectingPartitionSubset_withIndex.
@Test
public void whenSelectingPartitionSubset_withIndex() {
PartitionIdSet partitionSubset = new PartitionIdSet(4, asList(1, 3));
Set<String> matchingKeys = new HashSet<>();
map = instance.getMap("indexed");
for (int i = 0; i < 5; i++) {
String key = generateKeyForPartition(instance, i);
map.put(key, key);
if (partitionSubset.contains(i)) {
matchingKeys.add(key);
}
}
// "" is sorted before any non-null string - internally all items from all partitions are added
// to the result (because the index is global), but there's a code that eliminates partitions not
// in the subset - this test aims to test that code
Predicate<String, String> predicate = Predicates.greaterThan("this", "");
Collection<String> result = ((MapProxyImpl<String, String>) map).values(predicate, partitionSubset);
assertEquals(2, result.size());
assertEquals(matchingKeys, result);
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapValuesTest method whenSelectingPartitionSubset.
@Test
public void whenSelectingPartitionSubset() {
PartitionIdSet partitionSubset = new PartitionIdSet(4, asList(1, 3));
Set<String> matchingKeys = new HashSet<>();
for (int i = 0; i < 5; i++) {
String key = generateKeyForPartition(instance, i);
map.put(key, key);
if (partitionSubset.contains(i)) {
matchingKeys.add(key);
}
}
Collection<String> result = ((MapProxyImpl<String, String>) map).values(Predicates.alwaysTrue(), partitionSubset);
assertEquals(matchingKeys, result);
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapValuesTest method when_selectingPartitionSubset_and_partitionPredicate.
@Test
public void when_selectingPartitionSubset_and_partitionPredicate() {
PartitionIdSet partitionSubset = new PartitionIdSet(4, asList(1, 3));
Set<String> matchingKeys = new HashSet<>();
String key1 = null;
for (int i = 0; i < 5; i++) {
String key = generateKeyForPartition(instance, i);
if (i == 1) {
key1 = key;
}
map.put(key, key);
if (partitionSubset.contains(i)) {
matchingKeys.add(key);
}
}
Collection<String> result = ((MapProxyImpl<String, String>) map).values(partitionPredicate(key1, Predicates.alwaysTrue()), partitionSubset);
assertEquals(Collections.singleton(key1), result);
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testFullScan.
@Test
public void testFullScan() throws ExecutionException, InterruptedException {
PartitionIdSet partitions = getLocalPartitions(instance);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(null, true, null, true, false, null);
MapOperationProvider operationProvider = getOperationProvider(map);
MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 20);
Address address = instance.getCluster().getLocalMember().getAddress();
OperationServiceImpl operationService = getOperationService(instance);
MapFetchIndexOperationResult result = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).<MapFetchIndexOperationResult>invoke().get();
assertResultSorted(result, Arrays.asList(new Person("person6", null, "Dep1"), new Person("person7", null, null), new Person("person2", 39, "Dep1"), new Person("person5", 43, "Dep2"), new Person("person1", 45, "Dep1"), new Person("person4", 45, "Dep2"), new Person("person9", 45, "Dep3"), new Person("person10", 45, "Dep4"), new Person("person11", 45, "Dep5"), new Person("person3", 60, "Dep1"), new Person("person8", 79, null)));
}
Aggregations