isomorfeus-ferret 0.13.5 → 0.13.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f2a4a6ea097a25d4d32a958c730fffca81ded61133f37ef4c86ca5b78ecef77
4
- data.tar.gz: 7be1f98b64559be5f02e39d7a74894476046fef3fdd46d1e69ee3079c74c9681
3
+ metadata.gz: 524b384c2ab35457603726287160b443a50939473bab7852e5e6f5f886ded0a7
4
+ data.tar.gz: b304d0386bc0b14e68167bfcc1b62346f81c02f6eff25c3a6633bb0a1919083e
5
5
  SHA512:
6
- metadata.gz: d173777ee520433e8df0e1a07853f92b65aa350427668baea67a957a28a8cadc05790396d8d5167282c4c83fb1e874eec3316c226e8c961f9f3161f3bf3ecb79
7
- data.tar.gz: c64a96813a4b2546e21825cb4a6310c9384a8090bafe51e9c65c49d8c2b8bc69ab3deed82780e6df09089b6a915d6b7e7418bcac30f3d9770c1358800aa2286d
6
+ metadata.gz: b378ce12aa56bb35e57eec2c8df64152a7a7bd5cb1345d4a7dc0264e236fddcea3ffbc41a7213401cf50ff163c3172169fbf93699a4a7f96505f300782bc9a92
7
+ data.tar.gz: 6954e297df285f7726bd925a6f4dda4300f06d059dc4b674a494e775b901f7ea9e529e62be8793049c6df20a17515c41741f63155fbdd661de4595694deb4c27
@@ -329,7 +329,7 @@ static void cw_copy_file(FrtCompoundWriter *cw, FrtCWFileEntry *src, FrtOutStrea
329
329
  frt_is_close(is);
330
330
  }
331
331
 
332
- void frt_cw_close(FrtCompoundWriter *cw)
332
+ void frt_cw_close(FrtCompoundWriter *cw, FrtDeleter *dlr)
333
333
  {
334
334
  FrtOutStream *os = NULL;
335
335
  int i;
@@ -356,6 +356,9 @@ void frt_cw_close(FrtCompoundWriter *cw)
356
356
  for (i = 0; i < frt_ary_size(cw->file_entries); i++) {
357
357
  cw->file_entries[i].data_offset = frt_os_pos(os);
358
358
  cw_copy_file(cw, &cw->file_entries[i], os);
359
+ if (dlr) {
360
+ frt_deleter_queue_file(dlr, cw->file_entries[i].name);
361
+ }
359
362
  }
360
363
 
361
364
  /* Write the data offsets into the directory of the compound stream */
@@ -272,15 +272,13 @@ static const struct FrtOutStreamMethods FS_OUT_STREAM_METHODS = {
272
272
  static FrtOutStream *fs_new_output(FrtStore *store, const char *filename)
273
273
  {
274
274
  char path[FRT_MAX_FILE_PATH];
275
- int fd = open(join_path(path, store->dir.path, filename),
276
- O_WRONLY | O_CREAT | O_BINARY, store->file_mode);
277
- FrtOutStream *os;
275
+ int fd = open(join_path(path, store->dir.path, filename), O_WRONLY | O_CREAT | O_BINARY, store->file_mode);
278
276
  if (fd < 0) {
279
277
  FRT_RAISE(FRT_IO_ERROR, "couldn't create OutStream %s: <%s>",
280
278
  path, strerror(errno));
281
279
  }
282
280
 
283
- os = frt_os_new();
281
+ FrtOutStream *os = frt_os_new();
284
282
  os->file.fd = fd;
285
283
  os->m = &FS_OUT_STREAM_METHODS;
286
284
  return os;
@@ -681,15 +681,13 @@ static char *si_norm_file_name(FrtSegmentInfo *si, char *buf, int field_num)
681
681
  if (field_num >= si->norm_gens_size
682
682
  || 0 > (norm_gen = si->norm_gens[field_num])) {
683
683
  return NULL;
684
- }
685
- else {
684
+ } else {
686
685
  const char *ext = (si->use_compound_file && norm_gen > 0) ? "s" : "f";
687
686
  return fn_for_gen_field(buf, si->name, ext, norm_gen, field_num);
688
687
  }
689
688
  }
690
689
 
691
- static void deleter_queue_file(FrtDeleter *dlr, const char *file_name);
692
- #define DEL(file_name) deleter_queue_file(dlr, file_name)
690
+ void frt_deleter_queue_file(FrtDeleter *dlr, const char *file_name);
693
691
 
694
692
  static void si_delete_files(FrtSegmentInfo *si, FrtFieldInfos *fis, FrtDeleter *dlr)
695
693
  {
@@ -700,7 +698,7 @@ static void si_delete_files(FrtSegmentInfo *si, FrtFieldInfos *fis, FrtDeleter *
700
698
 
701
699
  for (i = si->norm_gens_size - 1; i >= 0; i--) {
702
700
  if (0 <= si->norm_gens[i]) {
703
- DEL(si_norm_file_name(si, file_name, fis->fields[i]->number));
701
+ frt_deleter_queue_file(dlr, si_norm_file_name(si, file_name, fis->fields[i]->number));
704
702
  }
705
703
  }
706
704
 
@@ -710,15 +708,14 @@ static void si_delete_files(FrtSegmentInfo *si, FrtFieldInfos *fis, FrtDeleter *
710
708
 
711
709
  if (si->use_compound_file) {
712
710
  memcpy(ext, "cfs", 4);
713
- DEL(file_name);
711
+ frt_deleter_queue_file(dlr, file_name);
714
712
  if (0 <= si->del_gen) {
715
- DEL(frt_fn_for_generation(file_name, si->name, "del", si->del_gen));
713
+ frt_deleter_queue_file(dlr, frt_fn_for_generation(file_name, si->name, "del", si->del_gen));
716
714
  }
717
- }
718
- else {
715
+ } else {
719
716
  for (i = FRT_NELEMS(INDEX_EXTENSIONS) - 1; i >= 0; i--) {
720
717
  memcpy(ext, INDEX_EXTENSIONS[i], 4);
721
- DEL(file_name);
718
+ frt_deleter_queue_file(dlr, file_name);
722
719
  }
723
720
  }
724
721
  }
@@ -3695,8 +3692,7 @@ static bool file_name_filter_is_cfs_file(const char *file_name) {
3695
3692
  ****************************************************************************/
3696
3693
 
3697
3694
  #define DELETABLE_START_CAPA 8
3698
- FrtDeleter *frt_deleter_new(FrtSegmentInfos *sis, FrtStore *store)
3699
- {
3695
+ FrtDeleter *frt_deleter_new(FrtSegmentInfos *sis, FrtStore *store) {
3700
3696
  FrtDeleter *dlr = FRT_ALLOC(FrtDeleter);
3701
3697
  dlr->sis = sis;
3702
3698
  dlr->store = store;
@@ -3704,19 +3700,16 @@ FrtDeleter *frt_deleter_new(FrtSegmentInfos *sis, FrtStore *store)
3704
3700
  return dlr;
3705
3701
  }
3706
3702
 
3707
- void frt_deleter_destroy(FrtDeleter *dlr)
3708
- {
3703
+ void frt_deleter_destroy(FrtDeleter *dlr) {
3709
3704
  frt_hs_destroy(dlr->pending);
3710
3705
  free(dlr);
3711
3706
  }
3712
3707
 
3713
- static void deleter_queue_file(FrtDeleter *dlr, const char *file_name)
3714
- {
3708
+ void frt_deleter_queue_file(FrtDeleter *dlr, const char *file_name) {
3715
3709
  frt_hs_add(dlr->pending, frt_estrdup(file_name));
3716
3710
  }
3717
3711
 
3718
- void frt_deleter_delete_file(FrtDeleter *dlr, char *file_name)
3719
- {
3712
+ void frt_deleter_delete_file(FrtDeleter *dlr, char *file_name) {
3720
3713
  FrtStore *store = dlr->store;
3721
3714
  FRT_TRY
3722
3715
  if (store->exists(store, file_name)) {
@@ -3728,8 +3721,7 @@ void frt_deleter_delete_file(FrtDeleter *dlr, char *file_name)
3728
3721
  FRT_XENDTRY
3729
3722
  }
3730
3723
 
3731
- static void deleter_commit_pending_deletions(FrtDeleter *dlr)
3732
- {
3724
+ static void deleter_commit_pending_deletions(FrtDeleter *dlr) {
3733
3725
  FrtHashSetEntry *hse, *hse_next = dlr->pending->first;
3734
3726
  while ((hse = hse_next) != NULL) {
3735
3727
  hse_next = hse->next;
@@ -3737,23 +3729,13 @@ static void deleter_commit_pending_deletions(FrtDeleter *dlr)
3737
3729
  }
3738
3730
  }
3739
3731
 
3740
- void frt_deleter_delete_files(FrtDeleter *dlr, char **files, int file_cnt)
3741
- {
3742
- int i;
3743
- for (i = file_cnt - 1; i >= 0; i--) {
3744
- deleter_queue_file(dlr, files[i]);
3745
- }
3746
- deleter_commit_pending_deletions(dlr);
3747
- }
3748
-
3749
3732
  struct DelFilesArg {
3750
3733
  char curr_seg_file_name[FRT_SEGMENT_NAME_MAX_LENGTH];
3751
3734
  FrtDeleter *dlr;
3752
3735
  FrtHash *current;
3753
3736
  };
3754
3737
 
3755
- static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg)
3756
- {
3738
+ static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg) {
3757
3739
  struct DelFilesArg *dfa = (struct DelFilesArg *)arg;
3758
3740
  FrtDeleter *dlr = dfa->dlr;
3759
3741
 
@@ -3773,8 +3755,7 @@ static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg)
3773
3755
  if (NULL != p) {
3774
3756
  *p = '\0';
3775
3757
  extension = p + 1;
3776
- }
3777
- else {
3758
+ } else {
3778
3759
  extension = NULL;
3779
3760
  }
3780
3761
 
@@ -3789,16 +3770,14 @@ static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg)
3789
3770
  if (NULL == (si = (FrtSegmentInfo *)frt_h_get(dfa->current, segment_name))) {
3790
3771
  /* Delete if segment is not referenced: */
3791
3772
  do_delete = true;
3792
- }
3793
- else {
3773
+ } else {
3794
3774
  char tmp_fn[FRT_SEGMENT_NAME_MAX_LENGTH];
3795
3775
  /* OK, segment is referenced, but file may still be orphan'd: */
3796
3776
  if (file_name_filter_is_cfs_file(file_name)
3797
3777
  && si->use_compound_file) {
3798
3778
  /* This file is stored in a CFS file for this segment: */
3799
3779
  do_delete = true;
3800
- }
3801
- else if (0 == strcmp("del", extension)) {
3780
+ } else if (0 == strcmp("del", extension)) {
3802
3781
  /* This is a _segmentName_N.del file: */
3803
3782
  if (!frt_fn_for_generation(tmp_fn, segment_name, "del", si->del_gen)
3804
3783
  || 0 != strcmp(file_name, tmp_fn)) {
@@ -3807,8 +3786,7 @@ static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg)
3807
3786
  * this segment, then delete it: */
3808
3787
  do_delete = true;
3809
3788
  }
3810
- }
3811
- else if (NULL != extension
3789
+ } else if (NULL != extension
3812
3790
  && ('s' == *extension || 'f' == *extension)
3813
3791
  && isdigit(extension[1])) {
3814
3792
  si_norm_file_name(si, tmp_fn, atoi(extension + 1));
@@ -3817,15 +3795,14 @@ static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg)
3817
3795
  /* This is an orphan'd norms file: */
3818
3796
  do_delete = true;
3819
3797
  }
3820
- }
3821
- else if (0 == strcmp("cfs", extension) && !si->use_compound_file) {
3798
+ } else if (0 == strcmp("cfs", extension) && !si->use_compound_file) {
3822
3799
  /* This is a partially written _segmentName.cfs: */
3823
3800
  do_delete = true;
3824
3801
  }
3825
3802
  }
3826
3803
 
3827
3804
  if (do_delete) {
3828
- deleter_queue_file(dlr, file_name);
3805
+ frt_deleter_queue_file(dlr, file_name);
3829
3806
  }
3830
3807
  }
3831
3808
  }
@@ -3837,8 +3814,7 @@ static void frt_deleter_find_deletable_files_i(const char *file_name, void *arg)
3837
3814
  * create the unused file (eg when merging segments), and we only remove from
3838
3815
  * deletable when a file is successfully deleted.
3839
3816
  */
3840
- void frt_deleter_find_deletable_files(FrtDeleter *dlr)
3841
- {
3817
+ void frt_deleter_find_deletable_files(FrtDeleter *dlr) {
3842
3818
  /* Gather all "current" segments: */
3843
3819
  int i;
3844
3820
  FrtSegmentInfos *sis = dlr->sis;
@@ -4207,7 +4183,7 @@ static void norm_rewrite(Norm *norm, FrtStore *store, FrtDeleter *dlr,
4207
4183
  const int field_num = norm->field_num;
4208
4184
 
4209
4185
  if (si_norm_file_name(si, norm_file_name, field_num)) {
4210
- deleter_queue_file(dlr, norm_file_name);
4186
+ frt_deleter_queue_file(dlr, norm_file_name);
4211
4187
  }
4212
4188
  frt_si_advance_norm_gen(si, field_num);
4213
4189
  si_norm_file_name(si, norm_file_name, field_num);
@@ -4363,7 +4339,7 @@ static void sr_commit_i(FrtIndexReader *ir)
4363
4339
  if (SR(ir)->undelete_all || SR(ir)->deleted_docs_dirty) {
4364
4340
  if (si->del_gen >= 0) {
4365
4341
  frt_fn_for_generation(tmp_file_name, segment, "del", si->del_gen);
4366
- deleter_queue_file(ir->deleter, tmp_file_name);
4342
+ frt_deleter_queue_file(ir->deleter, tmp_file_name);
4367
4343
  }
4368
4344
  if (SR(ir)->undelete_all) {
4369
4345
  si->del_gen = -1;
@@ -5687,7 +5663,6 @@ static SegmentMergeInfo *smi_new(int base, FrtStore *store, FrtSegmentInfo *si)
5687
5663
  smi->store = frt_open_cmpd_store(store, file_name);
5688
5664
  }
5689
5665
 
5690
-
5691
5666
  sprintf(file_name, "%s.fdx", segment);
5692
5667
  smi->doc_cnt = smi->max_doc
5693
5668
  = smi->store->length(smi->store, file_name) / FIELDS_IDX_PTR_SIZE;
@@ -6116,14 +6091,7 @@ int frt_iw_doc_count(FrtIndexWriter *iw)
6116
6091
  return doc_cnt;
6117
6092
  }
6118
6093
 
6119
- #define MOVE_TO_COMPOUND_DIR(file_name)\
6120
- deleter_queue_file(dlr, file_name);\
6121
- frt_cw_add_file(cw, file_name)
6122
-
6123
- static void iw_create_compound_file(FrtStore *store, FrtFieldInfos *fis,
6124
- FrtSegmentInfo *si, char *cfs_file_name,
6125
- FrtDeleter *dlr)
6126
- {
6094
+ static void iw_create_compound_file(FrtStore *store, FrtFieldInfos *fis, FrtSegmentInfo *si, char *cfs_file_name, FrtDeleter *dlr) {
6127
6095
  int i;
6128
6096
  FrtCompoundWriter *cw;
6129
6097
  char file_name[FRT_SEGMENT_NAME_MAX_LENGTH];
@@ -6137,19 +6105,18 @@ static void iw_create_compound_file(FrtStore *store, FrtFieldInfos *fis,
6137
6105
  cw = frt_open_cw(store, cfs_file_name);
6138
6106
  for (i = 0; i < FRT_NELEMS(COMPOUND_EXTENSIONS); i++) {
6139
6107
  memcpy(ext, COMPOUND_EXTENSIONS[i], 4);
6140
- MOVE_TO_COMPOUND_DIR(file_name);
6108
+ frt_cw_add_file(cw, file_name);
6141
6109
  }
6142
6110
 
6143
6111
  /* Field norm file_names */
6144
6112
  for (i = fis->size - 1; i >= 0; i--) {
6145
- if (fi_has_norms(fis->fields[i])
6146
- && si_norm_file_name(si, file_name, i)) {
6147
- MOVE_TO_COMPOUND_DIR(file_name);
6113
+ if (fi_has_norms(fis->fields[i]) && si_norm_file_name(si, file_name, i)) {
6114
+ frt_cw_add_file(cw, file_name);
6148
6115
  }
6149
6116
  }
6150
6117
 
6151
6118
  /* Perform the merge */
6152
- frt_cw_close(cw);
6119
+ frt_cw_close(cw, dlr);
6153
6120
  }
6154
6121
 
6155
6122
  static void iw_commit_compound_file(FrtIndexWriter *iw, FrtSegmentInfo *si)
@@ -627,9 +627,9 @@ struct FrtDeleter {
627
627
 
628
628
  extern FrtDeleter *frt_deleter_new(FrtSegmentInfos *sis, FrtStore *store);
629
629
  extern void frt_deleter_destroy(FrtDeleter *dlr);
630
+ extern void frt_deleter_queue_file(FrtDeleter *dlr, const char *file_name);
630
631
  extern void frt_deleter_delete_file(FrtDeleter *dlr, char *file_name);
631
632
  extern void frt_deleter_find_deletable_files(FrtDeleter *dlr);
632
- extern void frt_deleter_delete_files(FrtDeleter *dlr, char **files, int file_cnt);
633
633
 
634
634
  /****************************************************************************
635
635
  *
@@ -859,6 +859,6 @@ typedef struct FrtCompoundWriter {
859
859
 
860
860
  extern FrtCompoundWriter *frt_open_cw(FrtStore *store, char *name);
861
861
  extern void frt_cw_add_file(FrtCompoundWriter *cw, char *id);
862
- extern void frt_cw_close(FrtCompoundWriter *cw);
862
+ extern void frt_cw_close(FrtCompoundWriter *cw, FrtDeleter *dlr);
863
863
 
864
864
  #endif
@@ -810,7 +810,7 @@ void Init_Test(void) {
810
810
  rb_define_singleton_method(mTest, "filter", frb_ts_filter, 0);
811
811
  rb_define_singleton_method(mTest, "fs_store", frb_ts_fs_store, 0);
812
812
  rb_define_singleton_method(mTest, "global", frb_ts_global, 0);
813
- rb_define_singleton_method(mTest, "hash", frb_ts_hash, 0);
813
+ rb_define_singleton_method(mTest, "test_hash", frb_ts_hash, 0);
814
814
  rb_define_singleton_method(mTest, "hashset", frb_ts_hashset, 0);
815
815
  rb_define_singleton_method(mTest, "helper", frb_ts_helper, 0);
816
816
  rb_define_singleton_method(mTest, "highlighter", frb_ts_highlighter, 0);
@@ -48,7 +48,7 @@ void test_compound_writer(TestCase *tc, void *data)
48
48
  cw = frt_open_cw(store, (char *)"cfile");
49
49
  frt_cw_add_file(cw, (char *)"file1");
50
50
  frt_cw_add_file(cw, (char *)"file2");
51
- frt_cw_close(cw);
51
+ frt_cw_close(cw, NULL);
52
52
 
53
53
  is = store->open_input(store, "cfile");
54
54
  Aiequal(2, frt_is_read_vint(is));
@@ -94,7 +94,7 @@ void test_compound_io(TestCase *tc, void *data)
94
94
  frt_cw_add_file(cw, (char *)"file1");
95
95
  frt_cw_add_file(cw, (char *)"file2");
96
96
  frt_cw_add_file(cw, (char *)"file3");
97
- frt_cw_close(cw);
97
+ frt_cw_close(cw, NULL);
98
98
 
99
99
  c_reader = frt_open_cmpd_store(store, "cfile");
100
100
  is1 = c_reader->open_input(c_reader, "file1");
@@ -137,7 +137,7 @@ void test_compound_io_many_files(TestCase *tc, void *data)
137
137
  frt_os_write_vint(os, MAGIC);
138
138
  frt_os_close(os);
139
139
  }
140
- frt_cw_close(cw);
140
+ frt_cw_close(cw, NULL);
141
141
 
142
142
  c_reader = frt_open_cmpd_store(store, "_.cfs");
143
143
  for (i = 0; i < TEST_FILE_CNT; i++) {
@@ -45,6 +45,7 @@ static void test_hash_str(TestCase *tc, void *data)
45
45
 
46
46
  size_t res;
47
47
  f = temp_open();
48
+ Assert(f != NULL, "Could not open tempfile");
48
49
  frt_h_str_print_keys(h, f);
49
50
  fseek(f, 0, SEEK_SET);
50
51
  res = fread(buf, 1, 100, f);
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Ferret
3
- VERSION = '0.13.5'
3
+ VERSION = '0.13.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-ferret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.5
4
+ version: 0.13.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-20 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake