2012-06-25 00:17:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-01-25 05:07:51 +00:00
|
|
|
#include <map>
|
2013-07-16 14:55:01 +00:00
|
|
|
|
2017-06-06 17:18:32 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
2016-08-26 21:25:05 +00:00
|
|
|
|
2012-06-25 00:17:19 +00:00
|
|
|
#include <Poco/File.h>
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <Common/FileChecker.h>
|
|
|
|
#include <Common/escapeForFileName.h>
|
2017-07-24 12:58:01 +00:00
|
|
|
#include <Core/Defines.h>
|
2012-06-25 00:17:19 +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
|
|
|
* It differs from StorageLog in the absence of mark files.
|
2012-06-25 00:17:19 +00:00
|
|
|
*/
|
2017-06-06 18:36:13 +00:00
|
|
|
class StorageTinyLog : public ext::shared_ptr_helper<StorageTinyLog>, public IStorage
|
2012-06-25 00:17:19 +00:00
|
|
|
{
|
|
|
|
friend class TinyLogBlockInputStream;
|
|
|
|
friend class TinyLogBlockOutputStream;
|
|
|
|
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string getName() const override { return "TinyLog"; }
|
|
|
|
std::string getTableName() const override { return name; }
|
|
|
|
|
2017-12-25 21:57:29 +00:00
|
|
|
const NamesAndTypesList & getColumnsListImpl() const override { return columns; }
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
2017-07-15 03:48:36 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
2017-06-02 15:54:39 +00:00
|
|
|
size_t max_block_size,
|
|
|
|
unsigned num_streams) override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-05-21 22:25:25 +00:00
|
|
|
BlockOutputStreamPtr write(const ASTPtr & query, const Settings & settings) override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name) override;
|
|
|
|
|
|
|
|
bool checkData() const override;
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/// Column data
|
2017-04-01 07:20:54 +00:00
|
|
|
struct ColumnData
|
|
|
|
{
|
|
|
|
Poco::File data_file;
|
|
|
|
};
|
|
|
|
using Files_t = std::map<String, ColumnData>;
|
|
|
|
|
|
|
|
std::string full_path() { return path + escapeForFileName(name) + '/';}
|
2014-08-29 18:44:44 +00:00
|
|
|
|
2012-06-25 00:17:19 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
String path;
|
|
|
|
String name;
|
2017-12-25 21:57:29 +00:00
|
|
|
NamesAndTypesList columns;
|
2012-06-25 00:17:19 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t max_compress_block_size;
|
2014-03-28 14:36:24 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Files_t files;
|
2012-08-29 18:49:54 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
FileChecker file_checker;
|
2014-07-31 13:39:23 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Logger * log;
|
2014-07-31 13:39:23 +00:00
|
|
|
|
2017-11-04 03:20:18 +00:00
|
|
|
void addFile(const String & column_name, const IDataType & type, size_t level = 0);
|
2017-11-19 23:16:18 +00:00
|
|
|
void addFiles(const String & column_name, const IDataType & type);
|
2017-11-04 03:20:18 +00:00
|
|
|
|
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
StorageTinyLog(
|
|
|
|
const std::string & path_,
|
|
|
|
const std::string & name_,
|
2017-12-25 21:57:29 +00:00
|
|
|
const NamesAndTypesList & columns_,
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
2017-04-01 07:20:54 +00:00
|
|
|
const ColumnDefaults & column_defaults_,
|
|
|
|
bool attach,
|
2017-06-06 18:36:13 +00:00
|
|
|
size_t max_compress_block_size_ = DEFAULT_MAX_COMPRESS_BLOCK_SIZE);
|
2012-06-25 00:17:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|