Class: Picky::Backends::Memory
- Defined in:
- lib/picky/backends/memory.rb,
lib/picky/backends/memory/json.rb,
lib/picky/backends/memory/basic.rb,
lib/picky/backends/memory/marshal.rb
Defined Under Namespace
Instance Method Summary collapse
-
#create_configuration(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to: object # => value (a value for this config key).
-
#create_inverted(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to: object # => [id, id, id, id, id] (an array of ids).
-
#create_realtime(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to: object # => [:sym1, :sym2].
-
#create_similarity(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to: object # => [:original, :original] (an array of original symbols this similarity encoded thing maps to).
-
#create_weights(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to: object # => 1.23 (a weight).
- #json(*args) ⇒ Object
Methods inherited from Backend
Instance Method Details
#create_configuration(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to:
object[:key] # => value (a value for this config key)
38 39 40 |
# File 'lib/picky/backends/memory.rb', line 38 def create_configuration bundle, hints = nil json bundle.index_path(:configuration), hash_for(hints) end |
#create_inverted(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to:
object[:token] # => [id, id, id, id, id] (an array of ids)
14 15 16 |
# File 'lib/picky/backends/memory.rb', line 14 def create_inverted bundle, hints = nil json bundle.index_path(:inverted), hash_for(hints) end |
#create_realtime(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to:
object[id] # => [:sym1, :sym2]
46 47 48 49 |
# File 'lib/picky/backends/memory.rb', line 46 def create_realtime bundle, hints = nil # GoogleHashSparseLongToRuby # FIXME This is only true on number keys (add Picky hints). json bundle.index_path(:realtime), hash_for(hints) end |
#create_similarity(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to:
object[:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
30 31 32 |
# File 'lib/picky/backends/memory.rb', line 30 def create_similarity bundle, hints = nil Marshal.new bundle.index_path(:similarity), hash_for(hints) end |
#create_weights(bundle, hints = nil) ⇒ Object
Returns an object that on #initial, #load returns an object that responds to:
object[:token] # => 1.23 (a weight)
22 23 24 |
# File 'lib/picky/backends/memory.rb', line 22 def create_weights bundle, hints = nil JSON.new bundle.index_path(:weights), hash_for(hints) # GoogleHashSparseRubyToInt (I wish they had floats) end |