Sha256: 8a8d14839781a1f850bf6d685c8df718188f67780572fdcb000cb85a72ec09e7

Contents?: true

Size: 1.68 KB

Versions: 9

Compression:

Stored size: 1.68 KB

Contents

module Picky

  module Backends

    class SQLite < Backend

      attr_reader :realtime

      def initialize options = {}
        @realtime = options[:realtime]

        require 'sqlite3'
      rescue LoadError => e
        warn_gem_missing 'sqlite3', 'SQLite bindings'
      end

      # Returns an object that on #initial, #load returns an object that responds to:
      #   [:token] # => [id, id, id, id, id] (an array of ids)
      #
      def create_inverted bundle, _ = nil
        StringKeyArray.new bundle.index_path(:inverted), realtime: realtime
      end
      # Returns an object that on #initial, #load returns an object that responds to:
      #   [:token] # => 1.23 (a weight)
      #
      def create_weights bundle, _ = nil
        Value.new bundle.index_path(:weights), realtime: realtime
      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)
      #
      def create_similarity bundle, _ = nil
        StringKeyArray.new bundle.index_path(:similarity), realtime: realtime
      end
      # Returns an object that on #initial, #load returns an object that responds to:
      #   [:key] # => value (a value for this config key)
      #
      def create_configuration bundle, _ = nil
        Value.new bundle.index_path(:configuration), realtime: realtime
      end
      # Returns an object that on #initial, #load returns an object that responds to:
      #   [id] # => [:sym1, :sym2]
      #
      def create_realtime bundle, _ = nil
        IntegerKeyArray.new bundle.index_path(:realtime), realtime: realtime
      end

    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
picky-4.31.3 lib/picky/backends/sqlite.rb
picky-4.31.2 lib/picky/backends/sqlite.rb
picky-4.31.1 lib/picky/backends/sqlite.rb
picky-4.31.0 lib/picky/backends/sqlite.rb
picky-4.30.0 lib/picky/backends/sqlite.rb
picky-4.29.0 lib/picky/backends/sqlite.rb
picky-4.28.1 lib/picky/backends/sqlite.rb
picky-4.27.1 lib/picky/backends/sqlite.rb
picky-4.27.0 lib/picky/backends/sqlite.rb