[Groonga-commit] groonga/groonga-query-log at 9b8e890 [master] response-comparer: support specific output columns case

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jun 12 17:42:51 JST 2018


Kouhei Sutou	2018-06-12 17:42:51 +0900 (Tue, 12 Jun 2018)

  New Revision: 9b8e890c44368feb515d1f996c6f90e194d47c83
  https://github.com/groonga/groonga-query-log/commit/9b8e890c44368feb515d1f996c6f90e194d47c83

  Message:
    response-comparer: support specific output columns case

  Modified files:
    lib/groonga-query-log/response-comparer.rb
    test/test-response-comparer.rb

  Modified: lib/groonga-query-log/response-comparer.rb (+30 -1)
===================================================================
--- lib/groonga-query-log/response-comparer.rb    2018-06-12 17:37:58 +0900 (ccaf1c7)
+++ lib/groonga-query-log/response-comparer.rb    2018-06-12 17:42:51 +0900 (52b3f7b)
@@ -65,7 +65,7 @@ module GroongaQueryLog
         elsif have_unary_minus_output_column?
           same_records_unary_minus_output_column?
         else
-          same_response?
+          same_records?
         end
       else
         same_size_response?
@@ -207,6 +207,35 @@ module GroongaQueryLog
       true
     end
 
+    def same_records?
+      records_result1 =****@respo*****[0] || []
+      records_result2 =****@respo*****[0] || []
+      return false if records_result1.size != records_result2.size
+
+      n_hits1 = records_result1[0]
+      n_hits2 = records_result2[0]
+      return false if n_hits1 != n_hits2
+
+      columns1 = records_result1[1]
+      columns2 = records_result2[1]
+      return false if columns1 != columns2
+
+      records1 = records_result1[2..-1]
+      records2 = records_result2[2..-1]
+      records1.each_with_index do |record1, record_index|
+        record2 = records2[record_index]
+        columns1.each_with_index do |column1, column_index|
+          value1 = record1[column_index]
+          value1 = normalize_value(value1, column1)
+          value2 = record2[column_index]
+          value2 = normalize_value(value2, column1)
+          return false if value1 != value2
+        end
+      end
+
+      true
+    end
+
     def make_column_to_index_map(columns)
       map = {}
       columns.each_with_index do |(name, _), i|

  Modified: test/test-response-comparer.rb (+9 -0)
===================================================================
--- test/test-response-comparer.rb    2018-06-12 17:37:58 +0900 (7b95b35)
+++ test/test-response-comparer.rb    2018-06-12 17:42:51 +0900 (4124339)
@@ -333,6 +333,15 @@ class ResponseComparerTest < Test::Unit::TestCase
           same?(response1, response2)
         end
       end
+
+      def test_specific_output_columns
+        @command["output_columns"] = "_id, latitude, longitude"
+        response1 = create_response(35.6562002690605,  139.763570507358)
+        response2 = create_response(35.65620026906051, 139.7635705073576)
+        assert do
+          same?(response1, response2)
+        end
+      end
     end
 
     class ErrorTest < self
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180612/d7ee3294/attachment-0001.htm 



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