use of io.pravega.client.tables.impl.HashTableIteratorItem in project pravega by pravega.
the class SegmentHelper method readTableKeys.
public CompletableFuture<HashTableIteratorItem<TableSegmentKey>> readTableKeys(final String tableName, final PravegaNodeUri uri, final int suggestedKeyCount, final HashTableIteratorItem.State state, final String delegationToken, final long clientRequestId) {
final WireCommandType type = WireCommandType.READ_TABLE_KEYS;
RawClient connection = new RawClient(uri, connectionPool);
final long requestId = connection.getFlow().asLong();
final HashTableIteratorItem.State token = (state == null) ? HashTableIteratorItem.State.EMPTY : state;
WireCommands.TableIteratorArgs args = new WireCommands.TableIteratorArgs(token.getToken(), Unpooled.EMPTY_BUFFER, Unpooled.EMPTY_BUFFER, Unpooled.EMPTY_BUFFER);
WireCommands.ReadTableKeys request = new WireCommands.ReadTableKeys(requestId, tableName, delegationToken, suggestedKeyCount, args);
return sendRequest(connection, clientRequestId, request).thenApply(rpl -> {
handleReply(clientRequestId, rpl, connection, tableName, WireCommands.ReadTableKeys.class, type);
WireCommands.TableKeysRead tableKeysRead = (WireCommands.TableKeysRead) rpl;
final HashTableIteratorItem.State newState = HashTableIteratorItem.State.fromBytes(tableKeysRead.getContinuationToken());
final List<TableSegmentKey> keys = tableKeysRead.getKeys().stream().map(k -> TableSegmentKey.versioned(k.getData(), k.getKeyVersion())).collect(Collectors.toList());
return new HashTableIteratorItem<>(newState, keys);
});
}
Aggregations