susumu.yata
null+****@clear*****
Thu Nov 20 19:17:27 JST 2014
susumu.yata 2014-11-20 19:17:27 +0900 (Thu, 20 Nov 2014) New Revision: 2fade67cfedb53fa58effb2c1210231a7750cc7a https://github.com/groonga/grnxx/commit/2fade67cfedb53fa58effb2c1210231a7750cc7a Message: Change the order of function definitions. Modified files: lib/grnxx/impl/sorter.cpp lib/grnxx/impl/sorter.hpp Modified: lib/grnxx/impl/sorter.cpp (+33 -33) =================================================================== --- lib/grnxx/impl/sorter.cpp 2014-11-20 18:53:34 +0900 (f44d97f) +++ lib/grnxx/impl/sorter.cpp 2014-11-20 19:17:27 +0900 (ad4a668) @@ -430,6 +430,39 @@ Node *Node::create(SorterOrder &&order) try { using namespace sorter; +Sorter::Sorter(Array<SorterOrder> &&orders, const SorterOptions &options) + : table_(nullptr), + nodes_(), + records_(nullptr), + offset_(options.offset), + limit_(options.limit) { + // A sorter requires one or more orders. + // Also, expressions must be valid and associated tables must be the same. + if (orders.size() == 0) { + throw "No order"; // TODO + } + for (size_t i = 0; i < orders.size(); ++i) { + if (!orders[i].expression) { + throw "Missing expression"; // TODO + } + } + table_ = static_cast<const Table *>(orders[0].expression->table()); + for (size_t i = 1; i < orders.size(); ++i) { + if (orders[i].expression->table() != table_) { + throw "Table conflict"; // TODO + } + } + + nodes_.resize(orders.size()); + for (size_t i = 0; i < orders.size(); ++i) { + nodes_[i].reset(Node::create(std::move(orders[i]))); + } + for (size_t i = 1; i < orders.size(); ++i) { + nodes_[i - 1]->set_next(nodes_[i].get()); + } + orders.clear(); +} + Sorter::~Sorter() {} void Sorter::reset(Array<Record> *records) { @@ -470,38 +503,5 @@ void Sorter::sort(Array<Record> *records) { finish(); } -Sorter::Sorter(Array<SorterOrder> &&orders, const SorterOptions &options) - : table_(nullptr), - nodes_(), - records_(nullptr), - offset_(options.offset), - limit_(options.limit) { - // A sorter requires one or more orders. - // Also, expressions must be valid and associated tables must be the same. - if (orders.size() == 0) { - throw "No order"; // TODO - } - for (size_t i = 0; i < orders.size(); ++i) { - if (!orders[i].expression) { - throw "Missing expression"; // TODO - } - } - table_ = static_cast<const Table *>(orders[0].expression->table()); - for (size_t i = 1; i < orders.size(); ++i) { - if (orders[i].expression->table() != table_) { - throw "Table conflict"; // TODO - } - } - - nodes_.resize(orders.size()); - for (size_t i = 0; i < orders.size(); ++i) { - nodes_[i].reset(Node::create(std::move(orders[i]))); - } - for (size_t i = 1; i < orders.size(); ++i) { - nodes_[i - 1]->set_next(nodes_[i].get()); - } - orders.clear(); -} - } // namespace impl } // namespace grnxx Modified: lib/grnxx/impl/sorter.hpp (+1 -5) =================================================================== --- lib/grnxx/impl/sorter.hpp 2014-11-20 18:53:34 +0900 (96734ec) +++ lib/grnxx/impl/sorter.hpp 2014-11-20 19:17:27 +0900 (298fd29) @@ -20,6 +20,7 @@ class Sorter : public SorterInterface { // -- Public API (grnxx/sorter.hpp) -- + Sorter(Array<SorterOrder> &&orders, const SorterOptions &options); ~Sorter(); const Table *table() const { @@ -30,11 +31,6 @@ class Sorter : public SorterInterface { void finish(); void sort(Array<Record> *records); - // -- Internal API -- - - // On failure, throws an exception. - Sorter(Array<SorterOrder> &&orders, const SorterOptions &options); - private: const Table *table_; Array<std::unique_ptr<Node>> nodes_; -------------- next part -------------- HTML����������������������������...ダウンロード