Skip to content

Commit

Permalink
separate different streaming join
Browse files Browse the repository at this point in the history
  • Loading branch information
yl-lisen committed Dec 8, 2023
1 parent 16a408e commit 7186aa5
Show file tree
Hide file tree
Showing 36 changed files with 1,248 additions and 415 deletions.
17 changes: 0 additions & 17 deletions src/Core/BlockWithShard.h

This file was deleted.

23 changes: 23 additions & 0 deletions src/Core/DataBlockWithShard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <Core/Block.h>
#include <Core/LightChunk.h>

namespace DB
{
template <typename DataBlock>
struct DataBlockWithShard
{
DataBlock block;
int32_t shard;

DataBlockWithShard(DataBlock && block_, int32_t shard_) : block(std::move(block_)), shard(shard_) { }
};

using BlockWithShard = DataBlockWithShard<Block>;
using BlocksWithShard = std::vector<BlockWithShard>;

using LightChunkWithShard = DataBlockWithShard<LightChunk>;
using LightChunksWithShard = std::vector<LightChunkWithShard>;
}

21 changes: 19 additions & 2 deletions src/Core/LightChunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ struct LightChunk
void concat(const LightChunk & other)
{
auto added_rows = other.rows();
if (added_rows <= 0)
return;

assert(columns() == other.columns());
for (size_t c = 0; auto & col : data)
{
Expand All @@ -35,9 +38,21 @@ struct LightChunk
}
}

LightChunk cloneEmpty() const
{
LightChunk res;
res.data.reserve(data.size());

for (const auto & elem : data)
res.data.emplace_back(elem->cloneEmpty());

return res;
}

size_t rows() const noexcept { return data.empty() ? 0 : data[0]->size(); }
size_t columns() const noexcept { return data.size(); }

Columns & getColumns() noexcept { return data; }
const Columns & getColumns() const noexcept { return data; }
Columns detachColumns() noexcept { return std::move(data); }

Expand Down Expand Up @@ -88,7 +103,9 @@ struct LightChunkWithTimestamp
LightChunkWithTimestamp() = default;
LightChunkWithTimestamp(Columns && data_) : chunk(std::move(data_)) { }
LightChunkWithTimestamp(Chunk && chunk_, Int64 min_ts, Int64 max_ts)
: chunk(std::move(chunk_)), min_timestamp(min_ts), max_timestamp(max_ts) { }
: chunk(std::move(chunk_)), min_timestamp(min_ts), max_timestamp(max_ts)
{
}
LightChunkWithTimestamp(const Block & block)
: chunk(block), min_timestamp(block.minTimestamp()), max_timestamp(block.maxTimestamp()) { }

Expand Down Expand Up @@ -122,4 +139,4 @@ struct LightChunkWithTimestamp
Int64 maxTimestamp() const noexcept { return max_timestamp; }
};

}
}
2 changes: 1 addition & 1 deletion src/Interpreters/ExpressionAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ std::shared_ptr<IJoin> SelectQueryExpressionAnalyzer::chooseJoinAlgorithmStreami
return std::make_shared<Streaming::ConcurrentHashJoin>(
analyzed_join, max_threads, std::move(left_join_stream_desc), std::move(right_join_stream_desc));
else
return std::make_shared<Streaming::HashJoin>(analyzed_join, std::move(left_join_stream_desc), std::move(right_join_stream_desc));
return Streaming::HashJoin::create(analyzed_join, std::move(left_join_stream_desc), std::move(right_join_stream_desc));
}
/// proton : ends

Expand Down
17 changes: 17 additions & 0 deletions src/Interpreters/Streaming/AsofHashJoin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Interpreters/Streaming/HashJoin.h>

namespace DB
{
namespace Streaming
{
class AsofHashJoin final : public HashJoin
{
public:
using HashJoin::HashJoin;
HashJoinType type() const override { return HashJoinType::Asof; }
};

}
}
17 changes: 17 additions & 0 deletions src/Interpreters/Streaming/BidirectionalAllHashJoin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Interpreters/Streaming/HashJoin.h>

namespace DB
{
namespace Streaming
{
class BidirectionalAllHashJoin final : public HashJoin
{
public:
using HashJoin::HashJoin;
HashJoinType type() const override { return HashJoinType::BidirectionalAll; }
};

}
}
17 changes: 17 additions & 0 deletions src/Interpreters/Streaming/BidirectionalChangelogHashJoin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Interpreters/Streaming/HashJoin.h>

namespace DB
{
namespace Streaming
{
class BidirectionalChangelogHashJoin final : public HashJoin
{
public:
using HashJoin::HashJoin;
HashJoinType type() const override { return HashJoinType::BidirectionalChangelog; }
};

}
}
17 changes: 17 additions & 0 deletions src/Interpreters/Streaming/BidirectionalRangeHashJoin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Interpreters/Streaming/HashJoin.h>

namespace DB
{
namespace Streaming
{
class BidirectionalRangeHashJoin final : public HashJoin
{
public:
using HashJoin::HashJoin;
HashJoinType type() const override { return HashJoinType::BidirectionalRange; }
};

}
}
17 changes: 17 additions & 0 deletions src/Interpreters/Streaming/ChangelogHashJoin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Interpreters/Streaming/HashJoin.h>

namespace DB
{
namespace Streaming
{
class ChangelogHashJoin final : public HashJoin
{
public:
using HashJoin::HashJoin;
HashJoinType type() const override { return HashJoinType::Changelog; }
};

}
}
Loading

0 comments on commit 7186aa5

Please sign in to comment.