[Groonga-commit] groonga/grnxx at 1a00ef2 [master] Fix a bug that offset and limit don't work well in sorting records.

Back to archive index

susumu.yata null+****@clear*****
Tue Aug 5 17:56:11 JST 2014


susumu.yata	2014-08-05 17:56:11 +0900 (Tue, 05 Aug 2014)

  New Revision: 1a00ef25b8ab3fb658f9a285e74473833361fdbf
  https://github.com/groonga/grnxx/commit/1a00ef25b8ab3fb658f9a285e74473833361fdbf

  Message:
    Fix a bug that offset and limit don't work well in sorting records.

  Modified files:
    lib/grnxx/sorter.cpp

  Modified: lib/grnxx/sorter.cpp (+9 -2)
===================================================================
--- lib/grnxx/sorter.cpp    2014-08-05 17:44:40 +0900 (5da7812)
+++ lib/grnxx/sorter.cpp    2014-08-05 17:56:11 +0900 (cfe2c30)
@@ -540,12 +540,19 @@ bool Sorter::finish(Error *error) {
   if (limit_ <= (record_set_->size() - offset_)) {
     end = offset_ + limit_;
   } else {
-    end = record_set_->size() - offset_;
+    end = record_set_->size();
   }
   if (record_set_->size() <= 1) {
     return true;
   }
-  return head_->sort(error, record_set_->subset(), begin, end);
+  if (!head_->sort(error, record_set_->subset(), begin, end)) {
+    return false;
+  }
+  for (Int i = begin, j = 0; i < end; ++i, ++j) {
+    record_set_->set(j, record_set_->get(i));
+  }
+  record_set_->resize(nullptr, end - begin);
+  return true;
 }
 
 bool Sorter::sort(Error *error, RecordSet *record_set) {
-------------- next part --------------
HTML����������������������������...
Télécharger 



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