susumu.yata
null+****@clear*****
Tue Sep 9 17:16:41 JST 2014
susumu.yata 2014-09-09 17:16:41 +0900 (Tue, 09 Sep 2014) New Revision: 18613f92e4edb4c2c469faa7a25fffdef1d2b81a https://github.com/groonga/grnxx/commit/18613f92e4edb4c2c469faa7a25fffdef1d2b81a Message: Enable TypedNode<Float>::adjust(). (#50) Modified files: lib/grnxx/expression.cpp Modified: lib/grnxx/expression.cpp (+18 -17) =================================================================== --- lib/grnxx/expression.cpp 2014-09-09 16:11:49 +0900 (df22468) +++ lib/grnxx/expression.cpp 2014-09-09 17:16:41 +0900 (e23496b) @@ -205,7 +205,7 @@ class TypedNode<Float> : public Node { public: using Value = Float; - TypedNode() : Node() {} + TypedNode() : Node(), scores_() {} virtual ~TypedNode() {} DataType data_type() const { @@ -224,28 +224,29 @@ class TypedNode<Float> : public Node { } // Derived classes must override this member function. - virtual bool adjust(Error *error, ArrayRef<Record> records) = 0; + virtual bool adjust(Error *error, ArrayRef<Record> records); virtual bool evaluate(Error *error, ArrayCRef<Record> records, ArrayRef<Value> results) = 0; + + private: + Array<Float> scores_; }; -//template <> -//bool TypedNode<Float>::adjust(Error *error, ArrayRef<Record> records) { -// // TODO: This implementation should be overridden by derived classes. -// Array<Float> scores; -// if (!scores.resize(error, records.size())) { -// return false; -// } -// if (!evaluate(error, records, scores)) { -// return false; -// } -// for (Int i = 0; i < records.size(); ++i) { -// records.set_score(i, scores[i]); -// } -// return true; -//} +bool TypedNode<Float>::adjust(Error *error, ArrayRef<Record> records) { + // TODO: This implementation should be overridden by derived classes. + if (!scores_.resize(error, records.size())) { + return false; + } + if (!evaluate(error, records, scores_.ref())) { + return false; + } + for (Int i = 0; i < records.size(); ++i) { + records.set_score(i, scores_[i]); + } + return true; +} // -- DatumNode -- -------------- next part -------------- HTML����������������������������... Download