susumu.yata
null+****@clear*****
Wed Sep 10 14:49:24 JST 2014
susumu.yata 2014-09-10 14:49:24 +0900 (Wed, 10 Sep 2014) New Revision: 3c9c594c91d00fe1987a59a978b3cdb2f350f619 https://github.com/groonga/grnxx/commit/3c9c594c91d00fe1987a59a978b3cdb2f350f619 Message: Add Expression::push_row_id() and push_score(). (#54) Modified files: include/grnxx/expression.hpp lib/grnxx/expression.cpp Modified: include/grnxx/expression.hpp (+14 -0) =================================================================== --- include/grnxx/expression.hpp 2014-09-10 14:40:58 +0900 (0c1c11e) +++ include/grnxx/expression.hpp 2014-09-10 14:49:24 +0900 (796763b) @@ -214,6 +214,20 @@ class ExpressionBuilder { // "error" != nullptr. bool push_datum(Error *error, const Datum &datum); + // Push a node associated with row IDs of Records. + // + // On success, returns true. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_row_id(Error *error); + + // Push a node associated with scores of Records. + // + // On success, returns true. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_score(Error *error); + // Push a node associated with a column. // // TODO: "_id" and "_score" will be obsolete. Modified: lib/grnxx/expression.cpp (+50 -1) =================================================================== --- lib/grnxx/expression.cpp 2014-09-10 14:40:58 +0900 (e0d3b8c) +++ lib/grnxx/expression.cpp 2014-09-10 14:49:24 +0900 (52d32b6) @@ -2679,6 +2679,20 @@ class Builder { // "error" != nullptr. bool push_datum(Error *error, const Datum &datum); + // Push a node associated with row IDs of Records. + // + // On success, returns true. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_row_id(Error *error); + + // Push a node associated with scores of Records. + // + // On success, returns true. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_score(Error *error); + // Push a column. // // If "name" == "_id", pushes a pseudo column associated with row IDs. @@ -2793,7 +2807,6 @@ class Builder { unique_ptr<Node> &&arg2); }; - unique_ptr<Builder> Builder::create(Error *error, const Table *table) { unique_ptr<Builder> builder(new (nothrow) Builder(table)); if (!builder) { @@ -2817,6 +2830,34 @@ bool Builder::push_datum(Error *error, const Datum &datum) { return true; } +bool Builder::push_row_id(Error *error) { + // Reserve a space for a new node. + if (!stack_.reserve(error, stack_.size() + 1)) { + return false; + } + unique_ptr<Node> node(RowIDNode::create(error)); + if (!node) { + return false; + } + // This push_back() must not fail because a space is already reserved. + stack_.push_back(nullptr, std::move(node)); + return true; +} + +bool Builder::push_score(Error *error) { + // Reserve a space for a new node. + if (!stack_.reserve(error, stack_.size() + 1)) { + return false; + } + unique_ptr<Node> node(ScoreNode::create(error)); + if (!node) { + return false; + } + // This push_back() must not fail because a space is already reserved. + stack_.push_back(nullptr, std::move(node)); + return true; +} + bool Builder::push_column(Error *error, String name) { // Reserve a space for a new node. if (!stack_.reserve(error, stack_.size() + 1)) { @@ -3683,6 +3724,14 @@ bool ExpressionBuilder::push_datum(Error *error, const Datum &datum) { return builders_.back()->push_datum(error, datum); } +bool ExpressionBuilder::push_row_id(Error *error) { + return builders_.back()->push_row_id(error); +} + +bool ExpressionBuilder::push_score(Error *error) { + return builders_.back()->push_score(error); +} + bool ExpressionBuilder::push_column(Error *error, String name) { return builders_.back()->push_column(error, name); } -------------- next part -------------- HTML����������������������������...Descargar