mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
#pragma once
|
|
#include <Processors/Sources/SourceWithProgress.h>
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
#include <Storages/MergeTree/IMergeTreeReader.h>
|
|
#include <Storages/MergeTree/MarkRange.h>
|
|
#include <memory>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Lightweight (in terms of logic) stream for reading single part from MergeTree
|
|
class MergeTreeSequentialSource : public SourceWithProgress
|
|
{
|
|
public:
|
|
MergeTreeSequentialSource(
|
|
const MergeTreeData & storage_,
|
|
const StorageMetadataPtr & metadata_snapshot_,
|
|
MergeTreeData::DataPartPtr data_part_,
|
|
Names columns_to_read_,
|
|
bool read_with_direct_io_,
|
|
bool take_column_types_from_storage,
|
|
bool quiet = false);
|
|
|
|
~MergeTreeSequentialSource() override;
|
|
|
|
String getName() const override { return "MergeTreeSequentialSource"; }
|
|
|
|
size_t getCurrentMark() const { return current_mark; }
|
|
|
|
size_t getCurrentRow() const { return current_row; }
|
|
|
|
protected:
|
|
Chunk generate() override;
|
|
|
|
private:
|
|
|
|
const MergeTreeData & storage;
|
|
StorageMetadataPtr metadata_snapshot;
|
|
|
|
/// Data part will not be removed if the pointer owns it
|
|
MergeTreeData::DataPartPtr data_part;
|
|
|
|
/// Columns we have to read (each Block from read will contain them)
|
|
Names columns_to_read;
|
|
|
|
/// Should read using direct IO
|
|
bool read_with_direct_io;
|
|
|
|
Poco::Logger * log = &Poco::Logger::get("MergeTreeSequentialSource");
|
|
|
|
std::shared_ptr<MarkCache> mark_cache;
|
|
using MergeTreeReaderPtr = std::unique_ptr<IMergeTreeReader>;
|
|
MergeTreeReaderPtr reader;
|
|
|
|
/// current mark at which we stop reading
|
|
size_t current_mark = 0;
|
|
|
|
/// current row at which we stop reading
|
|
size_t current_row = 0;
|
|
|
|
private:
|
|
/// Closes readers and unlock part locks
|
|
void finish();
|
|
};
|
|
|
|
}
|