Class: Parqueteur::ColumnCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/parqueteur/column_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeColumnCollection

Returns a new instance of ColumnCollection.



9
10
11
12
13
# File 'lib/parqueteur/column_collection.rb', line 9

def initialize
  @columns = []
  @column_names = []
  @columns_idx = {}
end

Instance Attribute Details

#column_namesObject (readonly)

Returns the value of attribute column_names.



7
8
9
# File 'lib/parqueteur/column_collection.rb', line 7

def column_names
  @column_names
end

Instance Method Details

#add(column) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/parqueteur/column_collection.rb', line 23

def add(column)
  unless @columns_idx.key?(column.name)
    @columns_idx[column.name] = column
    @columns << column
    @column_names << column.name
  end

  true
end

#arrow_schemaObject



37
38
39
# File 'lib/parqueteur/column_collection.rb', line 37

def arrow_schema
  @arrow_schema ||= Arrow::Schema.new(@columns.collect(&:to_arrow_field))
end

#each(&block) ⇒ Object



19
20
21
# File 'lib/parqueteur/column_collection.rb', line 19

def each(&block)
  @columns.each(&block)
end

#find(name) ⇒ Object



33
34
35
# File 'lib/parqueteur/column_collection.rb', line 33

def find(name)
  @columns_idx.fetch(name, nil)
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/parqueteur/column_collection.rb', line 15

def key?(key)
  @columns_idx.key?(key)
end