susumu.yata
null+****@clear*****
Mon Aug 11 12:55:17 JST 2014
susumu.yata 2014-08-11 12:55:17 +0900 (Mon, 11 Aug 2014) New Revision: 16887780fe1e50883b03f7318cd5393ddec55cd5 https://github.com/groonga/grnxx/commit/16887780fe1e50883b03f7318cd5393ddec55cd5 Message: Implement LogicalAndNode. Modified files: lib/grnxx/expression2.cpp Modified: lib/grnxx/expression2.cpp (+24 -3) =================================================================== --- lib/grnxx/expression2.cpp 2014-08-11 11:58:42 +0900 (54ec053) +++ lib/grnxx/expression2.cpp 2014-08-11 12:55:17 +0900 (78e6512) @@ -810,7 +810,7 @@ class BinaryNode : public OperatorNode<T> { } }; -// ---- XXXNode ---- +// ---- LogicalAndNode ---- class LogicalAndNode : public BinaryNode<Bool, Bool, Bool> { public: @@ -843,8 +843,29 @@ bool LogicalAndNode::filter(Error *error, bool LogicalAndNode::evaluate(Error *error, ArrayCRef<Record> records, ArrayRef<Bool> *results) { - // TODO - return false; + // Apply argument filters to "records" and store the result to + // "temp_records_". Then, appends a sentinel to the end. + if (!temp_records_.resize(error, records.size() + 1)) { + return false; + } + ArrayRef<Record> ref = temp_records_; + if (!arg1_->filter(error, records, &ref) || + !arg2_->filter(error, ref, &ref)) { + return false; + } + temp_records_.set_row_id(ref.size(), NULL_ROW_ID); + + // Compare records in "records" and "ref". + Int count = 0; + for (Int i = 0; i < records.size(); ++i) { + if (records.get_row_id(i) == ref.get_row_id(count)) { + results->set(i, true); + ++count; + } else { + results->set(i, false); + } + } + return true; } // TODO: Other binary operators. -------------- next part -------------- HTML����������������������������...下载