susumu.yata
null+****@clear*****
Thu Jul 24 11:15:34 JST 2014
susumu.yata 2014-07-24 11:15:34 +0900 (Thu, 24 Jul 2014) New Revision: bd0e2281ba2aea212082159c1b1222026e7e6621 https://github.com/groonga/grnxx/commit/bd0e2281ba2aea212082159c1b1222026e7e6621 Message: Add Sorter dummy implementation. Modified files: include/grnxx/sorter.hpp lib/grnxx/sorter.cpp Modified: include/grnxx/sorter.hpp (+4 -2) =================================================================== --- include/grnxx/sorter.hpp 2014-07-24 09:57:42 +0900 (10611c0) +++ include/grnxx/sorter.hpp 2014-07-24 11:15:34 +0900 (580fd48) @@ -14,9 +14,9 @@ class Sorter { // On success, returns a poitner to the sorter. // On failure, returns nullptr and stores error information into "*error" if // "error" != nullptr. - static std::unique_ptr<Sorter> create( + static unique_ptr<Sorter> create( Error *error, - std::unique_ptr<OrderSet> &&order_set, + unique_ptr<OrderSet> &&order_set, const SorterOptions &options); // Set the target record set. @@ -55,6 +55,8 @@ class Sorter { bool sort(Error *error, RecordSet *record_set); private: + RecordSet *record_set_; + Sorter(); }; Modified: lib/grnxx/sorter.cpp (+45 -0) =================================================================== --- lib/grnxx/sorter.cpp 2014-07-24 09:57:42 +0900 (0a63eef) +++ lib/grnxx/sorter.cpp 2014-07-24 11:15:34 +0900 (92a88b9) @@ -1,7 +1,52 @@ #include "grnxx/sorter.hpp" +#include "grnxx/error.hpp" + namespace grnxx { +namespace { // TODO +} // namespace + +Sorter::~Sorter() {} + +unique_ptr<Sorter> Sorter::create( + Error *error, + unique_ptr<OrderSet> &&order_set, + const SorterOptions &options) { + unique_ptr<Sorter> sorter(new (nothrow) Sorter); + if (!sorter) { + GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed"); + return nullptr; + } + return sorter; +} + +bool Sorter::reset(Error *error, RecordSet *record_set) { + record_set_ = record_set; + return true; +} + +bool Sorter::progress(Error *error) { + // TODO: Incremental sorting is not supported yet. + return true; +} + +bool Sorter::finish(Error *error) { + if (!record_set_) { + // Nothing to do. + return true; + } + // TODO: Sorting is not supported yet. + GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet"); + return false; +} + +bool Sorter::sort(Error *error, RecordSet *record_set) { + return reset(error, record_set) && finish(error); +} + +Sorter::Sorter() : record_set_(nullptr) {} + } // namespace grnxx -------------- next part -------------- HTML����������������������������... 下載