[Groonga-commit] groonga/grnxx at a0b2171 [new_data_types] Remove old implementations of Column.

Zurück zum Archiv-Index

susumu.yata null+****@clear*****
Tue Nov 18 19:35:32 JST 2014


susumu.yata	2014-11-18 19:35:32 +0900 (Tue, 18 Nov 2014)

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

  Message:
    Remove old implementations of Column.

  Removed files:
    lib/grnxx/impl/column/column.cpp
    lib/grnxx/impl/column/column.hpp

  Deleted: lib/grnxx/impl/column/column.cpp (+0 -110) 100644
===================================================================
--- lib/grnxx/impl/column/column.cpp    2014-11-18 16:51:16 +0900 (ecafca0)
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "grnxx/impl/column/column.hpp"
-
-#include "grnxx/cursor.hpp"
-#include "grnxx/impl/db.hpp"
-#include "grnxx/impl/table.hpp"
-#include "grnxx/index.hpp"
-
-namespace grnxx {
-namespace impl {
-
-template <typename T>
-bool Column<T>::set(Error *error, Int row_id, const Datum &datum) {
-  if (datum.type() != TypeTraits<T>::data_type()) {
-    GRNXX_ERROR_SET(error, INVALID_ARGUMENT, "Wrong data type");
-    return false;
-  }
-  if (!table_->test_row(error, row_id)) {
-    return false;
-  }
-  // Note that a Bool object does not have its own address.
-  T old_value = get(row_id);
-  T new_value;
-  datum.force(&new_value);
-  if (new_value != old_value) {
-    for (Int i = 0; i < num_indexes(); ++i) {
-      if (!indexes_[i]->insert(error, row_id, datum)) {
-        for (Int j = 0; j < i; ++i) {
-          indexes_[j]->remove(nullptr, row_id, datum);
-        }
-        return false;
-      }
-    }
-    for (Int i = 0; i < num_indexes(); ++i) {
-      indexes_[i]->remove(nullptr, row_id, old_value);
-    }
-  }
-  values_.set(row_id, new_value);
-  return true;
-}
-
-template <typename T>
-bool Column<T>::get(Error *error, Int row_id, Datum *datum) const {
-  if (!table_->test_row(error, row_id)) {
-    return false;
-  }
-  *datum = values_[row_id];
-  return true;
-}
-
-template <typename T>
-unique_ptr<Column<T>> Column<T>::create(Error *error,
-                                        Table *table,
-                                        const StringCRef &name,
-                                        const ColumnOptions &options) {
-  unique_ptr<Column> column(new (nothrow) Column);
-  if (!column) {
-    GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed");
-    return nullptr;
-  }
-  if (!column->initialize_base(error, table, name,
-                               TypeTraits<T>::data_type(), options)) {
-    return nullptr;
-  }
-  if (!column->values_.resize(error, table->max_row_id() + 1,
-                              TypeTraits<T>::default_value())) {
-    return nullptr;
-  }
-  return column;
-}
-
-template <typename T>
-Column<T>::~Column() {}
-
-template <typename T>
-bool Column<T>::set_default_value(Error *error, Int row_id) {
-  if (row_id >= values_.size()) {
-    if (!values_.resize(error, row_id + 1, TypeTraits<T>::default_value())) {
-      return false;
-    }
-  }
-  T value = TypeTraits<T>::default_value();
-  for (Int i = 0; i < num_indexes(); ++i) {
-    if (!indexes_[i]->insert(error, row_id, value)) {
-      for (Int j = 0; j < i; ++j) {
-        indexes_[j]->remove(nullptr, row_id, value);
-      }
-      return false;
-    }
-  }
-  values_.set(row_id, value);
-  return true;
-}
-
-template <typename T>
-void Column<T>::unset(Int row_id) {
-  for (Int i = 0; i < num_indexes(); ++i) {
-    indexes_[i]->remove(nullptr, row_id, get(row_id));
-  }
-  values_.set(row_id, TypeTraits<T>::default_value());
-}
-
-template <typename T>
-Column<T>::Column() : ColumnBase(), values_() {}
-
-template class Column<Bool>;
-template class Column<GeoPoint>;
-template class Column<Vector<Bool>>;
-
-}  // namespace impl
-}  // namespace grnxx

  Deleted: lib/grnxx/impl/column/column.hpp (+0 -61) 100644
===================================================================
--- lib/grnxx/impl/column/column.hpp    2014-11-18 16:51:16 +0900 (4989837)
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef GRNXX_IMPL_COLUMN_COLUMN_HPP
-#define GRNXX_IMPL_COLUMN_COLUMN_HPP
-
-#include "grnxx/impl/column/base.hpp"
-
-namespace grnxx {
-namespace impl {
-
-//template <typename T> class Column;
-
-template <typename T>
-class Column : public ColumnBase {
- public:
-  // -- Public API (grnxx/column.hpp) --
-
-  bool set(Error *error, Int row_id, const Datum &datum);
-  bool get(Error *error, Int row_id, Datum *datum) const;
-
-  // -- Internal API (grnxx/impl/column/column_base.hpp) --
-
-  ~Column();
-
-  bool set_default_value(Error *error, Int row_id);
-  void unset(Int row_id);
-
-  // -- Internal API --
-
-  // Create a new column.
-  //
-  // Returns a pointer to the column on success.
-  // On failure, returns nullptr and stores error information into "*error" if
-  // "error" != nullptr.
-  static unique_ptr<Column> create(Error *error,
-                                   Table *table,
-                                   const StringCRef &name,
-                                   const ColumnOptions &options);
-
-  // Return a value identified by "row_id".
-  //
-  // Assumes that "row_id" is valid. Otherwise, the result is undefined.
-  T get(Int row_id) const {
-    return values_[row_id];
-  }
-
-  // Read values.
-  void read(ArrayCRef<Record> records, ArrayRef<T> values) const {
-    for (Int i = 0; i < records.size(); ++i) {
-      values.set(i, get(records.get_row_id(i)));
-    }
-  }
-
- private:
-  Array<T> values_;
-
-  Column();
-};
-
-}  // namespace impl
-}  // namespace grnxx
-
-#endif  // GRNXX_IMPL_COLUMN_COLUMN_HPP
-------------- next part --------------
HTML����������������������������...
Download 



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