Sha256: b962ae228cce3bdadee329c140f402c920317de3f7abc6d922a215be263301be
Contents?: true
Size: 1.62 KB
Versions: 31
Compression:
Stored size: 1.62 KB
Contents
# encoding: utf-8 # This writer collects index change requests but does not submit them immediately to the database. # The index changes are applied when the commit method is called. # This writer is intended for internal use only. Do not use it in a xapian configuration! # @author Gernot Kogler module XapianDb module IndexWriters class TransactionalWriter attr_reader :index_requests, :delete_requests # Constructor def initialize @index_requests = [] @delete_requests = [] end # Update an object in the index # @param [Object] obj An instance of a class with a blueprint configuration def index(obj, commit=false) @index_requests << obj end # Remove a document from the index # @param [String] xapian_id The document id def delete_doc_with(xapian_id, commit=false) @delete_requests << xapian_id end # Reindex all objects of a given class # @param [Class] klass The class to reindex # @param [Hash] options Options for reindexing # @option options [Boolean] :verbose (false) Should the reindexing give status informations? def reindex_class(klass, options={}) raise "rebuild_xapian_index is not supported in transactions" end # Commit all pending changes to the database # @param [DirectWriter, BeanstalkWriter] writer The writer to use def commit_using(writer) @index_requests.each { |obj| writer.index obj, false } @delete_requests.each { |xapian_id| writer.delete_doc_with xapian_id, false } XapianDb.database.commit end end end end
Version data entries
31 entries across 31 versions & 1 rubygems