susumu.yata
null+****@clear*****
Mon Jul 28 16:14:35 JST 2014
susumu.yata 2014-07-28 16:14:35 +0900 (Mon, 28 Jul 2014) New Revision: ee3dcea81aef33a48ba96670661c4bec7303b644 https://github.com/groonga/grnxx/commit/ee3dcea81aef33a48ba96670661c4bec7303b644 Message: Add get/set_row_id() and get/set_score() to RecordSet. Modified files: include/grnxx/record.hpp lib/grnxx/expression.cpp Modified: include/grnxx/record.hpp (+20 -6) =================================================================== --- include/grnxx/record.hpp 2014-07-28 13:38:20 +0900 (32858b1) +++ include/grnxx/record.hpp 2014-07-28 16:14:35 +0900 (99af53f) @@ -33,19 +33,33 @@ class RecordSet { return records_.push_back(error, record); } - // Return the record identified by "i". - // - // If "i" is invalid, the result is undefined. + // If "i" is invalid, the result of the following functions is undefined. + + // Return the "i"-th record. Record get(Int i) const { return records_[i]; } + // Return the row ID of the "i"-th record. + Int get_row_id(Int i) const { + return records_[i].row_id; + } + // Return the score of the "i"-th record. + Float get_score(Int i) const { + return records_[i].score; + } - // Set a record. - // - // If "i" is invalid, the result is undefined. + // Set the "i"-th record. void set(Int i, Record record) { records_[i] = record; } + // Set the row ID of the "i"-th record. + void set_row_id(Int i, Int row_id) { + records_[i].row_id = row_id; + } + // Set the score of the "i"-th record. + void set_score(Int i, Float score) { + records_[i].score = score; + } // Resize the set. // Modified: lib/grnxx/expression.cpp (+5 -7) =================================================================== --- lib/grnxx/expression.cpp 2014-07-28 13:38:20 +0900 (9a14600) +++ lib/grnxx/expression.cpp 2014-07-28 16:14:35 +0900 (19ee9cf) @@ -121,9 +121,7 @@ bool Node<Float>::adjust(Error *error, RecordSet *record_set) { return false; } for (Int i = 0; i < record_set->size(); ++i) { - Record record = record_set->get(i); - record.score = values_[i]; - record_set->set(i, record); + record_set->set_score(i, values_[i]); } return true; } @@ -205,7 +203,7 @@ class RowIDNode : public Node<Int> { return false; } for (Int i = 0; i < record_set.size(); ++i) { - this->values_[i] = record_set.get(i).row_id; + this->values_[i] = record_set.get_row_id(i); } return true; } @@ -227,7 +225,7 @@ class ScoreNode : public Node<Float> { return false; } for (Int i = 0; i < record_set.size(); ++i) { - this->values_[i] = record_set.get(i).score; + this->values_[i] = record_set.get_score(i); } return true; } @@ -252,7 +250,7 @@ class ColumnNode : public Node<T> { return false; } for (Int i = 0; i < record_set.size(); ++i) { - this->values_[i] = column_->get(record_set.get(i).row_id); + this->values_[i] = column_->get(record_set.get_row_id(i)); } return true; } @@ -560,7 +558,7 @@ bool LogicalOrNode::filter(Error *error, RecordSet *record_set) { Int left_count = 0; Int right_count = 0; for (Int i = 0; i < record_set->size(); ++i) { - if (record_set->get(i).row_id == left_record_set_.get(left_count).row_id) { + if (record_set->get_row_id(i) == left_record_set_.get_row_id((left_count))) { ++left_count; } else { right_record_set_.set(right_count, record_set->get(i)); -------------- next part -------------- HTML����������������������������... 下載