use of io.cdap.cdap.messaging.store.ScanRequest in project cdap by caskdata.
the class LevelDBMessageTable method scan.
@Override
protected CloseableIterator<RawMessageTableEntry> scan(ScanRequest scanRequest) throws IOException {
Collection<LevelDBPartition> partitions = partitionManager.getPartitions(scanRequest.getStartTime());
if (partitions.isEmpty()) {
return CloseableIterator.empty();
}
RawMessageTableEntry tableEntry = new RawMessageTableEntry();
TopicMetadata topicMetadata = scanRequest.getTopicMetadata();
byte[] topic = MessagingUtils.toDataKeyPrefix(topicMetadata.getTopicId(), topicMetadata.getGeneration());
MessageTableKey messageTableKey = MessageTableKey.fromTopic(topic);
BiFunction<byte[], byte[], RawMessageTableEntry> decodeFunction = (key, value) -> {
Map<String, byte[]> columns = decodeValue(value);
messageTableKey.setFromRowKey(key);
return tableEntry.set(messageTableKey, columns.get(TX_COL), columns.get(PAYLOAD_COL));
};
return new PartitionedDBScanIterator<>(partitions.iterator(), scanRequest.getStartRow(), scanRequest.getStopRow(), decodeFunction);
}
Aggregations