module Persist::PKIAdapter
Attributes
Public Class Methods
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 10 def self.open(path, write, pattern, &pos_function) db = CONNECTIONS[path] ||= PackedIndex.new(path, write, pattern) db.extend Persist::PKIAdapter db.persistence_path = path db.pos_function = pos_function db end
Public Instance Methods
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 40 def [](key, clean = false) if TSV::ENTRY_KEYS.include? key metadata[key] else key = pos_function.call(key) if pos_function and not clean res = super(key) res.extend MultipleResult unless res.nil? res end end
Calls superclass method
Persist::TSVAdapter#[]
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 55 def []=(key, value) if TSV::ENTRY_KEYS.include? key set_metadata(key, value) else add key, value end end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 63 def add(key, value) key = pos_function.call(key) if pos_function if Numeric === key @_last ||= -1 skipped = key - @_last - 1 skipped.times do self.send(:<<, nil) end @_last = key end self.send(:<<, value) end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 76 def add_range_point(key, value) key = pos_function.call(key) if pos_function super(key, value) end
Calls superclass method
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 87 def each size.times do |i| yield i, value(i) end end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 81 def include?(i) return true if Numeric === i and i < size return true if metadata.include? i false end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 27 def metadata return {} unless File.exist? metadata_file Open.open(metadata_file, :mode => "rb") do |f| Marshal.load(f) end end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 23 def metadata_file @metadata_file ||= self.persistence_path + '.metadata' end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 18 def persistence_path=(value) @persistence_path = value @file = value end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 34 def set_metadata(k,v) metadata = self.metadata metadata[k] = v Misc.sensiblewrite(metadata_file, Marshal.dump(metadata)) end
Source
# File lib/rbbt/persist/tsv/packed_index.rb, line 51 def value(pos) self.send(:[], pos, true) end