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-25 09:12:56 +00:00
|
|
|
* Use ENGINE = Redis(host:port, db_index, password, storage_type, 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
|
2023-05-23 08:42:46 +00:00
|
|
|
* 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;
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|