Module: Segment::RangeIndex
- Defined in:
- lib/rbbt/segment/range_index.rb
Instance Attribute Summary collapse
-
#corpus ⇒ Object
Returns the value of attribute corpus.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#corpus ⇒ Object
Returns the value of attribute corpus.
2 3 4 |
# File 'lib/rbbt/segment/range_index.rb', line 2 def corpus @corpus end |
Class Method Details
.index(segments, corpus = nil, persist_file = :memory) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbbt/segment/range_index.rb', line 9 def self.index(segments, corpus = nil, persist_file = :memory) segments = segments.values.flatten if Hash === segments annotation_index = Persist.persist("Segment_index", :fwt, :persist => (! (persist_file.nil? or persist_file == :memory)), :file => persist_file) do value_size = 0 index_data = segments.collect{|segment| next if segment.offset.nil? range = segment.range value_size = [segment.segid.length, value_size].max [segment.segid, [range.begin, range.end]] }.compact fwt = FixWidthTable.get :memory, value_size, true fwt.add_range index_data fwt end annotation_index.extend Segment::RangeIndex annotation_index.corpus = corpus annotation_index end |
Instance Method Details
#[](*args) ⇒ Object
4 5 6 7 |
# File 'lib/rbbt/segment/range_index.rb', line 4 def [](*args) res = super(*args) SegID.setup(res, :corpus => corpus) end |