]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow-dataset/lib/arrow-dataset/arrow-table-loadable.rb
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
19 module ArrowTableLoadable
22 absolute_path
= ::File.expand_path(path
)
23 if absolute_path
.start_with
?("/")
24 URI("file://#{absolute_path}")
26 URI("file:///#{absolute_path}")
30 def load_from_directory
31 internal_load_from_uri(path_to_uri(@input))
35 internal_load_from_uri(@input)
38 def internal_load_from_uri(uri
)
39 format
= FileFormat
.resolve(@options[:format])
40 dataset
= FileSystemDataset
.build(format
) do |factory
|
41 factory
.file_system_uri
= uri
43 scanner_builder
= dataset
.begin_scan
44 @options.each
do |key
, value
|
45 next if key
== :format
48 next unless scanner_builder
.respond_to
?(setter
)
49 scanner_builder
.public_send(setter
, value
)
51 scanner
= scanner_builder
.finish
59 include ArrowDataset
::ArrowTableLoadable