Ticket #215: ferret64.patch
| File ferret64.patch, 4.3 KB (added by kyle@…, 3 years ago) |
|---|
-
ruby/test/unit/largefile/tc_sample_large.rb
1 require File.dirname(__FILE__) + "/../../test_helper" 2 3 class SampleLargeTest < Test::Unit::TestCase 4 include Ferret::Index 5 include Ferret::Search 6 include Ferret::Store 7 include Ferret::Utils 8 9 INDEX_DIR = File.dirname(__FILE__) + "/../../temp/largefile" 10 RECORDS = 750 11 RECORD_SIZE = 10e5 12 13 def setup 14 @index = Index.new(:path => INDEX_DIR, :create_if_missing => true, :key => :id) 15 create_index! if @index.size == 0 or ENV["RELOAD_LARGE_INDEX"] 16 end 17 18 def test_file_index_created 19 assert @index.size == RECORDS, "Index size should be #{RECORDS}, is #{@index.size}" 20 end 21 22 def test_keys_work 23 @index << {:content => "foo", :id => RECORDS - 4} 24 assert @index.size == RECORDS, "Index size should be #{RECORDS}, is #{@index.size}" 25 end 26 27 def test_read_file_after_two_gigs 28 assert @index.reader[RECORDS - 5].load.is_a?Hash 29 end 30 31 def create_index! 32 @@already_built_large_index ||= false 33 return if @@already_built_large_index 34 @@already_built_large_index = true 35 a = "a" 36 RECORDS.times { |i| 37 seq = (a.succ! + " ") * RECORD_SIZE 38 record = {:id => i, :content => seq} 39 @index << record 40 print "i" 41 STDOUT.flush 42 } 43 puts "o" 44 @index.optimize 45 end 46 end -
ruby/test/unit/ts_largefile.rb
1 require File.join(File.dirname(__FILE__), "../test_helper.rb") 2 load_test_dir('unit/largefile') -
c/include/index.h
456 456 457 457 typedef struct Offset 458 458 { 459 int start;460 int end;459 off_t start; 460 off_t end; 461 461 } Offset; 462 462 463 extern Offset *offset_new( int start, int end);463 extern Offset *offset_new(off_t start, off_t end); 464 464 465 465 /**************************************************************************** 466 466 * … … 617 617 /* * * LazyDocField * * */ 618 618 typedef struct LazyDocFieldData 619 619 { 620 int start;620 off_t start; 621 621 int length; 622 622 char *text; 623 623 } LazyDocFieldData; -
c/src/index.c
1375 1375 lazy_doc = lazy_doc_new(stored_cnt, fdt_in); 1376 1376 1377 1377 for (i = 0; i < stored_cnt; i++) { 1378 int start = 0, end, data_cnt;1378 off_t start = 0, end, data_cnt; 1379 1379 field_num = is_read_vint(fdt_in); 1380 1380 fi = fr->fis->fields[field_num]; 1381 1381 data_cnt = is_read_vint(fdt_in); … … 1449 1449 if (store_offsets) { 1450 1450 int num_positions = tv->offset_cnt = is_read_vint(fdt_in); 1451 1451 Offset *offsets = tv->offsets = ALLOC_N(Offset, num_positions); 1452 int offset = 0;1452 off_t offset = 0; 1453 1453 for (i = 0; i < num_positions; i++) { 1454 1454 offsets[i].start = offset += is_read_vint(fdt_in); 1455 1455 offsets[i].end = offset += is_read_vint(fdt_in); … … 1683 1683 int last_end = 0; 1684 1684 os_write_vint(fdt_out, offset_count); /* write shared prefix length */ 1685 1685 for (i = 0; i < offset_count; i++) { 1686 int start = offsets[i].start;1687 int end = offsets[i].end;1686 off_t start = offsets[i].start; 1687 off_t end = offsets[i].end; 1688 1688 os_write_vint(fdt_out, start - last_end); 1689 1689 os_write_vint(fdt_out, end - start); 1690 1690 last_end = end; … … 4799 4799 * 4800 4800 ****************************************************************************/ 4801 4801 4802 Offset *offset_new( int start, int end)4802 Offset *offset_new(off_t start, off_t end) 4803 4803 { 4804 4804 Offset *offset = ALLOC(Offset); 4805 4805 offset->start = start; … … 5204 5204 int doc_num = dw->doc_num; 5205 5205 int i; 5206 5206 const int df_size = df->size; 5207 int start_offset = 0;5207 off_t start_offset = 0; 5208 5208 5209 5209 if (fld_inv->is_tokenized) { 5210 5210 Token *tk;
