[Groonga-commit] groonga/grnxx at 92ab7a1 [master] Enable Index mock-up.

Back to archive index

susumu.yata null+****@clear*****
Tue Dec 16 10:40:50 JST 2014


susumu.yata	2014-11-06 08:26:54 +0900 (Thu, 06 Nov 2014)

  New Revision: 92ab7a19b08df6ab3d0de990eb3c8fe6c8828dc2
  https://github.com/groonga/grnxx/commit/92ab7a19b08df6ab3d0de990eb3c8fe6c8828dc2

  Message:
    Enable Index mock-up.

  Modified files:
    include/grnxx/Makefile.am
    include/grnxx/index.hpp

  Modified: include/grnxx/Makefile.am (+1 -1)
===================================================================
--- include/grnxx/Makefile.am    2014-11-06 08:23:43 +0900 (1d9b0e1)
+++ include/grnxx/Makefile.am    2014-11-06 08:26:54 +0900 (0ddf15b)
@@ -10,12 +10,12 @@ pkginclude_HEADERS =	\
 	db.hpp		\
 	error.hpp	\
 	features.hpp	\
+	index.hpp	\
 	library.hpp	\
 	string.hpp	\
 	table.hpp
 
 #	expression.hpp	\
-#	index.hpp	\
 #	merger.hpp	\
 #	pipeline.hpp	\
 #	sorter.hpp

  Modified: include/grnxx/index.hpp (+194 -182)
===================================================================
--- include/grnxx/index.hpp    2014-11-06 08:23:43 +0900 (ab70f7b)
+++ include/grnxx/index.hpp    2014-11-06 08:26:54 +0900 (97c99c3)
@@ -1,199 +1,211 @@
 #ifndef GRNXX_INDEX_HPP
 #define GRNXX_INDEX_HPP
 
-#include "grnxx/name.hpp"
-#include "grnxx/types.hpp"
+#include <memory>
 
-namespace grnxx {
-namespace impl {
-
-class ColumnBase;
-
-}  // namespace impl
+#include "grnxx/cursor.hpp"
+#include "grnxx/data_types.hpp"
+#include "grnxx/index.hpp"
+#include "grnxx/string.hpp"
 
-enum EndPointType {
-  INCLUSIVE_END_POINT,
-  EXCLUSIVE_END_POINT
-};
+namespace grnxx {
 
-struct EndPoint {
-  Datum value;
-  EndPointType type;
+class Column;
+
+//enum EndPointType {
+//  INCLUSIVE_END_POINT,
+//  EXCLUSIVE_END_POINT
+//};
+
+//struct EndPoint {
+//  Datum value;
+//  EndPointType type;
+//};
+
+//class IndexRange {
+// public:
+//  IndexRange()
+//      : has_lower_bound_(false),
+//        has_upper_bound_(false),
+//        lower_bound_(),
+//        upper_bound_() {}
+
+//  bool has_lower_bound() const {
+//    return has_lower_bound_;
+//  }
+//  bool has_upper_bound() const {
+//    return has_upper_bound_;
+//  }
+
+//  const EndPoint &lower_bound() const {
+//    return lower_bound_;
+//  }
+//  const EndPoint &upper_bound() const {
+//    return upper_bound_;
+//  }
+
+//  void set_lower_bound(const Datum &value,
+//                       EndPointType type = INCLUSIVE_END_POINT) {
+//    has_lower_bound_ = true;
+//    lower_bound_.value = value;
+//    lower_bound_.type = type;
+//  }
+//  void set_upper_bound(const Datum &value,
+//                       EndPointType type = INCLUSIVE_END_POINT) {
+//    has_upper_bound_ = true;
+//    upper_bound_.value = value;
+//    upper_bound_.type = type;
+//  }
+
+//  void unset_lower_bound() {
+//    has_lower_bound_ = false;
+//  }
+//  void unset_upper_bound() {
+//    has_lower_bound_ = false;
+//  }
+
+// private:
+//  bool has_lower_bound_;
+//  bool has_upper_bound_;
+//  EndPoint lower_bound_;
+//  EndPoint upper_bound_;
+//};
+
+enum IndexType {
+  // TODO: Tree indexes support range search.
+  TREE_INDEX,
+  // TODO: Hash indexes support exact match search.
+  HASH_INDEX
 };
 
-class IndexRange {
- public:
-  IndexRange()
-      : has_lower_bound_(false),
-        has_upper_bound_(false),
-        lower_bound_(),
-        upper_bound_() {}
-
-  bool has_lower_bound() const {
-    return has_lower_bound_;
-  }
-  bool has_upper_bound() const {
-    return has_upper_bound_;
-  }
-
-  const EndPoint &lower_bound() const {
-    return lower_bound_;
-  }
-  const EndPoint &upper_bound() const {
-    return upper_bound_;
-  }
-
-  void set_lower_bound(const Datum &value,
-                       EndPointType type = INCLUSIVE_END_POINT) {
-    has_lower_bound_ = true;
-    lower_bound_.value = value;
-    lower_bound_.type = type;
-  }
-  void set_upper_bound(const Datum &value,
-                       EndPointType type = INCLUSIVE_END_POINT) {
-    has_upper_bound_ = true;
-    upper_bound_.value = value;
-    upper_bound_.type = type;
-  }
-
-  void unset_lower_bound() {
-    has_lower_bound_ = false;
-  }
-  void unset_upper_bound() {
-    has_lower_bound_ = false;
-  }
-
- private:
-  bool has_lower_bound_;
-  bool has_upper_bound_;
-  EndPoint lower_bound_;
-  EndPoint upper_bound_;
+struct IndexOptions {
 };
 
 class Index {
  public:
-  virtual ~Index();
-
-  // Return the owner column.
-  Column *column() const {
-    return column_;
-  }
-  // Return the name.
-  StringCRef name() const {
-    return name_.ref();
-  }
-  // Return the index type.
-  IndexType type() const {
-    return type_;
-  }
-
-  // Check if "datum" is registered or not.
-  //
-  // If registered, returns true.
-  // Otherwise, returns false.
-  virtual bool contains(const Datum &datum) const;
-
-  // Search the index for "datum".
-  //
-  // On success, returns the row ID of one of the matched values.
-  // On failure, returns NULL_ROW_ID.
-  virtual Int find_one(const Datum &datum) const;
-
-  // Create a cursor to get records.
-  //
-  // On success, returns a pointer to the cursor.
-  // On failure, returns nullptr and stores error information into "*error" if
-  // "error" != nullptr.
-  virtual unique_ptr<Cursor> find(
-      Error *error,
-      const Datum &datum,
-      const CursorOptions &options = CursorOptions()) const;
-
-  // Create a cursor to get records.
-  //
-  // Returns a pointer to the cursor on success.
-  // On failure, returns nullptr and stores error information into "*error" if
-  // "error" != nullptr.
-  virtual unique_ptr<Cursor> find_in_range(
-      Error *error,
-      const IndexRange &range = IndexRange(),
-      const CursorOptions &options = CursorOptions()) const;
-
-  // Create a cursor to get records.
-  //
-  // Returns a pointer to the cursor on success.
-  // On failure, returns nullptr and stores error information into "*error" if
-  // "error" != nullptr.
-  virtual unique_ptr<Cursor> find_starts_with(
-      Error *error,
-      const EndPoint &prefix,
-      const CursorOptions &options = CursorOptions()) const;
-
-  // Create a cursor to get records.
-  //
-  // Returns a pointer to the cursor on success.
-  // On failure, returns nullptr and stores error information into "*error" if
-  // "error" != nullptr.
-  virtual unique_ptr<Cursor> find_prefixes(
-      Error *error,
-      const Datum &datum,
-      const CursorOptions &options = CursorOptions()) const;
-
-  // Insert a new entry.
-  //
-  // On success, returns true.
-  // On failure, returns false and stores error information into "*error" if
-  // "error" != nullptr.
-  virtual bool insert(Error *error, Int row_id, const Datum &value) = 0;
-  // Insert an entry.
-  //
-  // On success, returns true.
-  // On failure, returns false and stores error information into "*error" if
-  // "error" != nullptr.
-  virtual bool remove(Error *error, Int row_id, const Datum &value) = 0;
+  virtual ~Index() = default;
+
+//  // Return the owner column.
+//  Column *column() const {
+//    return column_;
+//  }
+//  // Return the name.
+//  StringCRef name() const {
+//    return name_.ref();
+//  }
+//  // Return the index type.
+//  IndexType type() const {
+//    return type_;
+//  }
+
+//  // Check if "datum" is registered or not.
+//  //
+//  // If registered, returns true.
+//  // Otherwise, returns false.
+//  virtual bool contains(const Datum &datum) const;
+
+//  // Search the index for "datum".
+//  //
+//  // On success, returns the row ID of one of the matched values.
+//  // On failure, returns NULL_ROW_ID.
+//  virtual Int find_one(const Datum &datum) const;
+
+//  // Create a cursor to get records.
+//  //
+//  // On success, returns a pointer to the cursor.
+//  // On failure, returns nullptr and stores error information into "*error" if
+//  // "error" != nullptr.
+//  virtual unique_ptr<Cursor> find(
+//      Error *error,
+//      const Datum &datum,
+//      const CursorOptions &options = CursorOptions()) const;
+
+//  // Create a cursor to get records.
+//  //
+//  // Returns a pointer to the cursor on success.
+//  // On failure, returns nullptr and stores error information into "*error" if
+//  // "error" != nullptr.
+//  virtual unique_ptr<Cursor> find_in_range(
+//      Error *error,
+//      const IndexRange &range = IndexRange(),
+//      const CursorOptions &options = CursorOptions()) const;
+
+//  // Create a cursor to get records.
+//  //
+//  // Returns a pointer to the cursor on success.
+//  // On failure, returns nullptr and stores error information into "*error" if
+//  // "error" != nullptr.
+//  virtual unique_ptr<Cursor> find_starts_with(
+//      Error *error,
+//      const EndPoint &prefix,
+//      const CursorOptions &options = CursorOptions()) const;
+
+//  // Create a cursor to get records.
+//  //
+//  // Returns a pointer to the cursor on success.
+//  // On failure, returns nullptr and stores error information into "*error" if
+//  // "error" != nullptr.
+//  virtual unique_ptr<Cursor> find_prefixes(
+//      Error *error,
+//      const Datum &datum,
+//      const CursorOptions &options = CursorOptions()) const;
+
+//  // Insert a new entry.
+//  //
+//  // On success, returns true.
+//  // On failure, returns false and stores error information into "*error" if
+//  // "error" != nullptr.
+//  virtual bool insert(Error *error, Int row_id, const Datum &value) = 0;
+//  // Insert an entry.
+//  //
+//  // On success, returns true.
+//  // On failure, returns false and stores error information into "*error" if
+//  // "error" != nullptr.
+//  virtual bool remove(Error *error, Int row_id, const Datum &value) = 0;
+
+// protected:
+//  Column *column_;
+//  Name name_;
+//  IndexType type_;
+
+//  Index();
+
+//  // Initialize the base members.
+//  //
+//  // On success, returns true.
+//  // On failure, returns false and stores error information into "*error" if
+//  // "error" != nullptr.
+//  bool initialize_base(Error *error,
+//                       Column *column,
+//                       const StringCRef &name,
+//                       IndexType type,
+//                       const IndexOptions &options);
+
+// private:
+//  // Create a new index.
+//  //
+//  // Returns a pointer to the index on success.
+//  // On failure, returns nullptr and stores error information into "*error" if
+//  // "error" != nullptr.
+//  static unique_ptr<Index> create(
+//      Error *error,
+//      Column *column,
+//      const StringCRef &name,
+//      IndexType type,
+//      const IndexOptions &options = IndexOptions());
+
+//  // Change the index name.
+//  //
+//  // Returns true on success.
+//  // On failure, returns false and stores error information into "*error" if
+//  // "error" != nullptr.
+//  bool rename(Error *error, const StringCRef &new_name);
+
+//  // Return whether the index is removable or not.
+//  bool is_removable();
 
  protected:
-  Column *column_;
-  Name name_;
-  IndexType type_;
-
-  Index();
-
-  // Initialize the base members.
-  //
-  // On success, returns true.
-  // On failure, returns false and stores error information into "*error" if
-  // "error" != nullptr.
-  bool initialize_base(Error *error,
-                       Column *column,
-                       const StringCRef &name,
-                       IndexType type,
-                       const IndexOptions &options);
-
- private:
-  // Create a new index.
-  //
-  // Returns a pointer to the index on success.
-  // On failure, returns nullptr and stores error information into "*error" if
-  // "error" != nullptr.
-  static unique_ptr<Index> create(
-      Error *error,
-      Column *column,
-      const StringCRef &name,
-      IndexType type,
-      const IndexOptions &options = IndexOptions());
-
-  // Change the index name.
-  //
-  // Returns true on success.
-  // On failure, returns false and stores error information into "*error" if
-  // "error" != nullptr.
-  bool rename(Error *error, const StringCRef &new_name);
-
-  // Return whether the index is removable or not.
-  bool is_removable();
-
-  friend class impl::ColumnBase;
+  Index() = default;
 };
 
 }  // namespace grnxx
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index