ferret 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +109 -0
  3. data/Rakefile +275 -0
  4. data/TODO +9 -0
  5. data/TUTORIAL +197 -0
  6. data/ext/extconf.rb +3 -0
  7. data/ext/ferret.c +23 -0
  8. data/ext/ferret.h +85 -0
  9. data/ext/index_io.c +543 -0
  10. data/ext/priority_queue.c +227 -0
  11. data/ext/ram_directory.c +316 -0
  12. data/ext/segment_merge_queue.c +41 -0
  13. data/ext/string_helper.c +42 -0
  14. data/ext/tags +240 -0
  15. data/ext/term.c +261 -0
  16. data/ext/term_buffer.c +299 -0
  17. data/ext/util.c +12 -0
  18. data/lib/ferret.rb +41 -0
  19. data/lib/ferret/analysis.rb +11 -0
  20. data/lib/ferret/analysis/analyzers.rb +93 -0
  21. data/lib/ferret/analysis/standard_tokenizer.rb +65 -0
  22. data/lib/ferret/analysis/token.rb +79 -0
  23. data/lib/ferret/analysis/token_filters.rb +86 -0
  24. data/lib/ferret/analysis/token_stream.rb +26 -0
  25. data/lib/ferret/analysis/tokenizers.rb +107 -0
  26. data/lib/ferret/analysis/word_list_loader.rb +27 -0
  27. data/lib/ferret/document.rb +2 -0
  28. data/lib/ferret/document/document.rb +152 -0
  29. data/lib/ferret/document/field.rb +304 -0
  30. data/lib/ferret/index.rb +26 -0
  31. data/lib/ferret/index/compound_file_io.rb +343 -0
  32. data/lib/ferret/index/document_writer.rb +288 -0
  33. data/lib/ferret/index/field_infos.rb +259 -0
  34. data/lib/ferret/index/fields_io.rb +175 -0
  35. data/lib/ferret/index/index.rb +228 -0
  36. data/lib/ferret/index/index_file_names.rb +33 -0
  37. data/lib/ferret/index/index_reader.rb +462 -0
  38. data/lib/ferret/index/index_writer.rb +488 -0
  39. data/lib/ferret/index/multi_reader.rb +363 -0
  40. data/lib/ferret/index/multiple_term_doc_pos_enum.rb +105 -0
  41. data/lib/ferret/index/segment_infos.rb +130 -0
  42. data/lib/ferret/index/segment_merge_info.rb +47 -0
  43. data/lib/ferret/index/segment_merge_queue.rb +16 -0
  44. data/lib/ferret/index/segment_merger.rb +337 -0
  45. data/lib/ferret/index/segment_reader.rb +380 -0
  46. data/lib/ferret/index/segment_term_enum.rb +178 -0
  47. data/lib/ferret/index/segment_term_vector.rb +58 -0
  48. data/lib/ferret/index/term.rb +49 -0
  49. data/lib/ferret/index/term_buffer.rb +88 -0
  50. data/lib/ferret/index/term_doc_enum.rb +283 -0
  51. data/lib/ferret/index/term_enum.rb +52 -0
  52. data/lib/ferret/index/term_info.rb +41 -0
  53. data/lib/ferret/index/term_infos_io.rb +312 -0
  54. data/lib/ferret/index/term_vector_offset_info.rb +20 -0
  55. data/lib/ferret/index/term_vectors_io.rb +552 -0
  56. data/lib/ferret/query_parser.rb +274 -0
  57. data/lib/ferret/query_parser/query_parser.tab.rb +819 -0
  58. data/lib/ferret/search.rb +49 -0
  59. data/lib/ferret/search/boolean_clause.rb +100 -0
  60. data/lib/ferret/search/boolean_query.rb +303 -0
  61. data/lib/ferret/search/boolean_scorer.rb +294 -0
  62. data/lib/ferret/search/caching_wrapper_filter.rb +40 -0
  63. data/lib/ferret/search/conjunction_scorer.rb +99 -0
  64. data/lib/ferret/search/disjunction_sum_scorer.rb +203 -0
  65. data/lib/ferret/search/exact_phrase_scorer.rb +32 -0
  66. data/lib/ferret/search/explanation.rb +41 -0
  67. data/lib/ferret/search/field_cache.rb +216 -0
  68. data/lib/ferret/search/field_doc.rb +31 -0
  69. data/lib/ferret/search/field_sorted_hit_queue.rb +184 -0
  70. data/lib/ferret/search/filter.rb +11 -0
  71. data/lib/ferret/search/filtered_query.rb +130 -0
  72. data/lib/ferret/search/filtered_term_enum.rb +79 -0
  73. data/lib/ferret/search/fuzzy_query.rb +153 -0
  74. data/lib/ferret/search/fuzzy_term_enum.rb +244 -0
  75. data/lib/ferret/search/hit_collector.rb +34 -0
  76. data/lib/ferret/search/hit_queue.rb +11 -0
  77. data/lib/ferret/search/index_searcher.rb +173 -0
  78. data/lib/ferret/search/match_all_docs_query.rb +104 -0
  79. data/lib/ferret/search/multi_phrase_query.rb +204 -0
  80. data/lib/ferret/search/multi_term_query.rb +65 -0
  81. data/lib/ferret/search/non_matching_scorer.rb +22 -0
  82. data/lib/ferret/search/phrase_positions.rb +55 -0
  83. data/lib/ferret/search/phrase_query.rb +217 -0
  84. data/lib/ferret/search/phrase_scorer.rb +153 -0
  85. data/lib/ferret/search/prefix_query.rb +47 -0
  86. data/lib/ferret/search/query.rb +111 -0
  87. data/lib/ferret/search/query_filter.rb +51 -0
  88. data/lib/ferret/search/range_filter.rb +103 -0
  89. data/lib/ferret/search/range_query.rb +139 -0
  90. data/lib/ferret/search/req_excl_scorer.rb +125 -0
  91. data/lib/ferret/search/req_opt_sum_scorer.rb +70 -0
  92. data/lib/ferret/search/score_doc.rb +38 -0
  93. data/lib/ferret/search/score_doc_comparator.rb +114 -0
  94. data/lib/ferret/search/scorer.rb +91 -0
  95. data/lib/ferret/search/similarity.rb +278 -0
  96. data/lib/ferret/search/sloppy_phrase_scorer.rb +47 -0
  97. data/lib/ferret/search/sort.rb +105 -0
  98. data/lib/ferret/search/sort_comparator.rb +60 -0
  99. data/lib/ferret/search/sort_field.rb +87 -0
  100. data/lib/ferret/search/spans.rb +12 -0
  101. data/lib/ferret/search/spans/near_spans_enum.rb +304 -0
  102. data/lib/ferret/search/spans/span_first_query.rb +79 -0
  103. data/lib/ferret/search/spans/span_near_query.rb +108 -0
  104. data/lib/ferret/search/spans/span_not_query.rb +130 -0
  105. data/lib/ferret/search/spans/span_or_query.rb +176 -0
  106. data/lib/ferret/search/spans/span_query.rb +25 -0
  107. data/lib/ferret/search/spans/span_scorer.rb +74 -0
  108. data/lib/ferret/search/spans/span_term_query.rb +105 -0
  109. data/lib/ferret/search/spans/span_weight.rb +84 -0
  110. data/lib/ferret/search/spans/spans_enum.rb +44 -0
  111. data/lib/ferret/search/term_query.rb +128 -0
  112. data/lib/ferret/search/term_scorer.rb +181 -0
  113. data/lib/ferret/search/top_docs.rb +24 -0
  114. data/lib/ferret/search/top_field_docs.rb +17 -0
  115. data/lib/ferret/search/weight.rb +54 -0
  116. data/lib/ferret/search/wildcard_query.rb +26 -0
  117. data/lib/ferret/search/wildcard_term_enum.rb +61 -0
  118. data/lib/ferret/stemmers.rb +1 -0
  119. data/lib/ferret/stemmers/porter_stemmer.rb +218 -0
  120. data/lib/ferret/store.rb +5 -0
  121. data/lib/ferret/store/buffered_index_io.rb +191 -0
  122. data/lib/ferret/store/directory.rb +139 -0
  123. data/lib/ferret/store/fs_store.rb +338 -0
  124. data/lib/ferret/store/index_io.rb +259 -0
  125. data/lib/ferret/store/ram_store.rb +282 -0
  126. data/lib/ferret/utils.rb +7 -0
  127. data/lib/ferret/utils/bit_vector.rb +105 -0
  128. data/lib/ferret/utils/date_tools.rb +138 -0
  129. data/lib/ferret/utils/number_tools.rb +91 -0
  130. data/lib/ferret/utils/parameter.rb +41 -0
  131. data/lib/ferret/utils/priority_queue.rb +120 -0
  132. data/lib/ferret/utils/string_helper.rb +47 -0
  133. data/lib/ferret/utils/weak_key_hash.rb +51 -0
  134. data/rake_utils/code_statistics.rb +106 -0
  135. data/setup.rb +1551 -0
  136. data/test/benchmark/tb_ram_store.rb +76 -0
  137. data/test/benchmark/tb_rw_vint.rb +26 -0
  138. data/test/longrunning/tc_numbertools.rb +60 -0
  139. data/test/longrunning/tm_store.rb +19 -0
  140. data/test/test_all.rb +9 -0
  141. data/test/test_helper.rb +6 -0
  142. data/test/unit/analysis/tc_analyzer.rb +21 -0
  143. data/test/unit/analysis/tc_letter_tokenizer.rb +20 -0
  144. data/test/unit/analysis/tc_lower_case_filter.rb +20 -0
  145. data/test/unit/analysis/tc_lower_case_tokenizer.rb +27 -0
  146. data/test/unit/analysis/tc_per_field_analyzer_wrapper.rb +39 -0
  147. data/test/unit/analysis/tc_porter_stem_filter.rb +16 -0
  148. data/test/unit/analysis/tc_standard_analyzer.rb +20 -0
  149. data/test/unit/analysis/tc_standard_tokenizer.rb +20 -0
  150. data/test/unit/analysis/tc_stop_analyzer.rb +20 -0
  151. data/test/unit/analysis/tc_stop_filter.rb +14 -0
  152. data/test/unit/analysis/tc_white_space_analyzer.rb +21 -0
  153. data/test/unit/analysis/tc_white_space_tokenizer.rb +20 -0
  154. data/test/unit/analysis/tc_word_list_loader.rb +32 -0
  155. data/test/unit/document/tc_document.rb +47 -0
  156. data/test/unit/document/tc_field.rb +80 -0
  157. data/test/unit/index/tc_compound_file_io.rb +107 -0
  158. data/test/unit/index/tc_field_infos.rb +119 -0
  159. data/test/unit/index/tc_fields_io.rb +167 -0
  160. data/test/unit/index/tc_index.rb +140 -0
  161. data/test/unit/index/tc_index_reader.rb +622 -0
  162. data/test/unit/index/tc_index_writer.rb +57 -0
  163. data/test/unit/index/tc_multiple_term_doc_pos_enum.rb +80 -0
  164. data/test/unit/index/tc_segment_infos.rb +74 -0
  165. data/test/unit/index/tc_segment_term_docs.rb +17 -0
  166. data/test/unit/index/tc_segment_term_enum.rb +60 -0
  167. data/test/unit/index/tc_segment_term_vector.rb +71 -0
  168. data/test/unit/index/tc_term.rb +22 -0
  169. data/test/unit/index/tc_term_buffer.rb +57 -0
  170. data/test/unit/index/tc_term_info.rb +19 -0
  171. data/test/unit/index/tc_term_infos_io.rb +192 -0
  172. data/test/unit/index/tc_term_vector_offset_info.rb +18 -0
  173. data/test/unit/index/tc_term_vectors_io.rb +108 -0
  174. data/test/unit/index/th_doc.rb +244 -0
  175. data/test/unit/query_parser/tc_query_parser.rb +84 -0
  176. data/test/unit/search/tc_filter.rb +113 -0
  177. data/test/unit/search/tc_fuzzy_query.rb +136 -0
  178. data/test/unit/search/tc_index_searcher.rb +188 -0
  179. data/test/unit/search/tc_search_and_sort.rb +98 -0
  180. data/test/unit/search/tc_similarity.rb +37 -0
  181. data/test/unit/search/tc_sort.rb +48 -0
  182. data/test/unit/search/tc_sort_field.rb +27 -0
  183. data/test/unit/search/tc_spans.rb +153 -0
  184. data/test/unit/store/tc_fs_store.rb +84 -0
  185. data/test/unit/store/tc_ram_store.rb +35 -0
  186. data/test/unit/store/tm_store.rb +180 -0
  187. data/test/unit/store/tm_store_lock.rb +68 -0
  188. data/test/unit/ts_analysis.rb +16 -0
  189. data/test/unit/ts_document.rb +4 -0
  190. data/test/unit/ts_index.rb +18 -0
  191. data/test/unit/ts_query_parser.rb +3 -0
  192. data/test/unit/ts_search.rb +10 -0
  193. data/test/unit/ts_store.rb +6 -0
  194. data/test/unit/ts_utils.rb +10 -0
  195. data/test/unit/utils/tc_bit_vector.rb +65 -0
  196. data/test/unit/utils/tc_date_tools.rb +50 -0
  197. data/test/unit/utils/tc_number_tools.rb +59 -0
  198. data/test/unit/utils/tc_parameter.rb +40 -0
  199. data/test/unit/utils/tc_priority_queue.rb +62 -0
  200. data/test/unit/utils/tc_string_helper.rb +21 -0
  201. data/test/unit/utils/tc_weak_key_hash.rb +25 -0
  202. metadata +251 -0
@@ -0,0 +1,41 @@
1
+ #include "ferret.h"
2
+
3
+ ID eq, lt;
4
+ /****************************************************************************
5
+ *
6
+ * SegmentMergeQueue Methods
7
+ *
8
+ ****************************************************************************/
9
+
10
+ static VALUE
11
+ frt_smq_less_than(VALUE self, VALUE rsti1, VALUE rsti2)
12
+ {
13
+ int base1, base2;
14
+ int cmp = frt_term_compare_to_int(rb_iv_get(rsti1, "@term"), rb_iv_get(rsti2, "@term"));
15
+ if (cmp == 0) {
16
+ base1 = FIX2INT(rb_iv_get(rsti1, "@base"));
17
+ base2 = FIX2INT(rb_iv_get(rsti2, "@base"));
18
+ return base1 < base2 ? Qtrue : Qfalse;
19
+ } else {
20
+ return cmp < 0 ? Qtrue : Qfalse;
21
+ }
22
+ }
23
+
24
+ /****************************************************************************
25
+ *
26
+ * Init Function
27
+ *
28
+ ****************************************************************************/
29
+
30
+ void
31
+ Init_segment_merge_queue(void)
32
+ {
33
+ // IDs
34
+ eq = rb_intern("==");
35
+ lt = rb_intern("<");
36
+
37
+ // SegmentMergeQueue
38
+ cSegmentMergeQueue = rb_define_class_under(mIndex, "SegmentMergeQueue", cPriorityQueue);
39
+
40
+ rb_define_method(cSegmentMergeQueue, "less_than", frt_smq_less_than, 2);
41
+ }
@@ -0,0 +1,42 @@
1
+ #include "ferret.h"
2
+
3
+ /****************************************************************************
4
+ *
5
+ * StringHelper Methods
6
+ *
7
+ ****************************************************************************/
8
+ inline int
9
+ frt_sh_string_difference_int(VALUE self, VALUE rstr1, VALUE rstr2)
10
+ {
11
+ int i;
12
+ struct RString *str1 = RSTRING(rstr1), *str2 = RSTRING(rstr2);
13
+ char *s1 = str1->ptr, *s2 = str2->ptr;
14
+ int len = str1->len < str2->len ? str1->len : str2->len;
15
+ for (i = 0; i < len; i++) {
16
+ if (s1[i] != s2[i])
17
+ return i;
18
+ }
19
+ return len;
20
+ }
21
+
22
+ static VALUE
23
+ frt_sh_string_difference(VALUE self, VALUE rstr1, VALUE rstr2)
24
+ {
25
+ return INT2FIX(frt_sh_string_difference_int(self, rstr1, rstr2));
26
+ }
27
+
28
+
29
+ /****************************************************************************
30
+ *
31
+ * Init Function
32
+ *
33
+ ****************************************************************************/
34
+
35
+ void
36
+ Init_string_helper(void)
37
+ {
38
+ // StringHelper
39
+ mStringHelper = rb_define_module_under(mUtils, "StringHelper");
40
+
41
+ rb_define_method(mStringHelper, "string_difference", frt_sh_string_difference, 2);
42
+ }
@@ -0,0 +1,240 @@
1
+ !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
2
+ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3
+ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
4
+ !_TAG_PROGRAM_NAME Exuberant Ctags //
5
+ !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6
+ !_TAG_PROGRAM_VERSION 5.5.4 //
7
+ AR Makefile /^AR = ar$/;" m
8
+ BUFFER_SIZE ferret.h 6;" d
9
+ CC Makefile /^CC = gcc$/;" m
10
+ CFLAGS Makefile /^CFLAGS = -fPIC -Wall -g -O2 -fPIC $/;" m
11
+ CLEANFILES Makefile /^CLEANFILES = $/;" m
12
+ CLEANLIBS Makefile /^CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map$/;" m
13
+ CLEANOBJS Makefile /^CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak$/;" m
14
+ COPY Makefile /^COPY = cp$/;" m
15
+ CPPFLAGS Makefile /^CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) $/;" m
16
+ CXXFLAGS Makefile /^CXXFLAGS = $(CFLAGS) $/;" m
17
+ DEFFILE Makefile /^DEFFILE = $/;" m
18
+ DISTCLEANFILES Makefile /^DISTCLEANFILES = $/;" m
19
+ DLDFLAGS Makefile /^DLDFLAGS = $/;" m
20
+ DLLIB Makefile /^DLLIB = $(TARGET).so$/;" m
21
+ EXEEXT Makefile /^EXEEXT = $/;" m
22
+ INSTALL Makefile /^INSTALL = \/usr\/bin\/install -c$/;" m
23
+ INSTALL_DATA Makefile /^INSTALL_DATA = $(INSTALL) -m 644$/;" m
24
+ INSTALL_PROG Makefile /^INSTALL_PROG = $(INSTALL) -m 0755$/;" m
25
+ IndexBuffer ferret.h /^typedef struct IndexBuffer {$/;" s
26
+ IndexBuffer ferret.h /^} IndexBuffer;$/;" t
27
+ Init_extensions ferret.c /^Init_extensions(void)$/;" f
28
+ Init_indexio index_io.c /^Init_indexio(void)$/;" f
29
+ Init_priority_queue priority_queue.c /^Init_priority_queue(void)$/;" f
30
+ Init_ram_directory ram_directory.c /^Init_ram_directory(void)$/;" f
31
+ Init_segment_merge_queue segment_merge_queue.c /^Init_segment_merge_queue(void)$/;" f
32
+ Init_string_helper string_helper.c /^Init_string_helper(void)$/;" f
33
+ Init_term term.c /^Init_term(void)$/;" f
34
+ Init_term_buffer term_buffer.c /^Init_term_buffer(void) {$/;" f
35
+ LDSHARED Makefile /^LDSHARED = $(CC) -shared$/;" m
36
+ LIBPATH Makefile /^LIBPATH = -L"$(libdir)"$/;" m
37
+ LIBRUBY Makefile /^LIBRUBY = $(LIBRUBY_SO)$/;" m
38
+ LIBRUBYARG_SHARED Makefile /^LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)$/;" m
39
+ LIBRUBYARG_STATIC Makefile /^LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static$/;" m
40
+ LIBRUBY_A Makefile /^LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a$/;" m
41
+ LIBS Makefile /^LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lcrypt -lm -lc$/;" m
42
+ LOCAL_LIBS Makefile /^LOCAL_LIBS = $/;" m
43
+ MAKEDIRS Makefile /^MAKEDIRS = mkdir -p$/;" m
44
+ OBJS Makefile /^OBJS = index_io.o term_buffer.o ram_directory.o priority_queue.o string_helper.o segment_merge_queue.o ferret.o term.o util.o$/;" m
45
+ PriorityQueue ferret.h /^typedef struct PriorityQueue {$/;" s
46
+ PriorityQueue ferret.h /^} PriorityQueue;$/;" t
47
+ RAMFile ferret.h /^typedef struct RAMFile {$/;" s
48
+ RAMFile ferret.h /^} RAMFile;$/;" t
49
+ RM Makefile /^RM = rm -f$/;" m
50
+ RUBY Makefile /^RUBY = $(ruby)$/;" m
51
+ RUBYARCHDIR Makefile /^RUBYARCHDIR = $(sitearchdir)$(target_prefix)$/;" m
52
+ RUBYCOMMONDIR Makefile /^RUBYCOMMONDIR = $(sitedir)$(target_prefix)$/;" m
53
+ RUBYLIBDIR Makefile /^RUBYLIBDIR = $(sitelibdir)$(target_prefix)$/;" m
54
+ RUBY_INSTALL_NAME Makefile /^RUBY_INSTALL_NAME = ruby1.8$/;" m
55
+ RUBY_SO_NAME Makefile /^RUBY_SO_NAME = ruby1.8$/;" m
56
+ SHELL Makefile /^SHELL = \/bin\/sh$/;" m
57
+ SRCS Makefile /^SRCS = index_io.c term_buffer.c ram_directory.c priority_queue.c string_helper.c segment_merge_queue.c ferret.c term.c util.c$/;" m
58
+ STATIC_LIB Makefile /^STATIC_LIB = $/;" m
59
+ TARGET Makefile /^TARGET = extensions$/;" m
60
+ TARGET_SO Makefile /^TARGET_SO = $(DLLIB)$/;" m
61
+ Term ferret.h /^typedef struct Term {$/;" s
62
+ Term ferret.h /^} Term;$/;" t
63
+ TermBuffer ferret.h /^typedef struct TermBuffer {$/;" s
64
+ TermBuffer ferret.h /^} TermBuffer;$/;" t
65
+ VPATH Makefile /^VPATH = $(srcdir):$(topdir):$(hdrdir)$/;" m
66
+ __FERRET_H_ ferret.h 2;" d
67
+ arch Makefile /^arch = i486-linux$/;" m
68
+ archdir Makefile /^archdir = $(rubylibdir)\/$(arch)$/;" m
69
+ bindir Makefile /^bindir = $(exec_prefix)\/bin$/;" m
70
+ bufcnt ferret.h /^ int bufcnt;$/;" m struct:RAMFile
71
+ buffer ferret.h /^ byte_t *buffer;$/;" m struct:IndexBuffer
72
+ buffers ferret.h /^ void **buffers;$/;" m struct:RAMFile
73
+ byte_t ferret.h /^typedef unsigned char byte_t;$/;" t
74
+ cBufferedIndexIn ferret.h /^VALUE cBufferedIndexIn;$/;" v
75
+ cBufferedIndexOut ferret.h /^VALUE cBufferedIndexOut;$/;" v
76
+ cFSIndexIn ferret.h /^VALUE cFSIndexIn;$/;" v
77
+ cFSIndexOut ferret.h /^VALUE cFSIndexOut;$/;" v
78
+ cIndexIn ferret.h /^VALUE cIndexIn;$/;" v
79
+ cIndexOut ferret.h /^VALUE cIndexOut;$/;" v
80
+ cPriorityQueue ferret.h /^VALUE cPriorityQueue;$/;" v
81
+ cRAMDirectory ferret.h /^VALUE cRAMDirectory;$/;" v
82
+ cRAMIndexIn ferret.h /^VALUE cRAMIndexIn;$/;" v
83
+ cRAMIndexOut ferret.h /^VALUE cRAMIndexOut;$/;" v
84
+ cSegmentMergeQueue ferret.h /^VALUE cSegmentMergeQueue;$/;" v
85
+ cTerm ferret.h /^VALUE cTerm;$/;" v
86
+ cTermBuffer ferret.h /^VALUE cTermBuffer;$/;" v
87
+ datadir Makefile /^datadir = $(prefix)\/share$/;" m
88
+ eq segment_merge_queue.c /^ID eq, lt;$/;" v
89
+ exec_prefix Makefile /^exec_prefix = $(prefix)$/;" m
90
+ extout Makefile /^extout = $/;" m
91
+ extout_prefix Makefile /^extout_prefix = $/;" m
92
+ field ferret.h /^ char *field;$/;" m struct:Term
93
+ field ferret.h /^ char *field;$/;" m struct:TermBuffer
94
+ field_name term_buffer.c /^ID field_name;$/;" v
95
+ flen ferret.h /^ int flen;$/;" m struct:Term
96
+ flen ferret.h /^ int flen;$/;" m struct:TermBuffer
97
+ flush ram_directory.c /^ID flush, seek;$/;" v
98
+ frt_extend_buffer_if_necessary ram_directory.c /^frt_extend_buffer_if_necessary(RAMFile *rf, int bufnum)$/;" f
99
+ frt_flush_buffer index_io.c /^ID frt_length, frt_flush_buffer, frt_read_internal, frt_seek_internal; $/;" v
100
+ frt_hash util.c /^frt_hash(register char *p, register int len)$/;" f
101
+ frt_indexbuffer_alloc index_io.c /^frt_indexbuffer_alloc(VALUE klass)$/;" f file:
102
+ frt_indexbuffer_free index_io.c /^frt_indexbuffer_free(void *p)$/;" f
103
+ frt_indexin_init_copy index_io.c /^frt_indexin_init_copy(VALUE self, VALUE orig)$/;" f file:
104
+ frt_indexin_pos index_io.c /^frt_indexin_pos(VALUE self)$/;" f file:
105
+ frt_indexin_read_byte index_io.c /^frt_indexin_read_byte(VALUE self)$/;" f file:
106
+ frt_indexin_read_bytes index_io.c /^frt_indexin_read_bytes(VALUE self, VALUE rbuf, VALUE roffset, VALUE rlen)$/;" f file:
107
+ frt_indexin_read_int index_io.c /^frt_indexin_read_int(VALUE self)$/;" f file:
108
+ frt_indexin_read_long index_io.c /^frt_indexin_read_long(VALUE self)$/;" f file:
109
+ frt_indexin_read_string index_io.c /^frt_indexin_read_string(VALUE self)$/;" f file:
110
+ frt_indexin_read_uint index_io.c /^frt_indexin_read_uint(VALUE self)$/;" f file:
111
+ frt_indexin_read_ulong index_io.c /^frt_indexin_read_ulong(VALUE self)$/;" f file:
112
+ frt_indexin_read_vint index_io.c /^frt_indexin_read_vint(VALUE self)$/;" f file:
113
+ frt_indexin_refill index_io.c /^frt_indexin_refill(VALUE self)$/;" f file:
114
+ frt_indexin_seek index_io.c /^frt_indexin_seek(VALUE self, VALUE rpos)$/;" f file:
115
+ frt_indexout_flush index_io.c /^frt_indexout_flush(VALUE self)$/;" f file:
116
+ frt_indexout_pos index_io.c /^frt_indexout_pos(VALUE self)$/;" f file:
117
+ frt_indexout_seek index_io.c /^frt_indexout_seek(VALUE self, VALUE pos)$/;" f file:
118
+ frt_indexout_write_byte index_io.c /^frt_indexout_write_byte(VALUE self, VALUE rbyte)$/;" f file:
119
+ frt_indexout_write_bytes index_io.c /^frt_indexout_write_bytes(VALUE self, VALUE rbuffer, VALUE rlen)$/;" f file:
120
+ frt_indexout_write_chars index_io.c /^frt_indexout_write_chars(VALUE self, VALUE rstr, VALUE rstart, VALUE rlength)$/;" f file:
121
+ frt_indexout_write_int index_io.c /^frt_indexout_write_int(VALUE self, VALUE rint)$/;" f file:
122
+ frt_indexout_write_long index_io.c /^frt_indexout_write_long(VALUE self, VALUE rlong)$/;" f file:
123
+ frt_indexout_write_string index_io.c /^frt_indexout_write_string(VALUE self, VALUE rstr)$/;" f file:
124
+ frt_indexout_write_uint index_io.c /^frt_indexout_write_uint(VALUE self, VALUE ruint)$/;" f file:
125
+ frt_indexout_write_ulong index_io.c /^frt_indexout_write_ulong(VALUE self, VALUE rulong)$/;" f file:
126
+ frt_indexout_write_vint index_io.c /^frt_indexout_write_vint(VALUE self, VALUE rulong)$/;" f file:
127
+ frt_length index_io.c /^ID frt_length, frt_flush_buffer, frt_read_internal, frt_seek_internal; $/;" v
128
+ frt_newobj ferret.h /^ID frt_newobj;$/;" v
129
+ frt_priq_adjust_top priority_queue.c /^frt_priq_adjust_top(VALUE self)$/;" f file:
130
+ frt_priq_alloc priority_queue.c /^frt_priq_alloc(VALUE klass)$/;" f file:
131
+ frt_priq_clear priority_queue.c /^frt_priq_clear(VALUE self)$/;" f file:
132
+ frt_priq_free priority_queue.c /^frt_priq_free(void *p)$/;" f
133
+ frt_priq_init priority_queue.c /^frt_priq_init(VALUE self, VALUE rsize)$/;" f file:
134
+ frt_priq_insert priority_queue.c /^frt_priq_insert(VALUE self, VALUE e)$/;" f file:
135
+ frt_priq_pop priority_queue.c /^frt_priq_pop(VALUE self)$/;" f file:
136
+ frt_priq_push priority_queue.c /^frt_priq_push(VALUE self, VALUE e)$/;" f file:
137
+ frt_priq_size priority_queue.c /^frt_priq_size(VALUE self)$/;" f file:
138
+ frt_priq_top priority_queue.c /^frt_priq_top(VALUE self)$/;" f file:
139
+ frt_read_byte index_io.c /^frt_read_byte(VALUE self)$/;" f
140
+ frt_read_bytes index_io.c /^frt_read_bytes(VALUE self, VALUE rbuffer, int offset, int len)$/;" f file:
141
+ frt_read_chars index_io.c /^frt_read_chars(VALUE self, char* buffer, int off, int len) $/;" f
142
+ frt_read_internal index_io.c /^ID frt_length, frt_flush_buffer, frt_read_internal, frt_seek_internal; $/;" v
143
+ frt_read_vint index_io.c /^frt_read_vint(VALUE self)$/;" f
144
+ frt_rf_alloc ram_directory.c /^frt_rf_alloc(VALUE klass)$/;" f file:
145
+ frt_rf_extend ram_directory.c /^frt_rf_extend(RAMFile *rf)$/;" f
146
+ frt_rf_free ram_directory.c /^frt_rf_free(void *p)$/;" f
147
+ frt_rf_length ram_directory.c /^frt_rf_length(VALUE self)$/;" f file:
148
+ frt_rf_mark ram_directory.c /^frt_rf_mark(void *p)$/;" f
149
+ frt_rii_close ram_directory.c /^frt_rii_close(VALUE self)$/;" f file:
150
+ frt_rii_init ram_directory.c /^frt_rii_init(VALUE self, VALUE ramfile)$/;" f file:
151
+ frt_rii_length ram_directory.c /^frt_rii_length(VALUE self)$/;" f file:
152
+ frt_rii_read_internal ram_directory.c /^frt_rii_read_internal(VALUE self, VALUE rb, VALUE roffset, VALUE rlen)$/;" f file:
153
+ frt_rii_seek_internal ram_directory.c /^frt_rii_seek_internal(VALUE self, VALUE rpos)$/;" f file:
154
+ frt_rio_close ram_directory.c /^frt_rio_close(VALUE self)$/;" f file:
155
+ frt_rio_flush_buffer ram_directory.c /^frt_rio_flush_buffer(VALUE self, VALUE rsrc, VALUE rlen)$/;" f file:
156
+ frt_rio_init ram_directory.c /^frt_rio_init(VALUE self, VALUE ramfile)$/;" f file:
157
+ frt_rio_length ram_directory.c /^frt_rio_length(VALUE self)$/;" f file:
158
+ frt_rio_reset ram_directory.c /^frt_rio_reset(VALUE self)$/;" f file:
159
+ frt_rio_seek ram_directory.c /^frt_rio_seek(VALUE self, VALUE rpos)$/;" f file:
160
+ frt_rio_write_to ram_directory.c /^frt_rio_write_to(VALUE self, VALUE routput)$/;" f file:
161
+ frt_seek_internal index_io.c /^ID frt_length, frt_flush_buffer, frt_read_internal, frt_seek_internal; $/;" v
162
+ frt_sh_string_difference string_helper.c /^frt_sh_string_difference(VALUE self, VALUE rstr1, VALUE rstr2)$/;" f file:
163
+ frt_sh_string_difference_int string_helper.c /^frt_sh_string_difference_int(VALUE self, VALUE rstr1, VALUE rstr2)$/;" f
164
+ frt_smq_less_than segment_merge_queue.c /^frt_smq_less_than(VALUE self, VALUE rsti1, VALUE rsti2)$/;" f file:
165
+ frt_term_alloc term.c /^frt_term_alloc(VALUE klass)$/;" f file:
166
+ frt_term_compare_to term.c /^frt_term_compare_to(VALUE self, VALUE other)$/;" f file:
167
+ frt_term_compare_to_int term.c /^frt_term_compare_to_int(VALUE self, VALUE rother)$/;" f
168
+ frt_term_free term.c /^frt_term_free(void *p)$/;" f
169
+ frt_term_get_field term.c /^frt_term_get_field(VALUE self)$/;" f file:
170
+ frt_term_get_text term.c /^frt_term_get_text(VALUE self)$/;" f file:
171
+ frt_term_hash term.c /^frt_term_hash(VALUE self)$/;" f file:
172
+ frt_term_init term.c /^frt_term_init(VALUE self, VALUE rfield, VALUE rtext)$/;" f file:
173
+ frt_term_set term.c /^frt_term_set(VALUE self, VALUE rfield, VALUE rtext)$/;" f
174
+ frt_term_to_s term.c /^frt_term_to_s(VALUE self)$/;" f
175
+ frt_termbuffer_alloc term_buffer.c /^frt_termbuffer_alloc(VALUE klass)$/;" f file:
176
+ frt_termbuffer_compare_to term_buffer.c /^frt_termbuffer_compare_to(VALUE self, VALUE rother)$/;" f file:
177
+ frt_termbuffer_compare_to_int term_buffer.c /^frt_termbuffer_compare_to_int(VALUE self, VALUE rother)$/;" f
178
+ frt_termbuffer_free term_buffer.c /^frt_termbuffer_free(void *p)$/;" f
179
+ frt_termbuffer_get_field_name term_buffer.c /^frt_termbuffer_get_field_name(VALUE self)$/;" f file:
180
+ frt_termbuffer_get_text term_buffer.c /^frt_termbuffer_get_text(VALUE self)$/;" f file:
181
+ frt_termbuffer_get_text_length term_buffer.c /^frt_termbuffer_get_text_length(VALUE self)$/;" f file:
182
+ frt_termbuffer_hash term_buffer.c /^frt_termbuffer_hash(VALUE self)$/;" f file:
183
+ frt_termbuffer_init term_buffer.c /^frt_termbuffer_init(VALUE self)$/;" f file:
184
+ frt_termbuffer_init_copy term_buffer.c /^frt_termbuffer_init_copy(VALUE self, VALUE rother)$/;" f file:
185
+ frt_termbuffer_read term_buffer.c /^frt_termbuffer_read(VALUE self, VALUE input, VALUE info)$/;" f file:
186
+ frt_termbuffer_reset term_buffer.c /^frt_termbuffer_reset(VALUE self)$/;" f file:
187
+ frt_termbuffer_set_term term_buffer.c /^frt_termbuffer_set_term(VALUE self, VALUE rterm)$/;" f file:
188
+ frt_termbuffer_to_term term_buffer.c /^frt_termbuffer_to_term(VALUE self)$/;" f file:
189
+ frt_write_byte index_io.c /^frt_write_byte(VALUE self, byte_t b)$/;" f file:
190
+ frt_write_bytes index_io.c /^frt_write_bytes(VALUE self, byte_t *buf, int len)$/;" f
191
+ frt_write_chars index_io.c /^frt_write_chars(VALUE self, VALUE rbuf, int start, int length)$/;" f file:
192
+ frt_write_vint index_io.c /^frt_write_vint(VALUE self, register unsigned long long i)$/;" f file:
193
+ hdrdir Makefile /^hdrdir = $(topdir)$/;" m
194
+ heap ferret.h /^ VALUE *heap;$/;" m struct:PriorityQueue
195
+ includedir Makefile /^includedir = $(prefix)\/include$/;" m
196
+ infodir Makefile /^infodir = $(prefix)\/info$/;" m
197
+ len ferret.h /^ int len;$/;" m struct:PriorityQueue
198
+ len ferret.h /^ int len;$/;" m struct:IndexBuffer
199
+ length ferret.h /^ int length;$/;" m struct:RAMFile
200
+ less_than priority_queue.c /^ID less_than, put_heap;$/;" v
201
+ libdir Makefile /^libdir = $(exec_prefix)\/lib$/;" m
202
+ libexecdir Makefile /^libexecdir = $(exec_prefix)\/libexec$/;" m
203
+ libpath Makefile /^libpath = $(libdir)$/;" m
204
+ localstatedir Makefile /^localstatedir = $(DESTDIR)\/var$/;" m
205
+ lt segment_merge_queue.c /^ID eq, lt;$/;" v
206
+ mFerret ferret.h /^VALUE mFerret;$/;" v
207
+ mIndex ferret.h /^VALUE mIndex;$/;" v
208
+ mStore ferret.h /^VALUE mStore;$/;" v
209
+ mStringHelper ferret.h /^VALUE mStringHelper;$/;" v
210
+ mUtils ferret.h /^VALUE mUtils;$/;" v
211
+ mandir Makefile /^mandir = $(datadir)\/man$/;" m
212
+ mtime ferret.h /^ VALUE mtime;$/;" m struct:RAMFile
213
+ name ferret.h /^ char *name;$/;" m struct:RAMFile
214
+ oldincludedir Makefile /^oldincludedir = $(DESTDIR)\/usr\/include$/;" m
215
+ pos ferret.h /^ int pos;$/;" m struct:IndexBuffer
216
+ prefix Makefile /^prefix = $(DESTDIR)\/usr$/;" m
217
+ preload Makefile /^preload = $/;" m
218
+ priq_down priority_queue.c /^priq_down(PriorityQueue *priq, VALUE self, VALUE rary)$/;" f
219
+ priq_up priority_queue.c /^priq_up(PriorityQueue *priq, VALUE self, VALUE rary)$/;" f
220
+ put_heap priority_queue.c /^ID less_than, put_heap;$/;" v
221
+ ruby Makefile /^ruby = \/usr\/bin\/ruby1.8$/;" m
222
+ ruby_version Makefile /^ruby_version = 1.8$/;" m
223
+ rubylibdir Makefile /^rubylibdir = $(libdir)\/ruby\/$(ruby_version)$/;" m
224
+ sbindir Makefile /^sbindir = $(exec_prefix)\/sbin$/;" m
225
+ seek ram_directory.c /^ID flush, seek;$/;" v
226
+ sharedstatedir Makefile /^sharedstatedir = $(prefix)\/com$/;" m
227
+ sitearch Makefile /^sitearch = i486-linux$/;" m
228
+ sitearchdir Makefile /^sitearchdir = $(sitelibdir)\/$(sitearch)$/;" m
229
+ sitedir Makefile /^sitedir = $(DESTDIR)\/usr\/local\/lib\/site_ruby$/;" m
230
+ sitelibdir Makefile /^sitelibdir = $(sitedir)\/$(ruby_version)$/;" m
231
+ size ferret.h /^ int size;$/;" m struct:PriorityQueue
232
+ srcdir Makefile /^srcdir = .$/;" m
233
+ start ferret.h /^ long start;$/;" m struct:IndexBuffer
234
+ sysconfdir Makefile /^sysconfdir = $(DESTDIR)\/etc$/;" m
235
+ target_prefix Makefile /^target_prefix = \/ferret$/;" m
236
+ text ferret.h /^ char *text;$/;" m struct:Term
237
+ text ferret.h /^ char *text;$/;" m struct:TermBuffer
238
+ tlen ferret.h /^ int tlen;$/;" m struct:Term
239
+ tlen ferret.h /^ int tlen;$/;" m struct:TermBuffer
240
+ topdir Makefile /^topdir = \/usr\/lib\/ruby\/1.8\/i486-linux$/;" m
@@ -0,0 +1,261 @@
1
+ #include "ferret.h"
2
+
3
+
4
+ /****************************************************************************
5
+ *
6
+ * Term Methods
7
+ *
8
+ ****************************************************************************/
9
+
10
+ void
11
+ frt_term_free(void *p)
12
+ {
13
+ Term *term;
14
+ term = (Term *)p;
15
+ free((void *)(term->field));
16
+ free((void *)(term->text));
17
+ free(p);
18
+ }
19
+
20
+ static VALUE
21
+ frt_term_alloc(VALUE klass)
22
+ {
23
+ Term *term;
24
+ term = (Term *)ALLOC(Term);
25
+ term->field = (char *)ALLOC_N(char, 1);
26
+ term->text = (char *)ALLOC_N(char, 1);
27
+
28
+ VALUE rbuffer = Data_Wrap_Struct(klass, NULL, frt_term_free, term);
29
+ return rbuffer;
30
+ }
31
+
32
+ VALUE
33
+ frt_term_set(VALUE self, VALUE rfield, VALUE rtext)
34
+ {
35
+ Term *term;
36
+ int flen = RSTRING(rfield)->len;
37
+ int tlen = RSTRING(rtext)->len;
38
+ char *field = RSTRING(rfield)->ptr;
39
+ char *text = RSTRING(rtext)->ptr;
40
+ Data_Get_Struct(self, Term, term);
41
+
42
+ REALLOC_N(term->field, char, flen + 1);
43
+ REALLOC_N(term->text, char, tlen + 1);
44
+
45
+ MEMCPY(term->field, field, char, flen);
46
+ MEMCPY(term->text, text, char, tlen);
47
+ term->flen = flen;
48
+ term->tlen = tlen;
49
+
50
+ return Qnil;
51
+ }
52
+
53
+ static VALUE
54
+ frt_term_init(VALUE self, VALUE rfield, VALUE rtext)
55
+ {
56
+ frt_term_set(self, rfield, rtext);
57
+ return self;
58
+ }
59
+
60
+ static VALUE
61
+ frt_term_get_text(VALUE self)
62
+ {
63
+ Term *term;
64
+ Data_Get_Struct(self, Term, term);
65
+ return rb_str_new(term->text, term->tlen);
66
+ }
67
+
68
+ static VALUE
69
+ frt_term_set_text(VALUE self, VALUE rtext)
70
+ {
71
+ Term *term;
72
+ int tlen = RSTRING(rtext)->len;
73
+ char *text = RSTRING(rtext)->ptr;
74
+ Data_Get_Struct(self, Term, term);
75
+
76
+ REALLOC_N(term->text, char, tlen + 1);
77
+
78
+ MEMCPY(term->text, text, char, tlen);
79
+ term->tlen = tlen;
80
+
81
+ return Qnil;
82
+ }
83
+
84
+ static VALUE
85
+ frt_term_get_field(VALUE self)
86
+ {
87
+ Term *term;
88
+ Data_Get_Struct(self, Term, term);
89
+ return rb_str_new(term->field, term->flen);
90
+ }
91
+
92
+ static VALUE
93
+ frt_term_set_field(VALUE self, VALUE rfield)
94
+ {
95
+ Term *term;
96
+ int flen = RSTRING(rfield)->len;
97
+ char *field = RSTRING(rfield)->ptr;
98
+ Data_Get_Struct(self, Term, term);
99
+
100
+ REALLOC_N(term->field, char, flen + 1);
101
+
102
+ MEMCPY(term->field, field, char, flen);
103
+ term->flen = flen;
104
+
105
+ return Qnil;
106
+ }
107
+
108
+ VALUE
109
+ frt_term_to_s(VALUE self)
110
+ {
111
+ Term *term;
112
+ int tlen, flen;
113
+ Data_Get_Struct(self, Term, term);
114
+ tlen = term->tlen;
115
+ flen = term->flen;
116
+ char res[flen + tlen + 1];
117
+ char delim[] = ":";
118
+
119
+ MEMCPY(res, term->field, char, flen);
120
+ MEMCPY(res + flen, delim, char, 1);
121
+ MEMCPY(res + flen + 1, term->text, char, tlen);
122
+ return rb_str_new(res, tlen + flen + 1 );
123
+ }
124
+
125
+ VALUE
126
+ frt_term_compare_to(VALUE self, VALUE rother)
127
+ {
128
+ int comp, size, mylen, olen;
129
+ Term *term, *other;
130
+ Data_Get_Struct(self, Term, term);
131
+ Data_Get_Struct(rother, Term, other);
132
+
133
+ mylen = term->flen;
134
+ olen = other->flen;
135
+ size = mylen >= olen ? olen : mylen;
136
+ comp = memcmp(term->field, other->field, size);
137
+ if(comp == 0){
138
+ if(mylen == olen){
139
+ mylen = term->tlen;
140
+ olen = other->tlen;
141
+ size = mylen >= olen ? olen : mylen;
142
+ comp = memcmp(term->text, other->text, size);
143
+ if(comp == 0 && mylen != olen)
144
+ comp = mylen > olen ? 1 : -1;
145
+ } else
146
+ comp = mylen > olen ? 1 : -1;
147
+ }
148
+ //comp = strcmp(term->field, other->field);
149
+ //if(comp == 0)
150
+ // comp = strcmp(term->text, other->text);
151
+ return INT2FIX(comp);
152
+ }
153
+
154
+ // keep in synch with fuction above
155
+ int
156
+ frt_term_compare_to_int(VALUE self, VALUE rother)
157
+ {
158
+ int comp, size, mylen, olen;
159
+ Term *term, *other;
160
+ Data_Get_Struct(self, Term, term);
161
+ Data_Get_Struct(rother, Term, other);
162
+
163
+ mylen = term->flen;
164
+ olen = other->flen;
165
+ size = mylen >= olen ? olen : mylen;
166
+ comp = memcmp(term->field, other->field, size);
167
+ if(comp == 0){
168
+ if(mylen == olen){
169
+ mylen = term->tlen;
170
+ olen = other->tlen;
171
+ size = mylen >= olen ? olen : mylen;
172
+ comp = memcmp(term->text, other->text, size);
173
+ if(comp == 0 && mylen != olen)
174
+ comp = mylen > olen ? 1 : -1;
175
+ } else
176
+ comp = mylen > olen ? 1 : -1;
177
+ }
178
+ //comp = strcmp(term->field, other->field);
179
+ //if(comp == 0)
180
+ // comp = strcmp(term->text, other->text);
181
+ return comp;
182
+ }
183
+
184
+ VALUE
185
+ frt_term_lt(VALUE self, VALUE rother)
186
+ {
187
+ return frt_term_compare_to_int(self, rother) < 0 ? Qtrue : Qfalse;
188
+ }
189
+
190
+ VALUE
191
+ frt_term_gt(VALUE self, VALUE rother)
192
+ {
193
+ return frt_term_compare_to_int(self, rother) > 0 ? Qtrue : Qfalse;
194
+ }
195
+
196
+ VALUE
197
+ frt_term_le(VALUE self, VALUE rother)
198
+ {
199
+ return frt_term_compare_to_int(self, rother) <= 0 ? Qtrue : Qfalse;
200
+ }
201
+
202
+ VALUE
203
+ frt_term_ge(VALUE self, VALUE rother)
204
+ {
205
+ return frt_term_compare_to_int(self, rother) >= 0 ? Qtrue : Qfalse;
206
+ }
207
+
208
+ VALUE
209
+ frt_term_eq(VALUE self, VALUE rother)
210
+ {
211
+ if (rother == Qnil)
212
+ return Qfalse;
213
+ return frt_term_compare_to_int(self, rother) == 0 ? Qtrue : Qfalse;
214
+ }
215
+
216
+
217
+ //static VALUE
218
+ //frt_term_compare_to(VALUE self, VALUE other)
219
+ //{
220
+ // return INT2FIX(frt_term_compare_to_int(self, other));
221
+ //}
222
+
223
+ static VALUE
224
+ frt_term_hash(VALUE self)
225
+ {
226
+ Term *term;
227
+ Data_Get_Struct(self, Term, term);
228
+ return INT2FIX(frt_hash(term->text, term->tlen) +
229
+ frt_hash(term->field, term->flen));
230
+ }
231
+
232
+ /****************************************************************************
233
+ *
234
+ * Init Function
235
+ *
236
+ ****************************************************************************/
237
+
238
+ void
239
+ Init_term(void)
240
+ {
241
+ //Term
242
+ cTerm = rb_define_class_under(mIndex, "Term", rb_cObject);
243
+ rb_define_alloc_func(cTerm, frt_term_alloc);
244
+ rb_include_module(cTerm, rb_mComparable);
245
+
246
+ rb_define_method(cTerm, "initialize", frt_term_init, 2);
247
+ rb_define_method(cTerm, "set!", frt_term_set, 2);
248
+ rb_define_method(cTerm, "to_s", frt_term_to_s, 0);
249
+ rb_define_method(cTerm, "<=>", frt_term_compare_to, 1);
250
+ rb_define_method(cTerm, "<", frt_term_lt, 1);
251
+ rb_define_method(cTerm, ">", frt_term_gt, 1);
252
+ rb_define_method(cTerm, "<=", frt_term_le, 1);
253
+ rb_define_method(cTerm, ">=", frt_term_ge, 1);
254
+ rb_define_method(cTerm, "eql?", frt_term_eq, 1);
255
+ rb_define_method(cTerm, "==", frt_term_eq, 1);
256
+ rb_define_method(cTerm, "text", frt_term_get_text, 0);
257
+ rb_define_method(cTerm, "text=", frt_term_set_text, 1);
258
+ rb_define_method(cTerm, "field", frt_term_get_field, 0);
259
+ rb_define_method(cTerm, "field=", frt_term_set_field, 1);
260
+ rb_define_method(cTerm, "hash", frt_term_hash, 0);
261
+ }