Kouhei Sutou
null+****@clear*****
Mon Jan 19 16:39:29 JST 2015
Kouhei Sutou 2015-01-19 16:39:29 +0900 (Mon, 19 Jan 2015) New Revision: 33cfb7cd305929d0d2c60bf6426286402fb20bd4 https://github.com/groonga/groonga/commit/33cfb7cd305929d0d2c60bf6426286402fb20bd4 Message: Move grn_rset_* related code to grn_rset.h Added files: lib/grn_rset.h Modified files: lib/grn_db.h lib/sources.am Modified: lib/grn_db.h (+1 -34) =================================================================== --- lib/grn_db.h 2015-01-19 16:27:18 +0900 (3b38691) +++ lib/grn_db.h 2015-01-19 16:39:29 +0900 (a585612) @@ -20,6 +20,7 @@ #include "grn.h" #include "grn_ctx.h" #include "grn_store.h" +#include "grn_rset.h" #include <groonga/command.h> #include <groonga/token_filter.h> @@ -33,40 +34,6 @@ extern "C" { #define GRN_N_RESERVED_TYPES 256 -typedef struct { - int score; - int n_subrecs; - int subrecs[1]; -} grn_rset_recinfo; - -typedef struct { - grn_id rid; - uint32_t sid; - uint32_t pos; -} grn_rset_posinfo; - -#define GRN_RSET_UTIL_BIT (0x80000000) - -#define GRN_RSET_N_SUBRECS_SIZE (sizeof(int)) -#define GRN_RSET_MAX_SIZE (sizeof(int64_t)) -#define GRN_RSET_MIN_SIZE (sizeof(int64_t)) -#define GRN_RSET_SUM_SIZE (sizeof(int64_t)) -#define GRN_RSET_AVG_SIZE (sizeof(double)) - -#define GRN_RSET_SCORE_SIZE (sizeof(int)) - -#define GRN_RSET_N_SUBRECS(ri) ((ri)->n_subrecs & ~GRN_RSET_UTIL_BIT) - -#define GRN_RSET_SUBREC_SIZE(subrec_size) \ - (GRN_RSET_SCORE_SIZE + subrec_size) -#define GRN_RSET_SUBRECS_CMP(a,b,dir) (((a) - (b))*(dir)) -#define GRN_RSET_SUBRECS_NTH(subrecs,size,n) \ - ((int *)((byte *)subrecs + n * GRN_RSET_SUBREC_SIZE(size))) -#define GRN_RSET_SUBRECS_COPY(subrecs,size,n,src) \ - (memcpy(GRN_RSET_SUBRECS_NTH(subrecs, size, n), src, GRN_RSET_SUBREC_SIZE(size))) -#define GRN_RSET_SUBRECS_SIZE(subrec_size,n) \ - (GRN_RSET_SUBREC_SIZE(subrec_size) * n) - #define GRN_JSON_LOAD_OPEN_BRACKET 0x40000000 #define GRN_JSON_LOAD_OPEN_BRACE 0x40000001 Added: lib/grn_rset.h (+65 -0) 100644 =================================================================== --- /dev/null +++ lib/grn_rset.h 2015-01-19 16:39:29 +0900 (969407c) @@ -0,0 +1,65 @@ +/* -*- c-basic-offset: 2 -*- */ +/* Copyright(C) 2009-2015 Brazil + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GRN_RSET_H +#define GRN_RSET_H + +#include "grn.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int score; + int n_subrecs; + int subrecs[1]; +} grn_rset_recinfo; + +typedef struct { + grn_id rid; + uint32_t sid; + uint32_t pos; +} grn_rset_posinfo; + +#define GRN_RSET_UTIL_BIT (0x80000000) + +#define GRN_RSET_N_SUBRECS_SIZE (sizeof(int)) +#define GRN_RSET_MAX_SIZE (sizeof(int64_t)) +#define GRN_RSET_MIN_SIZE (sizeof(int64_t)) +#define GRN_RSET_SUM_SIZE (sizeof(int64_t)) +#define GRN_RSET_AVG_SIZE (sizeof(double)) + +#define GRN_RSET_SCORE_SIZE (sizeof(int)) + +#define GRN_RSET_N_SUBRECS(ri) ((ri)->n_subrecs & ~GRN_RSET_UTIL_BIT) + +#define GRN_RSET_SUBREC_SIZE(subrec_size) \ + (GRN_RSET_SCORE_SIZE + subrec_size) +#define GRN_RSET_SUBRECS_CMP(a,b,dir) (((a) - (b))*(dir)) +#define GRN_RSET_SUBRECS_NTH(subrecs,size,n) \ + ((int *)((byte *)subrecs + n * GRN_RSET_SUBREC_SIZE(size))) +#define GRN_RSET_SUBRECS_COPY(subrecs,size,n,src) \ + (memcpy(GRN_RSET_SUBRECS_NTH(subrecs, size, n), src, GRN_RSET_SUBREC_SIZE(size))) +#define GRN_RSET_SUBRECS_SIZE(subrec_size,n) \ + (GRN_RSET_SUBREC_SIZE(subrec_size) * n) + + +#ifdef __cplusplus +} +#endif + +#endif /* GRN_RSET_H */ Modified: lib/sources.am (+1 -0) =================================================================== --- lib/sources.am 2015-01-19 16:27:18 +0900 (4fa37c9) +++ lib/sources.am 2015-01-19 16:39:29 +0900 (f49baed) @@ -40,6 +40,7 @@ libgroonga_la_SOURCES = \ grn_proc.h \ request_canceler.c \ grn_request_canceler.h \ + grn_rset.h \ snip.c \ grn_snip.h \ store.c \ -------------- next part -------------- HTML����������������������������...Download