2015-08-16 07:01:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
2017-07-28 17:34:02 +00:00
|
|
|
#include <shared_mutex>
|
2016-08-26 21:25:05 +00:00
|
|
|
|
2017-06-06 17:18:32 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
2016-08-26 21:25:05 +00:00
|
|
|
|
2019-12-12 08:57:25 +00:00
|
|
|
#include <Core/Defines.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <Common/FileChecker.h>
|
|
|
|
#include <Common/escapeForFileName.h>
|
2015-08-16 07:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2017-06-25 00:17:08 +00:00
|
|
|
/** 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.
|
2015-08-16 07:01:41 +00:00
|
|
|
*/
|
2020-03-19 23:48:53 +00:00
|
|
|
class StorageStripeLog final : public ext::shared_ptr_helper<StorageStripeLog>, public IStorage
|
2015-08-16 07:01:41 +00:00
|
|
|
{
|
2020-02-14 10:57:09 +00:00
|
|
|
friend class StripeLogSource;
|
2019-12-12 08:57:25 +00:00
|
|
|
friend class StripeLogBlockOutputStream;
|
|
|
|
friend struct ext::shared_ptr_helper<StorageStripeLog>;
|
2015-08-16 07:01:41 +00:00
|
|
|
|
|
|
|
public:
|
2019-12-12 08:57:25 +00:00
|
|
|
String getName() const override { return "StripeLog"; }
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2020-08-03 13:54:14 +00:00
|
|
|
Pipe read(
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
2020-06-15 19:08:58 +00:00
|
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
2017-07-15 03:48:36 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
2018-04-19 14:47:09 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
2019-02-18 23:38:44 +00:00
|
|
|
size_t max_block_size,
|
2017-06-02 15:54:39 +00:00
|
|
|
unsigned num_streams) override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2020-06-15 19:08:58 +00:00
|
|
|
BlockOutputStreamPtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, const Context & context) override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2020-04-07 14:05:51 +00:00
|
|
|
void rename(const String & new_path_to_table_data, const StorageID & new_table_id) override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2019-07-03 13:17:19 +00:00
|
|
|
CheckResults checkData(const ASTPtr & /* query */, const Context & /* context */) override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2019-12-12 08:57:25 +00:00
|
|
|
Strings getDataPaths() const override { return {DB::fullPath(disk, table_path)}; }
|
2015-08-16 07:01:41 +00:00
|
|
|
|
2020-06-18 16:10:47 +00:00
|
|
|
void truncate(const ASTPtr &, const StorageMetadataPtr &, const Context &, TableExclusiveLockHolder&) override;
|
2018-04-21 00:35:20 +00:00
|
|
|
|
2019-12-12 08:57:25 +00:00
|
|
|
protected:
|
|
|
|
StorageStripeLog(
|
|
|
|
DiskPtr disk_,
|
2019-12-26 14:03:32 +00:00
|
|
|
const String & relative_path_,
|
2020-01-13 11:41:42 +00:00
|
|
|
const StorageID & table_id_,
|
2019-12-12 08:57:25 +00:00
|
|
|
const ColumnsDescription & columns_,
|
|
|
|
const ConstraintsDescription & constraints_,
|
|
|
|
bool attach,
|
|
|
|
size_t max_compress_block_size_);
|
|
|
|
|
2015-08-16 07:01:41 +00:00
|
|
|
private:
|
2019-12-12 08:57:25 +00:00
|
|
|
struct ColumnData
|
|
|
|
{
|
2019-12-25 08:24:13 +00:00
|
|
|
String data_file_path;
|
2019-12-12 08:57:25 +00:00
|
|
|
};
|
2019-12-25 08:24:13 +00:00
|
|
|
using Files = std::map<String, ColumnData>; /// file name -> column data
|
2019-12-12 08:57:25 +00:00
|
|
|
|
|
|
|
DiskPtr disk;
|
2019-12-26 14:03:32 +00:00
|
|
|
String table_path;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
size_t max_compress_block_size;
|
|
|
|
|
|
|
|
FileChecker file_checker;
|
2020-09-24 23:28:57 +00:00
|
|
|
mutable std::shared_mutex rwlock;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2020-05-30 21:57:37 +00:00
|
|
|
Poco::Logger * log;
|
2015-08-16 07:01:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|