ClickHouse/src/Storages/StorageStripeLog.h

78 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
#include <map>
#include <shared_mutex>
2017-06-06 17:18:32 +00:00
#include <ext/shared_ptr_helper.h>
#include <Core/Defines.h>
#include <Storages/IStorage.h>
#include <Common/FileChecker.h>
#include <Common/escapeForFileName.h>
namespace DB
{
/** Implements a table engine that is suitable for small chunks of the log.
2017-04-16 15:00:33 +00:00
* In doing so, stores all the columns in a single Native file, with a nearby index.
*/
class StorageStripeLog final : public ext::shared_ptr_helper<StorageStripeLog>, public IStorage
{
friend class StripeLogSource;
friend class StripeLogBlockOutputStream;
friend struct ext::shared_ptr_helper<StorageStripeLog>;
public:
String getName() const override { return "StripeLog"; }
2020-08-03 13:54:14 +00:00
Pipe read(
const Names & column_names,
const StorageMetadataPtr & /*metadata_snapshot*/,
SelectQueryInfo & query_info,
ContextPtr context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
2017-06-02 15:54:39 +00:00
unsigned num_streams) override;
BlockOutputStreamPtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, ContextPtr context) override;
2020-04-07 14:05:51 +00:00
void rename(const String & new_path_to_table_data, const StorageID & new_table_id) override;
CheckResults checkData(const ASTPtr & /* query */, ContextPtr /* context */) override;
2020-11-01 17:38:43 +00:00
bool storesDataOnDisk() const override { return true; }
Strings getDataPaths() const override { return {DB::fullPath(disk, table_path)}; }
void truncate(const ASTPtr &, const StorageMetadataPtr &, ContextPtr, TableExclusiveLockHolder&) override;
2018-04-21 00:35:20 +00:00
protected:
StorageStripeLog(
DiskPtr disk_,
const String & relative_path_,
const StorageID & table_id_,
const ColumnsDescription & columns_,
const ConstraintsDescription & constraints_,
2021-04-23 12:18:23 +00:00
const String & comment,
bool attach,
size_t max_compress_block_size_);
private:
struct ColumnData
{
String data_file_path;
};
using Files = std::map<String, ColumnData>; /// file name -> column data
DiskPtr disk;
String table_path;
size_t max_compress_block_size;
FileChecker file_checker;
std::shared_timed_mutex rwlock;
2020-05-30 21:57:37 +00:00
Poco::Logger * log;
};
}