Class: Stellr::Collections::Static

Inherits:
WriteableCollection show all
Defined in:
lib/stellr/collections/static.rb

Overview

Static collection implementation.

This kind of collection is for situations where your index usually doesn’t change but instead is rebuilt from scratch once in a while.

This collection keeps two indexes, one for searching, and one where all index modifications take place. Once you are finished building the new index, call the switch method to put it live. The old index is then dropped and the new one is used for searching from now on.

Direct Known Subclasses

RSync

Instance Attribute Summary

Attributes inherited from Base

#logger, #name

Instance Method Summary collapse

Methods inherited from WriteableCollection

#add_record, #add_records, #batch_finished, #clear!, #close, #delete_record, #dirty?, #flush, #optimize

Methods inherited from SearchableCollection

#close, #highlight, #on_shutdown, #search, #size

Methods inherited from Base

#batch_finished, #close, create, #on_shutdown

Methods included from Utils::Observable

#add_listener, #listeners, #notify_listeners

Methods included from Utils::Shutdown

#shutdown, #shutting_down?

Constructor Details

#initialize(name, options) ⇒ Static

Returns a new instance of Static.



15
16
17
18
19
# File 'lib/stellr/collections/static.rb', line 15

def initialize( name, options )
  super( name, options )
  reader
  writer
end

Instance Method Details

#switchObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/stellr/collections/static.rb', line 21

def switch
  @logger.info "switching indexes"
  @writer_monitor.synchronize do
    flush
    optimize
    close_writer
    @reader_monitor.synchronize do
      close_reader
      relink_indexes
      clear!
    end
  end
end