[Groonga-commit] groonga/grnxx at ddf75d2 [master] Add an interface to push a merger. (#63)

Back to archive index

susumu.yata null+****@clear*****
Mon Sep 22 11:26:58 JST 2014


susumu.yata	2014-09-22 11:26:58 +0900 (Mon, 22 Sep 2014)

  New Revision: ddf75d2568b1a485d3899af1ffdef0a897f3d313
  https://github.com/groonga/grnxx/commit/ddf75d2568b1a485d3899af1ffdef0a897f3d313

  Message:
    Add an interface to push a merger. (#63)
    
    Implementations are not provided yet.

  Modified files:
    include/grnxx/pipeline.hpp
    include/grnxx/types/constants.hpp
    include/grnxx/types/options.hpp
    lib/grnxx/pipeline.cpp
    lib/grnxx/types.cpp

  Modified: include/grnxx/pipeline.hpp (+3 -2)
===================================================================
--- include/grnxx/pipeline.hpp    2014-09-22 11:22:12 +0900 (cd4223a)
+++ include/grnxx/pipeline.hpp    2014-09-22 11:26:58 +0900 (7000e56)
@@ -90,8 +90,9 @@ class PipelineBuilder {
   // "error" != nullptr.
   bool push_sorter(Error *error, unique_ptr<Sorter> &&sorter);
 
-  // TODO: Not supported yet.
-//  bool push_merger(Error *error, const MergerOptions &options);
+  // Push a merger.
+  bool push_merger(Error *error,
+                   const MergerOptions &options = MergerOptions());
 
   // Clear the internal stack.
   void clear();

  Modified: include/grnxx/types/constants.hpp (+35 -0)
===================================================================
--- include/grnxx/types/constants.hpp    2014-09-22 11:22:12 +0900 (43bed86)
+++ include/grnxx/types/constants.hpp    2014-09-22 11:26:58 +0900 (a512876)
@@ -58,6 +58,41 @@ enum OrderType {
   REVERSE_ORDER
 };
 
+// TODO: The following names should be improved.
+enum MergerType {
+  // Keep records included in both the first input stream and the second input
+  // stream.
+  AND_MERGER,
+  // Keep records included in the first input stream and/or the second input
+  // stream.
+  OR_MERGER,
+  // Keep records included in only one of the input streams.
+  XOR_MERGER,
+  // Keep records included in the first input stream and not included in the
+  // second input stream.
+  MINUS_MERGER,
+  // Keep records included in the first input stream.
+  LHS_MERGER,
+  // Keep records included in the second input stream.
+  RHS_MERGER
+};
+
+// TODO: The following names should be improved.
+enum MergerOperatorType {
+  // Add the first input score and the second input score.
+  PLUS_MERGER_OPERATOR,
+  // Subtract the second input score from the first input score.
+  MINUS_MERGER_OPERATOR,
+  // Multiply the first input score by the second input score.
+  MULTIPLICATION_MERGER_OPERATOR,
+  // Ignores the second input score.
+  LHS_MERGER_OPERATOR,
+  // Ignores the first input score.
+  RHS_MERGER_OPERATOR,
+  // All zeros.
+  ZERO_MERGER_OPERATOR
+};
+
 }  // namespace grnxx
 
 #endif  // GRNXX_TYPES_CONSTANTS_HPP

  Modified: include/grnxx/types/options.hpp (+10 -0)
===================================================================
--- include/grnxx/types/options.hpp    2014-09-22 11:22:12 +0900 (a42fd13)
+++ include/grnxx/types/options.hpp    2014-09-22 11:26:58 +0900 (e8d8db5)
@@ -56,6 +56,16 @@ struct SorterOptions {
   SorterOptions();
 };
 
+struct MergerOptions {
+  // How to merge row IDs.
+  MergerType type;
+
+  // How to merge scores.
+  MergerOperatorType operator_type;
+
+  MergerOptions();
+};
+
 struct PipelineOptions {
   PipelineOptions();
 };

  Modified: lib/grnxx/pipeline.cpp (+6 -0)
===================================================================
--- lib/grnxx/pipeline.cpp    2014-09-22 11:22:12 +0900 (f472b8b)
+++ lib/grnxx/pipeline.cpp    2014-09-22 11:26:58 +0900 (c627135)
@@ -282,6 +282,12 @@ bool PipelineBuilder::push_sorter(Error *error, unique_ptr<Sorter> &&sorter) {
   return true;
 }
 
+bool PipelineBuilder::push_merger(Error *error, const MergerOptions &options) {
+  // TODO
+  GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet");
+  return false;
+}
+
 void PipelineBuilder::clear() {
   stack_.clear();
 }

  Modified: lib/grnxx/types.cpp (+4 -0)
===================================================================
--- lib/grnxx/types.cpp    2014-09-22 11:22:12 +0900 (117d755)
+++ lib/grnxx/types.cpp    2014-09-22 11:26:58 +0900 (d617bd9)
@@ -60,6 +60,10 @@ SorterOptions::SorterOptions()
     : offset(0),
       limit(numeric_limits<Int>::max()) {}
 
+MergerOptions::MergerOptions()
+    : type(AND_MERGER),
+      operator_type(PLUS_MERGER_OPERATOR) {}
+
 PipelineOptions::PipelineOptions() {}
 
 SortOrder::SortOrder() : expression(), type(REGULAR_ORDER) {}
-------------- next part --------------
HTML����������������������������...
Descargar 



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