impala git commit: Revert "IMPALA-7477: Batch-oriented query set construction" [Forced Update!]

2018-11-19 Thread boroknagyz
Repository: impala
Updated Branches:
  refs/heads/branch-3.1.0 33d943b25 -> 031d5690f (forced update)


Revert "IMPALA-7477: Batch-oriented query set construction"

This reverts commit 0f63b2c9f9d62b0d22191f454b672a6047206252.


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/031d5690
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/031d5690
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/031d5690

Branch: refs/heads/branch-3.1.0
Commit: 031d5690f8a7d354da83cb34da3cc96bd0a55e86
Parents: f79f2d4
Author: Zoltan Borok-Nagy 
Authored: Mon Nov 19 17:20:32 2018 +0100
Committer: Zoltan Borok-Nagy 
Committed: Mon Nov 19 17:20:32 2018 +0100

--
 be/src/exec/plan-root-sink.cc  |  26 ++-
 be/src/exec/plan-root-sink.h   |   4 +
 be/src/service/hs2-util.cc | 318 
 be/src/service/hs2-util.h  |  15 +-
 be/src/service/query-result-set.cc | 115 +---
 be/src/service/query-result-set.h  |  14 +-
 6 files changed, 161 insertions(+), 331 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/impala/blob/031d5690/be/src/exec/plan-root-sink.cc
--
diff --git a/be/src/exec/plan-root-sink.cc b/be/src/exec/plan-root-sink.cc
index 1f5b2e5..a64dbb9 100644
--- a/be/src/exec/plan-root-sink.cc
+++ b/be/src/exec/plan-root-sink.cc
@@ -79,11 +79,22 @@ Status PlanRootSink::Send(RuntimeState* state, RowBatch* 
batch) {
 
 // Otherwise the consumer is ready. Fill out the rows.
 DCHECK(results_ != nullptr);
+// List of expr values to hold evaluated rows from the query
+vector result_row;
+result_row.resize(output_exprs_.size());
+
+// List of scales for floating point values in result_row
+vector scales;
+scales.resize(result_row.size());
+
 int num_to_fetch = batch->num_rows() - current_batch_row;
 if (num_rows_requested_ > 0) num_to_fetch = min(num_to_fetch, 
num_rows_requested_);
-RETURN_IF_ERROR(
-results_->AddRows(output_expr_evals_, batch, current_batch_row, 
num_to_fetch));
-current_batch_row += num_to_fetch;
+for (int i = 0; i < num_to_fetch; ++i) {
+  TupleRow* row = batch->GetRow(current_batch_row);
+  GetRowValue(row, _row, );
+  RETURN_IF_ERROR(results_->AddOneRow(result_row, scales));
+  ++current_batch_row;
+}
 // Prevent expr result allocations from accumulating.
 expr_results_pool_->Clear();
 // Signal the consumer.
@@ -135,4 +146,13 @@ Status PlanRootSink::GetNext(
   *eos = sender_state_ == SenderState::EOS;
   return state->GetQueryStatus();
 }
+
+void PlanRootSink::GetRowValue(
+TupleRow* row, vector* result, vector* scales) {
+  DCHECK_GE(result->size(), output_expr_evals_.size());
+  for (int i = 0; i < output_expr_evals_.size(); ++i) {
+(*result)[i] = output_expr_evals_[i]->GetValue(row);
+(*scales)[i] = output_expr_evals_[i]->output_scale();
+  }
+}
 }

http://git-wip-us.apache.org/repos/asf/impala/blob/031d5690/be/src/exec/plan-root-sink.h
--
diff --git a/be/src/exec/plan-root-sink.h b/be/src/exec/plan-root-sink.h
index 300c993..1d64b21 100644
--- a/be/src/exec/plan-root-sink.h
+++ b/be/src/exec/plan-root-sink.h
@@ -118,6 +118,10 @@ class PlanRootSink : public DataSink {
 
   /// Set by GetNext() to indicate to Send() how many rows it should write to 
results_.
   int num_rows_requested_ = 0;
+
+  /// Writes a single row into 'result' and 'scales' by evaluating
+  /// output_expr_evals_ over 'row'.
+  void GetRowValue(TupleRow* row, std::vector* result, 
std::vector* scales);
 };
 }
 

http://git-wip-us.apache.org/repos/asf/impala/blob/031d5690/be/src/service/hs2-util.cc
--
diff --git a/be/src/service/hs2-util.cc b/be/src/service/hs2-util.cc
index 66a76bd..b856556 100644
--- a/be/src/service/hs2-util.cc
+++ b/be/src/service/hs2-util.cc
@@ -18,12 +18,9 @@
 #include "service/hs2-util.h"
 
 #include "common/logging.h"
-#include "exprs/scalar-expr-evaluator.h"
 #include "runtime/decimal-value.inline.h"
 #include "runtime/raw-value.inline.h"
-#include "runtime/row-batch.h"
 #include "runtime/types.h"
-#include "util/bit-util.h"
 
 #include 
 
@@ -52,9 +49,7 @@ inline bool GetNullBit(const string& nulls, uint32_t row_idx) 
{
 
 void impala::StitchNulls(uint32_t num_rows_before, uint32_t num_rows_added,
 uint32_t start_idx, const string& from, string* to) {
-  // Round up to power-of-two to avoid accidentally quadratic behaviour from 
repeated
-  // small increases in size.
-  to->reserve(BitUtil::RoundUpToPowerOfTwo((num_rows_before + num_rows_added + 
7) / 8));
+  to->reserve((num_rows_before + num_rows_added + 7) / 8);
 
   // 

impala git commit: Revert "IMPALA-7477: Batch-oriented query set construction"

2018-09-19 Thread boroknagyz
Repository: impala
Updated Branches:
  refs/heads/master 038af3459 -> 109028e89


Revert "IMPALA-7477: Batch-oriented query set construction"

This has been implicated in some incorrect results involving nulls in
HS2.

This reverts commit b288a6af2eda9631b2bad91896ae4bfd2a3fdf30.

Change-Id: I533c12f1b4cfc5b4a372ba834913975b5c52c5a8
Reviewed-on: http://gerrit.cloudera.org:8080/11462
Tested-by: Impala Public Jenkins 
Reviewed-by: Zoltan Borok-Nagy 


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/109028e8
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/109028e8
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/109028e8

Branch: refs/heads/master
Commit: 109028e89ce27880cc2ef69a7a5032c05df4d4df
Parents: 038af34
Author: Tim Armstrong 
Authored: Tue Sep 18 09:26:33 2018 -0700
Committer: Zoltan Borok-Nagy 
Committed: Wed Sep 19 10:16:20 2018 +

--
 be/src/exec/plan-root-sink.cc  |  26 ++-
 be/src/exec/plan-root-sink.h   |   4 +
 be/src/service/hs2-util.cc | 307 +---
 be/src/service/hs2-util.h  |  15 +-
 be/src/service/query-result-set.cc | 115 +---
 be/src/service/query-result-set.h  |  14 +-
 6 files changed, 161 insertions(+), 320 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/impala/blob/109028e8/be/src/exec/plan-root-sink.cc
--
diff --git a/be/src/exec/plan-root-sink.cc b/be/src/exec/plan-root-sink.cc
index 1f5b2e5..a64dbb9 100644
--- a/be/src/exec/plan-root-sink.cc
+++ b/be/src/exec/plan-root-sink.cc
@@ -79,11 +79,22 @@ Status PlanRootSink::Send(RuntimeState* state, RowBatch* 
batch) {
 
 // Otherwise the consumer is ready. Fill out the rows.
 DCHECK(results_ != nullptr);
+// List of expr values to hold evaluated rows from the query
+vector result_row;
+result_row.resize(output_exprs_.size());
+
+// List of scales for floating point values in result_row
+vector scales;
+scales.resize(result_row.size());
+
 int num_to_fetch = batch->num_rows() - current_batch_row;
 if (num_rows_requested_ > 0) num_to_fetch = min(num_to_fetch, 
num_rows_requested_);
-RETURN_IF_ERROR(
-results_->AddRows(output_expr_evals_, batch, current_batch_row, 
num_to_fetch));
-current_batch_row += num_to_fetch;
+for (int i = 0; i < num_to_fetch; ++i) {
+  TupleRow* row = batch->GetRow(current_batch_row);
+  GetRowValue(row, _row, );
+  RETURN_IF_ERROR(results_->AddOneRow(result_row, scales));
+  ++current_batch_row;
+}
 // Prevent expr result allocations from accumulating.
 expr_results_pool_->Clear();
 // Signal the consumer.
@@ -135,4 +146,13 @@ Status PlanRootSink::GetNext(
   *eos = sender_state_ == SenderState::EOS;
   return state->GetQueryStatus();
 }
+
+void PlanRootSink::GetRowValue(
+TupleRow* row, vector* result, vector* scales) {
+  DCHECK_GE(result->size(), output_expr_evals_.size());
+  for (int i = 0; i < output_expr_evals_.size(); ++i) {
+(*result)[i] = output_expr_evals_[i]->GetValue(row);
+(*scales)[i] = output_expr_evals_[i]->output_scale();
+  }
+}
 }

http://git-wip-us.apache.org/repos/asf/impala/blob/109028e8/be/src/exec/plan-root-sink.h
--
diff --git a/be/src/exec/plan-root-sink.h b/be/src/exec/plan-root-sink.h
index 300c993..1d64b21 100644
--- a/be/src/exec/plan-root-sink.h
+++ b/be/src/exec/plan-root-sink.h
@@ -118,6 +118,10 @@ class PlanRootSink : public DataSink {
 
   /// Set by GetNext() to indicate to Send() how many rows it should write to 
results_.
   int num_rows_requested_ = 0;
+
+  /// Writes a single row into 'result' and 'scales' by evaluating
+  /// output_expr_evals_ over 'row'.
+  void GetRowValue(TupleRow* row, std::vector* result, 
std::vector* scales);
 };
 }
 

http://git-wip-us.apache.org/repos/asf/impala/blob/109028e8/be/src/service/hs2-util.cc
--
diff --git a/be/src/service/hs2-util.cc b/be/src/service/hs2-util.cc
index cf571fb..b856556 100644
--- a/be/src/service/hs2-util.cc
+++ b/be/src/service/hs2-util.cc
@@ -18,12 +18,9 @@
 #include "service/hs2-util.h"
 
 #include "common/logging.h"
-#include "exprs/scalar-expr-evaluator.h"
 #include "runtime/decimal-value.inline.h"
 #include "runtime/raw-value.inline.h"
-#include "runtime/row-batch.h"
 #include "runtime/types.h"
-#include "util/bit-util.h"
 
 #include 
 
@@ -52,9 +49,7 @@ inline bool GetNullBit(const string& nulls, uint32_t row_idx) 
{
 
 void impala::StitchNulls(uint32_t num_rows_before, uint32_t num_rows_added,
 uint32_t start_idx, const string& from, string* to) {
-  // Round up to power-of-two to avoid accidentally quadratic