[Groonga-commit] groonga/grnxx at 4c8c126 [master] Put merger operator type constants in the C global namespace. (#144)

Back to archive index

susumu.yata null+****@clear*****
Mon Feb 9 14:34:18 JST 2015


susumu.yata	2015-02-09 14:34:18 +0900 (Mon, 09 Feb 2015)

  New Revision: 4c8c1266a7fa248534e487fbcb2eb3d8386a238f
  https://github.com/groonga/grnxx/commit/4c8c1266a7fa248534e487fbcb2eb3d8386a238f

  Message:
    Put merger operator type constants in the C global namespace. (#144)

  Modified files:
    include/grnxx/constants.h
    include/grnxx/merger.hpp
    lib/grnxx/impl/merger.cpp
    test/test_merger.cpp
    test/test_pipeline.cpp

  Modified: include/grnxx/constants.h (+12 -0)
===================================================================
--- include/grnxx/constants.h    2015-02-09 13:50:25 +0900 (164ae27)
+++ include/grnxx/constants.h    2015-02-09 14:34:18 +0900 (62db278)
@@ -44,6 +44,18 @@ typedef enum {
   GRNXX_HASH_INDEX
 } grnxx_index_type;
 
+typedef enum {
+  GRNXX_MERGER_AND,             // For Logical.
+  GRNXX_MERGER_OR,              // For Logical.
+  GRNXX_MERGER_XOR,             // For Logical.
+  GRNXX_MERGER_PLUS,            // For Score.
+  GRNXX_MERGER_MINUS,           // For Logical, Score.
+  GRNXX_MERGER_MULTIPLICATION,  // For Score.
+  GRNXX_MERGER_LEFT,            // For Logical, Score.
+  GRNXX_MERGER_RIGHT,           // For Logical, Score.
+  GRNXX_MERGER_ZERO             // For Score.
+} grnxx_merger_operator_type;
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif  // __cplusplus

  Modified: include/grnxx/merger.hpp (+5 -34)
===================================================================
--- include/grnxx/merger.hpp    2015-02-09 13:50:25 +0900 (6dc7e39)
+++ include/grnxx/merger.hpp    2015-02-09 14:34:18 +0900 (7319620)
@@ -5,42 +5,13 @@
 #include <memory>
 
 #include "grnxx/array.hpp"
+#include "grnxx/constants.h"
 #include "grnxx/data_types.hpp"
 
 namespace grnxx {
 
-enum MergerLogicalOperatorType {
-  // Keep records included in both the first input stream and the second input
-  // stream.
-  MERGER_LOGICAL_AND,
-  // Keep records included in the first input stream and/or the second input
-  // stream.
-  MERGER_LOGICAL_OR,
-  // Keep records included in only one of the input streams.
-  MERGER_LOGICAL_XOR,
-  // Keep records included in the first input stream and not included in the
-  // second input stream.
-  MERGER_LOGICAL_MINUS,
-  // Keep records included in the first input stream.
-  MERGER_LOGICAL_LEFT,
-  // Keep records included in the second input stream.
-  MERGER_LOGICAL_RIGHT
-};
-
-enum MergerScoreOperatorType {
-  // Add the first input score and the second input score.
-  MERGER_SCORE_PLUS,
-  // Subtract the second input score from the first input score.
-  MERGER_SCORE_MINUS,
-  // Multiply the first input score by the second input score.
-  MERGER_SCORE_MULTIPLICATION,
-  // Ignores the second input score.
-  MERGER_SCORE_LEFT,
-  // Ignores the first input score.
-  MERGER_SCORE_RIGHT,
-  // All zeros.
-  MERGER_SCORE_ZERO
-};
+using MergerLogicalOperatorType = grnxx_merger_operator_type;
+using MergerScoreOperatorType = grnxx_merger_operator_type;
 
 struct MergerOptions {
   // How to merge records.
@@ -55,8 +26,8 @@ struct MergerOptions {
   size_t limit;
 
   MergerOptions()
-      : logical_operator_type(MERGER_LOGICAL_AND),
-        score_operator_type(MERGER_SCORE_PLUS),
+      : logical_operator_type(GRNXX_MERGER_AND),
+        score_operator_type(GRNXX_MERGER_PLUS),
         missing_score(0.0),
         offset(0),
         limit(std::numeric_limits<size_t>::max()) {}

  Modified: lib/grnxx/impl/merger.cpp (+114 -78)
===================================================================
--- lib/grnxx/impl/merger.cpp    2015-02-09 13:50:25 +0900 (15048c2)
+++ lib/grnxx/impl/merger.cpp    2015-02-09 14:34:18 +0900 (e3c7ae2)
@@ -45,11 +45,11 @@ void AndMerger::finish() {
       Record record;
       record.row_id = Int(it->first);
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = (*stream_records)[i].score + it->second;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score - it->second;
           } else {
@@ -57,11 +57,11 @@ void AndMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = (*stream_records)[i].score * it->second;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score;
           } else {
@@ -69,7 +69,7 @@ void AndMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           if (stream_is_1) {
             record.score = it->second;
           } else {
@@ -77,10 +77,13 @@ void AndMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
       output_records_->push_back(record);
     }
@@ -138,11 +141,11 @@ void OrMerger::finish() {
     auto it = filter.find((*stream_records)[i].row_id.raw());
     if (it == filter.end()) {
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = (*stream_records)[i].score + missing_score_;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score - missing_score_;
           } else {
@@ -150,11 +153,11 @@ void OrMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = (*stream_records)[i].score * missing_score_;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score;
           } else {
@@ -162,7 +165,7 @@ void OrMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           if (stream_is_1) {
             record.score = missing_score_;
           } else {
@@ -170,18 +173,21 @@ void OrMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
     } else {
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = it->second + (*stream_records)[i].score;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score - it->second;
           } else {
@@ -189,11 +195,11 @@ void OrMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = it->second * (*stream_records)[i].score;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score;
           } else {
@@ -201,7 +207,7 @@ void OrMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           if (!stream_is_1) {
             record.score = (*stream_records)[i].score;
           } else {
@@ -209,10 +215,13 @@ void OrMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
       filter.erase(it);
     }
@@ -221,11 +230,11 @@ void OrMerger::finish() {
 
   for (auto it : filter) {
     switch (score_operator_type_) {
-      case MERGER_SCORE_PLUS: {
+      case GRNXX_MERGER_PLUS: {
         it.second += missing_score_;
         break;
       }
-      case MERGER_SCORE_MINUS: {
+      case GRNXX_MERGER_MINUS: {
         if (stream_is_1) {
           it.second = missing_score_ - it.second;
         } else {
@@ -233,26 +242,29 @@ void OrMerger::finish() {
         }
         break;
       }
-      case MERGER_SCORE_MULTIPLICATION: {
+      case GRNXX_MERGER_MULTIPLICATION: {
         it.second *= missing_score_;
         break;
       }
-      case MERGER_SCORE_LEFT: {
+      case GRNXX_MERGER_LEFT: {
         if (stream_is_1) {
           it.second = missing_score_;
         }
         break;
       }
-      case MERGER_SCORE_RIGHT: {
+      case GRNXX_MERGER_RIGHT: {
         if (!stream_is_1) {
           it.second = missing_score_;
         }
         break;
       }
-      case MERGER_SCORE_ZERO: {
+      case GRNXX_MERGER_ZERO: {
         it.second = Float(0.0);
         break;
       }
+      default: {
+        throw "Invalid operator type";  // TODO
+      }
     }
     output_records_->push_back(Record(Int(it.first), it.second));
   }
@@ -309,11 +321,11 @@ void XorMerger::finish() {
       Record record;
       record.row_id = (*stream_records)[i].row_id;
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = (*stream_records)[i].score + missing_score_;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score - missing_score_;
           } else {
@@ -321,11 +333,11 @@ void XorMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = (*stream_records)[i].score * missing_score_;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           if (stream_is_1) {
             record.score = (*stream_records)[i].score;
           } else {
@@ -333,7 +345,7 @@ void XorMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           if (stream_is_1) {
             record.score = missing_score_;
           } else {
@@ -341,10 +353,13 @@ void XorMerger::finish() {
           }
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
       output_records_->push_back(record);
     }
@@ -352,11 +367,11 @@ void XorMerger::finish() {
 
   for (auto it : filter) {
     switch (score_operator_type_) {
-      case MERGER_SCORE_PLUS: {
+      case GRNXX_MERGER_PLUS: {
         it.second += missing_score_;
         break;
       }
-      case MERGER_SCORE_MINUS: {
+      case GRNXX_MERGER_MINUS: {
         if (stream_is_1) {
           it.second = missing_score_ - it.second;
         } else {
@@ -364,26 +379,29 @@ void XorMerger::finish() {
         }
         break;
       }
-      case MERGER_SCORE_MULTIPLICATION: {
+      case GRNXX_MERGER_MULTIPLICATION: {
         it.second *= missing_score_;
         break;
       }
-      case MERGER_SCORE_LEFT: {
+      case GRNXX_MERGER_LEFT: {
         if (stream_is_1) {
           it.second = missing_score_;
         }
         break;
       }
-      case MERGER_SCORE_RIGHT: {
+      case GRNXX_MERGER_RIGHT: {
         if (!stream_is_1) {
           it.second = missing_score_;
         }
         break;
       }
-      case MERGER_SCORE_ZERO: {
+      case GRNXX_MERGER_ZERO: {
         it.second = Float(0.0);
         break;
       }
+      default: {
+        throw "Invalid operator type";  // TODO
+      }
     }
     output_records_->push_back(Record(Int(it.first), it.second));
   }
@@ -440,29 +458,32 @@ void MinusMerger::finish() {
       }
       Record record = stream_records->get(i);
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score += missing_score_;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           record.score -= missing_score_;
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score *= missing_score_;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           record.score = missing_score_;
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
       output_records_->push_back(record);
     }
@@ -477,30 +498,33 @@ void MinusMerger::finish() {
       Record record;
       record.row_id = Int(it.first);
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = it.second + missing_score_;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           record.score = it.second - missing_score_;
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = it.second * missing_score_;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           record.score = it.second;
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           record.score = missing_score_;
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
       output_records_->push_back(record);
     }
@@ -544,55 +568,61 @@ void LeftMerger::finish() {
     auto it = filter.find(record.row_id.raw());
     if (it != filter.end()) {
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score += it->second;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           record.score -= it->second;
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score *= it->second;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           record.score = it->second;
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
     } else {
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score += missing_score_;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           record.score -= missing_score_;
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score *= missing_score_;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           record.score = missing_score_;
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
     }
     output_records_->push_back(record);
@@ -637,57 +667,63 @@ void RightMerger::finish() {
     auto it = filter.find(record.row_id.raw());
     if (it != filter.end()) {
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = it->second + (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           record.score = it->second - (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = it->second * (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           record.score = it->second;
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           record.score = (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
     } else {
       switch (score_operator_type_) {
-        case MERGER_SCORE_PLUS: {
+        case GRNXX_MERGER_PLUS: {
           record.score = missing_score_ + (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_MINUS: {
+        case GRNXX_MERGER_MINUS: {
           record.score = missing_score_ - (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_MULTIPLICATION: {
+        case GRNXX_MERGER_MULTIPLICATION: {
           record.score = missing_score_ * (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_LEFT: {
+        case GRNXX_MERGER_LEFT: {
           record.score = missing_score_;
           break;
         }
-        case MERGER_SCORE_RIGHT: {
+        case GRNXX_MERGER_RIGHT: {
           record.score = (*input_records_2_)[i].score;
           break;
         }
-        case MERGER_SCORE_ZERO: {
+        case GRNXX_MERGER_ZERO: {
           record.score = Float(0.0);
           break;
         }
+        default: {
+          throw "Invalid operator type";  // TODO
+        }
       }
     }
     output_records_->push_back(record);
@@ -743,22 +779,22 @@ void Merger::merge(Array<Record> *input_records_1,
 
 Merger *Merger::create(const MergerOptions &options) try {
   switch (options.logical_operator_type) {
-    case MERGER_LOGICAL_AND: {
+    case GRNXX_MERGER_AND: {
       return new AndMerger(options);
     }
-    case MERGER_LOGICAL_OR: {
+    case GRNXX_MERGER_OR: {
       return new OrMerger(options);
     }
-    case MERGER_LOGICAL_XOR: {
+    case GRNXX_MERGER_XOR: {
       return new XorMerger(options);
     }
-    case MERGER_LOGICAL_MINUS: {
+    case GRNXX_MERGER_MINUS: {
       return new MinusMerger(options);
     }
-    case MERGER_LOGICAL_LEFT: {
+    case GRNXX_MERGER_LEFT: {
       return new LeftMerger(options);
     }
-    case MERGER_LOGICAL_RIGHT: {
+    case GRNXX_MERGER_RIGHT: {
       return new RightMerger(options);
     }
     default: {

  Modified: test/test_merger.cpp (+42 -42)
===================================================================
--- test/test_merger.cpp    2015-02-09 13:50:25 +0900 (5423726)
+++ test/test_merger.cpp    2015-02-09 14:34:18 +0900 (8449cab)
@@ -164,11 +164,11 @@ void test_and() {
 
   // Set options.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_AND;
+  options.logical_operator_type = GRNXX_MERGER_AND;
   options.missing_score = MISSING_SCORE;
 
   // Merge records (PLUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   auto output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -186,7 +186,7 @@ void test_and() {
   assert(count == output.size());
 
   // Merge records (MINUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_MINUS;
+  options.score_operator_type = GRNXX_MERGER_MINUS;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -196,7 +196,7 @@ void test_and() {
   }
 
   // Merge records (MULTIPLICATION).
-  options.score_operator_type = grnxx::MERGER_SCORE_MULTIPLICATION;
+  options.score_operator_type = GRNXX_MERGER_MULTIPLICATION;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -206,7 +206,7 @@ void test_and() {
   }
 
   // Merge records (LEFT).
-  options.score_operator_type = grnxx::MERGER_SCORE_LEFT;
+  options.score_operator_type = GRNXX_MERGER_LEFT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -216,7 +216,7 @@ void test_and() {
   }
 
   // Merge records (RIGHT).
-  options.score_operator_type = grnxx::MERGER_SCORE_RIGHT;
+  options.score_operator_type = GRNXX_MERGER_RIGHT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -226,7 +226,7 @@ void test_and() {
   }
 
   // Merge records (ZERO).
-  options.score_operator_type = grnxx::MERGER_SCORE_ZERO;
+  options.score_operator_type = GRNXX_MERGER_ZERO;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -243,11 +243,11 @@ void test_or() {
 
   // Set options.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_OR;
+  options.logical_operator_type = GRNXX_MERGER_OR;
   options.missing_score = MISSING_SCORE;
 
   // Merge records (PLUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   auto output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -265,7 +265,7 @@ void test_or() {
   assert(count == output.size());
 
   // Merge records (MINUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_MINUS;
+  options.score_operator_type = GRNXX_MERGER_MINUS;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -275,7 +275,7 @@ void test_or() {
   }
 
   // Merge records (MULTIPLICATION).
-  options.score_operator_type = grnxx::MERGER_SCORE_MULTIPLICATION;
+  options.score_operator_type = GRNXX_MERGER_MULTIPLICATION;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -285,7 +285,7 @@ void test_or() {
   }
 
   // Merge records (LEFT).
-  options.score_operator_type = grnxx::MERGER_SCORE_LEFT;
+  options.score_operator_type = GRNXX_MERGER_LEFT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -295,7 +295,7 @@ void test_or() {
   }
 
   // Merge records (RIGHT).
-  options.score_operator_type = grnxx::MERGER_SCORE_RIGHT;
+  options.score_operator_type = GRNXX_MERGER_RIGHT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -305,7 +305,7 @@ void test_or() {
   }
 
   // Merge records (ZERO).
-  options.score_operator_type = grnxx::MERGER_SCORE_ZERO;
+  options.score_operator_type = GRNXX_MERGER_ZERO;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -322,11 +322,11 @@ void test_xor() {
 
   // Set options.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_XOR;
+  options.logical_operator_type = GRNXX_MERGER_XOR;
   options.missing_score = MISSING_SCORE;
 
   // Merge records (PLUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   auto output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -343,7 +343,7 @@ void test_xor() {
   assert(count == output.size());
 
   // Merge records (MINUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_MINUS;
+  options.score_operator_type = GRNXX_MERGER_MINUS;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -353,7 +353,7 @@ void test_xor() {
   }
 
   // Merge records (MULTIPLICATION).
-  options.score_operator_type = grnxx::MERGER_SCORE_MULTIPLICATION;
+  options.score_operator_type = GRNXX_MERGER_MULTIPLICATION;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -363,7 +363,7 @@ void test_xor() {
   }
 
   // Merge records (LEFT).
-  options.score_operator_type = grnxx::MERGER_SCORE_LEFT;
+  options.score_operator_type = GRNXX_MERGER_LEFT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -373,7 +373,7 @@ void test_xor() {
   }
 
   // Merge records (RIGHT).
-  options.score_operator_type = grnxx::MERGER_SCORE_RIGHT;
+  options.score_operator_type = GRNXX_MERGER_RIGHT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -383,7 +383,7 @@ void test_xor() {
   }
 
   // Merge records (ZERO).
-  options.score_operator_type = grnxx::MERGER_SCORE_ZERO;
+  options.score_operator_type = GRNXX_MERGER_ZERO;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -400,11 +400,11 @@ void test_minus() {
 
   // Set options.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_MINUS;
+  options.logical_operator_type = GRNXX_MERGER_MINUS;
   options.missing_score = MISSING_SCORE;
 
   // Merge records (PLUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   auto output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -421,7 +421,7 @@ void test_minus() {
   assert(count == output.size());
 
   // Merge records (MINUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_MINUS;
+  options.score_operator_type = GRNXX_MERGER_MINUS;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -431,7 +431,7 @@ void test_minus() {
   }
 
   // Merge records (MULTIPLICATION).
-  options.score_operator_type = grnxx::MERGER_SCORE_MULTIPLICATION;
+  options.score_operator_type = GRNXX_MERGER_MULTIPLICATION;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -441,7 +441,7 @@ void test_minus() {
   }
 
   // Merge records (LEFT).
-  options.score_operator_type = grnxx::MERGER_SCORE_LEFT;
+  options.score_operator_type = GRNXX_MERGER_LEFT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -451,7 +451,7 @@ void test_minus() {
   }
 
   // Merge records (RIGHT).
-  options.score_operator_type = grnxx::MERGER_SCORE_RIGHT;
+  options.score_operator_type = GRNXX_MERGER_RIGHT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -461,7 +461,7 @@ void test_minus() {
   }
 
   // Merge records (ZERO).
-  options.score_operator_type = grnxx::MERGER_SCORE_ZERO;
+  options.score_operator_type = GRNXX_MERGER_ZERO;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -478,11 +478,11 @@ void test_left() {
 
   // Set options.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_LEFT;
+  options.logical_operator_type = GRNXX_MERGER_LEFT;
   options.missing_score = MISSING_SCORE;
 
   // Merge records (PLUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   auto output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -498,7 +498,7 @@ void test_left() {
   assert(count == output.size());
 
   // Merge records (MINUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_MINUS;
+  options.score_operator_type = GRNXX_MERGER_MINUS;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -507,7 +507,7 @@ void test_left() {
   }
 
   // Merge records (MULTIPLICATION).
-  options.score_operator_type = grnxx::MERGER_SCORE_MULTIPLICATION;
+  options.score_operator_type = GRNXX_MERGER_MULTIPLICATION;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -516,7 +516,7 @@ void test_left() {
   }
 
   // Merge records (LEFT).
-  options.score_operator_type = grnxx::MERGER_SCORE_LEFT;
+  options.score_operator_type = GRNXX_MERGER_LEFT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -525,7 +525,7 @@ void test_left() {
   }
 
   // Merge records (RIGHT).
-  options.score_operator_type = grnxx::MERGER_SCORE_RIGHT;
+  options.score_operator_type = GRNXX_MERGER_RIGHT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -534,7 +534,7 @@ void test_left() {
   }
 
   // Merge records (ZERO).
-  options.score_operator_type = grnxx::MERGER_SCORE_ZERO;
+  options.score_operator_type = GRNXX_MERGER_ZERO;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -550,11 +550,11 @@ void test_right() {
 
   // Set options.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_RIGHT;
+  options.logical_operator_type = GRNXX_MERGER_RIGHT;
   options.missing_score = MISSING_SCORE;
 
   // Merge records (PLUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   auto output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -570,7 +570,7 @@ void test_right() {
   assert(count == output.size());
 
   // Merge records (MINUS).
-  options.score_operator_type = grnxx::MERGER_SCORE_MINUS;
+  options.score_operator_type = GRNXX_MERGER_MINUS;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -579,7 +579,7 @@ void test_right() {
   }
 
   // Merge records (MULTIPLICATION).
-  options.score_operator_type = grnxx::MERGER_SCORE_MULTIPLICATION;
+  options.score_operator_type = GRNXX_MERGER_MULTIPLICATION;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -588,7 +588,7 @@ void test_right() {
   }
 
   // Merge records (LEFT).
-  options.score_operator_type = grnxx::MERGER_SCORE_LEFT;
+  options.score_operator_type = GRNXX_MERGER_LEFT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -597,7 +597,7 @@ void test_right() {
   }
 
   // Merge records (RIGHT).
-  options.score_operator_type = grnxx::MERGER_SCORE_RIGHT;
+  options.score_operator_type = GRNXX_MERGER_RIGHT;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();
@@ -606,7 +606,7 @@ void test_right() {
   }
 
   // Merge records (ZERO).
-  options.score_operator_type = grnxx::MERGER_SCORE_ZERO;
+  options.score_operator_type = GRNXX_MERGER_ZERO;
   output = merge_records(input_1, input_2, options);
   for (size_t i = 0; i < output.size(); ++i) {
     size_t row_id = output[i].row_id.raw();

  Modified: test/test_pipeline.cpp (+2 -2)
===================================================================
--- test/test_pipeline.cpp    2015-02-09 13:50:25 +0900 (3930902)
+++ test/test_pipeline.cpp    2015-02-09 14:34:18 +0900 (dbc1465)
@@ -348,8 +348,8 @@ void test_merger() {
 
   // Create a merger.
   grnxx::MergerOptions options;
-  options.logical_operator_type = grnxx::MERGER_LOGICAL_AND;
-  options.score_operator_type = grnxx::MERGER_SCORE_PLUS;
+  options.logical_operator_type = GRNXX_MERGER_AND;
+  options.score_operator_type = GRNXX_MERGER_PLUS;
   pipeline_builder->push_merger(options);
 
   // Complete a pipeline.
-------------- next part --------------
HTML����������������������������...
Download 



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