red-adbc 0.11.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97bc5368186dbbb7e3f23357bba96d58ab2401e3c37a6cf2bcd039b9880875a7
4
- data.tar.gz: b3e8197a27f928f8e29cd617928a2eccc2ac08717244f8395b055440d730a7ac
3
+ metadata.gz: b3e38661bb51d363808e530520d34e2db0c9ee10760e3131a3fc29ce8d24603c
4
+ data.tar.gz: bfa56ab21c18d1d415c80b1f702f74a8b65b249e414ae81fe175ac32fa1668d4
5
5
  SHA512:
6
- metadata.gz: 03f0422fea96fed1cb60caa6b5757b8744aab4c2c19e6a75b1c76fbdd6890baabb9df438cd1f1903472001029755e25ea90cd06195fd043e0d5127ccb189d9a8
7
- data.tar.gz: d4bd60c141d0cb11cd4214f4189528214c2c4780fcb92a1c98f64d6bc87c178446f637dd4318e1567f761b49938751a86a79d7186056ab1b2fd0559c4315f177
6
+ metadata.gz: 227b2de351ca2a2470a87899255eb0d42f563549c556de83e79c5198f1591de5bb620c6f359c91061471bed5dcdb70a8fe2db3c5175eaadd490a5cda50098e9f
7
+ data.tar.gz: 640804850814b5bab21f6c3cc5f50b443104c79b15bbb440d271d78870bdec43f55f5739dc73aebb9cbf08577c512aa4466dfc7efab18edf08a9af34d69220a1
@@ -0,0 +1,36 @@
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
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
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
16
+ # under the License.
17
+
18
+ module ADBCArrow
19
+ class Connection
20
+ include ADBC::ConnectionOperations
21
+
22
+ def open_statement(&block)
23
+ Statement.open(self, &block)
24
+ end
25
+
26
+ alias_method :get_info_raw, :get_info
27
+ def get_info(codes)
28
+ reader = get_info_raw(codes)
29
+ begin
30
+ yield(reader.read_all)
31
+ ensure
32
+ reader.unref
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,56 @@
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
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
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
16
+ # under the License.
17
+
18
+ module ADBC
19
+ module ConnectionOperations
20
+ def query(sql, &block)
21
+ open_statement do |statement|
22
+ statement.query(sql, &block)
23
+ end
24
+ end
25
+
26
+ def ingest(table_name, values, mode: :create)
27
+ open_statment do |statement|
28
+ statement.ingest(table_name, values, mode: mode)
29
+ end
30
+ end
31
+
32
+ def info(codes=nil)
33
+ unless codes.nil?
34
+ codes = codes.collect do |code|
35
+ ADBC::Info.try_convert(code)
36
+ end
37
+ end
38
+ get_info(codes) do |table|
39
+ values = {}
40
+ table.raw_records.each do |code, value|
41
+ value = value.values[0] if value.is_a?(Hash)
42
+ code = ADBC::Info.try_convert(code)
43
+ values[code.nick.gsub("-", "_").to_sym] = value
44
+ end
45
+ values
46
+ end
47
+ end
48
+
49
+ ADBC::Info.values.each do |value|
50
+ name = value.nick.gsub("-", "_").to_sym
51
+ define_method(name) do
52
+ info([name])[name]
53
+ end
54
+ end
55
+ end
56
+ end
@@ -15,42 +15,23 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
+ require_relative "connection-operations"
19
+
18
20
  module ADBC
19
21
  class Connection
22
+ include ConnectionOperations
23
+
20
24
  def open_statement(&block)
21
25
  Statement.open(self, &block)
22
26
  end
23
27
 
24
- def query(sql, &block)
25
- open_statement do |statement|
26
- statement.query(sql, &block)
27
- end
28
- end
29
-
30
- def ingest(table_name, values, mode: :create)
31
- open_statment do |statement|
32
- statement.ingest(table_name, values, mode: mode)
33
- end
34
- end
35
-
36
- def info(codes=nil)
37
- unless codes.nil?
38
- codes = codes.collect do |code|
39
- ADBC::Info.try_convert(code)
40
- end
41
- end
42
- c_abi_array_stream = get_info(codes)
28
+ alias_method :get_info_raw, :get_info
29
+ def get_info(codes)
30
+ c_abi_array_stream = get_info_raw(codes)
43
31
  begin
44
32
  reader = Arrow::RecordBatchReader.import(c_abi_array_stream)
45
33
  begin
46
- table = reader.read_all
47
- values = {}
48
- table.raw_records.each do |code, value|
49
- value = value.values[0] if value.is_a?(Hash)
50
- code = ADBC::Info.try_convert(code)
51
- values[code.nick.gsub("-", "_").to_sym] = value
52
- end
53
- values
34
+ yield(reader.read_all)
54
35
  ensure
55
36
  reader.unref
56
37
  end
@@ -58,12 +39,5 @@ module ADBC
58
39
  GLib.free(c_abi_array_stream)
59
40
  end
60
41
  end
61
-
62
- ADBC::Info.values.each do |value|
63
- name = value.nick.gsub("-", "_").to_sym
64
- define_method(name) do
65
- info([name])[name]
66
- end
67
- end
68
42
  end
69
43
  end
data/lib/adbc/loader.rb CHANGED
@@ -58,6 +58,7 @@ module ADBCArrow
58
58
  end
59
59
 
60
60
  def require_libraries
61
+ require_relative "arrow-connection"
61
62
  require_relative "arrow-statement"
62
63
  end
63
64
  end
data/lib/adbc/version.rb CHANGED
@@ -16,7 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  module ADBC
19
- VERSION = "0.11.0"
19
+ VERSION = "1.0.0"
20
20
 
21
21
  module Version
22
22
  MAJOR, MINOR, MICRO, TAG = VERSION.split(".").collect(&:to_i)
data/lib/adbc.rb CHANGED
@@ -32,6 +32,10 @@ begin
32
32
  rescue GObjectIntrospection::RepositoryError
33
33
  else
34
34
  module ADBC
35
+ RawConnection = Connection
36
+ remove_const(:Connection)
37
+ Connection = ADBCArrow::Connection
38
+
35
39
  RawStatement = Statement
36
40
  remove_const(:Statement)
37
41
  Statement = ADBCArrow::Statement
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-adbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache Arrow Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-31 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: red-arrow
@@ -38,7 +38,9 @@ files:
38
38
  - README.md
39
39
  - dependency-check/Rakefile
40
40
  - lib/adbc.rb
41
+ - lib/adbc/arrow-connection.rb
41
42
  - lib/adbc/arrow-statement.rb
43
+ - lib/adbc/connection-operations.rb
42
44
  - lib/adbc/connection.rb
43
45
  - lib/adbc/database.rb
44
46
  - lib/adbc/loader.rb