Skip to content

Commit

Permalink
Fixes for vector_size=64, including a fix to NLJ and a fix to properl…
Browse files Browse the repository at this point in the history
…y set vector types in Gather::Set
  • Loading branch information
Mytherin committed Feb 19, 2020
1 parent ab068b1 commit ff8540e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/common/vector_operations/gather.cpp
Expand Up @@ -65,6 +65,7 @@ template <class LOOP, class OP> static void generic_gather_loop(Vector &source,
if (source.type != TypeId::POINTER) {
throw InvalidTypeException(source.type, "Cannot gather from non-pointer type!");
}
dest.vector_type = VectorType::FLAT_VECTOR;
switch (dest.type) {
case TypeId::BOOL:
case TypeId::INT8:
Expand Down
2 changes: 2 additions & 0 deletions src/execution/operator/join/physical_hash_join.cpp
Expand Up @@ -201,6 +201,8 @@ void PhysicalHashJoin::GetChunkInternal(ClientContext &context, DataChunk &chunk
} else {
return;
}
#else
return;
#endif
} while (true);
}
24 changes: 21 additions & 3 deletions src/execution/operator/join/physical_nested_loop_join.cpp
Expand Up @@ -85,7 +85,7 @@ static void ConstructSemiOrAntiJoinResult(DataChunk &left, DataChunk &result, bo
}
result.SetCardinality(result_count, result.owned_sel_vector);
} else {
assert(result.size() == 0);
result.SetCardinality(0);
}
}

Expand Down Expand Up @@ -147,13 +147,30 @@ void PhysicalNestedLoopJoin::GetChunkInternal(ClientContext &context, DataChunk
bool found_match[STANDARD_VECTOR_SIZE] = {false};
ConstructMarkJoinResult(state->left_join_condition, state->child_chunk, chunk, found_match,
state->has_null);
} else if (type == JoinType::ANTI) {
// ANTI join, just pull chunk from RHS
children[0]->GetChunk(context, chunk, state->child_state.get());
} else if (type == JoinType::LEFT) {
children[0]->GetChunk(context, state->child_chunk, state->child_state.get());
if (state->child_chunk.size() == 0) {
return;
}
chunk.SetCardinality(state->child_chunk);
index_t idx = 0;
for(; idx < state->child_chunk.column_count(); idx++) {
chunk.data[idx].Reference(state->child_chunk.data[idx]);
}
for(; idx < chunk.column_count(); idx++) {
chunk.data[idx].vector_type = VectorType::CONSTANT_VECTOR;
chunk.data[idx].nullmask[0] = true;
}
} else {
throw Exception("Unhandled type for empty NL join");
}
return;
}

if (state->right_chunk >= state->right_chunks.chunks.size()) {
if ((type == JoinType::INNER || type == JoinType::LEFT) && state->right_chunk >= state->right_chunks.chunks.size()) {
return;
}
// now that we have fully materialized the right child
Expand Down Expand Up @@ -209,7 +226,8 @@ void PhysicalNestedLoopJoin::GetChunkInternal(ClientContext &context, DataChunk
ConstructSemiOrAntiJoinResult<false>(state->child_chunk, chunk, found_match);
}
// move to the next LHS chunk in the next iteration
state->right_chunk = state->right_chunks.chunks.size();
state->right_tuple = state->right_chunks.chunks[state->right_chunk]->size();
state->right_chunk = state->right_chunks.chunks.size() - 1;
return;
}
default:
Expand Down
2 changes: 1 addition & 1 deletion src/include/duckdb/common/constants.hpp
Expand Up @@ -33,7 +33,7 @@ using std::vector;
#define STANDARD_VECTOR_SIZE 1024
#endif

#if (STANDARD_VECTOR_SIZE < 128) || ((STANDARD_VECTOR_SIZE & (STANDARD_VECTOR_SIZE - 1)) != 0)
#if (STANDARD_VECTOR_SIZE < 64) || ((STANDARD_VECTOR_SIZE & (STANDARD_VECTOR_SIZE - 1)) != 0)
#error Vector size should be a power of two and bigger than or equal to 128
#endif

Expand Down
Expand Up @@ -12,7 +12,6 @@
#include "duckdb/execution/operator/join/physical_comparison_join.hpp"

namespace duckdb {

index_t nested_loop_join(ExpressionType op, Vector &left, Vector &right, index_t &lpos, index_t &rpos, sel_t lvector[],
sel_t rvector[]);
index_t nested_loop_comparison(ExpressionType op, Vector &left, Vector &right, sel_t lvector[], sel_t rvector[],
Expand Down
2 changes: 1 addition & 1 deletion test/common/test_ops.cpp
Expand Up @@ -162,7 +162,7 @@ TEST_CASE("Scatter/gather numeric vectors", "[vector_ops]") {
}

static void require_generate(TypeId t) {
VectorCardinality cardinality(100);
VectorCardinality cardinality(8);
Vector v(cardinality, t);
VectorOperations::GenerateSequence(v, 42, 1);
for (size_t i = 0; i < v.size(); i++) {
Expand Down

0 comments on commit ff8540e

Please sign in to comment.