embulk-output-bigobject 0.3.3 → 0.3.4
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 +4 -4
- data/embulk-output-bigobject.gemspec +1 -1
- data/lib/embulk/output/bigobject.rb +30 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e98e4ee288205d9e18ac9c3c4f22f29d01fcec5b
|
4
|
+
data.tar.gz: b3f2aba9a693ae919281242ba1cd5f17fd5d1808
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a08ac922777f9b2efb49695224eca2e7549c5efcc107caec26fcd484f7279f733559689bf261c7cf44aed1f58fd70201807adccceadce9cf4fd91b83cf47c4
|
7
|
+
data.tar.gz: b9f2004fbe397d06235b63f7633e6637dc46482c1d4868a484cc1aa3d7c8cc0faa98a4f5822871c9c76a032bb00605e60e667a5e110d9b5f1df6ff56bc7ddf83
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-output-bigobject"
|
4
|
-
spec.version = "0.3.
|
4
|
+
spec.version = "0.3.4"
|
5
5
|
spec.authors = ["Cheng-Ching Huang"]
|
6
6
|
spec.summary = "Bigobject output plugin for Embulk"
|
7
7
|
spec.description = "Dumps records to Bigobject."
|
@@ -18,6 +18,7 @@ module Embulk
|
|
18
18
|
"ncport" => config.param("ncport", :integer, :default => 9091), # integer, optional
|
19
19
|
"table" => config.param("table", :string), # string, required
|
20
20
|
"column_options" => config.param("column_options", :array, :default => []),
|
21
|
+
"payload_column_index" => config.param("payload_column_index", :integer, :default => nil),
|
21
22
|
}
|
22
23
|
|
23
24
|
task
|
@@ -44,7 +45,6 @@ module Embulk
|
|
44
45
|
if response["Status"] == 0 then # the table exists
|
45
46
|
Embulk.logger.debug { "#{response}" }
|
46
47
|
elsif response["Status"] == -11 then # the table does not exist
|
47
|
-
#response = rest_exec(task['rest_uri'], "#{create_botable_stmt("#{task['table']}",schema, task['co_map'])}")
|
48
48
|
response = rest_exec(task['rest_uri'], "#{create_botable_stmt("#{task['table']}",schema, task["column_options"])}")
|
49
49
|
if response["Status"] != 0 then
|
50
50
|
Embulk.logger.error { "#{response}" }
|
@@ -62,7 +62,7 @@ module Embulk
|
|
62
62
|
return next_config_diff
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def safe_io_write(buff)
|
66
66
|
@@io ||= create_shared_io
|
67
67
|
@@mutext ||= Mutex.new
|
68
68
|
@@mutext.synchronize do
|
@@ -97,22 +97,45 @@ module Embulk
|
|
97
97
|
def close
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
100
|
+
def add_csv(page)
|
101
101
|
data = Array.new
|
102
102
|
|
103
|
-
page.each do |
|
103
|
+
page.each do |record|
|
104
104
|
values = []
|
105
|
-
|
106
|
-
data.push "#{values.join(",")}"
|
105
|
+
record.each do |row| values << "\"#{row.to_s.gsub(/\"/,"\"\"")}\"" end
|
106
|
+
data.push "#{values.join(",")}\n"
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
safe_io_write "#{data.join}"
|
110
110
|
|
111
111
|
@counter += data.length
|
112
112
|
@task['ttl_counter'] += data.length
|
113
113
|
|
114
114
|
end
|
115
115
|
|
116
|
+
def add_payload(page)
|
117
|
+
data = Array.new
|
118
|
+
pindex = @task['payload_column_index']
|
119
|
+
|
120
|
+
page.each do |record|
|
121
|
+
data.push "#{record[pindex]}\n"
|
122
|
+
end
|
123
|
+
|
124
|
+
safe_io_write "#{data.join}"
|
125
|
+
|
126
|
+
@counter += data.length
|
127
|
+
@task['ttl_counter'] += data.length
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
def add(page)
|
132
|
+
if (@task['payload_column_index'])
|
133
|
+
add_payload(page)
|
134
|
+
else
|
135
|
+
add_csv(page)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
116
139
|
def finish
|
117
140
|
end
|
118
141
|
|