[Groonga-commit] groonga/grnxx at c5e54ce [new_data_types] Rename Int::value() to raw(). (#116)

Zurück zum Archiv-Index

susumu.yata null+****@clear*****
Tue Nov 25 12:44:39 JST 2014


susumu.yata	2014-11-25 12:44:39 +0900 (Tue, 25 Nov 2014)

  New Revision: c5e54ce02be179dff250b83b75f80f4b1683ca9b
  https://github.com/groonga/grnxx/commit/c5e54ce02be179dff250b83b75f80f4b1683ca9b

  Message:
    Rename Int::value() to raw(). (#116)

  Modified files:
    include/grnxx/data_types/scalar/geo_point.hpp
    include/grnxx/data_types/scalar/int.hpp
    include/grnxx/data_types/scalar/text.hpp
    include/grnxx/data_types/typecast.hpp
    include/grnxx/data_types/vector/bool.hpp
    include/grnxx/data_types/vector/float.hpp
    include/grnxx/data_types/vector/geo_point.hpp
    include/grnxx/data_types/vector/int.hpp
    include/grnxx/data_types/vector/text.hpp
    lib/grnxx/impl/column/scalar/bool.cpp
    lib/grnxx/impl/column/scalar/bool.hpp
    lib/grnxx/impl/column/scalar/float.cpp
    lib/grnxx/impl/column/scalar/float.hpp
    lib/grnxx/impl/column/scalar/geo_point.cpp
    lib/grnxx/impl/column/scalar/geo_point.hpp
    lib/grnxx/impl/column/scalar/int.cpp
    lib/grnxx/impl/column/scalar/int.hpp
    lib/grnxx/impl/column/scalar/text.cpp
    lib/grnxx/impl/column/scalar/text.hpp
    lib/grnxx/impl/column/vector/bool.cpp
    lib/grnxx/impl/column/vector/bool.hpp
    lib/grnxx/impl/column/vector/float.cpp
    lib/grnxx/impl/column/vector/float.hpp
    lib/grnxx/impl/column/vector/geo_point.cpp
    lib/grnxx/impl/column/vector/geo_point.hpp
    lib/grnxx/impl/column/vector/int.cpp
    lib/grnxx/impl/column/vector/int.hpp
    lib/grnxx/impl/column/vector/text.cpp
    lib/grnxx/impl/column/vector/text.hpp
    lib/grnxx/impl/expression.cpp
    lib/grnxx/impl/merger.cpp
    lib/grnxx/impl/table.cpp
    lib/grnxx/impl/table.hpp

  Modified: include/grnxx/data_types/scalar/geo_point.hpp (+2 -2)
===================================================================
--- include/grnxx/data_types/scalar/geo_point.hpp    2014-11-25 11:29:33 +0900 (17f194a)
+++ include/grnxx/data_types/scalar/geo_point.hpp    2014-11-25 12:44:39 +0900 (ad4ecce)
@@ -28,8 +28,8 @@ class GeoPoint {
   GeoPoint(Int latitude_in_milliseconds, Int longitude_in_milliseconds)
       : latitude_(),
         longitude_() {
-    int64_t latitude = latitude_in_milliseconds.value();
-    int64_t longitude = longitude_in_milliseconds.value();
+    int64_t latitude = latitude_in_milliseconds.raw();
+    int64_t longitude = longitude_in_milliseconds.raw();
     if ((latitude >= min_latitude()) && (latitude <= max_latitude()) &&
         (longitude >= min_longitude()) && (longitude <= max_longitude())) {
       if ((latitude == min_latitude()) || (latitude == max_latitude())) {

  Modified: include/grnxx/data_types/scalar/int.hpp (+89 -91)
===================================================================
--- include/grnxx/data_types/scalar/int.hpp    2014-11-25 11:29:33 +0900 (6d14b72)
+++ include/grnxx/data_types/scalar/int.hpp    2014-11-25 12:44:39 +0900 (4056b56)
@@ -21,21 +21,21 @@ class Int {
   constexpr Int(const Int &) = default;
   Int &operator=(const Int &) = default;
 
-  explicit constexpr Int(int64_t value) : value_(value) {}
-  explicit constexpr Int(NA) : value_(na_value()) {}
+  explicit constexpr Int(int64_t raw) : raw_(raw) {}
+  explicit constexpr Int(NA) : raw_(raw_na()) {}
 
-  constexpr int64_t value() const {
-    return value_;
+  constexpr int64_t raw() const {
+    return raw_;
   }
 
   constexpr bool is_min() const {
-    return value_ == min_value();
+    return raw_ == raw_min();
   }
   constexpr bool is_max() const {
-    return value_ == max_value();
+    return raw_ == raw_max();
   }
   constexpr bool is_na() const {
-    return value_ == na_value();
+    return raw_ == raw_na();
   }
 
   // -- Unary operators --
@@ -43,20 +43,20 @@ class Int {
   constexpr Int operator+() const {
     return *this;
   }
-  // NOTE: This implementation assumes that -na_value() returns na_value(),
-  //       although -na_value() in two's complement causes an overflow and
+  // NOTE: This implementation assumes that -raw_na() returns raw_na(),
+  //       although -raw_na() in two's complement causes an overflow and
   //       the behavior is undefined in C/C++.
   //       If this assumption is wrong, N/A must be excluded.
   constexpr Int operator-() const {
-    return Int(-value_);
+    return Int(-raw_);
   }
   constexpr Int operator~() const {
-    return is_na() ? na() : Int(~value_);
+    return is_na() ? na() : Int(~raw_);
   }
 
   Int &operator++() & {
     if (!is_na()) {
-      ++value_;
+      ++raw_;
     }
     return *this;
   }
@@ -64,11 +64,11 @@ class Int {
     if (is_na()) {
       return na();
     }
-    return Int(value_++);
+    return Int(raw_++);
   }
   Int &operator--() & {
     if (!is_na()) {
-      --value_;
+      --raw_;
     }
     return *this;
   }
@@ -76,36 +76,36 @@ class Int {
     if (is_na()) {
       return na();
     }
-    return Int(value_--);
+    return Int(raw_--);
   }
 
   // -- Binary operators --
 
   constexpr Int operator&(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? na() : Int(value_ & rhs.value_);
+    return (is_na() || rhs.is_na()) ? na() : Int(raw_ & rhs.raw_);
   }
   constexpr Int operator|(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? na() : Int(value_ | rhs.value_);
+    return (is_na() || rhs.is_na()) ? na() : Int(raw_ | rhs.raw_);
   }
   constexpr Int operator^(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? na() : Int(value_ ^ rhs.value_);
+    return (is_na() || rhs.is_na()) ? na() : Int(raw_ ^ rhs.raw_);
   }
 
   Int &operator&=(Int rhs) & {
     if (!is_na()) {
-      value_ = rhs.is_na() ? na_value() : (value_ & rhs.value_);
+      raw_ = rhs.is_na() ? raw_na() : (raw_ & rhs.raw_);
     }
     return *this;
   }
   Int &operator|=(Int rhs) & {
     if (!is_na()) {
-      value_ = rhs.is_na() ? na_value() : (value_ | rhs.value_);
+      raw_ = rhs.is_na() ? raw_na() : (raw_ | rhs.raw_);
     }
     return *this;
   }
   Int &operator^=(Int rhs) & {
     if (!is_na()) {
-      value_ = rhs.is_na() ? na_value() : (value_ ^ rhs.value_);
+      raw_ = rhs.is_na() ? raw_na() : (raw_ ^ rhs.raw_);
     }
     return *this;
   }
@@ -114,8 +114,8 @@ class Int {
 
   constexpr Int operator<<(Int rhs) const {
     return (is_na() || rhs.is_na() ||
-            (static_cast<uint64_t>(rhs.value_) >= 64)) ?
-           na() : Int(value_ << rhs.value_);
+            (static_cast<uint64_t>(rhs.raw_) >= 64)) ?
+             na() : Int(raw_ << rhs.raw_);
   }
   // NOTE: This is an arithmetic shift.
   constexpr Int operator>>(Int rhs) const {
@@ -124,10 +124,10 @@ class Int {
 
   Int &operator<<=(Int rhs) & {
     if (!is_na()) {
-      if (rhs.is_na() || (static_cast<uint64_t>(rhs.value_) >= 64)) {
-        value_ = na_value();
+      if (rhs.is_na() || (static_cast<uint64_t>(rhs.raw_) >= 64)) {
+        raw_ = raw_na();
       } else {
-        value_ <<= rhs.value_;
+        raw_ <<= rhs.raw_;
       }
     }
     return *this;
@@ -135,10 +135,10 @@ class Int {
   // NOTE: This is an arithmetic shift.
   Int &operator>>=(Int rhs) & {
     if (!is_na()) {
-      if (rhs.is_na() || (static_cast<uint64_t>(rhs.value_) >= 64)) {
-        value_ = na_value();
+      if (rhs.is_na() || (static_cast<uint64_t>(rhs.raw_) >= 64)) {
+        raw_ = raw_na();
       } else {
-        value_ >>= rhs.value_;
+        raw_ >>= rhs.raw_;
       }
     }
     return *this;
@@ -146,13 +146,13 @@ class Int {
 
   constexpr Int arithmetic_right_shift(Int rhs) const {
     return (is_na() || rhs.is_na() ||
-            (static_cast<uint64_t>(rhs.value_) >= 64)) ?
-           na() : Int(value_ >> rhs.value_);
+            (static_cast<uint64_t>(rhs.raw_) >= 64)) ?
+           na() : Int(raw_ >> rhs.raw_);
   }
   constexpr Int logical_right_shift(Int rhs) const {
     return (is_na() || rhs.is_na() ||
-            (static_cast<uint64_t>(rhs.value_) >= 64)) ?
-           na() : Int(static_cast<uint64_t>(value_) >> rhs.value_);
+            (static_cast<uint64_t>(rhs.raw_) >= 64)) ?
+           na() : Int(static_cast<uint64_t>(raw_) >> rhs.raw_);
   }
 
   // -- Arithmetic operators --
@@ -168,12 +168,12 @@ class Int {
     return multiply(*this, rhs);
   };
   Int operator/(Int rhs) const {
-    return (is_na() || rhs.is_na() || (rhs.value_ == 0)) ?
-           na() : Int(value_ / rhs.value_);
+    return (is_na() || rhs.is_na() || (rhs.raw_ == 0)) ?
+           na() : Int(raw_ / rhs.raw_);
   }
   Int operator%(Int rhs) const {
-    return (is_na() || rhs.is_na() || (rhs.value_ == 0)) ?
-           na() : Int(value_ % rhs.value_);
+    return (is_na() || rhs.is_na() || (rhs.raw_ == 0)) ?
+           na() : Int(raw_ % rhs.raw_);
   }
 
   Int &operator+=(Int rhs) & {
@@ -187,15 +187,13 @@ class Int {
   }
   Int &operator/=(Int rhs) &{
     if (!is_na()) {
-      value_ = (rhs.is_na() || (rhs.value_ == 0)) ?
-               na_value() : (value_ / rhs.value_);
+      raw_ = (rhs.is_na() || (rhs.raw_ == 0)) ? raw_na() : (raw_ / rhs.raw_);
     }
     return *this;
   }
   Int &operator%=(Int rhs) &{
     if (!is_na()) {
-      value_ = (rhs.is_na() || (rhs.value_ == 0)) ?
-               na_value() : (value_ % rhs.value_);
+      raw_ = (rhs.is_na() || (rhs.raw_ == 0)) ? raw_na() : (raw_ % rhs.raw_);
     }
     return *this;
   }
@@ -203,29 +201,29 @@ class Int {
   // -- Comparison operators --
 
   constexpr Bool operator==(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ == rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ == rhs.raw_);
   }
   constexpr Bool operator!=(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ != rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ != rhs.raw_);
   }
   constexpr Bool operator<(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ < rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ < rhs.raw_);
   }
   constexpr Bool operator>(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ > rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ > rhs.raw_);
   }
   constexpr Bool operator<=(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ <= rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ <= rhs.raw_);
   }
   constexpr Bool operator>=(Int rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ >= rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ >= rhs.raw_);
   }
 
   constexpr bool match(Int rhs) const {
-    return value_ == rhs.value_;
+    return raw_ == rhs.raw_;
   }
   constexpr bool unmatch(Int rhs) const {
-    return value_ != rhs.value_;
+    return raw_ != rhs.raw_;
   }
 
   // -- Typecast (grnxx/data_types/typecast.hpp) --
@@ -237,27 +235,27 @@ class Int {
   }
 
   static constexpr Int min() {
-    return Int(min_value());
+    return Int(raw_min());
   }
   static constexpr Int max() {
-    return Int(max_value());
+    return Int(raw_max());
   }
   static constexpr Int na() {
     return Int(NA());
   }
 
-  static constexpr int64_t min_value() {
+  static constexpr int64_t raw_min() {
     return std::numeric_limits<int64_t>::min() + 1;
   }
-  static constexpr int64_t max_value() {
+  static constexpr int64_t raw_max() {
     return std::numeric_limits<int64_t>::max();
   }
-  static constexpr int64_t na_value() {
+  static constexpr int64_t raw_na() {
     return std::numeric_limits<int64_t>::min();
   }
 
  private:
-  int64_t value_;
+  int64_t raw_;
 
 #if defined(GRNXX_GNUC) && defined(GRNXX_X86_64)
   // TODO: Implementations for MSC should be written.
@@ -270,8 +268,8 @@ class Int {
              "JNO GRNXX_INT_ADD_OVERFLOW%=;"
              "MOV %2, %0;"
              "GRNXX_INT_ADD_OVERFLOW%=:"
-             : "+r" (lhs.value_)
-             : "r" (rhs.value_), "r" (na_value())
+             : "+r" (lhs.raw_)
+             : "r" (rhs.raw_), "r" (raw_na())
              : "cc");
     return lhs;
   }
@@ -283,8 +281,8 @@ class Int {
              "JNO GRNXX_INT_SUBTRACT_OVERFLOW%=;"
              "MOV %2, %0;"
              "GRNXX_INT_SUBTRACT_OVERFLOW%=:"
-             : "+r" (lhs.value_)
-             : "r" (rhs.value_), "r" (na_value())
+             : "+r" (lhs.raw_)
+             : "r" (rhs.raw_), "r" (raw_na())
              : "cc");
     return lhs;
   }
@@ -296,8 +294,8 @@ class Int {
              "JNO GRNXX_INT_MULTIPLY_OVERFLOW%=;"
              "MOV %2, %0;"
              "GRNXX_INT_MULTIPLY_OVERFLOW%=:"
-             : "+r" (lhs.value_)
-             : "r" (rhs.value_), "r" (na_value())
+             : "+r" (lhs.raw_)
+             : "r" (rhs.raw_), "r" (raw_na())
              : "cc");
     return lhs;
   }
@@ -311,35 +309,35 @@ class Int {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
     }
-    int64_t result_value = lhs.value_ + rhs.value_;
-    lhs.value_ ^= result_value;
-    rhs.value_ ^= result_value;
-    if (static_cast<uint64_t>(lhs.value_ & rhs.value_) >> 63) {
+    int64_t result_raw = lhs.raw_ + rhs.raw_;
+    lhs.raw_ ^= result_raw;
+    rhs.raw_ ^= result_raw;
+    if (static_cast<uint64_t>(lhs.raw_ & rhs.raw_) >> 63) {
       return na();
     }
-    return Int(result_value);
+    return Int(result_raw);
   }
   static Int subtract(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
     }
-    int64_t result_value = lhs.value_ - rhs.value_;
-    lhs.value_ ^= result_value;
-    rhs.value_ ^= result_value;
-    if (static_cast<uint64_t>(lhs.value_ & rhs.value_) >> 63) {
+    int64_t result_raw = lhs.raw_ - rhs.raw_;
+    lhs.raw_ ^= result_raw;
+    rhs.raw_ ^= result_raw;
+    if (static_cast<uint64_t>(lhs.raw_ & rhs.raw_) >> 63) {
       return na();
     }
-    return Int(result_value);
+    return Int(result_raw);
   }
   static Int multiply(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
     }
-    if (rhs.value_ == 0) {
+    if (rhs.raw_ == 0) {
       return Int(0);
     }
-    int64_t result = lhs.value_ * rhs.value_;
-    if ((result / rhs.value_) != lhs.value_) {
+    int64_t result = lhs.raw_ * rhs.raw_;
+    if ((result / rhs.raw_) != lhs.raw_) {
       return na();
     }
     return Int(result);
@@ -350,59 +348,59 @@ class Int {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
     }
-    if (lhs.value_ >= 0) {
-      if (rhs.value_ > (max_value() - lhs.value_)) {
+    if (lhs.raw_ >= 0) {
+      if (rhs.raw_ > (raw_max() - lhs.raw_)) {
         return na();
       }
     } else {
-      if (rhs.value_ < (min_value() - lhs.value_)) {
+      if (rhs.raw_ < (raw_min() - lhs.raw_)) {
         return na();
       }
     }
-    return Int(lhs.value_ + rhs.value_);
+    return Int(lhs.raw_ + rhs.raw_);
   }
   static Int subtract(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
     }
-    if (rhs.value_ >= 0) {
-      if (lhs.value_ < (min_value() + rhs.value_)) {
+    if (rhs.raw_ >= 0) {
+      if (lhs.raw_ < (raw_min() + rhs.raw_)) {
         return na();
       }
     } else {
-      if (lhs.value_ > (max_value() + rhs.value_)) {
+      if (lhs.raw_ > (raw_max() + rhs.raw_)) {
         return na();
       }
     }
-    return Int(lhs.value_ - rhs.value_);
+    return Int(lhs.raw_ - rhs.raw_);
   }
   static Int multiply(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
     }
-    if (rhs.value_ == 0) {
+    if (rhs.raw_ == 0) {
       return Int(0);
     }
-    if (lhs.value_ >= 0) {
-      if (rhs.value_ > 0) {
-        if (lhs.value_ > (max_value() / rhs.value_)) {
+    if (lhs.raw_ >= 0) {
+      if (rhs.raw_ > 0) {
+        if (lhs.raw_ > (raw_max() / rhs.raw_)) {
           return na();
         }
       } else {
-        if (lhs.value_ > (min_value() / rhs.value_)) {
+        if (lhs.raw_ > (raw_min() / rhs.raw_)) {
           return na();
         }
       }
-    } else if (rhs.value_ > 0) {
-      if (lhs.value_ < (min_value() / rhs.value_)) {
+    } else if (rhs.raw_ > 0) {
+      if (lhs.raw_ < (raw_min() / rhs.raw_)) {
         return na();
       }
     } else {
-      if (lhs.value_ < (max_value() / rhs.value_)) {
+      if (lhs.raw_ < (raw_max() / rhs.raw_)) {
         return na();
       }
     }
-    return Int(lhs.value_ * rhs.value_);
+    return Int(lhs.raw_ * rhs.raw_);
   }
 # endif  // GRNXX_WRAP_AROUND
 };

  Modified: include/grnxx/data_types/scalar/text.hpp (+10 -10)
===================================================================
--- include/grnxx/data_types/scalar/text.hpp    2014-11-25 11:29:33 +0900 (152b8d9)
+++ include/grnxx/data_types/scalar/text.hpp    2014-11-25 12:44:39 +0900 (ab430ba)
@@ -40,7 +40,7 @@ class Text {
   }
 
   constexpr bool is_empty() const {
-    return size_.value() == 0;
+    return size_.raw() == 0;
   }
   constexpr bool is_na() const {
     return size_.is_na();
@@ -49,14 +49,14 @@ class Text {
   Bool operator==(const Text &rhs) const {
     Bool has_equal_size = (size_ == rhs.size_);
     if (has_equal_size.is_true()) {
-      return Bool(std::memcmp(data_, rhs.data_, size_.value()) == 0);
+      return Bool(std::memcmp(data_, rhs.data_, size_.raw()) == 0);
     }
     return has_equal_size;
   }
   Bool operator!=(const Text &rhs) const {
     Bool has_not_equal_size = (size_ != rhs.size_);
     if (has_not_equal_size.is_false()) {
-      return Bool(std::memcmp(data_, rhs.data_, size_.value()) != 0);
+      return Bool(std::memcmp(data_, rhs.data_, size_.raw()) != 0);
     }
     return has_not_equal_size;
   }
@@ -66,7 +66,7 @@ class Text {
       return Bool::na();
     }
     size_t min_size = has_less_size.is_true() ?
-                      size_.value() : rhs.size_.value();
+                      size_.raw() : rhs.size_.raw();
     int data_result = std::memcmp(data_, rhs.data_, min_size);
     return (data_result < 0) ? Bool(true) :
            ((data_result == 0) ? has_less_size : Bool(false));
@@ -80,7 +80,7 @@ class Text {
       return Bool::na();
     }
     size_t min_size = has_less_or_equal_size.is_true() ?
-                      size_.value() : rhs.size_.value();
+                      size_.raw() : rhs.size_.raw();
     int data_result = std::memcmp(data_, rhs.data_, min_size);
     return (data_result < 0) ? Bool(true) :
            ((data_result == 0) ? has_less_or_equal_size : Bool(false));
@@ -92,15 +92,15 @@ class Text {
   Bool starts_with(const Text &rhs) const {
     Bool has_greater_or_equal_size = (size_ >= rhs.size_);
     if (has_greater_or_equal_size.is_true()) {
-      return Bool(std::memcmp(data_, rhs.data_, rhs.size_.value()) == 0);
+      return Bool(std::memcmp(data_, rhs.data_, rhs.size_.raw()) == 0);
     }
     return has_greater_or_equal_size;
   }
   Bool ends_with(const Text &rhs) const {
     Bool has_greater_or_equal_size = (size_ >= rhs.size_);
     if (has_greater_or_equal_size.is_true()) {
-      return Bool(std::memcmp(data_ + size_.value() - rhs.size_.value(),
-                              rhs.data_, rhs.size_.value()) == 0);
+      return Bool(std::memcmp(data_ + size_.raw() - rhs.size_.raw(),
+                              rhs.data_, rhs.size_.raw()) == 0);
     }
     return has_greater_or_equal_size;
   }
@@ -112,7 +112,7 @@ class Text {
     if (is_na()) {
       return true;
     }
-    return std::memcmp(data_, rhs.data_, size_.value()) == 0;
+    return std::memcmp(data_, rhs.data_, size_.raw()) == 0;
   }
   bool unmatch(const Text &rhs) const {
     if (size_.unmatch(rhs.size_)) {
@@ -121,7 +121,7 @@ class Text {
     if (is_na()) {
       return false;
     }
-    return std::memcmp(data_, rhs.data_, size_.value()) != 0;
+    return std::memcmp(data_, rhs.data_, size_.raw()) != 0;
   }
 
   static constexpr DataType type() {

  Modified: include/grnxx/data_types/typecast.hpp (+1 -1)
===================================================================
--- include/grnxx/data_types/typecast.hpp    2014-11-25 11:29:33 +0900 (468017b)
+++ include/grnxx/data_types/typecast.hpp    2014-11-25 12:44:39 +0900 (f94e012)
@@ -9,7 +9,7 @@
 namespace grnxx {
 
 inline constexpr Float Int::to_float() const {
-  return is_na() ? Float::na() : Float(static_cast<double>(value_));
+  return is_na() ? Float::na() : Float(static_cast<double>(raw_));
 }
 
 // NOTE: This implementation assumes that an integer overflow in conversion

  Modified: include/grnxx/data_types/vector/bool.hpp (+8 -8)
===================================================================
--- include/grnxx/data_types/vector/bool.hpp    2014-11-25 11:29:33 +0900 (2306c29)
+++ include/grnxx/data_types/vector/bool.hpp    2014-11-25 12:44:39 +0900 (c9a4409)
@@ -22,11 +22,11 @@ class Vector<Bool> {
   explicit constexpr Vector(NA) : data_(nullptr), size_(NA()) {}
 
   Bool operator[](Int i) const {
-    if (is_na() || (static_cast<uint64_t>(i.value()) >=
-                    static_cast<uint64_t>(size_.value()))) {
+    if (is_na() || (static_cast<uint64_t>(i.raw()) >=
+                    static_cast<uint64_t>(size_.raw()))) {
       return Bool::na();
     }
-    return data_[i.value()];
+    return data_[i.raw()];
   }
   // TODO: To be removed.
   const Bool &operator[](size_t i) const {
@@ -40,7 +40,7 @@ class Vector<Bool> {
   }
 
   constexpr bool is_empty() const {
-    return size_.value() == 0;
+    return size_.raw() == 0;
   }
   constexpr bool is_na() const {
     return size_.is_na();
@@ -50,7 +50,7 @@ class Vector<Bool> {
   Bool operator==(const Vector &rhs) const {
     Bool has_equal_size = (size_ == rhs.size_);
     if (has_equal_size.is_true()) {
-      return Bool(std::memcmp(data_, rhs.data_, size_.value()) == 0);
+      return Bool(std::memcmp(data_, rhs.data_, size_.raw()) == 0);
     }
     return has_equal_size;
   }
@@ -58,7 +58,7 @@ class Vector<Bool> {
   Bool operator!=(const Vector &rhs) const {
     Bool has_not_equal_size = (size_ != rhs.size_);
     if (has_not_equal_size.is_false()) {
-      return Bool(std::memcmp(data_, rhs.data_, size_.value()) != 0);
+      return Bool(std::memcmp(data_, rhs.data_, size_.raw()) != 0);
     }
     return has_not_equal_size;
   }
@@ -70,7 +70,7 @@ class Vector<Bool> {
     if (is_na()) {
       return true;
     }
-    return std::memcmp(data_, rhs.data_, size_.value()) == 0;
+    return std::memcmp(data_, rhs.data_, size_.raw()) == 0;
   }
   bool unmatch(const Vector &rhs) const {
     if (size_.unmatch(rhs.size_)) {
@@ -79,7 +79,7 @@ class Vector<Bool> {
     if (is_na()) {
       return false;
     }
-    return std::memcmp(data_, rhs.data_, size_.value()) != 0;
+    return std::memcmp(data_, rhs.data_, size_.raw()) != 0;
   }
 
   static constexpr DataType type() {

  Modified: include/grnxx/data_types/vector/float.hpp (+8 -8)
===================================================================
--- include/grnxx/data_types/vector/float.hpp    2014-11-25 11:29:33 +0900 (ebf29df)
+++ include/grnxx/data_types/vector/float.hpp    2014-11-25 12:44:39 +0900 (74e0ac7)
@@ -24,11 +24,11 @@ class Vector<Float> {
   explicit constexpr Vector(NA) : data_(nullptr), size_(NA()) {}
 
   Float operator[](Int i) const {
-    if (is_na() || (static_cast<uint64_t>(i.value()) >=
-                    static_cast<uint64_t>(size_.value()))) {
+    if (is_na() || (static_cast<uint64_t>(i.raw()) >=
+                    static_cast<uint64_t>(size_.raw()))) {
       return Float::na();
     }
-    return data_[i.value()];
+    return data_[i.raw()];
   }
   // TODO: To be removed.
   const Float &operator[](size_t i) const {
@@ -42,7 +42,7 @@ class Vector<Float> {
   }
 
   constexpr bool is_empty() const {
-    return size_.value() == 0;
+    return size_.raw() == 0;
   }
   constexpr bool is_na() const {
     return size_.is_na();
@@ -52,7 +52,7 @@ class Vector<Float> {
   Bool operator==(const Vector &rhs) const {
     Bool has_equal_size = (size_ == rhs.size_);
     if (has_equal_size.is_true()) {
-      size_t size = size_.value();
+      size_t size = size_.raw();
       for (size_t i = 0; i < size; ++i) {
         if ((data_[i].value() != rhs.data_[i].value()) &&
             (!data_[i].is_na() || !rhs.data_[i].is_na())) {
@@ -66,7 +66,7 @@ class Vector<Float> {
   Bool operator!=(const Vector &rhs) const {
     Bool has_not_equal_size = (size_ != rhs.size_);
     if (has_not_equal_size.is_false()) {
-      size_t size = size_.value();
+      size_t size = size_.raw();
       for (size_t i = 0; i < size; ++i) {
         if ((data_[i].value() != rhs.data_[i].value()) &&
             (!data_[i].is_na() || !rhs.data_[i].is_na())) {
@@ -85,7 +85,7 @@ class Vector<Float> {
       return true;
     }
     // TODO: This is because raw values are not normalized.
-    size_t size = size_.value();
+    size_t size = size_.raw();
     for (size_t i = 0; i < size; ++i) {
       if (data_[i].unmatch(rhs.data_[i])) {
         return false;
@@ -101,7 +101,7 @@ class Vector<Float> {
       return false;
     }
     // TODO: This is because raw values are not normalized.
-    size_t size = size_.value();
+    size_t size = size_.raw();
     for (size_t i = 0; i < size; ++i) {
       if (data_[i].unmatch(rhs.data_[i])) {
         return true;

  Modified: include/grnxx/data_types/vector/geo_point.hpp (+8 -8)
===================================================================
--- include/grnxx/data_types/vector/geo_point.hpp    2014-11-25 11:29:33 +0900 (a0e5527)
+++ include/grnxx/data_types/vector/geo_point.hpp    2014-11-25 12:44:39 +0900 (5bdbcba)
@@ -24,11 +24,11 @@ class Vector<GeoPoint> {
   explicit constexpr Vector(NA) : data_(nullptr), size_(NA()) {}
 
   GeoPoint operator[](Int i) const {
-    if (is_na() || (static_cast<uint64_t>(i.value()) >=
-                    static_cast<uint64_t>(size_.value()))) {
+    if (is_na() || (static_cast<uint64_t>(i.raw()) >=
+                    static_cast<uint64_t>(size_.raw()))) {
       return GeoPoint::na();
     }
-    return data_[i.value()];
+    return data_[i.raw()];
   }
   // TODO: To be removed.
   const GeoPoint &operator[](size_t i) const {
@@ -42,7 +42,7 @@ class Vector<GeoPoint> {
   }
 
   constexpr bool is_empty() const {
-    return size_.value() == 0;
+    return size_.raw() == 0;
   }
   constexpr bool is_na() const {
     return size_.is_na();
@@ -53,7 +53,7 @@ class Vector<GeoPoint> {
     Bool has_equal_size = (size_ == rhs.size_);
     if (has_equal_size.is_true()) {
       return Bool(std::memcmp(data_, rhs.data_,
-                              sizeof(GeoPoint) * size_.value()) == 0);
+                              sizeof(GeoPoint) * size_.raw()) == 0);
     }
     return has_equal_size;
   }
@@ -62,7 +62,7 @@ class Vector<GeoPoint> {
     Bool has_not_equal_size = (size_ != rhs.size_);
     if (has_not_equal_size.is_false()) {
       return Bool(std::memcmp(data_, rhs.data_,
-                              sizeof(GeoPoint) * size_.value()) != 0);
+                              sizeof(GeoPoint) * size_.raw()) != 0);
     }
     return has_not_equal_size;
   }
@@ -75,7 +75,7 @@ class Vector<GeoPoint> {
       return true;
     }
     return std::memcmp(data_, rhs.data_,
-                       sizeof(GeoPoint) * size_.value()) == 0;
+                       sizeof(GeoPoint) * size_.raw()) == 0;
   }
   bool unmatch(const Vector &rhs) const {
     if (size_.unmatch(rhs.size_)) {
@@ -85,7 +85,7 @@ class Vector<GeoPoint> {
       return false;
     }
     return std::memcmp(data_, rhs.data_,
-                       sizeof(GeoPoint) * size_.value()) != 0;
+                       sizeof(GeoPoint) * size_.raw()) != 0;
   }
 
   static constexpr DataType type() {

  Modified: include/grnxx/data_types/vector/int.hpp (+8 -8)
===================================================================
--- include/grnxx/data_types/vector/int.hpp    2014-11-25 11:29:33 +0900 (c56a1d8)
+++ include/grnxx/data_types/vector/int.hpp    2014-11-25 12:44:39 +0900 (4857a1b)
@@ -22,11 +22,11 @@ class Vector<Int> {
   explicit constexpr Vector(NA) : data_(nullptr), size_(NA()) {}
 
   Int operator[](Int i) const {
-    if (is_na() || (static_cast<uint64_t>(i.value()) >=
-                    static_cast<uint64_t>(size_.value()))) {
+    if (is_na() || (static_cast<uint64_t>(i.raw()) >=
+                    static_cast<uint64_t>(size_.raw()))) {
       return Int::na();
     }
-    return data_[i.value()];
+    return data_[i.raw()];
   }
   // TODO: To be removed.
   const Int &operator[](size_t i) const {
@@ -40,7 +40,7 @@ class Vector<Int> {
   }
 
   constexpr bool is_empty() const {
-    return size_.value() == 0;
+    return size_.raw() == 0;
   }
   constexpr bool is_na() const {
     return size_.is_na();
@@ -51,7 +51,7 @@ class Vector<Int> {
     Bool has_equal_size = (size_ == rhs.size_);
     if (has_equal_size.is_true()) {
       return Bool(std::memcmp(data_, rhs.data_,
-                              sizeof(Int) * size_.value()) == 0);
+                              sizeof(Int) * size_.raw()) == 0);
     }
     return has_equal_size;
   }
@@ -60,7 +60,7 @@ class Vector<Int> {
     Bool has_not_equal_size = (size_ != rhs.size_);
     if (has_not_equal_size.is_false()) {
       return Bool(std::memcmp(data_, rhs.data_,
-                              sizeof(Int) * size_.value()) != 0);
+                              sizeof(Int) * size_.raw()) != 0);
     }
     return has_not_equal_size;
   }
@@ -72,7 +72,7 @@ class Vector<Int> {
     if (is_na()) {
       return true;
     }
-    return std::memcmp(data_, rhs.data_, sizeof(Int) * size_.value()) == 0;
+    return std::memcmp(data_, rhs.data_, sizeof(Int) * size_.raw()) == 0;
   }
   bool unmatch(const Vector &rhs) const {
     if (size_.unmatch(rhs.size_)) {
@@ -81,7 +81,7 @@ class Vector<Int> {
     if (is_na()) {
       return false;
     }
-    return std::memcmp(data_, rhs.data_, sizeof(Int) * size_.value()) != 0;
+    return std::memcmp(data_, rhs.data_, sizeof(Int) * size_.raw()) != 0;
   }
 
   static constexpr DataType type() {

  Modified: include/grnxx/data_types/vector/text.hpp (+10 -10)
===================================================================
--- include/grnxx/data_types/vector/text.hpp    2014-11-25 11:29:33 +0900 (91b904b)
+++ include/grnxx/data_types/vector/text.hpp    2014-11-25 12:44:39 +0900 (ee8fc89)
@@ -33,15 +33,15 @@ class Vector<Text> {
         data_(nullptr) {}
 
   Text operator[](Int i) const {
-    if (is_na() || (static_cast<uint64_t>(i.value()) >=
-                    static_cast<uint64_t>(size_.value()))) {
+    if (is_na() || (static_cast<uint64_t>(i.raw()) >=
+                    static_cast<uint64_t>(size_.raw()))) {
       return Text::na();
     }
     if (is_direct_) {
-      return data_[i.value()];
+      return data_[i.raw()];
     } else {
-      return Text(&bodies_[headers_[i.value()].offset],
-                  headers_[i.value()].size.value());
+      return Text(&bodies_[headers_[i.raw()].offset],
+                  headers_[i.raw()].size.raw());
     }
   }
   // TODO: To be removed.
@@ -53,7 +53,7 @@ class Vector<Text> {
   }
 
   constexpr bool is_empty() const {
-    return size_.value() == 0;
+    return size_.raw() == 0;
   }
   constexpr bool is_na() const {
     return size_.is_na();
@@ -63,7 +63,7 @@ class Vector<Text> {
   Bool operator==(const Vector &rhs) const {
     Bool has_equal_size = (size_ == rhs.size_);
     if (has_equal_size.is_true()) {
-      size_t size = size_.value();
+      size_t size = size_.raw();
       for (size_t i = 0; i < size; ++i) {
         Text lhs_text = (*this)[grnxx::Int(i)];
         Text rhs_text = rhs[grnxx::Int(i)];
@@ -80,7 +80,7 @@ class Vector<Text> {
   Bool operator!=(const Vector &rhs) const {
     Bool has_not_equal_size = (size_ != rhs.size_);
     if (has_not_equal_size.is_false()) {
-      size_t size = size_.value();
+      size_t size = size_.raw();
       for (size_t i = 0; i < size; ++i) {
         Text lhs_text = (*this)[grnxx::Int(i)];
         Text rhs_text = rhs[grnxx::Int(i)];
@@ -102,7 +102,7 @@ class Vector<Text> {
       return true;
     }
     // TODO: This is because raw values are not normalized.
-    size_t size = size_.value();
+    size_t size = size_.raw();
     for (size_t i = 0; i < size; ++i) {
       // TODO: This can be improved.
       if (operator[](grnxx::Int(i)).unmatch(rhs[grnxx::Int(i)])) {
@@ -119,7 +119,7 @@ class Vector<Text> {
       return false;
     }
     // TODO: This is because raw values are not normalized.
-    size_t size = size_.value();
+    size_t size = size_.raw();
     for (size_t i = 0; i < size; ++i) {
       // TODO: This can be improved.
       if (operator[](grnxx::Int(i)).unmatch(rhs[grnxx::Int(i)])) {

  Modified: lib/grnxx/impl/column/scalar/bool.cpp (+4 -4)
===================================================================
--- lib/grnxx/impl/column/scalar/bool.cpp    2014-11-25 11:29:33 +0900 (ca3a1ef)
+++ lib/grnxx/impl/column/scalar/bool.cpp    2014-11-25 12:44:39 +0900 (bba6118)
@@ -32,7 +32,7 @@ void Column<Bool>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     values_.resize(value_id + 1, Bool::na());
   }
@@ -49,7 +49,7 @@ void Column<Bool>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Bool>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     *datum = Bool::na();
   } else {
@@ -100,7 +100,7 @@ Int Column<Bool>::find_one(const Datum &datum) const {
 void Column<Bool>::unset(Int row_id) {
   Bool value = get(row_id);
   if (!value.is_na()) {
-    values_[row_id.value()] = Bool::na();
+    values_[row_id.raw()] = Bool::na();
     // TODO: Update indexes if exist.
   }
 }
@@ -119,7 +119,7 @@ size_t Column<Bool>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < values_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/scalar/bool.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/scalar/bool.hpp    2014-11-25 11:29:33 +0900 (8568bb1)
+++ lib/grnxx/impl/column/scalar/bool.hpp    2014-11-25 12:44:39 +0900 (95a0f7c)
@@ -34,7 +34,7 @@ class Column<Bool> : public ColumnBase {
   // If "row_id" is valid, returns the stored value.
   // If "row_id" is invalid, returns N/A.
   Bool get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= values_.size()) {
       return Bool::na();
     }

  Modified: lib/grnxx/impl/column/scalar/float.cpp (+4 -4)
===================================================================
--- lib/grnxx/impl/column/scalar/float.cpp    2014-11-25 11:29:33 +0900 (ae8ea8c)
+++ lib/grnxx/impl/column/scalar/float.cpp    2014-11-25 12:44:39 +0900 (1cac125)
@@ -33,7 +33,7 @@ void Column<Float>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     values_.resize(value_id + 1, Float::na());
   }
@@ -50,7 +50,7 @@ void Column<Float>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Float>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     *datum = Float::na();
   } else {
@@ -105,7 +105,7 @@ void Column<Float>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    values_[row_id.value()] = Float::na();
+    values_[row_id.raw()] = Float::na();
   }
 }
 
@@ -123,7 +123,7 @@ size_t Column<Float>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < values_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/scalar/float.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/scalar/float.hpp    2014-11-25 11:29:33 +0900 (b83411f)
+++ lib/grnxx/impl/column/scalar/float.hpp    2014-11-25 12:44:39 +0900 (d48864c)
@@ -34,7 +34,7 @@ class Column<Float> : public ColumnBase {
   // If "row_id" is valid, returns the stored value.
   // If "row_id" is invalid, returns N/A.
   Float get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= values_.size()) {
       return Float::na();
     }

  Modified: lib/grnxx/impl/column/scalar/geo_point.cpp (+4 -4)
===================================================================
--- lib/grnxx/impl/column/scalar/geo_point.cpp    2014-11-25 11:29:33 +0900 (adaf0ad)
+++ lib/grnxx/impl/column/scalar/geo_point.cpp    2014-11-25 12:44:39 +0900 (4ad2c29)
@@ -33,7 +33,7 @@ void Column<GeoPoint>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     values_.resize(value_id + 1, GeoPoint::na());
   }
@@ -50,7 +50,7 @@ void Column<GeoPoint>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<GeoPoint>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     *datum = GeoPoint::na();
   } else {
@@ -105,7 +105,7 @@ void Column<GeoPoint>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    values_[row_id.value()] = GeoPoint::na();
+    values_[row_id.raw()] = GeoPoint::na();
   }
 }
 
@@ -123,7 +123,7 @@ size_t Column<GeoPoint>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < values_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/scalar/geo_point.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/scalar/geo_point.hpp    2014-11-25 11:29:33 +0900 (de7fde7)
+++ lib/grnxx/impl/column/scalar/geo_point.hpp    2014-11-25 12:44:39 +0900 (1659e88)
@@ -34,7 +34,7 @@ class Column<GeoPoint> : public ColumnBase {
   // If "row_id" is valid, returns the stored value.
   // If "row_id" is invalid, returns N/A.
   GeoPoint get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= values_.size()) {
       return GeoPoint::na();
     }

  Modified: lib/grnxx/impl/column/scalar/int.cpp (+8 -13)
===================================================================
--- lib/grnxx/impl/column/scalar/int.cpp    2014-11-25 11:29:33 +0900 (65c1292)
+++ lib/grnxx/impl/column/scalar/int.cpp    2014-11-25 12:44:39 +0900 (b4afacc)
@@ -56,7 +56,7 @@ void Column<Int>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     values_.resize(value_id + 1, Int::na());
   }
@@ -73,7 +73,7 @@ void Column<Int>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Int>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     *datum = Int::na();
   } else {
@@ -162,15 +162,10 @@ void Column<Int>::set_key_attribute() {
 
   // TODO: An index should be used if available.
   std::unordered_set<int64_t> set;
-  size_t size = values_.size();
-  if (table_->max_row_id().is_na()) {
-    size = 0;
-  } else if (static_cast<size_t>(table_->max_row_id().value()) < size) {
-    size = static_cast<size_t>(table_->max_row_id().value()) + 1;
-  }
-  for (size_t i = 0; i < size; ++i) try {
+  size_t valid_size = get_valid_size();
+  for (size_t i = 0; i < valid_size; ++i) try {
     if (!values_[i].is_na()) {
-      if (!set.insert(values_[i].value()).second) {
+      if (!set.insert(values_[i].raw()).second) {
         throw "Key duplicate";  // TODO
       }
     }
@@ -194,7 +189,7 @@ void Column<Int>::set_key(Int row_id, const Datum &key) {
   if (contains(key)) {
     throw "Key already exists";  // TODO
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= values_.size()) {
     values_.resize(value_id + 1, Int::na());
   }
@@ -219,7 +214,7 @@ void Column<Int>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    values_[row_id.value()] = Int::na();
+    values_[row_id.raw()] = Int::na();
   }
 }
 
@@ -283,7 +278,7 @@ size_t Column<Int>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < values_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/scalar/int.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/scalar/int.hpp    2014-11-25 11:29:33 +0900 (f049237)
+++ lib/grnxx/impl/column/scalar/int.hpp    2014-11-25 12:44:39 +0900 (9e4a4ac)
@@ -38,7 +38,7 @@ class Column<Int> : public ColumnBase {
   // If "row_id" is valid, returns the stored value.
   // If "row_id" is invalid, returns N/A.
   Int get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= values_.size()) {
       return Int::na();
     }

  Modified: lib/grnxx/impl/column/scalar/text.cpp (+10 -15)
===================================================================
--- lib/grnxx/impl/column/scalar/text.cpp    2014-11-25 11:29:33 +0900 (a2a5c30)
+++ lib/grnxx/impl/column/scalar/text.cpp    2014-11-25 12:44:39 +0900 (27cea84)
@@ -46,7 +46,7 @@ void Column<Text>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -61,7 +61,7 @@ void Column<Text>::set(Int row_id, const Datum &datum) {
 //  }
   // TODO: Error handling.
   size_t offset = bodies_.size();
-  size_t size = new_value.size().value();
+  size_t size = new_value.size().raw();
   uint64_t header;
   if (size < 0xFFFF) {
     bodies_.resize(offset + size);
@@ -133,7 +133,7 @@ void Column<Text>::set(Int row_id, const Datum &datum) {
 //}
 
 void Column<Text>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     *datum = Text::na();
   } else {
@@ -231,16 +231,11 @@ void Column<Text>::set_key_attribute() {
   }
   // TODO: An index should be used if available.
   std::set<String> set;
-  size_t size = headers_.size();
-  if (table_->max_row_id().is_na()) {
-    size = 0;
-  } else if (static_cast<size_t>(table_->max_row_id().value()) < size) {
-    size = static_cast<size_t>(table_->max_row_id().value()) + 1;
-  }
-  for (size_t i = 0; i < size; ++i) try {
+  size_t valid_size = get_valid_size();
+  for (size_t i = 0; i < valid_size; ++i) try {
     Text value = get(grnxx::Int(i));
     if (!value.is_na()) {
-      if (!set.insert(String(value.data(), value.size().value())).second) {
+      if (!set.insert(String(value.data(), value.size().raw())).second) {
         throw "Key duplicate";  // TODO
       }
     }
@@ -303,7 +298,7 @@ void Column<Text>::set_key(Int row_id, const Datum &key) {
   if (contains(key)) {
     throw "Key already exists";  // TODO
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -320,7 +315,7 @@ void Column<Text>::set_key(Int row_id, const Datum &key) {
 //  }
   // TODO: Error handling.
   size_t offset = bodies_.size();
-  size_t size = value.size().value();
+  size_t size = value.size().raw();
   uint64_t header;
   if (size < 0xFFFF) {
     bodies_.resize(offset + size);
@@ -396,7 +391,7 @@ void Column<Text>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    headers_[row_id.value()] = na_header();
+    headers_[row_id.raw()] = na_header();
   }
 }
 
@@ -414,7 +409,7 @@ size_t Column<Text>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < headers_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/scalar/text.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/scalar/text.hpp    2014-11-25 11:29:33 +0900 (c044f60)
+++ lib/grnxx/impl/column/scalar/text.hpp    2014-11-25 12:44:39 +0900 (3afd9a1)
@@ -42,7 +42,7 @@ class Column<Text> : public ColumnBase {
   //
   // TODO: Text cannot reuse allocated memory because of this interface.
   Text get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= headers_.size()) {
       return Text::na();
     }

  Modified: lib/grnxx/impl/column/vector/bool.cpp (+5 -5)
===================================================================
--- lib/grnxx/impl/column/vector/bool.cpp    2014-11-25 11:29:33 +0900 (34d8e8c)
+++ lib/grnxx/impl/column/vector/bool.cpp    2014-11-25 12:44:39 +0900 (a27d78f)
@@ -37,7 +37,7 @@ void Column<Vector<Bool>>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -52,7 +52,7 @@ void Column<Vector<Bool>>::set(Int row_id, const Datum &datum) {
 //  }
   // TODO: Error handling.
   size_t offset = bodies_.size();
-  size_t size = new_value.size().value();
+  size_t size = new_value.size().raw();
   uint64_t header;
   if (size < 0xFFFF) {
     bodies_.resize(offset + size);
@@ -72,7 +72,7 @@ void Column<Vector<Bool>>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Vector<Bool>>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     *datum = Vector<Bool>::na();
   } else {
@@ -130,7 +130,7 @@ void Column<Vector<Bool>>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    headers_[row_id.value()] = na_header();
+    headers_[row_id.raw()] = na_header();
   }
 }
 
@@ -138,7 +138,7 @@ size_t Column<Vector<Bool>>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < headers_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/vector/bool.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/vector/bool.hpp    2014-11-25 11:29:33 +0900 (c2ae939)
+++ lib/grnxx/impl/column/vector/bool.hpp    2014-11-25 12:44:39 +0900 (ab58e7c)
@@ -38,7 +38,7 @@ class Column<Vector<Bool>> : public ColumnBase {
   //
   // TODO: Vector cannot reuse allocated memory because of this interface.
   Vector<Bool> get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= headers_.size()) {
       return Vector<Bool>::na();
     }

  Modified: lib/grnxx/impl/column/vector/float.cpp (+5 -5)
===================================================================
--- lib/grnxx/impl/column/vector/float.cpp    2014-11-25 11:29:33 +0900 (8d3b186)
+++ lib/grnxx/impl/column/vector/float.cpp    2014-11-25 12:44:39 +0900 (d721669)
@@ -37,7 +37,7 @@ void Column<Vector<Float>>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -52,7 +52,7 @@ void Column<Vector<Float>>::set(Int row_id, const Datum &datum) {
 //  }
   // TODO: Error handling.
   size_t offset = bodies_.size();
-  size_t size = new_value.size().value();
+  size_t size = new_value.size().raw();
   uint64_t header;
   if (size < 0xFFFF) {
     bodies_.resize(offset + size);
@@ -73,7 +73,7 @@ void Column<Vector<Float>>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Vector<Float>>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     *datum = Vector<Float>::na();
   } else {
@@ -131,7 +131,7 @@ void Column<Vector<Float>>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    headers_[row_id.value()] = na_header();
+    headers_[row_id.raw()] = na_header();
   }
 }
 
@@ -149,7 +149,7 @@ size_t Column<Vector<Float>>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < headers_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/vector/float.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/vector/float.hpp    2014-11-25 11:29:33 +0900 (6cf41c8)
+++ lib/grnxx/impl/column/vector/float.hpp    2014-11-25 12:44:39 +0900 (473f319)
@@ -38,7 +38,7 @@ class Column<Vector<Float>> : public ColumnBase {
   //
   // TODO: Vector cannot reuse allocated memory because of this interface.
   Vector<Float> get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= headers_.size()) {
       return Vector<Float>::na();
     }

  Modified: lib/grnxx/impl/column/vector/geo_point.cpp (+5 -5)
===================================================================
--- lib/grnxx/impl/column/vector/geo_point.cpp    2014-11-25 11:29:33 +0900 (f124521)
+++ lib/grnxx/impl/column/vector/geo_point.cpp    2014-11-25 12:44:39 +0900 (236b1da)
@@ -37,7 +37,7 @@ void Column<Vector<GeoPoint>>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -52,7 +52,7 @@ void Column<Vector<GeoPoint>>::set(Int row_id, const Datum &datum) {
 //  }
   // TODO: Error handling.
   size_t offset = bodies_.size();
-  size_t size = new_value.size().value();
+  size_t size = new_value.size().raw();
   uint64_t header;
   if (size < 0xFFFF) {
     bodies_.resize(offset + size);
@@ -73,7 +73,7 @@ void Column<Vector<GeoPoint>>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Vector<GeoPoint>>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     *datum = Vector<GeoPoint>::na();
   } else {
@@ -131,7 +131,7 @@ void Column<Vector<GeoPoint>>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    headers_[row_id.value()] = na_header();
+    headers_[row_id.raw()] = na_header();
   }
 }
 
@@ -149,7 +149,7 @@ size_t Column<Vector<GeoPoint>>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < headers_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/vector/geo_point.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/vector/geo_point.hpp    2014-11-25 11:29:33 +0900 (722af35)
+++ lib/grnxx/impl/column/vector/geo_point.hpp    2014-11-25 12:44:39 +0900 (f1fb553)
@@ -38,7 +38,7 @@ class Column<Vector<GeoPoint>> : public ColumnBase {
   //
   // TODO: Vector cannot reuse allocated memory because of this interface.
   Vector<GeoPoint> get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= headers_.size()) {
       return Vector<GeoPoint>::na();
     }

  Modified: lib/grnxx/impl/column/vector/int.cpp (+6 -6)
===================================================================
--- lib/grnxx/impl/column/vector/int.cpp    2014-11-25 11:29:33 +0900 (870b7d1)
+++ lib/grnxx/impl/column/vector/int.cpp    2014-11-25 12:44:39 +0900 (90a1156)
@@ -35,7 +35,7 @@ void Column<Vector<Int>>::set(Int row_id, const Datum &datum) {
     return;
   }
   if (reference_table_) {
-    size_t new_value_size = new_value.size().value();
+    size_t new_value_size = new_value.size().raw();
     for (size_t i = 0; i < new_value_size; ++i) {
       if (!reference_table_->test_row(new_value[i])) {
         throw "Invalid reference";  // TODO
@@ -52,7 +52,7 @@ void Column<Vector<Int>>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -67,7 +67,7 @@ void Column<Vector<Int>>::set(Int row_id, const Datum &datum) {
 //  }
   // TODO: Error handling.
   size_t offset = bodies_.size();
-  size_t size = new_value.size().value();
+  size_t size = new_value.size().raw();
   uint64_t header;
   if (size < 0xFFFF) {
     bodies_.resize(offset + size);
@@ -88,7 +88,7 @@ void Column<Vector<Int>>::set(Int row_id, const Datum &datum) {
 }
 
 void Column<Vector<Int>>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     *datum = Vector<Int>::na();
   } else {
@@ -146,7 +146,7 @@ void Column<Vector<Int>>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    headers_[row_id.value()] = na_header();
+    headers_[row_id.raw()] = na_header();
   }
 }
 
@@ -164,7 +164,7 @@ size_t Column<Vector<Int>>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < headers_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/vector/int.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/vector/int.hpp    2014-11-25 11:29:33 +0900 (f29649b)
+++ lib/grnxx/impl/column/vector/int.hpp    2014-11-25 12:44:39 +0900 (0e8e352)
@@ -38,7 +38,7 @@ class Column<Vector<Int>> : public ColumnBase {
   //
   // TODO: Vector cannot reuse allocated memory because of this interface.
   Vector<Int> get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= headers_.size()) {
       return Vector<Int>::na();
     }

  Modified: lib/grnxx/impl/column/vector/text.cpp (+8 -8)
===================================================================
--- lib/grnxx/impl/column/vector/text.cpp    2014-11-25 11:29:33 +0900 (a80b659)
+++ lib/grnxx/impl/column/vector/text.cpp    2014-11-25 12:44:39 +0900 (b06b4c6)
@@ -37,7 +37,7 @@ void Column<Vector<Text>>::set(Int row_id, const Datum &datum) {
 //      indexes_[i]->remove(row_id, old_value);
 //    }
   }
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     headers_.resize(value_id + 1, na_header());
   }
@@ -51,13 +51,13 @@ void Column<Vector<Text>>::set(Int row_id, const Datum &datum) {
 //    throw;
 //  }
   // TODO: Error handling.
-  size_t new_value_size = new_value.size().value();
+  size_t new_value_size = new_value.size().raw();
   size_t text_headers_offset = text_headers_.size();
   text_headers_.resize(text_headers_offset + new_value_size);
   size_t total_size = 0;
   for (size_t i = 0; i < new_value_size; ++i) {
     if (!new_value[i].is_na()) {
-      total_size += new_value[i].size().value();
+      total_size += new_value[i].size().raw();
     }
   }
   size_t bodies_offset = bodies_.size();
@@ -68,14 +68,14 @@ void Column<Vector<Text>>::set(Int row_id, const Datum &datum) {
     text_headers_[text_headers_offset + i].size = new_value[i].size();
     if (!new_value[i].is_na()) {
       std::memcpy(&bodies_[bodies_offset],
-                  new_value[i].data(), new_value[i].size().value());
-      bodies_offset += new_value[i].size().value();
+                  new_value[i].data(), new_value[i].size().raw());
+      bodies_offset += new_value[i].size().raw();
     }
   }
 }
 
 void Column<Vector<Text>>::get(Int row_id, Datum *datum) const {
-  size_t value_id = row_id.value();
+  size_t value_id = row_id.raw();
   if (value_id >= headers_.size()) {
     *datum = Vector<Text>::na();
   } else {
@@ -133,7 +133,7 @@ void Column<Vector<Text>>::unset(Int row_id) {
 //    for (size_t i = 0; i < num_indexes(); ++i) {
 //      indexes_[i]->remove(row_id, value);
 //    }
-    headers_[row_id.value()] = na_header();
+    headers_[row_id.raw()] = na_header();
   }
 }
 
@@ -151,7 +151,7 @@ size_t Column<Vector<Text>>::get_valid_size() const {
   if (table_->max_row_id().is_na()) {
     return 0;
   }
-  size_t table_size = table_->max_row_id().value() + 1;
+  size_t table_size = table_->max_row_id().raw() + 1;
   if (table_size < headers_.size()) {
     return table_size;
   }

  Modified: lib/grnxx/impl/column/vector/text.hpp (+1 -1)
===================================================================
--- lib/grnxx/impl/column/vector/text.hpp    2014-11-25 11:29:33 +0900 (c5a2ebe)
+++ lib/grnxx/impl/column/vector/text.hpp    2014-11-25 12:44:39 +0900 (2e0e75b)
@@ -35,7 +35,7 @@ class Column<Vector<Text>> : public ColumnBase {
   //
   // TODO: Vector cannot reuse allocated memory because of this interface.
   Vector<Text> get(Int row_id) const {
-    size_t value_id = row_id.value();
+    size_t value_id = row_id.raw();
     if (value_id >= headers_.size()) {
       return Vector<Text>::na();
     }

  Modified: lib/grnxx/impl/expression.cpp (+6 -6)
===================================================================
--- lib/grnxx/impl/expression.cpp    2014-11-25 11:29:33 +0900 (f66c3d2)
+++ lib/grnxx/impl/expression.cpp    2014-11-25 12:44:39 +0900 (265486f)
@@ -244,7 +244,7 @@ class ConstantNode<Text> : public TypedNode<Text> {
   explicit ConstantNode(const Value &value)
       : TypedNode<Value>(),
         value_() {
-    value_.assign(value.data(), value.size().value());
+    value_.assign(value.data(), value.size().raw());
   }
   ~ConstantNode() = default;
 
@@ -271,7 +271,7 @@ class ConstantNode<Vector<T>> : public TypedNode<Vector<T>> {
   explicit ConstantNode(const Value &value)
       : TypedNode<Value>(),
         value_() {
-    size_t value_size = value.size().value();
+    size_t value_size = value.size().raw();
     value_.resize(value_size);
     for (size_t i = 0; i < value_size; ++i) {
       value_[i] = value[i];
@@ -526,7 +526,7 @@ void LogicalNotNode::filter(ArrayCRef<Record> input_records,
   // Extract records which appear in "input_records" and don't appear in "ref".
   size_t count = 0;
   for (size_t i = 0, j = 0; i < input_records.size(); ++i) {
-    if (input_records[i].row_id.value() == ref[j].row_id.value()) {
+    if (input_records[i].row_id.match(ref[j].row_id)) {
       ++j;
       continue;
     }
@@ -1409,7 +1409,7 @@ void VectorDereferenceNode<T>::evaluate(ArrayCRef<Record> records,
   size_t total_size = 0;
   for (size_t i = 0; i < records.size(); ++i) {
     if (!this->arg1_values_[i].is_na()) {
-      total_size += this->arg1_values_[i].size().value();
+      total_size += this->arg1_values_[i].size().raw();
     }
   }
   temp_records_.resize(block_size_);
@@ -1422,7 +1422,7 @@ void VectorDereferenceNode<T>::evaluate(ArrayCRef<Record> records,
       continue;
     }
     Float score = records[i].score;
-    size_t value_size = this->arg1_values_[i].size().value();
+    size_t value_size = this->arg1_values_[i].size().raw();
     for (size_t j = 0; j < value_size; ++j) {
       temp_records_[count] = Record(this->arg1_values_[i][j], score);
       ++count;
@@ -1442,7 +1442,7 @@ void VectorDereferenceNode<T>::evaluate(ArrayCRef<Record> records,
     if (this->arg1_values_[i].is_na()) {
       results[i] = Value::na();
     } else {
-      size_t size = this->arg1_values_[i].size().value();
+      size_t size = this->arg1_values_[i].size().raw();
       results[i] = Value(&result_pool[offset], size);
       offset += size;
     }

  Modified: lib/grnxx/impl/merger.cpp (+13 -13)
===================================================================
--- lib/grnxx/impl/merger.cpp    2014-11-25 11:29:33 +0900 (55b50d4)
+++ lib/grnxx/impl/merger.cpp    2014-11-25 12:44:39 +0900 (15048c2)
@@ -32,7 +32,7 @@ void AndMerger::finish() {
   }
   std::unordered_map<int64_t, Float> filter;
   for (size_t i = 0; i < filter_records->size(); ++i) try {
-    filter[(*filter_records)[i].row_id.value()] = (*filter_records)[i].score;
+    filter[(*filter_records)[i].row_id.raw()] = (*filter_records)[i].score;
   } catch (const std::bad_alloc &) {
     throw "Memory allocation failed";  // TODO
   }
@@ -40,7 +40,7 @@ void AndMerger::finish() {
   // Filter the stream (the larger input) with the hash table.
   const bool stream_is_1 = (stream_records == input_records_1_);
   for (size_t i = 0; i < stream_records->size(); ++i) {
-    auto it = filter.find((*stream_records)[i].row_id.value());
+    auto it = filter.find((*stream_records)[i].row_id.raw());
     if (it != filter.end()) {
       Record record;
       record.row_id = Int(it->first);
@@ -125,7 +125,7 @@ void OrMerger::finish() {
   }
   std::unordered_map<int64_t, Float> filter;
   for (size_t i = 0; i < filter_records->size(); ++i) try {
-    filter[(*filter_records)[i].row_id.value()] = (*filter_records)[i].score;
+    filter[(*filter_records)[i].row_id.raw()] = (*filter_records)[i].score;
   } catch (const std::bad_alloc &) {
     throw "Memory allocation failed";  // TODO
   }
@@ -135,7 +135,7 @@ void OrMerger::finish() {
   for (size_t i = 0; i < stream_records->size(); ++i) {
     Record record;
     record.row_id = (*stream_records)[i].row_id;
-    auto it = filter.find((*stream_records)[i].row_id.value());
+    auto it = filter.find((*stream_records)[i].row_id.raw());
     if (it == filter.end()) {
       switch (score_operator_type_) {
         case MERGER_SCORE_PLUS: {
@@ -294,7 +294,7 @@ void XorMerger::finish() {
   }
   std::unordered_map<int64_t, Float> filter;
   for (size_t i = 0; i < filter_records->size(); ++i) try {
-    filter[(*filter_records)[i].row_id.value()] = (*filter_records)[i].score;
+    filter[(*filter_records)[i].row_id.raw()] = (*filter_records)[i].score;
   } catch (...) {
     throw "Memory allocation failed";  // TODO
   }
@@ -302,7 +302,7 @@ void XorMerger::finish() {
   // Filter the stream (the larger input) with the hash table.
   const bool stream_is_1 = (stream_records == input_records_1_);
   for (size_t i = 0; i < stream_records->size(); ++i) {
-    auto it = filter.find((*stream_records)[i].row_id.value());
+    auto it = filter.find((*stream_records)[i].row_id.raw());
     if (it != filter.end()) {
       filter.erase(it);
     } else {
@@ -425,7 +425,7 @@ void MinusMerger::finish() {
   }
   std::unordered_map<int64_t, Float> filter;
   for (size_t i = 0; i < filter_records->size(); ++i) try {
-    filter[(*filter_records)[i].row_id.value()] = (*filter_records)[i].score;
+    filter[(*filter_records)[i].row_id.raw()] = (*filter_records)[i].score;
   } catch (...) {
     throw "Memory allocation failed";  // TODO
   }
@@ -434,7 +434,7 @@ void MinusMerger::finish() {
   const bool stream_is_1 = (stream_records == input_records_1_);
   if (stream_is_1) {
     for (size_t i = 0; i < stream_records->size(); ++i) {
-      auto it = filter.find((*stream_records)[i].row_id.value());
+      auto it = filter.find((*stream_records)[i].row_id.raw());
       if (it != filter.end()) {
         continue;
       }
@@ -468,7 +468,7 @@ void MinusMerger::finish() {
     }
   } else {
     for (size_t i = 0; i < stream_records->size(); ++i) {
-      auto it = filter.find((*stream_records)[i].row_id.value());
+      auto it = filter.find((*stream_records)[i].row_id.raw());
       if (it != filter.end()) {
         filter.erase(it);
       }
@@ -534,14 +534,14 @@ void LeftMerger::finish() {
   // Create a hash table from the second input.
   std::unordered_map<int64_t, Float> filter;
   for (size_t i = 0; i < input_records_2_->size(); ++i) {
-    filter[(*input_records_2_)[i].row_id.value()] =
+    filter[(*input_records_2_)[i].row_id.raw()] =
         (*input_records_2_)[i].score;
   }
 
   // Adjust score of the first input.
   for (size_t i = 0; i < input_records_1_->size(); ++i) {
     Record record = input_records_1_->get(i);
-    auto it = filter.find(record.row_id.value());
+    auto it = filter.find(record.row_id.raw());
     if (it != filter.end()) {
       switch (score_operator_type_) {
         case MERGER_SCORE_PLUS: {
@@ -626,7 +626,7 @@ void RightMerger::finish() {
   // Create a hash table from the first input.
   std::unordered_map<int64_t, Float> filter;
   for (size_t i = 0; i < input_records_1_->size(); ++i) {
-    filter[(*input_records_1_)[i].row_id.value()] =
+    filter[(*input_records_1_)[i].row_id.raw()] =
         (*input_records_1_)[i].score;
   }
 
@@ -634,7 +634,7 @@ void RightMerger::finish() {
   for (size_t i = 0; i < input_records_2_->size(); ++i) {
     Record record;
     record.row_id = (*input_records_2_)[i].row_id;
-    auto it = filter.find(record.row_id.value());
+    auto it = filter.find(record.row_id.raw());
     if (it != filter.end()) {
       switch (score_operator_type_) {
         case MERGER_SCORE_PLUS: {

  Modified: lib/grnxx/impl/table.cpp (+11 -11)
===================================================================
--- lib/grnxx/impl/table.cpp    2014-11-25 11:29:33 +0900 (8c1f585)
+++ lib/grnxx/impl/table.cpp    2014-11-25 12:44:39 +0900 (d6ce9f6)
@@ -101,7 +101,7 @@ std::unique_ptr<Cursor> TableRegularCursor::create(
 TableRegularCursor::TableRegularCursor(const Table *table,
                                        const CursorOptions &options)
     : table_(table),
-      max_row_id_(table->max_row_id().value()),
+      max_row_id_(table->max_row_id().raw()),
       is_full_(table->is_full()),
       offset_left_(options.offset),
       limit_left_(options.limit),
@@ -204,7 +204,7 @@ TableReverseCursor::TableReverseCursor(const Table *table,
       is_full_(table->is_full()),
       offset_left_(options.offset),
       limit_left_(options.limit),
-      next_row_id_(table->max_row_id().value()) {}
+      next_row_id_(table->max_row_id().raw()) {}
 
 // -- Table --
 
@@ -371,7 +371,7 @@ void Table::insert_row_at(Int row_id, const Datum &key) {
   if (test_row(row_id)) {
     throw "Row ID already validated";  // TODO
   }
-  if (row_id.value() < 0) {
+  if (row_id.raw() < 0) {
     throw "Negative row ID";  // TODO
   }
   if (key_column_) {
@@ -476,7 +476,7 @@ Int Table::find_next_row_id() const {
   if (is_empty()) {
     return Int(0);
   } else if (is_full()) {
-    return Int(max_row_id_.value() + 1);
+    return Int(max_row_id_.raw() + 1);
   }
   size_t pos = 0;
   for (size_t i = bitmap_indexes_.size(); i > 0; ) {
@@ -489,11 +489,11 @@ Int Table::find_next_row_id() const {
 
 void Table::reserve_row(Int row_id) {
   // TODO: Define the upper limit for row ID.
-//  if (row_id.value() > MAX_ROW_ID_VALUE) {
+//  if (row_id.raw() > MAX_ROW_ID_VALUE) {
 //    throw "Too large row ID";  // TODO
 //  }
   // Resize the bitmap if required.
-  size_t block_id = static_cast<size_t>(row_id.value()) / 64;
+  size_t block_id = static_cast<size_t>(row_id.raw()) / 64;
   if (block_id >= bitmap_.size()) {
     bitmap_.resize(block_id + 1, 0);
   }
@@ -520,7 +520,7 @@ void Table::reserve_row(Int row_id) {
 
 void Table::validate_row(Int row_id) {
   // Update the bitmap and its indexes.
-  size_t bit_id = static_cast<size_t>(row_id.value());
+  size_t bit_id = static_cast<size_t>(row_id.raw());
   bitmap_[bit_id / 64] |= uint64_t(1) << (bit_id % 64);
   if (bitmap_[bit_id / 64] == ~uint64_t(0)) {
     for (size_t index_id = 0; index_id < bitmap_indexes_.size(); ++index_id) {
@@ -532,7 +532,7 @@ void Table::validate_row(Int row_id) {
     }
   }
   // This works well even if "max_row_id_" is N/A.
-  if (row_id.value() > max_row_id_.value()) {
+  if (row_id.raw() > max_row_id_.raw()) {
     max_row_id_ = row_id;
   }
   ++num_rows_;
@@ -540,7 +540,7 @@ void Table::validate_row(Int row_id) {
 
 void Table::invalidate_row(Int row_id) {
   // Update the bitmap and its indexes.
-  size_t bit_id = static_cast<size_t>(row_id.value());
+  size_t bit_id = row_id.raw();
   bool is_full = (bitmap_[bit_id / 64] == ~uint64_t(0));
   bitmap_[bit_id / 64] &= ~(uint64_t(1) << (bit_id % 64));
   if (is_full) {
@@ -557,8 +557,8 @@ void Table::invalidate_row(Int row_id) {
   --num_rows_;
   if (is_empty()) {
     max_row_id_ = Int::na();
-  } else if (row_id.value() == max_row_id_.value()) {
-    int64_t block_id = (row_id.value() - 1) / 64;
+  } else if (row_id.match(max_row_id_)) {
+    int64_t block_id = (row_id.raw() - 1) / 64;
     while (block_id >= 0) {
       if (bitmap_[block_id] != 0) {
         break;

  Modified: lib/grnxx/impl/table.hpp (+2 -2)
===================================================================
--- lib/grnxx/impl/table.hpp    2014-11-25 11:29:33 +0900 (54905e3)
+++ lib/grnxx/impl/table.hpp    2014-11-25 12:44:39 +0900 (44ea5f1)
@@ -44,7 +44,7 @@ class Table : public TableInterface {
   }
   bool is_full() const {
     return is_empty() ||
-           (num_rows_ == static_cast<size_t>(max_row_id_.value() + 1));
+           (num_rows_ == static_cast<size_t>(max_row_id_.raw() + 1));
   }
 
   ColumnBase *create_column(const String &name,
@@ -69,7 +69,7 @@ class Table : public TableInterface {
   void remove_row(Int row_id);
 
   bool test_row(Int row_id) const {
-    size_t bit_id = static_cast<size_t>(row_id.value());
+    size_t bit_id = row_id.raw();
     size_t block_id = bit_id / 64;
     return (block_id < bitmap_.size()) &&
            ((bitmap_[block_id] & (uint64_t(1) << (bit_id % 64))) != 0);




More information about the Groonga-commit mailing list
Zurück zum Archiv-Index