Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ Rewrote file backend to use the memory backend with the weights index

  • Loading branch information...
commit a5015c299497d0f66bdc0d45cad26da158c1b0e7 1 parent ed3c930
@floere authored
View
1  server/lib/picky.rb
@@ -25,6 +25,7 @@ class << self
require 'active_support/multibyte'
require 'multi_json'
require 'rack_fast_escape' if defined? Rack
+ require 'fileutils'
# Check if platform specific modifiers need to be installed.
#
View
8 server/lib/picky/backends/backend.rb
@@ -9,6 +9,8 @@ class Backend
# This is the default behaviour and should be overridden
# for different backends.
#
+ # TODO Push down.
+ #
# Returns an object that on #initial, #load returns
# an object that responds to:
@@ -21,9 +23,9 @@ def create_inverted bundle
# an object that responds to:
# [:token] # => 1.23 (a weight)
#
- def create_weights bundle
- json bundle.index_path(:weights)
- end
+ # def create_weights bundle
+ # json bundle.index_path(:weights)
+ # end
# # Returns an object that on #initial, #load returns
# # an object that responds to:
# # [:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
View
9 server/lib/picky/backends/file.rb
@@ -9,10 +9,11 @@ module Backends
# ...[1,2,3,21,7,4,13,15]...
#
class File < Backend
-
- # Returns an object that on #initial, #load returns an object that responds to:
- # [:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
- #
+
+ def create_weights bundle
+ Memory::JSON.new bundle.index_path(:weights)
+ end
+
def create_similarity bundle
json bundle.index_path(:similarity)
end
View
2  server/lib/picky/backends/file/basic.rb
@@ -27,7 +27,7 @@ def initialize cache_path, options = {}
# This is the mapping file with the in-memory hash for the
# file position/offset mappings.
#
- @mapping_file = Memory::JSON.new "#{cache_path}.file_mapping.#{extension}"
+ @mapping_file = Memory::JSON.new "#{cache_path}.file_mapping"
@empty = options[:empty]
@initial = options[:initial]
View
2  server/lib/picky/backends/file/json.rb
@@ -65,7 +65,7 @@ def load
def dump hash
offset = 0
mapping = {}
-
+
create_directory cache_path
::File.open(cache_path, 'w:utf-8') do |out_file|
hash.each do |(key, object)|
View
8 server/lib/picky/backends/memory.rb
@@ -4,10 +4,10 @@ module Backends
class Memory < Backend
- # Returns an object that on #initial, #load returns
- # an object that responds to:
- # [:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
- #
+ def create_weights bundle
+ JSON.new bundle.index_path(:weights)
+ end
+
def create_similarity bundle
Marshal.new bundle.index_path(:similarity)
end
View
2  server/lib/picky/backends/redis.rb
@@ -14,7 +14,7 @@ def initialize options = {}
check_hiredis_gem
check_redis_gem
- @client = options[:client] || ::Redis.new(:db => (options[:db] || 15))
+ @client = options[:client] || ::Redis.new(:db => (options[:db] || 15))
@realtime = options[:realtime]
end
def maybe_load_hiredis
Please sign in to comment.
Something went wrong with that request. Please try again.