| 1 | #pragma once | 
|---|---|
| 2 | |
| 3 | #include "config_core.h" | 
| 4 | #include <Core/Block.h> | 
| 5 | |
| 6 | #if USE_POCO_REDIS | 
| 7 | # include <Core/ExternalResultDescription.h> | 
| 8 | # include <DataStreams/IBlockInputStream.h> | 
| 9 | # include "RedisDictionarySource.h" | 
| 10 | # include <Poco/Redis/Array.h> | 
| 11 | # include <Poco/Redis/Type.h> | 
| 12 | |
| 13 | namespace Poco | 
| 14 | { | 
| 15 | namespace Redis | 
| 16 | { | 
| 17 | class Client; | 
| 18 | } | 
| 19 | } | 
| 20 | |
| 21 | |
| 22 | namespace DB | 
| 23 | { | 
| 24 | class RedisBlockInputStream final : public IBlockInputStream | 
| 25 | { | 
| 26 | public: | 
| 27 | using RedisArray = Poco::Redis::Array; | 
| 28 | using RedisBulkString = Poco::Redis::BulkString; | 
| 29 | |
| 30 | RedisBlockInputStream( | 
| 31 | const std::shared_ptr<Poco::Redis::Client> & client_, | 
| 32 | const Poco::Redis::Array & keys_, | 
| 33 | const RedisStorageType & storage_type_, | 
| 34 | const Block & sample_block, | 
| 35 | const size_t max_block_size); | 
| 36 | |
| 37 | ~RedisBlockInputStream() override; | 
| 38 | |
| 39 | String getName() const override { return "Redis"; } | 
| 40 | |
| 41 | Block getHeader() const override { return description.sample_block.cloneEmpty(); } | 
| 42 | |
| 43 | private: | 
| 44 | Block readImpl() override; | 
| 45 | |
| 46 | std::shared_ptr<Poco::Redis::Client> client; | 
| 47 | Poco::Redis::Array keys; | 
| 48 | RedisStorageType storage_type; | 
| 49 | const size_t max_block_size; | 
| 50 | ExternalResultDescription description; | 
| 51 | size_t cursor = 0; | 
| 52 | bool all_read = false; | 
| 53 | }; | 
| 54 | |
| 55 | } | 
| 56 | |
| 57 | #endif | 
| 58 | 
