Search in sources :

Example 21 with IterationPointer

use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.

the class CacheFetchEntriesOperation 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 22 with IterationPointer

use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.

the class CacheFetchKeysOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    int pointersCount = in.readInt();
    pointers = new IterationPointer[pointersCount];
    for (int i = 0; i < pointersCount; i++) {
        pointers[i] = new IterationPointer(in.readInt(), in.readInt());
    }
    fetchSize = in.readInt();
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer)

Example 23 with IterationPointer

use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.

the class ClientCacheIterator method fetch.

protected List fetch() {
    HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
    String name = cacheProxy.getPrefixedName();
    if (prefetchValues) {
        ClientMessage request = CacheIterateEntriesCodec.encodeRequest(name, encodePointers(pointers), fetchSize);
        try {
            ClientInvocation clientInvocation = new ClientInvocation(client, request, name, partitionIndex);
            ClientInvocationFuture future = clientInvocation.invoke();
            CacheIterateEntriesCodec.ResponseParameters responseParameters = CacheIterateEntriesCodec.decodeResponse(future.get());
            IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
            setIterationPointers(responseParameters.entries, pointers);
            return responseParameters.entries;
        } catch (Exception e) {
            throw rethrow(e);
        }
    } else {
        ClientMessage request = CacheIterateCodec.encodeRequest(name, encodePointers(pointers), fetchSize);
        try {
            ClientInvocation clientInvocation = new ClientInvocation(client, request, name, partitionIndex);
            ClientInvocationFuture future = clientInvocation.invoke();
            CacheIterateCodec.ResponseParameters responseParameters = CacheIterateCodec.decodeResponse(future.get());
            IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
            setIterationPointers(responseParameters.keys, pointers);
            return responseParameters.keys;
        } catch (Exception e) {
            throw rethrow(e);
        }
    }
}
Also used : CacheIterateCodec(com.hazelcast.client.impl.protocol.codec.CacheIterateCodec) CacheIterateEntriesCodec(com.hazelcast.client.impl.protocol.codec.CacheIterateEntriesCodec) IterationPointer(com.hazelcast.internal.iteration.IterationPointer) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 24 with IterationPointer

use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.

the class CacheRecordHashMap method fetchEntries.

@Override
public CacheEntriesWithCursor fetchEntries(IterationPointer[] pointers, int size) {
    List<Map.Entry<Data, CacheRecord>> entries = new ArrayList<>(size);
    IterationPointer[] newIterationPointers = fetchEntries(pointers, size, entries);
    List<Map.Entry<Data, Data>> entriesData = new ArrayList<>(entries.size());
    for (Map.Entry<Data, CacheRecord> entry : entries) {
        CacheRecord record = entry.getValue();
        Data dataValue = serializationService.toData(record.getValue());
        entriesData.add(new AbstractMap.SimpleEntry<>(entry.getKey(), dataValue));
    }
    return new CacheEntriesWithCursor(entriesData, newIterationPointers);
}
Also used : ArrayList(java.util.ArrayList) Data(com.hazelcast.internal.serialization.Data) AbstractMap(java.util.AbstractMap) IterationPointer(com.hazelcast.internal.iteration.IterationPointer) CacheEntriesWithCursor(com.hazelcast.cache.impl.CacheEntriesWithCursor) SampleableConcurrentHashMap(com.hazelcast.internal.util.SampleableConcurrentHashMap) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 25 with IterationPointer

use of com.hazelcast.internal.iteration.IterationPointer in project hazelcast by hazelcast.

the class CacheIterateMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    if (response == null) {
        return CacheIterateCodec.encodeResponse(Collections.emptyList(), Collections.emptyList());
    }
    CacheKeysWithCursor keyIteratorResult = (CacheKeysWithCursor) response;
    IterationPointer[] pointers = keyIteratorResult.getPointers();
    return CacheIterateCodec.encodeResponse(encodePointers(pointers), keyIteratorResult.getKeys());
}
Also used : CacheKeysWithCursor(com.hazelcast.cache.impl.CacheKeysWithCursor) 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