class RBHive::ResultSet
Public Class Methods
new(rows, schema)
click to toggle source
Calls superclass method
# File lib/rbhive/result_set.rb, line 3 def initialize(rows, schema) @schema = schema super(rows.map {|r| @schema.coerce_row(r) }) end
Public Instance Methods
as_arrays()
click to toggle source
# File lib/rbhive/result_set.rb, line 24 def as_arrays @as_arrays ||= self.map{ |r| @schema.coerce_row_to_array(r) } end
column_names()
click to toggle source
# File lib/rbhive/result_set.rb, line 8 def column_names @schema.column_names end
column_type_map()
click to toggle source
# File lib/rbhive/result_set.rb, line 12 def column_type_map @schema.column_type_map end
to_csv(out_file=nil)
click to toggle source
# File lib/rbhive/result_set.rb, line 16 def to_csv(out_file=nil) to_separated_output(",", out_file) end
to_tsv(out_file=nil)
click to toggle source
# File lib/rbhive/result_set.rb, line 20 def to_tsv(out_file=nil) to_separated_output("\t", out_file) end
Private Instance Methods
to_separated_output(sep, out_file)
click to toggle source
# File lib/rbhive/result_set.rb, line 30 def to_separated_output(sep, out_file) rows = self.map { |r| @schema.coerce_row_to_array(r).join(sep) } sv = rows.join("\n") return sv if out_file.nil? File.open(out_file, 'w+') { |f| f << sv } end