sip 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/LICENSE +674 -0
- data/README.rdoc +32 -0
- data/Rakefile +21 -0
- data/bin/sip +83 -0
- data/bin/transpart +114 -0
- data/docs/classes/Sip.html +169 -0
- data/docs/classes/Sip/CmdOpts.html +179 -0
- data/docs/classes/Sip/Config.html +362 -0
- data/docs/classes/Sip/DBBase.html +368 -0
- data/docs/classes/Sip/HadoopException.html +111 -0
- data/docs/classes/Sip/Hive.html +295 -0
- data/docs/classes/Sip/HiveQueryException.html +111 -0
- data/docs/classes/Sip/ImportScriptExecutionError.html +111 -0
- data/docs/classes/Sip/MySQLSipper.html +273 -0
- data/docs/classes/Sip/NoSuchColumn.html +111 -0
- data/docs/classes/Sip/NoSuchTable.html +111 -0
- data/docs/classes/Sip/PastFailureException.html +111 -0
- data/docs/classes/Sip/Sipper.html +454 -0
- data/docs/classes/Sip/UnsupportedDatabaseType.html +111 -0
- data/docs/classes/Sip/Utils.html +269 -0
- data/docs/classes/Struct.html +146 -0
- data/docs/created.rid +1 -0
- data/docs/files/README_rdoc.html +174 -0
- data/docs/files/lib/sip/cmdopts_rb.html +101 -0
- data/docs/files/lib/sip/config_rb.html +108 -0
- data/docs/files/lib/sip/databases/dbbase_rb.html +108 -0
- data/docs/files/lib/sip/databases/mysql_rb.html +108 -0
- data/docs/files/lib/sip/exceptions_rb.html +101 -0
- data/docs/files/lib/sip/extensions_rb.html +101 -0
- data/docs/files/lib/sip/hive_rb.html +101 -0
- data/docs/files/lib/sip/sipper_rb.html +101 -0
- data/docs/files/lib/sip/utils_rb.html +110 -0
- data/docs/files/lib/sip/version_rb.html +101 -0
- data/docs/files/lib/sip_rb.html +117 -0
- data/docs/fr_class_index.html +42 -0
- data/docs/fr_file_index.html +38 -0
- data/docs/fr_method_index.html +72 -0
- data/docs/index.html +24 -0
- data/docs/rdoc-style.css +208 -0
- data/lib/sip.rb +10 -0
- data/lib/sip/cmdopts.rb +20 -0
- data/lib/sip/config.rb +80 -0
- data/lib/sip/databases/dbbase.rb +56 -0
- data/lib/sip/databases/mysql.rb +52 -0
- data/lib/sip/exceptions.rb +9 -0
- data/lib/sip/extensions.rb +5 -0
- data/lib/sip/hive.rb +62 -0
- data/lib/sip/sipper.rb +118 -0
- data/lib/sip/templates/export.sh +73 -0
- data/lib/sip/utils.rb +58 -0
- data/lib/sip/version.rb +3 -0
- data/test/database_interaction_test.rb +7 -0
- data/test/hive_test.rb +28 -0
- data/test/sipper_test.rb +25 -0
- metadata +125 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Sip::HadoopException</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Sip::HadoopException</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/sip/exceptions_rb.html">
|
59
|
+
lib/sip/exceptions.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
StandardError
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
<!-- if includes -->
|
90
|
+
|
91
|
+
<div id="section">
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if method_list -->
|
101
|
+
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
<div id="validator-badges">
|
107
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</body>
|
111
|
+
</html>
|
@@ -0,0 +1,295 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: Sip::Hive</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Sip::Hive</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/sip/hive_rb.html">
|
59
|
+
lib/sip/hive.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
</div>
|
78
|
+
|
79
|
+
<div id="method-list">
|
80
|
+
<h3 class="section-bar">Methods</h3>
|
81
|
+
|
82
|
+
<div class="name-list">
|
83
|
+
<a href="#M000007">hdfs_ls</a>
|
84
|
+
<a href="#M000006">load_data_statements</a>
|
85
|
+
<a href="#M000003">run</a>
|
86
|
+
<a href="#M000004">run_file</a>
|
87
|
+
<a href="#M000002">run_hsql_create_table</a>
|
88
|
+
<a href="#M000005">run_import</a>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
<!-- if includes -->
|
96
|
+
|
97
|
+
<div id="section">
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<!-- if method_list -->
|
107
|
+
<div id="methods">
|
108
|
+
<h3 class="section-bar">Public Class methods</h3>
|
109
|
+
|
110
|
+
<div id="method-M000007" class="method-detail">
|
111
|
+
<a name="M000007"></a>
|
112
|
+
|
113
|
+
<div class="method-heading">
|
114
|
+
<a href="#M000007" class="method-signature">
|
115
|
+
<span class="method-name">hdfs_ls</span><span class="method-args">(location)</span>
|
116
|
+
</a>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
<div class="method-description">
|
120
|
+
<p><a class="source-toggle" href="#"
|
121
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
122
|
+
<div class="method-source-code" id="M000007-source">
|
123
|
+
<pre>
|
124
|
+
<span class="ruby-comment cmt"># File lib/sip/hive.rb, line 55</span>
|
125
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Hive</span>.<span class="ruby-identifier">hdfs_ls</span>(<span class="ruby-identifier">location</span>)
|
126
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-node">`#{ENV['HADOOP_HOME']}/bin/hadoop dfs -lsr hdfs://#{location}`</span>
|
127
|
+
<span class="ruby-identifier">lines</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"\n"</span>)
|
128
|
+
<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">shift</span>
|
129
|
+
<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">" "</span>).<span class="ruby-identifier">last</span> }
|
130
|
+
<span class="ruby-keyword kw">end</span>
|
131
|
+
</pre>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div id="method-M000006" class="method-detail">
|
137
|
+
<a name="M000006"></a>
|
138
|
+
|
139
|
+
<div class="method-heading">
|
140
|
+
<a href="#M000006" class="method-signature">
|
141
|
+
<span class="method-name">load_data_statements</span><span class="method-args">(tableconf, base_path)</span>
|
142
|
+
</a>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
<div class="method-description">
|
146
|
+
<p><a class="source-toggle" href="#"
|
147
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
148
|
+
<div class="method-source-code" id="M000006-source">
|
149
|
+
<pre>
|
150
|
+
<span class="ruby-comment cmt"># File lib/sip/hive.rb, line 43</span>
|
151
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_data_statements</span>(<span class="ruby-identifier">tableconf</span>, <span class="ruby-identifier">base_path</span>)
|
152
|
+
<span class="ruby-identifier">files</span> = <span class="ruby-constant">Hive</span>.<span class="ruby-identifier">hdfs_ls</span>(<span class="ruby-identifier">base_path</span>).<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-value">-5</span>, <span class="ruby-value">5</span>) <span class="ruby-operator">==</span> <span class="ruby-value str">'.part'</span> }
|
153
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tableconf</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-value str">'partition_by'</span>
|
154
|
+
<span class="ruby-identifier">files</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
|
155
|
+
<span class="ruby-identifier">partval</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>)[<span class="ruby-value">-2</span>]
|
156
|
+
<span class="ruby-node">"LOAD DATA INPATH '#{path}' INTO TABLE #{tableconf['hive_table_name']} PARTITION (#{tableconf['partition_by']}='#{partval}');"</span>
|
157
|
+
}
|
158
|
+
<span class="ruby-keyword kw">else</span>
|
159
|
+
[<span class="ruby-node">"LOAD DATA INPATH '#{base_path}' INTO TABLE #{tableconf['hive_table_name']};"</span>]
|
160
|
+
<span class="ruby-keyword kw">end</span>
|
161
|
+
<span class="ruby-keyword kw">end</span>
|
162
|
+
</pre>
|
163
|
+
</div>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div id="method-M000003" class="method-detail">
|
168
|
+
<a name="M000003"></a>
|
169
|
+
|
170
|
+
<div class="method-heading">
|
171
|
+
<a href="#M000003" class="method-signature">
|
172
|
+
<span class="method-name">run</span><span class="method-args">(sipper, query)</span>
|
173
|
+
</a>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
<div class="method-description">
|
177
|
+
<p><a class="source-toggle" href="#"
|
178
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
179
|
+
<div class="method-source-code" id="M000003-source">
|
180
|
+
<pre>
|
181
|
+
<span class="ruby-comment cmt"># File lib/sip/hive.rb, line 21</span>
|
182
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">sipper</span>, <span class="ruby-identifier">query</span>)
|
183
|
+
<span class="ruby-identifier">cmd</span> = <span class="ruby-node">"#{ENV['HIVE_HOME']}/bin/hive -S -e \"#{query}\""</span>
|
184
|
+
<span class="ruby-identifier">sipper</span>.<span class="ruby-identifier">log</span> <span class="ruby-node">"Running Hive command: #{cmd}"</span>
|
185
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">HiveQueryException</span>, <span class="ruby-node">"Could not execute hive command #{cmd}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">system</span>(<span class="ruby-identifier">cmd</span>)
|
186
|
+
<span class="ruby-keyword kw">end</span>
|
187
|
+
</pre>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
<div id="method-M000004" class="method-detail">
|
193
|
+
<a name="M000004"></a>
|
194
|
+
|
195
|
+
<div class="method-heading">
|
196
|
+
<a href="#M000004" class="method-signature">
|
197
|
+
<span class="method-name">run_file</span><span class="method-args">(sipper, path)</span>
|
198
|
+
</a>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
<div class="method-description">
|
202
|
+
<p><a class="source-toggle" href="#"
|
203
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
204
|
+
<div class="method-source-code" id="M000004-source">
|
205
|
+
<pre>
|
206
|
+
<span class="ruby-comment cmt"># File lib/sip/hive.rb, line 27</span>
|
207
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run_file</span>(<span class="ruby-identifier">sipper</span>, <span class="ruby-identifier">path</span>)
|
208
|
+
<span class="ruby-identifier">cmd</span> = <span class="ruby-node">"#{ENV['HIVE_HOME']}/bin/hive -S -f #{path}"</span>
|
209
|
+
<span class="ruby-identifier">sipper</span>.<span class="ruby-identifier">log</span> <span class="ruby-node">"Running Hive cmd: #{cmd}"</span>
|
210
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">HiveQueryException</span>, <span class="ruby-node">"Could not execute hive command #{cmd}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">system</span>(<span class="ruby-identifier">cmd</span>)
|
211
|
+
<span class="ruby-keyword kw">end</span>
|
212
|
+
</pre>
|
213
|
+
</div>
|
214
|
+
</div>
|
215
|
+
</div>
|
216
|
+
|
217
|
+
<div id="method-M000002" class="method-detail">
|
218
|
+
<a name="M000002"></a>
|
219
|
+
|
220
|
+
<div class="method-heading">
|
221
|
+
<a href="#M000002" class="method-signature">
|
222
|
+
<span class="method-name">run_hsql_create_table</span><span class="method-args">(sipper, db, tableconf, method)</span>
|
223
|
+
</a>
|
224
|
+
</div>
|
225
|
+
|
226
|
+
<div class="method-description">
|
227
|
+
<p><a class="source-toggle" href="#"
|
228
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
229
|
+
<div class="method-source-code" id="M000002-source">
|
230
|
+
<pre>
|
231
|
+
<span class="ruby-comment cmt"># File lib/sip/hive.rb, line 3</span>
|
232
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run_hsql_create_table</span>(<span class="ruby-identifier">sipper</span>, <span class="ruby-identifier">db</span>, <span class="ruby-identifier">tableconf</span>, <span class="ruby-identifier">method</span>)
|
233
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">method</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:overwrite</span>
|
234
|
+
<span class="ruby-constant">Hive</span>.<span class="ruby-identifier">run</span> <span class="ruby-identifier">sipper</span>, <span class="ruby-node">"DROP TABLE #{tableconf['hive_table_name']}"</span>
|
235
|
+
<span class="ruby-keyword kw">end</span>
|
236
|
+
|
237
|
+
<span class="ruby-identifier">partition</span> = <span class="ruby-value str">""</span>
|
238
|
+
<span class="ruby-identifier">cols</span> = <span class="ruby-identifier">db</span>.<span class="ruby-identifier">hive_columns</span> <span class="ruby-identifier">tableconf</span>[<span class="ruby-value str">'tablename'</span>]
|
239
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tableconf</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-value str">'partition_by'</span>
|
240
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">cols</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> }.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">tableconf</span>[<span class="ruby-value str">'partition_by'</span>]
|
241
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">NoSuchColumn</span>, <span class="ruby-node">"Column to parition by '#{tableconf['partition_by']}' not found in table '#{tableconf['tablename']}'"</span>
|
242
|
+
<span class="ruby-keyword kw">end</span>
|
243
|
+
<span class="ruby-identifier">partition_type</span> = <span class="ruby-identifier">cols</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">tableconf</span>[<span class="ruby-value str">'partition_by'</span>] }.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">first</span>
|
244
|
+
<span class="ruby-identifier">partition</span> = <span class="ruby-node">"PARTITIONED BY (#{tableconf['partition_by']} #{partition_type})"</span>
|
245
|
+
<span class="ruby-keyword kw">end</span>
|
246
|
+
<span class="ruby-identifier">colstring</span> = <span class="ruby-identifier">cols</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">tableconf</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value str">'partition_by'</span>, <span class="ruby-keyword kw">nil</span>) }.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{k} #{v}"</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">", "</span>)
|
247
|
+
<span class="ruby-constant">Hive</span>.<span class="ruby-identifier">run</span> <span class="ruby-identifier">sipper</span>, <span class="ruby-node">"CREATE TABLE IF NOT EXISTS #{tableconf['hive_table_name']} (#{colstring}) #{partition}"</span>
|
248
|
+
<span class="ruby-keyword kw">end</span>
|
249
|
+
</pre>
|
250
|
+
</div>
|
251
|
+
</div>
|
252
|
+
</div>
|
253
|
+
|
254
|
+
<div id="method-M000005" class="method-detail">
|
255
|
+
<a name="M000005"></a>
|
256
|
+
|
257
|
+
<div class="method-heading">
|
258
|
+
<a href="#M000005" class="method-signature">
|
259
|
+
<span class="method-name">run_import</span><span class="method-args">(sipper, tableconf)</span>
|
260
|
+
</a>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div class="method-description">
|
264
|
+
<p><a class="source-toggle" href="#"
|
265
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
266
|
+
<div class="method-source-code" id="M000005-source">
|
267
|
+
<pre>
|
268
|
+
<span class="ruby-comment cmt"># File lib/sip/hive.rb, line 33</span>
|
269
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run_import</span>(<span class="ruby-identifier">sipper</span>, <span class="ruby-identifier">tableconf</span>)
|
270
|
+
<span class="ruby-identifier">base_path</span> = <span class="ruby-node">"#{sipper.config['hdfs_tmpdir']}/#{tableconf['hive_table_name']}"</span>
|
271
|
+
<span class="ruby-identifier">stmts</span> = <span class="ruby-constant">Hive</span>.<span class="ruby-identifier">load_data_statements</span> <span class="ruby-identifier">tableconf</span>, <span class="ruby-identifier">base_path</span>
|
272
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">sipper</span>.<span class="ruby-identifier">config</span>[<span class="ruby-value str">'tmpdir'</span>], <span class="ruby-value str">'scripts'</span>, <span class="ruby-value str">'hive_import.hql'</span>)
|
273
|
+
<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
274
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">stmts</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
275
|
+
}
|
276
|
+
<span class="ruby-constant">Hive</span>.<span class="ruby-identifier">run_file</span> <span class="ruby-identifier">sipper</span>, <span class="ruby-identifier">path</span>
|
277
|
+
<span class="ruby-keyword kw">end</span>
|
278
|
+
</pre>
|
279
|
+
</div>
|
280
|
+
</div>
|
281
|
+
</div>
|
282
|
+
|
283
|
+
|
284
|
+
</div>
|
285
|
+
|
286
|
+
|
287
|
+
</div>
|
288
|
+
|
289
|
+
|
290
|
+
<div id="validator-badges">
|
291
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
292
|
+
</div>
|
293
|
+
|
294
|
+
</body>
|
295
|
+
</html>
|
@@ -0,0 +1,111 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Sip::HiveQueryException</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Sip::HiveQueryException</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/sip/exceptions_rb.html">
|
59
|
+
lib/sip/exceptions.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
StandardError
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
<!-- if includes -->
|
90
|
+
|
91
|
+
<div id="section">
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if method_list -->
|
101
|
+
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
<div id="validator-badges">
|
107
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</body>
|
111
|
+
</html>
|