ClickHouse/src/Storages/PartitionedSink.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
C++
Raw Normal View History

2021-10-26 12:22:13 +00:00
#pragma once
#include <Common/HashTable/HashMap.h>
#include <Common/Arena.h>
#include <absl/container/flat_hash_map.h>
2021-10-25 16:23:44 +00:00
#include <Processors/Sinks/SinkToStorage.h>
#include <Interpreters/ExpressionAnalyzer.h>
#include <Interpreters/Context_fwd.h>
namespace DB
{
class PartitionedSink : public SinkToStorage
{
public:
static constexpr auto PARTITION_ID_WILDCARD = "{_partition_id}";
PartitionedSink(const ASTPtr & partition_by, ContextPtr context_, const Block & sample_block_);
String getName() const override { return "PartitionedSink"; }
void consume(Chunk chunk) override;
2023-06-22 09:09:26 +00:00
void onException(std::exception_ptr exception) override;
2021-10-25 16:23:44 +00:00
void onFinish() override;
virtual SinkPtr createSinkForPartition(const String & partition_id) = 0;
static void validatePartitionKey(const String & str, bool allow_slash);
static String replaceWildcards(const String & haystack, const String & partition_id);
private:
ContextPtr context;
Block sample_block;
ExpressionActionsPtr partition_by_expr;
String partition_by_column_name;
absl::flat_hash_map<StringRef, SinkPtr> partition_id_to_sink;
HashMapWithSavedHash<StringRef, size_t> partition_id_to_chunk_index;
IColumn::Selector chunk_row_index_to_partition_index;
Arena partition_keys_arena;
SinkPtr getSinkForPartitionKey(StringRef partition_key);
2021-10-25 16:23:44 +00:00
};
}