isomorfeus-ferret 0.12.5 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +101 -19
- data/README.md +54 -4
- data/ext/isomorfeus_ferret_ext/bm_bitvector.c +22 -30
- data/ext/isomorfeus_ferret_ext/bm_hash.c +6 -12
- data/ext/isomorfeus_ferret_ext/bm_micro_string.c +3 -6
- data/ext/isomorfeus_ferret_ext/bm_store.c +11 -22
- data/ext/isomorfeus_ferret_ext/brotli_common_constants.c +15 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_constants.h +200 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_context.c +156 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_context.h +113 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +5914 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.h +64 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_platform.c +22 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_platform.h +594 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_transform.c +291 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_transform.h +85 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_version.h +26 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.c +76 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.h +351 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +2608 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.c +339 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.h +121 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_prefix.h +732 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_state.c +159 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_state.h +365 -0
- data/ext/isomorfeus_ferret_ext/brotli_decode.h +344 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.c +145 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.h +39 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.c +843 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.h +95 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_inc.h +163 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.c +35 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.h +63 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost_inc.h +127 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_encoder_inc.h +34 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.c +194 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.h +51 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter_inc.h +440 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.c +1314 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.h +84 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.c +56 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.h +48 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_cluster_inc.h +320 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_command.c +28 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_command.h +190 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.c +790 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.h +61 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.c +645 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.h +54 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.c +1846 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.h +25 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +1927 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.c +33 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.h +43 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.c +503 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.h +122 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode_static.h +539 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.c +105 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.h +66 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_find_match_length.h +79 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash.h +488 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_composite_inc.h +125 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_forgetful_chain_inc.h +293 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match64_inc.h +267 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_inc.h +262 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_quickly_inc.h +266 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_rolling_inc.h +212 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_to_binary_tree_inc.h +329 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.c +100 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.h +63 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_histogram_inc.h +51 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.c +175 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.h +30 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_memory.c +170 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_memory.h +114 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.c +663 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.h +105 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_metablock_inc.h +183 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_params.h +46 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_prefix.h +53 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_quality.h +165 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_ringbuffer.h +167 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.c +486 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.h +40 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict_lut.h +5864 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.c +85 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.h +32 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_write_bits.h +87 -0
- data/ext/isomorfeus_ferret_ext/brotli_encode.h +448 -0
- data/ext/isomorfeus_ferret_ext/brotli_port.h +288 -0
- data/ext/isomorfeus_ferret_ext/brotli_types.h +83 -0
- data/ext/isomorfeus_ferret_ext/bzip_blocksort.c +1094 -0
- data/ext/isomorfeus_ferret_ext/bzip_huffman.c +205 -0
- data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
- data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
- data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
- data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
- data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -0
- data/ext/isomorfeus_ferret_ext/bzlib_private.h +509 -0
- data/ext/isomorfeus_ferret_ext/bzlib_randtable.c +84 -0
- data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -53
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +785 -1192
- data/ext/isomorfeus_ferret_ext/frb_index.c +513 -464
- data/ext/isomorfeus_ferret_ext/frb_qparser.c +48 -60
- data/ext/isomorfeus_ferret_ext/frb_search.c +1520 -1002
- data/ext/isomorfeus_ferret_ext/frb_store.c +96 -96
- data/ext/isomorfeus_ferret_ext/frb_threading.h +0 -1
- data/ext/isomorfeus_ferret_ext/frb_utils.c +147 -196
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +695 -1090
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +174 -170
- data/ext/isomorfeus_ferret_ext/frt_array.c +2 -4
- data/ext/isomorfeus_ferret_ext/frt_bitvector.c +9 -16
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +32 -81
- data/ext/isomorfeus_ferret_ext/frt_document.c +15 -20
- data/ext/isomorfeus_ferret_ext/frt_document.h +10 -9
- data/ext/isomorfeus_ferret_ext/frt_except.c +5 -12
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +3 -3
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +6 -7
- data/ext/isomorfeus_ferret_ext/frt_filter.c +35 -46
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +2 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +105 -63
- data/ext/isomorfeus_ferret_ext/frt_global.h +7 -3
- data/ext/isomorfeus_ferret_ext/frt_hash.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_ind.c +32 -35
- data/ext/isomorfeus_ferret_ext/frt_ind.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_index.c +714 -384
- data/ext/isomorfeus_ferret_ext/frt_index.h +274 -290
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +67 -91
- data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
- data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
- data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +26 -25
- data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
- data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +46 -84
- data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
- data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
- data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
- data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
- data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
- data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +21 -109
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
- data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
- data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
- data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
- data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
- data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
- data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
- data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
- data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
- data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
- data/ext/isomorfeus_ferret_ext/test.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
- data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
- data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
- data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_fields.c +111 -100
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
- data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
- data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
- data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
- data/ext/isomorfeus_ferret_ext/test_index.c +373 -363
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
- data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
- data/ext/isomorfeus_ferret_ext/test_search.c +60 -62
- data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
- data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
- data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
- data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
- data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
- data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +113 -58
- data/ext/isomorfeus_ferret_ext/email.rl +0 -21
- data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
- data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
- data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
- data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
- data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
- data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
- data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
- data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
- data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
- data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
- data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
- data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -2,6 +2,8 @@
|
|
2
2
|
#include "isomorfeus_ferret.h"
|
3
3
|
#include <time.h>
|
4
4
|
|
5
|
+
#undef rename
|
6
|
+
|
5
7
|
static ID id_ref_cnt;
|
6
8
|
VALUE cLock;
|
7
9
|
VALUE cLockError;
|
@@ -10,41 +12,52 @@ VALUE cRAMDirectory;
|
|
10
12
|
VALUE cFSDirectory;
|
11
13
|
|
12
14
|
/****************************************************************************
|
13
|
-
*
|
14
15
|
* Lock Methods
|
15
|
-
*
|
16
16
|
****************************************************************************/
|
17
17
|
|
18
|
-
void
|
19
|
-
frb_unwrap_locks(FrtStore *store)
|
20
|
-
{
|
18
|
+
void frb_unwrap_locks(FrtStore *store) {
|
21
19
|
FrtHashSetEntry *hse = store->locks->first;
|
22
20
|
for (; hse; hse = hse->next) {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
FrtLock *lock = hse->elem;
|
22
|
+
if (lock->rlock != Qnil && lock->rlock != 0) {
|
23
|
+
((struct RData *)(lock->rlock))->data = NULL;
|
24
|
+
((struct RData *)(lock->rlock))->dmark = NULL;
|
25
|
+
((struct RData *)(lock->rlock))->dfree = NULL;
|
28
26
|
}
|
29
27
|
}
|
30
28
|
}
|
31
29
|
|
32
|
-
void
|
33
|
-
frb_lock_free(void *p)
|
34
|
-
{
|
30
|
+
void frb_lock_free(void *p) {
|
35
31
|
FrtLock *lock = (FrtLock *)p;
|
36
|
-
object_del(p);
|
37
32
|
frt_close_lock(lock);
|
38
33
|
}
|
39
34
|
|
40
|
-
void
|
41
|
-
frb_lock_mark(void *p)
|
42
|
-
{
|
35
|
+
void frb_lock_mark(void *p) {
|
43
36
|
FrtLock *lock = (FrtLock *)p;
|
44
|
-
|
37
|
+
if (lock->store->rstore)
|
38
|
+
rb_gc_mark(lock->store->rstore);
|
45
39
|
}
|
46
40
|
|
47
|
-
|
41
|
+
static size_t frb_lock_size(const void *p) {
|
42
|
+
return sizeof(FrtLock);
|
43
|
+
(void)p;
|
44
|
+
}
|
45
|
+
|
46
|
+
const rb_data_type_t frb_lock_t = {
|
47
|
+
.wrap_struct_name = "FrbLock",
|
48
|
+
.function = {
|
49
|
+
.dmark = frb_lock_mark,
|
50
|
+
.dfree = frb_lock_free,
|
51
|
+
.dsize = frb_lock_size,
|
52
|
+
.dcompact = NULL,
|
53
|
+
.reserved = {0},
|
54
|
+
},
|
55
|
+
.parent = NULL,
|
56
|
+
.data = NULL,
|
57
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
58
|
+
};
|
59
|
+
|
60
|
+
#define GET_LOCK(lock, self) TypedData_Get_Struct(self, FrtLock, &frb_lock_t, lock)
|
48
61
|
|
49
62
|
/*
|
50
63
|
* call-seq:
|
@@ -64,9 +77,7 @@ frb_lock_mark(void *p)
|
|
64
77
|
* return:: true if lock was successfully obtained. Raises a
|
65
78
|
* Lock::LockError otherwise.
|
66
79
|
*/
|
67
|
-
static VALUE
|
68
|
-
frb_lock_obtain(int argc, VALUE *argv, VALUE self)
|
69
|
-
{
|
80
|
+
static VALUE frb_lock_obtain(int argc, VALUE *argv, VALUE self) {
|
70
81
|
VALUE rtimeout;
|
71
82
|
int timeout = 1;
|
72
83
|
FrtLock *lock;
|
@@ -110,9 +121,7 @@ frb_lock_obtain(int argc, VALUE *argv, VALUE self)
|
|
110
121
|
* return:: true if lock was successfully obtained. Raises a
|
111
122
|
* Lock::LockError otherwise.
|
112
123
|
*/
|
113
|
-
static VALUE
|
114
|
-
frb_lock_while_locked(int argc, VALUE *argv, VALUE self)
|
115
|
-
{
|
124
|
+
static VALUE frb_lock_while_locked(int argc, VALUE *argv, VALUE self) {
|
116
125
|
VALUE rtimeout;
|
117
126
|
int timeout = 1;
|
118
127
|
FrtLock *lock;
|
@@ -150,9 +159,7 @@ frb_lock_while_locked(int argc, VALUE *argv, VALUE self)
|
|
150
159
|
*
|
151
160
|
* Returns true if the lock has been obtained.
|
152
161
|
*/
|
153
|
-
static VALUE
|
154
|
-
frb_lock_is_locked(VALUE self)
|
155
|
-
{
|
162
|
+
static VALUE frb_lock_is_locked(VALUE self) {
|
156
163
|
FrtLock *lock;
|
157
164
|
GET_LOCK(lock, self);
|
158
165
|
return lock->is_locked(lock) ? Qtrue : Qfalse;
|
@@ -165,9 +172,7 @@ frb_lock_is_locked(VALUE self)
|
|
165
172
|
* Release the lock. This should only be called by the process which obtains
|
166
173
|
* the lock.
|
167
174
|
*/
|
168
|
-
static VALUE
|
169
|
-
frb_lock_release(VALUE self)
|
170
|
-
{
|
175
|
+
static VALUE frb_lock_release(VALUE self) {
|
171
176
|
FrtLock *lock;
|
172
177
|
GET_LOCK(lock, self);
|
173
178
|
lock->release(lock);
|
@@ -180,11 +185,9 @@ frb_lock_release(VALUE self)
|
|
180
185
|
*
|
181
186
|
****************************************************************************/
|
182
187
|
|
183
|
-
void
|
184
|
-
|
185
|
-
{
|
188
|
+
void frb_dir_free(void *p) {
|
189
|
+
FrtStore *store = (FrtStore *)p;
|
186
190
|
frb_unwrap_locks(store);
|
187
|
-
object_del(store);
|
188
191
|
frt_store_deref(store);
|
189
192
|
}
|
190
193
|
|
@@ -196,15 +199,14 @@ frb_dir_free(FrtStore *store)
|
|
196
199
|
* Although the garbage collector will currently handle this for you, this
|
197
200
|
* behaviour may change in future.
|
198
201
|
*/
|
199
|
-
static VALUE
|
200
|
-
frb_dir_close(VALUE self)
|
201
|
-
{
|
202
|
+
static VALUE frb_dir_close(VALUE self) {
|
202
203
|
FrtStore *store = DATA_PTR(self);
|
203
204
|
int ref_cnt = FIX2INT(rb_ivar_get(self, id_ref_cnt)) - 1;
|
204
205
|
rb_ivar_set(self, id_ref_cnt, INT2FIX(ref_cnt));
|
205
206
|
if (ref_cnt < 0) {
|
206
|
-
|
207
|
-
|
207
|
+
((struct RData *)(self))->data = NULL;
|
208
|
+
((struct RData *)(self))->dmark = NULL;
|
209
|
+
((struct RData *)(self))->dfree = NULL;
|
208
210
|
frb_unwrap_locks(store);
|
209
211
|
frt_store_deref(store);
|
210
212
|
}
|
@@ -217,9 +219,7 @@ frb_dir_close(VALUE self)
|
|
217
219
|
*
|
218
220
|
* Return true if a file with the name +file_name+ exists in the directory.
|
219
221
|
*/
|
220
|
-
static VALUE
|
221
|
-
frb_dir_exists(VALUE self, VALUE rfname)
|
222
|
-
{
|
222
|
+
static VALUE frb_dir_exists(VALUE self, VALUE rfname) {
|
223
223
|
FrtStore *store = DATA_PTR(self);
|
224
224
|
StringValue(rfname);
|
225
225
|
return store->exists(store, rs2s(rfname)) ? Qtrue : Qfalse;
|
@@ -231,9 +231,7 @@ frb_dir_exists(VALUE self, VALUE rfname)
|
|
231
231
|
*
|
232
232
|
* Create an empty file in the directory with the name +file_name+.
|
233
233
|
*/
|
234
|
-
static VALUE
|
235
|
-
frb_dir_touch(VALUE self, VALUE rfname)
|
236
|
-
{
|
234
|
+
static VALUE frb_dir_touch(VALUE self, VALUE rfname) {
|
237
235
|
FrtStore *store = DATA_PTR(self);
|
238
236
|
StringValue(rfname);
|
239
237
|
store->touch(store, rs2s(rfname));
|
@@ -246,9 +244,7 @@ frb_dir_touch(VALUE self, VALUE rfname)
|
|
246
244
|
*
|
247
245
|
* Remove file +file_name+ from the directory. Returns true if successful.
|
248
246
|
*/
|
249
|
-
static VALUE
|
250
|
-
frb_dir_delete(VALUE self, VALUE rfname)
|
251
|
-
{
|
247
|
+
static VALUE frb_dir_delete(VALUE self, VALUE rfname) {
|
252
248
|
FrtStore *store = DATA_PTR(self);
|
253
249
|
StringValue(rfname);
|
254
250
|
return (store->remove(store, rs2s(rfname)) == 0) ? Qtrue : Qfalse;
|
@@ -260,9 +256,7 @@ frb_dir_delete(VALUE self, VALUE rfname)
|
|
260
256
|
*
|
261
257
|
* Return a count of the number of files in the directory.
|
262
258
|
*/
|
263
|
-
static VALUE
|
264
|
-
frb_dir_file_count(VALUE self)
|
265
|
-
{
|
259
|
+
static VALUE frb_dir_file_count(VALUE self) {
|
266
260
|
FrtStore *store = DATA_PTR(self);
|
267
261
|
return INT2FIX(store->count(store));
|
268
262
|
}
|
@@ -273,9 +267,7 @@ frb_dir_file_count(VALUE self)
|
|
273
267
|
*
|
274
268
|
* Delete all files in the directory. It gives you a clean slate.
|
275
269
|
*/
|
276
|
-
static VALUE
|
277
|
-
frb_dir_refresh(VALUE self)
|
278
|
-
{
|
270
|
+
static VALUE frb_dir_refresh(VALUE self) {
|
279
271
|
FrtStore *store = DATA_PTR(self);
|
280
272
|
store->clear_all(store);
|
281
273
|
return self;
|
@@ -288,9 +280,7 @@ frb_dir_refresh(VALUE self)
|
|
288
280
|
* Rename a file from +from+ to +to+. An error will be raised if the file
|
289
281
|
* doesn't exist or there is some other type of IOError.
|
290
282
|
*/
|
291
|
-
static VALUE
|
292
|
-
frb_dir_rename(VALUE self, VALUE rfrom, VALUE rto)
|
293
|
-
{
|
283
|
+
static VALUE frb_dir_rename(VALUE self, VALUE rfrom, VALUE rto) {
|
294
284
|
FrtStore *store = DATA_PTR(self);
|
295
285
|
StringValue(rfrom);
|
296
286
|
StringValue(rto);
|
@@ -307,19 +297,43 @@ frb_dir_rename(VALUE self, VALUE rfrom, VALUE rto)
|
|
307
297
|
* should avoid using files with a .lck extension as this extension is
|
308
298
|
* reserved for lock files
|
309
299
|
*/
|
310
|
-
static VALUE
|
311
|
-
frb_dir_make_lock(VALUE self, VALUE rlock_name)
|
312
|
-
{
|
300
|
+
static VALUE frb_dir_make_lock(VALUE self, VALUE rlock_name) {
|
313
301
|
VALUE rlock;
|
314
302
|
FrtLock *lock;
|
315
303
|
FrtStore *store = DATA_PTR(self);
|
316
304
|
StringValue(rlock_name);
|
317
305
|
lock = frt_open_lock(store, rs2s(rlock_name));
|
318
|
-
rlock =
|
319
|
-
|
306
|
+
rlock = TypedData_Wrap_Struct(cLock, &frb_lock_t, lock);
|
307
|
+
lock->rlock = rlock;
|
320
308
|
return rlock;
|
321
309
|
}
|
322
310
|
|
311
|
+
/*** FrbStore ****************************************************************/
|
312
|
+
|
313
|
+
static size_t frb_store_size(const void *p) {
|
314
|
+
return sizeof(FrtStore);
|
315
|
+
(void)p;
|
316
|
+
}
|
317
|
+
|
318
|
+
const rb_data_type_t frb_store_t = {
|
319
|
+
.wrap_struct_name = "FrbStore",
|
320
|
+
.function = {
|
321
|
+
.dmark = NULL,
|
322
|
+
.dfree = frb_dir_free,
|
323
|
+
.dsize = frb_store_size,
|
324
|
+
.dcompact = NULL,
|
325
|
+
.reserved = {0},
|
326
|
+
},
|
327
|
+
.parent = NULL,
|
328
|
+
.data = NULL,
|
329
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
330
|
+
};
|
331
|
+
|
332
|
+
static VALUE frb_store_alloc(VALUE rclass) {
|
333
|
+
FrtStore *st = frt_store_alloc();
|
334
|
+
return TypedData_Wrap_Struct(rclass, &frb_store_t, st);
|
335
|
+
}
|
336
|
+
|
323
337
|
/****************************************************************************
|
324
338
|
*
|
325
339
|
* RAMDirectory Methods
|
@@ -338,22 +352,21 @@ frb_dir_make_lock(VALUE self, VALUE rlock_name)
|
|
338
352
|
*
|
339
353
|
* dir:: Directory to load into memory
|
340
354
|
*/
|
341
|
-
|
342
|
-
frb_ramdir_init(int argc, VALUE *argv, VALUE self)
|
343
|
-
{
|
355
|
+
|
356
|
+
static VALUE frb_ramdir_init(int argc, VALUE *argv, VALUE self) {
|
344
357
|
VALUE rdir;
|
345
358
|
FrtStore *store;
|
359
|
+
TypedData_Get_Struct(self, FrtStore, &frb_store_t, store);
|
346
360
|
switch (rb_scan_args(argc, argv, "01", &rdir)) {
|
347
361
|
case 1: {
|
348
362
|
FrtStore *ostore;
|
349
|
-
|
350
|
-
store
|
363
|
+
TypedData_Get_Struct(rdir, FrtStore, &frb_store_t, ostore);
|
364
|
+
frt_open_ram_store_and_copy(store, ostore, false);
|
351
365
|
break;
|
352
366
|
}
|
353
|
-
default:
|
367
|
+
default: frt_open_ram_store(store);
|
354
368
|
}
|
355
|
-
|
356
|
-
object_add(store, self);
|
369
|
+
store->rstore = self;
|
357
370
|
rb_ivar_set(self, id_ref_cnt, INT2FIX(0));
|
358
371
|
return self;
|
359
372
|
}
|
@@ -378,9 +391,7 @@ frb_ramdir_init(int argc, VALUE *argv, VALUE self)
|
|
378
391
|
* create:: set to true if you want any existing files in the directory to be
|
379
392
|
* deleted
|
380
393
|
*/
|
381
|
-
static VALUE
|
382
|
-
frb_fsdir_new(int argc, VALUE *argv, VALUE klass)
|
383
|
-
{
|
394
|
+
static VALUE frb_fsdir_new(int argc, VALUE *argv, VALUE klass) {
|
384
395
|
VALUE self, rpath, rcreate;
|
385
396
|
FrtStore *store;
|
386
397
|
bool create;
|
@@ -397,12 +408,11 @@ frb_fsdir_new(int argc, VALUE *argv, VALUE klass)
|
|
397
408
|
}
|
398
409
|
store = frt_open_fs_store(rs2s(rpath));
|
399
410
|
if (create) store->clear_all(store);
|
400
|
-
if ((self =
|
401
|
-
self =
|
402
|
-
|
411
|
+
if ((self = store->rstore) == Qnil) {
|
412
|
+
self = TypedData_Wrap_Struct(klass, &frb_store_t, store);
|
413
|
+
store->rstore = self;
|
403
414
|
rb_ivar_set(self, id_ref_cnt, INT2FIX(0));
|
404
|
-
}
|
405
|
-
else {
|
415
|
+
} else {
|
406
416
|
int ref_cnt = FIX2INT(rb_ivar_get(self, id_ref_cnt)) + 1;
|
407
417
|
rb_ivar_set(self, id_ref_cnt, INT2FIX(ref_cnt));
|
408
418
|
FRT_DEREF(store);
|
@@ -434,9 +444,7 @@ frb_fsdir_new(int argc, VALUE *argv, VALUE klass)
|
|
434
444
|
* called _open_input_ If there is a risk of simultaneous modifications of
|
435
445
|
* the files then locks should be used. See Lock to find out how.
|
436
446
|
*/
|
437
|
-
void
|
438
|
-
Init_Directory(void)
|
439
|
-
{
|
447
|
+
void Init_Directory(void) {
|
440
448
|
cDirectory = rb_define_class_under(mStore, "Directory", rb_cObject);
|
441
449
|
rb_define_const(cDirectory, "LOCK_PREFIX", rb_str_new2(FRT_LOCK_PREFIX));
|
442
450
|
rb_define_method(cDirectory, "close", frb_dir_close, 0);
|
@@ -472,9 +480,7 @@ Init_Directory(void)
|
|
472
480
|
* ... # Do your file modifications # ...
|
473
481
|
* end
|
474
482
|
*/
|
475
|
-
void
|
476
|
-
Init_Lock(void)
|
477
|
-
{
|
483
|
+
void Init_Lock(void) {
|
478
484
|
cLock = rb_define_class_under(mStore, "Lock", rb_cObject);
|
479
485
|
rb_define_method(cLock, "obtain", frb_lock_obtain, -1);
|
480
486
|
rb_define_method(cLock, "while_locked", frb_lock_while_locked, -1);
|
@@ -493,11 +499,9 @@ Init_Lock(void)
|
|
493
499
|
* operating systems there won't be much difference so it wouldn't be worth
|
494
500
|
* your trouble.
|
495
501
|
*/
|
496
|
-
void
|
497
|
-
Init_RAMDirectory(void)
|
498
|
-
{
|
502
|
+
void Init_RAMDirectory(void) {
|
499
503
|
cRAMDirectory = rb_define_class_under(mStore, "RAMDirectory", cDirectory);
|
500
|
-
rb_define_alloc_func(cRAMDirectory,
|
504
|
+
rb_define_alloc_func(cRAMDirectory, frb_store_alloc);
|
501
505
|
rb_define_method(cRAMDirectory, "initialize", frb_ramdir_init, -1);
|
502
506
|
}
|
503
507
|
|
@@ -510,11 +514,9 @@ Init_RAMDirectory(void)
|
|
510
514
|
* the index. The one exception to this rule is you may need to delete stale
|
511
515
|
* lock files which have a ".lck" extension.
|
512
516
|
*/
|
513
|
-
void
|
514
|
-
Init_FSDirectory(void)
|
515
|
-
{
|
517
|
+
void Init_FSDirectory(void) {
|
516
518
|
cFSDirectory = rb_define_class_under(mStore, "FSDirectory", cDirectory);
|
517
|
-
rb_define_alloc_func(cFSDirectory,
|
519
|
+
rb_define_alloc_func(cFSDirectory, frb_store_alloc);
|
518
520
|
rb_define_singleton_method(cFSDirectory, "new", frb_fsdir_new, -1);
|
519
521
|
}
|
520
522
|
|
@@ -532,9 +534,7 @@ extern VALUE mFerret = rb_define_module("Ferret");
|
|
532
534
|
* you want to add a different type of Directory, like a database Directory
|
533
535
|
* for instance, you will to implement it in C.
|
534
536
|
*/
|
535
|
-
void
|
536
|
-
Init_Store(void)
|
537
|
-
{
|
537
|
+
void Init_Store(void) {
|
538
538
|
id_ref_cnt = rb_intern("@id_ref_cnt");
|
539
539
|
mStore = rb_define_module_under(mFerret, "Store");
|
540
540
|
Init_Directory();
|
@@ -18,7 +18,6 @@ typedef int frt_thread_once_t;
|
|
18
18
|
#define frt_thread_key_delete(a) frb_thread_key_delete(a)
|
19
19
|
#define frt_thread_setspecific(a, b) frb_thread_setspecific(a, b)
|
20
20
|
#define frt_thread_getspecific(a) frb_thread_getspecific(a)
|
21
|
-
#define frt_thread_exit(a)
|
22
21
|
#define frt_thread_once(a, b) frb_thread_once(a, b)
|
23
22
|
|
24
23
|
void frb_thread_once(int *once_control, void (*init_routine)(void));
|