isomorfeus-ferret 0.13.7 → 0.13.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -4
  3. data/ext/isomorfeus_ferret_ext/bm_store.c +3 -3
  4. data/ext/isomorfeus_ferret_ext/frb_analysis.c +7 -4
  5. data/ext/isomorfeus_ferret_ext/frb_index.c +18 -24
  6. data/ext/isomorfeus_ferret_ext/frb_qparser.c +2 -1
  7. data/ext/isomorfeus_ferret_ext/frb_search.c +23 -19
  8. data/ext/isomorfeus_ferret_ext/frb_store.c +34 -36
  9. data/ext/isomorfeus_ferret_ext/frt_analysis.c +4 -4
  10. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  11. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +1 -1
  12. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +1 -1
  13. data/ext/isomorfeus_ferret_ext/frt_compound_io.c +41 -66
  14. data/ext/isomorfeus_ferret_ext/frt_config.h +8 -0
  15. data/ext/isomorfeus_ferret_ext/frt_except.c +1 -0
  16. data/ext/isomorfeus_ferret_ext/frt_field_index.c +1 -1
  17. data/ext/isomorfeus_ferret_ext/frt_filter.c +2 -4
  18. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +24 -19
  19. data/ext/isomorfeus_ferret_ext/frt_global.c +6 -4
  20. data/ext/isomorfeus_ferret_ext/frt_global.h +1 -1
  21. data/ext/isomorfeus_ferret_ext/frt_hash.c +40 -48
  22. data/ext/isomorfeus_ferret_ext/frt_hash.h +14 -16
  23. data/ext/isomorfeus_ferret_ext/frt_ind.c +3 -4
  24. data/ext/isomorfeus_ferret_ext/frt_index.c +152 -222
  25. data/ext/isomorfeus_ferret_ext/frt_index.h +31 -31
  26. data/ext/isomorfeus_ferret_ext/frt_lang.c +1 -4
  27. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +8 -9
  28. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +1 -1
  29. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +7 -7
  30. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +1 -1
  31. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -3
  32. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +2 -2
  33. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +1742 -1742
  34. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +2 -3
  35. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +1 -1
  36. data/ext/isomorfeus_ferret_ext/frt_q_range.c +1 -1
  37. data/ext/isomorfeus_ferret_ext/frt_q_span.c +12 -11
  38. data/ext/isomorfeus_ferret_ext/frt_q_term.c +2 -2
  39. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -1
  40. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +24 -40
  41. data/ext/isomorfeus_ferret_ext/frt_search.c +30 -29
  42. data/ext/isomorfeus_ferret_ext/frt_search.h +18 -19
  43. data/ext/isomorfeus_ferret_ext/frt_sort.c +1 -1
  44. data/ext/isomorfeus_ferret_ext/frt_store.c +47 -40
  45. data/ext/isomorfeus_ferret_ext/frt_store.h +45 -47
  46. data/ext/isomorfeus_ferret_ext/frt_threading.h +12 -5
  47. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +4 -3
  48. data/ext/isomorfeus_ferret_ext/test_1710.c +1 -2
  49. data/ext/isomorfeus_ferret_ext/test_compound_io.c +8 -8
  50. data/ext/isomorfeus_ferret_ext/test_fields.c +7 -7
  51. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +1 -1
  52. data/ext/isomorfeus_ferret_ext/test_filter.c +5 -4
  53. data/ext/isomorfeus_ferret_ext/test_fs_store.c +1 -1
  54. data/ext/isomorfeus_ferret_ext/test_highlighter.c +4 -2
  55. data/ext/isomorfeus_ferret_ext/test_index.c +63 -63
  56. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +3 -2
  57. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +4 -3
  58. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +4 -2
  59. data/ext/isomorfeus_ferret_ext/test_q_span.c +9 -2
  60. data/ext/isomorfeus_ferret_ext/test_ram_store.c +4 -4
  61. data/ext/isomorfeus_ferret_ext/test_search.c +10 -5
  62. data/ext/isomorfeus_ferret_ext/test_segments.c +4 -3
  63. data/ext/isomorfeus_ferret_ext/test_sort.c +18 -10
  64. data/ext/isomorfeus_ferret_ext/test_store.c +1 -1
  65. data/ext/isomorfeus_ferret_ext/test_term.c +5 -3
  66. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +2 -2
  67. data/ext/isomorfeus_ferret_ext/test_threading.c +5 -4
  68. data/lib/isomorfeus/ferret/index/index.rb +8 -3
  69. data/lib/isomorfeus/ferret/version.rb +1 -1
  70. metadata +16 -2
@@ -28,17 +28,6 @@ void frt_with_lock_name(FrtStore *store, const char *lock_name, void (*func)(voi
28
28
  store->close_lock_i(lock);
29
29
  }
30
30
 
31
- void frt_store_deref(FrtStore *store)
32
- {
33
- frt_mutex_lock(&store->mutex_i);
34
- if (--store->ref_cnt <= 0) {
35
- store->close_i(store);
36
- }
37
- else {
38
- frt_mutex_unlock(&store->mutex_i);
39
- }
40
- }
41
-
42
31
  FrtLock *frt_open_lock(FrtStore *store, const char *lockname)
43
32
  {
44
33
  FrtLock *lock = store->open_lock_i(store, lockname);
@@ -78,16 +67,25 @@ FrtStore *frt_store_new(void) {
78
67
  }
79
68
 
80
69
  /**
81
- * Destroy the store freeing allocated resources
70
+ * close the store freeing allocated resources
82
71
  *
83
72
  * @param store the store struct to free
84
73
  */
85
- void frt_store_destroy(FrtStore *store)
86
- {
87
- frt_mutex_destroy(&store->mutex_i);
88
- frt_mutex_destroy(&store->mutex);
89
- frt_hs_destroy(store->locks);
90
- free(store);
74
+ void frt_store_close(FrtStore *store) {
75
+ if (store->ref_cnt == 0) {
76
+ fprintf(stderr, "store ref_cnt to low\n");
77
+ FRT_RAISE(FRT_STATE_ERROR, "store ref_cnt to low\n");
78
+ }
79
+
80
+ if (FRT_DEREF(store) == 0) {
81
+ frt_mutex_lock(&store->mutex_i);
82
+ store->close_i(store);
83
+ frt_hs_destroy(store->locks);
84
+ frt_mutex_destroy(&store->mutex);
85
+ frt_mutex_unlock(&store->mutex_i);
86
+ frt_mutex_destroy(&store->mutex_i);
87
+ free(store);
88
+ }
91
89
  }
92
90
 
93
91
  /**
@@ -127,7 +125,7 @@ off_t frt_os_pos(FrtOutStream *os)
127
125
  return os->buf.start + os->buf.pos;
128
126
  }
129
127
 
130
- void frt_os_seek(FrtOutStream *os, off_t new_pos)
128
+ void frt_os_seek(FrtOutStream *os, frt_off_t new_pos)
131
129
  {
132
130
  frt_os_flush(os);
133
131
  os->buf.start = new_pos;
@@ -186,10 +184,12 @@ void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len)
186
184
  */
187
185
  FrtInStream *frt_is_new(void) {
188
186
  FrtInStream *is = FRT_ALLOC(FrtInStream);
187
+ is->f = FRT_ALLOC_AND_ZERO(FrtInStreamFile);
188
+ is->f->ref_cnt = 1;
189
189
  is->buf.start = 0;
190
190
  is->buf.pos = 0;
191
191
  is->buf.len = 0;
192
- is->ref_cnt_ptr = FRT_ALLOC_AND_ZERO(int);
192
+ is->ref_cnt = 1;
193
193
  return is;
194
194
  }
195
195
 
@@ -202,9 +202,9 @@ FrtInStream *frt_is_new(void) {
202
202
  */
203
203
  static void is_refill(FrtInStream *is)
204
204
  {
205
- off_t start = is->buf.start + is->buf.pos;
206
- off_t last = start + FRT_BUFFER_SIZE;
207
- off_t flen = is->m->length_i(is);
205
+ frt_off_t start = is->buf.start + is->buf.pos;
206
+ frt_off_t last = start + FRT_BUFFER_SIZE;
207
+ frt_off_t flen = is->m->length_i(is);
208
208
 
209
209
  if (last > flen) { /* don't read past EOF */
210
210
  last = flen;
@@ -254,7 +254,7 @@ off_t frt_is_pos(FrtInStream *is)
254
254
  frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len)
255
255
  {
256
256
  int i;
257
- off_t start;
257
+ frt_off_t start;
258
258
 
259
259
  if ((is->buf.pos + len) < is->buf.len) {
260
260
  for (i = 0; i < len; i++) {
@@ -273,12 +273,10 @@ frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len)
273
273
  return buf;
274
274
  }
275
275
 
276
- void frt_is_seek(FrtInStream *is, off_t pos)
277
- {
276
+ void frt_is_seek(FrtInStream *is, frt_off_t pos) {
278
277
  if (pos >= is->buf.start && pos < (is->buf.start + is->buf.len)) {
279
278
  is->buf.pos = pos - is->buf.start; /* seek within buffer */
280
- }
281
- else {
279
+ } else {
282
280
  is->buf.start = pos;
283
281
  is->buf.pos = 0;
284
282
  is->buf.len = 0; /* trigger refill() on read() */
@@ -286,21 +284,30 @@ void frt_is_seek(FrtInStream *is, off_t pos)
286
284
  }
287
285
  }
288
286
 
289
- void frt_is_close(FrtInStream *is)
290
- {
291
- if (--(*(is->ref_cnt_ptr)) < 0) {
292
- is->m->close_i(is);
293
- free(is->ref_cnt_ptr);
287
+ void frt_is_close(FrtInStream *is) {
288
+ if (is->ref_cnt == 0) {
289
+ fprintf(stderr, "is ref_cnt to low\n");
290
+ FRT_RAISE(FRT_STATE_ERROR, "is ref_cnt to low\n");
291
+ }
292
+
293
+ if (FRT_DEREF(is) == 0) {
294
+ if (FRT_DEREF(is->f) == 0) {
295
+ is->m->close_i(is);
296
+ free(is->f);
297
+ }
298
+ free(is);
294
299
  }
295
- free(is);
296
300
  }
297
301
 
298
302
  FrtInStream *frt_is_clone(FrtInStream *is)
299
303
  {
300
- FrtInStream *new_index_i = FRT_ALLOC(FrtInStream);
301
- memcpy(new_index_i, is, sizeof(FrtInStream));
302
- (*(new_index_i->ref_cnt_ptr))++;
303
- return new_index_i;
304
+ if (!(is->f))
305
+ return NULL;
306
+ FrtInStream *new_is = FRT_ALLOC(FrtInStream);
307
+ memcpy(new_is, is, sizeof(FrtInStream));
308
+ new_is->ref_cnt = 1;
309
+ FRT_REF(new_is->f);
310
+ return new_is;
304
311
  }
305
312
 
306
313
  frt_i32 frt_is_read_i32(FrtInStream *is)
@@ -377,7 +384,7 @@ unsigned int frt_is_read_vint(FrtInStream *is)
377
384
  /* optimized to use unchecked read_byte if there is definitely space */
378
385
  off_t frt_is_read_voff_t(FrtInStream *is)
379
386
  {
380
- register off_t res, b;
387
+ register frt_off_t res, b;
381
388
  register int shift = 7;
382
389
 
383
390
  if (is->buf.pos > (is->buf.len - VINT_MAX_LEN)) {
@@ -546,7 +553,7 @@ void frt_os_write_vint(FrtOutStream *os, register unsigned int num)
546
553
  }
547
554
 
548
555
  /* optimized to use an unchecked write if there is space */
549
- void frt_os_write_voff_t(FrtOutStream *os, register off_t num)
556
+ void frt_os_write_voff_t(FrtOutStream *os, register frt_off_t num)
550
557
  {
551
558
  if (os->buf.pos > VINT_END) {
552
559
  while (num > 127) {
@@ -13,9 +13,9 @@
13
13
  typedef struct FrtBuffer
14
14
  {
15
15
  frt_uchar buf[FRT_BUFFER_SIZE];
16
- off_t start;
17
- off_t pos;
18
- off_t len;
16
+ frt_off_t start;
17
+ frt_off_t pos;
18
+ frt_off_t len;
19
19
  } FrtBuffer;
20
20
 
21
21
  typedef struct FrtOutStream FrtOutStream;
@@ -38,7 +38,7 @@ struct FrtOutStreamMethods {
38
38
  * @param pos the position to seek in the stream
39
39
  * @raise FRT_IO_ERROR if there is an error seeking in the output stream
40
40
  */
41
- void (*seek_i)(struct FrtOutStream *os, off_t pos);
41
+ void (*seek_i)(struct FrtOutStream *os, frt_off_t pos);
42
42
 
43
43
  /**
44
44
  * Close any resources used by the output stream +os+
@@ -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
+ frt_off_t len;
58
+ _Atomic unsigned int ref_cnt;
59
59
  } FrtRAMFile;
60
60
 
61
61
  struct FrtOutStream
@@ -66,7 +66,7 @@ struct FrtOutStream
66
66
  int fd;
67
67
  FrtRAMFile *rf;
68
68
  } file;
69
- off_t pointer; /* only used by RAMOut */
69
+ frt_off_t pointer; /* only used by RAMOut */
70
70
  const struct FrtOutStreamMethods *m;
71
71
  };
72
72
 
@@ -95,7 +95,7 @@ struct FrtInStreamMethods
95
95
  * @param pos the position to seek
96
96
  * @raise FRT_IO_ERROR if the seek fails
97
97
  */
98
- void (*seek_i)(struct FrtInStream *is, off_t pos);
98
+ void (*seek_i)(struct FrtInStream *is, frt_off_t pos);
99
99
 
100
100
  /**
101
101
  * Returns the length of the input stream +is+
@@ -103,7 +103,7 @@ struct FrtInStreamMethods
103
103
  * @param is self
104
104
  * @raise FRT_IO_ERROR if there is an error getting the file length
105
105
  */
106
- off_t (*length_i)(struct FrtInStream *is);
106
+ frt_off_t (*length_i)(struct FrtInStream *is);
107
107
 
108
108
  /**
109
109
  * Close the resources allocated to the inputstream +is+
@@ -114,29 +114,31 @@ 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
- {
127
- off_t pointer; /* only used by RAMIn */
123
+ } FrtInStreamFile;
124
+
125
+ struct FrtInStream {
126
+ FrtBuffer buf;
127
+ struct FrtInStreamFile *f;
128
+ union {
129
+ frt_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
 
135
137
  struct FrtCompoundInStream
136
138
  {
137
139
  FrtInStream *sub;
138
- off_t offset;
139
- off_t length;
140
+ frt_off_t offset;
141
+ frt_off_t length;
140
142
  };
141
143
 
142
144
  #define frt_is_length(mis) mis->m->length_i(mis)
@@ -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+.
@@ -275,7 +274,7 @@ struct FrtStore
275
274
  * @return the length of the file in bytes
276
275
  * @raise FRT_IO_ERROR if there is an error checking the file length
277
276
  */
278
- off_t (*length)(FrtStore *store, const char *filename);
277
+ frt_off_t (*length)(FrtStore *store, const char *filename);
279
278
 
280
279
  /**
281
280
  * Allocate the resources needed for the output stream in the +store+ with
@@ -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.
@@ -466,7 +465,7 @@ extern void frt_os_close(FrtOutStream *os);
466
465
  * @param os the FrtOutStream to get the position from
467
466
  * @return the current position in FrtOutStream +os+
468
467
  */
469
- extern off_t frt_os_pos(FrtOutStream *os);
468
+ extern frt_off_t frt_os_pos(FrtOutStream *os);
470
469
 
471
470
  /**
472
471
  * Set the current position in FrtOutStream +os+.
@@ -475,7 +474,7 @@ extern off_t frt_os_pos(FrtOutStream *os);
475
474
  * @param pos the new position in the FrtOutStream
476
475
  * @raise FRT_IO_ERROR if there is a file-system IO error seeking the file
477
476
  */
478
- extern void frt_os_seek(FrtOutStream *os, off_t new_pos);
477
+ extern void frt_os_seek(FrtOutStream *os, frt_off_t new_pos);
479
478
 
480
479
  /**
481
480
  * Write a single byte +b+ to the FrtOutStream +os+
@@ -542,14 +541,14 @@ extern void frt_os_write_u64(FrtOutStream *os, frt_u64 num);
542
541
  extern void frt_os_write_vint(FrtOutStream *os, register unsigned int num);
543
542
 
544
543
  /**
545
- * Write an unsigned off_t to FrtOutStream in compressed VINT format.
544
+ * Write an unsigned frt_off_t to FrtOutStream in compressed VINT format.
546
545
  * TODO: describe VINT format
547
546
  *
548
547
  * @param os FrtOutStream to write to
549
- * @param num the off_t to write
548
+ * @param num the frt_off_t to write
550
549
  * @raise FRT_IO_ERROR if there is an error writing to the file-system
551
550
  */
552
- extern void frt_os_write_voff_t(FrtOutStream *os, register off_t num);
551
+ extern void frt_os_write_voff_t(FrtOutStream *os, register frt_off_t num);
553
552
 
554
553
  /**
555
554
  * Write an unsigned 64bit int to FrtOutStream in compressed VINT format.
@@ -592,7 +591,7 @@ extern void frt_os_write_string(FrtOutStream *os, const char *str);
592
591
  * @param is the FrtInStream to get the current position from
593
592
  * @return the current position within the FrtInStream +is+
594
593
  */
595
- extern off_t frt_is_pos(FrtInStream *is);
594
+ extern frt_off_t frt_is_pos(FrtInStream *is);
596
595
 
597
596
  /**
598
597
  * Set the current position in FrtInStream +is+ to +pos+.
@@ -602,7 +601,7 @@ extern off_t frt_is_pos(FrtInStream *is);
602
601
  * @raise FRT_IO_ERROR if there is a error seeking from the file-system
603
602
  * @raise FRT_EOF_ERROR if there is an attempt to seek past the end of the file
604
603
  */
605
- extern void frt_is_seek(FrtInStream *is, off_t pos);
604
+ extern void frt_is_seek(FrtInStream *is, frt_off_t pos);
606
605
 
607
606
  /**
608
607
  * Close the FrtInStream freeing all allocated resources.
@@ -706,15 +705,15 @@ extern unsigned int frt_is_read_vint(FrtInStream *is);
706
705
  extern void frt_is_skip_vints(FrtInStream *is, register int cnt);
707
706
 
708
707
  /**
709
- * Read a compressed (VINT) unsigned off_t from the FrtInStream.
708
+ * Read a compressed (VINT) unsigned frt_off_t from the FrtInStream.
710
709
  * TODO: describe VINT format
711
710
  *
712
711
  * @param is the FrtInStream to read from
713
- * @return a off_t
712
+ * @return a frt_off_t
714
713
  * @raise FRT_IO_ERROR if there is a error reading from the file-system
715
714
  * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
716
715
  */
717
- extern off_t frt_is_read_voff_t(FrtInStream *is);
716
+ extern frt_off_t frt_is_read_voff_t(FrtInStream *is);
718
717
 
719
718
  /**
720
719
  * Read a compressed (VINT) unsigned 64bit int from the FrtInStream.
@@ -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
  }
@@ -2,7 +2,7 @@
2
2
  #include "frt_search.h"
3
3
  #include "test.h"
4
4
 
5
- #undef close
5
+ // #undef close
6
6
 
7
7
  #define FILTER_DOCS_SIZE 10
8
8
  #define ARRAY_SIZE 20
@@ -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
  }
@@ -3,7 +3,7 @@
3
3
  #include "testhelper.h"
4
4
  #include "test.h"
5
5
 
6
- #undef close
6
+ // #undef close
7
7
 
8
8
  #define ARRAY_SIZE 100
9
9
 
@@ -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
  }