isomorfeus-ferret 0.17.2 → 0.17.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) 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 +161 -187
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +77 -69
  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 +5 -33
  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 +14 -33
  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_filter.c +2 -2
  31. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  32. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  33. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  34. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  36. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  37. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  39. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  40. data/ext/isomorfeus_ferret_ext/frt_ind.c +21 -39
  41. data/ext/isomorfeus_ferret_ext/frt_ind.h +1 -1
  42. data/ext/isomorfeus_ferret_ext/frt_index.c +334 -848
  43. data/ext/isomorfeus_ferret_ext/frt_index.h +4 -105
  44. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  47. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  48. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  49. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  50. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  51. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  52. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  53. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  54. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  55. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  56. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  57. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  58. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  59. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +131 -217
  60. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +2 -2
  61. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +4 -4
  62. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +18 -26
  63. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +27 -28
  64. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  65. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +64 -116
  66. data/ext/isomorfeus_ferret_ext/frt_q_range.c +8 -14
  67. data/ext/isomorfeus_ferret_ext/frt_q_span.c +251 -365
  68. data/ext/isomorfeus_ferret_ext/frt_q_term.c +9 -9
  69. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  70. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  71. data/ext/isomorfeus_ferret_ext/frt_search.c +109 -191
  72. data/ext/isomorfeus_ferret_ext/frt_search.h +6 -6
  73. data/ext/isomorfeus_ferret_ext/frt_similarity.c +12 -23
  74. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  75. data/ext/isomorfeus_ferret_ext/frt_sort.c +20 -20
  76. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  77. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  78. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  79. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  80. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  81. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  82. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  83. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  84. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  85. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  86. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  87. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  88. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  89. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  90. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  91. data/ext/isomorfeus_ferret_ext/test.c +41 -88
  92. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  93. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  94. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  95. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  96. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  97. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  98. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  99. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  100. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +16 -25
  101. data/ext/isomorfeus_ferret_ext/test_filter.c +22 -33
  102. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  103. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  104. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  105. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  106. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  107. data/ext/isomorfeus_ferret_ext/test_index.c +307 -519
  108. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  109. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  110. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  111. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  112. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  113. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  114. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  115. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  116. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  117. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  118. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  119. data/ext/isomorfeus_ferret_ext/test_search.c +66 -115
  120. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  121. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  122. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -27
  123. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  124. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  125. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  126. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  127. data/ext/isomorfeus_ferret_ext/test_threading.c +15 -21
  128. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  129. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  130. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  131. data/lib/isomorfeus/ferret/index/index.rb +8 -8
  132. data/lib/isomorfeus/ferret/version.rb +1 -1
  133. metadata +32 -6
@@ -16,14 +16,13 @@ typedef struct SortTestData {
16
16
  const char *flt;
17
17
  } SortTestData;
18
18
 
19
- static void add_sort_test_data(SortTestData *std, FrtIndexWriter *iw)
20
- {
19
+ static void add_sort_test_data(SortTestData *std, FrtIndexWriter *iw) {
21
20
  FrtDocument *doc = frt_doc_new();
22
21
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
23
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(search), (char *)std->search, enc));
24
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(string), (char *)std->string, enc));
25
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(integer), (char *)std->integer, enc));
26
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flt), (char *)std->flt, enc));
22
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(search), std->search, enc));
23
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(string), std->string, enc));
24
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(integer), std->integer, enc));
25
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flt), std->flt, enc));
27
26
 
28
27
  sscanf(std->flt, "%f", &doc->boost);
29
28
 
@@ -44,8 +43,7 @@ static SortTestData data[] = { /* len mod */
44
43
  {"findall","b","4","0.000001"} /* 8 0 */
45
44
  };
46
45
 
47
- static void sort_test_setup(FrtStore *store)
48
- {
46
+ static void sort_test_setup(FrtStore *store) {
49
47
  int i;
50
48
  FrtIndexWriter *iw;
51
49
  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);
@@ -60,8 +58,7 @@ static void sort_test_setup(FrtStore *store)
60
58
  frt_iw_close(iw);
61
59
  }
62
60
 
63
- static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2)
64
- {
61
+ static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2) {
65
62
  int i;
66
63
  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);
67
64
  FrtIndexWriter *iw;
@@ -87,8 +84,7 @@ static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2)
87
84
 
88
85
  #define R_START 3
89
86
  #define R_END 6
90
- static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const char *expected_hits, FrtSort *sort)
91
- {
87
+ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const char *expected_hits, FrtSort *sort) {
92
88
  static int num_array[ARRAY_SIZE];
93
89
  int i;
94
90
  int total_hits = s2l(expected_hits, num_array);
@@ -101,7 +97,7 @@ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *quer
101
97
  if (false && sort && searcher->doc_freq != frt_isea_doc_freq) {
102
98
  FrtFieldDoc *fd = (FrtFieldDoc *)hit;
103
99
  int j;
104
- printf("%d == %d:%f ", num_array[i], hit->doc, hit->score);
100
+ printf("%d == %d:%f ", num_array[i], hit->doc_num, hit->score);
105
101
  for (j = 0; j < fd->size; j++) {
106
102
  switch (fd->comparables[j].type) {
107
103
  case FRT_SORT_TYPE_SCORE:
@@ -120,7 +116,7 @@ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *quer
120
116
  }
121
117
  printf("\n");
122
118
  }
123
- Aiequal(num_array[i], hit->doc);
119
+ Aiequal(num_array[i], hit->doc_num);
124
120
  }
125
121
  frt_td_destroy(top_docs);
126
122
 
@@ -128,7 +124,7 @@ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *quer
128
124
  top_docs = frt_searcher_search(searcher, query, R_START, R_END - R_START, NULL, sort, NULL);
129
125
  for (i = R_START; i < R_END; i++) {
130
126
  FrtHit *hit = top_docs->hits[i - R_START];
131
- Aiequal(num_array[i], hit->doc);
127
+ Aiequal(num_array[i], hit->doc_num);
132
128
  /*
133
129
  printf("%d == %d\n", num_array[i], hit->doc);
134
130
  */
@@ -147,8 +143,7 @@ static void do_test_top_docs(TestCase *tc, FrtSearcher *searcher, FrtQuery *quer
147
143
  } while (0)
148
144
 
149
145
 
150
- static void test_sort_field_to_s(TestCase *tc, void *data)
151
- {
146
+ static void test_sort_field_to_s(TestCase *tc, void *data) {
152
147
  (void)data;
153
148
  TEST_SF_TO_S("<SCORE>", frt_sort_field_score_new(false));
154
149
  TEST_SF_TO_S("<SCORE>!", frt_sort_field_score_new(true));
@@ -171,8 +166,7 @@ static void test_sort_field_to_s(TestCase *tc, void *data)
171
166
  free(_str);\
172
167
  } while (0)
173
168
 
174
- static void test_sort_to_s(TestCase *tc, void *data)
175
- {
169
+ static void test_sort_to_s(TestCase *tc, void *data) {
176
170
  FrtSort *sort = frt_sort_new();
177
171
  (void)data;
178
172
 
@@ -198,8 +192,7 @@ static void test_sort_to_s(TestCase *tc, void *data)
198
192
  }
199
193
 
200
194
  static bool do_byte_test = true;
201
- static void test_sorts(TestCase *tc, void *data)
202
- {
195
+ static void test_sorts(TestCase *tc, void *data) {
203
196
  FrtSearcher *sea = (FrtSearcher *)data;
204
197
  FrtQuery *q;
205
198
  FrtSort *sort = NULL;
@@ -288,10 +281,10 @@ static void test_sorts(TestCase *tc, void *data)
288
281
  frt_q_deref(q);
289
282
  }
290
283
 
291
- TestSuite *ts_sort(TestSuite *suite)
292
- {
284
+ TestSuite *ts_sort(TestSuite *suite) {
293
285
  FrtSearcher *sea, **searchers;
294
286
  FrtStore *store = frt_open_ram_store(NULL), *fs_store;
287
+ store->create_folder(store, segm_idx_name);
295
288
  FrtIndexReader *ir0;
296
289
  FrtIndexReader *ir1;
297
290
 
@@ -317,11 +310,8 @@ TestSuite *ts_sort(TestSuite *suite)
317
310
 
318
311
  do_byte_test = false;
319
312
 
320
- #if defined POSH_OS_WIN32 || defined POSH_OS_WIN64
321
- fs_store = frt_open_mdbx_store(".\\test\\testdir\\store");
322
- #else
323
313
  fs_store = frt_open_mdbx_store("./test/testdir/store");
324
- #endif
314
+
325
315
  sort_multi_test_setup(store, fs_store);
326
316
 
327
317
  searchers = FRT_ALLOC_N(FrtSearcher *, 2);
@@ -24,11 +24,10 @@ static void with_lock_test(void *p) {
24
24
  Assert(l->lock->is_locked(l->lock), "lock should be locked");
25
25
  }
26
26
 
27
- static void with_lock_name_test(void *p)
28
- {
27
+ static void with_lock_name_test(void *p) {
29
28
  WithLockNameTestArg *l = (WithLockNameTestArg *)p;
30
29
  TestCase *tc = l->tc;
31
- FrtLock *lock = frt_open_lock(l->store, l->lock_name);
30
+ FrtLock *lock = frt_open_lock(l->store, segm_idx_name, l->lock_name);
32
31
  Assert(lock->is_locked(lock), "lock should be locked");
33
32
  frt_close_lock(lock);
34
33
  }
@@ -36,22 +35,21 @@ static void with_lock_name_test(void *p)
36
35
  /**
37
36
  * Test that the lock is created and deleted correctly
38
37
  */
39
- static void test_lock(TestCase *tc, void *data)
40
- {
38
+ static void test_lock(TestCase *tc, void *data) {
41
39
  FrtStore *store = (FrtStore *)data;
42
40
  FrtLock *lock, *lock1, *lock2;
43
41
  bool handled;
44
42
  WithLockTestArg wlta;
45
43
  WithLockNameTestArg wlnta;
46
44
 
47
- lock1 = frt_open_lock(store, TEST_LOCK_NAME);
45
+ lock1 = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
48
46
  Aiequal(false, lock1->is_locked(lock1));
49
47
  Aiequal(true, lock1->obtain(lock1));
50
48
  Aiequal(true, lock1->is_locked(lock1));
51
49
  lock1->release(lock1);
52
50
  Aiequal(false, lock1->is_locked(lock1));
53
51
  Aiequal(true, lock1->obtain(lock1));
54
- lock2 = frt_open_lock(store, TEST_LOCK_NAME);
52
+ lock2 = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
55
53
  Aiequal(true, lock2->is_locked(lock2));
56
54
  lock1->release(lock1);
57
55
  Aiequal(false, lock2->is_locked(lock2));
@@ -59,7 +57,7 @@ static void test_lock(TestCase *tc, void *data)
59
57
  frt_close_lock(lock2);
60
58
 
61
59
  /* test with_lock */
62
- lock = frt_open_lock(store, TEST_LOCK_NAME);
60
+ lock = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
63
61
  Assert(!lock->is_locked(lock), "lock shouldn't be locked yet");
64
62
  wlta.lock = lock; wlta.tc = tc;
65
63
  frt_with_lock(lock, &with_lock_test, &wlta);
@@ -85,15 +83,15 @@ static void test_lock(TestCase *tc, void *data)
85
83
  frt_close_lock(lock);
86
84
 
87
85
  /* test with_lock_name */
88
- lock = frt_open_lock(store, TEST_LOCK_NAME);
86
+ lock = frt_open_lock(store, segm_idx_name, TEST_LOCK_NAME);
89
87
  Assert(!lock->is_locked(lock), "lock shouldn't be locked yet");
90
88
  wlnta.lock_name = TEST_LOCK_NAME; wlnta.tc = tc; wlnta.store = store;
91
- frt_with_lock_name(store, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
89
+ frt_with_lock_name(store, segm_idx_name, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
92
90
  Assert(!lock->is_locked(lock), "lock should be unlocked again");
93
91
  Assert(lock->obtain(lock), "lock should be obtainable");
94
92
  handled = false;
95
93
  FRT_TRY
96
- frt_with_lock_name(store, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
94
+ frt_with_lock_name(store, segm_idx_name, TEST_LOCK_NAME, &with_lock_name_test, &wlnta);
97
95
  Assert(false, "A locking exception should have been raised");
98
96
  break;
99
97
  case FRT_LOCK_ERROR:
@@ -117,32 +115,31 @@ static void test_lock(TestCase *tc, void *data)
117
115
  static void test_basic_file_ops(TestCase *tc, void *data) {
118
116
  FrtStore *store = (FrtStore *)data;
119
117
 
120
- store->clear_all(store); /* Make sure the test directory is empty. */
121
- Assert(!store->exists(store, "_1.f1"), "File1 should not been created yet");
122
- store->touch(store, "_1.f1");
123
- Aiequal(1, store->count(store));
124
- Assert(store->count(store) == 1, "The store now contains one file");
125
- Assert(store->exists(store, "_1.f1"), "File1 should now been created");
126
- store->touch(store, "_1.f2");
127
- Assert(store->count(store) == 2, "The store now contains two files");
128
- Assert(store->exists(store, "_1.f2"), "File2 should now been created");
129
- store->remove(store, "_1.f1");
130
- Assert(store->count(store) == 1, "The store now contains one file");
131
- Assert(!store->exists(store, "_1.f1"), "File1 should have been removed");
132
- Assert(store->exists(store, "_1.f2"), "File2 should still exist");
118
+ store->clear_all(store, segm_idx_name); /* Make sure the test directory is empty. */
119
+ Assert(!store->exists(store, segm_idx_name, "_1.f1"), "File1 should not been created yet");
120
+ store->touch(store, segm_idx_name, "_1.f1");
121
+ Aiequal(1, store->count(store, segm_idx_name));
122
+ Assert(store->count(store, segm_idx_name) == 1, "The store now contains one file");
123
+ Assert(store->exists(store, segm_idx_name, "_1.f1"), "File1 should now been created");
124
+ store->touch(store, segm_idx_name, "_1.f2");
125
+ Assert(store->count(store, segm_idx_name) == 2, "The store now contains two files");
126
+ Assert(store->exists(store, segm_idx_name, "_1.f2"), "File2 should now been created");
127
+ store->remove(store, segm_idx_name, "_1.f1");
128
+ Assert(store->count(store, segm_idx_name) == 1, "The store now contains one file");
129
+ Assert(!store->exists(store, segm_idx_name, "_1.f1"), "File1 should have been removed");
130
+ Assert(store->exists(store, segm_idx_name, "_1.f2"), "File2 should still exist");
133
131
 
134
132
  /* test that lock files get deleted by clear_all */
135
- store->touch(store, "ferret-write.lck");
136
- Assert(store->exists(store, "ferret-write.lck"),"lock should still exist");
137
- store->clear_all(store);
138
- Assert(!store->exists(store, "ferret-write.lck"), "lock should be deleted");
133
+ store->touch(store, segm_idx_name, "ferret-write.lck");
134
+ Assert(store->exists(store, segm_idx_name, "ferret-write.lck"),"lock should still exist");
135
+ store->clear_all(store, segm_idx_name);
136
+ Assert(!store->exists(store, segm_idx_name, "ferret-write.lck"), "lock should be deleted");
139
137
  }
140
138
 
141
139
  /**
142
140
  * Test argument used to test the store->each function
143
141
  */
144
- struct EachArg
145
- {
142
+ struct EachArg {
146
143
  char str[100];
147
144
  char *p;
148
145
  };
@@ -150,8 +147,7 @@ struct EachArg
150
147
  /**
151
148
  * Test function used to test store->each function
152
149
  */
153
- static void concat_filenames(const char *fname, struct EachArg *ea)
154
- {
150
+ static void concat_filenames(const char *fname, struct EachArg *ea) {
155
151
  strcpy(ea->p, fname);
156
152
  ea->p += strlen(fname);
157
153
  }
@@ -159,19 +155,18 @@ static void concat_filenames(const char *fname, struct EachArg *ea)
159
155
  /**
160
156
  * Test the store->each function
161
157
  */
162
- static void test_each(TestCase *tc, void *data)
163
- {
158
+ static void test_each(TestCase *tc, void *data) {
164
159
  FrtStore *store = (FrtStore *)data;
165
160
 
166
161
  struct EachArg ea;
167
162
  ea.p = ea.str;
168
163
 
169
- store->clear_all(store); /* Make sure the test directory is empty. */
170
- store->touch(store, "_1.f1");
171
- store->touch(store, "_1.f2");
172
- store->touch(store, "_1.f3");
173
- store->touch(store, "_1.f4");
174
- store->each(store, (void(*)(const char *fname, void *arg))&concat_filenames, &ea);
164
+ store->clear_all(store, segm_idx_name); /* Make sure the test directory is empty. */
165
+ store->touch(store, segm_idx_name, "_1.f1");
166
+ store->touch(store, segm_idx_name, "_1.f2");
167
+ store->touch(store, segm_idx_name, "_1.f3");
168
+ store->touch(store, segm_idx_name, "_1.f4");
169
+ store->each(store, segm_idx_name, (void(*)(const char *fname, void *arg))&concat_filenames, &ea);
175
170
  *(ea.p) = 0;
176
171
  Assert(strstr(ea.str, "_1.f1") != NULL, "should contain this file");
177
172
  Assert(strstr(ea.str, "_1.f2") != NULL, "should contain this file");
@@ -183,54 +178,52 @@ static void test_each(TestCase *tc, void *data)
183
178
  /**
184
179
  * Test the store->rename function
185
180
  */
186
- static void test_rename(TestCase *tc, void *data)
187
- {
181
+ static void test_rename(TestCase *tc, void *data) {
188
182
  int cnt_before, cnt_after;
189
183
  FrtStore *store = (FrtStore *)data;
190
- store->touch(store, "_from.f1");
191
- Assert(store->exists(store, "_from.f1"), "File should exist");
192
- Assert(!store->exists(store, "_to.f1"), "File should not exist");
193
- cnt_before = store->count(store);
194
- store->rename(store, "_from.f1", "_to.f1");
195
- cnt_after = store->count(store);
184
+ store->touch(store, segm_idx_name, "_from.f1");
185
+ Assert(store->exists(store, segm_idx_name, "_from.f1"), "File should exist");
186
+ Assert(!store->exists(store, segm_idx_name, "_to.f1"), "File should not exist");
187
+ cnt_before = store->count(store, segm_idx_name);
188
+ store->rename(store, segm_idx_name, "_from.f1", "_to.f1");
189
+ cnt_after = store->count(store, segm_idx_name);
196
190
  Aiequal(cnt_before, cnt_after);
197
- Assert(store->exists(store, "_to.f1"), "File should now exist");
198
- Assert(!store->exists(store, "_from.f1"), "File should no longer exist");
191
+ Assert(store->exists(store, segm_idx_name, "_to.f1"), "File should now exist");
192
+ Assert(!store->exists(store, segm_idx_name, "_from.f1"), "File should no longer exist");
199
193
  }
200
194
 
201
195
  /**
202
196
  * Test the reading and writing of bytes (8 bit)
203
197
  */
204
- static void test_rw_bytes(TestCase *tc, void *data)
205
- {
198
+ static void test_rw_bytes(TestCase *tc, void *data) {
206
199
  int i;
207
200
  FrtStore *store = (FrtStore *)data;
208
201
  frt_uchar bytes[6] = { 0x34, 0x87, 0xF9, 0xEA, 0x00, 0xFF };
209
- FrtOutStream *ostream = store->new_output(store, "_rw_byte.cfs");
202
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_byte.fdt");
210
203
  FrtInStream *istream;
211
- Assert(store->exists(store, "_rw_byte.cfs"), "File should now exist");
204
+
212
205
  for (i = 0; i < 6; i++) {
213
206
  frt_os_write_byte(ostream, bytes[i]);
214
207
  }
215
208
  frt_os_close(ostream);
209
+ Assert(store->exists(store, segm_idx_name, "_rw_byte.fdt"), "File should now exist");
216
210
 
217
- istream = store->open_input(store, "_rw_byte.cfs");
211
+ istream = store->open_input(store, segm_idx_name, "_rw_byte.fdt");
218
212
  for (i = 0; i < 6; i++) {
219
213
  Aiequal(bytes[i], frt_is_read_byte(istream));
220
214
  }
221
215
  frt_is_close(istream);
222
- Aiequal(6, store->length(store, "_rw_byte.cfs"));
223
- Assert(store->exists(store, "_rw_byte.cfs"), "File should now exist");
216
+ Aiequal(6, store->length(store, segm_idx_name, "_rw_byte.fdt"));
217
+ Assert(store->exists(store, segm_idx_name, "_rw_byte.fdt"), "File should now exist");
224
218
  }
225
219
 
226
220
  /**
227
221
  * Test the reading and writing of 32-bit integers
228
222
  */
229
- static void test_rw_i32(TestCase *tc, void *data)
230
- {
223
+ static void test_rw_i32(TestCase *tc, void *data) {
231
224
  int i;
232
225
  FrtStore *store = (FrtStore *)data;
233
- FrtOutStream *ostream = store->new_output(store, "_rw_int.cfs");
226
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_int.fdt");
234
227
  FrtInStream *istream;
235
228
  frt_i32 ints[4] = { POSH_I32_MAX, POSH_I32_MIN, -1, 0 };
236
229
 
@@ -239,25 +232,24 @@ static void test_rw_i32(TestCase *tc, void *data)
239
232
  }
240
233
  frt_os_close(ostream);
241
234
 
242
- istream = store->open_input(store, "_rw_int.cfs");
235
+ istream = store->open_input(store, segm_idx_name, "_rw_int.fdt");
243
236
  for (i = 0; i < 4; i++) {
244
237
  Aiequal(ints[i], frt_is_read_i32(istream));
245
238
  }
246
239
 
247
240
  frt_is_close(istream);
248
- Aiequal(16, store->length(store, "_rw_int.cfs"));
241
+ Aiequal(16, store->length(store, segm_idx_name, "_rw_int.fdt"));
249
242
  }
250
243
 
251
244
  /**
252
245
  * Test the reading and writing of 64-bit integers
253
246
  */
254
- static void test_rw_i64(TestCase *tc, void *data)
255
- {
247
+ static void test_rw_i64(TestCase *tc, void *data) {
256
248
  int i;
257
249
  FrtStore *store = (FrtStore *)data;
258
250
  frt_u64 longs[4] =
259
251
  { POSH_I64_MIN, POSH_I64_MAX, POSH_I64(-1), POSH_I64(0) };
260
- FrtOutStream *ostream = store->new_output(store, "_rw_long.cfs");
252
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_long.fdt");
261
253
  FrtInStream *istream;
262
254
 
263
255
  for (i = 0; i < 4; i++) {
@@ -265,23 +257,22 @@ static void test_rw_i64(TestCase *tc, void *data)
265
257
  }
266
258
  frt_os_close(ostream);
267
259
 
268
- istream = store->open_input(store, "_rw_long.cfs");
260
+ istream = store->open_input(store, segm_idx_name, "_rw_long.fdt");
269
261
  for (i = 0; i < 4; i++) {
270
262
  Aiequal(longs[i], frt_is_read_i64(istream));
271
263
  }
272
264
  frt_is_close(istream);
273
- Aiequal(32, store->length(store, "_rw_long.cfs"));
265
+ Aiequal(32, store->length(store, segm_idx_name, "_rw_long.fdt"));
274
266
  }
275
267
 
276
268
  /**
277
269
  * Test the reading and writing of 32-bit unsigned integers
278
270
  */
279
- static void test_rw_u32(TestCase *tc, void *data)
280
- {
271
+ static void test_rw_u32(TestCase *tc, void *data) {
281
272
  int i;
282
273
  FrtStore *store = (FrtStore *)data;
283
274
  frt_u32 uints[4] = { POSH_U32_MAX, POSH_U32_MIN, 100000, 1 };
284
- FrtOutStream *ostream = store->new_output(store, "_rw_uint.cfs");
275
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_uint.fdt");
285
276
  FrtInStream *istream;
286
277
 
287
278
  for (i = 0; i < 4; i++) {
@@ -289,24 +280,23 @@ static void test_rw_u32(TestCase *tc, void *data)
289
280
  }
290
281
  frt_os_close(ostream);
291
282
 
292
- istream = store->open_input(store, "_rw_uint.cfs");
283
+ istream = store->open_input(store, segm_idx_name, "_rw_uint.fdt");
293
284
  for (i = 0; i < 4; i++) {
294
285
  Aiequal(uints[i], frt_is_read_u32(istream));
295
286
  }
296
287
  frt_is_close(istream);
297
- Aiequal(16, store->length(store, "_rw_uint.cfs"));
288
+ Aiequal(16, store->length(store, segm_idx_name, "_rw_uint.fdt"));
298
289
  }
299
290
 
300
291
  /**
301
292
  * Test the reading and writing of 64-bit unsigned integers
302
293
  */
303
- static void test_rw_u64(TestCase *tc, void *data)
304
- {
294
+ static void test_rw_u64(TestCase *tc, void *data) {
305
295
  int i;
306
296
  FrtStore *store = (FrtStore *)data;
307
297
  frt_u64 ulongs[4] =
308
298
  { POSH_U64_MAX, POSH_U64_MIN, POSH_U64(100000000000000), POSH_U64(1) };
309
- FrtOutStream *ostream = store->new_output(store, "_rw_ulong.cfs");
299
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_ulong.fdt");
310
300
  FrtInStream *istream;
311
301
 
312
302
  for (i = 0; i < 4; i++) {
@@ -314,23 +304,22 @@ static void test_rw_u64(TestCase *tc, void *data)
314
304
  }
315
305
  frt_os_close(ostream);
316
306
 
317
- istream = store->open_input(store, "_rw_ulong.cfs");
307
+ istream = store->open_input(store, segm_idx_name, "_rw_ulong.fdt");
318
308
  for (i = 0; i < 4; i++) {
319
309
  Aiequal(ulongs[i], frt_is_read_u64(istream));
320
310
  }
321
311
  frt_is_close(istream);
322
- Aiequal(32, store->length(store, "_rw_ulong.cfs"));
312
+ Aiequal(32, store->length(store, segm_idx_name, "_rw_ulong.fdt"));
323
313
  }
324
314
 
325
315
  /**
326
316
  * Test reading and writing of variable size integers
327
317
  */
328
- static void test_rw_vints(TestCase *tc, void *data)
329
- {
318
+ static void test_rw_vints(TestCase *tc, void *data) {
330
319
  int i;
331
320
  FrtStore *store = (FrtStore *)data;
332
321
  unsigned int vints[4] = { UINT_MAX, 0, 10000, 1 };
333
- FrtOutStream *ostream = store->new_output(store, "_rw_vint.cfs");
322
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_vint.fdt");
334
323
  FrtInStream *istream;
335
324
 
336
325
  for (i = 0; i < 4; i++) {
@@ -338,7 +327,7 @@ static void test_rw_vints(TestCase *tc, void *data)
338
327
  }
339
328
  frt_os_close(ostream);
340
329
 
341
- istream = store->open_input(store, "_rw_vint.cfs");
330
+ istream = store->open_input(store, segm_idx_name, "_rw_vint.fdt");
342
331
  for (i = 0; i < 4; i++) {
343
332
  Aiequal(vints[i], frt_is_read_vint(istream));
344
333
  }
@@ -348,12 +337,11 @@ static void test_rw_vints(TestCase *tc, void *data)
348
337
  /**
349
338
  * Test reading and writing of variable size integers
350
339
  */
351
- static void test_rw_vlls(TestCase *tc, void *data)
352
- {
340
+ static void test_rw_vlls(TestCase *tc, void *data) {
353
341
  int i;
354
342
  FrtStore *store = (FrtStore *)data;
355
343
  unsigned long long vlls[4] = { ULLONG_MAX, 0, 10000, 1 };
356
- FrtOutStream *ostream = store->new_output(store, "_rw_vll.cfs");
344
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_vll.fdt");
357
345
  FrtInStream *istream;
358
346
 
359
347
  for (i = 0; i < 4; i++) {
@@ -361,7 +349,7 @@ static void test_rw_vlls(TestCase *tc, void *data)
361
349
  }
362
350
  frt_os_close(ostream);
363
351
 
364
- istream = store->open_input(store, "_rw_vll.cfs");
352
+ istream = store->open_input(store, segm_idx_name, "_rw_vll.fdt");
365
353
  for (i = 0; i < 4; i++) {
366
354
  Aiequal(vlls[i], frt_is_read_vll(istream));
367
355
  }
@@ -371,8 +359,7 @@ static void test_rw_vlls(TestCase *tc, void *data)
371
359
  /**
372
360
  * Test reading and writing of variable size 64-bit integers
373
361
  */
374
- static void test_rw_voff_ts(TestCase *tc, void *data)
375
- {
362
+ static void test_rw_voff_ts(TestCase *tc, void *data) {
376
363
  int i;
377
364
  FrtStore *store = (FrtStore *)data;
378
365
  FrtOutStream *ostream;
@@ -381,18 +368,17 @@ static void test_rw_voff_ts(TestCase *tc, void *data)
381
368
  { LONG_MAX, 0, 1000000, 1 };
382
369
  if (sizeof(off_t) == 8) {
383
370
  voff_ts[0] = POSH_I64_MAX;
384
- }
385
- else {
371
+ } else {
386
372
  voff_ts[0] = POSH_I32_MAX;
387
373
  }
388
- ostream = store->new_output(store, "_rw_voff_t.cfs");
374
+ ostream = store->new_output(store, segm_idx_name, "_rw_voff_t.fdt");
389
375
 
390
376
  for (i = 0; i < 4; i++) {
391
377
  frt_os_write_voff_t(ostream, (off_t)voff_ts[i]);
392
378
  }
393
379
  frt_os_close(ostream);
394
380
 
395
- istream = store->open_input(store, "_rw_voff_t.cfs");
381
+ istream = store->open_input(store, segm_idx_name, "_rw_voff_t.fdt");
396
382
  for (i = 0; i < 4; i++) {
397
383
  Aiequal(voff_ts[i], frt_is_read_voff_t(istream));
398
384
  }
@@ -402,8 +388,7 @@ static void test_rw_voff_ts(TestCase *tc, void *data)
402
388
  /**
403
389
  * Test reading and writing of strings
404
390
  */
405
- static void test_rw_strings(TestCase *tc, void *data)
406
- {
391
+ static void test_rw_strings(TestCase *tc, void *data) {
407
392
  int i;
408
393
  char *tmp;
409
394
  FrtStore *store = (FrtStore *)data;
@@ -417,12 +402,12 @@ static void test_rw_strings(TestCase *tc, void *data)
417
402
  strcat(buf, str);
418
403
  }
419
404
 
420
- ostream = store->new_output(store, "_rw_string.cfs");
405
+ ostream = store->new_output(store, segm_idx_name, "_rw_string.fdt");
421
406
  frt_os_write_string(ostream, str);
422
407
  frt_os_write_string(ostream, buf);
423
408
  frt_os_close(ostream);
424
409
 
425
- istream = store->open_input(store, "_rw_string.cfs");
410
+ istream = store->open_input(store, segm_idx_name, "_rw_string.fdt");
426
411
 
427
412
  tmp = frt_is_read_string(istream);
428
413
  Asequal(str, tmp);
@@ -431,14 +416,13 @@ static void test_rw_strings(TestCase *tc, void *data)
431
416
  Asequal(buf, tmp);
432
417
  free(tmp);
433
418
  frt_is_close(istream);
434
- Aiequal(59063, store->length(store, "_rw_string.cfs"));
419
+ Aiequal(59063, store->length(store, segm_idx_name, "_rw_string.fdt"));
435
420
  }
436
421
 
437
422
  /**
438
423
  * Test reading and writing of non-ascii characters
439
424
  */
440
- static void test_rw_funny_strings(TestCase *tc, void *data)
441
- {
425
+ static void test_rw_funny_strings(TestCase *tc, void *data) {
442
426
  int i;
443
427
  char *tmp;
444
428
  FrtStore *store = (FrtStore *)data;
@@ -451,12 +435,12 @@ static void test_rw_funny_strings(TestCase *tc, void *data)
451
435
  strcat(buf, str);
452
436
  }
453
437
 
454
- ostream = store->new_output(store, "_funny_string.cfs");
438
+ ostream = store->new_output(store, segm_idx_name, "_funny_string.fdt");
455
439
  frt_os_write_string(ostream, str);
456
440
  frt_os_write_string(ostream, buf);
457
441
  frt_os_close(ostream);
458
442
 
459
- istream = store->open_input(store, "_funny_string.cfs");
443
+ istream = store->open_input(store, segm_idx_name, "_funny_string.fdt");
460
444
  tmp = frt_is_read_string(istream);
461
445
  Asequal(str, tmp);
462
446
  free(tmp);
@@ -464,19 +448,18 @@ static void test_rw_funny_strings(TestCase *tc, void *data)
464
448
  Asequal(buf, tmp);
465
449
  free(tmp);
466
450
  frt_is_close(istream);
467
- Aiequal(17021, store->length(store, "_funny_string.cfs"));
451
+ Aiequal(17021, store->length(store, segm_idx_name, "_funny_string.fdt"));
468
452
  }
469
453
 
470
454
  /**
471
455
  * Test seek in both input stream and output stream, ie test the frt_os_seek and
472
456
  * frt_is_seek functions
473
457
  */
474
- static void test_buffer_seek(TestCase *tc, void *data)
475
- {
458
+ static void test_buffer_seek(TestCase *tc, void *data) {
476
459
  int i;
477
460
  FrtStore *store = (FrtStore *)data;
478
461
 
479
- FrtOutStream *ostream = store->new_output(store, "_rw_seek.cfs");
462
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_rw_seek.fdt");
480
463
  char text[60] = "This is another int test string !@#$%#$%&%$*%^&*()(_";
481
464
  FrtInStream *istream;
482
465
 
@@ -495,7 +478,7 @@ static void test_buffer_seek(TestCase *tc, void *data)
495
478
  frt_os_write_voff_t(ostream, 98763210);
496
479
  frt_os_close(ostream);
497
480
 
498
- istream = store->open_input(store, "_rw_seek.cfs");
481
+ istream = store->open_input(store, segm_idx_name, "_rw_seek.fdt");
499
482
  frt_is_seek(istream, 56);
500
483
  Aiequal(56, frt_is_pos(istream));
501
484
  Aiequal(12345, frt_is_read_vint(istream));
@@ -511,18 +494,17 @@ static void test_buffer_seek(TestCase *tc, void *data)
511
494
  /**
512
495
  * Test cloning of InputStream
513
496
  */
514
- static void test_is_clone(TestCase *tc, void *data)
515
- {
497
+ static void test_is_clone(TestCase *tc, void *data) {
516
498
  int i;
517
499
  FrtStore *store = (FrtStore *)data;
518
- FrtOutStream *ostream = store->new_output(store, "_clone.cfs");
500
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_clone.fdt");
519
501
  FrtInStream *istream, *alt_istream;
520
502
 
521
503
  for (i = 0; i < 10; i++) {
522
504
  frt_os_write_i64(ostream, i);
523
505
  }
524
506
  frt_os_close(ostream);
525
- istream = store->open_input(store, "_clone.cfs");
507
+ istream = store->open_input(store, segm_idx_name, "_clone.fdt");
526
508
  frt_is_seek(istream, 24);
527
509
  alt_istream = frt_is_clone(istream);
528
510
  Aiequal(frt_is_pos(istream), frt_is_pos(alt_istream));
@@ -542,16 +524,15 @@ static void test_is_clone(TestCase *tc, void *data)
542
524
  * Test the read_bytes method. This method reads a number of bytes into a
543
525
  * buffer.
544
526
  */
545
- static void test_read_bytes(TestCase *tc, void *data)
546
- {
527
+ static void test_read_bytes(TestCase *tc, void *data) {
547
528
  char str[11] = "0000000000";
548
529
  FrtStore *store = (FrtStore *)data;
549
- FrtOutStream *ostream = store->new_output(store, "_read_bytes.cfs");
530
+ FrtOutStream *ostream = store->new_output(store, segm_idx_name, "_read_bytes.fdt");
550
531
  FrtInStream *istream;
551
532
 
552
533
  frt_os_write_bytes(ostream, (frt_uchar *)"how are you doing?", 18);
553
534
  frt_os_close(ostream);
554
- istream = store->open_input(store, "_read_bytes.cfs");
535
+ istream = store->open_input(store, segm_idx_name, "_read_bytes.fdt");
555
536
  frt_is_read_bytes(istream, (frt_uchar *)(str + 2), 4);
556
537
  Asequal("00how 0000", str);
557
538
  frt_is_read_bytes(istream, (frt_uchar *)(str + 1), 8);
@@ -565,7 +546,7 @@ static void test_read_bytes(TestCase *tc, void *data)
565
546
  * store that you might want to create.
566
547
  */
567
548
  void create_test_store_suite(TestSuite *suite, FrtStore *store) {
568
- store->clear_all(store);
549
+ store->clear_all(store, segm_idx_name);
569
550
 
570
551
  tst_run_test(suite, test_basic_file_ops, store);
571
552
  tst_run_test(suite, test_rename, store);
@@ -585,5 +566,5 @@ void create_test_store_suite(TestSuite *suite, FrtStore *store) {
585
566
  tst_run_test(suite, test_read_bytes, store);
586
567
  tst_run_test(suite, test_lock, store);
587
568
 
588
- store->clear_all(store);
569
+ store->clear_all(store, segm_idx_name);
589
570
  }