[Groonga-commit] groonga/grnxx at 50a2453 [master] Add Sorter::table().

Back to archive index

susumu.yata null+****@clear*****
Tue Aug 19 10:21:06 JST 2014


susumu.yata	2014-08-19 10:21:06 +0900 (Tue, 19 Aug 2014)

  New Revision: 50a245367de35e9c4173df8ec2a198f07f95ce78
  https://github.com/groonga/grnxx/commit/50a245367de35e9c4173df8ec2a198f07f95ce78

  Message:
    Add Sorter::table().

  Modified files:
    include/grnxx/sorter.hpp
    lib/grnxx/sorter.cpp
    test/test_sorter.cpp

  Modified: include/grnxx/sorter.hpp (+6 -0)
===================================================================
--- include/grnxx/sorter.hpp    2014-08-18 18:09:26 +0900 (f6b7131)
+++ include/grnxx/sorter.hpp    2014-08-19 10:21:06 +0900 (1cf6acd)
@@ -21,6 +21,11 @@ class Sorter {
  public:
   ~Sorter();
 
+  // Return the associated table.
+  const Table *table() const {
+    return table_;
+  }
+
   // Create an object for sorting records.
   //
   // On success, returns a poitner to the sorter.
@@ -67,6 +72,7 @@ class Sorter {
   bool sort(Error *error, Array<Record> *records);
 
  private:
+  const Table *table_;
   unique_ptr<SorterNode> head_;
   Array<Record> *records_;
   Int offset_;

  Modified: lib/grnxx/sorter.cpp (+3 -1)
===================================================================
--- lib/grnxx/sorter.cpp    2014-08-18 18:09:26 +0900 (a185fd4)
+++ lib/grnxx/sorter.cpp    2014-08-19 10:21:06 +0900 (0dc8d86)
@@ -531,6 +531,7 @@ unique_ptr<Sorter> Sorter::create(
     GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed");
     return nullptr;
   }
+  sorter->table_ = table;
   for (Int i = orders.size() - 1; i >= 0; --i) {
     unique_ptr<SorterNode> node(
         SorterNode::create(error, std::move(orders[i])));
@@ -590,7 +591,8 @@ bool Sorter::sort(Error *error, Array<Record> *records) {
 }
 
 Sorter::Sorter()
-    : head_(),
+    : table_(nullptr),
+      head_(),
       records_(nullptr),
       offset_(0),
       limit_(0) {}

  Modified: test/test_sorter.cpp (+1 -0)
===================================================================
--- test/test_sorter.cpp    2014-08-18 18:09:26 +0900 (b23c744)
+++ test/test_sorter.cpp    2014-08-19 10:21:06 +0900 (38d10ec)
@@ -88,6 +88,7 @@ void test_sorter() {
 
   auto sorter = grnxx::Sorter::create(&error, std::move(orders));
   assert(sorter);
+  assert(sorter->table() == table);
 
   assert(sorter->sort(&error, &records));
   assert(records.size() == static_cast<grnxx::Int>(int_values.size()));
-------------- next part --------------
HTML����������������������������...
Download 



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