[Groonga-commit] groonga/groonga at bc5f681 [master] Invert subrec size and GRN_RSET_SCORES_SIZE

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 25 22:16:31 JST 2014


Kouhei Sutou	2014-06-25 22:16:31 +0900 (Wed, 25 Jun 2014)

  New Revision: bc5f6814aadaa61be297774553f5a9952351e77e
  https://github.com/groonga/groonga/commit/bc5f6814aadaa61be297774553f5a9952351e77e

  Message:
    Invert subrec size and GRN_RSET_SCORES_SIZE
    
    Because score is stored before subrec:
    
        |-score1-|-subrec1-|-score2-|-subrec2-|...|

  Modified files:
    lib/db.c
    lib/db.h

  Modified: lib/db.c (+2 -2)
===================================================================
--- lib/db.c    2014-06-21 15:15:09 +0900 (d89a3c8)
+++ lib/db.c    2014-06-25 22:16:31 +0900 (0bc37b8)
@@ -1988,7 +1988,7 @@ subrecs_push(byte *subrecs, int size, int n_subrecs, int score, void *body, int
     GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
     n = n2;
   }
-  v = subrecs + n * (size + GRN_RSET_SCORE_SIZE);
+  v = subrecs + n * (GRN_RSET_SCORE_SIZE + size);
   *((int *)v) = score;
   memcpy(v + GRN_RSET_SCORE_SIZE, body, size);
 }
@@ -2022,7 +2022,7 @@ subrecs_replace_min(byte *subrecs, int size, int n_subrecs, int score, void *bod
       }
     }
   }
-  v = subrecs + n * (size + GRN_RSET_SCORE_SIZE);
+  v = subrecs + n * (GRN_RSET_SCORE_SIZE + size);
   memcpy(v, &score, GRN_RSET_SCORE_SIZE);
   memcpy(v + GRN_RSET_SCORE_SIZE, body, size);
 }

  Modified: lib/db.h (+2 -2)
===================================================================
--- lib/db.h    2014-06-21 15:15:09 +0900 (11e25ee)
+++ lib/db.h    2014-06-25 22:16:31 +0900 (1fb7ee5)
@@ -58,9 +58,9 @@ typedef struct {
 
 #define GRN_RSET_SUBRECS_CMP(a,b,dir) (((a) - (b))*(dir))
 #define GRN_RSET_SUBRECS_NTH(subrecs,size,n) \
-  ((int *)((byte *)subrecs + n * (size + GRN_RSET_SCORE_SIZE)))
+  ((int *)((byte *)subrecs + n * (GRN_RSET_SCORE_SIZE + size)))
 #define GRN_RSET_SUBRECS_COPY(subrecs,size,n,src) \
-  (memcpy(GRN_RSET_SUBRECS_NTH(subrecs, size, n), src, size + GRN_RSET_SCORE_SIZE))
+  (memcpy(GRN_RSET_SUBRECS_NTH(subrecs, size, n), src, GRN_RSET_SCORE_SIZE + size))
 
 #define GRN_JSON_LOAD_OPEN_BRACKET 0x40000000
 #define GRN_JSON_LOAD_OPEN_BRACE   0x40000001
-------------- next part --------------
HTML����������������������������...
Download 



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