Class: StrokeDB::InvertedListIndex

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage) ⇒ InvertedListIndex



4
5
6
7
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 4

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

Instance Attribute Details

#document_storeObject

Returns the value of attribute document_store.



3
4
5
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 3

def document_store
  @document_store
end

#storageObject

Returns the value of attribute storage.



3
4
5
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 3

def storage
  @storage
end

Instance Method Details

#delete(doc) ⇒ Object



25
26
27
28
29
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 25

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

#find(*args) ⇒ Object



13
14
15
16
17
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 13

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

#find_uuids(*args) ⇒ Object



9
10
11
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 9

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

#insert(doc) ⇒ Object



19
20
21
22
23
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 19

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

#save!Object



31
32
33
# File 'lib/stores/inverted_list_index/inverted_list_index.rb', line 31

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