You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by ha...@apache.org on 2016/06/17 18:22:21 UTC
incubator-quickstep git commit: Additional changes to fix compile
errors and documentation is added.
Repository: incubator-quickstep
Updated Branches:
refs/heads/decimal-type 5646d0320 -> 18f526050
Additional changes to fix compile errors and documentation is added.
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/18f52605
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/18f52605
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/18f52605
Branch: refs/heads/decimal-type
Commit: 18f526050a7109445ce289921399db179c122bec
Parents: 5646d03
Author: Hakan Memisoglu <ha...@apache.org>
Authored: Fri Jun 17 13:21:56 2016 -0500
Committer: Hakan Memisoglu <ha...@apache.org>
Committed: Fri Jun 17 13:21:56 2016 -0500
----------------------------------------------------------------------
types/CMakeLists.txt | 4 +-
types/DecimalLit.hpp | 139 ++++++++++++++++++-
types/DecimalType.cpp | 2 +-
types/operations/comparisons/ComparisonUtil.hpp | 4 +-
4 files changed, 142 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/18f52605/types/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt
index eb2d4ba..9522ed6 100644
--- a/types/CMakeLists.txt
+++ b/types/CMakeLists.txt
@@ -104,8 +104,8 @@ target_link_libraries(quickstep_types_DecimalType
quickstep_types_Type
quickstep_types_TypeID
quickstep_types_TypedValue
- quickstep_utility_Macros
- quickstep_utility_EqualsAnyConstant)
+ quickstep_utility_EqualsAnyConstant
+ quickstep_utility_Macros)
target_link_libraries(quickstep_types_DoubleType
quickstep_types_NullCoercibilityCheckMacro
quickstep_types_NumericSuperType
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/18f52605/types/DecimalLit.hpp
----------------------------------------------------------------------
diff --git a/types/DecimalLit.hpp b/types/DecimalLit.hpp
index d1e2255..0d6933e 100644
--- a/types/DecimalLit.hpp
+++ b/types/DecimalLit.hpp
@@ -31,93 +31,228 @@ namespace quickstep {
* @brief A literal representing fixed-precision decimal.
**/
struct DecimalLit {
+ /**
+ * @brief Underlying data type.
+ **/
typedef std::int64_t data_type;
- static DecimalLit fromDouble(double value) {
+ /**
+ * @brief Builder for DecimalLit.
+ *
+ * @param value Corresponding floating point number to be converted to
+ * the DecimalLit.
+ * @return The resulting DecimalLit converted from the floating point.
+ **/
+ static DecimalLit fromDouble(const double value) {
return DecimalLit{static_cast<data_type>(value * kMaxFractionInt)};
}
- static DecimalLit fromInt(int64_t value) {
+ /**
+ * @brief Builder for DecimalLit.
+ *
+ * @param value Corresponding integer number to be converted to
+ * the DecimalLit.
+ * @return The resulting DecimalLit conveted from the integer number.
+ **/
+ static DecimalLit fromInt(const int64_t value) {
return DecimalLit{static_cast<data_type>(value * kMaxFractionInt)};
}
data_type data_;
+ /**
+ * @brief Number of decimals after point.
+ **/
static constexpr std::int64_t kPrecisionWidth = 2;
+ /**
+ * @brief Normalization factor between Decimal type and floating point types.
+ * It is always equal to pow(10, kPrecisionWidth).
+ **/
static constexpr std::int64_t kMaxFractionInt = 100;
+ /**
+ * @brief Getter for the fractional part of the Decimal type.
+ *
+ * @return Fractional part of the Decimal number as unsigned.
+ **/
inline std::uint64_t getFractionalPart() const {
return static_cast<std::uint64_t>(static_cast<std::uint64_t>(std::abs(data_)) % kMaxFractionInt);
}
+ /**
+ * @brief Getter for the integer part of the Decimal type.
+ *
+ * @return Integer part of the Decimal number as signed.
+ **/
inline std::int64_t getIntegerPart() const {
return static_cast<std::int64_t>(data_ / kMaxFractionInt);
}
+ /**
+ * @brief Operator overloading for "less than".
+ *
+ * @param other Other DecimalLit to be compared.
+ * @return True if this is less than other,
+ * false otherwise.
+ **/
inline bool operator<(const DecimalLit& other) const {
return data_ < other.data_;
}
+ /**
+ * @brief Operator overloading for "greater than".
+ *
+ * @param other Other DecimalLit to be compared.
+ * @return True if this is greater than other,
+ * false otherwise.
+ **/
inline bool operator>(const DecimalLit& other) const {
return data_ > other.data_;
}
+ /**
+ * @brief Operator overloading for "less than or equal to".
+ *
+ * @param other Other DecimalLit to be compared.
+ * @return True if this is less than or equal to other,
+ * false otherwise.
+ **/
inline bool operator<=(const DecimalLit& other) const {
return data_ <= other.data_;
}
+ /**
+ * @brief Operator overloading for "greater than or equal to".
+ *
+ * @param other Other DecimalLit to be compared.
+ * @return True if this is greater than or equal to other,
+ * false otherwise.
+ **/
inline bool operator>=(const DecimalLit& other) const {
return data_ >= other.data_;
}
+ /**
+ * @brief Operator overloading for "equal to".
+ *
+ * @param other Other DecimalLit to be compared.
+ * @return True if this is equal to other,
+ * false otherwise.
+ **/
inline bool operator==(const DecimalLit& other) const {
return data_ == other.data_;
}
+ /**
+ * @brief Operator overloading for "not equal to".
+ *
+ * @param other Other DecimalLit to be compared.
+ * @return True if this is not equal to other,
+ * false otherwise.
+ **/
inline bool operator!=(const DecimalLit& other) const {
return data_ != other.data_;
}
+ /**
+ * @brief Operator overloading for "negate".
+ *
+ * @return Negative of this.
+ **/
inline DecimalLit operator-() const {
return DecimalLit{-data_};
}
+ /**
+ * @brief Operator overloading for "plus".
+ *
+ * @param other Other DecimalLit to be added.
+ * @return Sum of this and other.
+ **/
inline DecimalLit operator+(const DecimalLit& other) const {
return DecimalLit{data_ + other.data_};
}
+ /**
+ * @brief Operator overloading for "subtract".
+ *
+ * @param other Other DecimalLit to be subtract.
+ * @return Subtraction of other from this.
+ **/
inline DecimalLit operator-(const DecimalLit& other) const {
return DecimalLit{data_ - other.data_};
}
+ /**
+ * @brief Operator overloading for "multiply".
+ *
+ * @param other Other DecimalLit to be multiplied.
+ * @return Multiplication of this and other.
+ **/
inline DecimalLit operator*(const DecimalLit& other) const {
return DecimalLit{(data_ * other.data_) / kMaxFractionInt};
}
+ /**
+ * @brief Operator overloading for "division".
+ *
+ * @param other Divisor DecimalLit.
+ * @return Division of this with other.
+ **/
inline DecimalLit operator/(const DecimalLit& other) const {
return DecimalLit{(data_ * kMaxFractionInt) / other.data_};
}
+ /**
+ * @brief Operator overloading for "modulo".
+ *
+ * @param other Mod DecimalLit.
+ * @return This modulo other.
+ **/
inline DecimalLit operator%(const DecimalLit& other) const {
return DecimalLit{data_ % other.data_};
}
+ /**
+ * @brief Operator overloading for "inplace add".
+ *
+ * @param other DecimalLit to be added.
+ * @return Reference to this.
+ **/
inline DecimalLit& operator+=(const DecimalLit& other) {
data_ += other.data_;
return *this;
}
+ /**
+ * @brief Operator overloading for "inplace subtract".
+ *
+ * @param other DecimalLit to be subtracted.
+ * @return Reference to this.
+ **/
inline DecimalLit& operator-=(const DecimalLit& other) {
data_ -= other.data_;
return *this;
}
+ /**
+ * @brief Operator overloading for "inplace multiply".
+ *
+ * @param other DecimalLit to be multiplied.
+ * @return Reference to this.
+ **/
inline DecimalLit& operator*=(const DecimalLit& other) {
data_ = (data_ * other.data_) / kMaxFractionInt;
return *this;
}
+ /**
+ * @brief Operator overloading for "inplace divide".
+ *
+ * @param other DecimalLit to be divided.
+ * @return Reference to this.
+ **/
inline DecimalLit& operator/=(const DecimalLit& other) {
data_ = (data_ * kMaxFractionInt) / other.data_;
return *this;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/18f52605/types/DecimalType.cpp
----------------------------------------------------------------------
diff --git a/types/DecimalType.cpp b/types/DecimalType.cpp
index db41033..29c441a 100644
--- a/types/DecimalType.cpp
+++ b/types/DecimalType.cpp
@@ -104,7 +104,7 @@ bool DecimalType::parseValueFromString(const std::string &value_string,
&parsed_double,
&read_chars);
- if (matched != 1 || read_chars != value_string.length()) {
+ if (matched != 1 || read_chars != static_cast<int>(value_string.length())) {
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/18f52605/types/operations/comparisons/ComparisonUtil.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/ComparisonUtil.hpp b/types/operations/comparisons/ComparisonUtil.hpp
index 2e381b7..9ffeeec 100644
--- a/types/operations/comparisons/ComparisonUtil.hpp
+++ b/types/operations/comparisons/ComparisonUtil.hpp
@@ -709,8 +709,8 @@ auto InvokeOnBothLessComparatorsForDifferentTypesIgnoreNullability(
return functor(comp, comp_reversed);
}
case kLong: {
- LessLiteralUncheckedComparator<DecimalLit, false, long, false> comp;
- LessLiteralUncheckedComparator<long, false, DecimalLit, false> comp_reversed;
+ LessLiteralUncheckedComparator<DecimalLit, false, std::int64_t, false> comp;
+ LessLiteralUncheckedComparator<std::int64_t, false, DecimalLit, false> comp_reversed;
return functor(comp, comp_reversed);
}
case kFloat: {