stash half

This commit is contained in:
Nikita Taranov 2024-08-14 16:41:37 +01:00
parent e3caa59f83
commit 9c55ad799b
3 changed files with 55 additions and 1 deletions

View File

@ -108,6 +108,20 @@ private:
Arena & pool,
bool & is_inserted);
template <typename KeyGetter, typename HashMap, typename Selector>
static size_t insertFromBlockImplTypeCase(
HashJoin & join,
HashMap & map,
const ColumnRawPtrs & key_columns,
const Sizes & key_sizes,
Block * stored_block,
const Selector & selector,
size_t rows,
ConstNullMapPtr null_map,
UInt8ColumnDataPtr join_mask,
Arena & pool,
bool & is_inserted);
template <typename AddedColumns>
static size_t switchJoinRightColumns(
const std::vector<const MapsTemplate *> & mapv,
@ -138,6 +152,14 @@ private:
AddedColumns & added_columns,
JoinStuff::JoinUsedFlags & used_flags);
template <typename KeyGetter, typename Map, bool need_filter, bool flag_per_row, typename AddedColumns, typename Selector>
static size_t joinRightColumns(
std::vector<KeyGetter> && key_getter_vector,
const std::vector<const Map *> & mapv,
AddedColumns & added_columns,
JoinStuff::JoinUsedFlags & used_flags,
const Selector & selector);
template <bool need_filter>
static void setUsed(IColumn::Filter & filter [[maybe_unused]], size_t pos [[maybe_unused]]);

View File

@ -1,5 +1,8 @@
#pragma once
#include <type_traits>
#include <Interpreters/HashJoin/HashJoinMethods.h>
#include "Columns/IColumn.h"
#include "Interpreters/HashJoin/ScatteredBlock.h"
namespace DB
{
@ -334,6 +337,24 @@ size_t HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::joinRightColumns(
const std::vector<const Map *> & mapv,
AddedColumns & added_columns,
JoinStuff::JoinUsedFlags & used_flags)
{
auto & block = added_columns.src_block;
if (block.getSelector().isContinuousRange())
return joinRightColumns<KeyGetter, Map, need_filter, flag_per_row, AddedColumns>(
std::move(key_getter_vector), mapv, added_columns, used_flags, block.getSelector().getRange());
else
return joinRightColumns<KeyGetter, Map, need_filter, flag_per_row, AddedColumns>(
std::move(key_getter_vector), mapv, added_columns, used_flags, block.getSelector().getSelector());
}
template <JoinKind KIND, JoinStrictness STRICTNESS, typename MapsTemplate>
template <typename KeyGetter, typename Map, bool need_filter, bool flag_per_row, typename AddedColumns, typename Selector>
size_t HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::joinRightColumns(
std::vector<KeyGetter> && key_getter_vector,
const std::vector<const Map *> & mapv,
AddedColumns & added_columns,
JoinStuff::JoinUsedFlags & used_flags,
const Selector & selector)
{
constexpr JoinFeatures<KIND, STRICTNESS, MapsTemplate> join_features;
@ -352,7 +373,12 @@ size_t HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::joinRightColumns(
size_t i = 0;
for (; i < rows; ++i)
{
const auto ind = block.getSelector()[i];
size_t ind = 0;
if constexpr (std::is_same_v<std::decay_t<Selector>, IColumn::Selector>)
ind = selector[i];
else
ind = selector.first + i;
if constexpr (join_features.need_replication)
{
if (unlikely(current_offset >= max_joined_block_rows))

View File

@ -133,6 +133,12 @@ public:
return std::get<Range>(data);
}
const IColumn::Selector & getSelector() const
{
chassert(!isContinuousRange());
return std::get<IColumn::Selector>(data);
}
std::string toString() const
{
if (std::holds_alternative<Range>(data))