red-arrow-activerecord 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5ac5974438fd59eeab35b60221680f207c80acfc
4
- data.tar.gz: 3bac786c5c9058ad3fcac6bbdaff8e6b3f2ff731
2
+ SHA256:
3
+ metadata.gz: 6e3ce2d50d09a561409312f1a6d46b9be1764028c7502b036147f8be00c1b5ce
4
+ data.tar.gz: e4a5aa2ccbcf04142b9e798e5363813476b42982154dfcc5b1ca259d975de5ab
5
5
  SHA512:
6
- metadata.gz: c5c20bb8254c395ea9eafafcf9996e7dac7df8110c49685211fec1edecd82299f2de96c20d67f0f62c339e5e153c255be8e1e09349413891f0fc327422c2bb5d
7
- data.tar.gz: e39eb1ea4ec0914dc0360b81c81b0b89ec9c848b2eafd3151574bf442795c24c138387fc91248c3df68ebdff823cd4504bb4165ac98b9ee203dfd2a10701094b
6
+ metadata.gz: b345fbf7fa5523565b991570bf09ea174be478e4b47644e0377c767380c6c27532ae4e2ad85e9587dccb7bbf48ad1eadd2b11e2c093e14ad81d91cb54300adbe
7
+ data.tar.gz: 752ec4e82b12c9f599fd02a1ea6b58204a4d7de22b7cf09b502bf7c183e3a55ddeaa74db73d02d3d07e49f6d02cf50fb4fe7f7c93f4835cba0ab8284f2bb8d5f
@@ -1,5 +1,18 @@
1
1
  # News
2
2
 
3
+ ## 0.1.1 - 2019-02-02
4
+
5
+ ### Improvements
6
+
7
+ * Suppressed a warning.
8
+ [GitHub#3][Patch by Yasuo Honda]
9
+
10
+ * Changed to use Red Arrow 0.12.0 or later.
11
+
12
+ ### Thanks
13
+
14
+ * Yasuo Honda
15
+
3
16
  ## 0.1.0 - 2018-02-05
4
17
 
5
18
  Initial release!!!
@@ -7,34 +7,23 @@ module ArrowActiveRecord
7
7
  target_column_names = column_names if select_values.empty?
8
8
 
9
9
  fields = []
10
- data_types = []
11
10
  target_column_names.each do |name|
12
11
  name = name.to_s
13
12
  target_column = columns.find do |column|
14
13
  column.name == name
15
14
  end
16
- arrow_data_type = extract_arrow_data_type(target_column)
17
- fields << Arrow::Field.new(name, arrow_data_type)
18
- data_types << arrow_data_type
15
+ fields << {name: name, data_type: extract_arrow_data_type(target_column)}
19
16
  end
20
17
  schema = Arrow::Schema.new(fields)
21
18
 
22
- arrow_array_batches = data_types.collect do
23
- []
24
- end
19
+ record_batches = []
20
+ record_batch_builder = Arrow::RecordBatchBuilder.new(schema)
25
21
  in_batches(of: batch_size).each do |relation|
26
- column_values_set = relation.pluck(*target_column_names).transpose
27
- data_types.each_with_index do |data_type, i|
28
- column_values = column_values_set[i]
29
- arrow_array_batches[i] << build_arrow_array(column_values, data_type)
30
- end
31
- end
32
- columns = fields.collect.with_index do |field, i|
33
- chunked_array = Arrow::ChunkedArray.new(arrow_array_batches[i])
34
- Arrow::Column.new(field, chunked_array)
22
+ records = relation.pluck(*target_column_names)
23
+ record_batch_builder.append(records)
24
+ record_batches << record_batch_builder.flush
35
25
  end
36
-
37
- Arrow::Table.new(schema, columns)
26
+ Arrow::Table.new(schema, record_batches)
38
27
  end
39
28
 
40
29
  private
@@ -49,56 +38,30 @@ module ArrowActiveRecord
49
38
  end
50
39
  case type
51
40
  when :bigint
52
- Arrow::Int64DataType.new
41
+ :int64
53
42
  when :binary
54
- Arrow::BinaryDataType.new
43
+ :binary
55
44
  when :boolean
56
- Arrow::BooleanDataType.new
45
+ :boolean
57
46
  when :date
58
- Arrow::Date32DataType.new
47
+ :date32
59
48
  when :datetime
60
- Arrow::TimestampDataType.new(:nano)
61
- # when :decimal
49
+ [:timestamp, :nano]
50
+ when :decimal
51
+ [:decimal128, type.precision, type.scale]
62
52
  when :float
63
- Arrow::FloatDataType.new
53
+ :float
64
54
  when :integer
65
- Arrow::Int32DataType.new
55
+ :int32
66
56
  # when :json
67
57
  when :string, :text
68
- Arrow::StringDataType.new
58
+ :string
69
59
  when :time, :timestamp
70
- Arrow::TimestampDataType.new(:nano)
71
- when :timestamp
72
- Arrow::TimestampDataType.new(:nano)
60
+ [:timestamp, :nano]
73
61
  else
74
62
  message = "unsupported data type: #{type}: #{column.inspect}"
75
63
  raise NotImplementedError, message
76
64
  end
77
65
  end
78
-
79
- def build_arrow_array(column_values, data_type)
80
- case data_type
81
- when Arrow::Int64DataType
82
- Arrow::Int64Array.new(column_values)
83
- when Arrow::BinaryDataType
84
- Arrow::BinaryArray.new(column_values)
85
- when Arrow::BooleanDataType
86
- Arrow::BooleanArray.new(column_values)
87
- when Arrow::Date32DataType
88
- Arrow::Date32Array.new(column_values)
89
- when Arrow::TimestampDataType
90
- builder = Arrow::TimestampArrayBuilder.new(data_type)
91
- builder.build(column_values)
92
- when Arrow::FloatDataType
93
- Arrow::FloatArray.new(column_values)
94
- when Arrow::Int32DataType
95
- Arrow::Int32Array.new(column_values)
96
- when Arrow::StringDataType
97
- Arrow::StringArray.new(column_values)
98
- else
99
- message = "unsupported data type: #{data_type.inspect}"
100
- raise NotImplementedError, message
101
- end
102
- end
103
66
  end
104
67
  end
@@ -1,3 +1,3 @@
1
1
  module ArrowActiverecord
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-arrow-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hatappi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-04 00:00:00.000000000 Z
12
+ date: 2019-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: 0.12.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: 0.12.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.5.2.2
132
+ rubygems_version: 2.7.6
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: A library that provides conversion method between Apache Arrow and ActiveRecord