ferret 0.11.6 → 0.11.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README +10 -22
  2. data/RELEASE_CHANGES +137 -0
  3. data/RELEASE_NOTES +60 -0
  4. data/Rakefile +379 -274
  5. data/TODO +100 -8
  6. data/bin/ferret-browser +0 -0
  7. data/ext/BZLIB_blocksort.c +1094 -0
  8. data/ext/BZLIB_bzlib.c +1578 -0
  9. data/ext/BZLIB_compress.c +672 -0
  10. data/ext/BZLIB_crctable.c +104 -0
  11. data/ext/BZLIB_decompress.c +626 -0
  12. data/ext/BZLIB_huffman.c +205 -0
  13. data/ext/BZLIB_randtable.c +84 -0
  14. data/ext/{api.c → STEMMER_api.c} +7 -10
  15. data/ext/{libstemmer.c → STEMMER_libstemmer.c} +3 -2
  16. data/ext/{stem_ISO_8859_1_danish.c → STEMMER_stem_ISO_8859_1_danish.c} +123 -124
  17. data/ext/{stem_ISO_8859_1_dutch.c → STEMMER_stem_ISO_8859_1_dutch.c} +177 -188
  18. data/ext/STEMMER_stem_ISO_8859_1_english.c +1117 -0
  19. data/ext/{stem_ISO_8859_1_finnish.c → STEMMER_stem_ISO_8859_1_finnish.c} +276 -306
  20. data/ext/STEMMER_stem_ISO_8859_1_french.c +1246 -0
  21. data/ext/{stem_ISO_8859_1_german.c → STEMMER_stem_ISO_8859_1_german.c} +161 -170
  22. data/ext/STEMMER_stem_ISO_8859_1_hungarian.c +1230 -0
  23. data/ext/STEMMER_stem_ISO_8859_1_italian.c +1065 -0
  24. data/ext/STEMMER_stem_ISO_8859_1_norwegian.c +297 -0
  25. data/ext/{stem_ISO_8859_1_porter.c → STEMMER_stem_ISO_8859_1_porter.c} +263 -290
  26. data/ext/{stem_ISO_8859_1_portuguese.c → STEMMER_stem_ISO_8859_1_portuguese.c} +362 -380
  27. data/ext/STEMMER_stem_ISO_8859_1_spanish.c +1093 -0
  28. data/ext/STEMMER_stem_ISO_8859_1_swedish.c +307 -0
  29. data/ext/STEMMER_stem_ISO_8859_2_romanian.c +998 -0
  30. data/ext/{stem_KOI8_R_russian.c → STEMMER_stem_KOI8_R_russian.c} +244 -245
  31. data/ext/STEMMER_stem_UTF_8_danish.c +339 -0
  32. data/ext/{stem_UTF_8_dutch.c → STEMMER_stem_UTF_8_dutch.c} +192 -211
  33. data/ext/STEMMER_stem_UTF_8_english.c +1125 -0
  34. data/ext/{stem_UTF_8_finnish.c → STEMMER_stem_UTF_8_finnish.c} +284 -324
  35. data/ext/STEMMER_stem_UTF_8_french.c +1256 -0
  36. data/ext/{stem_UTF_8_german.c → STEMMER_stem_UTF_8_german.c} +170 -187
  37. data/ext/STEMMER_stem_UTF_8_hungarian.c +1234 -0
  38. data/ext/STEMMER_stem_UTF_8_italian.c +1073 -0
  39. data/ext/STEMMER_stem_UTF_8_norwegian.c +299 -0
  40. data/ext/{stem_UTF_8_porter.c → STEMMER_stem_UTF_8_porter.c} +271 -310
  41. data/ext/STEMMER_stem_UTF_8_portuguese.c +1023 -0
  42. data/ext/STEMMER_stem_UTF_8_romanian.c +1004 -0
  43. data/ext/STEMMER_stem_UTF_8_russian.c +694 -0
  44. data/ext/STEMMER_stem_UTF_8_spanish.c +1097 -0
  45. data/ext/STEMMER_stem_UTF_8_swedish.c +309 -0
  46. data/ext/STEMMER_stem_UTF_8_turkish.c +2205 -0
  47. data/ext/{utilities.c → STEMMER_utilities.c} +100 -68
  48. data/ext/analysis.c +276 -121
  49. data/ext/analysis.h +190 -143
  50. data/ext/api.h +3 -4
  51. data/ext/array.c +5 -3
  52. data/ext/array.h +52 -43
  53. data/ext/bitvector.c +38 -482
  54. data/ext/bitvector.h +446 -124
  55. data/ext/bzlib.h +282 -0
  56. data/ext/bzlib_private.h +503 -0
  57. data/ext/compound_io.c +23 -22
  58. data/ext/config.h +21 -11
  59. data/ext/document.c +43 -40
  60. data/ext/document.h +31 -21
  61. data/ext/except.c +20 -38
  62. data/ext/except.h +89 -76
  63. data/ext/extconf.rb +3 -2
  64. data/ext/ferret.c +49 -35
  65. data/ext/ferret.h +14 -11
  66. data/ext/field_index.c +262 -0
  67. data/ext/field_index.h +52 -0
  68. data/ext/filter.c +11 -10
  69. data/ext/fs_store.c +65 -47
  70. data/ext/global.c +245 -165
  71. data/ext/global.h +252 -54
  72. data/ext/hash.c +200 -243
  73. data/ext/hash.h +205 -163
  74. data/ext/hashset.c +118 -96
  75. data/ext/hashset.h +110 -82
  76. data/ext/header.h +19 -19
  77. data/ext/helper.c +11 -10
  78. data/ext/helper.h +14 -6
  79. data/ext/index.c +745 -366
  80. data/ext/index.h +503 -529
  81. data/ext/internal.h +1020 -0
  82. data/ext/lang.c +10 -0
  83. data/ext/lang.h +35 -15
  84. data/ext/mempool.c +5 -4
  85. data/ext/mempool.h +30 -22
  86. data/ext/modules.h +35 -7
  87. data/ext/multimapper.c +43 -2
  88. data/ext/multimapper.h +32 -23
  89. data/ext/posh.c +0 -0
  90. data/ext/posh.h +4 -38
  91. data/ext/priorityqueue.c +10 -12
  92. data/ext/priorityqueue.h +33 -21
  93. data/ext/q_boolean.c +22 -9
  94. data/ext/q_const_score.c +3 -2
  95. data/ext/q_filtered_query.c +15 -12
  96. data/ext/q_fuzzy.c +147 -135
  97. data/ext/q_match_all.c +3 -2
  98. data/ext/q_multi_term.c +28 -32
  99. data/ext/q_parser.c +451 -173
  100. data/ext/q_phrase.c +158 -79
  101. data/ext/q_prefix.c +16 -18
  102. data/ext/q_range.c +363 -31
  103. data/ext/q_span.c +130 -141
  104. data/ext/q_term.c +21 -21
  105. data/ext/q_wildcard.c +19 -23
  106. data/ext/r_analysis.c +369 -242
  107. data/ext/r_index.c +421 -434
  108. data/ext/r_qparser.c +142 -92
  109. data/ext/r_search.c +790 -407
  110. data/ext/r_store.c +44 -44
  111. data/ext/r_utils.c +264 -96
  112. data/ext/ram_store.c +29 -23
  113. data/ext/scanner.c +895 -0
  114. data/ext/scanner.h +36 -0
  115. data/ext/scanner_mb.c +6701 -0
  116. data/ext/scanner_utf8.c +4415 -0
  117. data/ext/search.c +210 -87
  118. data/ext/search.h +556 -488
  119. data/ext/similarity.c +17 -16
  120. data/ext/similarity.h +51 -44
  121. data/ext/sort.c +157 -354
  122. data/ext/stem_ISO_8859_1_hungarian.h +16 -0
  123. data/ext/stem_ISO_8859_2_romanian.h +16 -0
  124. data/ext/stem_UTF_8_hungarian.h +16 -0
  125. data/ext/stem_UTF_8_romanian.h +16 -0
  126. data/ext/stem_UTF_8_turkish.h +16 -0
  127. data/ext/stopwords.c +287 -278
  128. data/ext/store.c +57 -51
  129. data/ext/store.h +308 -286
  130. data/ext/symbol.c +10 -0
  131. data/ext/symbol.h +23 -0
  132. data/ext/term_vectors.c +14 -293
  133. data/ext/threading.h +22 -22
  134. data/ext/win32.h +12 -4
  135. data/lib/ferret.rb +2 -1
  136. data/lib/ferret/browser.rb +1 -1
  137. data/lib/ferret/field_symbol.rb +94 -0
  138. data/lib/ferret/index.rb +221 -34
  139. data/lib/ferret/number_tools.rb +6 -6
  140. data/lib/ferret/version.rb +3 -0
  141. data/test/{unit → long_running}/largefile/tc_largefile.rb +1 -1
  142. data/test/test_helper.rb +7 -2
  143. data/test/test_installed.rb +1 -0
  144. data/test/threading/thread_safety_index_test.rb +10 -1
  145. data/test/threading/thread_safety_read_write_test.rb +4 -7
  146. data/test/threading/thread_safety_test.rb +0 -0
  147. data/test/unit/analysis/tc_analyzer.rb +29 -27
  148. data/test/unit/analysis/tc_token_stream.rb +23 -16
  149. data/test/unit/index/tc_index.rb +116 -11
  150. data/test/unit/index/tc_index_reader.rb +27 -27
  151. data/test/unit/index/tc_index_writer.rb +10 -0
  152. data/test/unit/index/th_doc.rb +38 -21
  153. data/test/unit/search/tc_filter.rb +31 -10
  154. data/test/unit/search/tc_index_searcher.rb +6 -0
  155. data/test/unit/search/tm_searcher.rb +53 -1
  156. data/test/unit/store/tc_fs_store.rb +40 -2
  157. data/test/unit/store/tc_ram_store.rb +0 -0
  158. data/test/unit/store/tm_store.rb +0 -0
  159. data/test/unit/store/tm_store_lock.rb +7 -6
  160. data/test/unit/tc_field_symbol.rb +26 -0
  161. data/test/unit/ts_analysis.rb +0 -0
  162. data/test/unit/ts_index.rb +0 -0
  163. data/test/unit/ts_store.rb +0 -0
  164. data/test/unit/ts_utils.rb +0 -0
  165. data/test/unit/utils/tc_number_tools.rb +0 -0
  166. data/test/utils/content_generator.rb +226 -0
  167. metadata +262 -221
  168. data/ext/inc/lang.h +0 -48
  169. data/ext/inc/threading.h +0 -31
  170. data/ext/stem_ISO_8859_1_english.c +0 -1156
  171. data/ext/stem_ISO_8859_1_french.c +0 -1276
  172. data/ext/stem_ISO_8859_1_italian.c +0 -1091
  173. data/ext/stem_ISO_8859_1_norwegian.c +0 -296
  174. data/ext/stem_ISO_8859_1_spanish.c +0 -1119
  175. data/ext/stem_ISO_8859_1_swedish.c +0 -307
  176. data/ext/stem_UTF_8_danish.c +0 -344
  177. data/ext/stem_UTF_8_english.c +0 -1176
  178. data/ext/stem_UTF_8_french.c +0 -1296
  179. data/ext/stem_UTF_8_italian.c +0 -1113
  180. data/ext/stem_UTF_8_norwegian.c +0 -302
  181. data/ext/stem_UTF_8_portuguese.c +0 -1055
  182. data/ext/stem_UTF_8_russian.c +0 -709
  183. data/ext/stem_UTF_8_spanish.c +0 -1137
  184. data/ext/stem_UTF_8_swedish.c +0 -313
  185. data/lib/ferret_version.rb +0 -3
@@ -1,6 +1,10 @@
1
1
  #include "ferret.h"
2
2
  #include "index.h"
3
- #include <st.h>
3
+ #ifdef FRT_RUBY_VERSION_1_9
4
+ # include <ruby/st.h>
5
+ #else
6
+ # include <st.h>
7
+ #endif
4
8
 
5
9
  VALUE mIndex;
6
10
 
@@ -52,15 +56,17 @@ static VALUE sym_with_positions;
52
56
  static VALUE sym_with_offsets;
53
57
  static VALUE sym_with_positions_offsets;
54
58
 
59
+ static Symbol fsym_content;
60
+
55
61
  static ID id_term;
56
62
  static ID id_fields;
57
63
  static ID id_fld_num_map;
58
64
  static ID id_field_num;
59
65
  static ID id_boost;
60
66
 
61
- extern void frt_set_term(VALUE rterm, Term *t);
62
- extern Analyzer *frt_get_cwrapped_analyzer(VALUE ranalyzer);
63
- extern VALUE frt_get_analyzer(Analyzer *a);
67
+ extern void frb_set_term(VALUE rterm, Term *t);
68
+ extern Analyzer *frb_get_cwrapped_analyzer(VALUE ranalyzer);
69
+ extern VALUE frb_get_analyzer(Analyzer *a);
64
70
 
65
71
  /****************************************************************************
66
72
  *
@@ -69,17 +75,17 @@ extern VALUE frt_get_analyzer(Analyzer *a);
69
75
  ****************************************************************************/
70
76
 
71
77
  static void
72
- frt_fi_free(void *p)
78
+ frb_fi_free(void *p)
73
79
  {
74
80
  object_del(p);
75
81
  fi_deref((FieldInfo *)p);
76
82
  }
77
83
 
78
84
  static void
79
- frt_fi_get_params(VALUE roptions,
80
- enum StoreValues *store,
81
- enum IndexValues *index,
82
- enum TermVectorValues *term_vector,
85
+ frb_fi_get_params(VALUE roptions,
86
+ StoreValue *store,
87
+ IndexValue *index,
88
+ TermVectorValue *term_vector,
83
89
  float *boost)
84
90
  {
85
91
  VALUE v;
@@ -151,14 +157,14 @@ frt_fi_get_params(VALUE roptions,
151
157
  }
152
158
 
153
159
  static VALUE
154
- frt_get_field_info(FieldInfo *fi)
160
+ frb_get_field_info(FieldInfo *fi)
155
161
  {
156
162
 
157
163
  VALUE rfi = Qnil;
158
164
  if (fi) {
159
165
  rfi = object_get(fi);
160
166
  if (rfi == Qnil) {
161
- rfi = Data_Wrap_Struct(cFieldInfo, NULL, &frt_fi_free, fi);
167
+ rfi = Data_Wrap_Struct(cFieldInfo, NULL, &frb_fi_free, fi);
162
168
  REF(fi);
163
169
  object_add(fi, rfi);
164
170
  }
@@ -176,22 +182,22 @@ frt_get_field_info(FieldInfo *fi)
176
182
  * information on these properties.
177
183
  */
178
184
  static VALUE
179
- frt_fi_init(int argc, VALUE *argv, VALUE self)
185
+ frb_fi_init(int argc, VALUE *argv, VALUE self)
180
186
  {
181
187
  VALUE roptions, rname;
182
188
  FieldInfo *fi;
183
- enum StoreValues store = STORE_YES;
184
- enum IndexValues index = INDEX_YES;
185
- enum TermVectorValues term_vector = TERM_VECTOR_WITH_POSITIONS_OFFSETS;
189
+ StoreValue store = STORE_YES;
190
+ IndexValue index = INDEX_YES;
191
+ TermVectorValue term_vector = TERM_VECTOR_WITH_POSITIONS_OFFSETS;
186
192
  float boost = 1.0f;
187
193
 
188
194
  rb_scan_args(argc, argv, "11", &rname, &roptions);
189
195
  if (argc > 1) {
190
- frt_fi_get_params(roptions, &store, &index, &term_vector, &boost);
196
+ frb_fi_get_params(roptions, &store, &index, &term_vector, &boost);
191
197
  }
192
- fi = fi_new(frt_field(rname), store, index, term_vector);
198
+ fi = fi_new(frb_field(rname), store, index, term_vector);
193
199
  fi->boost = boost;
194
- Frt_Wrap_Struct(self, NULL, &frt_fi_free, fi);
200
+ Frt_Wrap_Struct(self, NULL, &frb_fi_free, fi);
195
201
  object_add(fi, self);
196
202
  return self;
197
203
  }
@@ -203,10 +209,10 @@ frt_fi_init(int argc, VALUE *argv, VALUE self)
203
209
  * Return the name of the field
204
210
  */
205
211
  static VALUE
206
- frt_fi_name(VALUE self)
212
+ frb_fi_name(VALUE self)
207
213
  {
208
214
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
209
- return ID2SYM(rb_intern(fi->name));
215
+ return ID2SYM(fi->name);
210
216
  }
211
217
 
212
218
  /*
@@ -216,7 +222,7 @@ frt_fi_name(VALUE self)
216
222
  * Return true if the field is stored in the index.
217
223
  */
218
224
  static VALUE
219
- frt_fi_is_stored(VALUE self)
225
+ frb_fi_is_stored(VALUE self)
220
226
  {
221
227
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
222
228
  return fi_is_stored(fi) ? Qtrue : Qfalse;
@@ -229,7 +235,7 @@ frt_fi_is_stored(VALUE self)
229
235
  * Return true if the field is stored in the index in compressed format.
230
236
  */
231
237
  static VALUE
232
- frt_fi_is_compressed(VALUE self)
238
+ frb_fi_is_compressed(VALUE self)
233
239
  {
234
240
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
235
241
  return fi_is_compressed(fi) ? Qtrue : Qfalse;
@@ -242,7 +248,7 @@ frt_fi_is_compressed(VALUE self)
242
248
  * Return true if the field is indexed, ie searchable in the index.
243
249
  */
244
250
  static VALUE
245
- frt_fi_is_indexed(VALUE self)
251
+ frb_fi_is_indexed(VALUE self)
246
252
  {
247
253
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
248
254
  return fi_is_indexed(fi) ? Qtrue : Qfalse;
@@ -260,7 +266,7 @@ frt_fi_is_indexed(VALUE self)
260
266
  * A field can only be tokenized if it is indexed.
261
267
  */
262
268
  static VALUE
263
- frt_fi_is_tokenized(VALUE self)
269
+ frb_fi_is_tokenized(VALUE self)
264
270
  {
265
271
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
266
272
  return fi_is_tokenized(fi) ? Qtrue : Qfalse;
@@ -278,7 +284,7 @@ frt_fi_is_tokenized(VALUE self)
278
284
  * large number of documents.
279
285
  */
280
286
  static VALUE
281
- frt_fi_omit_norms(VALUE self)
287
+ frb_fi_omit_norms(VALUE self)
282
288
  {
283
289
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
284
290
  return fi_omit_norms(fi) ? Qtrue : Qfalse;
@@ -291,7 +297,7 @@ frt_fi_omit_norms(VALUE self)
291
297
  * Return true if the term-vectors are stored for this field.
292
298
  */
293
299
  static VALUE
294
- frt_fi_store_term_vector(VALUE self)
300
+ frb_fi_store_term_vector(VALUE self)
295
301
  {
296
302
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
297
303
  return fi_store_term_vector(fi) ? Qtrue : Qfalse;
@@ -304,7 +310,7 @@ frt_fi_store_term_vector(VALUE self)
304
310
  * Return true if positions are stored with the term-vectors for this field.
305
311
  */
306
312
  static VALUE
307
- frt_fi_store_positions(VALUE self)
313
+ frb_fi_store_positions(VALUE self)
308
314
  {
309
315
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
310
316
  return fi_store_positions(fi) ? Qtrue : Qfalse;
@@ -317,7 +323,7 @@ frt_fi_store_positions(VALUE self)
317
323
  * Return true if offsets are stored with the term-vectors for this field.
318
324
  */
319
325
  static VALUE
320
- frt_fi_store_offsets(VALUE self)
326
+ frb_fi_store_offsets(VALUE self)
321
327
  {
322
328
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
323
329
  return fi_store_offsets(fi) ? Qtrue : Qfalse;
@@ -332,7 +338,7 @@ frt_fi_store_offsets(VALUE self)
332
338
  * fi.indexed? and not fi.omit_norms?
333
339
  */
334
340
  static VALUE
335
- frt_fi_has_norms(VALUE self)
341
+ frb_fi_has_norms(VALUE self)
336
342
  {
337
343
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
338
344
  return fi_has_norms(fi) ? Qtrue : Qfalse;
@@ -345,7 +351,7 @@ frt_fi_has_norms(VALUE self)
345
351
  * Return the default boost for this field
346
352
  */
347
353
  static VALUE
348
- frt_fi_boost(VALUE self)
354
+ frb_fi_boost(VALUE self)
349
355
  {
350
356
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
351
357
  return rb_float_new((double)fi->boost);
@@ -358,7 +364,7 @@ frt_fi_boost(VALUE self)
358
364
  * Return a string representation of the FieldInfo object.
359
365
  */
360
366
  static VALUE
361
- frt_fi_to_s(VALUE self)
367
+ frb_fi_to_s(VALUE self)
362
368
  {
363
369
  FieldInfo *fi = (FieldInfo *)DATA_PTR(self);
364
370
  char *fi_s = fi_to_s(fi);
@@ -374,32 +380,32 @@ frt_fi_to_s(VALUE self)
374
380
  ****************************************************************************/
375
381
 
376
382
  static void
377
- frt_fis_free(void *p)
383
+ frb_fis_free(void *p)
378
384
  {
379
385
  object_del(p);
380
386
  fis_deref((FieldInfos *)p);
381
387
  }
382
388
 
383
389
  static void
384
- frt_fis_mark(void *p)
390
+ frb_fis_mark(void *p)
385
391
  {
386
392
  int i;
387
393
  FieldInfos *fis = (FieldInfos *)p;
388
394
 
389
395
  for (i = 0; i < fis->size; i++) {
390
- frt_gc_mark(fis->fields[i]);
396
+ frb_gc_mark(fis->fields[i]);
391
397
  }
392
398
  }
393
399
 
394
400
  static VALUE
395
- frt_get_field_infos(FieldInfos *fis)
401
+ frb_get_field_infos(FieldInfos *fis)
396
402
  {
397
403
 
398
404
  VALUE rfis = Qnil;
399
405
  if (fis) {
400
406
  rfis = object_get(fis);
401
407
  if (rfis == Qnil) {
402
- rfis = Data_Wrap_Struct(cFieldInfos, &frt_fis_mark, &frt_fis_free,
408
+ rfis = Data_Wrap_Struct(cFieldInfos, &frb_fis_mark, &frb_fis_free,
403
409
  fis);
404
410
  REF(fis);
405
411
  object_add(fis, rfis);
@@ -417,21 +423,21 @@ frt_get_field_infos(FieldInfos *fis)
417
423
  * property values.
418
424
  */
419
425
  static VALUE
420
- frt_fis_init(int argc, VALUE *argv, VALUE self)
426
+ frb_fis_init(int argc, VALUE *argv, VALUE self)
421
427
  {
422
428
  VALUE roptions;
423
429
  FieldInfos *fis;
424
- enum StoreValues store = STORE_YES;
425
- enum IndexValues index = INDEX_YES;
426
- enum TermVectorValues term_vector = TERM_VECTOR_WITH_POSITIONS_OFFSETS;
430
+ StoreValue store = STORE_YES;
431
+ IndexValue index = INDEX_YES;
432
+ TermVectorValue term_vector = TERM_VECTOR_WITH_POSITIONS_OFFSETS;
427
433
  float boost;
428
434
 
429
435
  rb_scan_args(argc, argv, "01", &roptions);
430
436
  if (argc > 0) {
431
- frt_fi_get_params(roptions, &store, &index, &term_vector, &boost);
437
+ frb_fi_get_params(roptions, &store, &index, &term_vector, &boost);
432
438
  }
433
439
  fis = fis_new(store, index, term_vector);
434
- Frt_Wrap_Struct(self, &frt_fis_mark, &frt_fis_free, fis);
440
+ Frt_Wrap_Struct(self, &frb_fis_mark, &frb_fis_free, fis);
435
441
  object_add(fis, self);
436
442
  return self;
437
443
  }
@@ -444,14 +450,14 @@ frt_fis_init(int argc, VALUE *argv, VALUE self)
444
450
  * object.
445
451
  */
446
452
  static VALUE
447
- frt_fis_to_a(VALUE self)
453
+ frb_fis_to_a(VALUE self)
448
454
  {
449
455
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
450
456
  VALUE rary = rb_ary_new();
451
457
  int i;
452
458
 
453
459
  for (i = 0; i < fis->size; i++) {
454
- rb_ary_push(rary, frt_get_field_info(fis->fields[i]));
460
+ rb_ary_push(rary, frb_get_field_info(fis->fields[i]));
455
461
  }
456
462
  return rary;
457
463
  }
@@ -469,7 +475,7 @@ frt_fis_to_a(VALUE self)
469
475
  * fi = fis[2]
470
476
  */
471
477
  static VALUE
472
- frt_fis_get(VALUE self, VALUE ridx)
478
+ frb_fis_get(VALUE self, VALUE ridx)
473
479
  {
474
480
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
475
481
  VALUE rfi = Qnil;
@@ -479,17 +485,20 @@ frt_fis_get(VALUE self, VALUE ridx)
479
485
  if (index < 0) index += fis->size;
480
486
  if (index < 0 || index >= fis->size) {
481
487
  rb_raise(rb_eArgError, "index of %d is out of range (0..%d)\n",
482
- index, fis->size);
488
+ index, fis->size - 1);
483
489
  }
484
- rfi = frt_get_field_info(fis->fields[index]);
490
+ rfi = frb_get_field_info(fis->fields[index]);
485
491
  break;
486
492
  }
487
493
  case T_SYMBOL:
488
- rfi = frt_get_field_info(fis_get_field(fis, frt_field(ridx)));
494
+ case T_STRING:
495
+ rfi = frb_get_field_info(fis_get_field(fis, frb_field(ridx)));
489
496
  break;
497
+ /*
490
498
  case T_STRING:
491
- rfi = frt_get_field_info(fis_get_field(fis, StringValuePtr(ridx)));
499
+ rfi = frb_get_field_info(fis_get_field(fis, StringValuePtr(ridx)));
492
500
  break;
501
+ */
493
502
  default:
494
503
  rb_raise(rb_eArgError, "Can't index FieldInfos with %s",
495
504
  rs2s(rb_obj_as_string(ridx)));
@@ -507,10 +516,10 @@ frt_fis_get(VALUE self, VALUE ridx)
507
516
  * possible.
508
517
  */
509
518
  static VALUE
510
- frt_fis_add(VALUE self, VALUE rfi)
519
+ frb_fis_add(VALUE self, VALUE rfi)
511
520
  {
512
521
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
513
- FieldInfo *fi = (FieldInfo *)frt_rb_data_ptr(rfi);
522
+ FieldInfo *fi = (FieldInfo *)frb_rb_data_ptr(rfi);
514
523
  fis_add_field(fis, fi);
515
524
  REF(fi);
516
525
  return self;
@@ -524,21 +533,21 @@ frt_fis_add(VALUE self, VALUE rfi)
524
533
  * of the available properties.
525
534
  */
526
535
  static VALUE
527
- frt_fis_add_field(int argc, VALUE *argv, VALUE self)
536
+ frb_fis_add_field(int argc, VALUE *argv, VALUE self)
528
537
  {
529
538
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
530
539
  FieldInfo *fi;
531
- enum StoreValues store = fis->store;
532
- enum IndexValues index = fis->index;
533
- enum TermVectorValues term_vector = fis->term_vector;
540
+ StoreValue store = fis->store;
541
+ IndexValue index = fis->index;
542
+ TermVectorValue term_vector = fis->term_vector;
534
543
  float boost = 1.0f;
535
544
  VALUE rname, roptions;
536
545
 
537
546
  rb_scan_args(argc, argv, "11", &rname, &roptions);
538
547
  if (argc > 1) {
539
- frt_fi_get_params(roptions, &store, &index, &term_vector, &boost);
548
+ frb_fi_get_params(roptions, &store, &index, &term_vector, &boost);
540
549
  }
541
- fi = fi_new(frt_field(rname), store, index, term_vector);
550
+ fi = fi_new(frb_field(rname), store, index, term_vector);
542
551
  fi->boost = boost;
543
552
  fis_add_field(fis, fi);
544
553
  return self;
@@ -551,13 +560,13 @@ frt_fis_add_field(int argc, VALUE *argv, VALUE self)
551
560
  * Iterate through the FieldInfo objects.
552
561
  */
553
562
  static VALUE
554
- frt_fis_each(VALUE self)
563
+ frb_fis_each(VALUE self)
555
564
  {
556
565
  int i;
557
566
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
558
567
 
559
568
  for (i = 0; i < fis->size; i++) {
560
- rb_yield(frt_get_field_info(fis->fields[i]));
569
+ rb_yield(frb_get_field_info(fis->fields[i]));
561
570
  }
562
571
  return self;
563
572
  }
@@ -569,7 +578,7 @@ frt_fis_each(VALUE self)
569
578
  * Return a string representation of the FieldInfos object.
570
579
  */
571
580
  static VALUE
572
- frt_fis_to_s(VALUE self)
581
+ frb_fis_to_s(VALUE self)
573
582
  {
574
583
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
575
584
  char *fis_s = fis_to_s(fis);
@@ -585,7 +594,7 @@ frt_fis_to_s(VALUE self)
585
594
  * Return the number of fields in the FieldInfos object.
586
595
  */
587
596
  static VALUE
588
- frt_fis_size(VALUE self)
597
+ frb_fis_size(VALUE self)
589
598
  {
590
599
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
591
600
  return INT2FIX(fis->size);
@@ -602,7 +611,7 @@ frt_fis_size(VALUE self)
602
611
  * directory and overwritten by the new index.
603
612
  */
604
613
  static VALUE
605
- frt_fis_create_index(VALUE self, VALUE rdir)
614
+ frb_fis_create_index(VALUE self, VALUE rdir)
606
615
  {
607
616
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
608
617
  Store *store = NULL;
@@ -611,7 +620,7 @@ frt_fis_create_index(VALUE self, VALUE rdir)
611
620
  REF(store);
612
621
  } else {
613
622
  StringValue(rdir);
614
- frt_create_dir(rdir);
623
+ frb_create_dir(rdir);
615
624
  store = open_fs_store(rs2s(rdir));
616
625
  }
617
626
  index_create(store, fis);
@@ -622,18 +631,19 @@ frt_fis_create_index(VALUE self, VALUE rdir)
622
631
  /*
623
632
  * call-seq:
624
633
  * fis.fields -> symbol array
634
+ * fis.field_names -> symbol array
625
635
  *
626
636
  * Return a list of the field names (as symbols) of all the fields in the
627
637
  * index.
628
638
  */
629
639
  static VALUE
630
- frt_fis_get_fields(VALUE self)
640
+ frb_fis_get_fields(VALUE self)
631
641
  {
632
642
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
633
643
  VALUE rfield_names = rb_ary_new();
634
644
  int i;
635
645
  for (i = 0; i < fis->size; i++) {
636
- rb_ary_push(rfield_names, ID2SYM(rb_intern(fis->fields[i]->name)));
646
+ rb_ary_push(rfield_names, FSYM2SYM(fis->fields[i]->name));
637
647
  }
638
648
  return rfield_names;
639
649
  }
@@ -646,14 +656,14 @@ frt_fis_get_fields(VALUE self)
646
656
  * in the index.
647
657
  */
648
658
  static VALUE
649
- frt_fis_get_tk_fields(VALUE self)
659
+ frb_fis_get_tk_fields(VALUE self)
650
660
  {
651
661
  FieldInfos *fis = (FieldInfos *)DATA_PTR(self);
652
662
  VALUE rfield_names = rb_ary_new();
653
663
  int i;
654
664
  for (i = 0; i < fis->size; i++) {
655
665
  if (!fi_is_tokenized(fis->fields[i])) continue;
656
- rb_ary_push(rfield_names, ID2SYM(rb_intern(fis->fields[i]->name)));
666
+ rb_ary_push(rfield_names, FSYM2SYM(fis->fields[i]->name));
657
667
  }
658
668
  return rfield_names;
659
669
  }
@@ -665,14 +675,14 @@ frt_fis_get_tk_fields(VALUE self)
665
675
  ****************************************************************************/
666
676
 
667
677
  static void
668
- frt_te_free(void *p)
678
+ frb_te_free(void *p)
669
679
  {
670
680
  TermEnum *te = (TermEnum *)p;
671
681
  te->close(te);
672
682
  }
673
683
 
674
684
  static VALUE
675
- frt_te_get_set_term(VALUE self, const char *term)
685
+ frb_te_get_set_term(VALUE self, const char *term)
676
686
  {
677
687
  TermEnum *te = (TermEnum *)DATA_PTR(self);
678
688
  VALUE str = term ? rb_str_new(term, te->curr_term_len) : Qnil;
@@ -681,12 +691,12 @@ frt_te_get_set_term(VALUE self, const char *term)
681
691
  }
682
692
 
683
693
  static VALUE
684
- frt_get_te(VALUE rir, TermEnum *te)
694
+ frb_get_te(VALUE rir, TermEnum *te)
685
695
  {
686
696
  VALUE self = Qnil;
687
697
  if (te != NULL) {
688
- self = Data_Wrap_Struct(cTermEnum, NULL, &frt_te_free, te);
689
- frt_te_get_set_term(self, te->curr_term);
698
+ self = Data_Wrap_Struct(cTermEnum, NULL, &frb_te_free, te);
699
+ frb_te_get_set_term(self, te->curr_term);
690
700
  rb_ivar_set(self, id_fld_num_map, rb_ivar_get(rir, id_fld_num_map));
691
701
  }
692
702
  return self;
@@ -699,10 +709,10 @@ frt_get_te(VALUE rir, TermEnum *te)
699
709
  * Returns the next term in the enumeration or nil otherwise.
700
710
  */
701
711
  static VALUE
702
- frt_te_next(VALUE self)
712
+ frb_te_next(VALUE self)
703
713
  {
704
714
  TermEnum *te = (TermEnum *)DATA_PTR(self);
705
- return frt_te_get_set_term(self, te->next(te));
715
+ return frb_te_get_set_term(self, te->next(te));
706
716
  }
707
717
 
708
718
  /*
@@ -713,7 +723,7 @@ frt_te_next(VALUE self)
713
723
  * be called after a successful call to TermEnum#next.
714
724
  */
715
725
  static VALUE
716
- frt_te_term(VALUE self)
726
+ frb_te_term(VALUE self)
717
727
  {
718
728
  return rb_ivar_get(self, id_term);
719
729
  }
@@ -727,7 +737,7 @@ frt_te_term(VALUE self)
727
737
  * should only be called after a successful call to TermEnum#next.
728
738
  */
729
739
  static VALUE
730
- frt_te_doc_freq(VALUE self)
740
+ frb_te_doc_freq(VALUE self)
731
741
  {
732
742
  TermEnum *te = (TermEnum *)DATA_PTR(self);
733
743
  return INT2FIX(te->curr_ti.doc_freq);
@@ -745,10 +755,10 @@ frt_te_doc_freq(VALUE self)
745
755
  * Returns the first term greater than or equal to +target+
746
756
  */
747
757
  static VALUE
748
- frt_te_skip_to(VALUE self, VALUE rterm)
758
+ frb_te_skip_to(VALUE self, VALUE rterm)
749
759
  {
750
760
  TermEnum *te = (TermEnum *)DATA_PTR(self);
751
- return frt_te_get_set_term(self, te->skip_to(te, frt_field(rterm)));
761
+ return frb_te_get_set_term(self, te->skip_to(te, rs2s(rterm)));
752
762
  }
753
763
 
754
764
  /*
@@ -759,15 +769,14 @@ frt_te_skip_to(VALUE self, VALUE rterm)
759
769
  * document frequency.
760
770
  */
761
771
  static VALUE
762
- frt_te_each(VALUE self)
772
+ frb_te_each(VALUE self)
763
773
  {
764
774
  TermEnum *te = (TermEnum *)DATA_PTR(self);
765
775
  char *term;
766
776
  int term_cnt = 0;
767
777
  VALUE vals = rb_ary_new2(2);
768
- RARRAY(vals)->len = 2;
769
- rb_mem_clear(RARRAY(vals)->ptr, 2);
770
-
778
+ rb_ary_store(vals, 0, Qnil);
779
+ rb_ary_store(vals, 1, Qnil);
771
780
 
772
781
  /* each is being called so there will be no current term */
773
782
  rb_ivar_set(self, id_term, Qnil);
@@ -775,8 +784,8 @@ frt_te_each(VALUE self)
775
784
 
776
785
  while (NULL != (term = te->next(te))) {
777
786
  term_cnt++;
778
- RARRAY(vals)->ptr[0] = rb_str_new(term, te->curr_term_len);
779
- RARRAY(vals)->ptr[1] = INT2FIX(te->curr_ti.doc_freq);
787
+ RARRAY_PTR(vals)[0] = rb_str_new(term, te->curr_term_len);
788
+ RARRAY_PTR(vals)[1] = INT2FIX(te->curr_ti.doc_freq);
780
789
  rb_yield(vals);
781
790
  }
782
791
  return INT2FIX(term_cnt);
@@ -794,7 +803,7 @@ frt_te_each(VALUE self)
794
803
  * end
795
804
  */
796
805
  static VALUE
797
- frt_te_set_field(VALUE self, VALUE rfield)
806
+ frb_te_set_field(VALUE self, VALUE rfield)
798
807
  {
799
808
  TermEnum *te = (TermEnum *)DATA_PTR(self);
800
809
  int field_num = 0;
@@ -806,7 +815,7 @@ frt_te_set_field(VALUE self, VALUE rfield)
806
815
  } else {
807
816
  Check_Type(rfield, T_SYMBOL);
808
817
  rb_raise(rb_eArgError, "field %s doesn't exist in the index",
809
- frt_field(rfield));
818
+ (char *)frb_field(rfield));
810
819
  }
811
820
  te->set_field(te, field_num);
812
821
 
@@ -836,7 +845,7 @@ frt_te_set_field(VALUE self, VALUE rfield)
836
845
  * # ]
837
846
  */
838
847
  static VALUE
839
- frt_te_to_json(int argc, VALUE *argv, VALUE self)
848
+ frb_te_to_json(int argc, VALUE *argv, VALUE self)
840
849
  {
841
850
  TermEnum *te = (TermEnum *)DATA_PTR(self);
842
851
  VALUE rjson;
@@ -900,16 +909,16 @@ frt_te_to_json(int argc, VALUE *argv, VALUE self)
900
909
  ****************************************************************************/
901
910
 
902
911
  static void
903
- frt_tde_free(void *p)
912
+ frb_tde_free(void *p)
904
913
  {
905
914
  TermDocEnum *tde = (TermDocEnum *)p;
906
915
  tde->close(tde);
907
916
  }
908
917
 
909
918
  static VALUE
910
- frt_get_tde(VALUE rir, TermDocEnum *tde)
919
+ frb_get_tde(VALUE rir, TermDocEnum *tde)
911
920
  {
912
- VALUE self = Data_Wrap_Struct(cTermDocEnum, NULL, &frt_tde_free, tde);
921
+ VALUE self = Data_Wrap_Struct(cTermDocEnum, NULL, &frb_tde_free, tde);
913
922
  rb_ivar_set(self, id_fld_num_map, rb_ivar_get(rir, id_fld_num_map));
914
923
  return self;
915
924
  }
@@ -923,7 +932,7 @@ frt_get_tde(VALUE rir, TermDocEnum *tde)
923
932
  * this particular term.
924
933
  */
925
934
  static VALUE
926
- frt_tde_seek(VALUE self, VALUE rfield, VALUE rterm)
935
+ frb_tde_seek(VALUE self, VALUE rfield, VALUE rterm)
927
936
  {
928
937
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
929
938
  char *term;
@@ -935,7 +944,7 @@ frt_tde_seek(VALUE self, VALUE rfield, VALUE rterm)
935
944
  field_num = FIX2INT(rfnum);
936
945
  } else {
937
946
  rb_raise(rb_eArgError, "field %s doesn't exist in the index",
938
- frt_field(rfield));
947
+ (char *)frb_field(rfield));
939
948
  }
940
949
  tde->seek(tde, field_num, term);
941
950
  return self;
@@ -954,10 +963,10 @@ frt_tde_seek(VALUE self, VALUE rfield, VALUE rterm)
954
963
  * a large performance improvement.
955
964
  */
956
965
  static VALUE
957
- frt_tde_seek_te(VALUE self, VALUE rterm_enum)
966
+ frb_tde_seek_te(VALUE self, VALUE rterm_enum)
958
967
  {
959
968
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
960
- TermEnum *te = (TermEnum *)frt_rb_data_ptr(rterm_enum);
969
+ TermEnum *te = (TermEnum *)frb_rb_data_ptr(rterm_enum);
961
970
  tde->seek_te(tde, te);
962
971
  return self;
963
972
  }
@@ -969,7 +978,7 @@ frt_tde_seek_te(VALUE self, VALUE rterm_enum)
969
978
  * Returns the current document number pointed to by the +term_doc_enum+.
970
979
  */
971
980
  static VALUE
972
- frt_tde_doc(VALUE self)
981
+ frb_tde_doc(VALUE self)
973
982
  {
974
983
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
975
984
  return INT2FIX(tde->doc_num(tde));
@@ -983,7 +992,7 @@ frt_tde_doc(VALUE self)
983
992
  * +term_doc_enum+.
984
993
  */
985
994
  static VALUE
986
- frt_tde_freq(VALUE self)
995
+ frb_tde_freq(VALUE self)
987
996
  {
988
997
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
989
998
  return INT2FIX(tde->freq(tde));
@@ -997,7 +1006,7 @@ frt_tde_freq(VALUE self)
997
1006
  * there is another document or +false+ otherwise.
998
1007
  */
999
1008
  static VALUE
1000
- frt_tde_next(VALUE self)
1009
+ frb_tde_next(VALUE self)
1001
1010
  {
1002
1011
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
1003
1012
  return tde->next(tde) ? Qtrue : Qfalse;
@@ -1011,7 +1020,7 @@ frt_tde_next(VALUE self)
1011
1020
  * there is another document or +false+ otherwise.
1012
1021
  */
1013
1022
  static VALUE
1014
- frt_tde_next_position(VALUE self)
1023
+ frb_tde_next_position(VALUE self)
1015
1024
  {
1016
1025
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
1017
1026
  int pos;
@@ -1035,18 +1044,18 @@ frt_tde_next_position(VALUE self)
1035
1044
  * call +#each+ again then you should call +#seek+ again too.
1036
1045
  */
1037
1046
  static VALUE
1038
- frt_tde_each(VALUE self)
1047
+ frb_tde_each(VALUE self)
1039
1048
  {
1040
1049
  int doc_cnt = 0;
1041
1050
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
1042
1051
  VALUE vals = rb_ary_new2(2);
1043
- RARRAY(vals)->len = 2;
1044
- rb_mem_clear(RARRAY(vals)->ptr, 2);
1052
+ rb_ary_store(vals, 0, Qnil);
1053
+ rb_ary_store(vals, 1, Qnil);
1045
1054
 
1046
1055
  while (tde->next(tde)) {
1047
1056
  doc_cnt++;
1048
- RARRAY(vals)->ptr[0] = INT2FIX(tde->doc_num(tde));
1049
- RARRAY(vals)->ptr[1] = INT2FIX(tde->freq(tde));
1057
+ RARRAY_PTR(vals)[0] = INT2FIX(tde->doc_num(tde));
1058
+ RARRAY_PTR(vals)[1] = INT2FIX(tde->freq(tde));
1050
1059
  rb_yield(vals);
1051
1060
 
1052
1061
  }
@@ -1079,7 +1088,7 @@ frt_tde_each(VALUE self)
1079
1088
  * # ]
1080
1089
  */
1081
1090
  static VALUE
1082
- frt_tde_to_json(int argc, VALUE *argv, VALUE self)
1091
+ frb_tde_to_json(int argc, VALUE *argv, VALUE self)
1083
1092
  {
1084
1093
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
1085
1094
  VALUE rjson;
@@ -1153,7 +1162,7 @@ frt_tde_to_json(int argc, VALUE *argv, VALUE self)
1153
1162
  * end
1154
1163
  */
1155
1164
  static VALUE
1156
- frt_tde_each_position(VALUE self)
1165
+ frb_tde_each_position(VALUE self)
1157
1166
  {
1158
1167
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
1159
1168
  int pos;
@@ -1176,7 +1185,7 @@ frt_tde_each_position(VALUE self)
1176
1185
  * a document >= +target+.
1177
1186
  */
1178
1187
  static VALUE
1179
- frt_tde_skip_to(VALUE self, VALUE rtarget)
1188
+ frb_tde_skip_to(VALUE self, VALUE rtarget)
1180
1189
  {
1181
1190
  TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
1182
1191
  return tde->skip_to(tde, FIX2INT(rtarget)) ? Qtrue : Qfalse;
@@ -1189,11 +1198,11 @@ frt_tde_skip_to(VALUE self, VALUE rtarget)
1189
1198
  ****************************************************************************/
1190
1199
 
1191
1200
  static VALUE
1192
- frt_get_tv_offsets(Offset *offset)
1201
+ frb_get_tv_offsets(Offset *offset)
1193
1202
  {
1194
1203
  return rb_struct_new(cTVOffsets,
1195
- ULL2NUM((unsigned long long)offset->start),
1196
- ULL2NUM((unsigned long long)offset->end),
1204
+ ULL2NUM((u64)offset->start),
1205
+ ULL2NUM((u64)offset->end),
1197
1206
  NULL);
1198
1207
  }
1199
1208
 
@@ -1204,7 +1213,7 @@ frt_get_tv_offsets(Offset *offset)
1204
1213
  ****************************************************************************/
1205
1214
 
1206
1215
  static VALUE
1207
- frt_get_tv_term(TVTerm *tv_term)
1216
+ frb_get_tv_term(TVTerm *tv_term)
1208
1217
  {
1209
1218
  int i;
1210
1219
  const int freq = tv_term->freq;
@@ -1212,16 +1221,13 @@ frt_get_tv_term(TVTerm *tv_term)
1212
1221
  VALUE rpositions = Qnil;
1213
1222
  rtext = rb_str_new2(tv_term->text);
1214
1223
  if (tv_term->positions) {
1215
- VALUE *rpos;
1216
1224
  int *positions = tv_term->positions;
1217
1225
  rpositions = rb_ary_new2(freq);
1218
- rpos = RARRAY(rpositions)->ptr;
1219
1226
  for (i = 0; i < freq; i++) {
1220
- rpos[i] = INT2FIX(positions[i]);
1227
+ rb_ary_store(rpositions, i, INT2FIX(positions[i]));
1221
1228
  }
1222
- RARRAY(rpositions)->len = freq;
1223
1229
  }
1224
- return rb_struct_new(cTVTerm, rtext, rpositions, NULL);
1230
+ return rb_struct_new(cTVTerm, rtext, INT2FIX(freq), rpositions, NULL);
1225
1231
  }
1226
1232
 
1227
1233
  /****************************************************************************
@@ -1231,31 +1237,26 @@ frt_get_tv_term(TVTerm *tv_term)
1231
1237
  ****************************************************************************/
1232
1238
 
1233
1239
  static VALUE
1234
- frt_get_tv(TermVector *tv)
1240
+ frb_get_tv(TermVector *tv)
1235
1241
  {
1236
1242
  int i;
1237
1243
  TVTerm *terms = tv->terms;
1238
1244
  const int t_cnt = tv->term_cnt;
1239
1245
  const int o_cnt = tv->offset_cnt;
1240
- VALUE rfield, rterms, *rts;
1246
+ VALUE rfield, rterms;
1241
1247
  VALUE roffsets = Qnil;
1242
- rfield = ID2SYM(rb_intern(tv->field));
1248
+ rfield = FSYM2SYM(tv->field);
1243
1249
 
1244
1250
  rterms = rb_ary_new2(t_cnt);
1245
- rts = RARRAY(rterms)->ptr;
1246
1251
  for (i = 0; i < t_cnt; i++) {
1247
- rts[i] = frt_get_tv_term(&terms[i]);
1248
- RARRAY(rterms)->len++;
1252
+ rb_ary_store(rterms, i, frb_get_tv_term(&terms[i]));
1249
1253
  }
1250
1254
 
1251
1255
  if (tv->offsets) {
1252
- VALUE *ros;
1253
1256
  Offset *offsets = tv->offsets;
1254
1257
  roffsets = rb_ary_new2(o_cnt);
1255
- ros = RARRAY(roffsets)->ptr;
1256
1258
  for (i = 0; i < o_cnt; i++) {
1257
- ros[i] = frt_get_tv_offsets(&offsets[i]);
1258
- RARRAY(roffsets)->len++;
1259
+ rb_ary_store(roffsets, i, frb_get_tv_offsets(&offsets[i]));
1259
1260
  }
1260
1261
  }
1261
1262
 
@@ -1269,18 +1270,18 @@ frt_get_tv(TermVector *tv)
1269
1270
  ****************************************************************************/
1270
1271
 
1271
1272
  void
1272
- frt_iw_free(void *p)
1273
+ frb_iw_free(void *p)
1273
1274
  {
1274
1275
  iw_close((IndexWriter *)p);
1275
1276
  }
1276
1277
 
1277
1278
  void
1278
- frt_iw_mark(void *p)
1279
+ frb_iw_mark(void *p)
1279
1280
  {
1280
1281
  IndexWriter *iw = (IndexWriter *)p;
1281
- frt_gc_mark(iw->analyzer);
1282
- frt_gc_mark(iw->store);
1283
- frt_gc_mark(iw->fis);
1282
+ frb_gc_mark(iw->analyzer);
1283
+ frb_gc_mark(iw->store);
1284
+ frb_gc_mark(iw->fis);
1284
1285
  }
1285
1286
 
1286
1287
  /*
@@ -1292,7 +1293,7 @@ frt_iw_mark(void *p)
1292
1293
  * automatically if not called explicitly.
1293
1294
  */
1294
1295
  static VALUE
1295
- frt_iw_close(VALUE self)
1296
+ frb_iw_close(VALUE self)
1296
1297
  {
1297
1298
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1298
1299
  Frt_Unwrap_Struct(self);
@@ -1325,7 +1326,7 @@ frt_iw_close(VALUE self)
1325
1326
  * See IndexWriter for more options.
1326
1327
  */
1327
1328
  static VALUE
1328
- frt_iw_init(int argc, VALUE *argv, VALUE self)
1329
+ frb_iw_init(int argc, VALUE *argv, VALUE self)
1329
1330
  {
1330
1331
  VALUE roptions, rval;
1331
1332
  bool create = false;
@@ -1344,7 +1345,7 @@ frt_iw_init(int argc, VALUE *argv, VALUE self)
1344
1345
  store = DATA_PTR(rval);
1345
1346
  } else if ((rval = rb_hash_aref(roptions, sym_path)) != Qnil) {
1346
1347
  StringValue(rval);
1347
- frt_create_dir(rval);
1348
+ frb_create_dir(rval);
1348
1349
  store = open_fs_store(rs2s(rval));
1349
1350
  DEREF(store);
1350
1351
  }
@@ -1361,7 +1362,7 @@ frt_iw_init(int argc, VALUE *argv, VALUE self)
1361
1362
  : true;
1362
1363
 
1363
1364
  if ((rval = rb_hash_aref(roptions, sym_analyzer)) != Qnil) {
1364
- analyzer = frt_get_cwrapped_analyzer(rval);
1365
+ analyzer = frb_get_cwrapped_analyzer(rval);
1365
1366
  }
1366
1367
 
1367
1368
  create = RTEST(rb_hash_aref(roptions, sym_create));
@@ -1399,11 +1400,11 @@ frt_iw_init(int argc, VALUE *argv, VALUE self)
1399
1400
 
1400
1401
  iw = iw_open(store, analyzer, &config);
1401
1402
 
1402
- Frt_Wrap_Struct(self, &frt_iw_mark, &frt_iw_free, iw);
1403
+ Frt_Wrap_Struct(self, &frb_iw_mark, &frb_iw_free, iw);
1403
1404
 
1404
1405
  if (rb_block_given_p()) {
1405
1406
  rb_yield(self);
1406
- frt_iw_close(self);
1407
+ frb_iw_close(self);
1407
1408
  return Qnil;
1408
1409
  } else {
1409
1410
  return self;
@@ -1418,35 +1419,22 @@ frt_iw_init(int argc, VALUE *argv, VALUE self)
1418
1419
  * taken into account until the IndexWriter has been committed.
1419
1420
  */
1420
1421
  static VALUE
1421
- frt_iw_get_doc_count(VALUE self)
1422
+ frb_iw_get_doc_count(VALUE self)
1422
1423
  {
1423
1424
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1424
1425
  return INT2FIX(iw_doc_count(iw));
1425
1426
  }
1426
1427
 
1427
1428
  static int
1428
- frt_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
1429
+ frb_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
1429
1430
  {
1430
1431
  if (key == Qundef) {
1431
1432
  return ST_CONTINUE;
1432
1433
  } else {
1433
1434
  Document *doc = (Document *)arg;
1434
- char *field;
1435
+ Symbol field = frb_field(key);
1435
1436
  VALUE val;
1436
1437
  DocField *df;
1437
- switch (TYPE(key)) {
1438
- case T_STRING:
1439
- field = rs2s(key);
1440
- break;
1441
- case T_SYMBOL:
1442
- field = rb_id2name(SYM2ID(key));
1443
- break;
1444
- default:
1445
- rb_raise(rb_eArgError,
1446
- "%s cannot be a key to a field. Field keys must "
1447
- " be symbols.", rs2s(rb_obj_as_string(key)));
1448
- break;
1449
- }
1450
1438
  if (NULL == (df = doc_get_field(doc, field))) {
1451
1439
  df = df_new(field);
1452
1440
  }
@@ -1458,19 +1446,19 @@ frt_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
1458
1446
  {
1459
1447
  int i;
1460
1448
  df->destroy_data = true;
1461
- for (i = 0; i < RARRAY(value)->len; i++) {
1462
- val = rb_obj_as_string(RARRAY(value)->ptr[i]);
1463
- df_add_data_len(df, nstrdup(val), RSTRING(val)->len);
1449
+ for (i = 0; i < RARRAY_LEN(value); i++) {
1450
+ val = rb_obj_as_string(RARRAY_PTR(value)[i]);
1451
+ df_add_data_len(df, rstrdup(val), RSTRING_LEN(val));
1464
1452
  }
1465
1453
  }
1466
1454
  break;
1467
1455
  case T_STRING:
1468
- df_add_data_len(df, rs2s(value), RSTRING(value)->len);
1456
+ df_add_data_len(df, rs2s(value), RSTRING_LEN(value));
1469
1457
  break;
1470
1458
  default:
1471
1459
  val = rb_obj_as_string(value);
1472
1460
  df->destroy_data = true;
1473
- df_add_data_len(df, nstrdup(val), RSTRING(val)->len);
1461
+ df_add_data_len(df, rstrdup(val), RSTRING_LEN(val));
1474
1462
  break;
1475
1463
  }
1476
1464
  doc_add_field(doc, df);
@@ -1479,7 +1467,7 @@ frt_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
1479
1467
  }
1480
1468
 
1481
1469
  static Document *
1482
- frt_get_doc(VALUE rdoc)
1470
+ frb_get_doc(VALUE rdoc)
1483
1471
  {
1484
1472
  VALUE val;
1485
1473
  Document *doc = doc_new();
@@ -1491,33 +1479,34 @@ frt_get_doc(VALUE rdoc)
1491
1479
 
1492
1480
  switch (TYPE(rdoc)) {
1493
1481
  case T_HASH:
1494
- rb_hash_foreach(rdoc, frt_hash_to_doc_i, (VALUE)doc);
1482
+ rb_hash_foreach(rdoc, frb_hash_to_doc_i, (VALUE)doc);
1495
1483
  break;
1496
1484
  case T_ARRAY:
1497
1485
  {
1498
1486
  int i;
1499
- df = df_new("content");
1487
+ df = df_new(fsym_content);
1500
1488
  df->destroy_data = true;
1501
- for (i = 0; i < RARRAY(rdoc)->len; i++) {
1502
- val = rb_obj_as_string(RARRAY(rdoc)->ptr[i]);
1503
- df_add_data_len(df, nstrdup(val), RSTRING(val)->len);
1489
+ for (i = 0; i < RARRAY_LEN(rdoc); i++) {
1490
+ val = rb_obj_as_string(RARRAY_PTR(rdoc)[i]);
1491
+ df_add_data_len(df, rstrdup(val), RSTRING_LEN(val));
1504
1492
  }
1505
1493
  doc_add_field(doc, df);
1506
1494
  }
1507
1495
  break;
1508
1496
  case T_SYMBOL:
1509
- df = df_add_data(df_new("content"), rb_id2name(SYM2ID(rdoc)));
1497
+ /* TODO: clean up this ugly cast */
1498
+ df = df_add_data(df_new(fsym_content), (char *)rb_id2name(SYM2ID(rdoc)));
1510
1499
  doc_add_field(doc, df);
1511
1500
  break;
1512
1501
  case T_STRING:
1513
- df = df_add_data_len(df_new("content"), rs2s(rdoc),
1514
- RSTRING(rdoc)->len);
1502
+ df = df_add_data_len(df_new(fsym_content), rs2s(rdoc),
1503
+ RSTRING_LEN(rdoc));
1515
1504
  doc_add_field(doc, df);
1516
1505
  break;
1517
1506
  default:
1518
1507
  val = rb_obj_as_string(rdoc);
1519
- df = df_add_data_len(df_new("content"), nstrdup(val),
1520
- RSTRING(val)->len);
1508
+ df = df_add_data_len(df_new(fsym_content), rstrdup(val),
1509
+ RSTRING_LEN(val));
1521
1510
  df->destroy_data = true;
1522
1511
  doc_add_field(doc, df);
1523
1512
  break;
@@ -1534,10 +1523,10 @@ frt_get_doc(VALUE rdoc)
1534
1523
  * hash object.
1535
1524
  */
1536
1525
  static VALUE
1537
- frt_iw_add_doc(VALUE self, VALUE rdoc)
1526
+ frb_iw_add_doc(VALUE self, VALUE rdoc)
1538
1527
  {
1539
1528
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1540
- Document *doc = frt_get_doc(rdoc);
1529
+ Document *doc = frb_get_doc(rdoc);
1541
1530
  iw_add_doc(iw, doc);
1542
1531
  doc_destroy(doc);
1543
1532
  return self;
@@ -1556,7 +1545,7 @@ frt_iw_add_doc(VALUE self, VALUE rdoc)
1556
1545
  * process).
1557
1546
  */
1558
1547
  static VALUE
1559
- frt_iw_optimize(VALUE self)
1548
+ frb_iw_optimize(VALUE self)
1560
1549
  {
1561
1550
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1562
1551
  iw_optimize(iw);
@@ -1572,7 +1561,7 @@ frt_iw_optimize(VALUE self)
1572
1561
  * with an IndexWriter.
1573
1562
  */
1574
1563
  static VALUE
1575
- frt_iw_commit(VALUE self)
1564
+ frb_iw_commit(VALUE self)
1576
1565
  {
1577
1566
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1578
1567
  iw_commit(iw);
@@ -1590,39 +1579,52 @@ frt_iw_commit(VALUE self)
1590
1579
  * index.
1591
1580
  */
1592
1581
  static VALUE
1593
- frt_iw_add_readers(VALUE self, VALUE rreaders)
1582
+ frb_iw_add_readers(VALUE self, VALUE rreaders)
1594
1583
  {
1595
1584
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1596
1585
  int i;
1597
1586
  IndexReader **irs;
1598
1587
  Check_Type(rreaders, T_ARRAY);
1599
1588
 
1600
- irs = ALLOC_N(IndexReader *, RARRAY(rreaders)->len);
1601
- i = RARRAY(rreaders)->len;
1589
+ irs = ALLOC_N(IndexReader *, RARRAY_LEN(rreaders));
1590
+ i = RARRAY_LEN(rreaders);
1602
1591
  while (i-- > 0) {
1603
1592
  IndexReader *ir;
1604
- Data_Get_Struct(RARRAY(rreaders)->ptr[i], IndexReader, ir);
1593
+ Data_Get_Struct(RARRAY_PTR(rreaders)[i], IndexReader, ir);
1605
1594
  irs[i] = ir;
1606
1595
  }
1607
- iw_add_readers(iw, irs, RARRAY(rreaders)->len);
1596
+ iw_add_readers(iw, irs, RARRAY_LEN(rreaders));
1608
1597
  free(irs);
1609
1598
  return self;
1610
1599
  }
1611
1600
 
1612
1601
  /*
1613
1602
  * call-seq:
1614
- * iw.delete(field, term) -> iw
1603
+ * iw.delete(field, term) -> iw
1604
+ * iw.delete(field, terms) -> iw
1615
1605
  *
1616
- * Delete all documents in the index with the term +term+ in the field
1617
- * +field+. You should usually have a unique document id which you use with
1618
- * this method, rather then deleting all documents with the word "the" in
1619
- * them. You may however use this method to delete spam.
1606
+ * Delete all documents in the index with the given +term+ or +terms+ in the
1607
+ * field +field+. You should usually have a unique document id which you use
1608
+ * with this method, rather then deleting all documents with the word "the"
1609
+ * in them. There are of course exceptions to this rule. For example, you may
1610
+ * want to delete all documents with the term "viagra" when deleting spam.
1620
1611
  */
1621
1612
  static VALUE
1622
- frt_iw_delete(VALUE self, VALUE rfield, VALUE rterm)
1613
+ frb_iw_delete(VALUE self, VALUE rfield, VALUE rterm)
1623
1614
  {
1624
1615
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1625
- iw_delete_term(iw, frt_field(rfield), StringValuePtr(rterm));
1616
+ if (TYPE(rterm) == T_ARRAY) {
1617
+ const int term_cnt = RARRAY_LEN(rterm);
1618
+ int i;
1619
+ char **terms = ALLOC_N(char *, term_cnt);
1620
+ for (i = 0; i < term_cnt; i++) {
1621
+ terms[i] = StringValuePtr(RARRAY_PTR(rterm)[i]);
1622
+ }
1623
+ iw_delete_terms(iw, frb_field(rfield), terms, term_cnt);
1624
+ free(terms);
1625
+ } else {
1626
+ iw_delete_term(iw, frb_field(rfield), StringValuePtr(rterm));
1627
+ }
1626
1628
  return self;
1627
1629
  }
1628
1630
 
@@ -1634,10 +1636,10 @@ frt_iw_delete(VALUE self, VALUE rfield, VALUE rterm)
1634
1636
  * to dynamically add new fields to the index with specific properties.
1635
1637
  */
1636
1638
  static VALUE
1637
- frt_iw_field_infos(VALUE self)
1639
+ frb_iw_field_infos(VALUE self)
1638
1640
  {
1639
1641
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1640
- return frt_get_field_infos(iw->fis);
1642
+ return frb_get_field_infos(iw->fis);
1641
1643
  }
1642
1644
 
1643
1645
  /*
@@ -1648,10 +1650,10 @@ frt_iw_field_infos(VALUE self)
1648
1650
  * to use the same analyzer in a QueryParser.
1649
1651
  */
1650
1652
  static VALUE
1651
- frt_iw_get_analyzer(VALUE self)
1653
+ frb_iw_get_analyzer(VALUE self)
1652
1654
  {
1653
1655
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1654
- return frt_get_analyzer(iw->analyzer);
1656
+ return frb_get_analyzer(iw->analyzer);
1655
1657
  }
1656
1658
 
1657
1659
  /*
@@ -1663,12 +1665,12 @@ frt_iw_get_analyzer(VALUE self)
1663
1665
  * same analyzer will be used for all documents during search.
1664
1666
  */
1665
1667
  static VALUE
1666
- frt_iw_set_analyzer(VALUE self, VALUE ranalyzer)
1668
+ frb_iw_set_analyzer(VALUE self, VALUE ranalyzer)
1667
1669
  {
1668
1670
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1669
1671
 
1670
1672
  a_deref(iw->analyzer);
1671
- iw->analyzer = frt_get_cwrapped_analyzer(ranalyzer);
1673
+ iw->analyzer = frb_get_cwrapped_analyzer(ranalyzer);
1672
1674
  return ranalyzer;
1673
1675
  }
1674
1676
 
@@ -1679,7 +1681,7 @@ frt_iw_set_analyzer(VALUE self, VALUE ranalyzer)
1679
1681
  * Returns the current version of the index writer.
1680
1682
  */
1681
1683
  static VALUE
1682
- frt_iw_version(VALUE self)
1684
+ frb_iw_version(VALUE self)
1683
1685
  {
1684
1686
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1685
1687
  return ULL2NUM(iw->sis->version);
@@ -1692,7 +1694,7 @@ frt_iw_version(VALUE self)
1692
1694
  * Return the current value of chunk_size
1693
1695
  */
1694
1696
  static VALUE
1695
- frt_iw_get_chunk_size(VALUE self)
1697
+ frb_iw_get_chunk_size(VALUE self)
1696
1698
  {
1697
1699
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1698
1700
  return INT2FIX(iw->config.chunk_size);
@@ -1705,7 +1707,7 @@ frt_iw_get_chunk_size(VALUE self)
1705
1707
  * Set the chunk_size parameter
1706
1708
  */
1707
1709
  static VALUE
1708
- frt_iw_set_chunk_size(VALUE self, VALUE rval)
1710
+ frb_iw_set_chunk_size(VALUE self, VALUE rval)
1709
1711
  {
1710
1712
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1711
1713
  iw->config.chunk_size = FIX2INT(rval);
@@ -1719,7 +1721,7 @@ frt_iw_set_chunk_size(VALUE self, VALUE rval)
1719
1721
  * Return the current value of max_buffer_memory
1720
1722
  */
1721
1723
  static VALUE
1722
- frt_iw_get_max_buffer_memory(VALUE self)
1724
+ frb_iw_get_max_buffer_memory(VALUE self)
1723
1725
  {
1724
1726
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1725
1727
  return INT2FIX(iw->config.max_buffer_memory);
@@ -1732,7 +1734,7 @@ frt_iw_get_max_buffer_memory(VALUE self)
1732
1734
  * Set the max_buffer_memory parameter
1733
1735
  */
1734
1736
  static VALUE
1735
- frt_iw_set_max_buffer_memory(VALUE self, VALUE rval)
1737
+ frb_iw_set_max_buffer_memory(VALUE self, VALUE rval)
1736
1738
  {
1737
1739
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1738
1740
  iw->config.max_buffer_memory = FIX2INT(rval);
@@ -1746,7 +1748,7 @@ frt_iw_set_max_buffer_memory(VALUE self, VALUE rval)
1746
1748
  * Return the current value of term_index_interval
1747
1749
  */
1748
1750
  static VALUE
1749
- frt_iw_get_index_interval(VALUE self)
1751
+ frb_iw_get_index_interval(VALUE self)
1750
1752
  {
1751
1753
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1752
1754
  return INT2FIX(iw->config.index_interval);
@@ -1759,7 +1761,7 @@ frt_iw_get_index_interval(VALUE self)
1759
1761
  * Set the term_index_interval parameter
1760
1762
  */
1761
1763
  static VALUE
1762
- frt_iw_set_index_interval(VALUE self, VALUE rval)
1764
+ frb_iw_set_index_interval(VALUE self, VALUE rval)
1763
1765
  {
1764
1766
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1765
1767
  iw->config.index_interval = FIX2INT(rval);
@@ -1773,7 +1775,7 @@ frt_iw_set_index_interval(VALUE self, VALUE rval)
1773
1775
  * Return the current value of doc_skip_interval
1774
1776
  */
1775
1777
  static VALUE
1776
- frt_iw_get_skip_interval(VALUE self)
1778
+ frb_iw_get_skip_interval(VALUE self)
1777
1779
  {
1778
1780
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1779
1781
  return INT2FIX(iw->config.skip_interval);
@@ -1786,7 +1788,7 @@ frt_iw_get_skip_interval(VALUE self)
1786
1788
  * Set the doc_skip_interval parameter
1787
1789
  */
1788
1790
  static VALUE
1789
- frt_iw_set_skip_interval(VALUE self, VALUE rval)
1791
+ frb_iw_set_skip_interval(VALUE self, VALUE rval)
1790
1792
  {
1791
1793
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1792
1794
  iw->config.skip_interval = FIX2INT(rval);
@@ -1800,7 +1802,7 @@ frt_iw_set_skip_interval(VALUE self, VALUE rval)
1800
1802
  * Return the current value of merge_factor
1801
1803
  */
1802
1804
  static VALUE
1803
- frt_iw_get_merge_factor(VALUE self)
1805
+ frb_iw_get_merge_factor(VALUE self)
1804
1806
  {
1805
1807
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1806
1808
  return INT2FIX(iw->config.merge_factor);
@@ -1813,7 +1815,7 @@ frt_iw_get_merge_factor(VALUE self)
1813
1815
  * Set the merge_factor parameter
1814
1816
  */
1815
1817
  static VALUE
1816
- frt_iw_set_merge_factor(VALUE self, VALUE rval)
1818
+ frb_iw_set_merge_factor(VALUE self, VALUE rval)
1817
1819
  {
1818
1820
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1819
1821
  iw->config.merge_factor = FIX2INT(rval);
@@ -1827,7 +1829,7 @@ frt_iw_set_merge_factor(VALUE self, VALUE rval)
1827
1829
  * Return the current value of max_buffered_docs
1828
1830
  */
1829
1831
  static VALUE
1830
- frt_iw_get_max_buffered_docs(VALUE self)
1832
+ frb_iw_get_max_buffered_docs(VALUE self)
1831
1833
  {
1832
1834
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1833
1835
  return INT2FIX(iw->config.max_buffered_docs);
@@ -1840,7 +1842,7 @@ frt_iw_get_max_buffered_docs(VALUE self)
1840
1842
  * Set the max_buffered_docs parameter
1841
1843
  */
1842
1844
  static VALUE
1843
- frt_iw_set_max_buffered_docs(VALUE self, VALUE rval)
1845
+ frb_iw_set_max_buffered_docs(VALUE self, VALUE rval)
1844
1846
  {
1845
1847
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1846
1848
  iw->config.max_buffered_docs = FIX2INT(rval);
@@ -1854,7 +1856,7 @@ frt_iw_set_max_buffered_docs(VALUE self, VALUE rval)
1854
1856
  * Return the current value of max_merge_docs
1855
1857
  */
1856
1858
  static VALUE
1857
- frt_iw_get_max_merge_docs(VALUE self)
1859
+ frb_iw_get_max_merge_docs(VALUE self)
1858
1860
  {
1859
1861
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1860
1862
  return INT2FIX(iw->config.max_merge_docs);
@@ -1867,7 +1869,7 @@ frt_iw_get_max_merge_docs(VALUE self)
1867
1869
  * Set the max_merge_docs parameter
1868
1870
  */
1869
1871
  static VALUE
1870
- frt_iw_set_max_merge_docs(VALUE self, VALUE rval)
1872
+ frb_iw_set_max_merge_docs(VALUE self, VALUE rval)
1871
1873
  {
1872
1874
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1873
1875
  iw->config.max_merge_docs = FIX2INT(rval);
@@ -1881,7 +1883,7 @@ frt_iw_set_max_merge_docs(VALUE self, VALUE rval)
1881
1883
  * Return the current value of max_field_length
1882
1884
  */
1883
1885
  static VALUE
1884
- frt_iw_get_max_field_length(VALUE self)
1886
+ frb_iw_get_max_field_length(VALUE self)
1885
1887
  {
1886
1888
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1887
1889
  return INT2FIX(iw->config.max_field_length);
@@ -1894,7 +1896,7 @@ frt_iw_get_max_field_length(VALUE self)
1894
1896
  * Set the max_field_length parameter
1895
1897
  */
1896
1898
  static VALUE
1897
- frt_iw_set_max_field_length(VALUE self, VALUE rval)
1899
+ frb_iw_set_max_field_length(VALUE self, VALUE rval)
1898
1900
  {
1899
1901
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1900
1902
  iw->config.max_field_length = FIX2INT(rval);
@@ -1908,7 +1910,7 @@ frt_iw_set_max_field_length(VALUE self, VALUE rval)
1908
1910
  * Return the current value of use_compound_file
1909
1911
  */
1910
1912
  static VALUE
1911
- frt_iw_get_use_compound_file(VALUE self)
1913
+ frb_iw_get_use_compound_file(VALUE self)
1912
1914
  {
1913
1915
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1914
1916
  return iw->config.use_compound_file ? Qtrue : Qfalse;
@@ -1921,7 +1923,7 @@ frt_iw_get_use_compound_file(VALUE self)
1921
1923
  * Set the use_compound_file parameter
1922
1924
  */
1923
1925
  static VALUE
1924
- frt_iw_set_use_compound_file(VALUE self, VALUE rval)
1926
+ frb_iw_set_use_compound_file(VALUE self, VALUE rval)
1925
1927
  {
1926
1928
  IndexWriter *iw = (IndexWriter *)DATA_PTR(self);
1927
1929
  iw->config.use_compound_file = RTEST(rval);
@@ -1935,13 +1937,13 @@ frt_iw_set_use_compound_file(VALUE self, VALUE rval)
1935
1937
  ****************************************************************************/
1936
1938
 
1937
1939
  static void
1938
- frt_lzd_date_free(void *p)
1940
+ frb_lzd_date_free(void *p)
1939
1941
  {
1940
1942
  lazy_doc_close((LazyDoc *)p);
1941
1943
  }
1942
1944
 
1943
1945
  static VALUE
1944
- frt_lazy_df_load(VALUE self, VALUE rkey, LazyDocField *lazy_df)
1946
+ frb_lazy_df_load(VALUE self, VALUE rkey, LazyDocField *lazy_df)
1945
1947
  {
1946
1948
  VALUE rdata = Qnil;
1947
1949
  if (lazy_df) {
@@ -1953,9 +1955,7 @@ frt_lazy_df_load(VALUE self, VALUE rkey, LazyDocField *lazy_df)
1953
1955
  rdata = rb_ary_new2(lazy_df->size);
1954
1956
  for (i = 0; i < lazy_df->size; i++) {
1955
1957
  char *data = lazy_df_get_data(lazy_df, i);
1956
- RARRAY(rdata)->ptr[i] =
1957
- rb_str_new(data, lazy_df->data[i].length);
1958
- RARRAY(rdata)->len++;
1958
+ rb_ary_store(rdata, i, rb_str_new(data, lazy_df->data[i].length));
1959
1959
  }
1960
1960
  }
1961
1961
  rb_hash_aset(self, rkey, rdata);
@@ -1971,25 +1971,13 @@ frt_lazy_df_load(VALUE self, VALUE rkey, LazyDocField *lazy_df)
1971
1971
  * really need to call it yourself.
1972
1972
  */
1973
1973
  static VALUE
1974
- frt_lzd_default(VALUE self, VALUE rkey)
1974
+ frb_lzd_default(VALUE self, VALUE rkey)
1975
1975
  {
1976
1976
  LazyDoc *lazy_doc = (LazyDoc *)DATA_PTR(rb_ivar_get(self, id_data));
1977
- char *field = NULL;
1978
- switch (TYPE(rkey)) {
1979
- case T_STRING:
1980
- field = rs2s(rkey);
1981
- rkey = ID2SYM(rb_intern(field));
1982
- break;
1983
- case T_SYMBOL:
1984
- field = frt_field(rkey);
1985
- break;
1986
- default:
1987
- rb_raise(rb_eArgError,
1988
- "%s cannot be a key to a field. Field keys must "
1989
- " be symbols.", rs2s(rb_obj_as_string(rkey)));
1990
- break;
1991
- }
1992
- return frt_lazy_df_load(self, rkey, h_get(lazy_doc->field_dict, field));
1977
+ Symbol field = frb_field(rkey);
1978
+ VALUE rfield = FSYM2SYM(field);
1979
+
1980
+ return frb_lazy_df_load(self, rfield, lazy_doc_get(lazy_doc, field));
1993
1981
  }
1994
1982
 
1995
1983
  /*
@@ -2001,7 +1989,7 @@ frt_lzd_default(VALUE self, VALUE rkey)
2001
1989
  * Try to access any other field an nil will be returned.
2002
1990
  */
2003
1991
  static VALUE
2004
- frt_lzd_fields(VALUE self)
1992
+ frb_lzd_fields(VALUE self)
2005
1993
  {
2006
1994
  return rb_ivar_get(self, id_fields);
2007
1995
  }
@@ -2013,19 +2001,19 @@ frt_lzd_fields(VALUE self)
2013
2001
  * Load all unloaded fields in the document from the index.
2014
2002
  */
2015
2003
  static VALUE
2016
- frt_lzd_load(VALUE self)
2004
+ frb_lzd_load(VALUE self)
2017
2005
  {
2018
2006
  LazyDoc *lazy_doc = (LazyDoc *)DATA_PTR(rb_ivar_get(self, id_data));
2019
2007
  int i;
2020
2008
  for (i = 0; i < lazy_doc->size; i++) {
2021
2009
  LazyDocField *lazy_df = lazy_doc->fields[i];
2022
- frt_lazy_df_load(self, ID2SYM(rb_intern(lazy_df->name)), lazy_df);
2010
+ frb_lazy_df_load(self, FSYM2SYM(lazy_df->name), lazy_df);
2023
2011
  }
2024
2012
  return self;
2025
2013
  }
2026
2014
 
2027
2015
  VALUE
2028
- frt_get_lazy_doc(LazyDoc *lazy_doc)
2016
+ frb_get_lazy_doc(LazyDoc *lazy_doc)
2029
2017
  {
2030
2018
  int i;
2031
2019
  VALUE rfields = rb_ary_new2(lazy_doc->size);
@@ -2034,12 +2022,11 @@ frt_get_lazy_doc(LazyDoc *lazy_doc)
2034
2022
  self = rb_hash_new();
2035
2023
  OBJSETUP(self, cLazyDoc, T_HASH);
2036
2024
 
2037
- rdata = Data_Wrap_Struct(cLazyDocData, NULL, &frt_lzd_date_free, lazy_doc);
2025
+ rdata = Data_Wrap_Struct(cLazyDocData, NULL, &frb_lzd_date_free, lazy_doc);
2038
2026
  rb_ivar_set(self, id_data, rdata);
2039
2027
 
2040
2028
  for (i = 0; i < lazy_doc->size; i++) {
2041
- RARRAY(rfields)->ptr[i] = ID2SYM(rb_intern(lazy_doc->fields[i]->name));
2042
- RARRAY(rfields)->len++;
2029
+ rb_ary_store(rfields, i, FSYM2SYM(lazy_doc->fields[i]->name));
2043
2030
  }
2044
2031
  rb_ivar_set(self, id_fields, rfields);
2045
2032
 
@@ -2053,28 +2040,28 @@ frt_get_lazy_doc(LazyDoc *lazy_doc)
2053
2040
  ****************************************************************************/
2054
2041
 
2055
2042
  void
2056
- frt_ir_free(void *p)
2043
+ frb_ir_free(void *p)
2057
2044
  {
2058
2045
  object_del(p);
2059
2046
  ir_close((IndexReader *)p);
2060
2047
  }
2061
2048
 
2062
2049
  void
2063
- frt_ir_mark(void *p)
2050
+ frb_ir_mark(void *p)
2064
2051
  {
2065
2052
  IndexReader *ir = (IndexReader *)p;
2066
- frt_gc_mark(ir->store);
2053
+ frb_gc_mark(ir->store);
2067
2054
  }
2068
2055
 
2069
- static VALUE frt_ir_close(VALUE self);
2056
+ static VALUE frb_ir_close(VALUE self);
2070
2057
 
2071
2058
  void
2072
- frt_mr_mark(void *p)
2059
+ frb_mr_mark(void *p)
2073
2060
  {
2074
2061
  MultiReader *mr = (MultiReader *)p;
2075
2062
  int i;
2076
2063
  for (i = 0; i < mr->r_cnt; i++) {
2077
- frt_gc_mark(mr->sub_readers[i]);
2064
+ frb_gc_mark(mr->sub_readers[i]);
2078
2065
  }
2079
2066
  }
2080
2067
 
@@ -2105,7 +2092,7 @@ frt_mr_mark(void *p)
2105
2092
  * iw = IndexReader.new(["/path/to/index1", "/path/to/index2"])
2106
2093
  */
2107
2094
  static VALUE
2108
- frt_ir_init(VALUE self, VALUE rdir)
2095
+ frb_ir_init(VALUE self, VALUE rdir)
2109
2096
  {
2110
2097
  Store *store = NULL;
2111
2098
  IndexReader *ir;
@@ -2115,11 +2102,11 @@ frt_ir_init(VALUE self, VALUE rdir)
2115
2102
 
2116
2103
  if (TYPE(rdir) == T_ARRAY) {
2117
2104
  VALUE rdirs = rdir;
2118
- const int reader_cnt = RARRAY(rdir)->len;
2105
+ const int reader_cnt = RARRAY_LEN(rdir);
2119
2106
  IndexReader **sub_readers = ALLOC_N(IndexReader *, reader_cnt);
2120
2107
  int i;
2121
2108
  for (i = 0; i < reader_cnt; i++) {
2122
- rdir = RARRAY(rdirs)->ptr[i];
2109
+ rdir = RARRAY_PTR(rdirs)[i];
2123
2110
  switch (TYPE(rdir)) {
2124
2111
  case T_DATA:
2125
2112
  if (CLASS_OF(rdir) == cIndexReader) {
@@ -2137,7 +2124,7 @@ frt_ir_init(VALUE self, VALUE rdir)
2137
2124
  }
2138
2125
  break;
2139
2126
  case T_STRING:
2140
- frt_create_dir(rdir);
2127
+ frb_create_dir(rdir);
2141
2128
  store = open_fs_store(rs2s(rdir));
2142
2129
  DEREF(store);
2143
2130
  break;
@@ -2151,14 +2138,14 @@ frt_ir_init(VALUE self, VALUE rdir)
2151
2138
  sub_readers[i] = ir_open(store);
2152
2139
  }
2153
2140
  ir = mr_open(sub_readers, reader_cnt);
2154
- Frt_Wrap_Struct(self, &frt_mr_mark, &frt_ir_free, ir);
2141
+ Frt_Wrap_Struct(self, &frb_mr_mark, &frb_ir_free, ir);
2155
2142
  } else {
2156
2143
  switch (TYPE(rdir)) {
2157
2144
  case T_DATA:
2158
2145
  store = DATA_PTR(rdir);
2159
2146
  break;
2160
2147
  case T_STRING:
2161
- frt_create_dir(rdir);
2148
+ frb_create_dir(rdir);
2162
2149
  store = open_fs_store(rs2s(rdir));
2163
2150
  DEREF(store);
2164
2151
  break;
@@ -2169,7 +2156,7 @@ frt_ir_init(VALUE self, VALUE rdir)
2169
2156
  break;
2170
2157
  }
2171
2158
  ir = ir_open(store);
2172
- Frt_Wrap_Struct(self, &frt_ir_mark, &frt_ir_free, ir);
2159
+ Frt_Wrap_Struct(self, &frb_ir_mark, &frb_ir_free, ir);
2173
2160
  }
2174
2161
  object_add(ir, self);
2175
2162
 
@@ -2177,7 +2164,7 @@ frt_ir_init(VALUE self, VALUE rdir)
2177
2164
  for (i = 0; i < fis->size; i++) {
2178
2165
  FieldInfo *fi = fis->fields[i];
2179
2166
  rb_hash_aset(rfield_num_map,
2180
- ID2SYM(rb_intern(fi->name)),
2167
+ FSYM2SYM(fi->name),
2181
2168
  INT2FIX(fi->number));
2182
2169
  }
2183
2170
  rb_ivar_set(self, id_fld_num_map, rfield_num_map);
@@ -2194,10 +2181,10 @@ frt_ir_init(VALUE self, VALUE rdir)
2194
2181
  * encoded float value.
2195
2182
  */
2196
2183
  static VALUE
2197
- frt_ir_set_norm(VALUE self, VALUE rdoc_id, VALUE rfield, VALUE rval)
2184
+ frb_ir_set_norm(VALUE self, VALUE rdoc_id, VALUE rfield, VALUE rval)
2198
2185
  {
2199
2186
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2200
- ir_set_norm(ir, FIX2INT(rdoc_id), frt_field(rfield), (uchar)NUM2CHR(rval));
2187
+ ir_set_norm(ir, FIX2INT(rdoc_id), frb_field(rfield), (uchar)NUM2CHR(rval));
2201
2188
  return self;
2202
2189
  }
2203
2190
 
@@ -2210,11 +2197,11 @@ frt_ir_set_norm(VALUE self, VALUE rdoc_id, VALUE rfield, VALUE rval)
2210
2197
  * could have null bytes.
2211
2198
  */
2212
2199
  static VALUE
2213
- frt_ir_norms(VALUE self, VALUE rfield)
2200
+ frb_ir_norms(VALUE self, VALUE rfield)
2214
2201
  {
2215
2202
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2216
2203
  uchar *norms;
2217
- norms = ir_get_norms(ir, frt_field(rfield));
2204
+ norms = ir_get_norms(ir, frb_field(rfield));
2218
2205
  if (norms) {
2219
2206
  return rb_str_new((char *)norms, ir->max_doc(ir));
2220
2207
  } else {
@@ -2229,20 +2216,20 @@ frt_ir_norms(VALUE self, VALUE rfield)
2229
2216
  * Expert: Get the norm values into a string +buffer+ starting at +offset+.
2230
2217
  */
2231
2218
  static VALUE
2232
- frt_ir_get_norms_into(VALUE self, VALUE rfield, VALUE rnorms, VALUE roffset)
2219
+ frb_ir_get_norms_into(VALUE self, VALUE rfield, VALUE rnorms, VALUE roffset)
2233
2220
  {
2234
2221
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2235
2222
  int offset;
2236
2223
  offset = FIX2INT(roffset);
2237
2224
  Check_Type(rnorms, T_STRING);
2238
- if (RSTRING(rnorms)->len < offset + ir->max_doc(ir)) {
2239
- rb_raise(rb_eArgError, "supplied a string of length:%d to "
2225
+ if (RSTRING_LEN(rnorms) < offset + ir->max_doc(ir)) {
2226
+ rb_raise(rb_eArgError, "supplied a string of length:%ld to "
2240
2227
  "IndexReader#get_norms_into but needed a string of length "
2241
2228
  "offset:%d + maxdoc:%d",
2242
- RSTRING(rnorms)->len, offset, ir->max_doc(ir));
2229
+ RSTRING_LEN(rnorms), offset, ir->max_doc(ir));
2243
2230
  }
2244
2231
 
2245
- ir_get_norms_into(ir, frt_field(rfield),
2232
+ ir_get_norms_into(ir, frb_field(rfield),
2246
2233
  (uchar *)rs2s(rnorms) + offset);
2247
2234
  return rnorms;
2248
2235
  }
@@ -2255,7 +2242,7 @@ frt_ir_get_norms_into(VALUE self, VALUE rfield, VALUE rnorms, VALUE roffset)
2255
2242
  * will use open a Commit lock.
2256
2243
  */
2257
2244
  static VALUE
2258
- frt_ir_commit(VALUE self)
2245
+ frb_ir_commit(VALUE self)
2259
2246
  {
2260
2247
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2261
2248
  ir_commit(ir);
@@ -2273,7 +2260,7 @@ frt_ir_commit(VALUE self)
2273
2260
  * errors.
2274
2261
  */
2275
2262
  static VALUE
2276
- frt_ir_close(VALUE self)
2263
+ frb_ir_close(VALUE self)
2277
2264
  {
2278
2265
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2279
2266
  object_del(ir);
@@ -2290,7 +2277,7 @@ frt_ir_close(VALUE self)
2290
2277
  * IndexReader or committed by any other IndexReader.
2291
2278
  */
2292
2279
  static VALUE
2293
- frt_ir_has_deletions(VALUE self)
2280
+ frb_ir_has_deletions(VALUE self)
2294
2281
  {
2295
2282
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2296
2283
  return ir->has_deletions(ir) ? Qtrue : Qfalse;
@@ -2305,7 +2292,7 @@ frt_ir_has_deletions(VALUE self)
2305
2292
  * returned by search methods.
2306
2293
  */
2307
2294
  static VALUE
2308
- frt_ir_delete(VALUE self, VALUE rdoc_id)
2295
+ frb_ir_delete(VALUE self, VALUE rdoc_id)
2309
2296
  {
2310
2297
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2311
2298
  ir_delete_doc(ir, FIX2INT(rdoc_id));
@@ -2319,7 +2306,7 @@ frt_ir_delete(VALUE self, VALUE rdoc_id)
2319
2306
  * Returns true if the document at +doc_id+ has been deleted.
2320
2307
  */
2321
2308
  static VALUE
2322
- frt_ir_is_deleted(VALUE self, VALUE rdoc_id)
2309
+ frb_ir_is_deleted(VALUE self, VALUE rdoc_id)
2323
2310
  {
2324
2311
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2325
2312
  return ir->is_deleted(ir, FIX2INT(rdoc_id)) ? Qtrue : Qfalse;
@@ -2335,7 +2322,7 @@ frt_ir_is_deleted(VALUE self, VALUE rdoc_id)
2335
2322
  * in the index.
2336
2323
  */
2337
2324
  static VALUE
2338
- frt_ir_max_doc(VALUE self)
2325
+ frb_ir_max_doc(VALUE self)
2339
2326
  {
2340
2327
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2341
2328
  return INT2FIX(ir->max_doc(ir));
@@ -2350,7 +2337,7 @@ frt_ir_max_doc(VALUE self)
2350
2337
  * deleted from the index.
2351
2338
  */
2352
2339
  static VALUE
2353
- frt_ir_num_docs(VALUE self)
2340
+ frb_ir_num_docs(VALUE self)
2354
2341
  {
2355
2342
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2356
2343
  return INT2FIX(ir->num_docs(ir));
@@ -2366,7 +2353,7 @@ frt_ir_num_docs(VALUE self)
2366
2353
  * effect on these documents.
2367
2354
  */
2368
2355
  static VALUE
2369
- frt_ir_undelete_all(VALUE self)
2356
+ frb_ir_undelete_all(VALUE self)
2370
2357
  {
2371
2358
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2372
2359
  ir_undelete_all(ir);
@@ -2374,7 +2361,7 @@ frt_ir_undelete_all(VALUE self)
2374
2361
  }
2375
2362
 
2376
2363
  static VALUE
2377
- frt_get_doc_range(IndexReader *ir, int pos, int len, int max)
2364
+ frb_get_doc_range(IndexReader *ir, int pos, int len, int max)
2378
2365
  {
2379
2366
  VALUE ary;
2380
2367
  int i;
@@ -2382,8 +2369,7 @@ frt_get_doc_range(IndexReader *ir, int pos, int len, int max)
2382
2369
  len = max - pos;
2383
2370
  ary = rb_ary_new2(len);
2384
2371
  for (i = 0; i < len; i++) {
2385
- RARRAY(ary)->ptr[i] = frt_get_lazy_doc(ir->get_lazy_doc(ir, i + pos));
2386
- RARRAY(ary)->len++;
2372
+ rb_ary_store(ary, i, frb_get_lazy_doc(ir->get_lazy_doc(ir, i + pos)));
2387
2373
  }
2388
2374
  return ary;
2389
2375
  }
@@ -2398,7 +2384,7 @@ frt_get_doc_range(IndexReader *ir, int pos, int len, int max)
2398
2384
  * which are returned by the Searchers search methods.
2399
2385
  */
2400
2386
  static VALUE
2401
- frt_ir_get_doc(int argc, VALUE *argv, VALUE self)
2387
+ frb_ir_get_doc(int argc, VALUE *argv, VALUE self)
2402
2388
  {
2403
2389
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2404
2390
  VALUE arg1, arg2;
@@ -2410,29 +2396,29 @@ frt_ir_get_doc(int argc, VALUE *argv, VALUE self)
2410
2396
  pos = FIX2INT(arg1);
2411
2397
  pos = (pos < 0) ? (max + pos) : pos;
2412
2398
  if (pos < 0 || pos >= max) {
2413
- rb_raise(rb_eArgError, ":%d is out of range [%d..%d] for "
2414
- "IndexReader#[]", pos, 0, max,
2415
- rb_id2name(SYM2ID(argv)));
2399
+ rb_raise(rb_eArgError, "index %ld is out of range [%d..%ld] for "
2400
+ "IndexReader#[]", pos, 0, max);
2416
2401
  }
2417
- return frt_get_lazy_doc(ir->get_lazy_doc(ir, pos));
2402
+ return frb_get_lazy_doc(ir->get_lazy_doc(ir, pos));
2418
2403
  }
2419
2404
 
2420
2405
  /* check if idx is Range */
2406
+ /* FIXME: test this with dodgy values */
2421
2407
  switch (rb_range_beg_len(arg1, &pos, &len, max, 0)) {
2422
2408
  case Qfalse:
2423
2409
  rb_raise(rb_eArgError, ":%s isn't a valid argument for "
2424
2410
  "IndexReader.get_document(index)",
2425
- rb_id2name(SYM2ID(argv)));
2411
+ rb_id2name(SYM2ID(arg1)));
2426
2412
  case Qnil:
2427
2413
  return Qnil;
2428
2414
  default:
2429
- return frt_get_doc_range(ir, pos, len, max);
2415
+ return frb_get_doc_range(ir, pos, len, max);
2430
2416
  }
2431
2417
  }
2432
2418
  else {
2433
2419
  pos = FIX2LONG(arg1);
2434
2420
  len = FIX2LONG(arg2);
2435
- return frt_get_doc_range(ir, pos, len, max);
2421
+ return frb_get_doc_range(ir, pos, len, max);
2436
2422
  }
2437
2423
  }
2438
2424
 
@@ -2445,7 +2431,7 @@ frt_ir_get_doc(int argc, VALUE *argv, VALUE self)
2445
2431
  * index to search the latest documents added to the index.
2446
2432
  */
2447
2433
  static VALUE
2448
- frt_ir_is_latest(VALUE self)
2434
+ frb_ir_is_latest(VALUE self)
2449
2435
  {
2450
2436
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2451
2437
  return ir_is_latest(ir) ? Qtrue : Qfalse;
@@ -2456,17 +2442,17 @@ frt_ir_is_latest(VALUE self)
2456
2442
  * index_reader.term_vector(doc_id, field) -> TermVector
2457
2443
  *
2458
2444
  * Return the TermVector for the field +field+ in the document at +doc_id+ in
2459
- * the index. Return nil of no such term_vector exists. See TermVector.
2445
+ * the index. Return nil if no such term_vector exists. See TermVector.
2460
2446
  */
2461
2447
  static VALUE
2462
- frt_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
2448
+ frb_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
2463
2449
  {
2464
2450
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2465
2451
  TermVector *tv;
2466
2452
  VALUE rtv;
2467
- tv = ir->term_vector(ir, FIX2INT(rdoc_id), frt_field(rfield));
2453
+ tv = ir->term_vector(ir, FIX2INT(rdoc_id), frb_field(rfield));
2468
2454
  if (tv) {
2469
- rtv = frt_get_tv(tv);
2455
+ rtv = frb_get_tv(tv);
2470
2456
  tv_destroy(tv);
2471
2457
  return rtv;
2472
2458
  }
@@ -2476,9 +2462,9 @@ frt_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
2476
2462
  }
2477
2463
 
2478
2464
  static void
2479
- frt_add_each_tv(void *key, void *value, void *rtvs)
2465
+ frb_add_each_tv(void *key, void *value, void *rtvs)
2480
2466
  {
2481
- rb_hash_aset((VALUE)rtvs, ID2SYM(rb_intern(key)), frt_get_tv(value));
2467
+ rb_hash_aset((VALUE)rtvs, ID2SYM((ID)key), frb_get_tv(value));
2482
2468
  }
2483
2469
 
2484
2470
  /*
@@ -2490,12 +2476,12 @@ frt_add_each_tv(void *key, void *value, void *rtvs)
2490
2476
  * and they are referenced by field names (as symbols).
2491
2477
  */
2492
2478
  static VALUE
2493
- frt_ir_term_vectors(VALUE self, VALUE rdoc_id)
2479
+ frb_ir_term_vectors(VALUE self, VALUE rdoc_id)
2494
2480
  {
2495
2481
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2496
- HashTable *tvs = ir->term_vectors(ir, FIX2INT(rdoc_id));
2482
+ Hash *tvs = ir->term_vectors(ir, FIX2INT(rdoc_id));
2497
2483
  VALUE rtvs = rb_hash_new();
2498
- h_each(tvs, &frt_add_each_tv, (void *)rtvs);
2484
+ h_each(tvs, &frb_add_each_tv, (void *)rtvs);
2499
2485
  h_destroy(tvs);
2500
2486
 
2501
2487
  return rtvs;
@@ -2510,10 +2496,10 @@ frt_ir_term_vectors(VALUE self, VALUE rdoc_id)
2510
2496
  * See TermDocEnum for more info.
2511
2497
  */
2512
2498
  static VALUE
2513
- frt_ir_term_docs(VALUE self)
2499
+ frb_ir_term_docs(VALUE self)
2514
2500
  {
2515
2501
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2516
- return frt_get_tde(self, ir->term_docs(ir));
2502
+ return frb_get_tde(self, ir->term_docs(ir));
2517
2503
  }
2518
2504
 
2519
2505
  /*
@@ -2524,11 +2510,11 @@ frt_ir_term_docs(VALUE self)
2524
2510
  * term +term+ in the field +field+. See TermDocEnum for more info.
2525
2511
  */
2526
2512
  static VALUE
2527
- frt_ir_term_docs_for(VALUE self, VALUE rfield, VALUE rterm)
2513
+ frb_ir_term_docs_for(VALUE self, VALUE rfield, VALUE rterm)
2528
2514
  {
2529
2515
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2530
- return frt_get_tde(self, ir_term_docs_for(ir,
2531
- frt_field(rfield),
2516
+ return frb_get_tde(self, ir_term_docs_for(ir,
2517
+ frb_field(rfield),
2532
2518
  StringValuePtr(rterm)));
2533
2519
  }
2534
2520
 
@@ -2541,10 +2527,10 @@ frt_ir_term_docs_for(VALUE self, VALUE rfield, VALUE rterm)
2541
2527
  * more info.
2542
2528
  */
2543
2529
  static VALUE
2544
- frt_ir_term_positions(VALUE self)
2530
+ frb_ir_term_positions(VALUE self)
2545
2531
  {
2546
2532
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2547
- return frt_get_tde(self, ir->term_positions(ir));
2533
+ return frb_get_tde(self, ir->term_positions(ir));
2548
2534
  }
2549
2535
 
2550
2536
  /*
@@ -2556,11 +2542,11 @@ frt_ir_term_positions(VALUE self)
2556
2542
  * TermDocEnum for more info.
2557
2543
  */
2558
2544
  static VALUE
2559
- frt_ir_t_pos_for(VALUE self, VALUE rfield, VALUE rterm)
2545
+ frb_ir_t_pos_for(VALUE self, VALUE rfield, VALUE rterm)
2560
2546
  {
2561
2547
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2562
- return frt_get_tde(self, ir_term_positions_for(ir,
2563
- frt_field(rfield),
2548
+ return frb_get_tde(self, ir_term_positions_for(ir,
2549
+ frb_field(rfield),
2564
2550
  StringValuePtr(rterm)));
2565
2551
  }
2566
2552
 
@@ -2572,11 +2558,11 @@ frt_ir_t_pos_for(VALUE self, VALUE rfield, VALUE rterm)
2572
2558
  * field +field+.
2573
2559
  */
2574
2560
  static VALUE
2575
- frt_ir_doc_freq(VALUE self, VALUE rfield, VALUE rterm)
2561
+ frb_ir_doc_freq(VALUE self, VALUE rfield, VALUE rterm)
2576
2562
  {
2577
2563
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2578
2564
  return INT2FIX(ir_doc_freq(ir,
2579
- frt_field(rfield),
2565
+ frb_field(rfield),
2580
2566
  StringValuePtr(rterm)));
2581
2567
  }
2582
2568
 
@@ -2588,10 +2574,10 @@ frt_ir_doc_freq(VALUE self, VALUE rfield, VALUE rterm)
2588
2574
  * terms in the field +field+ in the index.
2589
2575
  */
2590
2576
  static VALUE
2591
- frt_ir_terms(VALUE self, VALUE rfield)
2577
+ frb_ir_terms(VALUE self, VALUE rfield)
2592
2578
  {
2593
2579
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2594
- return frt_get_te(self, ir_terms(ir, frt_field(rfield)));
2580
+ return frb_get_te(self, ir_terms(ir, frb_field(rfield)));
2595
2581
  }
2596
2582
 
2597
2583
  /*
@@ -2602,11 +2588,11 @@ frt_ir_terms(VALUE self, VALUE rfield)
2602
2588
  * at term +term+.
2603
2589
  */
2604
2590
  static VALUE
2605
- frt_ir_terms_from(VALUE self, VALUE rfield, VALUE rterm)
2591
+ frb_ir_terms_from(VALUE self, VALUE rfield, VALUE rterm)
2606
2592
  {
2607
2593
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2608
- return frt_get_te(self, ir_terms_from(ir,
2609
- frt_field(rfield),
2594
+ return frb_get_te(self, ir_terms_from(ir,
2595
+ frb_field(rfield),
2610
2596
  StringValuePtr(rterm)));
2611
2597
  }
2612
2598
 
@@ -2617,10 +2603,10 @@ frt_ir_terms_from(VALUE self, VALUE rfield, VALUE rterm)
2617
2603
  * Same return a count of the number of terms in the field
2618
2604
  */
2619
2605
  static VALUE
2620
- frt_ir_term_count(VALUE self, VALUE rfield)
2606
+ frb_ir_term_count(VALUE self, VALUE rfield)
2621
2607
  {
2622
2608
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2623
- TermEnum *te = ir_terms(ir, frt_field(rfield));
2609
+ TermEnum *te = ir_terms(ir, frb_field(rfield));
2624
2610
  int count = 0;
2625
2611
  while (te->next(te)) {
2626
2612
  count++;
@@ -2639,14 +2625,14 @@ frt_ir_term_count(VALUE self, VALUE rfield)
2639
2625
  * gathered from the FieldInfos object.
2640
2626
  */
2641
2627
  static VALUE
2642
- frt_ir_fields(VALUE self)
2628
+ frb_ir_fields(VALUE self)
2643
2629
  {
2644
2630
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2645
2631
  FieldInfos *fis = ir->fis;
2646
2632
  VALUE rfield_names = rb_ary_new();
2647
2633
  int i;
2648
2634
  for (i = 0; i < fis->size; i++) {
2649
- rb_ary_push(rfield_names, ID2SYM(rb_intern(fis->fields[i]->name)));
2635
+ rb_ary_push(rfield_names, FSYM2SYM(fis->fields[i]->name));
2650
2636
  }
2651
2637
  return rfield_names;
2652
2638
  }
@@ -2658,10 +2644,10 @@ frt_ir_fields(VALUE self)
2658
2644
  * Get the FieldInfos object for this IndexReader.
2659
2645
  */
2660
2646
  static VALUE
2661
- frt_ir_field_infos(VALUE self)
2647
+ frb_ir_field_infos(VALUE self)
2662
2648
  {
2663
2649
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2664
- return frt_get_field_infos(ir->fis);
2650
+ return frb_get_field_infos(ir->fis);
2665
2651
  }
2666
2652
 
2667
2653
  /*
@@ -2674,7 +2660,7 @@ frt_ir_field_infos(VALUE self)
2674
2660
  * of field names can also be gathered from the FieldInfos object.
2675
2661
  */
2676
2662
  static VALUE
2677
- frt_ir_tk_fields(VALUE self)
2663
+ frb_ir_tk_fields(VALUE self)
2678
2664
  {
2679
2665
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2680
2666
  FieldInfos *fis = ir->fis;
@@ -2682,7 +2668,7 @@ frt_ir_tk_fields(VALUE self)
2682
2668
  int i;
2683
2669
  for (i = 0; i < fis->size; i++) {
2684
2670
  if (!fi_is_tokenized(fis->fields[i])) continue;
2685
- rb_ary_push(rfield_names, ID2SYM(rb_intern(fis->fields[i]->name)));
2671
+ rb_ary_push(rfield_names, FSYM2SYM(fis->fields[i]->name));
2686
2672
  }
2687
2673
  return rfield_names;
2688
2674
  }
@@ -2694,7 +2680,7 @@ frt_ir_tk_fields(VALUE self)
2694
2680
  * Returns the current version of the index reader.
2695
2681
  */
2696
2682
  static VALUE
2697
- frt_ir_version(VALUE self)
2683
+ frb_ir_version(VALUE self)
2698
2684
  {
2699
2685
  IndexReader *ir = (IndexReader *)DATA_PTR(self);
2700
2686
  return ULL2NUM(ir->sis->version);
@@ -2850,24 +2836,24 @@ Init_FieldInfo(void)
2850
2836
  sym_with_positions_offsets = ID2SYM(rb_intern("with_positions_offsets"));
2851
2837
 
2852
2838
  cFieldInfo = rb_define_class_under(mIndex, "FieldInfo", rb_cObject);
2853
- rb_define_alloc_func(cFieldInfo, frt_data_alloc);
2854
-
2855
- rb_define_method(cFieldInfo, "initialize", frt_fi_init, -1);
2856
- rb_define_method(cFieldInfo, "name", frt_fi_name, 0);
2857
- rb_define_method(cFieldInfo, "stored?", frt_fi_is_stored, 0);
2858
- rb_define_method(cFieldInfo, "compressed?", frt_fi_is_compressed, 0);
2859
- rb_define_method(cFieldInfo, "indexed?", frt_fi_is_indexed, 0);
2860
- rb_define_method(cFieldInfo, "tokenized?", frt_fi_is_tokenized, 0);
2861
- rb_define_method(cFieldInfo, "omit_norms?", frt_fi_omit_norms, 0);
2839
+ rb_define_alloc_func(cFieldInfo, frb_data_alloc);
2840
+
2841
+ rb_define_method(cFieldInfo, "initialize", frb_fi_init, -1);
2842
+ rb_define_method(cFieldInfo, "name", frb_fi_name, 0);
2843
+ rb_define_method(cFieldInfo, "stored?", frb_fi_is_stored, 0);
2844
+ rb_define_method(cFieldInfo, "compressed?", frb_fi_is_compressed, 0);
2845
+ rb_define_method(cFieldInfo, "indexed?", frb_fi_is_indexed, 0);
2846
+ rb_define_method(cFieldInfo, "tokenized?", frb_fi_is_tokenized, 0);
2847
+ rb_define_method(cFieldInfo, "omit_norms?", frb_fi_omit_norms, 0);
2862
2848
  rb_define_method(cFieldInfo, "store_term_vector?",
2863
- frt_fi_store_term_vector, 0);
2849
+ frb_fi_store_term_vector, 0);
2864
2850
  rb_define_method(cFieldInfo, "store_positions?",
2865
- frt_fi_store_positions, 0);
2851
+ frb_fi_store_positions, 0);
2866
2852
  rb_define_method(cFieldInfo, "store_offsets?",
2867
- frt_fi_store_offsets, 0);
2868
- rb_define_method(cFieldInfo, "has_norms?", frt_fi_has_norms, 0);
2869
- rb_define_method(cFieldInfo, "boost", frt_fi_boost, 0);
2870
- rb_define_method(cFieldInfo, "to_s", frt_fi_to_s, 0);
2853
+ frb_fi_store_offsets, 0);
2854
+ rb_define_method(cFieldInfo, "has_norms?", frb_fi_has_norms, 0);
2855
+ rb_define_method(cFieldInfo, "boost", frb_fi_boost, 0);
2856
+ rb_define_method(cFieldInfo, "to_s", frb_fi_to_s, 0);
2871
2857
  }
2872
2858
 
2873
2859
  /*
@@ -2916,21 +2902,21 @@ Init_FieldInfos(void)
2916
2902
  Init_FieldInfo();
2917
2903
 
2918
2904
  cFieldInfos = rb_define_class_under(mIndex, "FieldInfos", rb_cObject);
2919
- rb_define_alloc_func(cFieldInfos, frt_data_alloc);
2920
-
2921
- rb_define_method(cFieldInfos, "initialize", frt_fis_init, -1);
2922
- rb_define_method(cFieldInfos, "to_a", frt_fis_to_a, 0);
2923
- rb_define_method(cFieldInfos, "[]", frt_fis_get, 1);
2924
- rb_define_method(cFieldInfos, "add", frt_fis_add, 1);
2925
- rb_define_method(cFieldInfos, "<<", frt_fis_add, 1);
2926
- rb_define_method(cFieldInfos, "add_field", frt_fis_add_field, -1);
2927
- rb_define_method(cFieldInfos, "each", frt_fis_each, 0);
2928
- rb_define_method(cFieldInfos, "to_s", frt_fis_to_s, 0);
2929
- rb_define_method(cFieldInfos, "size", frt_fis_size, 0);
2905
+ rb_define_alloc_func(cFieldInfos, frb_data_alloc);
2906
+
2907
+ rb_define_method(cFieldInfos, "initialize", frb_fis_init, -1);
2908
+ rb_define_method(cFieldInfos, "to_a", frb_fis_to_a, 0);
2909
+ rb_define_method(cFieldInfos, "[]", frb_fis_get, 1);
2910
+ rb_define_method(cFieldInfos, "add", frb_fis_add, 1);
2911
+ rb_define_method(cFieldInfos, "<<", frb_fis_add, 1);
2912
+ rb_define_method(cFieldInfos, "add_field", frb_fis_add_field, -1);
2913
+ rb_define_method(cFieldInfos, "each", frb_fis_each, 0);
2914
+ rb_define_method(cFieldInfos, "to_s", frb_fis_to_s, 0);
2915
+ rb_define_method(cFieldInfos, "size", frb_fis_size, 0);
2930
2916
  rb_define_method(cFieldInfos, "create_index",
2931
- frt_fis_create_index, 1);
2932
- rb_define_method(cFieldInfos, "fields", frt_fis_get_fields, 0);
2933
- rb_define_method(cFieldInfos, "tokenized_fields", frt_fis_get_tk_fields, 0);
2917
+ frb_fis_create_index, 1);
2918
+ rb_define_method(cFieldInfos, "fields", frb_fis_get_fields, 0);
2919
+ rb_define_method(cFieldInfos, "tokenized_fields", frb_fis_get_tk_fields, 0);
2934
2920
  }
2935
2921
 
2936
2922
  /*
@@ -2960,16 +2946,16 @@ Init_TermEnum(void)
2960
2946
  id_term = rb_intern("@term");
2961
2947
 
2962
2948
  cTermEnum = rb_define_class_under(mIndex, "TermEnum", rb_cObject);
2963
- rb_define_alloc_func(cTermEnum, frt_data_alloc);
2949
+ rb_define_alloc_func(cTermEnum, frb_data_alloc);
2964
2950
 
2965
- rb_define_method(cTermEnum, "next?", frt_te_next, 0);
2966
- rb_define_method(cTermEnum, "term", frt_te_term, 0);
2967
- rb_define_method(cTermEnum, "doc_freq", frt_te_doc_freq, 0);
2968
- rb_define_method(cTermEnum, "skip_to", frt_te_skip_to, 1);
2969
- rb_define_method(cTermEnum, "each", frt_te_each, 0);
2970
- rb_define_method(cTermEnum, "field=", frt_te_set_field, 1);
2971
- rb_define_method(cTermEnum, "set_field",frt_te_set_field, 1);
2972
- rb_define_method(cTermEnum, "to_json", frt_te_to_json, -1);
2951
+ rb_define_method(cTermEnum, "next?", frb_te_next, 0);
2952
+ rb_define_method(cTermEnum, "term", frb_te_term, 0);
2953
+ rb_define_method(cTermEnum, "doc_freq", frb_te_doc_freq, 0);
2954
+ rb_define_method(cTermEnum, "skip_to", frb_te_skip_to, 1);
2955
+ rb_define_method(cTermEnum, "each", frb_te_each, 0);
2956
+ rb_define_method(cTermEnum, "field=", frb_te_set_field, 1);
2957
+ rb_define_method(cTermEnum, "set_field",frb_te_set_field, 1);
2958
+ rb_define_method(cTermEnum, "to_json", frb_te_to_json, -1);
2973
2959
  }
2974
2960
 
2975
2961
  /*
@@ -3011,17 +2997,17 @@ Init_TermDocEnum(void)
3011
2997
  id_field_num = rb_intern("@field_num");
3012
2998
 
3013
2999
  cTermDocEnum = rb_define_class_under(mIndex, "TermDocEnum", rb_cObject);
3014
- rb_define_alloc_func(cTermDocEnum, frt_data_alloc);
3015
- rb_define_method(cTermDocEnum, "seek", frt_tde_seek, 2);
3016
- rb_define_method(cTermDocEnum, "seek_term_enum", frt_tde_seek_te, 1);
3017
- rb_define_method(cTermDocEnum, "doc", frt_tde_doc, 0);
3018
- rb_define_method(cTermDocEnum, "freq", frt_tde_freq, 0);
3019
- rb_define_method(cTermDocEnum, "next?", frt_tde_next, 0);
3020
- rb_define_method(cTermDocEnum, "next_position", frt_tde_next_position, 0);
3021
- rb_define_method(cTermDocEnum, "each", frt_tde_each, 0);
3022
- rb_define_method(cTermDocEnum, "each_position", frt_tde_each_position, 0);
3023
- rb_define_method(cTermDocEnum, "skip_to", frt_tde_skip_to, 1);
3024
- rb_define_method(cTermDocEnum, "to_json", frt_tde_to_json, -1);
3000
+ rb_define_alloc_func(cTermDocEnum, frb_data_alloc);
3001
+ rb_define_method(cTermDocEnum, "seek", frb_tde_seek, 2);
3002
+ rb_define_method(cTermDocEnum, "seek_term_enum", frb_tde_seek_te, 1);
3003
+ rb_define_method(cTermDocEnum, "doc", frb_tde_doc, 0);
3004
+ rb_define_method(cTermDocEnum, "freq", frb_tde_freq, 0);
3005
+ rb_define_method(cTermDocEnum, "next?", frb_tde_next, 0);
3006
+ rb_define_method(cTermDocEnum, "next_position", frb_tde_next_position, 0);
3007
+ rb_define_method(cTermDocEnum, "each", frb_tde_each, 0);
3008
+ rb_define_method(cTermDocEnum, "each_position", frb_tde_each_position, 0);
3009
+ rb_define_method(cTermDocEnum, "skip_to", frb_tde_skip_to, 1);
3010
+ rb_define_method(cTermDocEnum, "to_json", frb_tde_to_json, -1);
3025
3011
  }
3026
3012
 
3027
3013
  /* rdochack
@@ -3078,7 +3064,7 @@ Init_TVTerm(void)
3078
3064
  /* rdochack
3079
3065
  cTVTerm = rb_define_class_under(cTermVector, "TVTerm", rb_cObject);
3080
3066
  */
3081
- cTVTerm = rb_struct_define(tv_term_class, "text", "positions", NULL);
3067
+ cTVTerm = rb_struct_define(tv_term_class, "text", "freq", "positions", NULL);
3082
3068
  rb_set_class_path(cTVTerm, cTermVector, tv_term_class);
3083
3069
  rb_const_set(mIndex, rb_intern(tv_term_class), cTVTerm);
3084
3070
  }
@@ -3097,7 +3083,7 @@ Init_TVTerm(void)
3097
3083
  *
3098
3084
  * == Example
3099
3085
  *
3100
- * tv = index_reader.term_vector(:content)
3086
+ * tv = index_reader.term_vector(doc_id, :content)
3101
3087
  * tv_term = tv.find {|tvt| tvt.term = "fox"}
3102
3088
  *
3103
3089
  * # get the term frequency
@@ -3262,7 +3248,7 @@ Init_IndexWriter(void)
3262
3248
  sym_use_compound_file = ID2SYM(rb_intern("use_compound_file"));
3263
3249
 
3264
3250
  cIndexWriter = rb_define_class_under(mIndex, "IndexWriter", rb_cObject);
3265
- rb_define_alloc_func(cIndexWriter, frt_data_alloc);
3251
+ rb_define_alloc_func(cIndexWriter, frb_data_alloc);
3266
3252
 
3267
3253
  rb_define_const(cIndexWriter, "WRITE_LOCK_TIMEOUT", INT2FIX(1));
3268
3254
  rb_define_const(cIndexWriter, "COMMIT_LOCK_TIMEOUT", INT2FIX(10));
@@ -3289,64 +3275,64 @@ Init_IndexWriter(void)
3289
3275
  rb_define_const(cIndexWriter, "DEFAULT_USE_COMPOUND_FILE",
3290
3276
  default_config.use_compound_file ? Qtrue : Qfalse);
3291
3277
 
3292
- rb_define_method(cIndexWriter, "initialize", frt_iw_init, -1);
3293
- rb_define_method(cIndexWriter, "doc_count", frt_iw_get_doc_count, 0);
3294
- rb_define_method(cIndexWriter, "close", frt_iw_close, 0);
3295
- rb_define_method(cIndexWriter, "add_document", frt_iw_add_doc, 1);
3296
- rb_define_method(cIndexWriter, "<<", frt_iw_add_doc, 1);
3297
- rb_define_method(cIndexWriter, "optimize", frt_iw_optimize, 0);
3298
- rb_define_method(cIndexWriter, "commit", frt_iw_commit, 0);
3299
- rb_define_method(cIndexWriter, "add_readers", frt_iw_add_readers, 1);
3300
- rb_define_method(cIndexWriter, "delete", frt_iw_delete, 2);
3301
- rb_define_method(cIndexWriter, "field_infos", frt_iw_field_infos, 0);
3302
- rb_define_method(cIndexWriter, "analyzer", frt_iw_get_analyzer, 0);
3303
- rb_define_method(cIndexWriter, "analyzer=", frt_iw_set_analyzer, 1);
3304
- rb_define_method(cIndexWriter, "version", frt_iw_version, 0);
3278
+ rb_define_method(cIndexWriter, "initialize", frb_iw_init, -1);
3279
+ rb_define_method(cIndexWriter, "doc_count", frb_iw_get_doc_count, 0);
3280
+ rb_define_method(cIndexWriter, "close", frb_iw_close, 0);
3281
+ rb_define_method(cIndexWriter, "add_document", frb_iw_add_doc, 1);
3282
+ rb_define_method(cIndexWriter, "<<", frb_iw_add_doc, 1);
3283
+ rb_define_method(cIndexWriter, "optimize", frb_iw_optimize, 0);
3284
+ rb_define_method(cIndexWriter, "commit", frb_iw_commit, 0);
3285
+ rb_define_method(cIndexWriter, "add_readers", frb_iw_add_readers, 1);
3286
+ rb_define_method(cIndexWriter, "delete", frb_iw_delete, 2);
3287
+ rb_define_method(cIndexWriter, "field_infos", frb_iw_field_infos, 0);
3288
+ rb_define_method(cIndexWriter, "analyzer", frb_iw_get_analyzer, 0);
3289
+ rb_define_method(cIndexWriter, "analyzer=", frb_iw_set_analyzer, 1);
3290
+ rb_define_method(cIndexWriter, "version", frb_iw_version, 0);
3305
3291
 
3306
3292
  rb_define_method(cIndexWriter, "chunk_size",
3307
- frt_iw_get_chunk_size, 0);
3293
+ frb_iw_get_chunk_size, 0);
3308
3294
  rb_define_method(cIndexWriter, "chunk_size=",
3309
- frt_iw_set_chunk_size, 1);
3295
+ frb_iw_set_chunk_size, 1);
3310
3296
 
3311
3297
  rb_define_method(cIndexWriter, "max_buffer_memory",
3312
- frt_iw_get_max_buffer_memory, 0);
3298
+ frb_iw_get_max_buffer_memory, 0);
3313
3299
  rb_define_method(cIndexWriter, "max_buffer_memory=",
3314
- frt_iw_set_max_buffer_memory, 1);
3300
+ frb_iw_set_max_buffer_memory, 1);
3315
3301
 
3316
3302
  rb_define_method(cIndexWriter, "term_index_interval",
3317
- frt_iw_get_index_interval, 0);
3303
+ frb_iw_get_index_interval, 0);
3318
3304
  rb_define_method(cIndexWriter, "term_index_interval=",
3319
- frt_iw_set_index_interval, 1);
3305
+ frb_iw_set_index_interval, 1);
3320
3306
 
3321
3307
  rb_define_method(cIndexWriter, "doc_skip_interval",
3322
- frt_iw_get_skip_interval, 0);
3308
+ frb_iw_get_skip_interval, 0);
3323
3309
  rb_define_method(cIndexWriter, "doc_skip_interval=",
3324
- frt_iw_set_skip_interval, 1);
3310
+ frb_iw_set_skip_interval, 1);
3325
3311
 
3326
3312
  rb_define_method(cIndexWriter, "merge_factor",
3327
- frt_iw_get_merge_factor, 0);
3313
+ frb_iw_get_merge_factor, 0);
3328
3314
  rb_define_method(cIndexWriter, "merge_factor=",
3329
- frt_iw_set_merge_factor, 1);
3315
+ frb_iw_set_merge_factor, 1);
3330
3316
 
3331
3317
  rb_define_method(cIndexWriter, "max_buffered_docs",
3332
- frt_iw_get_max_buffered_docs, 0);
3318
+ frb_iw_get_max_buffered_docs, 0);
3333
3319
  rb_define_method(cIndexWriter, "max_buffered_docs=",
3334
- frt_iw_set_max_buffered_docs, 1);
3320
+ frb_iw_set_max_buffered_docs, 1);
3335
3321
 
3336
3322
  rb_define_method(cIndexWriter, "max_merge_docs",
3337
- frt_iw_get_max_merge_docs, 0);
3323
+ frb_iw_get_max_merge_docs, 0);
3338
3324
  rb_define_method(cIndexWriter, "max_merge_docs=",
3339
- frt_iw_set_max_merge_docs, 1);
3325
+ frb_iw_set_max_merge_docs, 1);
3340
3326
 
3341
3327
  rb_define_method(cIndexWriter, "max_field_length",
3342
- frt_iw_get_max_field_length, 0);
3328
+ frb_iw_get_max_field_length, 0);
3343
3329
  rb_define_method(cIndexWriter, "max_field_length=",
3344
- frt_iw_set_max_field_length, 1);
3330
+ frb_iw_set_max_field_length, 1);
3345
3331
 
3346
3332
  rb_define_method(cIndexWriter, "use_compound_file",
3347
- frt_iw_get_use_compound_file, 0);
3333
+ frb_iw_get_use_compound_file, 0);
3348
3334
  rb_define_method(cIndexWriter, "use_compound_file=",
3349
- frt_iw_set_use_compound_file, 1);
3335
+ frb_iw_set_use_compound_file, 1);
3350
3336
 
3351
3337
  }
3352
3338
 
@@ -3387,12 +3373,12 @@ Init_LazyDoc(void)
3387
3373
 
3388
3374
 
3389
3375
  cLazyDoc = rb_define_class_under(mIndex, "LazyDoc", rb_cHash);
3390
- rb_define_method(cLazyDoc, "default", frt_lzd_default, 1);
3391
- rb_define_method(cLazyDoc, "load", frt_lzd_load, 0);
3392
- rb_define_method(cLazyDoc, "fields", frt_lzd_fields, 0);
3376
+ rb_define_method(cLazyDoc, "default", frb_lzd_default, 1);
3377
+ rb_define_method(cLazyDoc, "load", frb_lzd_load, 0);
3378
+ rb_define_method(cLazyDoc, "fields", frb_lzd_fields, 0);
3393
3379
 
3394
3380
  cLazyDocData = rb_define_class_under(cLazyDoc, "LazyDocData", rb_cObject);
3395
- rb_define_alloc_func(cLazyDocData, frt_data_alloc);
3381
+ rb_define_alloc_func(cLazyDocData, frb_data_alloc);
3396
3382
  }
3397
3383
 
3398
3384
  /*
@@ -3409,37 +3395,37 @@ void
3409
3395
  Init_IndexReader(void)
3410
3396
  {
3411
3397
  cIndexReader = rb_define_class_under(mIndex, "IndexReader", rb_cObject);
3412
- rb_define_alloc_func(cIndexReader, frt_data_alloc);
3413
- rb_define_method(cIndexReader, "initialize", frt_ir_init, 1);
3414
- rb_define_method(cIndexReader, "set_norm", frt_ir_set_norm, 3);
3415
- rb_define_method(cIndexReader, "norms", frt_ir_norms, 1);
3416
- rb_define_method(cIndexReader, "get_norms_into",frt_ir_get_norms_into, 3);
3417
- rb_define_method(cIndexReader, "commit", frt_ir_commit, 0);
3418
- rb_define_method(cIndexReader, "close", frt_ir_close, 0);
3419
- rb_define_method(cIndexReader, "has_deletions?",frt_ir_has_deletions, 0);
3420
- rb_define_method(cIndexReader, "delete", frt_ir_delete, 1);
3421
- rb_define_method(cIndexReader, "deleted?", frt_ir_is_deleted, 1);
3422
- rb_define_method(cIndexReader, "max_doc", frt_ir_max_doc, 0);
3423
- rb_define_method(cIndexReader, "num_docs", frt_ir_num_docs, 0);
3424
- rb_define_method(cIndexReader, "undelete_all", frt_ir_undelete_all, 0);
3425
- rb_define_method(cIndexReader, "latest?", frt_ir_is_latest, 0);
3426
- rb_define_method(cIndexReader, "get_document", frt_ir_get_doc, -1);
3427
- rb_define_method(cIndexReader, "[]", frt_ir_get_doc, -1);
3428
- rb_define_method(cIndexReader, "term_vector", frt_ir_term_vector, 2);
3429
- rb_define_method(cIndexReader, "term_vectors", frt_ir_term_vectors, 1);
3430
- rb_define_method(cIndexReader, "term_docs", frt_ir_term_docs, 0);
3431
- rb_define_method(cIndexReader, "term_positions",frt_ir_term_positions, 0);
3432
- rb_define_method(cIndexReader, "term_docs_for", frt_ir_term_docs_for, 2);
3433
- rb_define_method(cIndexReader, "term_positions_for", frt_ir_t_pos_for, 2);
3434
- rb_define_method(cIndexReader, "doc_freq", frt_ir_doc_freq, 2);
3435
- rb_define_method(cIndexReader, "terms", frt_ir_terms, 1);
3436
- rb_define_method(cIndexReader, "terms_from", frt_ir_terms_from, 2);
3437
- rb_define_method(cIndexReader, "term_count", frt_ir_term_count, 1);
3438
- rb_define_method(cIndexReader, "fields", frt_ir_fields, 0);
3439
- rb_define_method(cIndexReader, "field_names", frt_ir_fields, 0);
3440
- rb_define_method(cIndexReader, "field_infos", frt_ir_field_infos, 0);
3441
- rb_define_method(cIndexReader, "tokenized_fields", frt_ir_tk_fields, 0);
3442
- rb_define_method(cIndexReader, "version", frt_ir_version, 0);
3398
+ rb_define_alloc_func(cIndexReader, frb_data_alloc);
3399
+ rb_define_method(cIndexReader, "initialize", frb_ir_init, 1);
3400
+ rb_define_method(cIndexReader, "set_norm", frb_ir_set_norm, 3);
3401
+ rb_define_method(cIndexReader, "norms", frb_ir_norms, 1);
3402
+ rb_define_method(cIndexReader, "get_norms_into",frb_ir_get_norms_into, 3);
3403
+ rb_define_method(cIndexReader, "commit", frb_ir_commit, 0);
3404
+ rb_define_method(cIndexReader, "close", frb_ir_close, 0);
3405
+ rb_define_method(cIndexReader, "has_deletions?",frb_ir_has_deletions, 0);
3406
+ rb_define_method(cIndexReader, "delete", frb_ir_delete, 1);
3407
+ rb_define_method(cIndexReader, "deleted?", frb_ir_is_deleted, 1);
3408
+ rb_define_method(cIndexReader, "max_doc", frb_ir_max_doc, 0);
3409
+ rb_define_method(cIndexReader, "num_docs", frb_ir_num_docs, 0);
3410
+ rb_define_method(cIndexReader, "undelete_all", frb_ir_undelete_all, 0);
3411
+ rb_define_method(cIndexReader, "latest?", frb_ir_is_latest, 0);
3412
+ rb_define_method(cIndexReader, "get_document", frb_ir_get_doc, -1);
3413
+ rb_define_method(cIndexReader, "[]", frb_ir_get_doc, -1);
3414
+ rb_define_method(cIndexReader, "term_vector", frb_ir_term_vector, 2);
3415
+ rb_define_method(cIndexReader, "term_vectors", frb_ir_term_vectors, 1);
3416
+ rb_define_method(cIndexReader, "term_docs", frb_ir_term_docs, 0);
3417
+ rb_define_method(cIndexReader, "term_positions",frb_ir_term_positions, 0);
3418
+ rb_define_method(cIndexReader, "term_docs_for", frb_ir_term_docs_for, 2);
3419
+ rb_define_method(cIndexReader, "term_positions_for", frb_ir_t_pos_for, 2);
3420
+ rb_define_method(cIndexReader, "doc_freq", frb_ir_doc_freq, 2);
3421
+ rb_define_method(cIndexReader, "terms", frb_ir_terms, 1);
3422
+ rb_define_method(cIndexReader, "terms_from", frb_ir_terms_from, 2);
3423
+ rb_define_method(cIndexReader, "term_count", frb_ir_term_count, 1);
3424
+ rb_define_method(cIndexReader, "fields", frb_ir_fields, 0);
3425
+ rb_define_method(cIndexReader, "field_names", frb_ir_fields, 0);
3426
+ rb_define_method(cIndexReader, "field_infos", frb_ir_field_infos, 0);
3427
+ rb_define_method(cIndexReader, "tokenized_fields", frb_ir_tk_fields, 0);
3428
+ rb_define_method(cIndexReader, "version", frb_ir_version, 0);
3443
3429
  }
3444
3430
 
3445
3431
  /* rdoc hack
@@ -3472,6 +3458,7 @@ Init_Index(void)
3472
3458
  sym_boost = ID2SYM(rb_intern("boost"));
3473
3459
  sym_analyzer = ID2SYM(rb_intern("analyzer"));
3474
3460
  sym_close_dir = ID2SYM(rb_intern("close_dir"));
3461
+ fsym_content = I("content");
3475
3462
 
3476
3463
  Init_TermVector();
3477
3464
  Init_TermEnum();