Sha256: a33707bfc2bc79247eb57da4ae13dad6b2d1619fb81a49c48ae65f60c5ebfddb

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Picky

  # Indexes indexing.
  #
  class Indexes

    instance_delegate :index,
                      :check,
                      :clear,
                      :backup,
                      :restore,
                      :index_for_tests,
                      :tokenizer

    each_delegate :check,
                  :clear,
                  :backup,
                  :restore,
                  :to => :indexes

    # Runs the indexers in parallel (prepare + cache).
    #
    def index randomly = true
      # Run in parallel.
      #
      timed_exclaim "Indexing using #{Cores.max_processors} processors, in #{randomly ? 'random' : 'given'} order."

      # Run indexing/caching forked.
      #
      Cores.forked self.indexes, { randomly: randomly }, &:index

      timed_exclaim "Indexing finished."
    end

    # For integration testing – indexes for the tests
    # without forking and shouting ;)
    #
    def index_for_tests
      indexes.each(&:index)
    end

    #
    #
    def tokenizer
      Tokenizer.index_default
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-3.1.0 lib/picky/indexes_indexing.rb