2021-06-09 02:03:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-09-04 17:04:35 +00:00
|
|
|
#include <Processors/Sources/SourceWithProgress.h>
|
2021-06-09 02:03:36 +00:00
|
|
|
|
|
|
|
#include <Storages/FileLog/ReadBufferFromFileLog.h>
|
|
|
|
#include <Storages/FileLog/StorageFileLog.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
class Logger;
|
|
|
|
}
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-09-04 17:04:35 +00:00
|
|
|
class FileLogSource : public SourceWithProgress
|
2021-06-09 02:03:36 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-09-04 17:04:35 +00:00
|
|
|
FileLogSource(
|
2021-06-09 02:03:36 +00:00
|
|
|
StorageFileLog & storage_,
|
|
|
|
const StorageMetadataPtr & metadata_snapshot_,
|
2021-09-04 17:04:35 +00:00
|
|
|
const ContextPtr & context_,
|
2021-06-09 02:03:36 +00:00
|
|
|
const Names & columns,
|
2021-09-04 17:04:35 +00:00
|
|
|
size_t max_block_size_,
|
|
|
|
size_t poll_time_out_,
|
|
|
|
size_t stream_number_,
|
|
|
|
size_t max_streams_number_);
|
2021-06-09 02:03:36 +00:00
|
|
|
|
2021-07-04 06:16:40 +00:00
|
|
|
bool isStalled() { return !buffer || buffer->isStalled(); }
|
|
|
|
|
2021-09-04 17:04:35 +00:00
|
|
|
protected:
|
|
|
|
Chunk generate() override;
|
|
|
|
|
2021-06-09 02:03:36 +00:00
|
|
|
private:
|
|
|
|
StorageFileLog & storage;
|
|
|
|
StorageMetadataPtr metadata_snapshot;
|
|
|
|
ContextPtr context;
|
|
|
|
Names column_names;
|
|
|
|
UInt64 max_block_size;
|
|
|
|
|
2021-09-04 17:04:35 +00:00
|
|
|
size_t poll_time_out;
|
|
|
|
|
|
|
|
size_t stream_number;
|
|
|
|
size_t max_streams_number;
|
|
|
|
|
2021-06-09 02:03:36 +00:00
|
|
|
ReadBufferFromFileLogPtr buffer;
|
|
|
|
|
2021-09-04 17:04:35 +00:00
|
|
|
bool started = false;
|
|
|
|
|
2021-06-09 02:03:36 +00:00
|
|
|
const Block non_virtual_header;
|
|
|
|
const Block virtual_header;
|
2021-09-04 17:04:35 +00:00
|
|
|
|
|
|
|
void createReadBuffer();
|
2021-06-09 02:03:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|