isomorfeus-ferret 0.17.2 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
  3. data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
  4. data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
  5. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
  6. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
  7. data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
  8. data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
  9. data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
  12. data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
  13. data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
  14. data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
  15. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  16. data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
  17. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
  18. data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
  19. data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
  20. data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
  21. data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
  22. data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
  23. data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
  24. data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
  25. data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
  26. data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
  27. data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
  28. data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
  29. data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
  30. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  31. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  32. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  33. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  34. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  36. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  37. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  39. data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
  40. data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
  41. data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
  42. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  43. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  44. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  47. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  48. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  49. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  50. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  51. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  52. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  53. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  54. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  55. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  56. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  57. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
  58. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
  59. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
  60. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  61. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
  62. data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
  63. data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
  64. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  65. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  66. data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
  67. data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
  68. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  69. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  70. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  71. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  72. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  73. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  74. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  75. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  76. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  77. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  78. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  79. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  80. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  81. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  82. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  83. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  84. data/ext/isomorfeus_ferret_ext/test.c +40 -87
  85. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  86. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  87. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  88. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  89. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  90. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  91. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  92. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  93. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
  94. data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
  95. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  96. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  97. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  98. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  99. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  100. data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
  101. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  102. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  103. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  104. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  105. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  106. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  107. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  108. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  109. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  110. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  111. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  112. data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
  113. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  114. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  115. data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
  116. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  117. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  118. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  119. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  120. data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
  121. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  122. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  123. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  124. data/lib/isomorfeus/ferret/index/index.rb +1 -1
  125. data/lib/isomorfeus/ferret/version.rb +1 -1
  126. metadata +24 -4
@@ -14,11 +14,9 @@ static FrtFieldInfos *prep_all_fis(void) {
14
14
  frt_fis_add_field(fis, frt_fi_new(rb_intern("tv+offsets"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM));
15
15
  frt_fis_add_field(fis, frt_fi_new(rb_intern("tv+offsets un-t"), 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM));
16
16
  return fis;
17
-
18
17
  }
19
18
 
20
- static void destroy_docs(FrtDocument **docs, int len)
21
- {
19
+ static void destroy_docs(FrtDocument **docs, int len) {
22
20
  int i;
23
21
  for (i = 0; i < len; i++) {
24
22
  frt_doc_destroy(docs[i]);
@@ -30,19 +28,15 @@ static FrtFieldInfos *prep_book_fis(void) {
30
28
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM);
31
29
  frt_fis_add_field(fis, frt_fi_new(rb_intern("year"), 0 | FRT_FI_IS_STORED_BM));
32
30
  return fis;
33
-
34
31
  }
35
32
 
36
33
  FrtDocument *prep_book(void) {
37
34
  FrtDocument *doc = frt_doc_new();
38
35
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
39
36
 
40
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(author),
41
- frt_estrdup("P.H. Newby"), enc))->destroy_data = true;
42
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(title),
43
- frt_estrdup("Something To Answer For"), enc))->destroy_data = true;
44
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(year),
45
- frt_estrdup("1969"), enc))->destroy_data = true;
37
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(author), "P.H. Newby", enc));
38
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(title), "Something To Answer For", enc));
39
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(year), "1969", enc));
46
40
  return doc;
47
41
  }
48
42
 
@@ -51,285 +45,171 @@ FrtDocument **prep_book_list(void) {
51
45
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
52
46
  FrtDocument **docs = FRT_ALLOC_N(FrtDocument *, BOOK_LIST_LENGTH);
53
47
  docs[0] = frt_doc_new();
54
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(author),
55
- frt_estrdup("P.H. Newby"), enc))->destroy_data = true;
56
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(title),
57
- frt_estrdup("Something To Answer For"), enc))->destroy_data = true;
58
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(year),
59
- frt_estrdup("1969"), enc))->destroy_data = true;
48
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(author), "P.H. Newby", enc));
49
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(title), "Something To Answer For", enc));
50
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(year), "1969", enc));
60
51
  docs[1] = frt_doc_new();
61
- frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(author),
62
- frt_estrdup("Bernice Rubens"), enc))->destroy_data = true;
63
- frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(title),
64
- frt_estrdup("The Elected Member"), enc))->destroy_data = true;
65
- frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(year),
66
- frt_estrdup("1970"), enc))->destroy_data = true;
52
+ frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(author), "Bernice Rubens", enc));
53
+ frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(title), "The Elected Member", enc));
54
+ frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(year), "1970", enc));
67
55
  docs[2] = frt_doc_new();
68
- frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(author),
69
- frt_estrdup("V. S. Naipaul"), enc))->destroy_data = true;
70
- frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(title),
71
- frt_estrdup("In a Free State"), enc))->destroy_data = true;
72
- frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(year),
73
- frt_estrdup("1971"), enc))->destroy_data = true;
56
+ frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(author), "V. S. Naipaul", enc));
57
+ frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(title), "In a Free State", enc));
58
+ frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(year), "1971", enc));
74
59
  docs[3] = frt_doc_new();
75
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(author),
76
- frt_estrdup("John Berger"), enc))->destroy_data = true;
77
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(title),
78
- frt_estrdup("G"), enc))->destroy_data = true;
79
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(year),
80
- frt_estrdup("1972"), enc))->destroy_data = true;
60
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(author), "John Berger", enc));
61
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(title), "G", enc));
62
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(year), "1972", enc));
81
63
  docs[4] = frt_doc_new();
82
- frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(author),
83
- frt_estrdup("J. G. Farrell"), enc))->destroy_data = true;
84
- frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(title),
85
- frt_estrdup("The Siege of Krishnapur"), enc))->destroy_data = true;
86
- frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(year),
87
- frt_estrdup("1973"), enc))->destroy_data = true;
64
+ frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(author), "J. G. Farrell", enc));
65
+ frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(title), "The Siege of Krishnapur", enc));
66
+ frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(year), "1973", enc));
88
67
  docs[5] = frt_doc_new();
89
- frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(author),
90
- frt_estrdup("Stanley Middleton"), enc))->destroy_data = true;
91
- frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(title),
92
- frt_estrdup("Holiday"), enc))->destroy_data = true;
93
- frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(year),
94
- frt_estrdup("1974"), enc))->destroy_data = true;
68
+ frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(author), "Stanley Middleton", enc));
69
+ frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(title), "Holiday", enc));
70
+ frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(year), "1974", enc));
95
71
  docs[6] = frt_doc_new();
96
- frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(author),
97
- frt_estrdup("Nadine Gordimer"), enc))->destroy_data = true;
98
- frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(title),
99
- frt_estrdup("The Conservationist"), enc))->destroy_data = true;
100
- frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(year),
101
- frt_estrdup("1974"), enc))->destroy_data = true;
72
+ frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(author), "Nadine Gordimer", enc));
73
+ frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(title), "The Conservationist", enc));
74
+ frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(year), "1974", enc));
102
75
  docs[7] = frt_doc_new();
103
- frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(author),
104
- frt_estrdup("Ruth Prawer Jhabvala"), enc))->destroy_data = true;
105
- frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(title),
106
- frt_estrdup("Heat and Dust"), enc))->destroy_data = true;
107
- frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(year),
108
- frt_estrdup("1975"), enc))->destroy_data = true;
76
+ frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(author), "Ruth Prawer Jhabvala", enc));
77
+ frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(title), "Heat and Dust", enc));
78
+ frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(year), "1975", enc));
109
79
  docs[8] = frt_doc_new();
110
- frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(author),
111
- frt_estrdup("David Storey"), enc))->destroy_data = true;
112
- frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(title),
113
- frt_estrdup("Saville"), enc))->destroy_data = true;
114
- frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(year),
115
- frt_estrdup("1976"), enc))->destroy_data = true;
80
+ frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(author), "David Storey", enc));
81
+ frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(title), "Saville", enc));
82
+ frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(year), "1976", enc));
116
83
  docs[9] = frt_doc_new();
117
- frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(author),
118
- frt_estrdup("Paul Scott"), enc))->destroy_data = true;
119
- frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(title),
120
- frt_estrdup("Staying On"), enc))->destroy_data = true;
121
- frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(year),
122
- frt_estrdup("1977"), enc))->destroy_data = true;
84
+ frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(author), "Paul Scott", enc));
85
+ frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(title), "Staying On", enc));
86
+ frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(year), "1977", enc));
123
87
  docs[10] = frt_doc_new();
124
- frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(author),
125
- frt_estrdup("Iris Murdoch"), enc))->destroy_data = true;
126
- frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(title),
127
- frt_estrdup("The Sea"), enc))->destroy_data = true;
128
- frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(year),
129
- frt_estrdup("1978"), enc))->destroy_data = true;
88
+ frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(author), "Iris Murdoch", enc));
89
+ frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(title), "The Sea", enc));
90
+ frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(year), "1978", enc));
130
91
  docs[11] = frt_doc_new();
131
- frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(author),
132
- frt_estrdup("Penelope Fitzgerald"), enc))->destroy_data = true;
133
- frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(title),
134
- frt_estrdup("Offshore"), enc))->destroy_data = true;
135
- frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(year),
136
- frt_estrdup("1979"), enc))->destroy_data = true;
92
+ frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(author), "Penelope Fitzgerald", enc));
93
+ frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(title), "Offshore", enc));
94
+ frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(year), "1979", enc));
137
95
  docs[12] = frt_doc_new();
138
- frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(author),
139
- frt_estrdup("William Golding"), enc))->destroy_data = true;
140
- frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(title),
141
- frt_estrdup("Rites of Passage"), enc))->destroy_data = true;
142
- frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(year),
143
- frt_estrdup("1980"), enc))->destroy_data = true;
96
+ frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(author), "William Golding", enc));
97
+ frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(title), "Rites of Passage", enc));
98
+ frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(year), "1980", enc));
144
99
  docs[13] = frt_doc_new();
145
- frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(author),
146
- frt_estrdup("Salman Rushdie"), enc))->destroy_data = true;
147
- frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(title),
148
- frt_estrdup("Midnight's Children"), enc))->destroy_data = true;
149
- frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(year),
150
- frt_estrdup("1981"), enc))->destroy_data = true;
100
+ frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(author), "Salman Rushdie", enc));
101
+ frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(title), "Midnight's Children", enc));
102
+ frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(year), "1981", enc));
151
103
  docs[14] = frt_doc_new();
152
- frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(author),
153
- frt_estrdup("Thomas Keneally"), enc))->destroy_data = true;
154
- frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(title),
155
- frt_estrdup("Schindler's Ark"), enc))->destroy_data = true;
156
- frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(year),
157
- frt_estrdup("1982"), enc))->destroy_data = true;
104
+ frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(author), "Thomas Keneally", enc));
105
+ frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(title), "Schindler's Ark", enc));
106
+ frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(year), "1982", enc));
158
107
  docs[15] = frt_doc_new();
159
- frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(author),
160
- frt_estrdup("J. M. Coetzee"), enc))->destroy_data = true;
161
- frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(title),
162
- frt_estrdup("Life and Times of Michael K"), enc))->destroy_data = true;
163
- frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(year),
164
- frt_estrdup("1983"), enc))->destroy_data = true;
108
+ frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(author), "J. M. Coetzee", enc));
109
+ frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(title), "Life and Times of Michael K", enc));
110
+ frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(year), "1983", enc));
165
111
  docs[16] = frt_doc_new();
166
- frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(author),
167
- frt_estrdup("Anita Brookner"), enc))->destroy_data = true;
168
- frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(title),
169
- frt_estrdup("Hotel du Lac"), enc))->destroy_data = true;
170
- frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(year),
171
- frt_estrdup("1984"), enc))->destroy_data = true;
112
+ frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(author), "Anita Brookner", enc));
113
+ frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(title), "Hotel du Lac", enc));
114
+ frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(year), "1984", enc));
172
115
  docs[17] = frt_doc_new();
173
- frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(author),
174
- frt_estrdup("Keri Hulme"), enc))->destroy_data = true;
175
- frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(title),
176
- frt_estrdup("The Bone People"), enc))->destroy_data = true;
177
- frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(year),
178
- frt_estrdup("1985"), enc))->destroy_data = true;
116
+ frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(author), "Keri Hulme", enc));
117
+ frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(title), "The Bone People", enc));
118
+ frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(year), "1985", enc));
179
119
  docs[18] = frt_doc_new();
180
- frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(author),
181
- frt_estrdup("Kingsley Amis"), enc))->destroy_data = true;
182
- frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(title),
183
- frt_estrdup("The Old Devils"), enc))->destroy_data = true;
184
- frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(year),
185
- frt_estrdup("1986"), enc))->destroy_data = true;
120
+ frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(author), "Kingsley Amis", enc));
121
+ frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(title), "The Old Devils", enc));
122
+ frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(year), "1986", enc));
186
123
  docs[19] = frt_doc_new();
187
- frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(author),
188
- frt_estrdup("Penelope Lively"), enc))->destroy_data = true;
189
- frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(title),
190
- frt_estrdup("Moon Tiger"), enc))->destroy_data = true;
191
- frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(year),
192
- frt_estrdup("1987"), enc))->destroy_data = true;
124
+ frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(author), "Penelope Lively", enc));
125
+ frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(title), "Moon Tiger", enc));
126
+ frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(year), "1987", enc));
193
127
  docs[20] = frt_doc_new();
194
- frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(author),
195
- frt_estrdup("Peter Carey"), enc))->destroy_data = true;
196
- frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(title),
197
- frt_estrdup("Oscar and Lucinda"), enc))->destroy_data = true;
198
- frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(year),
199
- frt_estrdup("1988"), enc))->destroy_data = true;
128
+ frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(author), "Peter Carey", enc));
129
+ frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(title), "Oscar and Lucinda", enc));
130
+ frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(year), "1988", enc));
200
131
  docs[21] = frt_doc_new();
201
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(author),
202
- frt_estrdup("Kazuo Ishiguro"), enc))->destroy_data = true;
203
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(title),
204
- frt_estrdup("The Remains of the Day"), enc))->destroy_data = true;
205
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(year),
206
- frt_estrdup("1989"), enc))->destroy_data = true;
132
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(author), "Kazuo Ishiguro", enc));
133
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(title), "The Remains of the Day", enc));
134
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(year), "1989", enc));
207
135
  docs[22] = frt_doc_new();
208
- frt_doc_add_field(docs[22], frt_df_add_data(frt_df_new(author),
209
- frt_estrdup("A. S. Byatt"), enc))->destroy_data = true;
210
- frt_doc_add_field(docs[22], frt_df_add_data(frt_df_new(title),
211
- frt_estrdup("Possession"), enc))->destroy_data = true;
212
- frt_doc_add_field(docs[22], frt_df_add_data(frt_df_new(year),
213
- frt_estrdup("1990"), enc))->destroy_data = true;
136
+ frt_doc_add_field(docs[22], frt_df_add_data(frt_df_new(author), "A. S. Byatt", enc));
137
+ frt_doc_add_field(docs[22], frt_df_add_data(frt_df_new(title), "Possession", enc));
138
+ frt_doc_add_field(docs[22], frt_df_add_data(frt_df_new(year), "1990", enc));
214
139
  docs[23] = frt_doc_new();
215
- frt_doc_add_field(docs[23], frt_df_add_data(frt_df_new(author),
216
- frt_estrdup("Ben Okri"), enc))->destroy_data = true;
217
- frt_doc_add_field(docs[23], frt_df_add_data(frt_df_new(title),
218
- frt_estrdup("The Famished Road"), enc))->destroy_data = true;
219
- frt_doc_add_field(docs[23], frt_df_add_data(frt_df_new(year),
220
- frt_estrdup("1991"), enc))->destroy_data = true;
140
+ frt_doc_add_field(docs[23], frt_df_add_data(frt_df_new(author), "Ben Okri", enc));
141
+ frt_doc_add_field(docs[23], frt_df_add_data(frt_df_new(title), "The Famished Road", enc));
142
+ frt_doc_add_field(docs[23], frt_df_add_data(frt_df_new(year), "1991", enc));
221
143
  docs[24] = frt_doc_new();
222
- frt_doc_add_field(docs[24], frt_df_add_data(frt_df_new(author),
223
- frt_estrdup("Michael Ondaatje"), enc))->destroy_data = true;
224
- frt_doc_add_field(docs[24], frt_df_add_data(frt_df_new(title),
225
- frt_estrdup("The English Patient"), enc))->destroy_data = true;
226
- frt_doc_add_field(docs[24], frt_df_add_data(frt_df_new(year),
227
- frt_estrdup("1992"), enc))->destroy_data = true;
144
+ frt_doc_add_field(docs[24], frt_df_add_data(frt_df_new(author), "Michael Ondaatje", enc));
145
+ frt_doc_add_field(docs[24], frt_df_add_data(frt_df_new(title), "The English Patient", enc));
146
+ frt_doc_add_field(docs[24], frt_df_add_data(frt_df_new(year), "1992", enc));
228
147
  docs[25] = frt_doc_new();
229
- frt_doc_add_field(docs[25], frt_df_add_data(frt_df_new(author),
230
- frt_estrdup("Barry Unsworth"), enc))->destroy_data = true;
231
- frt_doc_add_field(docs[25], frt_df_add_data(frt_df_new(title),
232
- frt_estrdup("Sacred Hunger"), enc))->destroy_data = true;
233
- frt_doc_add_field(docs[25], frt_df_add_data(frt_df_new(year),
234
- frt_estrdup("1992"), enc))->destroy_data = true;
148
+ frt_doc_add_field(docs[25], frt_df_add_data(frt_df_new(author), "Barry Unsworth", enc));
149
+ frt_doc_add_field(docs[25], frt_df_add_data(frt_df_new(title), "Sacred Hunger", enc));
150
+ frt_doc_add_field(docs[25], frt_df_add_data(frt_df_new(year), "1992", enc));
235
151
  docs[26] = frt_doc_new();
236
- frt_doc_add_field(docs[26], frt_df_add_data(frt_df_new(author),
237
- frt_estrdup("Roddy Doyle"), enc))->destroy_data = true;
238
- frt_doc_add_field(docs[26], frt_df_add_data(frt_df_new(title),
239
- frt_estrdup("Paddy Clarke Ha Ha Ha"), enc))->destroy_data = true;
240
- frt_doc_add_field(docs[26], frt_df_add_data(frt_df_new(year),
241
- frt_estrdup("1993"), enc))->destroy_data = true;
152
+ frt_doc_add_field(docs[26], frt_df_add_data(frt_df_new(author), "Roddy Doyle", enc));
153
+ frt_doc_add_field(docs[26], frt_df_add_data(frt_df_new(title), "Paddy Clarke Ha Ha Ha", enc));
154
+ frt_doc_add_field(docs[26], frt_df_add_data(frt_df_new(year), "1993", enc));
242
155
  docs[27] = frt_doc_new();
243
- frt_doc_add_field(docs[27], frt_df_add_data(frt_df_new(author),
244
- frt_estrdup("James Kelman"), enc))->destroy_data = true;
245
- frt_doc_add_field(docs[27], frt_df_add_data(frt_df_new(title),
246
- frt_estrdup("How Late It Was, How Late"), enc))->destroy_data = true;
247
- frt_doc_add_field(docs[27], frt_df_add_data(frt_df_new(year),
248
- frt_estrdup("1994"), enc))->destroy_data = true;
156
+ frt_doc_add_field(docs[27], frt_df_add_data(frt_df_new(author), "James Kelman", enc));
157
+ frt_doc_add_field(docs[27], frt_df_add_data(frt_df_new(title), "How Late It Was, How Late", enc));
158
+ frt_doc_add_field(docs[27], frt_df_add_data(frt_df_new(year), "1994", enc));
249
159
  docs[28] = frt_doc_new();
250
- frt_doc_add_field(docs[28], frt_df_add_data(frt_df_new(author),
251
- frt_estrdup("Pat Barker"), enc))->destroy_data = true;
252
- frt_doc_add_field(docs[28], frt_df_add_data(frt_df_new(title),
253
- frt_estrdup("The Ghost Road"), enc))->destroy_data = true;
254
- frt_doc_add_field(docs[28], frt_df_add_data(frt_df_new(year),
255
- frt_estrdup("1995"), enc))->destroy_data = true;
160
+ frt_doc_add_field(docs[28], frt_df_add_data(frt_df_new(author), "Pat Barker", enc));
161
+ frt_doc_add_field(docs[28], frt_df_add_data(frt_df_new(title), "The Ghost Road", enc));
162
+ frt_doc_add_field(docs[28], frt_df_add_data(frt_df_new(year), "1995", enc));
256
163
  docs[29] = frt_doc_new();
257
- frt_doc_add_field(docs[29], frt_df_add_data(frt_df_new(author),
258
- frt_estrdup("Graham Swift"), enc))->destroy_data = true;
259
- frt_doc_add_field(docs[29], frt_df_add_data(frt_df_new(title),
260
- frt_estrdup("Last Orders"), enc))->destroy_data = true;
261
- frt_doc_add_field(docs[29], frt_df_add_data(frt_df_new(year),
262
- frt_estrdup("1996"), enc))->destroy_data = true;
164
+ frt_doc_add_field(docs[29], frt_df_add_data(frt_df_new(author), "Graham Swift", enc));
165
+ frt_doc_add_field(docs[29], frt_df_add_data(frt_df_new(title), "Last Orders", enc));
166
+ frt_doc_add_field(docs[29], frt_df_add_data(frt_df_new(year), "1996", enc));
263
167
  docs[30] = frt_doc_new();
264
- frt_doc_add_field(docs[30], frt_df_add_data(frt_df_new(author),
265
- frt_estrdup("Arundati Roy"), enc))->destroy_data = true;
266
- frt_doc_add_field(docs[30], frt_df_add_data(frt_df_new(title),
267
- frt_estrdup("The God of Small Things"), enc))->destroy_data = true;
268
- frt_doc_add_field(docs[30], frt_df_add_data(frt_df_new(year),
269
- frt_estrdup("1997"), enc))->destroy_data = true;
168
+ frt_doc_add_field(docs[30], frt_df_add_data(frt_df_new(author), "Arundati Roy", enc));
169
+ frt_doc_add_field(docs[30], frt_df_add_data(frt_df_new(title), "The God of Small Things", enc));
170
+ frt_doc_add_field(docs[30], frt_df_add_data(frt_df_new(year), "1997", enc));
270
171
  docs[31] = frt_doc_new();
271
- frt_doc_add_field(docs[31], frt_df_add_data(frt_df_new(author),
272
- frt_estrdup("Ian McEwan"), enc))->destroy_data = true;
273
- frt_doc_add_field(docs[31], frt_df_add_data(frt_df_new(title),
274
- frt_estrdup("Amsterdam"), enc))->destroy_data = true;
275
- frt_doc_add_field(docs[31], frt_df_add_data(frt_df_new(year),
276
- frt_estrdup("1998"), enc))->destroy_data = true;
172
+ frt_doc_add_field(docs[31], frt_df_add_data(frt_df_new(author), "Ian McEwan", enc));
173
+ frt_doc_add_field(docs[31], frt_df_add_data(frt_df_new(title), "Amsterdam", enc));
174
+ frt_doc_add_field(docs[31], frt_df_add_data(frt_df_new(year), "1998", enc));
277
175
  docs[32] = frt_doc_new();
278
- frt_doc_add_field(docs[32], frt_df_add_data(frt_df_new(author),
279
- frt_estrdup("J. M. Coetzee"), enc))->destroy_data = true;
280
- frt_doc_add_field(docs[32], frt_df_add_data(frt_df_new(title),
281
- frt_estrdup("Disgrace"), enc))->destroy_data = true;
282
- frt_doc_add_field(docs[32], frt_df_add_data(frt_df_new(year),
283
- frt_estrdup("1999"), enc))->destroy_data = true;
176
+ frt_doc_add_field(docs[32], frt_df_add_data(frt_df_new(author), "J. M. Coetzee", enc));
177
+ frt_doc_add_field(docs[32], frt_df_add_data(frt_df_new(title), "Disgrace", enc));
178
+ frt_doc_add_field(docs[32], frt_df_add_data(frt_df_new(year), "1999", enc));
284
179
  docs[33] = frt_doc_new();
285
- frt_doc_add_field(docs[33], frt_df_add_data(frt_df_new(author),
286
- frt_estrdup("Margaret Atwood"), enc))->destroy_data = true;
287
- frt_doc_add_field(docs[33], frt_df_add_data(frt_df_new(title),
288
- frt_estrdup("The Blind Assassin"), enc))->destroy_data = true;
289
- frt_doc_add_field(docs[33], frt_df_add_data(frt_df_new(year),
290
- frt_estrdup("2000"), enc))->destroy_data = true;
180
+ frt_doc_add_field(docs[33], frt_df_add_data(frt_df_new(author), "Margaret Atwood", enc));
181
+ frt_doc_add_field(docs[33], frt_df_add_data(frt_df_new(title), "The Blind Assassin", enc));
182
+ frt_doc_add_field(docs[33], frt_df_add_data(frt_df_new(year), "2000", enc));
291
183
  docs[34] = frt_doc_new();
292
- frt_doc_add_field(docs[34], frt_df_add_data(frt_df_new(author),
293
- frt_estrdup("Peter Carey"), enc))->destroy_data = true;
294
- frt_doc_add_field(docs[34], frt_df_add_data(frt_df_new(title),
295
- frt_estrdup("True History of the Kelly Gang"), enc))->destroy_data = true;
296
- frt_doc_add_field(docs[34], frt_df_add_data(frt_df_new(year),
297
- frt_estrdup("2001"), enc))->destroy_data = true;
184
+ frt_doc_add_field(docs[34], frt_df_add_data(frt_df_new(author), "Peter Carey", enc));
185
+ frt_doc_add_field(docs[34], frt_df_add_data(frt_df_new(title), "True History of the Kelly Gang", enc));
186
+ frt_doc_add_field(docs[34], frt_df_add_data(frt_df_new(year), "2001", enc));
298
187
  docs[35] = frt_doc_new();
299
- frt_doc_add_field(docs[35], frt_df_add_data(frt_df_new(author),
300
- frt_estrdup("Yann Martel"), enc))->destroy_data = true;
301
- frt_doc_add_field(docs[35], frt_df_add_data(frt_df_new(title),
302
- frt_estrdup("The Life of Pi"), enc))->destroy_data = true;
303
- frt_doc_add_field(docs[35], frt_df_add_data(frt_df_new(year),
304
- frt_estrdup("2002"), enc))->destroy_data = true;
188
+ frt_doc_add_field(docs[35], frt_df_add_data(frt_df_new(author), "Yann Martel", enc));
189
+ frt_doc_add_field(docs[35], frt_df_add_data(frt_df_new(title), "The Life of Pi", enc));
190
+ frt_doc_add_field(docs[35], frt_df_add_data(frt_df_new(year), "2002", enc));
305
191
  docs[36] = frt_doc_new();
306
- frt_doc_add_field(docs[36], frt_df_add_data(frt_df_new(author),
307
- frt_estrdup("DBC Pierre"), enc))->destroy_data = true;
308
- frt_doc_add_field(docs[36], frt_df_add_data(frt_df_new(title),
309
- frt_estrdup("Vernon God Little"), enc))->destroy_data = true;
310
- frt_doc_add_field(docs[36], frt_df_add_data(frt_df_new(year),
311
- frt_estrdup("2003"), enc))->destroy_data = true;
192
+ frt_doc_add_field(docs[36], frt_df_add_data(frt_df_new(author), "DBC Pierre", enc));
193
+ frt_doc_add_field(docs[36], frt_df_add_data(frt_df_new(title), "Vernon God Little", enc));
194
+ frt_doc_add_field(docs[36], frt_df_add_data(frt_df_new(year), "2003", enc));
312
195
 
313
196
  return docs;
314
197
  }
315
198
 
316
- static void add_document_with_fields(FrtIndexWriter *iw, int i)
317
- {
199
+ static void add_document_with_fields(FrtIndexWriter *iw, int i) {
318
200
  FrtDocument **docs = prep_book_list();
319
201
  frt_iw_add_doc(iw, docs[i]);
320
202
  destroy_docs(docs, BOOK_LIST_LENGTH);
321
203
  }
322
204
 
323
- static FrtIndexWriter *create_book_iw_conf(FrtStore *store, const FrtConfig *config)
324
- {
205
+ static FrtIndexWriter *create_book_iw_conf(FrtStore *store, const FrtConfig *config) {
325
206
  FrtFieldInfos *fis = prep_book_fis();
326
207
  frt_index_create(store, fis);
327
208
  frt_fis_deref(fis);
328
209
  return frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), config);
329
210
  }
330
211
 
331
- static FrtIndexWriter *create_book_iw(FrtStore *store)
332
- {
212
+ static FrtIndexWriter *create_book_iw(FrtStore *store) {
333
213
  return create_book_iw_conf(store, &frt_default_config);
334
214
  }
335
215
 
@@ -343,146 +223,91 @@ FrtDocument **prep_ir_test_docs(void) {
343
223
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
344
224
 
345
225
  docs[0] = frt_doc_new();
346
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(changing_field),
347
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 "
348
- "word3 word3"), enc))->destroy_data = true;
349
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(compressed_field_brotli),
350
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 "
351
- "word3 word3"), enc))->destroy_data = true;
352
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(compressed_field_bzip2),
353
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 "
354
- "word3 word3"), enc))->destroy_data = true;
355
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(compressed_field_lz4),
356
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 "
357
- "word3 word3"), enc))->destroy_data = true;
358
- frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(body),
359
- frt_estrdup("Where is Wally"), enc))->destroy_data = true;
226
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(changing_field), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
227
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(compressed_field_brotli), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
228
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(compressed_field_bzip2), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
229
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(compressed_field_lz4), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
230
+ frt_doc_add_field(docs[0], frt_df_add_data(frt_df_new(body), "Where is Wally", enc));
360
231
  docs[1] = frt_doc_new();
361
- frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(body),
362
- frt_estrdup("Some Random Sentence read"), enc))->destroy_data = true;
363
- frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(tag),
364
- frt_estrdup("id_test"), enc))->destroy_data = true;
232
+ frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(body), "Some Random Sentence read", enc));
233
+ frt_doc_add_field(docs[1], frt_df_add_data(frt_df_new(tag), "id_test", enc));
365
234
  docs[2] = frt_doc_new();
366
- frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(body),
367
- frt_estrdup("Some read Random Sentence read"), enc))->destroy_data = true;
235
+ frt_doc_add_field(docs[2], frt_df_add_data(frt_df_new(body), "Some read Random Sentence read", enc));
368
236
  df = frt_df_new(tag);
369
- frt_df_add_data(df, frt_estrdup("one"), enc);
370
- frt_df_add_data(df, frt_estrdup("two"), enc);
371
- frt_df_add_data(df, frt_estrdup("three"), enc);
372
- frt_df_add_data(df, frt_estrdup("four"), enc);
373
- frt_doc_add_field(docs[2], df)->destroy_data = true;
237
+ frt_df_add_data(df, "one ", enc);
238
+ frt_df_add_data(df, "two ", enc);
239
+ frt_df_add_data(df, "three ", enc);
240
+ frt_df_add_data(df, "four", enc);
241
+ frt_doc_add_field(docs[2], df);
374
242
  df = frt_df_new(compressed_field_brotli);
375
- frt_df_add_data(df, frt_estrdup("one"), enc);
376
- frt_df_add_data(df, frt_estrdup("two"), enc);
377
- frt_df_add_data(df, frt_estrdup("three"), enc);
378
- frt_df_add_data(df, frt_estrdup("four"), enc);
379
- frt_doc_add_field(docs[2], df)->destroy_data = true;
243
+ frt_df_add_data(df, "one ", enc);
244
+ frt_df_add_data(df, "two ", enc);
245
+ frt_df_add_data(df, "three ", enc);
246
+ frt_df_add_data(df, "four", enc);
247
+ frt_doc_add_field(docs[2], df);
380
248
  df = frt_df_new(compressed_field_bzip2);
381
- frt_df_add_data(df, frt_estrdup("one"), enc);
382
- frt_df_add_data(df, frt_estrdup("two"), enc);
383
- frt_df_add_data(df, frt_estrdup("three"), enc);
384
- frt_df_add_data(df, frt_estrdup("four"), enc);
385
- frt_doc_add_field(docs[2], df)->destroy_data = true;
249
+ frt_df_add_data(df, "one ", enc);
250
+ frt_df_add_data(df, "two ", enc);
251
+ frt_df_add_data(df, "three ", enc);
252
+ frt_df_add_data(df, "four", enc);
253
+ frt_doc_add_field(docs[2], df);
386
254
  df = frt_df_new(compressed_field_lz4);
387
- frt_df_add_data(df, frt_estrdup("one"), enc);
388
- frt_df_add_data(df, frt_estrdup("two"), enc);
389
- frt_df_add_data(df, frt_estrdup("three"), enc);
390
- frt_df_add_data(df, frt_estrdup("four"), enc);
391
- frt_doc_add_field(docs[2], df)->destroy_data = true;
255
+ frt_df_add_data(df, "one ", enc);
256
+ frt_df_add_data(df, "two ", enc);
257
+ frt_df_add_data(df, "three ", enc);
258
+ frt_df_add_data(df, "four", enc);
259
+ frt_doc_add_field(docs[2], df);
392
260
  docs[3] = frt_doc_new();
393
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(title),
394
- frt_estrdup("War And Peace"), enc))->destroy_data = true;
395
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(body),
396
- frt_estrdup("word3 word4 word1 word2 word1 "
397
- "word3 word4 word1 word3 word3"), enc))->destroy_data = true;
398
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(author),
399
- frt_estrdup("Leo Tolstoy"), enc))->destroy_data = true;
400
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(year),
401
- frt_estrdup("1865"), enc))->destroy_data = true;
402
- frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(text),
403
- frt_estrdup("more text which is not stored"), enc))->destroy_data = true;
261
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(title), "War And Peace", enc));
262
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(body), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
263
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(author), "Leo Tolstoy", enc));
264
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(year), "1865", enc));
265
+ frt_doc_add_field(docs[3], frt_df_add_data(frt_df_new(text), "more text which is not stored", enc));
404
266
  docs[4] = frt_doc_new();
405
- frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(body),
406
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
267
+ frt_doc_add_field(docs[4], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
407
268
  docs[5] = frt_doc_new();
408
- frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(body),
409
- frt_estrdup("Here's Wally"), enc))->destroy_data = true;
410
- frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(text),
411
- frt_estrdup("so_that_norm_can_be_set"), enc))->destroy_data = true;
269
+ frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(body), "Here's Wally", enc));
270
+ frt_doc_add_field(docs[5], frt_df_add_data(frt_df_new(text), "so_that_norm_can_be_set", enc));
412
271
  docs[6] = frt_doc_new();
413
- frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(body),
414
- frt_estrdup("Some Random Sentence read read read read"
415
- ), enc))->destroy_data = true;
272
+ frt_doc_add_field(docs[6], frt_df_add_data(frt_df_new(body), "Some Random Sentence read read read read", enc));
416
273
  docs[7] = frt_doc_new();
417
- frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(body),
418
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
274
+ frt_doc_add_field(docs[7], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
419
275
  docs[8] = frt_doc_new();
420
- frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(body),
421
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
276
+ frt_doc_add_field(docs[8], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
422
277
  docs[9] = frt_doc_new();
423
- frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(body),
424
- frt_estrdup("read Some Random Sentence read this will be used after "
425
- "unfinished next position read"), enc))->destroy_data = true;
278
+ frt_doc_add_field(docs[9], frt_df_add_data(frt_df_new(body), "read Some Random Sentence read this will be used after unfinished next position read", enc));
426
279
  docs[10] = frt_doc_new();
427
- frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(body),
428
- frt_estrdup("Some read Random Sentence"), enc))->destroy_data = true;
429
- frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(changing_field),
430
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 word3 "
431
- "word3"), enc))->destroy_data = true;
280
+ frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(body), "Some read Random Sentence", enc));
281
+ frt_doc_add_field(docs[10], frt_df_add_data(frt_df_new(changing_field), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
432
282
  docs[11] = frt_doc_new();
433
- frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(body),
434
- frt_estrdup("And here too. Well, maybe Not"), enc))->destroy_data = true;
283
+ frt_doc_add_field(docs[11], frt_df_add_data(frt_df_new(body), "And here too. Well, maybe Not", enc));
435
284
  docs[12] = frt_doc_new();
436
- frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(title),
437
- frt_estrdup("Shawshank Redemption"), enc))->destroy_data = true;
438
- frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(body),
439
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
285
+ frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(title), "Shawshank Redemption", enc));
286
+ frt_doc_add_field(docs[12], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
440
287
  docs[13] = frt_doc_new();
441
- frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(body),
442
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
288
+ frt_doc_add_field(docs[13], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
443
289
  docs[14] = frt_doc_new();
444
- frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(body),
445
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
290
+ frt_doc_add_field(docs[14], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
446
291
  docs[15] = frt_doc_new();
447
- frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(body),
448
- frt_estrdup("Some read Random Sentence"), enc))->destroy_data = true;
292
+ frt_doc_add_field(docs[15], frt_df_add_data(frt_df_new(body), "Some read Random Sentence", enc));
449
293
  docs[16] = frt_doc_new();
450
- frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(body),
451
- frt_estrdup("Some Random read read Sentence"), enc))->destroy_data = true;
294
+ frt_doc_add_field(docs[16], frt_df_add_data(frt_df_new(body), "Some Random read read Sentence", enc));
452
295
  docs[17] = frt_doc_new();
453
- frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(body),
454
- frt_estrdup("Some Random read Sentence"), enc))->destroy_data = true;
455
- frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(changing_field),
456
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 word3 "
457
- "word3"), enc))->destroy_data = true;
296
+ frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(body), "Some Random read Sentence", enc));
297
+ frt_doc_add_field(docs[17], frt_df_add_data(frt_df_new(changing_field), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
458
298
  docs[18] = frt_doc_new();
459
- frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(body),
460
- frt_estrdup("Wally Wally Wally"), enc))->destroy_data = true;
299
+ frt_doc_add_field(docs[18], frt_df_add_data(frt_df_new(body), "Wally Wally Wally", enc));
461
300
  docs[19] = frt_doc_new();
462
- frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(body),
463
- frt_estrdup("Some Random Sentence"), enc))->destroy_data = true;
464
- frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(changing_field),
465
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 word3 "
466
- "word3"), enc))->destroy_data = true;
301
+ frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(body), "Some Random Sentence", enc));
302
+ frt_doc_add_field(docs[19], frt_df_add_data(frt_df_new(changing_field), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
467
303
  docs[20] = frt_doc_new();
468
- frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(body),
469
- frt_estrdup("Wally is where Wally usually likes to go. Wally Mart! "
470
- "Wally likes shopping there for Where's Wally books. "
471
- "Wally likes to read"), enc))->destroy_data = true;
472
- frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(changing_field),
473
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 word3 "
474
- "word3"), enc))->destroy_data = true;
304
+ frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(body), "Wally is where Wally usually likes to go. Wally Mart! Wally likes shopping there for Where's Wally books. Wally likes to read", enc));
305
+ frt_doc_add_field(docs[20], frt_df_add_data(frt_df_new(changing_field), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
475
306
  docs[21] = frt_doc_new();
476
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(body),
477
- frt_estrdup("Some Random Sentence read read read and more read read "
478
- "read"), enc))->destroy_data = true;
479
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(changing_field),
480
- frt_estrdup("word3 word4 word1 word2 word1 word3 word4 word1 word3 "
481
- "word3"), enc))->destroy_data = true;
482
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(rb_intern("new field")),
483
- frt_estrdup("zdata znot zto zbe zfound"), enc))->destroy_data = true;
484
- frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(title),
485
- frt_estrdup("title_too_long_for_max_word_lengthxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), enc))->destroy_data = true;
307
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(body), "Some Random Sentence read read read and more read read read", enc));
308
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(changing_field), "word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", enc));
309
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(rb_intern("new field")), "zdata znot zto zbe zfound", enc));
310
+ frt_doc_add_field(docs[21], frt_df_add_data(frt_df_new(title), "title_too_long_for_max_word_lengthxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", enc));
486
311
 
487
312
  for (i = 1; i < 22; i++) {
488
313
  strcat(buf, "skip ");
@@ -491,7 +316,7 @@ FrtDocument **prep_ir_test_docs(void) {
491
316
  strcat(buf, "skip ");
492
317
  docs[i] = frt_doc_new();
493
318
  frt_doc_add_field(docs[i], frt_df_add_data(frt_df_new(text),
494
- frt_estrdup(buf), enc))->destroy_data = true;
319
+ buf, enc));
495
320
  }
496
321
  return docs;
497
322
  }
@@ -500,8 +325,7 @@ FrtDocument **prep_ir_test_docs(void) {
500
325
  #define MAX_TEST_WORDS 1000
501
326
 
502
327
  static void prep_stde_test_docs(FrtDocument **docs, int doc_cnt, int num_words,
503
- FrtFieldInfos *fis)
504
- {
328
+ FrtFieldInfos *fis) {
505
329
  int i, j;
506
330
  char *buf = FRT_ALLOC_N(char, num_words * (TEST_WORD_LIST_MAX_LEN + 1));
507
331
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
@@ -511,8 +335,7 @@ static void prep_stde_test_docs(FrtDocument **docs, int doc_cnt, int num_words,
511
335
  for (j = 0; j < fis->size; j++) {
512
336
  if ((rand() % 2) == 0) {
513
337
  FrtDocField *df = frt_df_new(fis->fields[j]->name);
514
- frt_df_add_data(df, frt_estrdup(make_random_string(buf, num_words)), enc);
515
- df->destroy_data = true;
338
+ frt_df_add_data(df, make_random_string(buf, num_words), enc);
516
339
  frt_doc_add_field(docs[i], df);
517
340
  }
518
341
  }
@@ -521,8 +344,7 @@ static void prep_stde_test_docs(FrtDocument **docs, int doc_cnt, int num_words,
521
344
  }
522
345
 
523
346
  static void prep_test_1seg_index(FrtStore *store, FrtDocument **docs,
524
- int doc_cnt, FrtFieldInfos *fis)
525
- {
347
+ int doc_cnt, FrtFieldInfos *fis) {
526
348
  int i;
527
349
  FrtDocWriter *dw;
528
350
  FrtIndexWriter *iw;
@@ -548,8 +370,7 @@ static void prep_test_1seg_index(FrtStore *store, FrtDocument **docs,
548
370
  *
549
371
  ****************************************************************************/
550
372
 
551
- static void test_segment_term_doc_enum(TestCase *tc, void *data)
552
- {
373
+ static void test_segment_term_doc_enum(TestCase *tc, void *data) {
553
374
  int i, j;
554
375
  FrtStore *store = (FrtStore *)data;
555
376
  FrtFieldInfos *fis = prep_all_fis();
@@ -570,8 +391,8 @@ static void test_segment_term_doc_enum(TestCase *tc, void *data)
570
391
  sfi = frt_sfi_open(store, "_0");
571
392
  tir = frt_tir_open(store, sfi, "_0");
572
393
  skip_interval = ((FrtSegmentTermEnum *)tir->orig_te)->skip_interval;
573
- frq_in = store->open_input(store, "_0.frq");
574
- prx_in = store->open_input(store, "_0.prx");
394
+ frq_in = store->open_input(store, segm_idx_name, "_0.frq");
395
+ prx_in = store->open_input(store, segm_idx_name, "_0.prx");
575
396
  tde = frt_stde_new(tir, frq_in, bv, skip_interval);
576
397
  tde_reader = frt_stde_new(tir, frq_in, bv, skip_interval);
577
398
  tde_skip_to = frt_stde_new(tir, frq_in, bv, skip_interval);
@@ -645,7 +466,6 @@ static void test_segment_term_doc_enum(TestCase *tc, void *data)
645
466
  Atrue(! tde->next(tde));
646
467
  Atrue(! tde->skip_to(tde, 0));
647
468
  Atrue(! tde->skip_to(tde, 1000000));
648
-
649
469
  }
650
470
  tde->close(tde);
651
471
  tde_skip_to->close(tde_skip_to);
@@ -663,8 +483,7 @@ static void test_segment_term_doc_enum(TestCase *tc, void *data)
663
483
  const char *double_word = "word word";
664
484
  const char *triple_word = "word word word";
665
485
 
666
- static void test_segment_tde_deleted_docs(TestCase *tc, void *data)
667
- {
486
+ static void test_segment_tde_deleted_docs(TestCase *tc, void *data) {
668
487
  int i, doc_num_expected, skip_interval;
669
488
  FrtStore *store = (FrtStore *)data;
670
489
  FrtDocWriter *dw;
@@ -686,8 +505,7 @@ static void test_segment_tde_deleted_docs(TestCase *tc, void *data)
686
505
  frt_bv_set(bv, i);
687
506
  Aiequal(1, frt_bv_get(bv, i));
688
507
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("f")), (char *)double_word, enc));
689
- }
690
- else {
508
+ } else {
691
509
  frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("f")), (char *)triple_word, enc));
692
510
  }
693
511
  frt_dw_add_doc(dw, doc);
@@ -699,8 +517,8 @@ static void test_segment_tde_deleted_docs(TestCase *tc, void *data)
699
517
 
700
518
  sfi = frt_sfi_open(store, "_0");
701
519
  tir = frt_tir_open(store, sfi, "_0");
702
- frq_in = store->open_input(store, "_0.frq");
703
- prx_in = store->open_input(store, "_0.prx");
520
+ frq_in = store->open_input(store, segm_idx_name, "_0.frq");
521
+ prx_in = store->open_input(store, segm_idx_name, "_0.prx");
704
522
  skip_interval = sfi->skip_interval;
705
523
  tde = frt_stpe_new(tir, frq_in, prx_in, bv, skip_interval);
706
524
 
@@ -734,21 +552,19 @@ static void test_segment_tde_deleted_docs(TestCase *tc, void *data)
734
552
  *
735
553
  ****************************************************************************/
736
554
 
737
- static void test_index_create(TestCase *tc, void *data)
738
- {
555
+ static void test_index_create(TestCase *tc, void *data) {
739
556
  FrtStore *store = (FrtStore *)data;
740
557
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM);
741
558
  (void)tc;
742
559
 
743
- store->clear_all(store);
744
- Assert(!store->exists(store, "segments"), "segments shouldn't exist yet");
560
+ store->clear_all(store, segm_idx_name);
561
+ Assert(!store->exists(store, segm_idx_name, "segments"), "segments shouldn't exist yet");
745
562
  frt_index_create(store, fis);
746
- Assert(store->exists(store, "segments"), "segments should now exist");
563
+ Assert(store->exists(store, segm_idx_name, "segments"), "segments should now exist");
747
564
  frt_fis_deref(fis);
748
565
  }
749
566
 
750
- static void test_index_version(TestCase *tc, void *data)
751
- {
567
+ static void test_index_version(TestCase *tc, void *data) {
752
568
  frt_u64 version;
753
569
  FrtStore *store = (FrtStore *)data;
754
570
  FrtIndexWriter *iw = create_book_iw(store);
@@ -773,8 +589,7 @@ static void test_index_version(TestCase *tc, void *data)
773
589
  frt_ir_close(ir);
774
590
  }
775
591
 
776
- static void test_index_undelete_all_after_close(TestCase *tc, void *data)
777
- {
592
+ static void test_index_undelete_all_after_close(TestCase *tc, void *data) {
778
593
  FrtStore *store = (FrtStore *)data;
779
594
  FrtIndexWriter *iw = create_book_iw(store);
780
595
  FrtIndexReader *ir;
@@ -801,8 +616,7 @@ static void test_index_undelete_all_after_close(TestCase *tc, void *data)
801
616
  *
802
617
  ****************************************************************************/
803
618
 
804
- static void test_fld_inverter(TestCase *tc, void *data)
805
- {
619
+ static void test_fld_inverter(TestCase *tc, void *data) {
806
620
  FrtStore *store = (FrtStore *)data;
807
621
  FrtHash *plists;
808
622
  FrtHash *curr_plists;
@@ -816,9 +630,9 @@ static void test_fld_inverter(TestCase *tc, void *data)
816
630
  dw = frt_dw_open(iw, frt_sis_new_segment(iw->sis, 0, iw->store));
817
631
 
818
632
  df = frt_df_new(rb_intern("no tv"));
819
- frt_df_add_data(df, (char *)"one two three four five two three four five three four five four five", enc);
820
- frt_df_add_data(df, (char *)"ichi ni san yon go ni san yon go san yon go yon go go", enc);
821
- frt_df_add_data(df, (char *)"The quick brown fox jumped over five lazy dogs", enc);
633
+ frt_df_add_data(df, "one two three four five two three four five three four five four five", enc);
634
+ frt_df_add_data(df, "ichi ni san yon go ni san yon go san yon go yon go go", enc);
635
+ frt_df_add_data(df, "The quick brown fox jumped over five lazy dogs", enc);
822
636
 
823
637
  curr_plists = frt_dw_invert_field(
824
638
  dw,
@@ -830,7 +644,6 @@ static void test_fld_inverter(TestCase *tc, void *data)
830
644
  plists = ((FrtFieldInverter *)frt_h_get_int(
831
645
  dw->fields, frt_fis_get_field(dw->fis, df->name)->number))->plists;
832
646
 
833
-
834
647
  pl = (FrtPostingList *)frt_h_get(curr_plists, "one");
835
648
  if (Apnotnull(pl)) {
836
649
  Asequal("one", pl->term);
@@ -862,8 +675,8 @@ static void test_fld_inverter(TestCase *tc, void *data)
862
675
  frt_df_destroy(df);
863
676
 
864
677
  df = frt_df_new(rb_intern("no tv"));
865
- frt_df_add_data(df, (char *)"seven new words and six old ones", enc);
866
- frt_df_add_data(df, (char *)"ichi ni one two quick dogs", enc);
678
+ frt_df_add_data(df, "seven new words and six old ones", enc);
679
+ frt_df_add_data(df, "ichi ni one two quick dogs", enc);
867
680
 
868
681
  dw->doc_num++;
869
682
  frt_dw_reset_postings(dw->curr_plists);
@@ -900,8 +713,7 @@ static void test_fld_inverter(TestCase *tc, void *data)
900
713
  }
901
714
 
902
715
  #define NUM_POSTINGS TEST_WORD_LIST_SIZE
903
- static void test_postings_sorter(TestCase *tc, void *data)
904
- {
716
+ static void test_postings_sorter(TestCase *tc, void *data) {
905
717
  int i;
906
718
  FrtPostingList plists[NUM_POSTINGS], *p_ptr[NUM_POSTINGS];
907
719
  (void)data, (void)tc;
@@ -919,8 +731,7 @@ static void test_postings_sorter(TestCase *tc, void *data)
919
731
  }
920
732
  }
921
733
 
922
- static void test_iw_add_doc(TestCase *tc, void *data)
923
- {
734
+ static void test_iw_add_doc(TestCase *tc, void *data) {
924
735
  FrtStore *store = (FrtStore *)data;
925
736
  FrtIndexWriter *iw = create_book_iw(store);
926
737
  FrtDocument **docs = prep_book_list();
@@ -929,20 +740,20 @@ static void test_iw_add_doc(TestCase *tc, void *data)
929
740
  Aiequal(1, frt_iw_doc_count(iw));
930
741
  // Assert(!store->exists(store, "_0.fdx"), "data shouldn't have been written yet");
931
742
  frt_iw_commit(iw);
932
- Assert(store->exists(store, "_0.fdx"), "data should now be written");
743
+ Assert(store->exists(store, segm_idx_name, "_0.fdx"), "data should now be written");
933
744
  frt_iw_close(iw);
934
- Assert(store->exists(store, "_0.fdx"), "data should still be there");
745
+ Assert(store->exists(store, segm_idx_name, "_0.fdx"), "data should still be there");
935
746
 
936
747
  iw = frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), &frt_default_config);
937
748
  frt_iw_add_doc(iw, docs[1]);
938
749
  Aiequal(2, frt_iw_doc_count(iw));
939
750
  // Assert(!store->exists(store, "_1.fdx"), "data shouldn't have been written yet");
940
- Assert(store->exists(store, "_0.fdx"), "data should still be there");
751
+ Assert(store->exists(store, segm_idx_name, "_0.fdx"), "data should still be there");
941
752
  frt_iw_commit(iw);
942
- Assert(store->exists(store, "_1.fdx"), "data should now be written");
753
+ Assert(store->exists(store, segm_idx_name, "_1.fdx"), "data should now be written");
943
754
  frt_iw_close(iw);
944
- Assert(store->exists(store, "_1.fdx"), "data should still be there");
945
- Assert(store->exists(store, "_0.fdx"), "data should still be there");
755
+ Assert(store->exists(store, segm_idx_name, "_1.fdx"), "data should still be there");
756
+ Assert(store->exists(store, segm_idx_name, "_0.fdx"), "data should still be there");
946
757
 
947
758
  destroy_docs(docs, BOOK_LIST_LENGTH);
948
759
  }
@@ -952,14 +763,14 @@ static void test_iw_add_doc(TestCase *tc, void *data)
952
763
  * reader holds it open (this fails pre lock-less
953
764
  * commits on windows):
954
765
  */
955
- static void test_create_with_reader(TestCase *tc, void *data)
956
- {
766
+ static void test_create_with_reader(TestCase *tc, void *data) {
957
767
  FrtStore *store = frt_open_mdbx_store(TEST_DIR);
768
+ store->create_folder(store, segm_idx_name);
958
769
  (void)data;
959
770
  FrtIndexWriter *iw;
960
771
  FrtIndexReader *ir, *ir2;
961
772
  FrtDocument *doc = prep_book();
962
- store->clear_all(store);
773
+ store->clear_all(store, segm_idx_name);
963
774
 
964
775
  /* add one document & close writer */
965
776
  iw = create_book_iw(store);
@@ -981,7 +792,7 @@ static void test_create_with_reader(TestCase *tc, void *data)
981
792
  Aiequal(1, ir2->num_docs(ir));
982
793
  frt_ir_close(ir);
983
794
  frt_ir_close(ir2);
984
- store->clear_all(store);
795
+ store->clear_all(store, segm_idx_name);
985
796
  frt_store_close(store);
986
797
  frt_doc_destroy(doc);
987
798
  }
@@ -992,8 +803,7 @@ static void test_create_with_reader(TestCase *tc, void *data)
992
803
  * gracefully fallback to the previous segments file),
993
804
  * and that we can add to the index:
994
805
  */
995
- static void test_simulated_crashed_writer(TestCase *tc, void *data)
996
- {
806
+ static void test_simulated_crashed_writer(TestCase *tc, void *data) {
997
807
  int i;
998
808
  long gen;
999
809
  frt_off_t length;
@@ -1025,8 +835,8 @@ static void test_simulated_crashed_writer(TestCase *tc, void *data)
1025
835
  * writing segments file: */
1026
836
  frt_sis_curr_seg_file_name(file_name_in, store);
1027
837
  frt_fn_for_generation(file_name_out, FRT_SEGMENTS_FILE_NAME, NULL, 1 + gen);
1028
- is = store->open_input(store, file_name_in);
1029
- os = store->new_output(store, file_name_out);
838
+ is = store->open_input(store, segm_idx_name, file_name_in);
839
+ os = store->new_output(store, segm_idx_name, file_name_out);
1030
840
  length = frt_is_length(is);
1031
841
  for(i = 0; i < length - 1; i++) {
1032
842
  frt_os_write_byte(os, frt_is_read_byte(is));
@@ -1053,8 +863,7 @@ static void test_simulated_crashed_writer(TestCase *tc, void *data)
1053
863
  * latest segments file and make sure we get an
1054
864
  * IOException trying to open the index:
1055
865
  */
1056
- static void test_simulated_corrupt_index1(TestCase *tc, void *data)
1057
- {
866
+ static void test_simulated_corrupt_index1(TestCase *tc, void *data) {
1058
867
  int i;
1059
868
  long gen;
1060
869
  frt_off_t length;
@@ -1086,15 +895,15 @@ static void test_simulated_corrupt_index1(TestCase *tc, void *data)
1086
895
  * writing segments file: */
1087
896
  frt_sis_curr_seg_file_name(file_name_in, store);
1088
897
  frt_fn_for_generation(file_name_out, FRT_SEGMENTS_FILE_NAME, "", 1 + gen);
1089
- is = store->open_input(store, file_name_in);
1090
- os = store->new_output(store, file_name_out);
898
+ is = store->open_input(store, segm_idx_name, file_name_in);
899
+ os = store->new_output(store, segm_idx_name, file_name_out);
1091
900
  length = frt_is_length(is);
1092
901
  for(i = 0; i < length - 1; i++) {
1093
902
  frt_os_write_byte(os, frt_is_read_byte(is));
1094
903
  }
1095
904
  frt_is_close(is);
1096
905
  frt_os_close(os);
1097
- store->remove(store, file_name_in);
906
+ store->remove(store, segm_idx_name, file_name_in);
1098
907
 
1099
908
  FRT_TRY
1100
909
  ir = frt_ir_open(NULL, store);
@@ -1116,8 +925,7 @@ static void test_simulated_corrupt_index1(TestCase *tc, void *data)
1116
925
  * files and make sure we get an IOException trying to
1117
926
  * open the index:
1118
927
  */
1119
- static void test_simulated_corrupt_index2(TestCase *tc, void *data)
1120
- {
928
+ static void test_simulated_corrupt_index2(TestCase *tc, void *data) {
1121
929
  int i;
1122
930
  long gen;
1123
931
  FrtStore *store = (FrtStore *)data;
@@ -1139,8 +947,8 @@ static void test_simulated_corrupt_index2(TestCase *tc, void *data)
1139
947
  /* segment generation should be > 1 */
1140
948
  Atrue(gen > 1);
1141
949
 
1142
- Atrue(store->exists(store, "_0.fdx"));
1143
- store->remove(store, "_0.fdx");
950
+ Atrue(store->exists(store, segm_idx_name, "_0.fdx"));
951
+ store->remove(store, segm_idx_name, "_0.fdx");
1144
952
 
1145
953
  FRT_TRY
1146
954
  ir = frt_ir_open(NULL, store);
@@ -1156,8 +964,7 @@ static void test_simulated_corrupt_index2(TestCase *tc, void *data)
1156
964
  destroy_docs(docs, BOOK_LIST_LENGTH);
1157
965
  }
1158
966
 
1159
- static void test_iw_add_docs(TestCase *tc, void *data)
1160
- {
967
+ static void test_iw_add_docs(TestCase *tc, void *data) {
1161
968
  int i;
1162
969
  FrtConfig config = frt_default_config;
1163
970
  FrtStore *store = (FrtStore *)data;
@@ -1174,15 +981,14 @@ static void test_iw_add_docs(TestCase *tc, void *data)
1174
981
 
1175
982
  frt_iw_close(iw);
1176
983
  destroy_docs(docs, BOOK_LIST_LENGTH);
1177
- if (!Aiequal(11, store->count(store))) {
1178
- char *buf = frt_store_to_s(store);
984
+ if (!Aiequal(11, store->count(store, segm_idx_name))) {
985
+ char *buf = frt_store_folder_to_s(store, segm_idx_name);
1179
986
  Tmsg("To many files: %s\n", buf);
1180
987
  free(buf);
1181
988
  }
1182
989
  }
1183
990
 
1184
- void test_iw_add_empty_tv(TestCase *tc, void *data)
1185
- {
991
+ void test_iw_add_empty_tv(TestCase *tc, void *data) {
1186
992
  FrtStore *store = (FrtStore *)data;
1187
993
  FrtIndexWriter *iw;
1188
994
  FrtDocument *doc;
@@ -1195,9 +1001,9 @@ void test_iw_add_empty_tv(TestCase *tc, void *data)
1195
1001
 
1196
1002
  iw = frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), &frt_default_config);
1197
1003
  doc = frt_doc_new();
1198
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("tv1")), (char *)"", enc));
1199
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("tv2")), (char *)"", enc));
1200
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("no_tv")), (char *)"one two three", enc));
1004
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("tv1")), "", enc));
1005
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("tv2")), "", enc));
1006
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern("no_tv")), "one two three", enc));
1201
1007
 
1202
1008
  frt_iw_add_doc(iw, doc);
1203
1009
  frt_iw_commit(iw);
@@ -1206,8 +1012,7 @@ void test_iw_add_empty_tv(TestCase *tc, void *data)
1206
1012
  frt_doc_destroy(doc);
1207
1013
  }
1208
1014
 
1209
- static void test_iw_del_terms(TestCase *tc, void *data)
1210
- {
1015
+ static void test_iw_del_terms(TestCase *tc, void *data) {
1211
1016
  int i;
1212
1017
  FrtConfig config = frt_default_config;
1213
1018
  FrtStore *store = (FrtStore *)data;
@@ -1304,8 +1109,7 @@ typedef struct ReaderTestEnvironment {
1304
1109
  int store_cnt;
1305
1110
  } ReaderTestEnvironment;
1306
1111
 
1307
- static void reader_test_env_destroy(ReaderTestEnvironment *rte)
1308
- {
1112
+ static void reader_test_env_destroy(ReaderTestEnvironment *rte) {
1309
1113
  int i;
1310
1114
  for (i = 0; i < rte->store_cnt; i++) {
1311
1115
  frt_store_close(rte->stores[i]);
@@ -1314,12 +1118,10 @@ static void reader_test_env_destroy(ReaderTestEnvironment *rte)
1314
1118
  free(rte);
1315
1119
  }
1316
1120
 
1317
- static FrtIndexReader *reader_test_env_ir_open(ReaderTestEnvironment *rte)
1318
- {
1121
+ static FrtIndexReader *reader_test_env_ir_open(ReaderTestEnvironment *rte) {
1319
1122
  if (rte->store_cnt == 1) {
1320
1123
  return frt_ir_open(NULL, rte->stores[0]);
1321
- }
1322
- else {
1124
+ } else {
1323
1125
  FrtIndexReader **sub_readers = FRT_ALLOC_N(FrtIndexReader *, rte->store_cnt);
1324
1126
  int i;
1325
1127
  for (i = 0; i < rte->store_cnt; i++) {
@@ -1330,8 +1132,7 @@ static FrtIndexReader *reader_test_env_ir_open(ReaderTestEnvironment *rte)
1330
1132
  }
1331
1133
  }
1332
1134
 
1333
- static ReaderTestEnvironment *reader_test_env_new(int type)
1334
- {
1135
+ static ReaderTestEnvironment *reader_test_env_new(int type) {
1335
1136
  int i, j;
1336
1137
  FrtConfig config = frt_default_config;
1337
1138
  FrtIndexWriter *iw;
@@ -1344,6 +1145,7 @@ static ReaderTestEnvironment *reader_test_env_new(int type)
1344
1145
  rte->stores = FRT_ALLOC_N(FrtStore *, store_cnt);
1345
1146
  for (i = 0; i < store_cnt; i++) {
1346
1147
  FrtStore *store = rte->stores[i] = frt_open_ram_store(NULL);
1148
+ store->create_folder(store, segm_idx_name);
1347
1149
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM);
1348
1150
  int start_doc = i * doc_cnt;
1349
1151
  int end_doc = (i + 1) * doc_cnt;
@@ -1361,7 +1163,7 @@ static ReaderTestEnvironment *reader_test_env_new(int type)
1361
1163
  FrtDocument *doc = docs[j];
1362
1164
  /* add fields when needed. This is to make the FrtFieldInfos objects
1363
1165
  * different for multi_external_reader */
1364
- for (k = 0; k < doc->size; k++) {
1166
+ for (k = 0; k < doc->field_count; k++) {
1365
1167
  FrtDocField *df = doc->fields[k];
1366
1168
  fis = iw->fis;
1367
1169
  if (NULL == frt_fis_get_field(fis, df->name)) {
@@ -1374,11 +1176,11 @@ static ReaderTestEnvironment *reader_test_env_new(int type)
1374
1176
  } else if (text == df->name) {
1375
1177
  frt_fis_add_field(fis, frt_fi_new(text, 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1376
1178
  } else if (compressed_field_brotli == df->name) {
1377
- frt_fis_add_field(fis, frt_fi_new(compressed_field_brotli, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1179
+ frt_fis_add_field(fis, frt_fi_new(compressed_field_brotli, 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1378
1180
  } else if (compressed_field_bzip2 == df->name) {
1379
- frt_fis_add_field(fis, frt_fi_new(compressed_field_bzip2, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BZ2_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1181
+ frt_fis_add_field(fis, frt_fi_new(compressed_field_bzip2, 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BZ2_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1380
1182
  } else if (compressed_field_lz4 == df->name) {
1381
- frt_fis_add_field(fis, frt_fi_new(compressed_field_lz4, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_LZ4_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1183
+ frt_fis_add_field(fis, frt_fi_new(compressed_field_lz4, 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_LZ4_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1382
1184
  }
1383
1185
  }
1384
1186
  }
@@ -1391,6 +1193,7 @@ static ReaderTestEnvironment *reader_test_env_new(int type)
1391
1193
  if (type == add_indexes_reader_type) {
1392
1194
  /* Prepare store for Add Indexes test */
1393
1195
  FrtStore *store = frt_open_ram_store(NULL);
1196
+ store->create_folder(store, segm_idx_name);
1394
1197
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_POSITIONS_BM | FRT_FI_STORE_OFFSETS_BM);
1395
1198
  FrtIndexReader **readers = FRT_ALLOC_N(FrtIndexReader *, rte->store_cnt);
1396
1199
  int i;
@@ -1418,8 +1221,7 @@ static ReaderTestEnvironment *reader_test_env_new(int type)
1418
1221
  return rte;
1419
1222
  }
1420
1223
 
1421
- static void write_ir_test_docs(FrtStore *store)
1422
- {
1224
+ static void write_ir_test_docs(FrtStore *store) {
1423
1225
  int i;
1424
1226
  FrtConfig config = frt_default_config;
1425
1227
  FrtIndexWriter *iw;
@@ -1430,9 +1232,9 @@ static void write_ir_test_docs(FrtStore *store)
1430
1232
  frt_fis_add_field(fis, frt_fi_new(title, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_STORE_TERM_VECTOR_BM | FRT_FI_STORE_OFFSETS_BM));
1431
1233
  frt_fis_add_field(fis, frt_fi_new(year, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM));
1432
1234
  frt_fis_add_field(fis, frt_fi_new(text, 0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1433
- frt_fis_add_field(fis, frt_fi_new(compressed_field_brotli, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1434
- frt_fis_add_field(fis, frt_fi_new(compressed_field_bzip2, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_BZ2_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1435
- frt_fis_add_field(fis, frt_fi_new(compressed_field_lz4, 0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_COMPRESSED_BM | FRT_FI_COMPRESSION_LZ4_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1235
+ frt_fis_add_field(fis, frt_fi_new(compressed_field_brotli, 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BROTLI_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1236
+ frt_fis_add_field(fis, frt_fi_new(compressed_field_bzip2, 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_BZ2_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1237
+ frt_fis_add_field(fis, frt_fi_new(compressed_field_lz4, 0 | FRT_FI_IS_STORED_BM | FRT_FI_COMPRESSION_LZ4_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM));
1436
1238
  frt_index_create(store, fis);
1437
1239
  frt_fis_deref(fis);
1438
1240
  config.max_buffered_docs = 5;
@@ -1447,10 +1249,9 @@ static void write_ir_test_docs(FrtStore *store)
1447
1249
  destroy_docs(docs, IR_TEST_DOC_CNT);
1448
1250
  }
1449
1251
 
1450
- static void test_ir_open_empty_index(TestCase *tc, void *data)
1451
- {
1252
+ static void test_ir_open_empty_index(TestCase *tc, void *data) {
1452
1253
  FrtStore *store = (FrtStore *)data;
1453
- store->clear_all(store);
1254
+ store->clear_all(store, segm_idx_name);
1454
1255
  FRT_TRY
1455
1256
  frt_ir_close(frt_ir_open(NULL, store));
1456
1257
  Afail("IndexReader should have failed when opening empty index");
@@ -1464,8 +1265,7 @@ static void test_ir_open_empty_index(TestCase *tc, void *data)
1464
1265
  FRT_XENDTRY
1465
1266
  }
1466
1267
 
1467
- static void test_ir_basic_ops(TestCase *tc, void *data)
1468
- {
1268
+ static void test_ir_basic_ops(TestCase *tc, void *data) {
1469
1269
  FrtIndexReader *ir = (FrtIndexReader *)data;
1470
1270
  Aiequal(IR_TEST_DOC_CNT, ir->num_docs(ir));
1471
1271
  Aiequal(IR_TEST_DOC_CNT, ir->max_doc(ir));
@@ -1474,8 +1274,7 @@ static void test_ir_basic_ops(TestCase *tc, void *data)
1474
1274
  Atrue(frt_ir_is_latest(ir));
1475
1275
  }
1476
1276
 
1477
- static void test_ir_term_docpos_enum_skip_to(TestCase *tc, FrtTermDocEnum *tde, int field_num)
1478
- {
1277
+ static void test_ir_term_docpos_enum_skip_to(TestCase *tc, FrtTermDocEnum *tde, int field_num) {
1479
1278
  /* test skip_to working skip interval */
1480
1279
  tde->seek(tde, field_num, "skip");
1481
1280
 
@@ -1509,8 +1308,7 @@ static void test_ir_term_docpos_enum_skip_to(TestCase *tc, FrtTermDocEnum *tde,
1509
1308
 
1510
1309
  #define AA3(x, a, b, c) x[0] = a; x[1] = b; x[2] = c;
1511
1310
 
1512
- static void test_ir_term_enum(TestCase *tc, void *data)
1513
- {
1311
+ static void test_ir_term_enum(TestCase *tc, void *data) {
1514
1312
  FrtIndexReader *ir = (FrtIndexReader *)data;
1515
1313
  FrtTermEnum *te = frt_ir_terms(ir, author);
1516
1314
 
@@ -1558,8 +1356,7 @@ static void test_ir_term_enum(TestCase *tc, void *data)
1558
1356
  te->close(te);
1559
1357
  }
1560
1358
 
1561
- static void test_ir_term_doc_enum(TestCase *tc, void *data)
1562
- {
1359
+ static void test_ir_term_doc_enum(TestCase *tc, void *data) {
1563
1360
  FrtIndexReader *ir = (FrtIndexReader *)data;
1564
1361
 
1565
1362
  FrtTermDocEnum *tde;
@@ -1674,8 +1471,7 @@ static void test_ir_term_doc_enum(TestCase *tc, void *data)
1674
1471
  tde->close(tde);
1675
1472
  }
1676
1473
 
1677
- static void test_ir_term_vectors(TestCase *tc, void *data)
1678
- {
1474
+ static void test_ir_term_vectors(TestCase *tc, void *data) {
1679
1475
  FrtIndexReader *ir = (FrtIndexReader *)data;
1680
1476
  FrtHash *tvs;
1681
1477
  FrtTermVector *tv = ir->term_vector(ir, 3, rb_intern("body"));
@@ -1754,12 +1550,11 @@ static void test_ir_term_vectors(TestCase *tc, void *data)
1754
1550
  frt_h_destroy(tvs);
1755
1551
  }
1756
1552
 
1757
- static void test_ir_get_doc(TestCase *tc, void *data)
1758
- {
1553
+ static void test_ir_get_doc(TestCase *tc, void *data) {
1759
1554
  FrtIndexReader *ir = (FrtIndexReader *)data;
1760
1555
  FrtDocument *doc = ir->get_doc(ir, 3);
1761
1556
  FrtDocField *df;
1762
- Aiequal(4, doc->size);
1557
+ Aiequal(4, doc->field_count);
1763
1558
 
1764
1559
  df = frt_doc_get_field(doc, author);
1765
1560
  Asequal(rb_id2name(author), rb_id2name(df->name));
@@ -1768,8 +1563,7 @@ static void test_ir_get_doc(TestCase *tc, void *data)
1768
1563
 
1769
1564
  df = frt_doc_get_field(doc, body);
1770
1565
  Asequal(rb_id2name(body), rb_id2name(df->name));
1771
- Asequal("word3 word4 word1 word2 word1 "
1772
- "word3 word4 word1 word3 word3", df->data[0]);
1566
+ Asequal("word3 word4 word1 word2 word1 word3 word4 word1 word3 word3", df->data[0]);
1773
1567
  Afequal(df->boost, 1.0);
1774
1568
  df = frt_doc_get_field(doc, title);
1775
1569
  Asequal(rb_id2name(title), rb_id2name(df->name));
@@ -1787,8 +1581,7 @@ static void test_ir_get_doc(TestCase *tc, void *data)
1787
1581
  frt_doc_destroy(doc);
1788
1582
  }
1789
1583
 
1790
- static void test_ir_compression(TestCase *tc, void *data)
1791
- {
1584
+ static void test_ir_compression(TestCase *tc, void *data) {
1792
1585
  int i;
1793
1586
  FrtIndexReader *ir = (FrtIndexReader *)data;
1794
1587
  FrtLazyDoc *lz_doc;
@@ -1796,7 +1589,7 @@ static void test_ir_compression(TestCase *tc, void *data)
1796
1589
  FrtDocument *doc = ir->get_doc(ir, 0);
1797
1590
  FrtDocField *df1, *df2, *df3, *df4;
1798
1591
  char buf1[20], buf2[20];
1799
- Aiequal(5, doc->size);
1592
+ Aiequal(5, doc->field_count);
1800
1593
 
1801
1594
  df1 = frt_doc_get_field(doc, changing_field);
1802
1595
  df2 = frt_doc_get_field(doc, compressed_field_brotli);
@@ -1865,8 +1658,7 @@ static void test_ir_compression(TestCase *tc, void *data)
1865
1658
  frt_lazy_doc_close(lz_doc);
1866
1659
  }
1867
1660
 
1868
- static void test_ir_mtdpe(TestCase *tc, void *data)
1869
- {
1661
+ static void test_ir_mtdpe(TestCase *tc, void *data) {
1870
1662
  FrtIndexReader *ir = (FrtIndexReader *)data;
1871
1663
  const char *terms[3] = {"Where", "is", "books."};
1872
1664
 
@@ -1886,8 +1678,7 @@ static void test_ir_mtdpe(TestCase *tc, void *data)
1886
1678
  tde->close(tde);
1887
1679
  }
1888
1680
 
1889
- static void test_ir_norms(TestCase *tc, void *data)
1890
- {
1681
+ static void test_ir_norms(TestCase *tc, void *data) {
1891
1682
  int i;
1892
1683
  frt_uchar *norms;
1893
1684
  FrtIndexReader *ir, *ir2;
@@ -1982,10 +1773,10 @@ static void test_ir_norms(TestCase *tc, void *data)
1982
1773
  free(norms);
1983
1774
  }
1984
1775
 
1985
- static void test_ir_delete(TestCase *tc, void *data)
1986
- {
1776
+ static void test_ir_delete(TestCase *tc, void *data) {
1987
1777
  int i;
1988
1778
  FrtStore *store = frt_open_ram_store(NULL);
1779
+ store->create_folder(store, segm_idx_name);
1989
1780
  FrtIndexReader *ir, *ir2;
1990
1781
  FrtIndexWriter *iw;
1991
1782
  int type = *((int *)data);
@@ -2097,8 +1888,7 @@ static void test_ir_delete(TestCase *tc, void *data)
2097
1888
  frt_store_close(store);
2098
1889
  }
2099
1890
 
2100
- static void test_ir_read_while_optimizing(TestCase *tc, void *data)
2101
- {
1891
+ static void test_ir_read_while_optimizing(TestCase *tc, void *data) {
2102
1892
  FrtStore *store = (FrtStore *)data;
2103
1893
  FrtIndexReader *ir;
2104
1894
  FrtIndexWriter *iw;
@@ -2117,8 +1907,7 @@ static void test_ir_read_while_optimizing(TestCase *tc, void *data)
2117
1907
  frt_ir_close(ir);
2118
1908
  }
2119
1909
 
2120
- static void test_ir_multivalue_fields(TestCase *tc, void *data)
2121
- {
1910
+ static void test_ir_multivalue_fields(TestCase *tc, void *data) {
2122
1911
  FrtStore *store = (FrtStore *)data;
2123
1912
  FrtIndexReader *ir;
2124
1913
  FrtFieldInfo *fi;
@@ -2135,13 +1924,13 @@ static void test_ir_multivalue_fields(TestCase *tc, void *data)
2135
1924
  frt_fis_deref(fis);
2136
1925
  iw = frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), NULL);
2137
1926
 
2138
- df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(tag), (char *)"Ruby", enc));
2139
- frt_df_add_data(df, (char *)"C", enc);
2140
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(body), (char *)body_text, enc));
2141
- frt_df_add_data(df, (char *)"Lucene", enc);
2142
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(title), (char *)title_text, enc));
2143
- frt_df_add_data(df, (char *)"Ferret", enc);
2144
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(author), (char *)author_text, enc));
1927
+ df = frt_doc_add_field(doc, frt_df_add_data(frt_df_new(tag), "Ruby", enc));
1928
+ frt_df_add_data(df, "C", enc);
1929
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(body), body_text, enc));
1930
+ frt_df_add_data(df, "Lucene", enc);
1931
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(title), title_text, enc));
1932
+ frt_df_add_data(df, "Ferret", enc);
1933
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(author), author_text, enc));
2145
1934
 
2146
1935
  Aiequal(0, iw->fis->size);
2147
1936
 
@@ -2163,7 +1952,7 @@ static void test_ir_multivalue_fields(TestCase *tc, void *data)
2163
1952
  ir = frt_ir_open(NULL, store);
2164
1953
 
2165
1954
  doc = ir->get_doc(ir, 0);
2166
- Aiequal(4, doc->size);
1955
+ Aiequal(4, doc->field_count);
2167
1956
  df = frt_doc_get_field(doc, tag);
2168
1957
  Aiequal(4, df->size);
2169
1958
  Asequal("Ruby", df->data[0]);
@@ -2193,12 +1982,12 @@ static void test_ir_multivalue_fields(TestCase *tc, void *data)
2193
1982
  * IndexSuite
2194
1983
  *
2195
1984
  ***************************************************************************/
2196
- TestSuite *ts_index(TestSuite *suite)
2197
- {
1985
+ TestSuite *ts_index(TestSuite *suite) {
2198
1986
  FrtIndexReader *ir;
2199
- FrtStore *fs_store, *store = frt_open_ram_store(NULL);
1987
+ FrtStore *fs_store;
2200
1988
  ReaderTestEnvironment *rte = NULL;
2201
- /* FrtStore *store = frt_open_mdbx_store(TEST_DIR); */
1989
+ FrtStore *store = frt_open_mdbx_store(TEST_DIR);
1990
+ store->create_folder(store, segm_idx_name);
2202
1991
 
2203
1992
  /* initialize IDs */
2204
1993
  body = rb_intern("body");
@@ -2312,8 +2101,9 @@ TestSuite *ts_index(TestSuite *suite)
2312
2101
  tst_run_test_with_name(suite, test_ir_read_while_optimizing, store, "test_ir_read_while_optimizing_in_ram");
2313
2102
 
2314
2103
  fs_store = frt_open_mdbx_store(TEST_DIR);
2104
+ fs_store->create_folder(fs_store, segm_idx_name);
2315
2105
  tst_run_test_with_name(suite, test_ir_read_while_optimizing, fs_store, "test_ir_read_while_optimizing_on_disk");
2316
- fs_store->clear_all(fs_store);
2106
+ fs_store->clear_all(fs_store, segm_idx_name);
2317
2107
  frt_store_close(fs_store);
2318
2108
 
2319
2109
  tst_run_test(suite, test_ir_multivalue_fields, store);