Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
ARROW-14911: [C++] arrow-compute-hash-join-node-test failed by westonpace · Pull Request #12894 · apache/arrow · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-14911: [C++] arrow-compute-hash-join-node-test failed by westonpace · Pull Request #12894 · apache/arrow · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-14911: [C++] arrow-compute-hash-join-node-test failed by westonpace · Pull Request #12894 · apache/arrow · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' ARROW-14911: [C++] arrow-compute-hash-join-node-test failed by westonpace · Pull Request #12894 · apache/arrow · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-14911: [C++] arrow-compute-hash-join-node-test failed by westonpace · Pull Request #12894 · apache/arrow · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); ARROW-14911: [C++] arrow-compute-hash-join-node-test failed by westonpace · Pull Request #12894 · apache/arrow · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -576,8 +576,7 @@ class HashJoinNode : public ExecNode {
{{"node.label", label()},
{"node.detail", ToString()},
{"node.kind", kind_name()}});
finished_ = Future<>::Make();
END_SPAN_ON_FUTURE_COMPLETION(span_, finished_, this);
END_SPAN_ON_FUTURE_COMPLETION(span_, finished(), this);

bool use_sync_execution = !(plan_->exec_context()->executor());
size_t num_threads = use_sync_execution ? 1 : thread_indexer_.Capacity();
Expand DownExpand Up@@ -609,11 +608,11 @@ class HashJoinNode : public ExecNode {
for (auto&& input : inputs_) {
input->StopProducing(this);
}
impl_->Abort([this]() { finished_.MarkFinished(); });
impl_->Abort([this]() { ARROW_UNUSED(task_group_.End()); });
}
}

Future<> finished() override { return finished_; }
Future<> finished() override { return task_group_.OnFinished(); }

private:
void OutputBatchCallback(ExecBatch batch) {
Expand All@@ -624,14 +623,14 @@ class HashJoinNode : public ExecNode {
bool expected = false;
if (complete_.compare_exchange_strong(expected, true)) {
outputs_[0]->InputFinished(this, static_cast<int>(total_num_batches));
finished_.MarkFinished();
ARROW_UNUSED(task_group_.End());
}
}

Status ScheduleTaskCallback(std::function<Status(size_t)> func) {
auto executor = plan_->exec_context()->executor();
if (executor) {
RETURN_NOT_OK(executor->Spawn([this, func] {
ARROW_ASSIGN_OR_RAISE(auto task_fut, executor->Submit([this, func] {
size_t thread_index = thread_indexer_();
Status status = func(thread_index);
if (!status.ok()) {
Expand All@@ -640,6 +639,7 @@ class HashJoinNode : public ExecNode {
return;
}
}));
return task_group_.AddTask(task_fut);
} else {
// We should not get here in serial execution mode
ARROW_DCHECK(false);
Expand All@@ -656,6 +656,7 @@ class HashJoinNode : public ExecNode {
ThreadIndexer thread_indexer_;
std::unique_ptr<HashJoinSchema> schema_mgr_;
std::unique_ptr<HashJoinImpl> impl_;
util::AsyncTaskGroup task_group_;
};

namespace internal {
Expand Down
53 changes: 31 additions & 22 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,43 +883,49 @@ std::shared_ptr<Table> HashJoinSimple(
return Table::Make(schema, result, result[0]->length());
}

void HashJoinWithExecPlan(Random64Bit& rng, bool parallel,
const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l,
int num_batches_r, std::shared_ptr<Table>* output) {
Result<std::vector<ExecBatch>> HashJoinWithExecPlan(
Random64Bit& rng, bool parallel, const HashJoinNodeOptions& join_options,
const std::shared_ptr<Schema>& output_schema,
const std::vector<std::shared_ptr<Array>>& l,
const std::vector<std::shared_ptr<Array>>& r, int num_batches_l, int num_batches_r) {
auto exec_ctx = arrow::internal::make_unique<ExecContext>(
default_memory_pool(), parallel ? arrow::internal::GetCpuThreadPool() : nullptr);

ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ARROW_ASSIGN_OR_RAISE(auto plan, ExecPlan::Make(exec_ctx.get()));

// add left source
BatchesWithSchema l_batches = TableToBatches(rng, num_batches_l, l, "l_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * l_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{l_batches.schema, l_batches.gen(parallel,
/*slow=*/false)}));
/*slow=*/true)}));

// add right source
BatchesWithSchema r_batches = TableToBatches(rng, num_batches_r, r, "r_");
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
ExecNode * r_source,
MakeExecNode("source", plan.get(), {},
SourceNodeOptions{r_batches.schema, r_batches.gen(parallel,
/*slow=*/false)}));

ASSERT_OK_AND_ASSIGN(ExecNode * join, MakeExecNode("hashjoin", plan.get(),
{l_source, r_source}, join_options));
ARROW_ASSIGN_OR_RAISE(
ExecNode * join,
MakeExecNode("hashjoin", plan.get(), {l_source, r_source}, join_options));

AsyncGenerator<util::optional<ExecBatch>> sink_gen;
ASSERT_OK_AND_ASSIGN(
ARROW_ASSIGN_OR_RAISE(
std::ignore, MakeExecNode("sink", plan.get(), {join}, SinkNodeOptions{&sink_gen}));

ASSERT_FINISHES_OK_AND_ASSIGN(auto res, StartAndCollect(plan.get(), sink_gen));

ASSERT_OK_AND_ASSIGN(*output, TableFromExecBatches(output_schema, res));
auto batches_fut = StartAndCollect(plan.get(), sink_gen);
if (!batches_fut.Wait(::arrow::kDefaultAssertFinishesWaitSeconds)) {
plan->StopProducing();
// If this second wait fails then there isn't much we can do. We will abort
// and probably get a segmentation fault.
plan->finished().Wait(::arrow::kDefaultAssertFinishesWaitSeconds);
return Status::Invalid("Plan did not finish in a reasonable amount of time");
}
return batches_fut.result();
}

TEST(HashJoin, Suffix) {
Expand DownExpand Up@@ -1161,12 +1167,15 @@ TEST(HashJoin, Random) {
}
std::shared_ptr<Schema> output_schema =
std::make_shared<Schema>(std::move(output_schema_fields));
std::shared_ptr<Table> output_rows_test;
HashJoinWithExecPlan(rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size)),
&output_rows_test);
ASSERT_OK_AND_ASSIGN(
auto batches, HashJoinWithExecPlan(
rng, parallel, join_options, output_schema,
shuffled_input_arrays[0], shuffled_input_arrays[1],
static_cast<int>(bit_util::CeilDiv(num_rows_l, batch_size)),
static_cast<int>(bit_util::CeilDiv(num_rows_r, batch_size))));

ASSERT_OK_AND_ASSIGN(auto output_rows_test,
TableFromExecBatches(output_schema, batches));

// Compare results
AssertTablesEqual(output_rows_ref, output_rows_test);
Expand Down