Class: BSONOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo-hadoop/output.rb

Direct Known Subclasses

BSONKeyValueOutput

Instance Method Summary collapse

Constructor Details

#initialize(stream = nil) ⇒ BSONOutput

Returns a new instance of BSONOutput.



2
3
4
# File 'lib/mongo-hadoop/output.rb', line 2

def initialize(stream=nil)
  @stream = stream || $stdout
end

Instance Method Details

#write(doc) ⇒ Object



6
7
8
9
10
# File 'lib/mongo-hadoop/output.rb', line 6

def write(doc)
  bson_doc = BSON.serialize(doc)
  @stream.write(bson_doc)
  @stream.flush
end