Class: WisconsinBenchmark::TableGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/wisconsin-benchmark/table_generator.rb

Overview

Arrow::Table generator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ TableGenerator

Create Scaled Wisconsin Benchmark dataset object.



8
9
10
11
# File 'lib/wisconsin-benchmark/table_generator.rb', line 8

def initialize(size)
  @size = size
  @array = WisconsinBenchmark::ArrayGenerator.new(size)
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



13
14
15
# File 'lib/wisconsin-benchmark/table_generator.rb', line 13

def array
  @array
end

#sizeObject (readonly)

Returns the value of attribute size.



13
14
15
# File 'lib/wisconsin-benchmark/table_generator.rb', line 13

def size
  @size
end

#tableObject (readonly)

Returns the value of attribute table.



13
14
15
# File 'lib/wisconsin-benchmark/table_generator.rb', line 13

def table
  @table
end

Instance Method Details

#generateArrow::Table

Generate Scaled Wisconsin Benchmark dataset in Arrow::Table.

Returns:

  • (Arrow::Table)

    generated dataset in Arrow::Table.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/wisconsin-benchmark/table_generator.rb', line 19

def generate
  unique1 = @array.unique1
  onePercent = unique1 % 100

  @table = Arrow::Table.new(
    [
      [:unique1,        unique1],
      [:unique2,        @array.unique2],
      [:two,            unique1 % 2],
      [:four,           unique1 % 4],
      [:ten,            unique1 % 10],
      [:twenty,         unique1 % 20],
      [:onePercent,     onePercent],
      [:tenPercent,     unique1 % 10],
      [:twentyPercent,  unique1 % 5],
      [:fiftyPercent,   unique1 % 2],
      [:unique3,        unique1],
      [:evenOnePercent, onePercent * 2],
      [:oddOnePercent,  (onePercent * 2) + 1],
      [:stringu1,       @array.stringu1],
      [:stringu2,       @array.stringu2],
      [:string4,        @array.string4],
    ]
  )
end

#inspectObject



45
46
47
# File 'lib/wisconsin-benchmark/table_generator.rb', line 45

def inspect
  "<#{self.class} (size=#{@size}, table=#{@table ? '#<Arrow::Table>' : 'nil'})>"
end