Class: StrokeDB::InvertedListIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/strokedb/stores/inverted_list_file_storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage) ⇒ InvertedListIndex

Returns a new instance of InvertedListIndex.



61
62
63
64
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 61

def initialize(storage)
  @storage = storage
  @list = nil
end

Instance Attribute Details

#document_storeObject

Returns the value of attribute document_store.



60
61
62
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 60

def document_store
  @document_store
end

#storageObject

Returns the value of attribute storage.



60
61
62
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 60

def storage
  @storage
end

Instance Method Details

#delete(doc) ⇒ Object



82
83
84
85
86
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 82

def delete(doc)
  slots = indexable_slots_for_doc(doc)
  q = PointQuery.new(slots)
  list.delete(q.slots, doc.uuid)
end

#find(*args) ⇒ Object



70
71
72
73
74
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 70

def find(*args)
  find_uuids(*args).map do |uuid|
    @document_store.find(uuid)
  end
end

#find_uuids(*args) ⇒ Object



66
67
68
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 66

def find_uuids(*args)
  list.find(*args)
end

#insert(doc) ⇒ Object



76
77
78
79
80
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 76

def insert(doc)
  slots = indexable_slots_for_doc(doc)
  q = PointQuery.new(slots)
  list.insert(q.slots, doc.uuid)
end

#save!Object



88
89
90
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 88

def save!
  @storage.save!(list)
end