2019-01-15 22:08:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-17 14:55:09 +00:00
|
|
|
#include "config_core.h"
|
2019-01-15 22:08:56 +00:00
|
|
|
#include <Core/Block.h>
|
2019-09-17 14:55:09 +00:00
|
|
|
|
|
|
|
#if USE_POCO_REDIS
|
|
|
|
# include <Core/ExternalResultDescription.h>
|
|
|
|
# include <DataStreams/IBlockInputStream.h>
|
|
|
|
# include "RedisDictionarySource.h"
|
|
|
|
# include <Poco/Redis/Array.h>
|
2019-09-17 17:57:48 +00:00
|
|
|
# include <Poco/Redis/Type.h>
|
2019-01-15 22:08:56 +00:00
|
|
|
|
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
namespace Redis
|
|
|
|
{
|
|
|
|
class Client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2019-01-27 22:22:18 +00:00
|
|
|
class RedisBlockInputStream final : public IBlockInputStream
|
2019-01-15 22:08:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-09-16 16:17:56 +00:00
|
|
|
using RedisArray = Poco::Redis::Array;
|
2019-09-17 17:57:48 +00:00
|
|
|
using RedisBulkString = Poco::Redis::BulkString;
|
2019-09-16 16:17:56 +00:00
|
|
|
|
2019-01-15 22:08:56 +00:00
|
|
|
RedisBlockInputStream(
|
2019-01-27 22:22:18 +00:00
|
|
|
const std::shared_ptr<Poco::Redis::Client> & client_,
|
|
|
|
const Poco::Redis::Array & keys_,
|
2019-09-16 16:17:56 +00:00
|
|
|
const RedisStorageType & storage_type_,
|
2019-01-15 22:08:56 +00:00
|
|
|
const Block & sample_block,
|
|
|
|
const size_t max_block_size);
|
|
|
|
|
|
|
|
~RedisBlockInputStream() override;
|
|
|
|
|
|
|
|
String getName() const override { return "Redis"; }
|
|
|
|
|
|
|
|
Block getHeader() const override { return description.sample_block.cloneEmpty(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Block readImpl() override;
|
|
|
|
|
2019-01-27 22:22:18 +00:00
|
|
|
std::shared_ptr<Poco::Redis::Client> client;
|
|
|
|
Poco::Redis::Array keys;
|
2019-09-16 16:17:56 +00:00
|
|
|
RedisStorageType storage_type;
|
2019-01-15 22:08:56 +00:00
|
|
|
const size_t max_block_size;
|
|
|
|
ExternalResultDescription description;
|
2019-01-27 13:14:02 +00:00
|
|
|
size_t cursor = 0;
|
2019-01-15 22:08:56 +00:00
|
|
|
bool all_read = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2019-09-17 14:55:09 +00:00
|
|
|
|
|
|
|
#endif
|