Clean up switch statements in column_predicate.cc Where possible, remove default branches in favor of LOG(FATAL) calls outside the switch. This makes it more likely that the switch will be updated in the future for new predicate types, since C++ compilers can warn on incomplete switches if there is no default branch.
Also cleans up a confusing fall-through in ColumnPredicate::operator==. Change-Id: I80b750f7bc7455607c380ca65744d8cc66eeabd1 Reviewed-on: http://gerrit.cloudera.org:8080/4599 Reviewed-by: Adar Dembo <[email protected]> Reviewed-by: Todd Lipcon <[email protected]> Reviewed-by: Dinesh Bhat <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/26ef3360 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/26ef3360 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/26ef3360 Branch: refs/heads/master Commit: 26ef3360280bc4c4e37a31dc38c8500b8b3e4010 Parents: 407f95d Author: Dan Burkert <[email protected]> Authored: Mon Oct 3 11:46:13 2016 -0700 Committer: Dan Burkert <[email protected]> Committed: Mon Oct 3 19:28:37 2016 +0000 ---------------------------------------------------------------------- src/kudu/common/column_predicate.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/26ef3360/src/kudu/common/column_predicate.cc ---------------------------------------------------------------------- diff --git a/src/kudu/common/column_predicate.cc b/src/kudu/common/column_predicate.cc index 4bc270b..28c182a 100644 --- a/src/kudu/common/column_predicate.cc +++ b/src/kudu/common/column_predicate.cc @@ -425,8 +425,8 @@ void ColumnPredicate::MergeIntoInList(const ColumnPredicate &other) { Simplify(); return; }; - default: LOG(FATAL) << "unknown predicate type"; } + LOG(FATAL) << "unknown predicate type"; } namespace { @@ -499,9 +499,9 @@ void ColumnPredicate::EvaluateForPhysicalType(const ColumnBlock& block, }); return; }; - default: - LOG(FATAL) << "unknown predicate type"; + case PredicateType::None: LOG(FATAL) << "NONE predicate evaluation"; } + LOG(FATAL) << "unknown predicate type"; } void ColumnPredicate::Evaluate(const ColumnBlock& block, SelectionVector* sel) const { @@ -584,10 +584,12 @@ bool ColumnPredicate::operator==(const ColumnPredicate& other) const { for (int i = 0; i < values_.size(); i++) { if (column_.type_info()->Compare(values_[i], other.values_[i]) != 0) return false; } + return true; }; case PredicateType::None: case PredicateType::IsNotNull: return true; } + LOG(FATAL) << "unknown predicate type"; } bool ColumnPredicate::CheckValueInRange(const void* value) const {
