Ticket #215: ferret64.patch

File ferret64.patch, 4.3 KB (added by kyle@…, 3 years ago)

Patch for LFS issues

  • ruby/test/unit/largefile/tc_sample_large.rb

     
     1require File.dirname(__FILE__) + "/../../test_helper" 
     2 
     3class 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 
     46end 
  • ruby/test/unit/ts_largefile.rb

     
     1require File.join(File.dirname(__FILE__), "../test_helper.rb") 
     2load_test_dir('unit/largefile') 
  • c/include/index.h

     
    456456 
    457457typedef struct Offset 
    458458{ 
    459     int start; 
    460     int end; 
     459    off_t start; 
     460    off_t end; 
    461461} Offset; 
    462462 
    463 extern Offset *offset_new(int start, int end); 
     463extern Offset *offset_new(off_t start, off_t end); 
    464464 
    465465/**************************************************************************** 
    466466 * 
     
    617617/* * * LazyDocField * * */ 
    618618typedef struct LazyDocFieldData 
    619619{ 
    620     int   start; 
     620    off_t   start; 
    621621    int   length; 
    622622    char *text; 
    623623} LazyDocFieldData; 
  • c/src/index.c

     
    13751375    lazy_doc = lazy_doc_new(stored_cnt, fdt_in); 
    13761376 
    13771377    for (i = 0; i < stored_cnt; i++) { 
    1378         int start = 0, end, data_cnt; 
     1378        off_t start = 0, end, data_cnt; 
    13791379        field_num = is_read_vint(fdt_in); 
    13801380        fi = fr->fis->fields[field_num]; 
    13811381        data_cnt = is_read_vint(fdt_in); 
     
    14491449        if (store_offsets) { 
    14501450            int num_positions = tv->offset_cnt = is_read_vint(fdt_in); 
    14511451            Offset *offsets = tv->offsets = ALLOC_N(Offset, num_positions); 
    1452             int offset = 0; 
     1452            off_t offset = 0; 
    14531453            for (i = 0; i < num_positions; i++) { 
    14541454                offsets[i].start = offset += is_read_vint(fdt_in); 
    14551455                offsets[i].end = offset += is_read_vint(fdt_in); 
     
    16831683        int last_end = 0; 
    16841684        os_write_vint(fdt_out, offset_count);  /* write shared prefix length */ 
    16851685        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; 
    16881688            os_write_vint(fdt_out, start - last_end); 
    16891689            os_write_vint(fdt_out, end - start); 
    16901690            last_end = end; 
     
    47994799 * 
    48004800 ****************************************************************************/ 
    48014801 
    4802 Offset *offset_new(int start, int end) 
     4802Offset *offset_new(off_t start, off_t end) 
    48034803{ 
    48044804    Offset *offset = ALLOC(Offset); 
    48054805    offset->start = start; 
     
    52045204    int doc_num = dw->doc_num; 
    52055205    int i; 
    52065206    const int df_size = df->size; 
    5207     int start_offset = 0; 
     5207    off_t start_offset = 0; 
    52085208 
    52095209    if (fld_inv->is_tokenized) { 
    52105210        Token *tk;