2021-12-09 10:39:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
#include <condition_variable>
|
2021-12-09 10:39:28 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include <base/types.h>
|
|
|
|
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/ReadBuffer.h>
|
|
|
|
|
|
|
|
#include <Storages/MergeTree/MarkRange.h>
|
2023-02-03 13:34:18 +00:00
|
|
|
#include <Storages/MergeTree/RangesInDataPart.h>
|
2021-12-09 10:39:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
enum class CoordinationMode
|
|
|
|
{
|
|
|
|
Default,
|
|
|
|
/// For reading in order
|
|
|
|
WithOrder,
|
|
|
|
ReverseOrder
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Represents a segment [left; right]
|
2021-12-09 10:39:28 +00:00
|
|
|
struct PartBlockRange
|
|
|
|
{
|
|
|
|
Int64 begin;
|
|
|
|
Int64 end;
|
|
|
|
|
|
|
|
bool operator==(const PartBlockRange & rhs) const
|
|
|
|
{
|
|
|
|
return begin == rhs.begin && end == rhs.end;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
struct ParallelReadRequest
|
2021-12-09 10:39:28 +00:00
|
|
|
{
|
2023-02-03 13:34:18 +00:00
|
|
|
CoordinationMode mode;
|
|
|
|
size_t replica_num;
|
|
|
|
size_t min_number_of_marks;
|
|
|
|
|
|
|
|
/// Extension for ordered mode
|
|
|
|
RangesInDataPartsDescription description;
|
2021-12-09 10:39:28 +00:00
|
|
|
|
|
|
|
void serialize(WriteBuffer & out) const;
|
2023-02-03 13:34:18 +00:00
|
|
|
String describe() const;
|
2021-12-09 10:39:28 +00:00
|
|
|
void deserialize(ReadBuffer & in);
|
2023-02-03 13:34:18 +00:00
|
|
|
void merge(ParallelReadRequest & other);
|
|
|
|
};
|
2021-12-09 10:39:28 +00:00
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
struct ParallelReadResponse
|
|
|
|
{
|
|
|
|
bool finish{false};
|
|
|
|
RangesInDataPartsDescription description;
|
2022-11-14 06:13:42 +00:00
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
void serialize(WriteBuffer & out) const;
|
|
|
|
String describe() const;
|
|
|
|
void deserialize(ReadBuffer & in);
|
2021-12-09 10:39:28 +00:00
|
|
|
};
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
|
|
|
|
struct InitialAllRangesAnnouncement
|
2021-12-09 10:39:28 +00:00
|
|
|
{
|
2023-02-03 13:34:18 +00:00
|
|
|
RangesInDataPartsDescription description;
|
|
|
|
size_t replica_num;
|
2021-12-09 10:39:28 +00:00
|
|
|
|
|
|
|
void serialize(WriteBuffer & out) const;
|
2023-02-03 13:34:18 +00:00
|
|
|
String describe();
|
2021-12-09 10:39:28 +00:00
|
|
|
void deserialize(ReadBuffer & in);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
using MergeTreeAllRangesCallback = std::function<void(InitialAllRangesAnnouncement)>;
|
|
|
|
using MergeTreeReadTaskCallback = std::function<std::optional<ParallelReadResponse>(ParallelReadRequest)>;
|
2021-12-09 10:39:28 +00:00
|
|
|
|
|
|
|
}
|