susumu.yata
null+****@clear*****
Tue Dec 16 10:40:50 JST 2014
susumu.yata 2014-11-06 08:27:45 +0900 (Thu, 06 Nov 2014) New Revision: da88eb99a4f730a61815bac7ed0238255b72ad72 https://github.com/groonga/grnxx/commit/da88eb99a4f730a61815bac7ed0238255b72ad72 Message: Update Column interface. Modified files: include/grnxx/column.hpp lib/grnxx/impl/column/base.cpp lib/grnxx/impl/column/base.hpp Modified: include/grnxx/column.hpp (+59 -80) =================================================================== --- include/grnxx/column.hpp 2014-11-06 08:26:54 +0900 (2600868) +++ include/grnxx/column.hpp 2014-11-06 08:27:45 +0900 (c32ea51) @@ -3,9 +3,9 @@ #include <memory> -#include "grnxx/column.hpp" #include "grnxx/cursor.hpp" #include "grnxx/data_types.hpp" +#include "grnxx/index.hpp" #include "grnxx/string.hpp" namespace grnxx { @@ -32,75 +32,57 @@ class Column { // Return the reference table. // If "this" is not a reference column, returns nullptr. virtual Table *reference_table() const = 0; -// // Return whether the column has the key attribute or not. -// virtual bool is_key() const = 0; -// // Return the number of indexes. -// virtual size_t num_indexes() const = 0; - -// // Create an index with "name", "index_type", and "index_options". -// // -// // On success, returns a pointer to the index. -// // On failure, returns nullptr and stores error information into "*error" if -// // "error" != nullptr. -// virtual Index *create_index( -// Error *error, -// const String &name, -// IndexType type, -// const IndexOptions &options = IndexOptions()) = 0; - -// // Remove an index named "name". -// // -// // On success, returns true. -// // On failure, returns false and stores error information into "*error" if -// // "error" != nullptr. -// // -// // Note: Pointers to the removed index must not be used after deletion. -// virtual bool remove_index(Error *error, const String &name) = 0; - -// // Rename an index named "name" to "new_name". -// // -// // On success, returns true. -// // On failure, returns false and stores error information into "*error" if -// // "error" != nullptr. -// virtual bool rename_index(Error *error, -// const String &name, -// const String &new_name) = 0; - -// // Change the order of indexes. -// // -// // If "prev_name" is an empty string, moves an index named "name" to the -// // head. -// // If "name" == "prev_name", does nothing. -// // Otherwise, moves an index named "name" to next to an index named -// // "prev_name". -// // -// // On success, returns true. -// // On failure, returns false and stores error information into "*error" if -// // "error" != nullptr. -// virtual bool reorder_index(Error *error, -// const String &name, -// const String &prev_name) = 0; - -// // Get an index identified by "index_id". -// // -// // If "index_id" is invalid, the result is undefined. -// // -// // On success, returns a pointer to the index. -// // On failure, returns nullptr and stores error information into "*error" if -// // "error" != nullptr. -// virtual Index *get_index(Int index_id) const = 0; - -// // Find an index named "name". -// // -// // On success, returns a pointer to the index. -// // On failure, returns nullptr and stores error information into "*error" if -// // "error" != nullptr. -// virtual Index *find_index(Error *error, const String &name) const = 0; - - // Get a value associated with "row_id". + // Return whether "this" is a key column or not. + virtual bool is_key() const = 0; + // Return the number of indexes. + virtual size_t num_indexes() const = 0; + + // Create an index. // - // If "row_id" is invalid, stores N/A into "*datum". + // On success, returns the index. + // On failure, throws an exception. + virtual Index *create_index( + const String &name, + IndexType type, + const IndexOptions &options = IndexOptions()) = 0; + + // Remove an index. + // + // On failure, throws an exception. + virtual void remove_index(const String &name) = 0; + + // Rename an index. + // + // On failure, throws an exception. + virtual void rename_index(const String &name, const String &new_name) = 0; + + // Change the order of indexes. // + // If "prev_name" is an empty string, moves an index named "name" to the + // head. + // If "name" == "prev_name", does nothing. + // Otherwise, moves an index named "name" to next to an index named + // "prev_name". + // + // On failure, throws an exception. + virtual void reorder_index(const String &name, + const String &prev_name) = 0; + + // Return the "i"-th index. + // + // If "i" >= "num_indexes()", the behavior is undefined. + virtual Index *get_index(size_t i) const = 0; + + // Find an index. + // + // If found, returns the index. + // If not found, returns nullptr. + virtual Index *find_index(const String &name) const = 0; + + // Get a value. + // + // If "row_id" is valid, stores the value into "*datum". + // If "row_id" is invalid, stores N/A into "*datum". // On failure, throws an exception. virtual void get(Int row_id, Datum *datum) const = 0; @@ -109,20 +91,17 @@ class Column { // On failure, throws an exception. virtual void set(Int row_id, const Datum &datum) = 0; -// // Check if "datum" exists in the column or not. -// // -// // If exists, returns true. -// // Otherwise, returns false. -// virtual bool contains(const Datum &datum) const = 0; + // Return whether "this" contains "datum" or not. + virtual bool contains(const Datum &datum) const = 0; -// // Find "datum" in the column. -// // -// // On success, returns the row ID of the matched value. -// // On failure, returns NULL_ROW_ID. -// virtual Int find_one(const Datum &datum) const = 0; + // Find "datum" in the column. + // + // If found, returns the row ID. + // If not found, returns N/A. + virtual Int find_one(const Datum &datum) const = 0; - std::unique_ptr<Cursor> create_cursor( - const CursorOptions &options = CursorOptions()); +// virtual std::unique_ptr<Cursor> create_cursor( +// const CursorOptions &options = CursorOptions()) = 0; protected: virtual ~Column() = default; Modified: lib/grnxx/impl/column/base.cpp (+4 -4) =================================================================== --- lib/grnxx/impl/column/base.cpp 2014-11-06 08:26:54 +0900 (42c8403) +++ lib/grnxx/impl/column/base.cpp 2014-11-06 08:27:45 +0900 (a8d2f2d) @@ -138,10 +138,10 @@ TableInterface *ColumnBase::reference_table() const { // return find_one(datum) != NULL_ROW_ID; //} -Int ColumnBase::find_one(const Datum &) const { - // TODO: This function should be pure virtual. - return Int::na(); -} +//Int ColumnBase::find_one(const Datum &) const { +// // TODO: This function should be pure virtual. +// return Int::na(); +//} std::unique_ptr<ColumnBase> ColumnBase::create(Table *table, const String &name, Modified: lib/grnxx/impl/column/base.hpp (+4 -9) =================================================================== --- lib/grnxx/impl/column/base.hpp 2014-11-06 08:26:54 +0900 (c437ff4) +++ lib/grnxx/impl/column/base.hpp 2014-11-06 08:27:45 +0900 (10ff7bb) @@ -41,17 +41,12 @@ class ColumnBase : public ColumnInterface { } // Index *create_index( -// Error *error, // const String &name, // IndexType type, // const IndexOptions &options = IndexOptions()); -// bool remove_index(Error *error, const String &name); -// bool rename_index(Error *error, -// const String &name, -// const String &new_name); -// bool reorder_index(Error *error, -// const String &name, -// const String &prev_name); +// void remove_index(const String &name); +// void rename_index(const String &name, const String &new_name); +// bool reorder_index(const String &name, const String &prev_name); // Index *get_index(Int index_id) const { // return indexes_[index_id].get(); @@ -62,7 +57,7 @@ class ColumnBase : public ColumnInterface { // bool get(Error *error, Int row_id, Datum *datum) const; // bool contains(const Datum &datum) const; - Int find_one(const Datum &datum) const; +// Int find_one(const Datum &datum) const; // -- Internal API -- -------------- next part -------------- HTML����������������������������...Descargar