Class: RubySnowflake::Result

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruby_snowflake/result.rb

Direct Known Subclasses

StreamingResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(partition_count, row_type_data) ⇒ Result

Returns a new instance of Result.



13
14
15
16
# File 'lib/ruby_snowflake/result.rb', line 13

def initialize(partition_count, row_type_data)
  @data = Concurrent::Array.new(partition_count)
  (row_type_data)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/ruby_snowflake/result.rb', line 11

def data
  @data
end

Instance Method Details

#[]=(index, value) ⇒ Object



18
19
20
# File 'lib/ruby_snowflake/result.rb', line 18

def []=(index, value)
  data[index] = value
end

#columnsObject



50
51
52
# File 'lib/ruby_snowflake/result.rb', line 50

def columns
  @row_types.map {|type| type[:name].downcase }
end

#eachObject



26
27
28
29
30
31
32
33
34
# File 'lib/ruby_snowflake/result.rb', line 26

def each
  return to_enum(:each) unless block_given?

  data.each do |partition|
    partition.each do |row|
      yield wrap_row(row)
    end
  end
end

#firstObject



42
43
44
# File 'lib/ruby_snowflake/result.rb', line 42

def first
  wrap_row(data.first.first)
end

#get_all_rowsObject



22
23
24
# File 'lib/ruby_snowflake/result.rb', line 22

def get_all_rows
  map(&:to_h)
end

#lastObject



46
47
48
# File 'lib/ruby_snowflake/result.rb', line 46

def last
  wrap_row(data.last.last)
end

#sizeObject Also known as: length



36
37
38
# File 'lib/ruby_snowflake/result.rb', line 36

def size
  data.map(&:size).sum
end