Sha256: bfd488107928efccfec07e75a9e91edee93617da897f104bf97c9511039f5ef2

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module WisconsinBenchmark
  # Arrow::Table generator
  class TableGenerator
    # Create Scaled Wisconsin Benchmark dataset object.
    #
    # @return size [Integer] number of tuples.
    #
    def initialize(size)
      @size = size
      @array = WisconsinBenchmark::ArrayGenerator.new(size)
    end

    attr_reader :table, :size, :array

    # Generate Scaled Wisconsin Benchmark dataset in Arrow::Table.
    #
    # @return [Arrow::Table] generated dataset in Arrow::Table.
    #
    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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wisconsin-benchmark-0.1.0 lib/wisconsin-benchmark/table_generator.rb