class MemDB
TODO: move to mem_db/index.rb
Constants
- VERSION
Public Class Methods
new(fields, index)
click to toggle source
# File lib/mem_db.rb, line 38 def initialize(fields, index) @fields = fields @index = index @entries = Entries.new end
Public Instance Methods
add(obj, value)
click to toggle source
# File lib/mem_db.rb, line 48 def add(obj, value) matching = @fields.new_matching(obj) entry_id = @entries.add(matching, value) @index.add(obj, entry_id) end
new_indexation()
click to toggle source
# File lib/mem_db.rb, line 44 def new_indexation MemDB::Indexation.new(self) end
query(query)
click to toggle source
# File lib/mem_db.rb, line 55 def query(query) checked = Set.new found = [] @index.query(query).each do |entry_id| next if checked.include?(entry_id) checked.add(entry_id) entry = @entries[entry_id] found.push(entry.value) if entry.matching.match?(query) end found end