You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/03/31 03:39:41 UTC

incubator-kudu git commit: remove unused scan predicate classes

Repository: incubator-kudu
Updated Branches:
  refs/heads/master 601814559 -> d5938e951


remove unused scan predicate classes

Change-Id: Ie2ffb28a134cd229ef6fb52357dd13c5ecfa1c33
Reviewed-on: http://gerrit.cloudera.org:8080/2670
Tested-by: Kudu Jenkins
Reviewed-by: Jean-Daniel Cryans
Reviewed-by: Adar Dembo <ad...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/d5938e95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/d5938e95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/d5938e95

Branch: refs/heads/master
Commit: d5938e951fa6e145808eb16bd28516f63f5b8bef
Parents: 6018145
Author: Dan Burkert <da...@cloudera.com>
Authored: Mon Mar 28 14:45:58 2016 -0700
Committer: Dan Burkert <da...@cloudera.com>
Committed: Thu Mar 31 01:17:22 2016 +0000

----------------------------------------------------------------------
 src/kudu/cfile/cfile_util.h              |   1 -
 src/kudu/client/scan_predicate.cc        |   1 -
 src/kudu/common/CMakeLists.txt           |   2 -
 src/kudu/common/partition-test.cc        |   1 -
 src/kudu/common/partition.cc             |   1 -
 src/kudu/common/partition_pruner-test.cc |   1 -
 src/kudu/common/predicate-test.cc        | 132 --------------------------
 src/kudu/common/scan_predicate.cc        | 111 ----------------------
 src/kudu/common/scan_predicate.h         | 132 --------------------------
 9 files changed, 382 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/cfile/cfile_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile_util.h b/src/kudu/cfile/cfile_util.h
index cf647a6..ea3fac5 100644
--- a/src/kudu/cfile/cfile_util.h
+++ b/src/kudu/cfile/cfile_util.h
@@ -24,7 +24,6 @@
 
 #include "kudu/common/schema.h"
 #include "kudu/common/row.h"
-#include "kudu/common/scan_predicate.h"
 #include "kudu/common/encoded_key.h"
 #include "kudu/util/bloom_filter.h"
 #include "kudu/util/slice.h"

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/client/scan_predicate.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/scan_predicate.cc b/src/kudu/client/scan_predicate.cc
index f11b8d1..1520a0b 100644
--- a/src/kudu/client/scan_predicate.cc
+++ b/src/kudu/client/scan_predicate.cc
@@ -23,7 +23,6 @@
 #include "kudu/client/scan_predicate-internal.h"
 #include "kudu/client/value-internal.h"
 #include "kudu/client/value.h"
-#include "kudu/common/scan_predicate.h"
 #include "kudu/common/scan_spec.h"
 #include "kudu/gutil/strings/substitute.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/kudu/common/CMakeLists.txt b/src/kudu/common/CMakeLists.txt
index 28415b5..7280db8 100644
--- a/src/kudu/common/CMakeLists.txt
+++ b/src/kudu/common/CMakeLists.txt
@@ -53,7 +53,6 @@ set(COMMON_SRCS
   rowblock.cc
   row_changelist.cc
   row_operations.cc
-  scan_predicate.cc
   scan_spec.cc
   schema.cc
   timestamp.cc
@@ -86,7 +85,6 @@ ADD_KUDU_TEST(key_util-test)
 ADD_KUDU_TEST(partial_row-test)
 ADD_KUDU_TEST(partition-test)
 ADD_KUDU_TEST(partition_pruner-test)
-ADD_KUDU_TEST(predicate-test)
 ADD_KUDU_TEST(row_changelist-test)
 ADD_KUDU_TEST(row_operations-test)
 ADD_KUDU_TEST(scan_spec-test)

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/partition-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition-test.cc b/src/kudu/common/partition-test.cc
index 4af83c4..b2e9b98 100644
--- a/src/kudu/common/partition-test.cc
+++ b/src/kudu/common/partition-test.cc
@@ -23,7 +23,6 @@
 #include "kudu/common/partial_row.h"
 #include "kudu/common/partition.h"
 #include "kudu/common/row.h"
-#include "kudu/common/scan_predicate.h"
 #include "kudu/common/schema.h"
 #include "kudu/util/hash_util.h"
 #include "kudu/util/test_util.h"

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/partition.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc
index 86b63a4..76b341e 100644
--- a/src/kudu/common/partition.cc
+++ b/src/kudu/common/partition.cc
@@ -21,7 +21,6 @@
 #include <set>
 
 #include "kudu/common/partial_row.h"
-#include "kudu/common/scan_predicate.h"
 #include "kudu/common/wire_protocol.pb.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/strings/join.h"

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/partition_pruner-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition_pruner-test.cc b/src/kudu/common/partition_pruner-test.cc
index f819db8..1b14cc7 100644
--- a/src/kudu/common/partition_pruner-test.cc
+++ b/src/kudu/common/partition_pruner-test.cc
@@ -27,7 +27,6 @@
 #include "kudu/common/partial_row.h"
 #include "kudu/common/partition.h"
 #include "kudu/common/row.h"
-#include "kudu/common/scan_predicate.h"
 #include "kudu/common/scan_spec.h"
 #include "kudu/common/schema.h"
 #include "kudu/util/test_util.h"

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/predicate-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/predicate-test.cc b/src/kudu/common/predicate-test.cc
deleted file mode 100644
index e1db67b..0000000
--- a/src/kudu/common/predicate-test.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <gtest/gtest.h>
-
-#include "kudu/common/scan_predicate.h"
-#include "kudu/common/rowblock.h"
-#include "kudu/util/memory/overwrite.h"
-#include "kudu/util/test_util.h"
-
-namespace kudu {
-
-class TestPredicate : public KuduTest {
- public:
-  TestPredicate() :
-    arena_(1024, 4096),
-    n_rows_(100),
-    schema_({ ColumnSchema("col0", UINT32),
-              ColumnSchema("col1", UINT32),
-              ColumnSchema("col2", STRING) },
-            1),
-    row_block_(schema_, n_rows_, &arena_)
-  {}
-
-  // Set up a block of data with two columns:
-  // col0   col1
-  // ----   ------
-  // 0      0
-  // 1      10
-  // ...    ...
-  // N      N * 10
-  //
-  // The third STRING column is left unset.
-  void SetUp() OVERRIDE {
-    KuduTest::SetUp();
-
-    ColumnBlock col0 = row_block_.column_block(0, n_rows_);
-    ColumnBlock col1 = row_block_.column_block(1, n_rows_);
-
-    for (uint32_t i = 0; i < n_rows_; i++) {
-      uint32_t i1 = i * 10;
-      col0.SetCellValue(i, &i);
-      col1.SetCellValue(i, &i1);
-    }
-  }
-
- protected:
-  Arena arena_;
-  const size_t n_rows_;
-  Schema schema_;
-  RowBlock row_block_;
-};
-
-TEST_F(TestPredicate, TestSelectionVector) {
-  SelectionVector selvec(10);
-  selvec.SetAllTrue();
-  ASSERT_TRUE(selvec.IsRowSelected(0));
-  ASSERT_TRUE(selvec.IsRowSelected(9));
-  ASSERT_EQ(10, selvec.CountSelected());
-  ASSERT_TRUE(selvec.AnySelected());
-
-  for (int i = 0; i < 10; i++) {
-    BitmapClear(selvec.mutable_bitmap(), i);
-  }
-
-  ASSERT_FALSE(selvec.AnySelected());
-
-  // Test Resize()
-  selvec.SetAllTrue();
-  for (int i = 10; i > 0; --i) {
-    selvec.Resize(i);
-    ASSERT_EQ(selvec.CountSelected(), i);
-    ASSERT_TRUE(selvec.AnySelected());
-  }
-  selvec.Resize(0);
-  ASSERT_EQ(selvec.CountSelected(), 0);
-  ASSERT_FALSE(selvec.AnySelected());
-}
-
-TEST_F(TestPredicate, TestColumnRange) {
-  SelectionVector selvec(n_rows_);
-  selvec.SetAllTrue();
-  ASSERT_EQ(100, selvec.CountSelected());
-
-  // Apply predicate 20 <= col0 <= 29
-  uint32_t col0_lower = 20;
-  uint32_t col0_upper = 29;
-  ColumnRangePredicate pred1(schema_.column(0), &col0_lower, &col0_upper);
-  ASSERT_EQ("(`col0` BETWEEN 20 AND 29)", pred1.ToString());
-  pred1.Evaluate(&row_block_, &selvec);
-  ASSERT_EQ(10, selvec.CountSelected()) << "Only 10 rows should be left (20-29)";
-
-  // Apply predicate col1 >= 250
-  uint32_t col1_lower = 250;
-  ColumnRangePredicate pred2(schema_.column(1), &col1_lower, nullptr);
-  ASSERT_EQ("(`col1` >= 250)", pred2.ToString());
-  pred2.Evaluate(&row_block_, &selvec);
-  ASSERT_EQ(5, selvec.CountSelected()) << "Only 5 rows should be left (25-29)";
-}
-
-// Regression test for KUDU-54: should not try to access rows for which the
-// selection vector is 0.
-TEST_F(TestPredicate, TestDontEvalauteOnUnselectedRows) {
-  SelectionVector selvec(n_rows_);
-  selvec.SetAllFalse();
-
-  // Fill the STRING column with garbage data.
-  OverwriteWithPattern(reinterpret_cast<char*>(row_block_.column_block(2).data()),
-                       row_block_.column_block(2).stride() * row_block_.nrows(),
-                       "JUNKDATA");
-
-  Slice lower("lower");
-  ColumnRangePredicate p(schema_.column(2), &lower, nullptr);
-  p.Evaluate(&row_block_, &selvec);
-  ASSERT_EQ(0, selvec.CountSelected());
-}
-
-} // namespace kudu

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/scan_predicate.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/scan_predicate.cc b/src/kudu/common/scan_predicate.cc
deleted file mode 100644
index e919cae..0000000
--- a/src/kudu/common/scan_predicate.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "kudu/common/scan_predicate.h"
-
-#include <string>
-
-#include "kudu/common/rowblock.h"
-#include "kudu/common/types.h"
-#include "kudu/util/bitmap.h"
-
-namespace kudu {
-
-using std::string;
-
-ValueRange::ValueRange(const TypeInfo* type,
-                       const void* lower_bound,
-                       const void* upper_bound)
-  : type_info_(type),
-    lower_bound_(lower_bound),
-    upper_bound_(upper_bound) {
-  CHECK(has_lower_bound() || has_upper_bound())
-    << "range predicate has no bounds";
-}
-
-bool ValueRange::IsEquality() const {
-  if (has_lower_bound() && has_upper_bound()) {
-    return type_info_->Compare(upper_bound(), lower_bound()) == 0;
-  }
-  return false;
-}
-
-bool ValueRange::ContainsCell(const void* cell) const {
-  if (has_lower_bound() && type_info_->Compare(cell, lower_bound()) < 0) {
-    return false;
-  }
-  if (has_upper_bound() && type_info_->Compare(cell, upper_bound()) > 0) {
-    return false;
-  }
-  return true;
-}
-
-////////////////////////////////////////////////////////////
-
-ColumnRangePredicate::ColumnRangePredicate(ColumnSchema col,
-                                           const void* lower_bound,
-                                           const void* upper_bound)
-    : col_(std::move(col)),
-      range_(col_.type_info(), lower_bound, upper_bound) {}
-
-void ColumnRangePredicate::Evaluate(RowBlock* block, SelectionVector* vec) const {
-  int col_idx = block->schema().find_column(col_.name());
-  CHECK_GE(col_idx, 0) << "bad col: " << col_.ToString();
-
-  ColumnBlock cblock(block->column_block(col_idx, block->nrows()));
-
-  // TODO: this is all rather slow, could probably push down all the way
-  // to the TypeInfo so we only make one virtual call, or use codegen.
-  // Not concerned for now -- plan of record is to eventually embed Impala
-  // expression evaluation somewhere here, so this is just a stub.
-  if (cblock.is_nullable()) {
-    for (size_t i = 0; i < block->nrows(); i++) {
-      if (!vec->IsRowSelected(i)) continue;
-      const void *cell = cblock.nullable_cell_ptr(i);
-      if (cell == nullptr || !range_.ContainsCell(cell)) {
-        BitmapClear(vec->mutable_bitmap(), i);
-      }
-    }
-  } else {
-    for (size_t i = 0; i < block->nrows(); i++) {
-      if (!vec->IsRowSelected(i)) continue;
-      const void *cell = cblock.cell_ptr(i);
-      if (!range_.ContainsCell(cell)) {
-        BitmapClear(vec->mutable_bitmap(), i);
-      }
-    }
-  }
-}
-
-string ColumnRangePredicate::ToString() const {
-  if (range_.has_lower_bound() && range_.has_upper_bound()) {
-    return StringPrintf("(`%s` BETWEEN %s AND %s)", col_.name().c_str(),
-                        col_.Stringify(range_.lower_bound()).c_str(),
-                        col_.Stringify(range_.upper_bound()).c_str());
-  } else if (range_.has_lower_bound()) {
-    return StringPrintf("(`%s` >= %s)", col_.name().c_str(),
-                        col_.Stringify(range_.lower_bound()).c_str());
-  } else if (range_.has_upper_bound()) {
-    return StringPrintf("(`%s` <= %s)", col_.name().c_str(),
-                        col_.Stringify(range_.upper_bound()).c_str());
-  } else {
-    LOG(FATAL) << "Cannot reach here";
-    return string("Does not reach here");
-  }
-}
-
-} // namespace kudu

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/d5938e95/src/kudu/common/scan_predicate.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/scan_predicate.h b/src/kudu/common/scan_predicate.h
deleted file mode 100644
index 6d52b7c..0000000
--- a/src/kudu/common/scan_predicate.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-#ifndef KUDU_COMMON_SCAN_PREDICATE_H
-#define KUDU_COMMON_SCAN_PREDICATE_H
-
-#include <string>
-
-#include <gtest/gtest_prod.h>
-
-#include "kudu/common/schema.h"
-#include "kudu/util/bitmap.h"
-#include "kudu/util/faststring.h"
-
-namespace kudu {
-
-using std::string;
-
-class RowBlock;
-class SelectionVector;
-
-class ValueRange {
- public:
-  // Construct a new column range predicate.
-  //
-  // The min_value and upper_bound pointers should point to storage
-  // which represents a constant cell value to be used as a range.
-  // The range is inclusive on both ends.
-  // The cells are not copied by this object, so should remain unchanged
-  // for the lifetime of this object.
-  //
-  // If either optional is unspecified (i.e. NULL), then the range is
-  // open on that end.
-  //
-  // A range must be bounded on at least one end.
-  ValueRange(const TypeInfo* type,
-             const void* lower_bound,
-             const void* upper_bound);
-
-  bool has_lower_bound() const {
-    return lower_bound_;
-  }
-
-  bool has_upper_bound() const {
-    return upper_bound_;
-  }
-
-  const void* lower_bound() const {
-    return lower_bound_;
-  }
-
-  const void* upper_bound() const {
-    return upper_bound_;
-  }
-
-  bool IsEquality() const;
-
-  bool ContainsCell(const void* cell) const;
-
- private:
-  const TypeInfo* type_info_;
-  const void* lower_bound_;
-  const void* upper_bound_;
-};
-
-// Predicate which evaluates to true when the value for a given column
-// is within a specified range.
-//
-// TODO: extract an interface for this once it's clearer what the interface should
-// look like. Column range is not the only predicate in the world.
-class ColumnRangePredicate {
- public:
-
-  // Construct a new column range predicate.
-  // The lower_bound and upper_bound pointers should point to storage
-  // which represents a constant cell value to be used as a range.
-  // The range is inclusive on both ends.
-  // If either optional is unspecified (i.e. NULL), then the range is
-  // open on that end.
-  ColumnRangePredicate(ColumnSchema col, const void* lower_bound,
-                       const void* upper_bound);
-
-  const ColumnSchema &column() const {
-    return col_;
-  }
-
-  string ToString() const;
-
-  // Return the value range for which this predicate passes.
-  const ValueRange &range() const { return range_; }
-
- private:
-  // For Evaluate.
-  friend class MaterializingIterator;
-  friend class PredicateEvaluatingIterator;
-  FRIEND_TEST(TestPredicate, TestColumnRange);
-  FRIEND_TEST(TestPredicate, TestDontEvalauteOnUnselectedRows);
-
-  // Evaluate the predicate on every row in the rowblock.
-  //
-  // This is evaluated as an 'AND' with the current contents of *sel:
-  // - wherever the predicate evaluates false, set the appropriate bit in the selection
-  //   vector to 0.
-  // - If the predicate evalutes true, does not make any change to the
-  //   selection vector.
-  //
-  // On any rows where the current value of *sel is false, the predicate evaluation
-  // may be skipped.
-  //
-  // NOTE: the evaluation result is stored into '*sel' which may or may not be the
-  // same vector as block->selection_vector().
-  void Evaluate(RowBlock *block, SelectionVector *sel) const;
-
-  ColumnSchema col_;
-  ValueRange range_;
-};
-
-} // namespace kudu
-#endif