Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ doc

  • Loading branch information...
commit 27bf3db693da89b1bcb210acd1598c21a56ba7be 1 parent 15f9690
@floere authored
View
14 server/lib/picky/backends/file.rb
@@ -5,20 +5,32 @@ module Backends
# Naive implementation of a file-based index.
# In-Memory Hash with length, offset:
# { :bla => [20, 312] }
- # That map to positions the File, encoded in JSON?:
+ # That map to positions the File, encoded in JSON:
# ...[1,2,3,21,7,4,13,15]...
#
class File < Backend
+ # Returns an object that responds to:
+ # [:token] => [id, id, id, id, id] # (an array of ids)
+ #
def create_inverted bundle
JSON.new bundle.index_path(:inverted)
end
+ # Returns an object that responds to:
+ # [:token] => 1.23 # (a weight)
+ #
def create_weights bundle
JSON.new bundle.index_path(:weights)
end
+ # Returns an object that responds to:
+ # [:encoded] => [:original, :original] # (an array of original symbols this similarity encoded thing maps to)
+ #
def create_similarity bundle
JSON.new bundle.index_path(:similarity)
end
+ # Returns an object that responds to:
+ # [:key] => value # (a value for this config key)
+ #
def create_configuration bundle
JSON.new bundle.index_path(:configuration)
end
View
12 server/lib/picky/backends/memory.rb
@@ -4,15 +4,27 @@ module Backends
class Memory < Backend
+ # Returns an object that responds to:
+ # [:token] => [id, id, id, id, id] # (an array of ids)
+ #
def create_inverted bundle
JSON.new bundle.index_path(:inverted)
end
+ # Returns an object that responds to:
+ # [:token] => 1.23 # (a weight)
+ #
def create_weights bundle
JSON.new bundle.index_path(:weights)
end
+ # Returns an object that responds to:
+ # [:encoded] => [:original, :original] # (an array of original symbols this similarity encoded thing maps to)
+ #
def create_similarity bundle
Marshal.new bundle.index_path(:similarity)
end
+ # Returns an object that responds to:
+ # [:key] => value # (a value for this config key)
+ #
def create_configuration bundle
JSON.new bundle.index_path(:configuration)
end
View
12 server/lib/picky/backends/redis.rb
@@ -12,15 +12,27 @@ def initialize options = {}
@client = options[:client] || ::Redis.new(:db => (options[:db] || 15))
end
+ # Returns an object that responds to:
+ # [:token] => [id, id, id, id, id] # (an array of ids)
+ #
def create_inverted bundle
List.new client, "#{bundle.identifier}:inverted"
end
+ # Returns an object that responds to:
+ # [:token] => 1.23 # (a weight)
+ #
def create_weights bundle
Float.new client, "#{bundle.identifier}:weights"
end
+ # Returns an object that responds to:
+ # [:encoded] => [:original, :original] # (an array of original symbols this similarity encoded thing maps to)
+ #
def create_similarity bundle
List.new client, "#{bundle.identifier}:similarity"
end
+ # Returns an object that responds to:
+ # [:key] => value # (a value for this config key)
+ #
def create_configuration bundle
String.new client, "#{bundle.identifier}:configuration"
end
Please sign in to comment.
Something went wrong with that request. Please try again.