ferret 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/ext/Makefile +2 -2
  2. data/ext/ferret.c +27 -2
  3. data/ext/ferret.h +59 -16
  4. data/ext/ferret_ext.so +0 -0
  5. data/ext/index_io.c +72 -77
  6. data/ext/priority_queue.c +150 -145
  7. data/ext/ram_directory.c +47 -42
  8. data/ext/segment_merge_queue.c +4 -8
  9. data/ext/segment_term_enum.c +324 -0
  10. data/ext/similarity.c +59 -0
  11. data/ext/string_helper.c +2 -2
  12. data/ext/tags +150 -46
  13. data/ext/term.c +107 -152
  14. data/ext/term_buffer.c +105 -174
  15. data/ext/term_infos_reader.c +54 -0
  16. data/ext/terminfo.c +160 -0
  17. data/ext/token.c +93 -0
  18. data/lib/ferret.rb +1 -1
  19. data/lib/ferret/analysis/analyzers.rb +18 -0
  20. data/lib/ferret/analysis/standard_tokenizer.rb +19 -14
  21. data/lib/ferret/analysis/token.rb +8 -1
  22. data/lib/ferret/analysis/tokenizers.rb +10 -5
  23. data/lib/ferret/document/field.rb +33 -11
  24. data/lib/ferret/index/document_writer.rb +3 -2
  25. data/lib/ferret/index/field_infos.rb +38 -12
  26. data/lib/ferret/index/fields_io.rb +10 -4
  27. data/lib/ferret/index/index.rb +20 -4
  28. data/lib/ferret/index/index_reader.rb +19 -4
  29. data/lib/ferret/index/index_writer.rb +1 -1
  30. data/lib/ferret/index/multi_reader.rb +21 -7
  31. data/lib/ferret/index/segment_merge_info.rb +24 -22
  32. data/lib/ferret/index/segment_merge_queue.rb +2 -2
  33. data/lib/ferret/index/segment_merger.rb +28 -11
  34. data/lib/ferret/index/segment_reader.rb +19 -4
  35. data/lib/ferret/index/segment_term_enum.rb +3 -11
  36. data/lib/ferret/index/term_buffer.rb +13 -16
  37. data/lib/ferret/index/term_doc_enum.rb +8 -5
  38. data/lib/ferret/index/term_enum.rb +2 -2
  39. data/lib/ferret/index/term_info.rb +1 -5
  40. data/lib/ferret/index/term_infos_io.rb +2 -0
  41. data/lib/ferret/query_parser/query_parser.tab.rb +7 -7
  42. data/lib/ferret/search/phrase_scorer.rb +0 -1
  43. data/lib/ferret/search/similarity.rb +2 -2
  44. data/lib/ferret/search/term_scorer.rb +2 -2
  45. data/lib/ferret/store/directory.rb +2 -0
  46. data/lib/ferret/store/fs_store.rb +16 -3
  47. data/lib/ferret/store/ram_store.rb +2 -2
  48. data/test/unit/document/tc_field.rb +9 -0
  49. data/test/unit/index/tc_field_infos.rb +29 -21
  50. data/test/unit/index/tc_index.rb +44 -7
  51. data/test/unit/index/tc_term_buffer.rb +3 -3
  52. data/test/unit/index/tc_term_info.rb +1 -1
  53. data/test/unit/query_parser/tc_query_parser.rb +1 -1
  54. data/test/unit/search/tc_index_searcher.rb +3 -0
  55. data/test/unit/store/tc_fs_store.rb +47 -16
  56. data/test/unit/store/tc_ram_store.rb +1 -1
  57. metadata +8 -3
@@ -8,7 +8,7 @@ class TermBufferTest < Test::Unit::TestCase
8
8
  tb = TermBuffer.new
9
9
  tb.term = t
10
10
  assert_equal(t.field, tb.field)
11
- assert_equal("Ferret Tutorial", tb.text_str)
11
+ assert_equal("Ferret Tutorial", tb.text)
12
12
  assert_equal("Ferret Tutorial".length, tb.text_length)
13
13
  assert_equal(t, tb.term)
14
14
  end
@@ -19,7 +19,7 @@ class TermBufferTest < Test::Unit::TestCase
19
19
  tb2 = TermBuffer.new
20
20
  tb2.set!(tb)
21
21
  assert_equal(tb.field, tb2.field)
22
- assert_equal("Ferret Tutorial", tb2.text_str)
22
+ assert_equal("Ferret Tutorial", tb2.text)
23
23
  assert_equal("Ferret Tutorial".length, tb2.text_length)
24
24
  assert_equal(tb.term, tb2.term)
25
25
  end
@@ -50,7 +50,7 @@ class TermBufferTest < Test::Unit::TestCase
50
50
  output.close
51
51
  input = dir.open_input("term_buffer_read_test")
52
52
  tb.read(input, fi)
53
- assert_equal("Dave Balmain", tb.text_str)
53
+ assert_equal("Dave Balmain", tb.text)
54
54
  assert_equal("Dave Balmain", tb.term.text)
55
55
  assert_equal("Writer", tb.field)
56
56
  end
@@ -9,7 +9,7 @@ class TermInfoTest < Test::Unit::TestCase
9
9
  assert_equal(ti1.freq_pointer, 2)
10
10
  assert_equal(ti1.prox_pointer, 3)
11
11
  assert_equal(ti1.skip_offset, 1)
12
- ti2 = ti1.copy_of()
12
+ ti2 = ti1.clone()
13
13
  assert(ti1 == ti2)
14
14
  ti2 = TermInfo.new(10, 9, 8)
15
15
  assert(ti1 != ti2)
@@ -124,7 +124,7 @@ class QueryParserTest < Test::Unit::TestCase
124
124
  :handle_parse_errors => true)
125
125
 
126
126
  pairs = [
127
- ['(*word', 'word'],
127
+ ['::*word', 'word'],
128
128
  ['()*&)(*^&*(', ''],
129
129
  ['()*&one)(*two(*&"', 'one two']
130
130
  ]
@@ -66,6 +66,9 @@ class IndexSearcherTest < Test::Unit::TestCase
66
66
  tq.boost = 100
67
67
  check_hits(tq, [1,4,8])
68
68
 
69
+ tq = TermQuery.new(Term.new("field", "2342"));
70
+ check_hits(tq, [])
71
+
69
72
  tq = TermQuery.new(Term.new("field", ""));
70
73
  check_hits(tq, [])
71
74
 
@@ -60,25 +60,56 @@ class FSStoreTest < Test::Unit::TestCase
60
60
  end
61
61
 
62
62
  def test_fslock
63
- name = "lfile"
64
- lock_file_path = @dpath + "/" + @dir.get_lock_prefix() + name
65
- if File.exists?(lock_file_path) then
66
- File.delete(lock_file_path)
67
- end
68
- assert(! File.exists?(lock_file_path),
69
- "There should be no lock file")
70
- lock = @dir.make_lock(name)
71
- assert(! File.exists?(lock_file_path),
72
- "There should still be no lock file")
63
+ lock_name = "lfile"
64
+ lock_file_path = make_lock_file_path(lock_name)
65
+ assert(! File.exists?(lock_file_path), "There should be no lock file")
66
+ lock = @dir.make_lock(lock_name)
67
+ assert(! File.exists?(lock_file_path), "There should still be no lock file")
68
+ assert(! lock.locked?, "lock shouldn't be locked yet")
69
+
70
+ lock.obtain
71
+
72
+ assert(lock.locked?, "lock should now be locked")
73
+ assert(File.exists?(lock_file_path), "A lock file should have been created")
74
+
73
75
  assert(! @dir.exists?(lock_file_path),
74
76
  "The lock should be hidden by the FSDirectories directory scan")
75
- assert(! lock.locked?, "lock shouldn't be locked yet")
76
- lock.obtain
77
- assert(lock.locked?, "lock should now be locked")
78
- assert(File.exists?(lock_file_path),
79
- "A lock file should have been created")
77
+
80
78
  lock.release
81
- assert(! lock.locked?, "lock should be freed again")
79
+
80
+ assert(! lock.locked?, "lock should be freed again")
82
81
  assert(! File.exists?(lock_file_path), "The lock file should have been deleted")
83
82
  end
83
+
84
+ # def make_and_loose_lock
85
+ # lock = @dir.make_lock("finalizer_lock")
86
+ # lock.obtain
87
+ # lock = nil
88
+ # end
89
+ #
90
+ # def test_fslock_finalizer
91
+ # lock_name = "finalizer_lock"
92
+ # lock_file_path = make_lock_file_path(lock_name)
93
+ # assert(! File.exists?(lock_file_path), "There should be no lock file")
94
+ #
95
+ # make_and_loose_lock
96
+ #
97
+ # #assert(File.exists?(lock_file_path), "There should now be a lock file")
98
+ #
99
+ # lock = @dir.make_lock(lock_name)
100
+ # assert(lock.locked?, "lock should now be locked")
101
+ #
102
+ # GC.start
103
+ #
104
+ # assert(! lock.locked?, "lock should be freed again")
105
+ # assert(! File.exists?(lock_file_path), "The lock file should have been deleted")
106
+ # end
107
+ #
108
+ def make_lock_file_path(name)
109
+ lock_file_path = File.join(@dpath, @dir.get_lock_prefix() + name)
110
+ if File.exists?(lock_file_path) then
111
+ File.delete(lock_file_path)
112
+ end
113
+ return lock_file_path
114
+ end
84
115
  end
@@ -15,7 +15,7 @@ class RAMStoreTest < Test::Unit::TestCase
15
15
 
16
16
  def test_ramlock
17
17
  name = "lfile"
18
- lfile = "rubylock-" + name
18
+ lfile = Ferret::Store::Directory::LOCK_PREFIX + name
19
19
  assert(! @dir.exists?(lfile),
20
20
  "There should be no lock file")
21
21
  lock = @dir.make_lock(name)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ferret
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.2
7
- date: 2005-11-22 00:00:00 +09:00
6
+ version: 0.3.0
7
+ date: 2005-12-02 00:00:00 +09:00
8
8
  summary: Ruby indexing library.
9
9
  require_paths:
10
10
  - lib
@@ -47,9 +47,14 @@ files:
47
47
  - ext/term.c
48
48
  - ext/ferret.h
49
49
  - ext/util.c
50
+ - ext/token.c
50
51
  - ext/tags
51
- - ext/ferret_ext.so
52
52
  - ext/dummy.exe
53
+ - ext/segment_term_enum.c
54
+ - ext/terminfo.c
55
+ - ext/term_infos_reader.c
56
+ - ext/ferret_ext.so
57
+ - ext/similarity.c
53
58
  - lib/ferret.rb
54
59
  - lib/ferret/analysis.rb
55
60
  - lib/ferret/document.rb