ClickHouse/dbms/src/Dictionaries/RedisBlockInputStream.h

58 lines
1.4 KiB
C++
Raw Normal View History

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>
# 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:
using RedisArray = Poco::Redis::Array;
using RedisBulkString = Poco::Redis::BulkString;
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_,
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;
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