You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sp...@apache.org on 2016/12/11 17:45:59 UTC
[36/51] [abbrv] [partial] incubator-quickstep git commit: remove c++
files
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/ComparisonPredicate.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/ComparisonPredicate.hpp b/expressions/predicate/ComparisonPredicate.hpp
deleted file mode 100644
index 9030857..0000000
--- a/expressions/predicate/ComparisonPredicate.hpp
+++ /dev/null
@@ -1,156 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_COMPARISON_PREDICATE_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_COMPARISON_PREDICATE_HPP_
-
-#include <memory>
-#include <utility>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "expressions/scalar/Scalar.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class TupleIdSequence;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief A Predicate which is a comparison of two scalar values.
- **/
-class ComparisonPredicate : public Predicate {
- public:
- /**
- * @brief Constructor
- *
- * @param Comparison The comparison operation to be performed.
- * @param left_operand The left argument of the comparison, becomes owned by
- * this ComparisonPredicate.
- * @param right_operand The right argument of the comparison, becomes owned
- * by this ComparisonPredicate.
- **/
- ComparisonPredicate(const Comparison &comparison,
- Scalar *left_operand,
- Scalar *right_operand);
-
- ~ComparisonPredicate() override {
- }
-
- serialization::Predicate getProto() const override;
-
- Predicate* clone() const override;
-
- PredicateType getPredicateType() const override {
- return kComparison;
- }
-
- bool isAttributeLiteralComparisonPredicate() const override;
-
- bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const override;
-
- bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const override;
-
- TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const override;
-
- bool hasStaticResult() const override {
- return (fast_comparator_.get() == nullptr);
- }
-
- bool getStaticResult() const override;
-
- /**
- * @brief Get the comparison operation for this predicate.
- *
- * @return This predicate's comparison.
- **/
- const Comparison& getComparison() const {
- return comparison_;
- }
-
- /**
- * @brief Get the left operand of this comparison.
- *
- * @return This comparison's left operand.
- **/
- const Scalar& getLeftOperand() const {
- DCHECK(left_operand_.get() != nullptr);
- return *left_operand_;
- }
-
- /**
- * @brief Get the right operand of this comparison.
- *
- * @return This comparison's right operand.
- **/
- const Scalar& getRightOperand() const {
- DCHECK(right_operand_.get() != nullptr);
- return *right_operand_;
- }
-
- /**
- * @brief For an attribute-literal comparison, determine whether the
- * attribute is on the left and what its attribute_id is.
- * @warning This is only usable if isAttributeLiteralComparisonPredicate() is
- * true.
- *
- * @return A pair: first is true if attribute is on the left, false if on the
- * right. second is the ID of the attribute.
- **/
- std::pair<bool, attribute_id> getAttributeFromAttributeLiteralComparison() const;
-
- private:
- const Comparison &comparison_;
- std::unique_ptr<Scalar> left_operand_;
- std::unique_ptr<Scalar> right_operand_;
- bool static_result_;
- std::unique_ptr<UncheckedComparator> fast_comparator_;
-
- void initHelper(bool own_children);
-
- DISALLOW_COPY_AND_ASSIGN(ComparisonPredicate);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_COMPARISON_PREDICATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/ConjunctionPredicate.cpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/ConjunctionPredicate.cpp b/expressions/predicate/ConjunctionPredicate.cpp
deleted file mode 100644
index 4f5cc77..0000000
--- a/expressions/predicate/ConjunctionPredicate.cpp
+++ /dev/null
@@ -1,201 +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 "expressions/predicate/ConjunctionPredicate.hpp"
-
-#include <memory>
-
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "storage/TupleIdSequence.hpp"
-#include "storage/ValueAccessor.hpp"
-#include "utility/PtrList.hpp"
-
-namespace quickstep {
-
-serialization::Predicate ConjunctionPredicate::getProto() const {
- serialization::Predicate proto;
- proto.set_predicate_type(serialization::Predicate::CONJUNCTION);
-
- for (PtrList<Predicate>::const_iterator it = static_operand_list_.begin();
- it != static_operand_list_.end();
- ++it) {
- proto.AddExtension(serialization::PredicateWithList::operands)->CopyFrom(it->getProto());
- }
-
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- proto.AddExtension(serialization::PredicateWithList::operands)->CopyFrom(it->getProto());
- }
-
- return proto;
-}
-
-Predicate* ConjunctionPredicate::clone() const {
- ConjunctionPredicate *clone = new ConjunctionPredicate();
-
- for (PtrList<Predicate>::const_iterator it = static_operand_list_.begin();
- it != static_operand_list_.end();
- ++it) {
- clone->addPredicate(it->clone());
- }
-
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- clone->addPredicate(it->clone());
- }
-
- return clone;
-}
-
-bool ConjunctionPredicate::matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const {
- if (has_static_result_) {
- return static_result_;
- } else {
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- if (!it->matchesForSingleTuple(accessor, tuple)) {
- return false;
- }
- }
-
- return true;
- }
-}
-
-bool ConjunctionPredicate::matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const {
- if (has_static_result_) {
- return static_result_;
- } else {
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- if (!it->matchesForJoinedTuples(left_accessor,
- left_relation_id,
- left_tuple_id,
- right_accessor,
- right_relation_id,
- right_tuple_id)) {
- return false;
- }
- }
-
- return true;
- }
-}
-
-TupleIdSequence* ConjunctionPredicate::getAllMatches(
- ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const {
- if (has_static_result_) {
- return GenerateSequenceForStaticResult(accessor, filter, existence_map, static_result_);
- } else {
- tuple_id end_pos = accessor->getEndPositionVirtual();
-
- TupleIdSequence *current_filter = new TupleIdSequence(end_pos);
- if (filter != nullptr) {
- current_filter->assignFrom(*filter);
- } else if (existence_map != nullptr) {
- current_filter->assignFrom(*existence_map);
- } else {
- current_filter->setRange(0, end_pos, true);
- }
-
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- if (current_filter->empty()) {
- break;
- }
- std::unique_ptr<TupleIdSequence> operand_result(it->getAllMatches(accessor,
- sub_blocks_ref,
- current_filter,
- existence_map));
- current_filter->intersectWith(*operand_result);
- }
-
- return current_filter;
- }
-}
-
-void ConjunctionPredicate::addPredicate(Predicate *operand) {
- if (operand->getPredicateType() == kConjunction) {
- ConjunctionPredicate *conjunction_operand = static_cast<ConjunctionPredicate*>(operand);
-
- PtrList<Predicate>::iterator checkpos;
- if (static_operand_list_.empty()) {
- static_operand_list_.splice(static_operand_list_.end(), conjunction_operand->static_operand_list_);
- checkpos = static_operand_list_.begin();
- } else {
- checkpos = static_operand_list_.end();
- --checkpos;
- static_operand_list_.splice(static_operand_list_.end(), conjunction_operand->static_operand_list_);
- ++checkpos;
- }
-
- while (checkpos != static_operand_list_.end()) {
- processStaticOperand(*checkpos);
- ++checkpos;
- }
-
- if (!conjunction_operand->dynamic_operand_list_.empty()) {
- dynamic_operand_list_.splice(dynamic_operand_list_.end(), conjunction_operand->dynamic_operand_list_);
- processDynamicOperand();
- }
-
- delete conjunction_operand;
- } else {
- if (operand->hasStaticResult()) {
- static_operand_list_.push_back(operand);
- processStaticOperand(*operand);
- } else {
- dynamic_operand_list_.push_back(operand);
- processDynamicOperand();
- }
- }
-}
-
-void ConjunctionPredicate::processStaticOperand(const Predicate &operand) {
- if (!operand.getStaticResult()) {
- has_static_result_ = true;
- static_result_ = false;
- }
-}
-
-void ConjunctionPredicate::processDynamicOperand() {
- if (has_static_result_) {
- if (static_result_) {
- has_static_result_ = false;
- }
- }
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/ConjunctionPredicate.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/ConjunctionPredicate.hpp b/expressions/predicate/ConjunctionPredicate.hpp
deleted file mode 100644
index b24036a..0000000
--- a/expressions/predicate/ConjunctionPredicate.hpp
+++ /dev/null
@@ -1,97 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_CONJUNCTION_PREDICATE_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_CONJUNCTION_PREDICATE_HPP_
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "expressions/predicate/PredicateWithList.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class TupleIdSequence;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief A conjunction of other Predicates.
- **/
-class ConjunctionPredicate : public PredicateWithList {
- public:
- /**
- * @brief Constructor.
- **/
- ConjunctionPredicate()
- : PredicateWithList() {
- }
-
- serialization::Predicate getProto() const override;
-
- Predicate *clone() const override;
-
- PredicateType getPredicateType() const override {
- return kConjunction;
- }
-
- bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const override;
-
- bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const override;
-
- TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const override;
-
- /**
- * @brief Add a predicate to this conjunction.
- * @note If operand is another ConjunctionPredicate, it will be flattened
- * into this Predicate, rather than nested beneath it.
- *
- * @param operand The predicate to add, becomes owned by this Predicate.
- **/
- void addPredicate(Predicate *operand);
-
- private:
- void processStaticOperand(const Predicate &operand);
- void processDynamicOperand();
-
- DISALLOW_COPY_AND_ASSIGN(ConjunctionPredicate);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_CONJUNCTION_PREDICATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/DisjunctionPredicate.cpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/DisjunctionPredicate.cpp b/expressions/predicate/DisjunctionPredicate.cpp
deleted file mode 100644
index e117c99..0000000
--- a/expressions/predicate/DisjunctionPredicate.cpp
+++ /dev/null
@@ -1,222 +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 "expressions/predicate/DisjunctionPredicate.hpp"
-
-#include <memory>
-
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "storage/TupleIdSequence.hpp"
-#include "storage/ValueAccessor.hpp"
-#include "utility/PtrList.hpp"
-
-namespace quickstep {
-
-serialization::Predicate DisjunctionPredicate::getProto() const {
- serialization::Predicate proto;
- proto.set_predicate_type(serialization::Predicate::DISJUNCTION);
-
- for (PtrList<Predicate>::const_iterator it(static_operand_list_.begin());
- it != static_operand_list_.end();
- ++it) {
- proto.AddExtension(serialization::PredicateWithList::operands)->CopyFrom(it->getProto());
- }
-
- for (PtrList<Predicate>::const_iterator it(dynamic_operand_list_.begin());
- it != dynamic_operand_list_.end();
- ++it) {
- proto.AddExtension(serialization::PredicateWithList::operands)->CopyFrom(it->getProto());
- }
-
- return proto;
-}
-
-Predicate* DisjunctionPredicate::clone() const {
- DisjunctionPredicate *clone = new DisjunctionPredicate();
-
- for (PtrList<Predicate>::const_iterator it = static_operand_list_.begin();
- it != static_operand_list_.end();
- ++it) {
- clone->addPredicate(it->clone());
- }
-
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- clone->addPredicate(it->clone());
- }
-
- return clone;
-}
-
-bool DisjunctionPredicate::matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const {
- if (has_static_result_) {
- return static_result_;
- } else {
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- if (it->matchesForSingleTuple(accessor, tuple)) {
- return true;
- }
- }
-
- return false;
- }
-}
-
-bool DisjunctionPredicate::matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const {
- if (has_static_result_) {
- return static_result_;
- } else {
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
- if (it->matchesForJoinedTuples(left_accessor,
- left_relation_id,
- left_tuple_id,
- right_accessor,
- right_relation_id,
- right_tuple_id)) {
- return true;
- }
- }
-
- return false;
- }
-}
-
-TupleIdSequence* DisjunctionPredicate::getAllMatches(
- ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const {
- if (has_static_result_) {
- return GenerateSequenceForStaticResult(accessor, filter, existence_map, static_result_);
- } else {
- tuple_id end_pos = accessor->getEndPositionVirtual();
- TupleIdSequence *union_result = new TupleIdSequence(end_pos);
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT
- std::unique_ptr<TupleIdSequence> current_filter(new TupleIdSequence(end_pos));
- if (filter != nullptr) {
- current_filter->assignFrom(*filter);
- } else if (existence_map != nullptr) {
- current_filter->assignFrom(*existence_map);
- } else {
- current_filter->setRange(0, end_pos, true);
- }
-#endif // QUICKSTEP_ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT
-
- for (PtrList<Predicate>::const_iterator it = dynamic_operand_list_.begin();
- it != dynamic_operand_list_.end();
- ++it) {
-#ifdef QUICKSTEP_ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT
- std::unique_ptr<TupleIdSequence> operand_result(it->getAllMatches(accessor,
- sub_blocks_ref,
- current_filter.get(),
- existence_map));
-#else
- std::unique_ptr<TupleIdSequence> operand_result(it->getAllMatches(accessor,
- sub_blocks_ref,
- filter,
- existence_map));
-#endif // QUICKSTEP_ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT
- union_result->unionWith(*operand_result);
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT
- // Don't bother checking tuples which are already known to match some
- // part of the union.
- operand_result->invert();
- current_filter->intersectWith(*operand_result);
-#endif // QUICKSTEP_ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT
- }
-
- return union_result;
- }
-}
-
-void DisjunctionPredicate::addPredicate(Predicate *operand) {
- if (operand->getPredicateType() == kDisjunction) {
- DisjunctionPredicate *disjunction_operand = static_cast<DisjunctionPredicate*>(operand);
-
- PtrList<Predicate>::iterator checkpos;
- if (static_operand_list_.empty()) {
- static_operand_list_.splice(static_operand_list_.end(), disjunction_operand->static_operand_list_);
- checkpos = static_operand_list_.begin();
- } else {
- checkpos = static_operand_list_.end();
- --checkpos;
- static_operand_list_.splice(static_operand_list_.end(), disjunction_operand->static_operand_list_);
- ++checkpos;
- }
-
- while (checkpos != static_operand_list_.end()) {
- processStaticOperand(*checkpos);
- ++checkpos;
- }
-
- if (!disjunction_operand->dynamic_operand_list_.empty()) {
- dynamic_operand_list_.splice(dynamic_operand_list_.end(), disjunction_operand->dynamic_operand_list_);
- processDynamicOperand();
- }
-
- delete disjunction_operand;
- } else {
- if (operand->hasStaticResult()) {
- static_operand_list_.push_back(operand);
- processStaticOperand(*operand);
- } else {
- dynamic_operand_list_.push_back(operand);
- processDynamicOperand();
- }
- }
-}
-
-void DisjunctionPredicate::processStaticOperand(const Predicate &operand) {
- if (operand.getStaticResult()) {
- has_static_result_ = true;
- static_result_ = true;
- } else if (fresh_) {
- has_static_result_ = true;
- static_result_ = false;
- }
-
- fresh_ = false;
-}
-
-void DisjunctionPredicate::processDynamicOperand() {
- if (has_static_result_ && !static_result_) {
- has_static_result_ = false;
- } else if (fresh_) {
- has_static_result_ = false;
- }
-
- fresh_ = false;
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/DisjunctionPredicate.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/DisjunctionPredicate.hpp b/expressions/predicate/DisjunctionPredicate.hpp
deleted file mode 100644
index 2127573..0000000
--- a/expressions/predicate/DisjunctionPredicate.hpp
+++ /dev/null
@@ -1,99 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_DISJUNCTION_PREDICATE_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_DISJUNCTION_PREDICATE_HPP_
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "expressions/predicate/PredicateWithList.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class TupleIdSequence;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief A disjunction of other Predicates.
- **/
-class DisjunctionPredicate : public PredicateWithList {
- public:
- /**
- * @brief Constructor.
- **/
- DisjunctionPredicate()
- : PredicateWithList(), fresh_(true) {
- }
-
- serialization::Predicate getProto() const override;
-
- Predicate* clone() const override;
-
- PredicateType getPredicateType() const override {
- return kDisjunction;
- }
-
- bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const override;
-
- bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const override;
-
- TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const override;
-
- /**
- * @brief Add a predicate to this disjunction.
- * @note If operand is another DusjunctionPredicate, it will be flattened
- * into this Predicate, rather than nested beneath it.
- *
- * @param operand The predicate to add, becomes owned by this Predicate.
- **/
- void addPredicate(Predicate *operand);
-
- private:
- void processStaticOperand(const Predicate &operand);
- void processDynamicOperand();
-
- bool fresh_;
-
- DISALLOW_COPY_AND_ASSIGN(DisjunctionPredicate);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_DISJUNCTION_PREDICATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/NegationPredicate.cpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/NegationPredicate.cpp b/expressions/predicate/NegationPredicate.cpp
deleted file mode 100644
index bee1c8d..0000000
--- a/expressions/predicate/NegationPredicate.cpp
+++ /dev/null
@@ -1,123 +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 "expressions/predicate/NegationPredicate.hpp"
-
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "storage/TupleIdSequence.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class ValueAccessor;
-
-serialization::Predicate NegationPredicate::getProto() const {
- serialization::Predicate proto;
- proto.set_predicate_type(serialization::Predicate::NEGATION);
- proto.MutableExtension(serialization::NegationPredicate::operand)->CopyFrom(operand_->getProto());
-
- return proto;
-}
-
-Predicate* NegationPredicate::clone() const {
- return new NegationPredicate(operand_->clone());
-}
-
-bool NegationPredicate::matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const {
- if (has_static_result_) {
- return static_result_;
- } else {
- return !(operand_->matchesForSingleTuple(accessor, tuple));
- }
-}
-
-bool NegationPredicate::matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const {
- if (has_static_result_) {
- return static_result_;
- } else {
- return !(operand_->matchesForJoinedTuples(left_accessor,
- left_relation_id,
- left_tuple_id,
- right_accessor,
- right_relation_id,
- right_tuple_id));
- }
-}
-
-TupleIdSequence* NegationPredicate::getAllMatches(
- ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const {
- if (has_static_result_) {
- return GenerateSequenceForStaticResult(accessor, filter, existence_map, static_result_);
- } else {
- TupleIdSequence *operand_matches = operand_->getAllMatches(accessor,
- sub_blocks_ref,
- filter,
- existence_map);
-
- operand_matches->invert();
- if (filter != nullptr) {
- operand_matches->intersectWith(*filter);
- }
- if (existence_map != nullptr) {
- operand_matches->intersectWith(*existence_map);
- }
- return operand_matches;
- }
-}
-
-bool NegationPredicate::getStaticResult() const {
- if (has_static_result_) {
- return static_result_;
- } else {
- FATAL_ERROR("Called getStaticResult() on a predicate which has no static result");
- }
-}
-
-void NegationPredicate::initHelper() {
- if (operand_->hasStaticResult()) {
- has_static_result_ = true;
- static_result_ = !operand_->getStaticResult();
- } else {
- has_static_result_ = false;
- }
-}
-
-Predicate* NegationPredicate::NegatePredicate(Predicate *operand) {
- if (operand->getPredicateType() == kNegation) {
- NegationPredicate *negation_operand = static_cast<NegationPredicate*>(operand);
- Predicate *inner = negation_operand->operand_.release();
- delete negation_operand;
- return inner;
- } else {
- return new NegationPredicate(operand);
- }
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/NegationPredicate.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/NegationPredicate.hpp b/expressions/predicate/NegationPredicate.hpp
deleted file mode 100644
index 33c6df8..0000000
--- a/expressions/predicate/NegationPredicate.hpp
+++ /dev/null
@@ -1,125 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_NEGATION_PREDICATE_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_NEGATION_PREDICATE_HPP_
-
-#include <memory>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class TupleIdSequence;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief A negation of another Predicate.
- **/
-class NegationPredicate : public Predicate {
- public:
- /**
- * @brief Constructor.
- * @note The static factory method NegatePredicate (which is able to simplify
- * away double-negations) should be used instead of this constructor in
- * most cases.
- *
- * @param operand The Predicate which will be negated, becomes owned by this
- * NegationPredicate.
- **/
- explicit NegationPredicate(Predicate *operand):
- operand_(operand) {
- initHelper();
- }
-
- /**
- * @brief Destructor which also deletes the operand.
- **/
- ~NegationPredicate() override {
- }
-
- /**
- * @brief Static method to obtain the negated form of a Predicate. This
- * should be used instead of invoking NegationPredicate's constructor,
- * as it allows double-negations to be simplified away.
- *
- * @param operand The Predicate to negate. Caller relinquishes ownership of
- * operand by calling this method.
- * @return The negative of operand.
- **/
- static Predicate* NegatePredicate(Predicate *operand);
-
- serialization::Predicate getProto() const override;
-
- Predicate* clone() const override;
-
- PredicateType getPredicateType() const override {
- return kNegation;
- }
-
- bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const override;
-
- bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const override;
-
- TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const override;
-
- bool hasStaticResult() const override {
- return has_static_result_;
- }
-
- bool getStaticResult() const override;
-
- private:
- void initHelper();
-
- std::unique_ptr<Predicate> operand_;
-
- bool has_static_result_;
- bool static_result_;
-
- friend class PredicateTest;
-
- DISALLOW_COPY_AND_ASSIGN(NegationPredicate);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_NEGATION_PREDICATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/Predicate.cpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/Predicate.cpp b/expressions/predicate/Predicate.cpp
deleted file mode 100644
index 006e8f1..0000000
--- a/expressions/predicate/Predicate.cpp
+++ /dev/null
@@ -1,60 +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 "expressions/predicate/Predicate.hpp"
-
-#include "storage/TupleIdSequence.hpp"
-#include "storage/ValueAccessor.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-const char *Predicate::kPredicateTypeNames[] = {
- "True",
- "False",
- "Comparison",
- "Negation",
- "Conjunction",
- "Disjunction"
-};
-
-bool Predicate::getStaticResult() const {
- FATAL_ERROR("Called getStaticResult() on a predicate which has no static result");
-}
-
-TupleIdSequence* Predicate::GenerateSequenceForStaticResult(
- ValueAccessor *accessor,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map,
- const bool static_result) {
- TupleIdSequence *result = new TupleIdSequence(accessor->getEndPositionVirtual());
- if (static_result) {
- if (filter != nullptr) {
- // '*filter' will always be a subset of '*existence_map'.
- result->assignFrom(*filter);
- } else if (existence_map != nullptr) {
- result->assignFrom(*existence_map);
- } else {
- result->setRange(0, result->length(), true);
- }
- }
- return result;
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/Predicate.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/Predicate.hpp b/expressions/predicate/Predicate.hpp
deleted file mode 100644
index 5fb3ef5..0000000
--- a/expressions/predicate/Predicate.hpp
+++ /dev/null
@@ -1,208 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_HPP_
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "storage/StorageBlockInfo.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class TupleIdSequence;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief Base class for all predicates.
- **/
-class Predicate {
- public:
- /**
- * @brief The possible types of predicates.
- **/
- enum PredicateType {
- kTrue = 0,
- kFalse,
- kComparison,
- kNegation,
- kConjunction,
- kDisjunction,
- kNumPredicateTypes // Not a real PredicateType, exists for counting purposes.
- };
-
- /**
- * @brief Strings naming the elements in PredicateType.
- * @note String literals are defined out-of-line in Predicate.cpp
- **/
- static const char *kPredicateTypeNames[kNumPredicateTypes];
-
- /**
- * @brief Virtual destructor.
- *
- **/
- virtual ~Predicate() {
- }
-
- /**
- * @brief Serialize this predicate in Protocol Buffer form.
- *
- * @return The Protocol Buffer representation of this predicate object.
- **/
- virtual serialization::Predicate getProto() const = 0;
-
- /**
- * @brief Make a deep copy of this Predicate.
- *
- * @return A cloned copy of this Predicate.
- **/
- virtual Predicate* clone() const = 0;
-
- /**
- * @brief Get the type of this particular Predicate instance.
- *
- * @return The type of this Predicate.
- **/
- virtual PredicateType getPredicateType() const = 0;
-
- /**
- * @brief Check whether this predicate is a comparison of the form
- * 'attribute comp literal' or 'literal comp attribute'.
- **/
- virtual bool isAttributeLiteralComparisonPredicate() const {
- return false;
- }
-
- /**
- * @brief Determine whether the given tuple in the given TupleStorageSubBlock
- * matches this predicate.
- * @note This only works for predicates which can be evaluated on a single
- * table. Use matchesForJoinedTuples() to evaluate join predicates.
- *
- * @param accessor ValueAccessor that will be used to read the tuple to check
- * this Predicate on.
- * @param tuple The ID of the tuple in tupleStore to check this Predicate on.
- * @return Whether the specified tuple matches this predicate.
- **/
- virtual bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const = 0;
-
- /**
- * @brief Determine whether this predicate matches for a given pair of joined
- * tuples.
- *
- * @param left_accessor The ValueAccessor that the first of the joined tuples
- * will be read from (this does NOT necessarily correspond to the left
- * operand of a binary operation).
- * @param left_relation_id The ID of the relation that left_accessor provides
- * access to.
- * @param left_tuple_id The ID of the tuple (the absolute position) from
- * left_accessor to evaluate this Predicate for.
- * @param right_accessor The ValueAccessor that the second of the joined
- * tuples will be read from (this does NOT necessarily correspond to
- * the right operand of a binary operation).
- * @param right_relation_id The ID of the relation that right_accessor
- * provides access to.
- * @param right_tuple_id The ID of the tuple (the absolute position) from
- * right_accessor to evaluate this Predicate for.
- * @return Whether this predicate is true for the given tuples.
- **/
- // TODO(chasseur): Add vectorized method for getting/filtering matches across
- // a join all at once. In the general case, this might require materializing
- // an expression across the cross product of all tuples in a pair of blocks
- // (which could incur prohibitively high temporary memory costs), although
- // there are plenty of common cases where this can be avoided (e.g. filtering
- // a smallish set of matches from a hash-join by a residual predicate).
- virtual bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const = 0;
-
- /**
- * @brief Determine whether this predicate is true for all tuples accessible
- * via a ValueAccessor.
- *
- * @param accessor A ValueAccessor which will be used to read attribute
- * values.
- * @param sub_blocks_ref If non-NULL, contains references to the
- * TupleStorageSubBlock that produced accessor and any IndexSubBlocks
- * in the same StorageBlock. These sub-blocks may be used for
- * fast-path (non-scan) evaluation of parts of this predicate. May be
- * NULL, in which case scan-based evaluation is always used.
- * @param filter If non-NULL, then only tuple IDs which are set in the
- * filter will be checked (all others will be assumed to be false).
- * @param existence_map If non-NULL, this indicates which tuples actually
- * exist and are accessible via ValueAccessor (this is intended for
- * use with ValueAccessors that read values from non-packed
- * TupleStorageSubBlocks).
- * @return The IDs of tuples accessible via accessor that match this
- * predicate.
- **/
- virtual TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const = 0;
-
- /**
- * @brief Determine whether this predicate's result is static (i.e. whether
- * it can be evaluated completely independent of any tuples).
- *
- * @return Whether this predicate's result is static.
- **/
- virtual bool hasStaticResult() const {
- return false;
- }
-
- /**
- * @brief Determine whether this predicate's static result is true or false.
- * @note hasStaticResult() should be called first to check whether this
- * Predicate actually has a static result.
- *
- * @return The static result of this predicate.
- **/
- virtual bool getStaticResult() const;
-
- protected:
- Predicate() {
- }
-
- static TupleIdSequence* GenerateSequenceForStaticResult(ValueAccessor *accessor,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map,
- const bool static_result);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Predicate);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/PredicateCost.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/PredicateCost.hpp b/expressions/predicate/PredicateCost.hpp
deleted file mode 100644
index 60e6721..0000000
--- a/expressions/predicate/PredicateCost.hpp
+++ /dev/null
@@ -1,62 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_COST_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_COST_HPP_
-
-#include <cstdint>
-#include <limits>
-
-namespace quickstep {
-
-/**
- * @brief Represents a simple estimation of the cost to evaluate a
- * ComparisonPredicate using a particular sub-block.
- **/
-typedef std::uint8_t predicate_cost_t;
-
-namespace predicate_cost {
-
-// TODO(chasseur): For now, these static constants define an order of
-// preference for different predicate-evaluation methods. In the future, we may
-// want to use statistics to get more accurate cost estimation.
-static constexpr predicate_cost_t kConstantTime = 0;
-static constexpr predicate_cost_t kBitWeavingVScan = 1;
-static constexpr predicate_cost_t kBitWeavingHScan = 2;
-static constexpr predicate_cost_t kBinarySearch = 3;
-static constexpr predicate_cost_t kTreeSearch = 4;
-static constexpr predicate_cost_t kCompressedColumnScan = 5;
-static constexpr predicate_cost_t kColumnScan = 6;
-static constexpr predicate_cost_t kCompressedRowScan = 7;
-static constexpr predicate_cost_t kRowScan = 8;
-static constexpr predicate_cost_t kInfinite = std::numeric_limits<predicate_cost_t>::max();
-
-} // namespace predicate_cost
-
-/**
- * @brief Determine if a predicate_cost_t represents a simple scan on a
- * TupleStorageSubBlock.
- **/
-inline bool PredicateCostIsSimpleScan(const predicate_cost_t cost) {
- return (cost == predicate_cost::kRowScan) || (cost == predicate_cost::kColumnScan);
-}
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_COST_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/PredicateWithList.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/PredicateWithList.hpp b/expressions/predicate/PredicateWithList.hpp
deleted file mode 100644
index b1bf7e5..0000000
--- a/expressions/predicate/PredicateWithList.hpp
+++ /dev/null
@@ -1,77 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_WITH_LIST_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_WITH_LIST_HPP_
-
-#include "expressions/predicate/Predicate.hpp"
-#include "utility/Macros.hpp"
-#include "utility/PtrList.hpp"
-
-namespace quickstep {
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief Abstract base class for conjunctions and disjunctions.
- **/
-class PredicateWithList : public Predicate {
- public:
- PredicateWithList()
- : has_static_result_(true), static_result_(true) {
- }
-
- /**
- * @brief Destructor which also deletes all operands.
- **/
- virtual ~PredicateWithList() {
- }
-
- bool hasStaticResult() const override {
- return has_static_result_;
- }
-
- bool getStaticResult() const override {
- if (has_static_result_) {
- return static_result_;
- } else {
- FATAL_ERROR("Called getStaticResult() on a predicate which has no static result");
- }
- }
-
- protected:
- PtrList<Predicate> static_operand_list_;
- PtrList<Predicate> dynamic_operand_list_;
-
- bool has_static_result_;
- bool static_result_;
-
- private:
- friend class PredicateTest;
-
- DISALLOW_COPY_AND_ASSIGN(PredicateWithList);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_PREDICATE_WITH_LIST_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/TrivialPredicates.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/TrivialPredicates.hpp b/expressions/predicate/TrivialPredicates.hpp
deleted file mode 100644
index 4e44976..0000000
--- a/expressions/predicate/TrivialPredicates.hpp
+++ /dev/null
@@ -1,167 +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 QUICKSTEP_EXPRESSIONS_PREDICATE_TRIVIAL_PREDICATES_HPP_
-#define QUICKSTEP_EXPRESSIONS_PREDICATE_TRIVIAL_PREDICATES_HPP_
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/predicate/Predicate.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class TupleIdSequence;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief Base class for trivial predicates which always evaluate to the same value.
- **/
-class TrivialPredicate : public Predicate {
- public:
- bool hasStaticResult() const override {
- return true;
- }
-
- protected:
- TrivialPredicate() {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TrivialPredicate);
-};
-
-/**
- * @brief Predicate which always evaluates to true.
- **/
-class TruePredicate : public TrivialPredicate {
- public:
- TruePredicate() {
- }
-
- serialization::Predicate getProto() const override {
- serialization::Predicate proto;
- proto.set_predicate_type(serialization::Predicate::TRUE);
-
- return proto;
- }
-
- Predicate* clone() const override {
- return new TruePredicate();
- }
-
- PredicateType getPredicateType() const override {
- return kTrue;
- }
-
- bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const override {
- return true;
- }
-
- bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const override {
- return true;
- }
-
- TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const override {
- return GenerateSequenceForStaticResult(accessor, filter, existence_map, true);
- }
-
- bool getStaticResult() const override {
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TruePredicate);
-};
-
-/**
- * @brief Predicate which always evaluates to false.
- **/
-class FalsePredicate : public TrivialPredicate {
- public:
- FalsePredicate() {
- }
-
- serialization::Predicate getProto() const override {
- serialization::Predicate proto;
- proto.set_predicate_type(serialization::Predicate::FALSE);
-
- return proto;
- }
-
- Predicate* clone() const override {
- return new FalsePredicate();
- }
-
- PredicateType getPredicateType() const override {
- return kFalse;
- }
-
- bool matchesForSingleTuple(const ValueAccessor &accessor,
- const tuple_id tuple) const override {
- return false;
- }
-
- bool matchesForJoinedTuples(
- const ValueAccessor &left_accessor,
- const relation_id left_relation_id,
- const tuple_id left_tuple_id,
- const ValueAccessor &right_accessor,
- const relation_id right_relation_id,
- const tuple_id right_tuple_id) const override {
- return false;
- }
-
- TupleIdSequence* getAllMatches(ValueAccessor *accessor,
- const SubBlocksReference *sub_blocks_ref,
- const TupleIdSequence *filter,
- const TupleIdSequence *existence_map) const override {
- return GenerateSequenceForStaticResult(accessor, filter, existence_map, false);
- }
-
- bool getStaticResult() const override {
- return false;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FalsePredicate);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_PREDICATE_TRIVIAL_PREDICATES_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/predicate/tests/Predicate_unittest.cpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/tests/Predicate_unittest.cpp b/expressions/predicate/tests/Predicate_unittest.cpp
deleted file mode 100644
index 3c2889d..0000000
--- a/expressions/predicate/tests/Predicate_unittest.cpp
+++ /dev/null
@@ -1,447 +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 <cstddef>
-#include <cstdint>
-#include <limits>
-#include <memory>
-#include <string>
-
-#include "catalog/CatalogAttribute.hpp"
-#include "catalog/CatalogDatabase.hpp"
-#include "catalog/CatalogRelation.hpp"
-#include "expressions/ExpressionFactories.hpp"
-#include "expressions/predicate/ComparisonPredicate.hpp"
-#include "expressions/predicate/ConjunctionPredicate.hpp"
-#include "expressions/predicate/DisjunctionPredicate.hpp"
-#include "expressions/predicate/NegationPredicate.hpp"
-#include "expressions/predicate/Predicate.hpp"
-#include "expressions/predicate/PredicateWithList.hpp"
-#include "expressions/predicate/TrivialPredicates.hpp"
-#include "expressions/scalar/Scalar.hpp"
-#include "expressions/scalar/ScalarAttribute.hpp"
-#include "expressions/scalar/ScalarBinaryExpression.hpp"
-#include "expressions/scalar/ScalarLiteral.hpp"
-#include "expressions/scalar/ScalarUnaryExpression.hpp"
-#include "types/DatetimeLit.hpp"
-#include "types/IntervalLit.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "types/operations/comparisons/ComparisonFactory.hpp"
-#include "types/operations/comparisons/ComparisonID.hpp"
-#include "types/operations/unary_operations/UnaryOperation.hpp"
-#include "types/operations/unary_operations/UnaryOperationID.hpp"
-#include "utility/Macros.hpp"
-#include "utility/PtrList.hpp"
-
-#include "gtest/gtest.h"
-
-using std::int64_t;
-using std::numeric_limits;
-using std::size_t;
-using std::string;
-using std::unique_ptr;
-
-namespace quickstep {
-
-class PredicateTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- database_.reset(new CatalogDatabase(NULL, "database_"));
-
- rel_numeric_ = createCatalogRelation("rel_numeric_");
- attr_int_ = createCatalogAttribute(rel_numeric_, "attr_int", TypeFactory::GetType(kInt));
- attr_long_ = createCatalogAttribute(rel_numeric_, "attr_long", TypeFactory::GetType(kLong));
- attr_float_ = createCatalogAttribute(rel_numeric_, "attr_float", TypeFactory::GetType(kFloat));
- attr_double_ = createCatalogAttribute(rel_numeric_, "attr_double", TypeFactory::GetType(kDouble));
-
- rel_date_ = createCatalogRelation("rel_date_");
- attr_datetime_ = createCatalogAttribute(rel_date_, "attr_datetime", TypeFactory::GetType(kDatetime));
- attr_datetime_interval_ =
- createCatalogAttribute(rel_date_, "attr_datetime_interval", TypeFactory::GetType(kDatetimeInterval));
- attr_year_month_interval_ =
- createCatalogAttribute(rel_date_, "attr_year_month_interval", TypeFactory::GetType(kYearMonthInterval));
- }
-
- void checkComparisonPredicateSerialization(const Comparison &comparison) {
- checkPredicateSerialization(ComparisonPredicate(comparison, createScalarInt(9), createScalarInt(-1)));
- checkPredicateSerialization(
- ComparisonPredicate(comparison, createScalarInt(0), createScalarLong(static_cast<int64_t>(9))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison, createScalarInt(4), createScalarFloat(static_cast<float>(1.2))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison, createScalarInt(7), createScalarDouble(static_cast<double>(3.14))));
-
- checkPredicateSerialization(
- ComparisonPredicate(comparison, createScalarLong(static_cast<int64_t>(-10)), createScalarInt(8)));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarLong(static_cast<int64_t>(9)),
- createScalarLong(static_cast<int64_t>(-9))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarLong(static_cast<int64_t>(-9)),
- createScalarFloat(static_cast<float>(1.2))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarLong(static_cast<int64_t>(9)),
- createScalarDouble(static_cast<double>(3.14))));
-
- checkPredicateSerialization(
- ComparisonPredicate(comparison, createScalarFloat(static_cast<float>(1.2)), createScalarInt(-1)));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarFloat(static_cast<float>(1.2)),
- createScalarLong(static_cast<int64_t>(-9))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarFloat(static_cast<float>(1.2)),
- createScalarFloat(static_cast<float>(-3.6))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarFloat(static_cast<float>(-1.2)),
- createScalarDouble(static_cast<double>(3.14))));
-
- checkPredicateSerialization(
- ComparisonPredicate(comparison, createScalarDouble(static_cast<double>(3.14)), createScalarInt(6)));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarDouble(static_cast<double>(3.14)),
- createScalarLong(static_cast<int64_t>(-9))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarDouble(static_cast<double>(-3.14)),
- createScalarFloat(static_cast<float>(1.2))));
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarDouble(static_cast<double>(3.14)),
- createScalarDouble(static_cast<double>(-3.14))));
-
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarDatetime(numeric_limits<int64_t>::max()),
- createScalarNull(TypeFactory::GetType(kDatetime,
- true /* nullable */))));
-
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarDatetimeInterval(numeric_limits<int64_t>::min()),
- createScalarNull(TypeFactory::GetType(kDatetimeInterval,
- true /* nullable */))));
-
- checkPredicateSerialization(
- ComparisonPredicate(comparison,
- createScalarYearMonthInterval(numeric_limits<int64_t>::max()),
- createScalarNull(TypeFactory::GetType(kYearMonthInterval,
- true /* nullable */))));
- }
-
- void checkPredicateSerialization(const Predicate &predicate) {
- unique_ptr<Predicate> predicate_from_proto(
- PredicateFactory::ReconstructFromProto(predicate.getProto(), *database_));
- comparePredicate(predicate, *predicate_from_proto);
- }
-
- CatalogRelation* createCatalogRelation(const std::string &name) {
- return database_->getRelationByIdMutable(database_->addRelation(new CatalogRelation(NULL, name)));
- }
-
- const CatalogAttribute* createCatalogAttribute(CatalogRelation* rel, const std::string &name, const Type &type) {
- rel->addAttribute(new CatalogAttribute(NULL, name, type));
- return rel->getAttributeByName(name);
- }
-
- static Scalar* createScalarNull(const Type &type) {
- return new ScalarLiteral(type.makeNullValue(), type);
- }
-
- static Scalar* createScalarInt(int int_literal) {
- return new ScalarLiteral(TypedValue(int_literal),
- TypeFactory::GetType(kInt));
- }
-
- static Scalar* createScalarLong(int64_t long_literal) {
- return new ScalarLiteral(TypedValue(long_literal),
- TypeFactory::GetType(kLong));
- }
-
- static Scalar* createScalarFloat(float float_literal) {
- return new ScalarLiteral(TypedValue(float_literal),
- TypeFactory::GetType(kFloat));
- }
-
- static Scalar* createScalarDouble(double double_literal) {
- return new ScalarLiteral(TypedValue(double_literal),
- TypeFactory::GetType(kDouble));
- }
-
- static Scalar* createScalarDatetime(int64_t tick) {
- DatetimeLit datetime;
- datetime.ticks = tick;
- return new ScalarLiteral(TypedValue(datetime),
- TypeFactory::GetType(kDatetime));
- }
-
- static Scalar* createScalarDatetimeInterval(int64_t tick) {
- DatetimeIntervalLit datetime_interval;
- datetime_interval.interval_ticks = tick;
- return new ScalarLiteral(TypedValue(datetime_interval),
- TypeFactory::GetType(kDatetimeInterval));
- }
-
- static Scalar* createScalarYearMonthInterval(int64_t month) {
- YearMonthIntervalLit year_month_interval;
- year_month_interval.months = month;
- return new ScalarLiteral(TypedValue(year_month_interval),
- TypeFactory::GetType(kYearMonthInterval));
- }
-
- static void comparePredicatePtrList(const PtrList<Predicate> &expected, const PtrList<Predicate> &checked) {
- ASSERT_EQ(expected.size(), checked.size());
-
- for (PtrList<Predicate>::const_iterator it_expected = expected.begin(), it_checked = checked.begin();
- it_expected != expected.end();
- ++it_expected, ++it_checked) {
- comparePredicate(*it_expected, *it_checked);
- }
- }
-
- static void comparePredicate(const Predicate &expected, const Predicate &checked) {
- ASSERT_EQ(expected.getPredicateType(), checked.getPredicateType());
-
- switch (expected.getPredicateType()) {
- case Predicate::kTrue: // Fall through.
- case Predicate::kFalse: {
- break;
- }
- case Predicate::kComparison: {
- EXPECT_TRUE(static_cast<const ComparisonPredicate&>(expected).getComparison().equals(
- static_cast<const ComparisonPredicate&>(checked).getComparison()));
-
- compareScalar(static_cast<const ComparisonPredicate&>(expected).getLeftOperand(),
- static_cast<const ComparisonPredicate&>(checked).getLeftOperand());
-
- compareScalar(static_cast<const ComparisonPredicate&>(expected).getRightOperand(),
- static_cast<const ComparisonPredicate&>(checked).getRightOperand());
- break;
- }
- case Predicate::kNegation: {
- EXPECT_EQ(expected.hasStaticResult(), checked.hasStaticResult());
- if (expected.hasStaticResult()) {
- EXPECT_EQ(expected.getStaticResult(), checked.getStaticResult());
- }
-
- comparePredicate(*static_cast<const NegationPredicate&>(expected).operand_,
- *static_cast<const NegationPredicate&>(checked).operand_);
- break;
- }
- case Predicate::kConjunction: // Fall through.
- case Predicate::kDisjunction: {
- EXPECT_EQ(expected.hasStaticResult(), checked.hasStaticResult());
- if (expected.hasStaticResult()) {
- EXPECT_EQ(expected.getStaticResult(), checked.getStaticResult());
- }
-
- comparePredicatePtrList(static_cast<const PredicateWithList&>(expected).static_operand_list_,
- static_cast<const PredicateWithList&>(checked).static_operand_list_);
- comparePredicatePtrList(static_cast<const PredicateWithList&>(expected).dynamic_operand_list_,
- static_cast<const PredicateWithList&>(checked).dynamic_operand_list_);
- break;
- }
- default:
- FATAL_ERROR("checked is not a valid PredicateType in comparePredicate");
- }
- }
-
- static void compareScalar(const Scalar &expected, const Scalar &checked) {
- ASSERT_EQ(expected.getDataSource(), checked.getDataSource());
- ASSERT_TRUE(expected.getType().equals(checked.getType()));
-
- switch (expected.getDataSource()) {
- case Scalar::kLiteral: {
- compareTypedValue(expected.getType(), expected.getStaticValue(), checked.getStaticValue());
- break;
- }
- case Scalar::kAttribute: {
- compareCatalogAttribute(static_cast<const ScalarAttribute&>(expected).getAttribute(),
- static_cast<const ScalarAttribute&>(checked).getAttribute());
- break;
- }
- case Scalar::kUnaryExpression: {
- EXPECT_EQ(expected.hasStaticValue(), checked.hasStaticValue());
- if (expected.hasStaticValue()) {
- compareTypedValue(expected.getType(), expected.getStaticValue(), checked.getStaticValue());
- }
-
- EXPECT_EQ(static_cast<const ScalarUnaryExpression&>(expected).operation_.getUnaryOperationID(),
- static_cast<const ScalarUnaryExpression&>(checked).operation_.getUnaryOperationID());
- compareScalar(*(static_cast<const ScalarUnaryExpression&>(expected).operand_),
- *(static_cast<const ScalarUnaryExpression&>(checked).operand_));
- break;
- }
- case Scalar::kBinaryExpression: {
- EXPECT_EQ(expected.hasStaticValue(), checked.hasStaticValue());
- if (expected.hasStaticValue()) {
- compareTypedValue(expected.getType(), expected.getStaticValue(), checked.getStaticValue());
- }
-
- EXPECT_EQ(static_cast<const ScalarBinaryExpression&>(expected).operation_.getBinaryOperationID(),
- static_cast<const ScalarBinaryExpression&>(checked).operation_.getBinaryOperationID());
- compareScalar(*(static_cast<const ScalarBinaryExpression&>(expected).left_operand_),
- *(static_cast<const ScalarBinaryExpression&>(checked).left_operand_));
- compareScalar(*(static_cast<const ScalarBinaryExpression&>(expected).right_operand_),
- *(static_cast<const ScalarBinaryExpression&>(checked).right_operand_));
- break;
- }
- default:
- FATAL_ERROR("checked is not a valid Scalar in compareScalar");
- }
- }
-
- static void compareTypedValue(const Type &type,
- const TypedValue &expected,
- const TypedValue &checked) {
- ASSERT_EQ(expected.isNull(), checked.isNull());
-
- if (expected.isNull()) {
- return;
- }
-
- switch (type.getTypeID()) {
- case kInt:
- EXPECT_EQ(expected.getLiteral<int>(), checked.getLiteral<int>());
- break;
- case kLong:
- EXPECT_EQ(expected.getLiteral<int64_t>(), checked.getLiteral<int64_t>());
- break;
- case kFloat:
- EXPECT_FLOAT_EQ(expected.getLiteral<float>(), checked.getLiteral<float>());
- break;
- case kDouble:
- EXPECT_DOUBLE_EQ(expected.getLiteral<double>(), checked.getLiteral<double>());
- break;
- case kDatetime:
- EXPECT_EQ(expected.getLiteral<DatetimeLit>(), checked.getLiteral<DatetimeLit>());
- break;
- case kDatetimeInterval:
- EXPECT_EQ(expected.getLiteral<DatetimeIntervalLit>(), checked.getLiteral<DatetimeIntervalLit>());
- break;
- case kYearMonthInterval:
- EXPECT_EQ(expected.getLiteral<YearMonthIntervalLit>(), checked.getLiteral<YearMonthIntervalLit>());
- break;
- case kChar: // Fall through.
- case kVarChar:
- EXPECT_EQ(expected.getDataSize(), checked.getDataSize());
- EXPECT_EQ(expected.getAsciiStringLength(), checked.getAsciiStringLength());
- EXPECT_STREQ(static_cast<const char*>(expected.getDataPtr()),
- static_cast<const char*>(checked.getDataPtr()));
- break;
- default:
- FATAL_ERROR("Unrecognized Type in compareTypedValue");
- }
- }
-
- static void compareCatalogAttribute(const CatalogAttribute &expected, const CatalogAttribute &checked) {
- EXPECT_EQ(expected.getID(), checked.getID());
- EXPECT_EQ(expected.getName(), checked.getName());
- EXPECT_TRUE(expected.getType().equals(checked.getType()));
- }
-
- unique_ptr<CatalogDatabase> database_;
- // Both pointers below are owned by database_.
- CatalogRelation *rel_numeric_, *rel_date_;
- // All pointers below are owned by relations.
- const CatalogAttribute *attr_int_, *attr_long_, *attr_float_, *attr_double_,
- *attr_datetime_, *attr_datetime_interval_, *attr_year_month_interval_;
-};
-
-TEST_F(PredicateTest, TrivialPredicateSerializationTest) {
- checkPredicateSerialization(TruePredicate());
- checkPredicateSerialization(FalsePredicate());
-}
-
-TEST_F(PredicateTest, NegationPredicateSerializationTest) {
- checkPredicateSerialization(NegationPredicate(new TruePredicate()));
- checkPredicateSerialization(NegationPredicate(new FalsePredicate()));
-
- checkPredicateSerialization(
- NegationPredicate(new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kEqual),
- new ScalarAttribute(*attr_int_),
- createScalarInt(-1))));
- checkPredicateSerialization(
- NegationPredicate(new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kNotEqual),
- new ScalarAttribute(*attr_long_),
- createScalarLong(numeric_limits<int64_t>::max()))));
- checkPredicateSerialization(
- NegationPredicate(new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kLess),
- new ScalarAttribute(*attr_float_),
- createScalarFloat(numeric_limits<float>::max()))));
- checkPredicateSerialization(
- NegationPredicate(new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kLessOrEqual),
- new ScalarAttribute(*attr_double_),
- createScalarDouble(numeric_limits<double>::max()))));
- checkPredicateSerialization(
- NegationPredicate(new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kGreater),
- new ScalarAttribute(*attr_datetime_),
- createScalarDatetime(numeric_limits<int64_t>::min()))));
- checkPredicateSerialization(
- NegationPredicate(new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kGreaterOrEqual),
- new ScalarAttribute(*attr_datetime_interval_),
- createScalarDatetimeInterval(numeric_limits<int64_t>::min()))));
-}
-
-TEST_F(PredicateTest, ComparisonPredicateSerializationTest) {
- checkComparisonPredicateSerialization(ComparisonFactory::GetComparison(ComparisonID::kEqual));
- checkComparisonPredicateSerialization(ComparisonFactory::GetComparison(ComparisonID::kNotEqual));
- checkComparisonPredicateSerialization(ComparisonFactory::GetComparison(ComparisonID::kLess));
- checkComparisonPredicateSerialization(ComparisonFactory::GetComparison(ComparisonID::kLessOrEqual));
- checkComparisonPredicateSerialization(ComparisonFactory::GetComparison(ComparisonID::kGreater));
- checkComparisonPredicateSerialization(ComparisonFactory::GetComparison(ComparisonID::kGreaterOrEqual));
-}
-
-TEST_F(PredicateTest, ConjunctionPredicateSerializationTest) {
- ConjunctionPredicate predicate;
- predicate.addPredicate(new TruePredicate());
- predicate.addPredicate(NegationPredicate::NegatePredicate(new FalsePredicate()));
- predicate.addPredicate(NegationPredicate::NegatePredicate(
- new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kGreaterOrEqual),
- new ScalarAttribute(*attr_year_month_interval_),
- createScalarYearMonthInterval(numeric_limits<int64_t>::min()))));
-
- checkPredicateSerialization(predicate);
-}
-
-TEST_F(PredicateTest, DisjunctionPredicateSerializationTest) {
- DisjunctionPredicate predicate;
- predicate.addPredicate(new FalsePredicate());
- predicate.addPredicate(NegationPredicate::NegatePredicate(new TruePredicate()));
- predicate.addPredicate(NegationPredicate::NegatePredicate(
- new ComparisonPredicate(ComparisonFactory::GetComparison(ComparisonID::kLess),
- new ScalarAttribute(*attr_year_month_interval_),
- createScalarYearMonthInterval(numeric_limits<int64_t>::max()))));
-
- checkPredicateSerialization(predicate);
-}
-
-} // namespace quickstep