Skip to content
This repository
tag: v3.5.4
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 71 lines (65 sloc) 1.849 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
module Picky

  # A Bundle is a number of indexes
  # per [index, category] combination.
  #
  # At most, there are three indexes:
  # * *core* index (always used)
  # * *weights* index (always used)
  # * *similarity* index (used with similarity)
  #
  # In Picky, indexing is separated from the index
  # handling itself through a parallel structure.
  #
  # Both use methods provided by this base class, but
  # have very different goals:
  #
  # * *Indexing*::*Bundle* is just concerned with creating index files
  # and providing helper functions to e.g. check the indexes.
  #
  # * *Index*::*Bundle* is concerned with loading these index files into
  # memory and looking up search data as fast as possible.
  #
  # This is the indexing bundle.
  #
  # It does all menial tasks that have nothing to do
  # with the actual index running etc.
  # (Find these in Indexed::Bundle)
  #
  class Bundle

    attr_reader :backend

    # When indexing, clear only clears the inverted index.
    #
    delegate :clear,
             :to => :inverted

    # Saves the indexes in a dump file.
    #
    def dump
      dump_inverted
      dump_similarity
      dump_weights
      dump_configuration
    end
    # Dumps the core index.
    #
    def dump_inverted
      @backend_inverted.dump @inverted
    end
    # Dumps the weights index.
    #
    def dump_weights
      # TODO THINK about this. Perhaps the strategies should implement the backend methods? Or only the internal index ones?
      #
      @backend_weights.dump @weights if @weights_strategy.saved?
    end
    # Dumps the similarity index.
    #
    def dump_similarity
      @backend_similarity.dump @similarity if @similarity_strategy.saved?
    end
    # Dumps the configuration.
    #
    def dump_configuration
      @backend_configuration.dump @configuration
    end

  end

end
Something went wrong with that request. Please try again.