Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ii.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2009-2012 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 #ifndef GRN_II_H
18 #define GRN_II_H
19 
20 /* "ii" is for inverted index */
21 
22 #ifndef GROONGA_IN_H
23 #include "groonga_in.h"
24 #endif /* GROONGA_IN_H */
25 
26 #ifndef GRN_HASH_H
27 #include "hash.h"
28 #endif /* GRN_HASH_H */
29 
30 #ifndef GRN_IO_H
31 #include "io.h"
32 #endif /* GRN_IO_H */
33 
34 #ifndef GRN_STORE_H
35 #include "store.h"
36 #endif /* GRN_STORE_H */
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 struct _grn_ii {
49  uint32_t n_elements;
51 };
52 
53 #define GRN_II_BGQSIZE 16
54 #define GRN_II_MAX_LSEG 0x10000
55 #define GRN_II_W_TOTAL_CHUNK 40
56 #define GRN_II_W_CHUNK 22
57 #define GRN_II_W_LEAST_CHUNK (GRN_II_W_TOTAL_CHUNK - 32)
58 #define GRN_II_MAX_CHUNK (1 << (GRN_II_W_TOTAL_CHUNK - GRN_II_W_CHUNK))
59 #define GRN_II_N_CHUNK_VARIATION (GRN_II_W_CHUNK - GRN_II_W_LEAST_CHUNK)
60 
61 struct grn_ii_header {
62  uint64_t total_chunk_size;
63  uint64_t bmax;
64  uint32_t flags;
65  uint32_t amax;
66  uint32_t smax;
67  uint32_t param1;
68  uint32_t param2;
69  uint32_t pnext;
70  uint32_t bgqhead;
71  uint32_t bgqtail;
73  uint32_t reserved[288];
79  uint8_t chunks[GRN_II_MAX_CHUNK >> 3];
80 };
81 
82 struct _grn_ii_pos {
83  struct _grn_ii_pos *next;
84  uint32_t pos;
85 };
86 
88  uint32_t rid;
89  uint32_t sid;
90  int32_t weight;
91  int32_t tf; /* number of postings successfully stored to index */
92  int32_t atf; /* actual number of postings */
93  int32_t offset;
94  struct _grn_ii_pos *pos;
95  struct _grn_ii_pos *tail;
96  /* grn_vgram_vnode *vnodes; */
97 };
98 
100 
101 GRN_API grn_ii *grn_ii_create(grn_ctx *ctx, const char *path, grn_obj *lexicon,
102  uint32_t flags);
103 GRN_API grn_ii *grn_ii_open(grn_ctx *ctx, const char *path, grn_obj *lexicon);
105 GRN_API grn_rc grn_ii_remove(grn_ctx *ctx, const char *path);
106 grn_rc grn_ii_info(grn_ctx *ctx, grn_ii *ii, uint64_t *seg_size, uint64_t *chunk_size);
107 grn_rc grn_ii_update_one(grn_ctx *ctx, grn_ii *ii, uint32_t key, grn_ii_updspec *u,
108  grn_hash *h);
109 grn_rc grn_ii_delete_one(grn_ctx *ctx, grn_ii *ii, uint32_t key, grn_ii_updspec *u,
110  grn_hash *h);
111 grn_ii_updspec *grn_ii_updspec_open(grn_ctx *ctx, uint32_t rid, uint32_t sid);
113 grn_rc grn_ii_updspec_add(grn_ctx *ctx, grn_ii_updspec *u, int pos, int32_t weight);
115 
116 uint32_t grn_ii_estimate_size(grn_ctx *ctx, grn_ii *ii, uint32_t key);
117 
118 void grn_ii_expire(grn_ctx *ctx, grn_ii *ii);
119 
120 typedef struct {
122  uint32_t sid;
123  uint32_t pos;
124  uint32_t tf;
125  uint32_t weight;
126  uint32_t rest;
128 
130 
132  grn_hash *s, grn_operator op);
133 
135  grn_id min, grn_id max, int nelements, int flags);
137 grn_rc grn_ii_cursor_openv2(grn_ii_cursor **cursors, int ncursors);
141 
142 uint32_t grn_ii_max_section(grn_ii *ii);
143 
144 int grn_ii_check(grn_ii *ii);
145 const char *grn_ii_path(grn_ii *ii);
147 
148 /*
149 grn_rc grn_ii_upd(grn_ctx *ctx, grn_ii *ii, grn_id rid, grn_vgram *vgram,
150  const char *oldvalue, unsigned int oldvalue_len,
151  const char *newvalue, unsigned int newvalue_len);
152 grn_rc grn_ii_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, grn_vgram *vgram,
153  unsigned int section,
154  grn_values *oldvalues, grn_values *newvalues);
155 */
156 
158 
165  int (*func)(grn_ctx *, grn_hash *, const void *, int, void *);
166  void *func_arg;
167  int max_size;
168 };
169 
171  unsigned int section, grn_obj *oldvalue,
172  grn_obj *newvalue, grn_obj *posting);
173 grn_rc grn_ii_term_extract(grn_ctx *ctx, grn_ii *ii, const char *string,
174  unsigned int string_len, grn_hash *s,
175  grn_operator op, grn_select_optarg *optarg);
176 grn_rc grn_ii_similar_search(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_len,
177  grn_hash *s, grn_operator op, grn_select_optarg *optarg);
178 GRN_API grn_rc grn_ii_select(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_len,
179  grn_hash *s, grn_operator op, grn_select_optarg *optarg);
180 grn_rc grn_ii_sel(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_len,
181  grn_hash *s, grn_operator op, grn_search_optarg *optarg);
182 
184 
185 grn_rc grn_ii_at(grn_ctx *ctx, grn_ii *ii, grn_id id, grn_hash *s, grn_operator op);
186 
187 void grn_ii_inspect_elements(grn_ctx *ctx, grn_ii *ii, grn_obj *buf);
189 
190 grn_rc grn_ii_build(grn_ctx *ctx, grn_ii *ii, uint64_t sparsity);
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* GRN_II_H */