Search in sources :

Example 1 with IterationPointer

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);
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer)

Example 2 with IterationPointer

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);
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider)

Example 3 with IterationPointer

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);
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) Query(com.hazelcast.map.impl.query.Query) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) Predicate(com.hazelcast.query.Predicate)

Example 4 with IterationPointer

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();
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer)

Example 5 with IterationPointer

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);
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer)

Aggregations

IterationPointer (com.hazelcast.internal.iteration.IterationPointer)37 Data (com.hazelcast.internal.serialization.Data)9 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)4 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)4 ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)4 AbstractMap (java.util.AbstractMap)4 ArrayList (java.util.ArrayList)4 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)3 Map (java.util.Map)3 CacheEntriesWithCursor (com.hazelcast.cache.impl.CacheEntriesWithCursor)2 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)2 SampleableConcurrentHashMap (com.hazelcast.internal.util.SampleableConcurrentHashMap)2 MapEntriesWithCursor (com.hazelcast.map.impl.iterator.MapEntriesWithCursor)2 CacheKeysWithCursor (com.hazelcast.cache.impl.CacheKeysWithCursor)1 CacheOperationProvider (com.hazelcast.cache.impl.CacheOperationProvider)1 CacheIterateCodec (com.hazelcast.client.impl.protocol.codec.CacheIterateCodec)1 CacheIterateEntriesCodec (com.hazelcast.client.impl.protocol.codec.CacheIterateEntriesCodec)1 MapFetchEntriesCodec (com.hazelcast.client.impl.protocol.codec.MapFetchEntriesCodec)1 MapFetchKeysCodec (com.hazelcast.client.impl.protocol.codec.MapFetchKeysCodec)1 MapFetchWithQueryCodec (com.hazelcast.client.impl.protocol.codec.MapFetchWithQueryCodec)1