sip 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/Gemfile +2 -0
  2. data/LICENSE +674 -0
  3. data/README.rdoc +32 -0
  4. data/Rakefile +21 -0
  5. data/bin/sip +83 -0
  6. data/bin/transpart +114 -0
  7. data/docs/classes/Sip.html +169 -0
  8. data/docs/classes/Sip/CmdOpts.html +179 -0
  9. data/docs/classes/Sip/Config.html +362 -0
  10. data/docs/classes/Sip/DBBase.html +368 -0
  11. data/docs/classes/Sip/HadoopException.html +111 -0
  12. data/docs/classes/Sip/Hive.html +295 -0
  13. data/docs/classes/Sip/HiveQueryException.html +111 -0
  14. data/docs/classes/Sip/ImportScriptExecutionError.html +111 -0
  15. data/docs/classes/Sip/MySQLSipper.html +273 -0
  16. data/docs/classes/Sip/NoSuchColumn.html +111 -0
  17. data/docs/classes/Sip/NoSuchTable.html +111 -0
  18. data/docs/classes/Sip/PastFailureException.html +111 -0
  19. data/docs/classes/Sip/Sipper.html +454 -0
  20. data/docs/classes/Sip/UnsupportedDatabaseType.html +111 -0
  21. data/docs/classes/Sip/Utils.html +269 -0
  22. data/docs/classes/Struct.html +146 -0
  23. data/docs/created.rid +1 -0
  24. data/docs/files/README_rdoc.html +174 -0
  25. data/docs/files/lib/sip/cmdopts_rb.html +101 -0
  26. data/docs/files/lib/sip/config_rb.html +108 -0
  27. data/docs/files/lib/sip/databases/dbbase_rb.html +108 -0
  28. data/docs/files/lib/sip/databases/mysql_rb.html +108 -0
  29. data/docs/files/lib/sip/exceptions_rb.html +101 -0
  30. data/docs/files/lib/sip/extensions_rb.html +101 -0
  31. data/docs/files/lib/sip/hive_rb.html +101 -0
  32. data/docs/files/lib/sip/sipper_rb.html +101 -0
  33. data/docs/files/lib/sip/utils_rb.html +110 -0
  34. data/docs/files/lib/sip/version_rb.html +101 -0
  35. data/docs/files/lib/sip_rb.html +117 -0
  36. data/docs/fr_class_index.html +42 -0
  37. data/docs/fr_file_index.html +38 -0
  38. data/docs/fr_method_index.html +72 -0
  39. data/docs/index.html +24 -0
  40. data/docs/rdoc-style.css +208 -0
  41. data/lib/sip.rb +10 -0
  42. data/lib/sip/cmdopts.rb +20 -0
  43. data/lib/sip/config.rb +80 -0
  44. data/lib/sip/databases/dbbase.rb +56 -0
  45. data/lib/sip/databases/mysql.rb +52 -0
  46. data/lib/sip/exceptions.rb +9 -0
  47. data/lib/sip/extensions.rb +5 -0
  48. data/lib/sip/hive.rb +62 -0
  49. data/lib/sip/sipper.rb +118 -0
  50. data/lib/sip/templates/export.sh +73 -0
  51. data/lib/sip/utils.rb +58 -0
  52. data/lib/sip/version.rb +3 -0
  53. data/test/database_interaction_test.rb +7 -0
  54. data/test/hive_test.rb +28 -0
  55. data/test/sipper_test.rb +25 -0
  56. metadata +125 -0
@@ -0,0 +1,362 @@
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::Config</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::Config</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/sip/config_rb.html">
59
+ lib/sip/config.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
+ Hash
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
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000016">dbconf</a>&nbsp;&nbsp;
90
+ <a href="#M000013">load_file</a>&nbsp;&nbsp;
91
+ <a href="#M000014">new</a>&nbsp;&nbsp;
92
+ <a href="#M000015">save_file</a>&nbsp;&nbsp;
93
+ <a href="#M000020">set_temp</a>&nbsp;&nbsp;
94
+ <a href="#M000018">store_database</a>&nbsp;&nbsp;
95
+ <a href="#M000019">store_table</a>&nbsp;&nbsp;
96
+ <a href="#M000017">tconf</a>&nbsp;&nbsp;
97
+ </div>
98
+ </div>
99
+
100
+ </div>
101
+
102
+
103
+ <!-- if includes -->
104
+
105
+ <div id="section">
106
+
107
+
108
+ <div id="constants-list">
109
+ <h3 class="section-bar">Constants</h3>
110
+
111
+ <div class="name-list">
112
+ <table summary="Constants">
113
+ <tr class="top-aligned-row context-row">
114
+ <td class="context-item-name">DBCONF_DEFAULT</td>
115
+ <td>=</td>
116
+ <td class="context-item-value">{ 'type' =&gt; 'mysql', 'host' =&gt; 'localhost', 'dbport' =&gt; nil</td>
117
+ </tr>
118
+ <tr class="top-aligned-row context-row">
119
+ <td class="context-item-name">TABLECONF_DEFAULT</td>
120
+ <td>=</td>
121
+ <td class="context-item-value">{ 'incremental_index' =&gt; 'id', 'method' =&gt; 'append', 'incremental_index_value' =&gt; 0, 'partition_by' =&gt; nil, 'columns' =&gt; nil</td>
122
+ </tr>
123
+ </table>
124
+ </div>
125
+ </div>
126
+
127
+
128
+
129
+
130
+
131
+
132
+ <!-- if method_list -->
133
+ <div id="methods">
134
+ <h3 class="section-bar">Public Class methods</h3>
135
+
136
+ <div id="method-M000013" class="method-detail">
137
+ <a name="M000013"></a>
138
+
139
+ <div class="method-heading">
140
+ <a href="#M000013" class="method-signature">
141
+ <span class="method-name">load_file</span><span class="method-args">(location)</span>
142
+ </a>
143
+ </div>
144
+
145
+ <div class="method-description">
146
+ <p><a class="source-toggle" href="#"
147
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
148
+ <div class="method-source-code" id="M000013-source">
149
+ <pre>
150
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 20</span>
151
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">location</span>)
152
+ <span class="ruby-constant">Config</span>.<span class="ruby-identifier">new</span> <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">location</span>)
153
+ <span class="ruby-keyword kw">end</span>
154
+ </pre>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <div id="method-M000014" class="method-detail">
160
+ <a name="M000014"></a>
161
+
162
+ <div class="method-heading">
163
+ <a href="#M000014" class="method-signature">
164
+ <span class="method-name">new</span><span class="method-args">(initial_values)</span>
165
+ </a>
166
+ </div>
167
+
168
+ <div class="method-description">
169
+ <p><a class="source-toggle" href="#"
170
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
171
+ <div class="method-source-code" id="M000014-source">
172
+ <pre>
173
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 24</span>
174
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">initial_values</span>)
175
+ <span class="ruby-comment cmt"># temp_keys are ones we'll delete before saving to a file</span>
176
+ <span class="ruby-ivar">@temp_keys</span> = []
177
+ <span class="ruby-identifier">merge!</span> <span class="ruby-identifier">initial_values</span>
178
+
179
+ <span class="ruby-comment cmt"># initialize defaults, including setting dbname and tablename ease of use keys</span>
180
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dbname</span>, <span class="ruby-identifier">dbconf</span><span class="ruby-operator">|</span>
181
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>] = <span class="ruby-constant">DBCONF_DEFAULT</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">dbconf</span>)
182
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>][<span class="ruby-value str">'dbname'</span>] = <span class="ruby-identifier">dbname</span>
183
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>][<span class="ruby-value str">'tables'</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">tablename</span>, <span class="ruby-identifier">tableconf</span><span class="ruby-operator">|</span>
184
+ <span class="ruby-identifier">tableconf</span> = {<span class="ruby-value str">'hive_table_name'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{dbname}_#{tablename}&quot;</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-constant">TABLECONF_DEFAULT</span>).<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">tableconf</span>)
185
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>][<span class="ruby-value str">'tables'</span>][<span class="ruby-identifier">tablename</span>] = <span class="ruby-identifier">tableconf</span>
186
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>][<span class="ruby-value str">'tables'</span>][<span class="ruby-identifier">tablename</span>][<span class="ruby-value str">'tablename'</span>] = <span class="ruby-identifier">tablename</span>
187
+ }
188
+ }
189
+ <span class="ruby-keyword kw">end</span>
190
+ </pre>
191
+ </div>
192
+ </div>
193
+ </div>
194
+
195
+ <h3 class="section-bar">Public Instance methods</h3>
196
+
197
+ <div id="method-M000016" class="method-detail">
198
+ <a name="M000016"></a>
199
+
200
+ <div class="method-heading">
201
+ <a href="#M000016" class="method-signature">
202
+ <span class="method-name">dbconf</span><span class="method-args">(dbname)</span>
203
+ </a>
204
+ </div>
205
+
206
+ <div class="method-description">
207
+ <p><a class="source-toggle" href="#"
208
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
209
+ <div class="method-source-code" id="M000016-source">
210
+ <pre>
211
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 57</span>
212
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dbconf</span>(<span class="ruby-identifier">dbname</span>)
213
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>]
214
+ <span class="ruby-keyword kw">end</span>
215
+ </pre>
216
+ </div>
217
+ </div>
218
+ </div>
219
+
220
+ <div id="method-M000015" class="method-detail">
221
+ <a name="M000015"></a>
222
+
223
+ <div class="method-heading">
224
+ <a href="#M000015" class="method-signature">
225
+ <span class="method-name">save_file</span><span class="method-args">(location)</span>
226
+ </a>
227
+ </div>
228
+
229
+ <div class="method-description">
230
+ <p><a class="source-toggle" href="#"
231
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
232
+ <div class="method-source-code" id="M000015-source">
233
+ <pre>
234
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 41</span>
235
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_file</span>(<span class="ruby-identifier">location</span>)
236
+ <span class="ruby-comment cmt"># remove unecessary dbname and tablename keys</span>
237
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dbname</span>, <span class="ruby-identifier">dbconf</span><span class="ruby-operator">|</span>
238
+ <span class="ruby-identifier">dbconf</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">'dbname'</span>
239
+ <span class="ruby-identifier">dbconf</span>[<span class="ruby-value str">'tables'</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">tablename</span>, <span class="ruby-identifier">tableconf</span><span class="ruby-operator">|</span>
240
+ <span class="ruby-identifier">tableconf</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">'tablename'</span>
241
+ }
242
+ }
243
+
244
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">location</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
245
+ <span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">merge</span> <span class="ruby-keyword kw">self</span>
246
+ <span class="ruby-ivar">@temp_keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">k</span> }
247
+ <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">h</span>, <span class="ruby-identifier">f</span>)
248
+ }
249
+ <span class="ruby-keyword kw">end</span>
250
+ </pre>
251
+ </div>
252
+ </div>
253
+ </div>
254
+
255
+ <div id="method-M000020" class="method-detail">
256
+ <a name="M000020"></a>
257
+
258
+ <div class="method-heading">
259
+ <a href="#M000020" class="method-signature">
260
+ <span class="method-name">set_temp</span><span class="method-args">(other, keys)</span>
261
+ </a>
262
+ </div>
263
+
264
+ <div class="method-description">
265
+ <p><a class="source-toggle" href="#"
266
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
267
+ <div class="method-source-code" id="M000020-source">
268
+ <pre>
269
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 73</span>
270
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_temp</span>(<span class="ruby-identifier">other</span>, <span class="ruby-identifier">keys</span>)
271
+ <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
272
+ <span class="ruby-ivar">@temp_keys</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">k</span>
273
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">other</span>[<span class="ruby-identifier">k</span>]
274
+ }
275
+ <span class="ruby-keyword kw">end</span>
276
+ </pre>
277
+ </div>
278
+ </div>
279
+ </div>
280
+
281
+ <div id="method-M000018" class="method-detail">
282
+ <a name="M000018"></a>
283
+
284
+ <div class="method-heading">
285
+ <a href="#M000018" class="method-signature">
286
+ <span class="method-name">store_database</span><span class="method-args">(dbname, conf)</span>
287
+ </a>
288
+ </div>
289
+
290
+ <div class="method-description">
291
+ <p><a class="source-toggle" href="#"
292
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
293
+ <div class="method-source-code" id="M000018-source">
294
+ <pre>
295
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 65</span>
296
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_database</span>(<span class="ruby-identifier">dbname</span>, <span class="ruby-identifier">conf</span>)
297
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>] = <span class="ruby-identifier">conf</span>
298
+ <span class="ruby-keyword kw">end</span>
299
+ </pre>
300
+ </div>
301
+ </div>
302
+ </div>
303
+
304
+ <div id="method-M000019" class="method-detail">
305
+ <a name="M000019"></a>
306
+
307
+ <div class="method-heading">
308
+ <a href="#M000019" class="method-signature">
309
+ <span class="method-name">store_table</span><span class="method-args">(dbname, tablename, conf)</span>
310
+ </a>
311
+ </div>
312
+
313
+ <div class="method-description">
314
+ <p><a class="source-toggle" href="#"
315
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
316
+ <div class="method-source-code" id="M000019-source">
317
+ <pre>
318
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 69</span>
319
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_table</span>(<span class="ruby-identifier">dbname</span>, <span class="ruby-identifier">tablename</span>, <span class="ruby-identifier">conf</span>)
320
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">'databases'</span>][<span class="ruby-identifier">dbname</span>][<span class="ruby-value str">'tables'</span>][<span class="ruby-identifier">tablename</span>] = <span class="ruby-identifier">conf</span>
321
+ <span class="ruby-keyword kw">end</span>
322
+ </pre>
323
+ </div>
324
+ </div>
325
+ </div>
326
+
327
+ <div id="method-M000017" class="method-detail">
328
+ <a name="M000017"></a>
329
+
330
+ <div class="method-heading">
331
+ <a href="#M000017" class="method-signature">
332
+ <span class="method-name">tconf</span><span class="method-args">(dbname, tablename)</span>
333
+ </a>
334
+ </div>
335
+
336
+ <div class="method-description">
337
+ <p><a class="source-toggle" href="#"
338
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
339
+ <div class="method-source-code" id="M000017-source">
340
+ <pre>
341
+ <span class="ruby-comment cmt"># File lib/sip/config.rb, line 61</span>
342
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tconf</span>(<span class="ruby-identifier">dbname</span>, <span class="ruby-identifier">tablename</span>)
343
+ <span class="ruby-identifier">dbconf</span>(<span class="ruby-identifier">dbname</span>)[<span class="ruby-value str">'tables'</span>][<span class="ruby-identifier">tablename</span>]
344
+ <span class="ruby-keyword kw">end</span>
345
+ </pre>
346
+ </div>
347
+ </div>
348
+ </div>
349
+
350
+
351
+ </div>
352
+
353
+
354
+ </div>
355
+
356
+
357
+ <div id="validator-badges">
358
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
359
+ </div>
360
+
361
+ </body>
362
+ </html>
@@ -0,0 +1,368 @@
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::DBBase</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::DBBase</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/sip/databases/dbbase_rb.html">
59
+ lib/sip/databases/dbbase.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
+ Object
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
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000037">columns</a>&nbsp;&nbsp;
90
+ <a href="#M000039">generate_command</a>&nbsp;&nbsp;
91
+ <a href="#M000035">get_column_max</a>&nbsp;&nbsp;
92
+ <a href="#M000036">hive_columns</a>&nbsp;&nbsp;
93
+ <a href="#M000031">make_interface</a>&nbsp;&nbsp;
94
+ <a href="#M000032">new</a>&nbsp;&nbsp;
95
+ <a href="#M000038">order_column_list</a>&nbsp;&nbsp;
96
+ <a href="#M000034">rowcount</a>&nbsp;&nbsp;
97
+ <a href="#M000033">tables</a>&nbsp;&nbsp;
98
+ </div>
99
+ </div>
100
+
101
+ </div>
102
+
103
+
104
+ <!-- if includes -->
105
+
106
+ <div id="section">
107
+
108
+
109
+
110
+
111
+
112
+ <div id="attribute-list">
113
+ <h3 class="section-bar">Attributes</h3>
114
+
115
+ <div class="name-list">
116
+ <table>
117
+ <tr class="top-aligned-row context-row">
118
+ <td class="context-item-name">args</td>
119
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
120
+ <td class="context-item-desc"></td>
121
+ </tr>
122
+ </table>
123
+ </div>
124
+ </div>
125
+
126
+
127
+
128
+ <!-- if method_list -->
129
+ <div id="methods">
130
+ <h3 class="section-bar">Public Class methods</h3>
131
+
132
+ <div id="method-M000031" class="method-detail">
133
+ <a name="M000031"></a>
134
+
135
+ <div class="method-heading">
136
+ <a href="#M000031" class="method-signature">
137
+ <span class="method-name">make_interface</span><span class="method-args">(type, args, sipper)</span>
138
+ </a>
139
+ </div>
140
+
141
+ <div class="method-description">
142
+ <p><a class="source-toggle" href="#"
143
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
144
+ <div class="method-source-code" id="M000031-source">
145
+ <pre>
146
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 5</span>
147
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">make_interface</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">sipper</span>)
148
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'mysql'</span>
149
+ <span class="ruby-identifier">require</span> <span class="ruby-value str">'sip/databases/mysql'</span>
150
+ <span class="ruby-constant">MySQLSipper</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">args</span>, <span class="ruby-identifier">sipper</span>
151
+ <span class="ruby-keyword kw">else</span>
152
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnsupportedDatabaseType</span>, <span class="ruby-node">&quot;DB type #{type.to_s} not supported.&quot;</span>
153
+ <span class="ruby-keyword kw">end</span>
154
+ <span class="ruby-keyword kw">end</span>
155
+ </pre>
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <div id="method-M000032" class="method-detail">
161
+ <a name="M000032"></a>
162
+
163
+ <div class="method-heading">
164
+ <a href="#M000032" class="method-signature">
165
+ <span class="method-name">new</span><span class="method-args">(args, sipper)</span>
166
+ </a>
167
+ </div>
168
+
169
+ <div class="method-description">
170
+ <p><a class="source-toggle" href="#"
171
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
172
+ <div class="method-source-code" id="M000032-source">
173
+ <pre>
174
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 14</span>
175
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">sipper</span>)
176
+ <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">args</span>
177
+ <span class="ruby-ivar">@sipper</span> = <span class="ruby-identifier">sipper</span>
178
+ <span class="ruby-keyword kw">end</span>
179
+ </pre>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+ <h3 class="section-bar">Public Instance methods</h3>
185
+
186
+ <div id="method-M000037" class="method-detail">
187
+ <a name="M000037"></a>
188
+
189
+ <div class="method-heading">
190
+ <a href="#M000037" class="method-signature">
191
+ <span class="method-name">columns</span><span class="method-args">(table)</span>
192
+ </a>
193
+ </div>
194
+
195
+ <div class="method-description">
196
+ <p><a class="source-toggle" href="#"
197
+ onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
198
+ <div class="method-source-code" id="M000037-source">
199
+ <pre>
200
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 37</span>
201
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">columns</span>(<span class="ruby-identifier">table</span>)
202
+ <span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;DESCRIBE #{table}&quot;</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">col</span><span class="ruby-operator">|</span>
203
+ <span class="ruby-identifier">col</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-value">0</span>,<span class="ruby-value">2</span>)
204
+ }
205
+ <span class="ruby-keyword kw">end</span>
206
+ </pre>
207
+ </div>
208
+ </div>
209
+ </div>
210
+
211
+ <div id="method-M000039" class="method-detail">
212
+ <a name="M000039"></a>
213
+
214
+ <div class="method-heading">
215
+ <a href="#M000039" class="method-signature">
216
+ <span class="method-name">generate_command</span><span class="method-args">(tableconf, first=nil, last=nil)</span>
217
+ </a>
218
+ </div>
219
+
220
+ <div class="method-description">
221
+ <p><a class="source-toggle" href="#"
222
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
223
+ <div class="method-source-code" id="M000039-source">
224
+ <pre>
225
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 47</span>
226
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_command</span>(<span class="ruby-identifier">tableconf</span>, <span class="ruby-identifier">first</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">last</span>=<span class="ruby-keyword kw">nil</span>)
227
+ <span class="ruby-identifier">select</span> = <span class="ruby-node">&quot;SELECT #{columns(tableconf['tablename']).map { |k,v| k }.join(',')} FROM #{tableconf['tablename']}&quot;</span>
228
+ <span class="ruby-identifier">wheres</span> = []
229
+ <span class="ruby-identifier">wheres</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{tableconf['incremental_index']} &gt;= #{first}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">first</span>.<span class="ruby-identifier">nil?</span>
230
+ <span class="ruby-identifier">wheres</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{tableconf['incremental_index']} &lt;= #{last}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">last</span>.<span class="ruby-identifier">nil?</span>
231
+ <span class="ruby-identifier">select</span> <span class="ruby-operator">+=</span> <span class="ruby-node">&quot; WHERE #{wheres.join(&quot; AND &quot;)}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">wheres</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
232
+ <span class="ruby-identifier">cmd_line_execute_string</span> <span class="ruby-identifier">select</span>
233
+ <span class="ruby-keyword kw">end</span>
234
+ </pre>
235
+ </div>
236
+ </div>
237
+ </div>
238
+
239
+ <div id="method-M000035" class="method-detail">
240
+ <a name="M000035"></a>
241
+
242
+ <div class="method-heading">
243
+ <a href="#M000035" class="method-signature">
244
+ <span class="method-name">get_column_max</span><span class="method-args">(tablename, field)</span>
245
+ </a>
246
+ </div>
247
+
248
+ <div class="method-description">
249
+ <p><a class="source-toggle" href="#"
250
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
251
+ <div class="method-source-code" id="M000035-source">
252
+ <pre>
253
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 27</span>
254
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_column_max</span>(<span class="ruby-identifier">tablename</span>, <span class="ruby-identifier">field</span>)
255
+ <span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;SELECT max(#{field}) FROM #{tablename}&quot;</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_i</span>
256
+ <span class="ruby-keyword kw">end</span>
257
+ </pre>
258
+ </div>
259
+ </div>
260
+ </div>
261
+
262
+ <div id="method-M000036" class="method-detail">
263
+ <a name="M000036"></a>
264
+
265
+ <div class="method-heading">
266
+ <a href="#M000036" class="method-signature">
267
+ <span class="method-name">hive_columns</span><span class="method-args">(table)</span>
268
+ </a>
269
+ </div>
270
+
271
+ <div class="method-description">
272
+ <p><a class="source-toggle" href="#"
273
+ onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
274
+ <div class="method-source-code" id="M000036-source">
275
+ <pre>
276
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 31</span>
277
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hive_columns</span>(<span class="ruby-identifier">table</span>)
278
+ <span class="ruby-identifier">columns</span>(<span class="ruby-identifier">table</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
279
+ [<span class="ruby-identifier">name</span>, <span class="ruby-identifier">convert_to_hive_type</span>(<span class="ruby-identifier">type</span>)]
280
+ }
281
+ <span class="ruby-keyword kw">end</span>
282
+ </pre>
283
+ </div>
284
+ </div>
285
+ </div>
286
+
287
+ <div id="method-M000038" class="method-detail">
288
+ <a name="M000038"></a>
289
+
290
+ <div class="method-heading">
291
+ <a href="#M000038" class="method-signature">
292
+ <span class="method-name">order_column_list</span><span class="method-args">(table, cols)</span>
293
+ </a>
294
+ </div>
295
+
296
+ <div class="method-description">
297
+ <p><a class="source-toggle" href="#"
298
+ onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
299
+ <div class="method-source-code" id="M000038-source">
300
+ <pre>
301
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 43</span>
302
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">order_column_list</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">cols</span>)
303
+ <span class="ruby-identifier">columns</span>(<span class="ruby-identifier">table</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">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">cols</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">c</span> }
304
+ <span class="ruby-keyword kw">end</span>
305
+ </pre>
306
+ </div>
307
+ </div>
308
+ </div>
309
+
310
+ <div id="method-M000034" class="method-detail">
311
+ <a name="M000034"></a>
312
+
313
+ <div class="method-heading">
314
+ <a href="#M000034" class="method-signature">
315
+ <span class="method-name">rowcount</span><span class="method-args">(table)</span>
316
+ </a>
317
+ </div>
318
+
319
+ <div class="method-description">
320
+ <p><a class="source-toggle" href="#"
321
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
322
+ <div class="method-source-code" id="M000034-source">
323
+ <pre>
324
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 23</span>
325
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rowcount</span>(<span class="ruby-identifier">table</span>)
326
+ <span class="ruby-identifier">query</span>(<span class="ruby-value str">'SELECT count(1) FROM #{table}'</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_i</span>
327
+ <span class="ruby-keyword kw">end</span>
328
+ </pre>
329
+ </div>
330
+ </div>
331
+ </div>
332
+
333
+ <div id="method-M000033" class="method-detail">
334
+ <a name="M000033"></a>
335
+
336
+ <div class="method-heading">
337
+ <a href="#M000033" class="method-signature">
338
+ <span class="method-name">tables</span><span class="method-args">()</span>
339
+ </a>
340
+ </div>
341
+
342
+ <div class="method-description">
343
+ <p><a class="source-toggle" href="#"
344
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
345
+ <div class="method-source-code" id="M000033-source">
346
+ <pre>
347
+ <span class="ruby-comment cmt"># File lib/sip/databases/dbbase.rb, line 19</span>
348
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tables</span>
349
+ <span class="ruby-identifier">query</span>(<span class="ruby-value str">'SHOW tables'</span>)
350
+ <span class="ruby-keyword kw">end</span>
351
+ </pre>
352
+ </div>
353
+ </div>
354
+ </div>
355
+
356
+
357
+ </div>
358
+
359
+
360
+ </div>
361
+
362
+
363
+ <div id="validator-badges">
364
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
365
+ </div>
366
+
367
+ </body>
368
+ </html>