Sha256: 06d4d19a56a31bf77bf9fab56962ad18594ebe46ac71d19a2ebfe8c527e2d18c

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

require "arrow/record-containable"

module Arrow
  class RecordBatch
    include RecordContainable
    include Enumerable

    class << self
      def new(*args)
        n_args = args.size
        case n_args
        when 2
          schema, data = args
          RecordBatchBuilder.build(schema, data)
        when 3
          super
        else
          message = "wrong number of arguments (given #{n_args}, expected 2..3)"
          raise ArgumentError, message
        end
      end
    end

    alias_method :each, :each_record

    alias_method :columns_raw, :columns
    def columns
      @columns ||= columns_raw
    end

    # Converts the record batch to {Arrow::Table}.
    #
    # @return [Arrow::Table]
    #
    # @since 0.12.0
    def to_table
      Table.new(schema, [self])
    end

    def respond_to_missing?(name, include_private)
      return true if find_column(name)
      super
    end

    def method_missing(name, *args, &block)
      if args.empty?
        column = find_column(name)
        return column if column
      end
      super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
red-arrow-0.14.1 lib/arrow/record-batch.rb
red-arrow-0.14.0 lib/arrow/record-batch.rb
red-arrow-0.13.0 lib/arrow/record-batch.rb
red-arrow-0.12.0 lib/arrow/record-batch.rb