aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/FilesystemReadPrefetchesLog.h
blob: 313c8ab5872a3da865ba0c1ea2641f7af237204d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include <Core/NamesAndAliases.h>
#include <Core/NamesAndTypes.h>
#include <Interpreters/SystemLog.h>
#include <Common/Stopwatch.h>
#include <Common/Priority.h>

namespace DB
{

enum class FilesystemPrefetchState
{
    USED,
    CANCELLED_WITH_SEEK,
    CANCELLED_WITH_RANGE_CHANGE,
    UNNEEDED,
};

struct FilesystemReadPrefetchesLogElement
{
    time_t event_time{};
    String query_id;
    String path;
    UInt64 offset;
    Int64 size; /// -1 means unknown
    std::chrono::system_clock::time_point prefetch_submit_time;
    std::optional<Stopwatch> execution_watch;
    Priority priority;
    FilesystemPrefetchState state;
    UInt64 thread_id;
    String reader_id;

    static std::string name() { return "FilesystemReadPrefetchesLog"; }

    static NamesAndTypesList getNamesAndTypes();
    static NamesAndAliases getNamesAndAliases() { return {}; }

    void appendToBlock(MutableColumns & columns) const;
    static const char * getCustomColumnList() { return nullptr; }
};

class FilesystemReadPrefetchesLog : public SystemLog<FilesystemReadPrefetchesLogElement>
{
public:
    using SystemLog<FilesystemReadPrefetchesLogElement>::SystemLog;
};

using FilesystemReadPrefetchesLogPtr = std::shared_ptr<FilesystemReadPrefetchesLog>;

}