isomorfeus-ferret 0.13.8 → 0.13.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/ext/isomorfeus_ferret_ext/frb_index.c +15 -21
  3. data/ext/isomorfeus_ferret_ext/frb_search.c +1 -4
  4. data/ext/isomorfeus_ferret_ext/frb_store.c +32 -34
  5. data/ext/isomorfeus_ferret_ext/frt_analysis.c +2 -2
  6. data/ext/isomorfeus_ferret_ext/frt_analysis.h +5 -5
  7. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +1 -1
  8. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +1 -1
  9. data/ext/isomorfeus_ferret_ext/frt_compound_io.c +34 -59
  10. data/ext/isomorfeus_ferret_ext/frt_except.c +1 -0
  11. data/ext/isomorfeus_ferret_ext/frt_filter.c +2 -4
  12. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +11 -12
  13. data/ext/isomorfeus_ferret_ext/frt_global.c +6 -4
  14. data/ext/isomorfeus_ferret_ext/frt_global.h +1 -1
  15. data/ext/isomorfeus_ferret_ext/frt_hash.c +40 -48
  16. data/ext/isomorfeus_ferret_ext/frt_hash.h +14 -16
  17. data/ext/isomorfeus_ferret_ext/frt_ind.c +2 -3
  18. data/ext/isomorfeus_ferret_ext/frt_index.c +120 -193
  19. data/ext/isomorfeus_ferret_ext/frt_index.h +13 -13
  20. data/ext/isomorfeus_ferret_ext/frt_lang.c +1 -4
  21. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +8 -9
  22. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +1 -1
  23. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +6 -6
  24. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -3
  25. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +1742 -1742
  26. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +1 -2
  27. data/ext/isomorfeus_ferret_ext/frt_q_span.c +11 -10
  28. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +18 -34
  29. data/ext/isomorfeus_ferret_ext/frt_search.c +29 -28
  30. data/ext/isomorfeus_ferret_ext/frt_search.h +18 -19
  31. data/ext/isomorfeus_ferret_ext/frt_store.c +40 -33
  32. data/ext/isomorfeus_ferret_ext/frt_store.h +24 -26
  33. data/ext/isomorfeus_ferret_ext/frt_threading.h +12 -5
  34. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +4 -3
  35. data/ext/isomorfeus_ferret_ext/test_1710.c +1 -2
  36. data/ext/isomorfeus_ferret_ext/test_compound_io.c +8 -8
  37. data/ext/isomorfeus_ferret_ext/test_fields.c +7 -7
  38. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +1 -1
  39. data/ext/isomorfeus_ferret_ext/test_filter.c +4 -3
  40. data/ext/isomorfeus_ferret_ext/test_fs_store.c +1 -1
  41. data/ext/isomorfeus_ferret_ext/test_highlighter.c +3 -1
  42. data/ext/isomorfeus_ferret_ext/test_index.c +59 -59
  43. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +2 -1
  44. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -2
  45. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +3 -1
  46. data/ext/isomorfeus_ferret_ext/test_q_span.c +8 -1
  47. data/ext/isomorfeus_ferret_ext/test_ram_store.c +4 -4
  48. data/ext/isomorfeus_ferret_ext/test_search.c +9 -4
  49. data/ext/isomorfeus_ferret_ext/test_segments.c +4 -3
  50. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -9
  51. data/ext/isomorfeus_ferret_ext/test_term.c +4 -2
  52. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +2 -2
  53. data/ext/isomorfeus_ferret_ext/test_threading.c +5 -4
  54. data/lib/isomorfeus/ferret/index/index.rb +8 -3
  55. data/lib/isomorfeus/ferret/version.rb +1 -1
  56. metadata +2 -2
@@ -51,11 +51,11 @@ struct FrtOutStreamMethods {
51
51
 
52
52
  typedef struct FrtRAMFile
53
53
  {
54
- char *name;
55
- frt_uchar **buffers;
56
- int bufcnt;
57
- off_t len;
58
- int ref_cnt;
54
+ char *name;
55
+ frt_uchar **buffers;
56
+ int bufcnt;
57
+ off_t len;
58
+ _Atomic unsigned int ref_cnt;
59
59
  } FrtRAMFile;
60
60
 
61
61
  struct FrtOutStream
@@ -114,21 +114,23 @@ struct FrtInStreamMethods
114
114
  void (*close_i)(struct FrtInStream *is);
115
115
  };
116
116
 
117
- struct FrtInStream
118
- {
119
- FrtBuffer buf;
120
- union
121
- {
117
+ typedef struct FrtInStreamFile {
118
+ _Atomic unsigned int ref_cnt;
119
+ union {
122
120
  int fd;
123
121
  FrtRAMFile *rf;
124
122
  } file;
125
- union
126
- {
123
+ } FrtInStreamFile;
124
+
125
+ struct FrtInStream {
126
+ FrtBuffer buf;
127
+ struct FrtInStreamFile *f;
128
+ union {
127
129
  off_t pointer; /* only used by RAMIn */
128
130
  char *path; /* only used by FSIn */
129
131
  FrtCompoundInStream *cis;
130
132
  } d;
131
- int *ref_cnt_ptr;
133
+ _Atomic unsigned int ref_cnt;
132
134
  const struct FrtInStreamMethods *m;
133
135
  };
134
136
 
@@ -161,24 +163,21 @@ typedef struct FrtCompoundStore
161
163
  FrtInStream *stream;
162
164
  } FrtCompoundStore;
163
165
 
164
- struct FrtStore
165
- {
166
- int ref_cnt; /* for fs_store only */
166
+ struct FrtStore {
167
+ _Atomic unsigned int ref_cnt;
167
168
  frt_mutex_t mutex_i; /* for internal use only */
168
169
  frt_mutex_t mutex; /* external mutex for use outside */
169
- union
170
- {
171
- char *path; /* for fs_store only */
172
- FrtHash *ht; /* for ram_store only */
170
+ union {
171
+ char *path; /* for fs_store only */
172
+ FrtHash *ht; /* for ram_store only */
173
173
  FrtCompoundStore *cmpd; /* for compound_store only */
174
174
  } dir;
175
-
176
175
  #if defined POSH_OS_WIN32 || defined POSH_OS_WIN64
177
- int file_mode;
176
+ int file_mode;
178
177
  #else
179
- mode_t file_mode;
178
+ mode_t file_mode;
180
179
  #endif
181
- FrtHashSet *locks;
180
+ FrtHashSet *locks;
182
181
 
183
182
  /**
184
183
  * Create the file +filename+ in the +store+.
@@ -443,7 +442,7 @@ extern void frt_with_lock_name(FrtStore *store, const char *lock_name, void (*fu
443
442
  *
444
443
  * @param store the store to be dereferenced
445
444
  */
446
- extern void frt_store_deref(FrtStore *store);
445
+ extern void frt_store_close(FrtStore *store);
447
446
 
448
447
  /**
449
448
  * Flush the buffered contents of the FrtOutStream to the store.
@@ -788,7 +787,6 @@ extern void frt_close_lock(FrtLock *lock);
788
787
  extern FrtStore *frt_store_alloc();
789
788
  extern FrtStore *frt_store_init(FrtStore *store);
790
789
  extern FrtStore *frt_store_new();
791
- extern void frt_store_destroy(FrtStore *store);
792
790
  extern FrtOutStream *frt_os_new();
793
791
  extern FrtInStream *frt_is_new();
794
792
  extern int frt_file_is_lock(const char *filename);
@@ -4,8 +4,15 @@
4
4
  #include <pthread.h>
5
5
 
6
6
  typedef pthread_mutex_t frt_mutex_t;
7
- typedef pthread_key_t frt_thread_key_t;
7
+ typedef struct FrtHash *frt_thread_key_t;
8
8
  typedef pthread_once_t frt_thread_once_t;
9
+
10
+ // extern void frb_thread_once(int *once_control, void (*init_routine) (void));
11
+ extern int frb_thread_key_create(frt_thread_key_t *key, void (*destr_function)(void *));
12
+ extern void frb_thread_key_delete(frt_thread_key_t key);
13
+ extern void frb_thread_setspecific(frt_thread_key_t key, const void *pointer);
14
+ extern void *frb_thread_getspecific(frt_thread_key_t key);
15
+
9
16
  #define FRT_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
10
17
  #define FRT_THREAD_ONCE_INIT PTHREAD_ONCE_INIT
11
18
  #define frt_mutex_init(a, b) pthread_mutex_init(a, b)
@@ -13,10 +20,10 @@ typedef pthread_once_t frt_thread_once_t;
13
20
  #define frt_mutex_trylock(a) pthread_mutex_trylock(a)
14
21
  #define frt_mutex_unlock(a) pthread_mutex_unlock(a)
15
22
  #define frt_mutex_destroy(a) pthread_mutex_destroy(a)
16
- #define frt_thread_key_create(a, b) pthread_key_create(a, b)
17
- #define frt_thread_key_delete(a) pthread_key_delete(a)
18
- #define frt_thread_setspecific(a, b) pthread_setspecific(a, b)
19
- #define frt_thread_getspecific(a) pthread_getspecific(a)
23
+ #define frt_thread_key_create(a, b) frb_thread_key_create(a, b)
24
+ #define frt_thread_key_delete(a) frb_thread_key_delete(a)
25
+ #define frt_thread_setspecific(a, b) frb_thread_setspecific(a, b)
26
+ #define frt_thread_getspecific(a) frb_thread_getspecific(a)
20
27
  #define frt_thread_once(a, b) pthread_once(a, b)
21
28
 
22
29
  #endif
@@ -46,8 +46,8 @@ VALUE cStateError;
46
46
  void Init_Benchmark(void);
47
47
  void Init_Test(void);
48
48
 
49
- unsigned long long value_hash(const void *key) {
50
- return (unsigned long long)key;
49
+ unsigned long value_hash(const void *key) {
50
+ return (unsigned long)key;
51
51
  }
52
52
 
53
53
  int value_eq(const void *key1, const void *key2) {
@@ -61,8 +61,9 @@ void frb_thread_once(int *once_control, void (*init_routine) (void)) {
61
61
  }
62
62
  }
63
63
 
64
- void frb_thread_key_create(frt_thread_key_t *key, void (*destr_function)(void *)) {
64
+ int frb_thread_key_create(frt_thread_key_t *key, void (*destr_function)(void *)) {
65
65
  *key = frt_h_new(&value_hash, &value_eq, NULL, destr_function);
66
+ return 0;
66
67
  }
67
68
 
68
69
  void frb_thread_key_delete(frt_thread_key_t key) {
@@ -55,8 +55,7 @@ TestSuite *ts_1710(TestSuite *suite)
55
55
 
56
56
  tst_run_test(suite, test_problem_text, store);
57
57
 
58
- frt_store_deref(store);
58
+ frt_store_close(store);
59
59
 
60
60
  return suite;
61
61
  }
62
-
@@ -29,7 +29,7 @@ void test_compound_reader(TestCase *tc, void *data)
29
29
  Asequal("this is file 2", p = frt_is_read_string(is2)); free(p);
30
30
  frt_is_close(is1);
31
31
  frt_is_close(is2);
32
- frt_store_deref(c_reader);
32
+ frt_store_close(c_reader);
33
33
  }
34
34
 
35
35
  void test_compound_writer(TestCase *tc, void *data)
@@ -42,12 +42,12 @@ void test_compound_writer(TestCase *tc, void *data)
42
42
  FrtInStream *is;
43
43
 
44
44
  frt_os_write_u32(os1, 20);
45
- frt_os_write_string(os2,"this is file2");
45
+ frt_os_write_string(os2, "this is file2");
46
46
  frt_os_close(os1);
47
47
  frt_os_close(os2);
48
- cw = frt_open_cw(store, (char *)"cfile");
49
- frt_cw_add_file(cw, (char *)"file1");
50
- frt_cw_add_file(cw, (char *)"file2");
48
+ cw = frt_open_cw(store, "cfile");
49
+ frt_cw_add_file(cw, "file1");
50
+ frt_cw_add_file(cw, "file2");
51
51
  frt_cw_close(cw, NULL);
52
52
 
53
53
  is = store->open_input(store, "cfile");
@@ -109,7 +109,7 @@ void test_compound_io(TestCase *tc, void *data)
109
109
  Asequal(short_string, p = frt_is_read_string(is3)); free(p);
110
110
  frt_is_close(is3);
111
111
 
112
- frt_store_deref(c_reader);
112
+ frt_store_close(c_reader);
113
113
  }
114
114
 
115
115
  #define MAX_TEST_WORDS 50
@@ -150,7 +150,7 @@ void test_compound_io_many_files(TestCase *tc, void *data)
150
150
  Aiequal(frt_is_length(is), frt_is_pos(is));
151
151
  frt_is_close(is);
152
152
  }
153
- frt_store_deref(c_reader);
153
+ frt_store_close(c_reader);
154
154
  }
155
155
 
156
156
  TestSuite *ts_compound_io(TestSuite *suite)
@@ -164,7 +164,7 @@ TestSuite *ts_compound_io(TestSuite *suite)
164
164
  tst_run_test(suite, test_compound_io, store);
165
165
  tst_run_test(suite, test_compound_io_many_files, store);
166
166
 
167
- frt_store_deref(store);
167
+ frt_store_close(store);
168
168
 
169
169
  return suite;
170
170
  }
@@ -190,7 +190,7 @@ static void test_fis_rw(TestCase *tc, void *data)
190
190
  is = store->open_input(store, "fields");
191
191
  fis = frt_fis_read(is);
192
192
  frt_is_close(is);
193
- Aiequal(FRT_STORE_YES, fis->store);
193
+ Aiequal(FRT_STORE_YES, fis->store_val);
194
194
  Aiequal(FRT_INDEX_UNTOKENIZED_OMIT_NORMS, fis->index);
195
195
  Aiequal(FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS, fis->term_vector);
196
196
 
@@ -247,7 +247,7 @@ static void test_fis_rw(TestCase *tc, void *data)
247
247
  " term_vector: :with_positions_offsets\n", str);
248
248
  free(str);
249
249
  frt_fis_deref(fis);
250
- frt_store_deref(store);
250
+ frt_store_close(store);
251
251
  }
252
252
 
253
253
  /****************************************************************************
@@ -373,8 +373,8 @@ static void test_fields_rw_single(TestCase *tc, void *data)
373
373
  check_df_data(df, 4, "go");
374
374
 
375
375
  free(bin_data);
376
- frt_store_deref(store);
377
- frt_doc_destroy(doc);
376
+ frt_store_close(store);
377
+ frt_doc_destroy(doc);
378
378
  frt_fis_deref(fis);
379
379
  }
380
380
 
@@ -453,8 +453,8 @@ static void test_fields_rw_multi(TestCase *tc, void *data)
453
453
  check_df_data(df, 4, "go");
454
454
 
455
455
  free(bin_data);
456
- frt_store_deref(store);
457
- frt_doc_destroy(doc);
456
+ frt_store_close(store);
457
+ frt_doc_destroy(doc);
458
458
  frt_fis_deref(fis);
459
459
  }
460
460
 
@@ -490,7 +490,7 @@ static void test_lazy_field_loading(TestCase *tc, void *data)
490
490
  lazy_doc = frt_fr_get_lazy_doc(fr, 0);
491
491
  frt_fr_close(fr);
492
492
  frt_fis_deref(fis);
493
- frt_store_deref(store);
493
+ frt_store_close(store);
494
494
 
495
495
  lazy_df = frt_lazy_doc_get(lazy_doc, rb_intern("stored"));
496
496
  Apnull(lazy_doc->fields[0]->data[0].text);
@@ -163,6 +163,6 @@ TestSuite *ts_file_deleter(TestSuite *suite)
163
163
 
164
164
  tst_run_test(suite, test_delete_leftover_files, store);
165
165
 
166
- frt_store_deref(store);
166
+ frt_store_close(store);
167
167
  return suite;
168
168
  }
@@ -50,7 +50,7 @@ void prepare_filter_index(FrtStore *store)
50
50
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)data[i].date, enc));
51
51
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flipflop), (char *)data[i].flipflop, enc));
52
52
  frt_iw_add_doc(iw, doc);
53
- frt_doc_destroy(doc);
53
+ frt_doc_destroy(doc);
54
54
  }
55
55
  frt_iw_close(iw);
56
56
  return;
@@ -328,7 +328,8 @@ TestSuite *ts_filter(TestSuite *suite)
328
328
  tst_run_test(suite, test_filter_func, searcher);
329
329
  tst_run_test(suite, test_score_altering_filter_func, searcher);
330
330
 
331
- frt_store_deref(store);
332
- searcher->close(searcher);
331
+ frt_searcher_close(searcher);
332
+ frt_ir_close(ir);
333
+ frt_store_close(store);
333
334
  return suite;
334
335
  }
@@ -19,7 +19,7 @@ TestSuite *ts_fs_store(TestSuite *suite)
19
19
 
20
20
  create_test_store_suite(suite, store);
21
21
 
22
- frt_store_deref(store);
22
+ frt_store_close(store);
23
23
 
24
24
  return suite;
25
25
  }
@@ -120,6 +120,7 @@ static void check_searcher_match_vector(TestCase *tc, FrtStore *store, FrtQuery
120
120
  }
121
121
  frt_matchv_destroy(mv);
122
122
  frt_searcher_close(sea);
123
+ frt_ir_close(ir);
123
124
  }
124
125
 
125
126
  #define Chk_mv(query, doc_num, expected) check_match_vector(tc, store, query, doc_num, expected)
@@ -529,6 +530,7 @@ static void test_searcher_highlight(TestCase *tc, void *data)
529
530
  frt_q_deref(q);
530
531
 
531
532
  frt_searcher_close(sea);
533
+ frt_ir_close(ir);
532
534
  }
533
535
 
534
536
  TestSuite *ts_highlighter(TestSuite *suite)
@@ -547,6 +549,6 @@ TestSuite *ts_highlighter(TestSuite *suite)
547
549
  tst_run_test(suite, test_searcher_get_match_vector, store);
548
550
  tst_run_test(suite, test_searcher_highlight, store);
549
551
 
550
- frt_store_deref(store);
552
+ frt_store_close(store);
551
553
  return suite;
552
554
  }
@@ -539,7 +539,7 @@ static void prep_test_1seg_index(FrtStore *store, FrtDocument **docs,
539
539
 
540
540
  frt_dw_close(dw);
541
541
  frt_iw_close(iw);
542
- frt_si_deref(si);
542
+ frt_si_close(si);
543
543
  }
544
544
 
545
545
  /****************************************************************************
@@ -725,7 +725,7 @@ static void test_segment_tde_deleted_docs(TestCase *tc, void *data)
725
725
  frt_is_close(prx_in);
726
726
  frt_tir_close(tir);
727
727
  frt_sfi_close(sfi);
728
- frt_si_deref(si);
728
+ frt_si_close(si);
729
729
  }
730
730
 
731
731
  /****************************************************************************
@@ -984,7 +984,7 @@ static void test_create_with_reader(TestCase *tc, void *data)
984
984
  frt_ir_close(ir);
985
985
  frt_ir_close(ir2);
986
986
  store->clear_all(store);
987
- frt_store_deref(store);
987
+ frt_store_close(store);
988
988
  frt_doc_destroy(doc);
989
989
  }
990
990
 
@@ -1312,7 +1312,7 @@ static void reader_test_env_destroy(ReaderTestEnvironment *rte)
1312
1312
  {
1313
1313
  int i;
1314
1314
  for (i = 0; i < rte->store_cnt; i++) {
1315
- frt_store_deref(rte->stores[i]);
1315
+ frt_store_close(rte->stores[i]);
1316
1316
  }
1317
1317
  free(rte->stores);
1318
1318
  free(rte);
@@ -1328,6 +1328,7 @@ static FrtIndexReader *reader_test_env_ir_open(ReaderTestEnvironment *rte)
1328
1328
  int i;
1329
1329
  for (i = 0; i < rte->store_cnt; i++) {
1330
1330
  sub_readers[i] = frt_ir_open(NULL, rte->stores[i]);
1331
+ FRT_DEREF(sub_readers[i]);
1331
1332
  }
1332
1333
  return (frt_mr_open(NULL, sub_readers, rte->store_cnt));
1333
1334
  }
@@ -1413,7 +1414,7 @@ static ReaderTestEnvironment *reader_test_env_new(int type)
1413
1414
  frt_iw_close(iw);
1414
1415
  for (i = 0; i < rte->store_cnt; i++) {
1415
1416
  frt_ir_close(readers[i]);
1416
- frt_store_deref(rte->stores[i]);
1417
+ frt_store_close(rte->stores[i]);
1417
1418
  }
1418
1419
  free(readers);
1419
1420
  rte->stores[0] = store;
@@ -1473,7 +1474,6 @@ static void test_ir_open_empty_index(TestCase *tc, void *data)
1473
1474
  static void test_ir_basic_ops(TestCase *tc, void *data)
1474
1475
  {
1475
1476
  FrtIndexReader *ir = (FrtIndexReader *)data;
1476
-
1477
1477
  Aiequal(IR_TEST_DOC_CNT, ir->num_docs(ir));
1478
1478
  Aiequal(IR_TEST_DOC_CNT, ir->max_doc(ir));
1479
1479
 
@@ -1684,55 +1684,55 @@ static void test_ir_term_doc_enum(TestCase *tc, void *data)
1684
1684
  static void test_ir_term_vectors(TestCase *tc, void *data)
1685
1685
  {
1686
1686
  FrtIndexReader *ir = (FrtIndexReader *)data;
1687
-
1688
- FrtTermVector *tv = ir->term_vector(ir, 3, rb_intern("body"));
1689
1687
  FrtHash *tvs;
1690
-
1691
- Asequal("body", rb_id2name(tv->field));
1692
- Aiequal(4, tv->term_cnt);
1693
- Asequal("word1", tv->terms[0].text);
1694
- Asequal("word2", tv->terms[1].text);
1695
- Asequal("word3", tv->terms[2].text);
1696
- Asequal("word4", tv->terms[3].text);
1697
- Aiequal(3, tv->terms[0].freq);
1698
- Aiequal(2, tv->terms[0].positions[0]);
1699
- Aiequal(4, tv->terms[0].positions[1]);
1700
- Aiequal(7, tv->terms[0].positions[2]);
1701
- Aiequal(12, tv->offsets[tv->terms[0].positions[0]].start);
1702
- Aiequal(17, tv->offsets[tv->terms[0].positions[0]].end);
1703
- Aiequal(24, tv->offsets[tv->terms[0].positions[1]].start);
1704
- Aiequal(29, tv->offsets[tv->terms[0].positions[1]].end);
1705
- Aiequal(42, tv->offsets[tv->terms[0].positions[2]].start);
1706
- Aiequal(47, tv->offsets[tv->terms[0].positions[2]].end);
1707
-
1708
- Aiequal(1, tv->terms[1].freq);
1709
- Aiequal(3, tv->terms[1].positions[0]);
1710
- Aiequal(18, tv->offsets[tv->terms[1].positions[0]].start);
1711
- Aiequal(23, tv->offsets[tv->terms[1].positions[0]].end);
1712
-
1713
- Aiequal(4, tv->terms[2].freq);
1714
- Aiequal(0, tv->terms[2].positions[0]);
1715
- Aiequal(5, tv->terms[2].positions[1]);
1716
- Aiequal(8, tv->terms[2].positions[2]);
1717
- Aiequal(9, tv->terms[2].positions[3]);
1718
- Aiequal(0, tv->offsets[tv->terms[2].positions[0]].start);
1719
- Aiequal(5, tv->offsets[tv->terms[2].positions[0]].end);
1720
- Aiequal(30, tv->offsets[tv->terms[2].positions[1]].start);
1721
- Aiequal(35, tv->offsets[tv->terms[2].positions[1]].end);
1722
- Aiequal(48, tv->offsets[tv->terms[2].positions[2]].start);
1723
- Aiequal(53, tv->offsets[tv->terms[2].positions[2]].end);
1724
- Aiequal(54, tv->offsets[tv->terms[2].positions[3]].start);
1725
- Aiequal(59, tv->offsets[tv->terms[2].positions[3]].end);
1726
-
1727
- Aiequal(2, tv->terms[3].freq);
1728
- Aiequal(1, tv->terms[3].positions[0]);
1729
- Aiequal(6, tv->terms[3].positions[1]);
1730
- Aiequal(6, tv->offsets[tv->terms[3].positions[0]].start);
1731
- Aiequal(11, tv->offsets[tv->terms[3].positions[0]].end);
1732
- Aiequal(36, tv->offsets[tv->terms[3].positions[1]].start);
1733
- Aiequal(41, tv->offsets[tv->terms[3].positions[1]].end);
1734
-
1735
- frt_tv_destroy(tv);
1688
+ FrtTermVector *tv = ir->term_vector(ir, 3, rb_intern("body"));
1689
+ if (Apnotnull(tv)) {
1690
+ Asequal("body", rb_id2name(tv->field));
1691
+ Aiequal(4, tv->term_cnt);
1692
+ Asequal("word1", tv->terms[0].text);
1693
+ Asequal("word2", tv->terms[1].text);
1694
+ Asequal("word3", tv->terms[2].text);
1695
+ Asequal("word4", tv->terms[3].text);
1696
+ Aiequal(3, tv->terms[0].freq);
1697
+ Aiequal(2, tv->terms[0].positions[0]);
1698
+ Aiequal(4, tv->terms[0].positions[1]);
1699
+ Aiequal(7, tv->terms[0].positions[2]);
1700
+ Aiequal(12, tv->offsets[tv->terms[0].positions[0]].start);
1701
+ Aiequal(17, tv->offsets[tv->terms[0].positions[0]].end);
1702
+ Aiequal(24, tv->offsets[tv->terms[0].positions[1]].start);
1703
+ Aiequal(29, tv->offsets[tv->terms[0].positions[1]].end);
1704
+ Aiequal(42, tv->offsets[tv->terms[0].positions[2]].start);
1705
+ Aiequal(47, tv->offsets[tv->terms[0].positions[2]].end);
1706
+
1707
+ Aiequal(1, tv->terms[1].freq);
1708
+ Aiequal(3, tv->terms[1].positions[0]);
1709
+ Aiequal(18, tv->offsets[tv->terms[1].positions[0]].start);
1710
+ Aiequal(23, tv->offsets[tv->terms[1].positions[0]].end);
1711
+
1712
+ Aiequal(4, tv->terms[2].freq);
1713
+ Aiequal(0, tv->terms[2].positions[0]);
1714
+ Aiequal(5, tv->terms[2].positions[1]);
1715
+ Aiequal(8, tv->terms[2].positions[2]);
1716
+ Aiequal(9, tv->terms[2].positions[3]);
1717
+ Aiequal(0, tv->offsets[tv->terms[2].positions[0]].start);
1718
+ Aiequal(5, tv->offsets[tv->terms[2].positions[0]].end);
1719
+ Aiequal(30, tv->offsets[tv->terms[2].positions[1]].start);
1720
+ Aiequal(35, tv->offsets[tv->terms[2].positions[1]].end);
1721
+ Aiequal(48, tv->offsets[tv->terms[2].positions[2]].start);
1722
+ Aiequal(53, tv->offsets[tv->terms[2].positions[2]].end);
1723
+ Aiequal(54, tv->offsets[tv->terms[2].positions[3]].start);
1724
+ Aiequal(59, tv->offsets[tv->terms[2].positions[3]].end);
1725
+
1726
+ Aiequal(2, tv->terms[3].freq);
1727
+ Aiequal(1, tv->terms[3].positions[0]);
1728
+ Aiequal(6, tv->terms[3].positions[1]);
1729
+ Aiequal(6, tv->offsets[tv->terms[3].positions[0]].start);
1730
+ Aiequal(11, tv->offsets[tv->terms[3].positions[0]].end);
1731
+ Aiequal(36, tv->offsets[tv->terms[3].positions[1]].start);
1732
+ Aiequal(41, tv->offsets[tv->terms[3].positions[1]].end);
1733
+
1734
+ frt_tv_destroy(tv);
1735
+ }
1736
1736
 
1737
1737
  tvs = ir->term_vectors(ir, 3);
1738
1738
  Aiequal(3, tvs->size);
@@ -2103,7 +2103,7 @@ static void test_ir_delete(TestCase *tc, void *data)
2103
2103
  frt_ir_close(ir);
2104
2104
  frt_ir_close(ir2);
2105
2105
  reader_test_env_destroy(rte);
2106
- frt_store_deref(store);
2106
+ frt_store_close(store);
2107
2107
  }
2108
2108
 
2109
2109
  static void test_ir_read_while_optimizing(TestCase *tc, void *data)
@@ -2167,7 +2167,7 @@ static void test_ir_multivalue_fields(TestCase *tc, void *data)
2167
2167
  Aiequal(true, fi_store_offsets(fi));
2168
2168
  Aiequal(true, fi_store_positions(fi));
2169
2169
 
2170
- frt_doc_destroy(doc);
2170
+ frt_doc_destroy(doc);
2171
2171
  frt_iw_close(iw);
2172
2172
 
2173
2173
  ir = frt_ir_open(NULL, store);
@@ -2193,7 +2193,7 @@ static void test_ir_multivalue_fields(TestCase *tc, void *data)
2193
2193
  Aiequal(1, df->size);
2194
2194
  Asequal(author_text, df->data[0]);
2195
2195
 
2196
- frt_doc_destroy(doc);
2196
+ frt_doc_destroy(doc);
2197
2197
  frt_ir_delete_doc(ir, 0);
2198
2198
  frt_ir_close(ir);
2199
2199
  }
@@ -2324,10 +2324,10 @@ TestSuite *ts_index(TestSuite *suite)
2324
2324
  fs_store = frt_open_fs_store(TEST_DIR);
2325
2325
  tst_run_test_with_name(suite, test_ir_read_while_optimizing, fs_store, "test_ir_read_while_optimizing_on_disk");
2326
2326
  fs_store->clear_all(fs_store);
2327
- frt_store_deref(fs_store);
2327
+ frt_store_close(fs_store);
2328
2328
 
2329
2329
  tst_run_test(suite, test_ir_multivalue_fields, store);
2330
2330
 
2331
- frt_store_deref(store);
2331
+ frt_store_close(store);
2332
2332
  return suite;
2333
2333
  }
@@ -80,7 +80,8 @@ TestSuite *ts_q_const_score(TestSuite *suite)
80
80
  tst_run_test(suite, test_const_score_query, (void *)searcher);
81
81
  tst_run_test(suite, test_const_score_query_hash, NULL);
82
82
 
83
- frt_store_deref(store);
84
83
  frt_searcher_close(searcher);
84
+ frt_ir_close(ir);
85
+ frt_store_close(store);
85
86
  return suite;
86
87
  }
@@ -57,7 +57,8 @@ TestSuite *ts_q_filtered(TestSuite *suite)
57
57
 
58
58
  tst_run_test(suite, test_filtered_query, (void *)searcher);
59
59
 
60
- frt_store_deref(store);
61
- searcher->close(searcher);
60
+ frt_searcher_close(searcher);
61
+ frt_ir_close(ir);
62
+ frt_store_close(store);
62
63
  return suite;
63
64
  }
@@ -110,6 +110,7 @@ static void test_fuzziness(TestCase *tc, void *data)
110
110
  frt_td_destroy(top_docs);
111
111
 
112
112
  frt_searcher_close(sea);
113
+ frt_ir_close(ir);
113
114
  }
114
115
 
115
116
  static void test_fuzziness_long(TestCase *tc, void *data)
@@ -165,6 +166,7 @@ static void test_fuzziness_long(TestCase *tc, void *data)
165
166
  frt_td_destroy(top_docs);
166
167
 
167
168
  frt_searcher_close(sea);
169
+ frt_ir_close(ir);
168
170
  }
169
171
 
170
172
  /**
@@ -239,6 +241,6 @@ TestSuite *ts_q_fuzzy(TestSuite *suite)
239
241
  tst_run_test(suite, test_fuzzy_query_hash, (void *)store);
240
242
  tst_run_test(suite, test_fuzzy_query_to_s, (void *)store);
241
243
 
242
- frt_store_deref(store);
244
+ frt_store_close(store);
243
245
  return suite;
244
246
  }
@@ -100,6 +100,7 @@ static void test_span_term(TestCase *tc, void *data)
100
100
  frt_q_deref(tq);
101
101
 
102
102
  frt_searcher_close(sea);
103
+ frt_ir_close(ir);
103
104
  }
104
105
 
105
106
  static void test_span_term_hash(TestCase *tc, void *data)
@@ -169,6 +170,7 @@ static void test_span_multi_term(TestCase *tc, void *data)
169
170
  frt_q_deref(mtq);
170
171
 
171
172
  frt_searcher_close(sea);
173
+ frt_ir_close(ir);
172
174
  }
173
175
 
174
176
  static void test_span_multi_term_hash(TestCase *tc, void *data)
@@ -230,6 +232,7 @@ static void test_span_prefix(TestCase *tc, void *data)
230
232
  frt_q_deref(prq);
231
233
 
232
234
  frt_searcher_close(sea);
235
+ frt_ir_close(ir);
233
236
  }
234
237
 
235
238
  static void test_span_prefix_hash(TestCase *tc, void *data)
@@ -279,6 +282,7 @@ static void test_span_first(TestCase *tc, void *data)
279
282
  frt_q_deref(q);
280
283
 
281
284
  frt_searcher_close(sea);
285
+ frt_ir_close(ir);
282
286
  }
283
287
 
284
288
  static void test_span_first_hash(TestCase *tc, void *data)
@@ -327,6 +331,7 @@ static void test_span_or(TestCase *tc, void *data)
327
331
  TEST_SE(q, ir, "SpanOrEnum(span_or[span_terms(field:flip),span_terms(field:flop)])@START");
328
332
  frt_q_deref(q);
329
333
  frt_searcher_close(sea);
334
+ frt_ir_close(ir);
330
335
  }
331
336
 
332
337
  static void test_span_or_hash(TestCase *tc, void *data)
@@ -407,6 +412,7 @@ static void test_span_near(TestCase *tc, void *data)
407
412
  frt_q_deref(q);
408
413
 
409
414
  frt_searcher_close(sea);
415
+ frt_ir_close(ir);
410
416
  }
411
417
 
412
418
  static void test_span_near_hash(TestCase *tc, void *data)
@@ -514,6 +520,7 @@ static void test_span_not(TestCase *tc, void *data)
514
520
  frt_q_deref(q);
515
521
 
516
522
  frt_searcher_close(sea);
523
+ frt_ir_close(ir);
517
524
  }
518
525
 
519
526
  static void test_span_not_hash(TestCase *tc, void *data)
@@ -573,6 +580,6 @@ TestSuite *ts_q_span(TestSuite *suite)
573
580
  tst_run_test(suite, test_span_near_hash, NULL);
574
581
  tst_run_test(suite, test_span_not, (void *)store);
575
582
  tst_run_test(suite, test_span_not_hash, NULL);
576
- frt_store_deref(store);
583
+ frt_store_close(store);
577
584
  return suite;
578
585
  }
@@ -42,7 +42,7 @@ void test_write_to(TestCase *tc, void *data)
42
42
  frt_is_close(istream);
43
43
 
44
44
  Aiequal(17021, fs_store->length(fs_store, "_rw_funny_string.cfs"));
45
- frt_store_deref(ram_store);
45
+ frt_store_close(ram_store);
46
46
  ram_store = frt_open_ram_store_and_copy(NULL, fs_store, false);
47
47
 
48
48
  istream = ram_store->open_input(ram_store, "_rw_funny_string.cfs");
@@ -54,8 +54,8 @@ void test_write_to(TestCase *tc, void *data)
54
54
  Aiequal(17021, ram_store->length(ram_store, "_rw_funny_string.cfs"));
55
55
 
56
56
  fs_store->clear_all(fs_store);
57
- frt_store_deref(fs_store);
58
- frt_store_deref(ram_store);
57
+ frt_store_close(fs_store);
58
+ frt_store_close(ram_store);
59
59
  }
60
60
 
61
61
  /**
@@ -71,7 +71,7 @@ TestSuite *ts_ram_store(TestSuite *suite)
71
71
 
72
72
  tst_run_test(suite, test_write_to, NULL);
73
73
 
74
- frt_store_deref(store);
74
+ frt_store_close(store);
75
75
 
76
76
  return suite;
77
77
  }