2023-05-17 02:42:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/Redis/Redis.h>
|
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <Dictionaries/RedisSource.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
/* Implements storage in the Redis.
|
2023-05-23 07:31:50 +00:00
|
|
|
* Use ENGINE = Redis(host:port, db_index, password, storage_type, conn_pool_size);
|
2023-05-17 02:42:52 +00:00
|
|
|
* Read only.
|
2023-05-23 07:31:50 +00:00
|
|
|
*
|
|
|
|
* Note If storage_type is
|
|
|
|
* simple: there should be 2 columns and the first one is key in Redis, the second one is value.
|
|
|
|
* hash_map: there should be 3 columns and the first one is key in Redis and the second is the field of Redis Map.
|
2023-05-17 02:42:52 +00:00
|
|
|
*/
|
|
|
|
class StorageRedis : public IStorage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StorageRedis(
|
|
|
|
const StorageID & table_id_,
|
2023-05-20 03:48:57 +00:00
|
|
|
const RedisConfiguration & configuration_,
|
2023-05-17 02:42:52 +00:00
|
|
|
const ColumnsDescription & columns_,
|
|
|
|
const ConstraintsDescription & constraints_,
|
|
|
|
const String & comment_);
|
|
|
|
|
|
|
|
std::string getName() const override { return "Redis"; }
|
|
|
|
|
|
|
|
Pipe read(
|
|
|
|
const Names & column_names,
|
|
|
|
const StorageSnapshotPtr & storage_snapshot,
|
|
|
|
SelectQueryInfo & query_info,
|
|
|
|
ContextPtr context,
|
|
|
|
QueryProcessingStage::Enum processed_stage,
|
|
|
|
size_t max_block_size,
|
|
|
|
size_t num_streams) override;
|
|
|
|
|
|
|
|
SinkToStoragePtr write(
|
|
|
|
const ASTPtr & query,
|
|
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
|
|
|
ContextPtr context) override;
|
|
|
|
|
2023-05-20 03:48:57 +00:00
|
|
|
static RedisConfiguration getConfiguration(ASTs engine_args, ContextPtr context);
|
|
|
|
|
2023-05-17 02:42:52 +00:00
|
|
|
private:
|
|
|
|
StorageID table_id;
|
2023-05-20 03:48:57 +00:00
|
|
|
RedisConfiguration configuration;
|
|
|
|
|
2023-05-23 07:31:50 +00:00
|
|
|
Poco::Logger * log;
|
2023-05-20 03:48:57 +00:00
|
|
|
RedisPoolPtr pool;
|
2023-05-17 02:42:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|