class Charty::TableAdapters::ArrowAdapter

Attributes

data[R]

Public Class Methods

new(data) click to toggle source
# File lib/charty/table_adapters/arrow_adapter.rb, line 10
def initialize(data)
  @data = data
  @column_names = @data.columns.map(&:name)
  self.columns = Index.new(@column_names)
  self.index = RangeIndex.new(0 ... length)
end
supported?(data) click to toggle source
# File lib/charty/table_adapters/arrow_adapter.rb, line 6
def self.supported?(data)
  defined?(Arrow::Table) && data.is_a?(Arrow::Table)
end

Public Instance Methods

[](row, column) click to toggle source
# File lib/charty/table_adapters/arrow_adapter.rb, line 36
def [](row, column)
  if row
    @data[column][row]
  else
    case column
    when Array
      Table.new(@data.select_columns(*column))
    else
      column_data = @data[column]
      Vector.new(column_data.data.combine,
                 index: index,
                 name: column_data.name)
    end
  end
end
column_length() click to toggle source
# File lib/charty/table_adapters/arrow_adapter.rb, line 23
def column_length
  @column_names.length
end
compare_data_equality(other) click to toggle source
Calls superclass method
# File lib/charty/table_adapters/arrow_adapter.rb, line 27
def compare_data_equality(other)
  case other
  when ArrowAdapter
    data == other.data
  else
    super
  end
end
length() click to toggle source
# File lib/charty/table_adapters/arrow_adapter.rb, line 19
def length
  @data.n_rows
end