Class: Traject::MockWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/traject/mock_writer.rb

Overview

A writer for Traject::Indexer, that just writes out all the output as serialized text with #puts.

Should be thread-safe (ie, multiple worker threads can be calling #put concurrently), by wrapping write to actual output file in a mutex synchronize. This does not seem to effect performance much, as far as I could tell benchmarking.

Output will be sent to settings string path, or else settings (ruby IO object), or else stdout.

This class can be sub-classed to write out different serialized reprentations – subclasses will just override the #serialize method. For instance, see JsonWriter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argSettings) ⇒ MockWriter

Returns a new instance of MockWriter.



18
19
# File 'lib/traject/mock_writer.rb', line 18

def initialize(argSettings)
end

Instance Attribute Details

#settingsObject (readonly)

Returns the value of attribute settings.



16
17
18
# File 'lib/traject/mock_writer.rb', line 16

def settings
  @settings
end

Instance Method Details

#closeObject



30
31
32
# File 'lib/traject/mock_writer.rb', line 30

def close
  # null
end

#put(context) ⇒ Object



26
27
28
# File 'lib/traject/mock_writer.rb', line 26

def put(context)
  # null
end

#serialize(context) ⇒ Object



22
23
24
# File 'lib/traject/mock_writer.rb', line 22

def serialize(context)
  # null
end