Search in sources :

Example 16 with IterationPointer

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

the class CacheIterateEntriesMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    if (response == null) {
        return CacheIterateEntriesCodec.encodeResponse(Collections.emptyList(), Collections.emptyList());
    }
    CacheEntriesWithCursor iteratorResult = (CacheEntriesWithCursor) response;
    IterationPointer[] pointers = iteratorResult.getPointers();
    return CacheIterateEntriesCodec.encodeResponse(encodePointers(pointers), iteratorResult.getEntries());
}
Also used : CacheEntriesWithCursor(com.hazelcast.cache.impl.CacheEntriesWithCursor) IterationPointer(com.hazelcast.internal.iteration.IterationPointer)

Example 17 with IterationPointer

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

the class ClientMapQueryPartitionIterator method fetch.

@Override
protected List<Data> fetch() {
    HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
    ClientMessage request = MapFetchWithQueryCodec.encodeRequest(mapProxy.getName(), encodePointers(pointers), fetchSize, getSerializationService().toData(query.getProjection()), getSerializationService().toData(query.getPredicate()));
    ClientInvocation clientInvocation = new ClientInvocation(client, request, mapProxy.getName(), partitionId);
    try {
        ClientInvocationFuture f = clientInvocation.invoke();
        MapFetchWithQueryCodec.ResponseParameters responseParameters = MapFetchWithQueryCodec.decodeResponse(f.get());
        List<Data> results = responseParameters.results;
        IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
        setLastTableIndex(results, pointers);
        return results;
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) Data(com.hazelcast.internal.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) MapFetchWithQueryCodec(com.hazelcast.client.impl.protocol.codec.MapFetchWithQueryCodec) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 18 with IterationPointer

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

the class ClientMapPartitionIterator method fetchWithPrefetchValues.

private List fetchWithPrefetchValues(HazelcastClientInstanceImpl client) {
    ClientMessage request = MapFetchEntriesCodec.encodeRequest(mapProxy.getName(), encodePointers(pointers), fetchSize);
    ClientInvocation clientInvocation = new ClientInvocation(client, request, mapProxy.getName(), partitionId);
    try {
        ClientInvocationFuture f = clientInvocation.invoke();
        MapFetchEntriesCodec.ResponseParameters responseParameters = MapFetchEntriesCodec.decodeResponse(f.get());
        IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
        setIterationPointers(responseParameters.entries, pointers);
        return responseParameters.entries;
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) MapFetchEntriesCodec(com.hazelcast.client.impl.protocol.codec.MapFetchEntriesCodec) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 19 with IterationPointer

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

the class CacheKeysWithCursor method writeData.

@Override
public void writeData(ObjectDataOutput out) throws IOException {
    out.writeInt(pointers.length);
    for (IterationPointer pointer : pointers) {
        out.writeInt(pointer.getIndex());
        out.writeInt(pointer.getSize());
    }
    int size = keys.size();
    out.writeInt(size);
    for (Data o : keys) {
        IOUtil.writeData(out, o);
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) Data(com.hazelcast.internal.serialization.Data)

Example 20 with IterationPointer

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

the class CacheKeysWithCursor method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    int pointersCount = in.readInt();
    pointers = new IterationPointer[pointersCount];
    for (int i = 0; i < pointersCount; i++) {
        pointers[i] = new IterationPointer(in.readInt(), in.readInt());
    }
    int size = in.readInt();
    keys = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        Data data = IOUtil.readData(in);
        keys.add(data);
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) Data(com.hazelcast.internal.serialization.Data)

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