isomorfeus-ferret 0.13.6 → 0.13.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -34
  3. data/ext/isomorfeus_ferret_ext/frb_analysis.c +7 -4
  4. data/ext/isomorfeus_ferret_ext/frb_index.c +18 -24
  5. data/ext/isomorfeus_ferret_ext/frb_qparser.c +2 -1
  6. data/ext/isomorfeus_ferret_ext/frb_search.c +23 -19
  7. data/ext/isomorfeus_ferret_ext/frb_store.c +34 -36
  8. data/ext/isomorfeus_ferret_ext/frt_analysis.c +2 -2
  9. data/ext/isomorfeus_ferret_ext/frt_analysis.h +5 -5
  10. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +1 -1
  11. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +1 -1
  12. data/ext/isomorfeus_ferret_ext/frt_compound_io.c +34 -59
  13. data/ext/isomorfeus_ferret_ext/frt_except.c +1 -0
  14. data/ext/isomorfeus_ferret_ext/frt_field_index.c +1 -1
  15. data/ext/isomorfeus_ferret_ext/frt_filter.c +2 -4
  16. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +11 -12
  17. data/ext/isomorfeus_ferret_ext/frt_global.c +6 -4
  18. data/ext/isomorfeus_ferret_ext/frt_global.h +2 -2
  19. data/ext/isomorfeus_ferret_ext/frt_hash.c +40 -48
  20. data/ext/isomorfeus_ferret_ext/frt_hash.h +14 -16
  21. data/ext/isomorfeus_ferret_ext/frt_ind.c +3 -4
  22. data/ext/isomorfeus_ferret_ext/frt_index.c +127 -197
  23. data/ext/isomorfeus_ferret_ext/frt_index.h +13 -13
  24. data/ext/isomorfeus_ferret_ext/frt_lang.c +1 -4
  25. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +8 -9
  26. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +1 -1
  27. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +7 -7
  28. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +1 -1
  29. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -3
  30. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +2 -2
  31. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +1742 -1742
  32. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +2 -3
  33. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +1 -1
  34. data/ext/isomorfeus_ferret_ext/frt_q_range.c +1 -1
  35. data/ext/isomorfeus_ferret_ext/frt_q_span.c +12 -11
  36. data/ext/isomorfeus_ferret_ext/frt_q_term.c +2 -2
  37. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -1
  38. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +18 -34
  39. data/ext/isomorfeus_ferret_ext/frt_search.c +30 -29
  40. data/ext/isomorfeus_ferret_ext/frt_search.h +18 -19
  41. data/ext/isomorfeus_ferret_ext/frt_sort.c +1 -1
  42. data/ext/isomorfeus_ferret_ext/frt_store.c +45 -41
  43. data/ext/isomorfeus_ferret_ext/frt_store.h +24 -26
  44. data/ext/isomorfeus_ferret_ext/frt_threading.h +12 -5
  45. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +4 -3
  46. data/ext/isomorfeus_ferret_ext/test_1710.c +1 -2
  47. data/ext/isomorfeus_ferret_ext/test_compound_io.c +8 -8
  48. data/ext/isomorfeus_ferret_ext/test_fields.c +7 -7
  49. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +1 -1
  50. data/ext/isomorfeus_ferret_ext/test_filter.c +5 -4
  51. data/ext/isomorfeus_ferret_ext/test_fs_store.c +1 -1
  52. data/ext/isomorfeus_ferret_ext/test_highlighter.c +4 -2
  53. data/ext/isomorfeus_ferret_ext/test_index.c +61 -61
  54. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +3 -2
  55. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +4 -3
  56. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +4 -2
  57. data/ext/isomorfeus_ferret_ext/test_q_span.c +9 -2
  58. data/ext/isomorfeus_ferret_ext/test_ram_store.c +4 -4
  59. data/ext/isomorfeus_ferret_ext/test_search.c +10 -5
  60. data/ext/isomorfeus_ferret_ext/test_segments.c +4 -3
  61. data/ext/isomorfeus_ferret_ext/test_sort.c +18 -10
  62. data/ext/isomorfeus_ferret_ext/test_store.c +1 -1
  63. data/ext/isomorfeus_ferret_ext/test_term.c +5 -3
  64. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +2 -2
  65. data/ext/isomorfeus_ferret_ext/test_threading.c +5 -4
  66. data/lib/isomorfeus/ferret/index/index.rb +8 -3
  67. data/lib/isomorfeus/ferret/version.rb +1 -1
  68. metadata +2 -2
@@ -100,7 +100,7 @@ typedef struct FrtFieldInfo {
100
100
  float boost;
101
101
  unsigned int bits;
102
102
  int number;
103
- int ref_cnt;
103
+ _Atomic unsigned int ref_cnt;
104
104
  VALUE rfi;
105
105
  } FrtFieldInfo;
106
106
 
@@ -133,7 +133,7 @@ extern void frt_fi_deref(FrtFieldInfo *fi);
133
133
  #define FIELD_INFOS_INIT_CAPA 4
134
134
  /* carry changes over to dummy_fis in test/test_segments.c */
135
135
  typedef struct FrtFieldInfos {
136
- FrtStoreValue store;
136
+ FrtStoreValue store_val;
137
137
  FrtCompressionType compression;
138
138
  FrtIndexValue index;
139
139
  FrtTermVectorValue term_vector;
@@ -141,7 +141,7 @@ typedef struct FrtFieldInfos {
141
141
  int capa;
142
142
  FrtFieldInfo **fields;
143
143
  FrtHash *field_dict;
144
- int ref_cnt;
144
+ _Atomic unsigned int ref_cnt;
145
145
  VALUE rfis;
146
146
  } FrtFieldInfos;
147
147
 
@@ -167,18 +167,18 @@ extern void frt_fis_deref(FrtFieldInfos *fis);
167
167
  #define FRT_SEGMENTS_FILE_NAME "segments"
168
168
 
169
169
  typedef struct FrtSegmentInfo {
170
- int ref_cnt;
171
- char *name;
172
- FrtStore *store;
173
- int doc_cnt;
174
- int del_gen;
175
- int *norm_gens;
176
- int norm_gens_size;
177
- bool use_compound_file;
170
+ _Atomic unsigned int ref_cnt;
171
+ char *name;
172
+ FrtStore *store;
173
+ int doc_cnt;
174
+ int del_gen;
175
+ int *norm_gens;
176
+ int norm_gens_size;
177
+ bool use_compound_file;
178
178
  } FrtSegmentInfo;
179
179
 
180
180
  extern FrtSegmentInfo *frt_si_new(char *name, int doc_cnt, FrtStore *store);
181
- extern void frt_si_deref(FrtSegmentInfo *si);
181
+ extern void frt_si_close(FrtSegmentInfo *si);
182
182
  extern bool frt_si_has_deletions(FrtSegmentInfo *si);
183
183
  extern bool frt_si_has_separate_norms(FrtSegmentInfo *si);
184
184
  extern void frt_si_advance_norm_gen(FrtSegmentInfo *si, int field_num);
@@ -671,7 +671,7 @@ struct FrtIndexReader {
671
671
  bool (*is_latest_i)(FrtIndexReader *ir);
672
672
  void (*commit_i)(FrtIndexReader *ir);
673
673
  void (*close_i)(FrtIndexReader *ir);
674
- int ref_cnt;
674
+ _Atomic unsigned int ref_cnt;
675
675
  FrtDeleter *deleter;
676
676
  FrtStore *store;
677
677
  FrtLock *write_lock;
@@ -43,10 +43,7 @@ void *frt_erealloc(void *ptr, size_t size)
43
43
  return p;
44
44
  }
45
45
 
46
-
47
- struct timeval rb_time_interval _((VALUE));
48
-
49
- extern void frt_micro_sleep(const int micro_seconds) {
46
+ void frt_micro_sleep(const int micro_seconds) {
50
47
  rb_thread_wait_for(rb_time_interval(rb_float_new((double)micro_seconds/1000000.0)));
51
48
  }
52
49
 
@@ -328,19 +328,18 @@ char *frt_mulmap_dynamic_map(FrtMultiMapper *self, char *from)
328
328
  return to;
329
329
  }
330
330
 
331
- void frt_mulmap_destroy(FrtMultiMapper *self)
332
- {
333
- if (--(self->ref_cnt) <= 0) {
331
+ void frt_mulmap_destroy(FrtMultiMapper *mulm) {
332
+ if (FRT_DEREF(mulm) <= 0) {
334
333
  int i;
335
- mulmap_free_dstates(self);
336
- for (i = self->size - 1; i >= 0; i--) {
337
- FrtMapping *mapping = self->mappings[i];
334
+ mulmap_free_dstates(mulm);
335
+ for (i = mulm->size - 1; i >= 0; i--) {
336
+ FrtMapping *mapping = mulm->mappings[i];
338
337
  free(mapping->pattern);
339
338
  free(mapping->replacement);
340
339
  free(mapping);
341
340
  }
342
- free(self->mappings);
343
- free(self->dstates);
344
- free(self);
341
+ free(mulm->mappings);
342
+ free(mulm->dstates);
343
+ free(mulm);
345
344
  }
346
345
  }
@@ -38,7 +38,7 @@ typedef struct FrtMultiMapper
38
38
  FrtState **nstates;
39
39
  int nsize;
40
40
  int *next_states;
41
- int ref_cnt;
41
+ _Atomic unsigned int ref_cnt;
42
42
  } FrtMultiMapper;
43
43
 
44
44
  extern FrtMultiMapper *frt_mulmap_new();
@@ -1264,10 +1264,10 @@ void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur) {
1264
1264
  }
1265
1265
  }
1266
1266
 
1267
- void frt_bc_deref(FrtBooleanClause *self) {
1268
- if (--self->ref_cnt <= 0) {
1269
- frt_q_deref(self->query);
1270
- free(self);
1267
+ void frt_bc_deref(FrtBooleanClause *bc) {
1268
+ if (FRT_DEREF(bc) == 0) {
1269
+ frt_q_deref(bc->query);
1270
+ free(bc);
1271
1271
  }
1272
1272
  }
1273
1273
 
@@ -1280,7 +1280,7 @@ static int bc_eq(FrtBooleanClause *self, FrtBooleanClause *o) {
1280
1280
  }
1281
1281
 
1282
1282
  FrtBooleanClause *frt_bc_alloc(void) {
1283
- return FRT_ALLOC(FrtBooleanClause);
1283
+ return FRT_ALLOC_AND_ZERO(FrtBooleanClause);
1284
1284
  }
1285
1285
 
1286
1286
  FrtBooleanClause *frt_bc_init(FrtBooleanClause *self, FrtQuery *query, FrtBCType occur) {
@@ -1345,7 +1345,7 @@ static FrtQuery *bq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
1345
1345
  }
1346
1346
  }
1347
1347
 
1348
- self->ref_cnt++;
1348
+ FRT_REF(self);
1349
1349
  /* replace each clause's query with its rewritten query */
1350
1350
  for (i = 0; i < clause_cnt; i++) {
1351
1351
  FrtBooleanClause *clause = BQ(self)->clauses[i];
@@ -1364,7 +1364,7 @@ static FrtQuery *bq_rewrite(FrtQuery *self, FrtIndexReader *ir) {
1364
1364
  for (j = 0; j < clause_cnt; j++) {
1365
1365
  FRT_REF(BQ(self)->clauses[j]);
1366
1366
  }
1367
- self->ref_cnt--;
1367
+ FRT_DEREF(self);
1368
1368
  self = new_self;
1369
1369
  self->ref_cnt = 1;
1370
1370
  rewritten = true;
@@ -2,7 +2,7 @@
2
2
  #include "frt_search.h"
3
3
  #include "frt_helper.h"
4
4
 
5
- #undef close
5
+ // #undef close
6
6
 
7
7
  /****************************************************************************
8
8
  *
@@ -45,9 +45,15 @@ static FrtExplanation *masc_explain(FrtScorer *self, int doc_num)
45
45
  return frt_expl_new(1.0, "MatchAllScorer");
46
46
  }
47
47
 
48
+ void masc_destroy_i(FrtScorer *self) {
49
+ frt_ir_close(MASc(self)->ir);
50
+ frt_scorer_destroy_i(self);
51
+ }
52
+
48
53
  static FrtScorer *masc_new(FrtWeight *weight, FrtIndexReader *ir) {
49
- FrtScorer *self = frt_scorer_new(MatchAllScorer, weight->similarity);
54
+ FrtScorer *self = frt_scorer_new(MatchAllScorer, weight->similarity);
50
55
  MASc(self)->ir = ir;
56
+ FRT_REF(ir);
51
57
  MASc(self)->max_doc = ir->max_doc(ir);
52
58
  MASc(self)->score = weight->value;
53
59
  self->doc = -1;
@@ -55,7 +61,7 @@ static FrtScorer *masc_new(FrtWeight *weight, FrtIndexReader *ir) {
55
61
  self->next = &masc_next;
56
62
  self->skip_to = &masc_skip_to;
57
63
  self->explain = &masc_explain;
58
- self->destroy = &frt_scorer_destroy_i;
64
+ self->destroy = &masc_destroy_i;
59
65
 
60
66
  return self;
61
67
  }
@@ -142,4 +148,3 @@ FrtQuery *frt_maq_new(void) {
142
148
  FrtQuery *self = frt_maq_alloc();
143
149
  return frt_maq_init(self);
144
150
  }
145
-
@@ -3,8 +3,8 @@
3
3
  #include "frt_search.h"
4
4
  #include "frt_helper.h"
5
5
 
6
- #undef close
7
- #undef read
6
+ // #undef close
7
+ // #undef read
8
8
 
9
9
  #define MTQ(query) ((FrtMultiTermQuery *)(query))
10
10