Groonga 3.0.9 Source Code Document
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
groonga
lib
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
{
43
grn_db_obj
obj
;
44
grn_io
*
seg
;
45
grn_io
*
chunk
;
46
grn_obj
*
lexicon
;
47
grn_obj_flags
lflags
;
48
grn_encoding
encoding
;
49
uint32_t
n_elements
;
50
struct
grn_ii_header
*
header
;
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
;
72
uint32_t
bgqbody
[
GRN_II_BGQSIZE
];
73
uint32_t
reserved
[288];
74
uint32_t
ainfo
[
GRN_II_MAX_LSEG
];
75
uint32_t
binfo
[
GRN_II_MAX_LSEG
];
76
uint32_t
free_chunks
[
GRN_II_N_CHUNK_VARIATION
+ 1];
77
uint32_t
garbages
[
GRN_II_N_CHUNK_VARIATION
+ 1];
78
uint32_t
ngarbages
[
GRN_II_N_CHUNK_VARIATION
+ 1];
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
87
struct
_grn_ii_updspec
{
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
99
typedef
struct
_grn_ii_updspec
grn_ii_updspec
;
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);
104
GRN_API
grn_rc
grn_ii_close
(
grn_ctx
*ctx,
grn_ii
*ii);
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
);
112
grn_rc
grn_ii_updspec_close
(
grn_ctx
*ctx,
grn_ii_updspec
*u);
113
grn_rc
grn_ii_updspec_add
(
grn_ctx
*ctx,
grn_ii_updspec
*u,
int
pos
, int32_t
weight
);
114
int
grn_ii_updspec_cmp
(
grn_ii_updspec
*a,
grn_ii_updspec
*
b
);
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
{
121
grn_id
rid
;
122
uint32_t
sid
;
123
uint32_t
pos
;
124
uint32_t
tf
;
125
uint32_t
weight
;
126
uint32_t
rest
;
127
}
grn_ii_posting
;
128
129
typedef
struct
_grn_ii_cursor
grn_ii_cursor
;
130
131
GRN_API
grn_rc
grn_ii_posting_add
(
grn_ctx
*
ctx
,
grn_ii_posting
*pos,
132
grn_hash
*s,
grn_operator
op);
133
134
GRN_API
grn_ii_cursor
*
grn_ii_cursor_open
(
grn_ctx
*
ctx
,
grn_ii
*
ii
,
grn_id
tid,
135
grn_id
min
,
grn_id
max
,
int
nelements
,
int
flags
);
136
grn_ii_cursor
*
grn_ii_cursor_openv1
(
grn_ii
*
ii
, uint32_t key);
137
grn_rc
grn_ii_cursor_openv2
(
grn_ii_cursor
**cursors,
int
ncursors);
138
GRN_API
grn_ii_posting
*
grn_ii_cursor_next
(
grn_ctx
*
ctx
,
grn_ii_cursor
*c);
139
grn_ii_posting
*
grn_ii_cursor_next_pos
(
grn_ctx
*
ctx
,
grn_ii_cursor
*c);
140
GRN_API
grn_rc
grn_ii_cursor_close
(
grn_ctx
*
ctx
,
grn_ii_cursor
*c);
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
);
146
grn_obj
*
grn_ii_lexicon
(
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
157
typedef
struct
_grn_select_optarg
grn_select_optarg
;
158
159
struct
_grn_select_optarg
{
160
grn_operator
mode
;
161
int
similarity_threshold
;
162
int
max_interval
;
163
int
*
weight_vector
;
164
int
vector_size
;
165
int (*
func
)(
grn_ctx
*,
grn_hash
*,
const
void
*, int,
void
*);
166
void
*
func_arg
;
167
int
max_size
;
168
};
169
170
GRN_API
grn_rc
grn_ii_column_update
(
grn_ctx
*ctx,
grn_ii
*ii,
grn_id
id
,
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
183
void
grn_ii_resolve_sel_and
(
grn_ctx
*ctx,
grn_hash
*s,
grn_operator
op);
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);
188
void
grn_ii_cursor_inspect
(
grn_ctx
*ctx,
grn_ii_cursor
*c,
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 */
Generated on Sun Nov 10 2013 09:49:03 for Groonga 3.0.9 Source Code Document by
1.8.1.2