ClickHouse/src/Storages/StorageTinyLog.h

80 lines
2.1 KiB
C++
Raw Normal View History

2012-06-25 00:17:19 +00:00
#pragma once
2015-01-25 05:07:51 +00:00
#include <map>
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>
2012-06-25 00:17:19 +00:00
namespace DB
{
/** Implements a table engine that is suitable for small chunks of the log.
2017-04-16 15:00:33 +00:00
* It differs from StorageLog in the absence of mark files.
2012-06-25 00:17:19 +00:00
*/
class StorageTinyLog final : public ext::shared_ptr_helper<StorageTinyLog>, public IStorage
2012-06-25 00:17:19 +00:00
{
friend class TinyLogSource;
friend class TinyLogBlockOutputStream;
friend struct ext::shared_ptr_helper<StorageTinyLog>;
2012-06-25 00:17:19 +00:00
public:
String getName() const override { return "TinyLog"; }
Pipes read(
const Names & column_names,
const SelectQueryInfo & query_info,
const Context & 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 Context & 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;
2019-07-03 13:17:19 +00:00
CheckResults checkData(const ASTPtr & /* query */, const Context & /* context */) override;
Strings getDataPaths() const override { return {DB::fullPath(disk, table_path)}; }
2019-08-27 20:43:08 +00:00
void truncate(const ASTPtr &, const Context &, TableStructureWriteLockHolder &) override;
2018-04-21 00:35:20 +00:00
2020-01-22 11:30:11 +00:00
void drop() override;
protected:
StorageTinyLog(
DiskPtr disk_,
const String & relative_path_,
const StorageID & table_id_,
const ColumnsDescription & columns_,
const ConstraintsDescription & constraints_,
bool attach,
size_t max_compress_block_size_);
2012-06-25 00:17:19 +00:00
private:
struct ColumnData
{
String data_file_path;
};
using Files = std::map<String, ColumnData>; /// file name -> column data
DiskPtr disk;
String table_path;
2012-06-25 00:17:19 +00:00
size_t max_compress_block_size;
2014-03-28 14:36:24 +00:00
Files files;
2012-08-29 18:49:54 +00:00
FileChecker file_checker;
mutable std::shared_mutex rwlock;
2020-05-30 21:57:37 +00:00
Poco::Logger * log;
void addFiles(const String & column_name, const IDataType & type);
2012-06-25 00:17:19 +00:00
};
}