ferret 0.10.10 → 0.10.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,6 @@
1
+ Tue Oct 10 14:42:17 JST 2006
2
+ * Fixed MultiTermDocEnum bug introduced in version 0.10.10 during
3
+ performance enhancements.
4
+ * Added Filter#bits(index_reader) method to C implemented filters so that
5
+ they can be used in Ruby.
6
+
data/ext/index.c CHANGED
@@ -2415,9 +2415,9 @@ static TermDocEnum *mtde_next_tde(MultiTermDocEnum *mtde)
2415
2415
  return mtde->curr_tde = NULL;
2416
2416
  }
2417
2417
  else {
2418
- TermDocEnum *tde = mtde->curr_tde = mtde->irs_tde[mtde->ptr];
2418
+ TermDocEnum *tde = mtde->irs_tde[mtde->ptr];
2419
2419
  mtde->base = mtde->starts[mtde->ptr];
2420
- return tde;
2420
+ return mtde->curr_tde = tde;
2421
2421
  }
2422
2422
  }
2423
2423
 
@@ -2454,9 +2454,13 @@ static void mtde_seek(TermDocEnum *tde, int field_num, const char *term)
2454
2454
  {
2455
2455
  MultiTermDocEnum *mtde = MTDE(tde);
2456
2456
  TermEnum *te = mtde->te;
2457
+ char *t;
2457
2458
  te->set_field(te, field_num);
2458
- te->skip_to(te, term);
2459
- mtde_seek_te(tde, te);
2459
+ if ((t = te->skip_to(te, term)) != NULL && strcmp(term, t) == 0) {
2460
+ mtde_seek_te(tde, te);
2461
+ } else {
2462
+ memset(mtde->state, 0, mtde->ir_cnt);
2463
+ }
2460
2464
  }
2461
2465
 
2462
2466
  static int mtde_doc_num(TermDocEnum *tde)
data/ext/r_index.c CHANGED
@@ -3234,7 +3234,6 @@ Init_IndexReader(void)
3234
3234
  {
3235
3235
  cIndexReader = rb_define_class_under(mIndex, "IndexReader", rb_cObject);
3236
3236
  rb_define_alloc_func(cIndexReader, frt_data_alloc);
3237
- /*rb_define_singleton_method(cIndexReader, "version", frt_class_ir_version, 0); */
3238
3237
  rb_define_method(cIndexReader, "initialize", frt_ir_init, 1);
3239
3238
  rb_define_method(cIndexReader, "set_norm", frt_ir_set_norm, 3);
3240
3239
  rb_define_method(cIndexReader, "norms", frt_ir_norms, 1);
data/ext/r_search.c CHANGED
@@ -1733,6 +1733,26 @@ frt_f_to_s(VALUE self)
1733
1733
  return rstr;
1734
1734
  }
1735
1735
 
1736
+ extern VALUE frt_get_bv(BitVector *bv);
1737
+
1738
+ /*
1739
+ * call-seq:
1740
+ * filter.bits(index_reader) -> bit_vector
1741
+ *
1742
+ * Get the bit_vector used by this filter. This method will usually be used
1743
+ * to group filters or apply filters to other filters.
1744
+ */
1745
+ static VALUE
1746
+ frt_f_get_bits(VALUE self, VALUE rindex_reader)
1747
+ {
1748
+ BitVector *bv;
1749
+ IndexReader *ir;
1750
+ GET_F();
1751
+ Data_Get_Struct(rindex_reader, IndexReader, ir);
1752
+ bv = filt_get_bv(f, ir);
1753
+ return frt_get_bv(bv);
1754
+ }
1755
+
1736
1756
  /****************************************************************************
1737
1757
  *
1738
1758
  * RangeFilter Methods
@@ -3610,6 +3630,7 @@ Init_Filter(void)
3610
3630
  frt_mark_cclass(cFilter);
3611
3631
  rb_define_alloc_func(cConstantScoreQuery, frt_data_alloc);
3612
3632
 
3633
+ rb_define_method(cFilter, "bits", frt_f_get_bits, 1);
3613
3634
  rb_define_method(cFilter, "to_s", frt_f_to_s, 0);
3614
3635
  }
3615
3636
 
data/ext/r_utils.c CHANGED
@@ -6,14 +6,36 @@
6
6
  *****************/
7
7
  static VALUE cBitVector;
8
8
 
9
+ static void
10
+ frt_bv_free(void *p)
11
+ {
12
+ object_del(p);
13
+ bv_destroy((BitVector *)p);
14
+ }
15
+
9
16
  static VALUE
10
17
  frt_bv_alloc(VALUE klass)
11
18
  {
12
- return Data_Wrap_Struct(klass, NULL, &bv_destroy, bv_new());
19
+ BitVector *bv = bv_new();
20
+ VALUE rbv = Data_Wrap_Struct(klass, NULL, &frt_bv_free, bv);
21
+ object_add(bv, rbv);
22
+ return rbv;
13
23
  }
14
24
 
15
25
  #define GET_BV(bv, self) Data_Get_Struct(self, BitVector, bv)
16
26
 
27
+ VALUE
28
+ frt_get_bv(BitVector *bv)
29
+ {
30
+ VALUE rbv;
31
+ if ((rbv = object_get(bv)) == Qnil) {
32
+ rbv = Data_Wrap_Struct(cBitVector, NULL, &frt_bv_free, bv);
33
+ REF(bv);
34
+ object_add(bv, rbv);
35
+ }
36
+ return rbv;
37
+ }
38
+
17
39
  /*
18
40
  * call-seq:
19
41
  * BitVector.new() -> new_bv
data/ext/sort.c CHANGED
@@ -265,6 +265,7 @@ static int sf_byte_compare(void *index, Hit *hit1, Hit *hit2)
265
265
  static void *sf_byte_create_index(int size)
266
266
  {
267
267
  int *index = ALLOC_AND_ZERO_N(int, size + 1);
268
+ index[0]++;
268
269
  return &index[1];
269
270
  }
270
271
 
@@ -1,3 +1,3 @@
1
1
  module Ferret
2
- VERSION = '0.10.10'
2
+ VERSION = '0.10.11'
3
3
  end
@@ -68,6 +68,13 @@ class FilterTest < Test::Unit::TestCase
68
68
  do_test_top_docs(searcher, q, [0,1,2], rf)
69
69
  rf = RangeFilter.new(:int, :< => "2")
70
70
  do_test_top_docs(searcher, q, [0,1], rf)
71
+
72
+ bits = rf.bits(searcher.reader)
73
+ assert(bits[0])
74
+ assert(bits[1])
75
+ assert(!bits[2])
76
+ assert(!bits[3])
77
+ assert(!bits[4])
71
78
  end
72
79
 
73
80
  def test_range_filter_errors
@@ -85,6 +92,18 @@ class FilterTest < Test::Unit::TestCase
85
92
  do_test_top_docs(searcher, q, [0,2,4,6,8], qf)
86
93
  qf = QueryFilter.new(TermQuery.new(:switch, "off"))
87
94
  do_test_top_docs(searcher, q, [1,3,5,7,9], qf)
95
+
96
+ bits = qf.bits(searcher.reader)
97
+ assert(bits[1])
98
+ assert(bits[3])
99
+ assert(bits[5])
100
+ assert(bits[7])
101
+ assert(bits[9])
102
+ assert(!bits[0])
103
+ assert(!bits[2])
104
+ assert(!bits[4])
105
+ assert(!bits[6])
106
+ assert(!bits[8])
88
107
  end
89
108
 
90
109
  def test_filtered_query
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ferret
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.10.10
7
- date: 2006-10-08 00:00:00 +09:00
6
+ version: 0.10.11
7
+ date: 2006-10-11 00:00:00 +09:00
8
8
  summary: Ruby indexing library.
9
9
  require_paths:
10
10
  - lib
@@ -35,6 +35,7 @@ files:
35
35
  - README
36
36
  - MIT-LICENSE
37
37
  - TUTORIAL
38
+ - CHANGELOG
38
39
  - ext/q_filtered_query.c
39
40
  - ext/priorityqueue.c
40
41
  - ext/hashset.c