[Groonga-commit] groonga/grnxx at 14793e2 [master] Add an argument "offset" to Expression::adjust(). (#31)

Back to archive index

susumu.yata null+****@clear*****
Fri Aug 1 15:34:25 JST 2014


susumu.yata	2014-08-01 15:34:25 +0900 (Fri, 01 Aug 2014)

  New Revision: 14793e2bb9e30fb1e4f39cbd543e2c7f1f1401a3
  https://github.com/groonga/grnxx/commit/14793e2bb9e30fb1e4f39cbd543e2c7f1f1401a3

  Message:
    Add an argument "offset" to Expression::adjust(). (#31)

  Modified files:
    include/grnxx/expression.hpp
    lib/grnxx/expression.cpp

  Modified: include/grnxx/expression.hpp (+2 -1)
===================================================================
--- include/grnxx/expression.hpp    2014-08-01 13:49:31 +0900 (15a437b)
+++ include/grnxx/expression.hpp    2014-08-01 15:34:25 +0900 (d484159)
@@ -95,11 +95,12 @@ class Expression {
   //
   // Evaluates the expression for the given record set and replaces their
   // scores with the evaluation results.
+  // The first "offset" records are not modified.
   //
   // Returns true on success.
   // On failure, returns false and stores error information into "*error" if
   // "error" != nullptr.
-  bool adjust(Error *error, RecordSet *record_set);
+  bool adjust(Error *error, RecordSet *record_set, Int offset = 0);
 
   // Evaluate the expression.
   //

  Modified: lib/grnxx/expression.cpp (+9 -9)
===================================================================
--- lib/grnxx/expression.cpp    2014-08-01 13:49:31 +0900 (1241b81)
+++ lib/grnxx/expression.cpp    2014-08-01 15:34:25 +0900 (3dfad1e)
@@ -49,7 +49,7 @@ class ExpressionNode {
   // Returns true on success.
   // On failure, returns false and stores error information into "*error" if
   // "error" != nullptr.
-  virtual bool adjust(Error *error, RecordSet *record_set) = 0;
+  virtual bool adjust(Error *error, RecordSubset record_set) = 0;
 
   // Evaluate the expression subtree.
   //
@@ -74,7 +74,7 @@ class Node : public ExpressionNode {
   }
 
   virtual bool filter(Error *error, RecordSet *record_set);
-  virtual bool adjust(Error *error, RecordSet *record_set);
+  virtual bool adjust(Error *error, RecordSubset record_set);
 
   virtual bool evaluate(Error *error, const RecordSubset &record_set) = 0;
 
@@ -109,19 +109,19 @@ bool Node<Bool>::filter(Error *error, RecordSet *record_set) {
 }
 
 template <typename T>
-bool Node<T>::adjust(Error *error, RecordSet *record_set) {
+bool Node<T>::adjust(Error *error, RecordSubset record_set) {
   // Only Node<Float> supports filter().
   GRNXX_ERROR_SET(error, INVALID_OPERATION, "Invalid operation");
   return false;
 }
 
 template <>
-bool Node<Float>::adjust(Error *error, RecordSet *record_set) {
-  if (!evaluate(error, *record_set)) {
+bool Node<Float>::adjust(Error *error, RecordSubset record_set) {
+  if (!evaluate(error, record_set)) {
     return false;
   }
-  for (Int i = 0; i < record_set->size(); ++i) {
-    record_set->set_score(i, values_[i]);
+  for (Int i = 0; i < record_set.size(); ++i) {
+    record_set.set_score(i, values_[i]);
   }
   return true;
 }
@@ -715,8 +715,8 @@ bool Expression::filter(Error *error, RecordSet *record_set) {
   return root_->filter(error, record_set);
 }
 
-bool Expression::adjust(Error *error, RecordSet *record_set) {
-  return root_->adjust(error, record_set);
+bool Expression::adjust(Error *error, RecordSet *record_set, Int offset) {
+  return root_->adjust(error, record_set->subset(offset));
 }
 
 template <typename T>
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index