use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.
the class CacheFetchKeysOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
super.writeInternal(out);
out.writeInt(pointers.length);
for (IterationPointer pointer : pointers) {
out.writeInt(pointer.getIndex());
out.writeInt(pointer.getSize());
}
out.writeInt(fetchSize);
}
use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.
the class MapFetchEntriesMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
IterationPointer[] pointers = decodePointers(parameters.iterationPointers);
return operationProvider.createFetchEntriesOperation(parameters.name, pointers, parameters.batch);
}
use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.
the class MapFetchWithQueryMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
Projection<?, ?> projection = nodeEngine.getSerializationService().toObject(parameters.projection);
Predicate predicate = nodeEngine.getSerializationService().toObject(parameters.predicate);
Query query = Query.of().mapName(parameters.name).iterationType(IterationType.VALUE).predicate(predicate).projection(projection).build();
IterationPointer[] pointers = decodePointers(parameters.iterationPointers);
return operationProvider.createFetchWithQueryOperation(parameters.name, pointers, parameters.batch, query);
}
use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.
the class SampleableConcurrentHashMap method fetchNext.
/**
* Fetches at most {@code size} keys starting at the given {@code pointers} and
* invokes the {@code entryConsumer} for each key-value pair.
*
* @param pointers the pointers defining the state where to begin iteration
* @param size Count of how many entries will be fetched
* @param entryConsumer the consumer to call with fetched key-value pairs
* @return the pointers defining the state where iteration has ended
*/
private IterationPointer[] fetchNext(IterationPointer[] pointers, int size, BiConsumer<K, V> entryConsumer) {
long now = Clock.currentTimeMillis();
Segment<K, V> segment = segments[0];
try {
segment.lock();
HashEntry<K, V>[] currentTable = segment.table;
int currentTableSize = currentTable.length;
pointers = checkPointers(pointers, currentTableSize);
IterationPointer lastPointer = pointers[pointers.length - 1];
int nextTableIndex;
if (lastPointer.getIndex() >= 0 && lastPointer.getIndex() < segment.table.length) {
nextTableIndex = lastPointer.getIndex();
} else {
nextTableIndex = currentTable.length - 1;
}
int counter = 0;
while (nextTableIndex >= 0 && counter < size) {
HashEntry<K, V> nextEntry = currentTable[nextTableIndex--];
while (nextEntry != null) {
V value = nextEntry.value();
if (isValidForFetching(value, now)) {
K key = nextEntry.key();
if (key != null && hasNotBeenObserved(key, pointers)) {
entryConsumer.accept(key, value);
counter++;
}
}
nextEntry = nextEntry.next;
}
}
lastPointer.setIndex(nextTableIndex);
return pointers;
} finally {
segment.unlock();
}
}
use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.
the class MapFetchWithQueryOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
super.writeInternal(out);
out.writeInt(fetchSize);
out.writeInt(pointers.length);
for (IterationPointer pointer : pointers) {
out.writeInt(pointer.getIndex());
out.writeInt(pointer.getSize());
}
out.writeObject(query);
}
Aggregations