rroonga 0.9.4-x86-mingw32 → 0.9.5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/NEWS.ja.rdoc +29 -0
  2. data/NEWS.rdoc +29 -0
  3. data/Rakefile +6 -6
  4. data/ext/groonga/rb-grn-array.c +1 -1
  5. data/ext/groonga/rb-grn-context.c +15 -28
  6. data/ext/groonga/rb-grn-exception.c +46 -1
  7. data/ext/groonga/rb-grn-expression.c +22 -13
  8. data/ext/groonga/rb-grn-fix-size-column.c +2 -8
  9. data/ext/groonga/rb-grn-hash.c +8 -1
  10. data/ext/groonga/rb-grn-object.c +1 -1
  11. data/ext/groonga/rb-grn-patricia-trie.c +23 -1
  12. data/ext/groonga/rb-grn-table-key-support.c +22 -0
  13. data/ext/groonga/rb-grn-table.c +37 -5
  14. data/ext/groonga/rb-grn-utils.c +20 -2
  15. data/ext/groonga/rb-grn.h +1 -1
  16. data/ext/groonga/rb-groonga.c +76 -38
  17. data/extconf.rb +17 -1
  18. data/html/developer.html +32 -7
  19. data/html/footer.html.erb +5 -0
  20. data/html/heading-mark.svg +393 -0
  21. data/html/index.html +33 -3
  22. data/lib/1.8/groonga.so +0 -0
  23. data/lib/1.9/groonga.so +0 -0
  24. data/lib/groonga.rb +3 -7
  25. data/lib/groonga/context.rb +2 -13
  26. data/lib/groonga/expression-builder.rb +273 -67
  27. data/lib/groonga/pagination.rb +143 -0
  28. data/lib/groonga/record.rb +2 -0
  29. data/lib/groonga/schema.rb +140 -29
  30. data/pkg/rroonga-0.9.5/NEWS.ja.rdoc +156 -0
  31. data/pkg/rroonga-0.9.5/NEWS.rdoc +158 -0
  32. data/pkg/rroonga-0.9.5/README.ja.rdoc +65 -0
  33. data/pkg/rroonga-0.9.5/README.rdoc +66 -0
  34. data/pkg/rroonga-0.9.5/text/TUTORIAL.ja.rdoc +394 -0
  35. data/pkg/rroonga-0.9.5/text/expression.rdoc +285 -0
  36. data/rroonga-build.rb +2 -2
  37. data/test-unit/Rakefile +40 -0
  38. data/test-unit/TODO +5 -0
  39. data/test-unit/bin/testrb +5 -0
  40. data/test-unit/html/classic.html +15 -0
  41. data/test-unit/html/index.html +25 -0
  42. data/test-unit/html/index.html.ja +27 -0
  43. data/test-unit/lib/test/unit.rb +323 -0
  44. data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
  45. data/test-unit/lib/test/unit/assertions.rb +1230 -0
  46. data/test-unit/lib/test/unit/attribute.rb +125 -0
  47. data/test-unit/lib/test/unit/autorunner.rb +360 -0
  48. data/test-unit/lib/test/unit/collector.rb +36 -0
  49. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  50. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  51. data/test-unit/lib/test/unit/collector/load.rb +144 -0
  52. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  53. data/test-unit/lib/test/unit/color-scheme.rb +102 -0
  54. data/test-unit/lib/test/unit/color.rb +96 -0
  55. data/test-unit/lib/test/unit/diff.rb +724 -0
  56. data/test-unit/lib/test/unit/error.rb +130 -0
  57. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  58. data/test-unit/lib/test/unit/failure.rb +136 -0
  59. data/test-unit/lib/test/unit/fixture.rb +176 -0
  60. data/test-unit/lib/test/unit/notification.rb +129 -0
  61. data/test-unit/lib/test/unit/omission.rb +191 -0
  62. data/test-unit/lib/test/unit/pending.rb +150 -0
  63. data/test-unit/lib/test/unit/priority.rb +180 -0
  64. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  65. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  66. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  67. data/test-unit/lib/test/unit/testcase.rb +476 -0
  68. data/test-unit/lib/test/unit/testresult.rb +89 -0
  69. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  70. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  71. data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
  72. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
  73. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
  74. data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
  75. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  76. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  77. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  78. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  79. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  80. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  81. data/test-unit/lib/test/unit/version.rb +7 -0
  82. data/test-unit/sample/adder.rb +13 -0
  83. data/test-unit/sample/subtracter.rb +12 -0
  84. data/test-unit/sample/test_adder.rb +20 -0
  85. data/test-unit/sample/test_subtracter.rb +20 -0
  86. data/test-unit/sample/test_user.rb +23 -0
  87. data/test-unit/test/collector/test-descendant.rb +133 -0
  88. data/test-unit/test/collector/test-load.rb +442 -0
  89. data/test-unit/test/collector/test_dir.rb +406 -0
  90. data/test-unit/test/collector/test_objectspace.rb +100 -0
  91. data/test-unit/test/run-test.rb +15 -0
  92. data/test-unit/test/test-attribute.rb +86 -0
  93. data/test-unit/test/test-color-scheme.rb +67 -0
  94. data/test-unit/test/test-color.rb +47 -0
  95. data/test-unit/test/test-diff.rb +518 -0
  96. data/test-unit/test/test-emacs-runner.rb +60 -0
  97. data/test-unit/test/test-fixture.rb +287 -0
  98. data/test-unit/test/test-notification.rb +33 -0
  99. data/test-unit/test/test-omission.rb +81 -0
  100. data/test-unit/test/test-pending.rb +70 -0
  101. data/test-unit/test/test-priority.rb +119 -0
  102. data/test-unit/test/test-testcase.rb +544 -0
  103. data/test-unit/test/test_assertions.rb +1151 -0
  104. data/test-unit/test/test_error.rb +26 -0
  105. data/test-unit/test/test_failure.rb +33 -0
  106. data/test-unit/test/test_testresult.rb +113 -0
  107. data/test-unit/test/test_testsuite.rb +129 -0
  108. data/test-unit/test/testunit-test-util.rb +14 -0
  109. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  110. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  111. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  112. data/test-unit/test/util/test_observable.rb +102 -0
  113. data/test-unit/test/util/test_procwrapper.rb +36 -0
  114. data/test/groonga-test-utils.rb +3 -2
  115. data/test/run-test.rb +14 -2
  116. data/test/test-column.rb +7 -7
  117. data/test/test-context-select.rb +34 -11
  118. data/test/test-exception.rb +3 -0
  119. data/test/test-expression-builder.rb +11 -0
  120. data/test/test-expression.rb +3 -6
  121. data/test/test-gqtp.rb +3 -5
  122. data/test/test-pagination.rb +249 -0
  123. data/test/test-record.rb +36 -8
  124. data/test/test-remote.rb +11 -4
  125. data/test/test-schema-create-table.rb +251 -0
  126. data/test/test-schema.rb +4 -24
  127. data/test/test-table-offset-and-limit.rb +3 -5
  128. data/test/test-table-select-mecab.rb +80 -0
  129. data/test/test-table-select-weight.rb +104 -0
  130. data/test/test-table.rb +22 -4
  131. data/test/test-version.rb +1 -1
  132. data/text/TUTORIAL.ja.rdoc +2 -0
  133. data/text/expression.rdoc +1 -0
  134. data/vendor/local/bin/grntest.exe +0 -0
  135. data/vendor/local/bin/groonga.exe +0 -0
  136. data/vendor/local/bin/libgroonga-0.dll +0 -0
  137. data/vendor/local/include/{groonga.h → groonga/groonga.h} +93 -32
  138. data/vendor/local/lib/groonga/modules/functions/cast.dll +0 -0
  139. data/vendor/local/lib/groonga/modules/functions/cast.la +41 -0
  140. data/vendor/local/lib/pkgconfig/groonga.pc +12 -0
  141. data/vendor/local/share/groonga/admin_html/css/admin.css +104 -0
  142. data/vendor/local/share/groonga/admin_html/css/ui-lightness/jquery-ui-1.8.1.custom.css +486 -0
  143. data/vendor/local/share/groonga/admin_html/index.html +1355 -0
  144. data/vendor/local/share/groonga/admin_html/js/jquery-1.4.2.min.js +154 -0
  145. data/vendor/local/share/groonga/admin_html/js/jquery-ui-1.8.1.custom.min.js +756 -0
  146. data/vendor/local/share/groonga/munin/plugins/groonga_cpu_load +47 -0
  147. data/vendor/local/share/groonga/munin/plugins/groonga_cpu_time +57 -0
  148. data/vendor/local/share/groonga/munin/plugins/groonga_disk +162 -0
  149. data/vendor/local/share/groonga/munin/plugins/groonga_memory +51 -0
  150. data/vendor/local/share/groonga/munin/plugins/groonga_n_records +110 -0
  151. data/vendor/local/share/groonga/munin/plugins/groonga_query_performance +133 -0
  152. data/vendor/local/share/groonga/munin/plugins/groonga_status +84 -0
  153. metadata +126 -36
@@ -0,0 +1,1355 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+ <html lang="ja">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
+ <meta http-equiv="Content-Style-Type" content="text/css">
7
+ <meta http-equiv="Content-Script-Type" content="text/javascript">
8
+ <meta name="robots" content="noindex,nofollow,noarchive">
9
+ <title>groonga admin</title>
10
+ <link rel="stylesheet" type="text/css" href="/css/admin.css">
11
+ <link rel="stylesheet" type="text/css" href="/css/ui-lightness/jquery-ui-1.8.1.custom.css">
12
+ <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
13
+ <script type="text/javascript" src="/js/jquery-ui-1.8.1.custom.min.js"></script>
14
+ <script type="text/javascript" src="/js/jquery.json-2.2.min.js"></script>
15
+ </head>
16
+ <body>
17
+ <div id="header">
18
+ </div>
19
+ <div id="body">
20
+ <table>
21
+ <tr>
22
+ <td id="left-column">
23
+ <div id="side-menu">
24
+ テーブル一覧
25
+ <ul id="side-menu-tablelist" />
26
+ </div>
27
+ </td>
28
+
29
+ <td id="right-column">
30
+ <!-- database view -->
31
+ <div id="database-tabs">
32
+ <ul>
33
+ <li><a href="#database-tab-summary">サマリー</a></li>
34
+ <li><a href="#database-tab-tablelist" id="tab-tablelist-link">テーブル一覧</a></li>
35
+ <li><a href="#database-tab-createtable">テーブル作成</a></li>
36
+ </ul>
37
+ <div id="database-tab-summary">
38
+ <p>
39
+ groongaの管理ツールです。
40
+ </p>
41
+ <ul>
42
+ <li>開始時間: <span id="status-starttime"></span></li>
43
+ <li>uptime: <span id="status-uptime"></span></li>
44
+ <li>クエリ数: <span id="status-n-queries"></span></li>
45
+ <li>キャッシュヒット率: <span id="status-cache-hit-rate"></span></li>
46
+ </ul>
47
+ </div>
48
+ <div id="database-tab-tablelist">
49
+ <div id="tab-tablelist-table">
50
+ </div>
51
+ <input type="button" id="tablelist-remove-table" value="選択テーブル削除">
52
+ </div>
53
+ <div id="database-tab-createtable">
54
+ <table>
55
+ <tr>
56
+ <td>
57
+ <label for="createtable-name">テーブル名</label>
58
+ </td>
59
+ <td>
60
+ <input type="text" id="createtable-name">
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ 主キー
66
+ </td>
67
+ <td>
68
+ <label for="createtable-key-type">keyの型:</label>
69
+ <select id="createtable-key-type">
70
+ <optgroup label="組み込み型" id="createtable-key-type-builtin">
71
+ </optgroup>
72
+ <optgroup label="テーブル" id="createtable-key-type-table">
73
+ </optgroup>
74
+ </select>
75
+ <label for="createtable-key-index">keyのインデックス種類:</label>
76
+ <select id="createtable-key-index">
77
+ <option value="GRN_OBJ_TABLE_PAT_KEY">パトリシア木</option>
78
+ <option value="GRN_OBJ_TABLE_HASH_KEY">ハッシュテーブル</option>
79
+ <option value="GRN_OBJ_TABLE_NO_KEY">キーなし</option>
80
+ </select>
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <td>
85
+ フラグ
86
+ </td>
87
+ <td id="createtable-flags">
88
+ <input type="checkbox" value="GRN_OBJ_PERSISTENT" checked>永続化</input>
89
+ <input type="checkbox" value="GRN_OBJ_KEY_NORMALIZE">key文字列の正規化</input>
90
+ <input type="checkbox" value="GRN_OBJ_KEY_WITH_SIS">key文字列のsuffix登録</input>
91
+ </td>
92
+ </tr>
93
+ <tr>
94
+ <td>
95
+ valueの型
96
+ </td>
97
+ <td>
98
+ <select id="createtable-value-type">
99
+ <optgroup label="組み込み型" id="createtable-value-type-builtin">
100
+ </optgroup>
101
+ <optgroup label="テーブル" id="createtable-value-type-table">
102
+ </optgroup>
103
+ </select>
104
+ </td>
105
+ </tr>
106
+ <tr>
107
+ <td>
108
+ デフォルトトークナイザ
109
+ </td>
110
+ <td>
111
+ <select id="createtable-default-tokenizer">
112
+ <optgroup label="組み込み" id="createtable-default-tokenizer-builtin">
113
+ </optgroup>
114
+ </select>
115
+ </td>
116
+ </tr>
117
+ </table>
118
+ <input type="button" id="createtable-add-table" value="テーブル追加">
119
+ </div>
120
+ </div>
121
+
122
+ <!-- table view -->
123
+ <div id="table-tabs">
124
+ <ul>
125
+ <li><a href="#table-tab-recordlist" id="tab-recordlist-link">レコード一覧</a></li>
126
+ <li><a href="#table-tab-columnlist" id="tab-columnlist-link">カラム一覧</a></li>
127
+ <li><a href="#table-tab-createrecord" id="tab-createrecord-link">レコード作成</a></li>
128
+ <li><a href="#table-tab-createcolumn">カラム作成</a></li>
129
+ </ul>
130
+ <div id="table-tab-recordlist">
131
+ <input type="checkbox" id="table-tab-recordlist-full-checkbox" /><label for="table-tab-recordlist-full-checkbox">管理モード</label>
132
+ <div id="table-tab-recordlist-form-simple">
133
+ <label for="tab-recordlist-simplequery">検索クエリ: </label><input type="text" id="tab-recordlist-simplequery">
134
+ <select id="tab-recordlist-simplequerytype">
135
+ <option value="query">query</option>
136
+ <option value="filter">filter</option>
137
+ </select>
138
+ <input type="checkbox" id="tab-recordlist-incremental" /><label for="tab-recordlist-incremental" id="tab-recordlist-incremental-label">インクリメンタル検索</label>
139
+ </div>
140
+ <div id="table-tab-recordlist-form-full">
141
+ <table>
142
+ <tr><td>match_columns</td><td><input type="text" id="tab-recordlist-match_columns" /></td></tr>
143
+ <tr><td>query</td><td><input type="text" id="tab-recordlist-query" /></td></tr>
144
+ <tr><td>filter</td><td><input type="text" id="tab-recordlist-filter" /></td></tr>
145
+ <tr><td>scorer</td><td><input type="text" id="tab-recordlist-scorer" /></td></tr>
146
+ <tr><td>sortby</td><td><input type="text" id="tab-recordlist-sortby" /></td></tr>
147
+ <tr><td>output_columns</td><td><input type="text" id="tab-recordlist-output_columns" /></td></tr>
148
+ <tr><td>offset</td><td><input type="text" id="tab-recordlist-offset" /></td></tr>
149
+ <tr><td>limit</td><td><input type="text" id="tab-recordlist-limit" /></td></tr>
150
+ <tr><td>drilldown</td><td><input type="text" id="tab-recordlist-drilldown" /></td></tr>
151
+ <tr><td>drilldown_sortby</td><td><input type="text" id="tab-recordlist-drilldown_sortby" /></td></tr>
152
+ <tr><td>drilldown_output_columns</td><td><input type="text" id="tab-recordlist-drilldown_output_columns" /></td></tr>
153
+ <tr><td>drilldown_offset</td><td><input type="text" id="tab-recordlist-drilldown_offset" /></td></tr>
154
+ <tr><td>drilldown_limit</td><td><input type="text" id="tab-recordlist-drilldown_limit" /></td></tr>
155
+ </table>
156
+ </div>
157
+ <input type="button" id="tab-recordlist-submit" value="検索"/>
158
+ <div id="tab-recordlist-table">
159
+ </div>
160
+ <input type="button" id="recordlist-remove-record" value="選択レコード削除">
161
+ </div>
162
+ <div id="table-tab-columnlist">
163
+ <div id="tab-columnlist-table">
164
+ </div>
165
+ <input type="button" id="columnlist-remove-column" value="選択カラム削除">
166
+ </div>
167
+ <div id="table-tab-createrecord">
168
+ <table id="table-createrecord">
169
+ </table>
170
+ <input type="button" id="createrecord-add-record" value="レコード追加">
171
+ </div>
172
+ <div id="table-tab-createcolumn">
173
+ <table>
174
+ <tr>
175
+ <td>
176
+ <label for="createcolumn-name">カラム名</label>
177
+ </td>
178
+ <td>
179
+ <input type="text" id="createcolumn-name">
180
+ </td>
181
+ </tr>
182
+ <tr>
183
+ <td>
184
+ 設定
185
+ </td>
186
+ <td>
187
+ <label for="createcolumn-type">型:</label>
188
+ <select id="createcolumn-type">
189
+ <optgroup label="組み込み型" id="createcolumn-type-builtin">
190
+ </optgroup>
191
+ <optgroup label="テーブル" id="createcolumn-type-table">
192
+ </optgroup>
193
+ </select>
194
+
195
+ <label for="createcolumn-source">テーブル型の場合カラム</label>
196
+ <select id="createcolumn-source" disabled>
197
+ </select>
198
+
199
+ <label for="createcolumn-column-type">カラム種別:</label>
200
+ <select id="createcolumn-column-type">
201
+ <option value="GRN_OBJ_COLUMN_SCALAR">スカラ</option>
202
+ <option value="GRN_OBJ_COLUMN_VECTOR">ベクタ</option>
203
+ <option value="GRN_OBJ_COLUMN_INDEX">転置インデックス</option>
204
+ </select>
205
+
206
+ <label for="createcolumn-compress">圧縮:</label>
207
+ <select id="createcolumn-compress">
208
+ <option value="GRN_OBJ_COMPRESS_NONE">圧縮なし</option>
209
+ <option value="GRN_OBJ_COMPRESS_ZLIB">zlib</option>
210
+ <option value="GRN_OBJ_COMPRESS_LZO">lzo</option>
211
+ </select>
212
+ </td>
213
+ </tr>
214
+ <tr>
215
+ <td>
216
+ フラグ
217
+ </td>
218
+ <td id="createcolumn-flags">
219
+ <input type="checkbox" value="GRN_OBJ_PERSISTENT" checked>永続化</input>
220
+ </td>
221
+ </tr>
222
+ <tr>
223
+ <td>
224
+ 転置インデックス用フラグ
225
+ </td>
226
+ <td id="createcolumn-ii-flags">
227
+ <input type="checkbox" value="GRN_OBJ_WITH_SECTION">段落情報を含める</input>
228
+ <input type="checkbox" value="GRN_OBJ_WITH_WEIGHT">重みを含める</input>
229
+ <input type="checkbox" value="GRN_OBJ_WITH_POSITION">位置情報を含める</input>
230
+ </td>
231
+ </tr>
232
+ </table>
233
+ <input type="button" id="createcolumn-add-column" value="カラム追加">
234
+ </div>
235
+ </div>
236
+ </div>
237
+ </td>
238
+ </tr>
239
+ </table>
240
+ <div id="footer">
241
+ Powered by <a href="http://jquery.com/">jQuery</a> and <a href="http://jqueryui.com/">jQuery UI</a>.
242
+ </div>
243
+ <script type="text/javascript">
244
+ function prim2html(prim, limit) {
245
+ switch(typeof prim) {
246
+ case 'undefined':
247
+ return 'undefined';
248
+ case 'boolean':
249
+ return prim ? 'true' : 'false';
250
+ case 'number':
251
+ return String(prim);
252
+ case 'string':
253
+ if (prim.length > limit) {
254
+ prim = prim.substring(0, limit) + '...';
255
+ }
256
+ return escapeHTML(prim);
257
+ case 'array':
258
+ case 'object':
259
+ if (prim == null) {
260
+ return 'null';
261
+ } else if ($.isArray(prim)) {
262
+ return 'array'; /* TODO: implement */
263
+ } else {
264
+ return 'object'; /* TODO: implement */
265
+ }
266
+ default:
267
+ return 'ERROR';
268
+ }
269
+ }
270
+
271
+ function escapeHTML(str) {
272
+ return str.replace(/&/g, "&amp;")
273
+ .replace(/"/g, "&quot;")
274
+ .replace(/</g, "&lt;")
275
+ .replace(/>/g, "&gt;");
276
+ }
277
+ Groonga = {
278
+ key_type_list: ['Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32',
279
+ 'Int64', 'UInt64', 'Float', 'Time', 'ShortText',
280
+ 'TokyoGeoPoint', 'WGS84GeoPoint'],
281
+ value_type_list: ['Object', 'Bool',
282
+ 'Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32',
283
+ 'Int64', 'UInt64', 'Float', 'Time'],
284
+ column_type_list: ['Object', 'Bool',
285
+ 'Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32',
286
+ 'Int64', 'UInt64', 'Float', 'Time', 'ShortText',
287
+ 'Text', 'LongText', 'TokyoGeoPoint', 'WGS84GeoPoint'],
288
+ tokenizer_list: ['TokenDelimit', 'TokenUnigram', 'TokenBigram', 'TokenTrigram', 'TokenMecab'],
289
+ GRN_OBJ_PERSISTENT: (0x01<<15),
290
+
291
+ GRN_OBJ_TABLE_TYPE_MASK: (0x07),
292
+ GRN_OBJ_TABLE_HASH_KEY: (0x00),
293
+ GRN_OBJ_TABLE_PAT_KEY: (0x01),
294
+ GRN_OBJ_TABLE_NO_KEY: (0x03),
295
+
296
+ GRN_OBJ_KEY_WITH_SIS: (0x01<<6),
297
+ GRN_OBJ_KEY_NORMALIZE: (0x01<<7),
298
+
299
+ GRN_OBJ_COLUMN_TYPE_MASK: (0x07),
300
+ GRN_OBJ_COLUMN_SCALAR: (0x00),
301
+ GRN_OBJ_COLUMN_VECTOR: (0x01),
302
+ GRN_OBJ_COLUMN_INDEX: (0x02),
303
+
304
+ GRN_OBJ_COMPRESS_MASK: (0x07<<4),
305
+ GRN_OBJ_COMPRESS_NONE: (0x00<<4),
306
+ GRN_OBJ_COMPRESS_ZLIB: (0x01<<4),
307
+ GRN_OBJ_COMPRESS_LZO: (0x02<<4),
308
+
309
+ GRN_OBJ_WITH_SECTION: (0x01<<7),
310
+ GRN_OBJ_WITH_WEIGHT: (0x01<<8),
311
+ GRN_OBJ_WITH_POSITION: (0x01<<9)
312
+ };
313
+ GroongaAdmin = {
314
+ SELECT_PARAMS_LIST: ['match_columns', 'query', 'filter', 'scorer', 'sortby', 'output_columns', 'offset', 'limit', 'drilldown', 'drilldown_sortby', 'drilldown_output_columns', 'drilldown_offset', 'drilldown_limit'],
315
+ initialize: function() {
316
+ GroongaAdmin.current_table = null;
317
+ GroongaAdmin.statusTimer = null;
318
+ GroongaAdmin.semaphore = new Array();
319
+ GroongaAdmin.current_status = 0;
320
+ GroongaAdmin.reload_record_func = function(){};
321
+
322
+ GroongaAdmin.database_tabs = $('#database-tabs').tabs({
323
+ show: function(e, ui) {
324
+ GroongaAdmin.stop_status_timer();
325
+ if (ui.panel.id == 'database-tab-summary') {
326
+ GroongaAdmin.start_status_timer();
327
+ }
328
+ }
329
+ });
330
+ GroongaAdmin.table_tabs = $('#table-tabs').tabs({
331
+ show: function(e, ui) {
332
+ }
333
+ });
334
+ $('#tab-tablelist-link').click(function() {
335
+ GroongaAdmin.tablelist();
336
+ });
337
+ $('#tab-columnlist-link').click(function() {
338
+ GroongaAdmin.columnlist(GroongaAdmin.current_table);
339
+ });
340
+ $('#tab-createrecord-link').click(function() {
341
+ GroongaAdmin.update_createrecord(GroongaAdmin.current_table);
342
+ });
343
+ $('#tab-recordlist-link').click(function() {
344
+ GroongaAdmin.reload_record_func();
345
+ });
346
+ $('#createtable-add-table').click(function() {
347
+ GroongaAdmin.createtable();
348
+ });
349
+ $('#createrecord-add-record').click(function() {
350
+ GroongaAdmin.createrecord();
351
+ });
352
+ $('#createcolumn-add-column').click(function() {
353
+ GroongaAdmin.createcolumn();
354
+ });
355
+ $('#recordlist-remove-record').click(function() {
356
+ GroongaAdmin.removerecord();
357
+ });
358
+ $('#columnlist-remove-column').click(function() {
359
+ GroongaAdmin.removecolumn();
360
+ });
361
+ $('#tablelist-remove-table').click(function() {
362
+ GroongaAdmin.removetable();
363
+ });
364
+ $('#tab-recordlist-submit').click(function() {
365
+ if ($('#table-tab-recordlist-full-checkbox').attr('checked')) {
366
+ // full
367
+ var d = {
368
+ 'table': GroongaAdmin.current_table
369
+ }
370
+ $.each(GroongaAdmin.SELECT_PARAMS_LIST, function(i, val) {
371
+ var e = $('#tab-recordlist-' + val);
372
+ if (e.val()) {
373
+ d[val] = e.val();
374
+ }
375
+ });
376
+ GroongaAdmin.recordlist(d, true);
377
+ } else {
378
+ // simple
379
+ GroongaAdmin.recordlist_simple(
380
+ GroongaAdmin.current_table,
381
+ $('#tab-recordlist-simplequery').val(),
382
+ $('#tab-recordlist-simplequerytype').val(),
383
+ 1);
384
+ }
385
+ });
386
+ GroongaAdmin.update_tablelist();
387
+
388
+ var e1 = $('#createtable-key-type-builtin');
389
+ $.each(Groonga.key_type_list, function(i, val) {
390
+ e1.append($('<option />').val(val).text(val));
391
+ });
392
+
393
+ e1 = $('#createtable-value-type-builtin');
394
+ e1.append($('<option />').val('').text('なし'));
395
+ $.each(Groonga.value_type_list, function(i, val) {
396
+ e1.append($('<option />').val(val).text(val));
397
+ });
398
+
399
+ e1 = $('#createtable-default-tokenizer-builtin');
400
+ e1.append($('<option />').val('').text('なし'));
401
+ $.each(Groonga.tokenizer_list, function(i, val) {
402
+ e1.append($('<option />').val(val).text(val));
403
+ });
404
+
405
+ e1 = $('#createcolumn-type-builtin');
406
+ $.each(Groonga.column_type_list, function(i, val) {
407
+ e1.append($('<option />').val(val).text(val));
408
+ });
409
+
410
+ $('#tab-recordlist-simplequerytype').change(function() {
411
+ if ($(this).val() == 'scorer') {
412
+ $('#tab-recordlist-incremental').hide();
413
+ $('#tab-recordlist-incremental-label').hide();
414
+ } else {
415
+ $('#tab-recordlist-incremental').show();
416
+ $('#tab-recordlist-incremental-label').show();
417
+ }
418
+ $('#tab-recordlist-incremental').change();
419
+ }).change();
420
+
421
+ $('#table-tab-recordlist-full-checkbox').change(function() {
422
+ if ($(this).attr('checked')) {
423
+ $('#table-tab-recordlist-form-simple').hide();
424
+ $('#table-tab-recordlist-form-full').show();
425
+ } else {
426
+ $('#table-tab-recordlist-form-simple').show();
427
+ $('#table-tab-recordlist-form-full').hide();
428
+ }
429
+ }).change();
430
+
431
+ $('#tab-recordlist-incremental').change(function() {
432
+ $('#tab-recordlist-simplequery').unbind('keyup');
433
+ if ($(this).attr('checked') &&
434
+ $('#tab-recordlist-simplequerytype').val() != 'scorer') {
435
+ $('#tab-recordlist-simplequery').keyup(function(e) {
436
+ GroongaAdmin.recordlist_simple(
437
+ GroongaAdmin.current_table,
438
+ $('#tab-recordlist-simplequery').val(),
439
+ $('#tab-recordlist-simplequerytype').val(),
440
+ 1,
441
+ true);
442
+ });
443
+ }
444
+ }).change();
445
+
446
+ $('#createcolumn-type').change(function(e) {
447
+ var s = $('#createcolumn-type-table option:selected');
448
+ var cs = $('#createcolumn-source');
449
+ if (s.length > 0) {
450
+ cs.empty().removeAttr('disabled');
451
+ GroongaAdmin.showloading(
452
+ $.ajax({
453
+ url: '/d/column_list',
454
+ data: {'table': s.val()},
455
+ dataType: 'json',
456
+ success: function(d) {
457
+ if(GroongaAdmin.validateajax(d) < 0) { return; }
458
+ var idx;
459
+ var b = d[1];
460
+ $.each(b[0], function(i, val) {
461
+ if (val[0] == 'name') { idx = i; }
462
+ });
463
+ if (idx) {
464
+ b.shift();
465
+ $.each(b, function(i, val) {
466
+ cs.append($('<option />').val(val[idx]).text(val[idx]));
467
+ });
468
+ }
469
+ GroongaAdmin.hideloading();
470
+ },
471
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
472
+ GroongaAdmin.errorloading(XMLHttpRequest);
473
+ }
474
+ })
475
+ );
476
+ } else {
477
+ cs.empty().attr('disabled', 'disabled');
478
+ }
479
+ });
480
+
481
+ GroongaAdmin.recordlist_count = 30;
482
+ },
483
+ start_status_timer: function() {
484
+ GroongaAdmin.stop_status_timer();
485
+ GroongaAdmin.status();
486
+ GroongaAdmin.statusTimer = setInterval(GroongaAdmin.status, 1000);
487
+ },
488
+ change_status_timer: function(time) {
489
+ GroongaAdmin.stop_status_timer();
490
+ GroongaAdmin.statusTimer = setInterval(GroongaAdmin.status, time);
491
+ },
492
+ stop_status_timer: function() {
493
+ if (GroongaAdmin.statusTimer) {
494
+ clearInterval(GroongaAdmin.statusTimer);
495
+ GroongaAdmin.statusTimer = null;
496
+ }
497
+ },
498
+ create_table_element: function (d, check, button) {
499
+ var elms = ['<table class="records">'];
500
+ if ($.isArray(d)) {
501
+ elms.push('<thead>');
502
+ var l = d.length;
503
+ if (l >= 1) {
504
+ var line = d[0];
505
+ elms.push('<thead>');
506
+ if ($.isArray(line)) {
507
+ elms.push('<tr>');
508
+ var m = line.length;
509
+ if (check) {
510
+ elms.push('<th/>');
511
+ }
512
+ for (var j = 0; j < m; j++) {
513
+ elms.push('<th>');
514
+ elms.push(prim2html(line[j][0], 128));
515
+ elms.push('<br />');
516
+ elms.push(prim2html(line[j][1], 128));
517
+ elms.push('</th>');
518
+ }
519
+ if (button) {
520
+ elms.push('<th/>');
521
+ }
522
+ elms.push('</tr>');
523
+ }
524
+ elms.push('</thead>');
525
+ elms.push('<tbody>');
526
+ for (var i = 1; i < l; i++) {
527
+ line = d[i];
528
+ if ($.isArray(line)) {
529
+ elms.push('<tr>');
530
+ var m = line.length;
531
+ switch(check) {// チェックボックスの値を何にするか
532
+ case 1: // 1番目の要素(レコード一覧の_id等)
533
+ case 2: // 2番目の要素(テーブル・カラム一覧のname等)
534
+ elms.push('<td><input type="checkbox" value="');
535
+ elms.push(line[check-1]);
536
+ elms.push('" /></td>');
537
+ break;
538
+ }
539
+ for (var j = 0; j < m; j++) {
540
+ elms.push('<td>');
541
+ elms.push(prim2html(line[j], 128));
542
+ elms.push('</td>');
543
+ }
544
+ switch(button) {
545
+ case 1: // Edit record
546
+ elms.push('<td><input type="button" onClick="GroongaAdmin.show_edit_record(');
547
+ elms.push(line[0]);
548
+ elms.push(');" value="編集" /></td>');
549
+ break;
550
+ case 2: // Table
551
+ elms.push('<td><input type="button" onClick="$(\'#side-menu-tablelist-link-');
552
+ elms.push(line[1]);
553
+ elms.push('\').click();" value="詳細" /></td>');
554
+ break;
555
+ }
556
+ elms.push('</tr>');
557
+ }
558
+ }
559
+ elms.push('</tbody>');
560
+ }
561
+ }
562
+ elms.push('</table>');
563
+ return elms.join('');
564
+ },
565
+ show_edit_record: function(id) {
566
+ $('#table-tabs').tabs('select', 2);
567
+ GroongaAdmin.update_createrecord(GroongaAdmin.current_table, id);
568
+ },
569
+ format_unix_time: function(unix_time) {
570
+ var date = new Date();
571
+ date.setTime(unix_time * 1000);
572
+ return date.toLocaleString();
573
+ },
574
+ format_duration: function(duration_in_seconds) {
575
+ var duration = "";
576
+ var days = Math.floor(duration_in_seconds / 3600 / 24);
577
+ var hours = Math.floor(duration_in_seconds / 3600 % 24);
578
+ var minutes = Math.floor(duration_in_seconds / 60 % 60);
579
+ var seconds = Math.floor(duration_in_seconds % 60);
580
+
581
+ if (days > 0) {
582
+ duration += days;
583
+ if (days == 1) {
584
+ duration += " day, ";
585
+ } else {
586
+ duration += " days, ";
587
+ }
588
+ }
589
+ if (days > 0 || hours > 0) {
590
+ duration += hours + ":" + minutes + ":" + seconds;
591
+ } else if (minutes > 0) {
592
+ duration += minutes + ":" + seconds;
593
+ } else {
594
+ duration += seconds;
595
+ }
596
+
597
+ return duration;
598
+ },
599
+ status: function() {
600
+ if (GroongaAdmin.current_status > 0) { return; }
601
+ GroongaAdmin.current_status++;
602
+ $.ajax({
603
+ url: '/d/status',
604
+ data: {},
605
+ dataType: 'json',
606
+ success: function(b) {
607
+ GroongaAdmin.current_status--;
608
+ if (!b) {
609
+ GroongaAdmin.change_status_timer(10000);
610
+ return;
611
+ }
612
+ var d = b[1];
613
+ $('#status-starttime').text(GroongaAdmin.format_unix_time(d.starttime));
614
+ $('#status-uptime').text(GroongaAdmin.format_duration(d.uptime));
615
+ $('#status-n-queries').text(d.n_queries);
616
+ $('#status-cache-hit-rate').text(d.cache_hit_rate);
617
+ GroongaAdmin.change_status_timer(1000);
618
+ },
619
+ error: function() {
620
+ GroongaAdmin.current_status--;
621
+ GroongaAdmin.change_status_timer(10000);
622
+ }
623
+ });
624
+ },
625
+ update_tablelist: function() {
626
+ GroongaAdmin.showloading(
627
+ $.ajax({
628
+ url: '/d/table_list',
629
+ data: {},
630
+ dataType: 'json',
631
+ success: function(d) {
632
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
633
+ d.shift();
634
+ var tl = $('#side-menu-tablelist').empty();
635
+ var tt = $('#createtable-key-type-table').empty();
636
+ var vt = $('#createtable-value-type-table').empty();
637
+ var ct = $('#createcolumn-type-table').empty();
638
+ tl.append(
639
+ $('<li />').append(
640
+ $('<a />').attr('href', '#side-menu-database')
641
+ .text('サマリー')
642
+ .click(function() {
643
+ GroongaAdmin.current_table = null;
644
+ $('#table-tabs').hide();
645
+ $('#database-tabs').show();
646
+ GroongaAdmin.start_status_timer();
647
+ })
648
+ )
649
+ )
650
+ var b = d.shift();
651
+ b.shift();
652
+ $.each(b, function(i, val) {
653
+ var table_name = val[1];
654
+ tl.append(
655
+ $('<li />').append(
656
+ $('<a />')
657
+ .attr('id', 'side-menu-tablelist-link-' + table_name)
658
+ .attr('href', '#side-menu-tablelist-' + table_name)
659
+ .text(table_name)
660
+ .click(function() {
661
+ GroongaAdmin.current_table = table_name;
662
+ $('#database-tabs').hide();
663
+ GroongaAdmin.stop_status_timer();
664
+ $('#table-tabs').show();
665
+ GroongaAdmin.columnlist(table_name);
666
+ $('#tab-recordlist-simplequery').val('');
667
+ GroongaAdmin.recordlist_simple(table_name, null, null, 1);
668
+ GroongaAdmin.update_createrecord(GroongaAdmin.current_table);
669
+ })
670
+ )
671
+ );
672
+ tt.append($('<option />').val(val[1]).text(val[1]));
673
+ vt.append($('<option />').val(val[1]).text(val[1]));
674
+ ct.append($('<option />').val(val[1]).text(val[1]));
675
+ });
676
+ GroongaAdmin.hideloading();
677
+ },
678
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
679
+ GroongaAdmin.errorloading(XMLHttpRequest);
680
+ }
681
+ })
682
+ );
683
+ },
684
+ tablelist: function() {
685
+ $('#tab-tablelist-table').empty();
686
+ GroongaAdmin.showloading(
687
+ $.ajax({
688
+ url: '/d/table_list',
689
+ data: {},
690
+ dataType: 'json',
691
+ success: function(d) {
692
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
693
+ var b = d[1];
694
+ var table = $(GroongaAdmin.create_table_element(b, 2, 2));
695
+ $('#tab-tablelist-table').append($('<h1 />').text('テーブル一覧')).append(table);
696
+ GroongaAdmin.hideloading();
697
+ },
698
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
699
+ GroongaAdmin.errorloading(XMLHttpRequest);
700
+ }
701
+ })
702
+ );
703
+ },
704
+ pager_element_factory: function(per_page, current_page, show_num, func) {
705
+ return function (total) {
706
+ var ret = $('<div />').addClass('pager');
707
+ if (total) {
708
+ var last_page = Math.floor((total - 1) / per_page) + 1;
709
+ var st = current_page - Math.floor(show_num / 2);
710
+ st = (st < 1) ? 1 : st;
711
+ var ed = st + show_num - 1;
712
+ ed = (ed > last_page) ? last_page : ed;
713
+
714
+ if (st > 1) {
715
+ ret.append(
716
+ $('<span />').addClass('pager').append(
717
+ $('<a />').attr('href', '#').text('1').click(func)
718
+ )
719
+ ).append($('<span />').text('....'));
720
+ }
721
+ for (var i = st; i <= ed; i++) {
722
+ var s = $('<span />').append(
723
+ $('<a />').attr('href', '#').text(String(i)).click(func)
724
+ );
725
+ if (i == current_page) {
726
+ s.addClass('pager-current');
727
+ } else {
728
+ s.addClass('pager');
729
+ }
730
+ ret.append(s);
731
+ }
732
+ if (ed < last_page) {
733
+ ret.append($('<span />').text('....')).append(
734
+ $('<span />').addClass('pager').append(
735
+ $('<a />').attr('href', '#').text(String(last_page)).click(func)
736
+ )
737
+ )
738
+ }
739
+ }
740
+ return ret;
741
+ }
742
+ },
743
+ recordlist_simple: function(table_name, simplequery, simplequery_type, page, hide_dialog) {
744
+ var d = {
745
+ 'table': table_name,
746
+ 'offset': (page - 1) * GroongaAdmin.recordlist_count,
747
+ 'limit': GroongaAdmin.recordlist_count
748
+ }
749
+ switch (simplequery_type) {
750
+ case 'query':
751
+ case 'filter':
752
+ case null:
753
+ if (simplequery) {
754
+ d[simplequery_type] = simplequery;
755
+ }
756
+ GroongaAdmin.recordlist(d, true, hide_dialog);
757
+ break;
758
+ }
759
+ },
760
+ recordlist: function(params, show_pager, hide_dialog) {
761
+ GroongaAdmin.reload_record_func = function(){
762
+ GroongaAdmin.recordlist(params, show_pager, hide_dialog);
763
+ };
764
+ GroongaAdmin.showloading(
765
+ $.ajax({
766
+ url: '/d/select',
767
+ data: params,
768
+ dataType: 'json',
769
+ success: function(d) {
770
+ if (GroongaAdmin.validateajax(d, hide_dialog) < 0) { return; }
771
+ var rc = d.shift();
772
+ if (rc[0] != 0) {
773
+ alert('error');
774
+ return false;
775
+ }
776
+ var body = d.shift();
777
+ var recs = body.shift();
778
+ var all_count = recs.shift()[0];
779
+ var pager;
780
+ if (show_pager) {
781
+ offset = params['offset'] || 0;
782
+ rows = params['limit'] || 10;
783
+ if (rows < 0){
784
+ rows = all_count + parseInt(rows) + 1;
785
+ }
786
+ if (rows != '' && !parseInt(rows)) {
787
+ pager = $('<span />');
788
+ } else {
789
+ pager =
790
+ GroongaAdmin.pager_element_factory(
791
+ rows,
792
+ Math.floor(offset/rows)+1,
793
+ 13,
794
+ function() {
795
+ params['offset'] = (Number($(this).text()) - 1) * rows;
796
+ GroongaAdmin.recordlist(params, true, false);
797
+ return false;
798
+ }
799
+ )(all_count);
800
+ }
801
+ } else {
802
+ pager = $('<span />');
803
+ }
804
+ $('#tab-recordlist-table')
805
+ .empty()
806
+ .append($('<h1 />').text('レコード一覧: ' + params['table']))
807
+ .append($('<p />').text('総件数: ' + all_count))
808
+ .append(pager.clone(true))
809
+ .append($('<div />').html(GroongaAdmin.create_table_element(recs, 1, 1)))
810
+ .append(pager);
811
+ GroongaAdmin.hideloading();
812
+ },
813
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
814
+ GroongaAdmin.errorloading(XMLHttpRequest, hide_dialog);
815
+ }
816
+ })
817
+ ,hide_dialog);
818
+ },
819
+ columnlist: function(table_name) {
820
+ $('#tab-columnlist-table').empty();
821
+ GroongaAdmin.showloading(
822
+ $.ajax({
823
+ url: '/d/column_list',
824
+ data: {'table': table_name},
825
+ dataType: 'json',
826
+ success: function(d) {
827
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
828
+ var b = d[1];
829
+ var table = $(GroongaAdmin.create_table_element(b, 2));
830
+ $('#tab-columnlist-table')
831
+ .append($('<h1 />').text('カラム一覧: ' + table_name))
832
+ .append(table);
833
+ GroongaAdmin.hideloading();
834
+ },
835
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
836
+ GroongaAdmin.errorloading(XMLHttpRequest);
837
+ }
838
+ })
839
+ );
840
+ },
841
+ add_record_inputbox: function(type, value) {
842
+ var inputbox = null;
843
+ switch(type){
844
+ case "Bool":
845
+ inputbox = $('<input />')
846
+ .attr("type","checkbox")
847
+ .attr("value","true");
848
+ if (value) {
849
+ inputbox.attr("checked","");
850
+ }
851
+ break;
852
+ case "UInt8":
853
+ case "UInt16":
854
+ case "UInt32":
855
+ case "UInt64":
856
+ case "Int8":
857
+ case "Int16":
858
+ case "Int32":
859
+ case "Int64":
860
+ case "Float":
861
+ inputbox = $('<input />')
862
+ .attr("type", "text")
863
+ .val(isNaN(value) ? "" : value);
864
+ break;
865
+ case "Text":
866
+ case "ShortText":
867
+ case "LongText":
868
+ inputbox = $('<textarea />')
869
+ .attr("cols", "50")
870
+ .attr("rows", "2")
871
+ .text(value ? value : "");
872
+ break;
873
+ case "TokyoGeoPoint":
874
+ case "WGS84GeoPoint":
875
+ case "Time":
876
+ inputbox = $('<input />')
877
+ .attr("type", "text")
878
+ .attr("size", "40")
879
+ .val(value ? value : "");
880
+ break;
881
+ case "Object":
882
+ inputbox = $('<input />')
883
+ .attr("type", "text")
884
+ .attr("disabled", "disabled");
885
+ break;
886
+ default:
887
+ inputbox = $('<input />')
888
+ .attr("type", "text")
889
+ .val(value ? value : "");
890
+ }
891
+ inputbox.addClass('column_values');
892
+ return inputbox;
893
+ },
894
+ add_record_deletebutton: function(){
895
+ var ret =
896
+ $('<span />')
897
+ .append("[×]")
898
+ .css('cursor', 'pointer')
899
+ .click(function() {
900
+ $(this).prev().remove();
901
+ $(this).next().remove();
902
+ $(this).remove();
903
+ });
904
+ return ret;
905
+ },
906
+ update_createrecord_loadcomplete: function(d_sel, d_col) {
907
+ var b = d_sel[1][0];
908
+ var columns = $('<tbody />');
909
+ var listofs = b[1].length - (d_col[1].length - 1);
910
+ for (var i = 1; i < b[1].length; i++) {
911
+ var line = b[1][i];
912
+ var value = null;
913
+ if (b[2]) value = b[2][i];
914
+ if ($.isArray(line)) {
915
+ var tr = $('<tr/ >')
916
+ .addClass('create-record-columns')
917
+ .append(
918
+ $('<td />')
919
+ .addClass('columnname')
920
+ .append(prim2html(line[0], 128))
921
+ )
922
+ .append(
923
+ $('<td />')
924
+ .addClass('columntype')
925
+ .append("(")
926
+ .append($('<span />')
927
+ .append(prim2html(line[1], 128))
928
+ )
929
+ .append(")")
930
+ );
931
+ var inputtd = $('<td />').addClass('columnval');
932
+ if (i >= listofs && d_col[1][i - listofs + 1][4].indexOf("COLUMN_VECTOR") >= 0){
933
+ var type = line[1];
934
+ if (value != null) {
935
+ for (var j = 0; j < value.length; j++) {
936
+ inputtd
937
+ .append(GroongaAdmin.add_record_inputbox(line[1], value[j]))
938
+ .append(GroongaAdmin.add_record_deletebutton())
939
+ .append('<br />');
940
+ }
941
+ }
942
+ inputtd
943
+ .append($('<span />')
944
+ .append("[値を追加]")
945
+ .css('cursor', 'pointer')
946
+ .click(function() {
947
+ var target = $(this).parent();
948
+ target
949
+ .append(GroongaAdmin.add_record_inputbox($(this).parent().prev().children().text()))
950
+ .append(GroongaAdmin.add_record_deletebutton())
951
+ .append("<br />");
952
+ $(this).appendTo(target);
953
+ })
954
+ );
955
+ } else {
956
+ inputtd.append(GroongaAdmin.add_record_inputbox(line[1], value));
957
+ if (line[0] == "_key" && value != null) {
958
+ inputtd.children().attr("disabled", "disabled");
959
+ }
960
+ }
961
+ tr.append(inputtd);
962
+ columns.append(tr);
963
+ }
964
+ }
965
+ $("#table-createrecord").append(columns);
966
+ GroongaAdmin.hideloading();
967
+ },
968
+ update_createrecord: function(table_name, id) {
969
+ var d_sel = null;
970
+ var d_col = null;
971
+ $('#table-createrecord').empty();
972
+ GroongaAdmin.showloading(
973
+ $.ajax({
974
+ url: '/d/select',
975
+ data: {
976
+ 'table' : table_name,
977
+ 'limit' : 1,
978
+ 'query' : '_id:' + id
979
+ },
980
+ dataType: 'json',
981
+ success: function(d) {
982
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
983
+ d_sel = d;
984
+ if (d_col) {
985
+ GroongaAdmin.update_createrecord_loadcomplete(d_sel, d_col);
986
+ }
987
+ },
988
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
989
+ GroongaAdmin.errorloading(XMLHttpRequest);
990
+ }
991
+ })
992
+ );
993
+ GroongaAdmin.showloading(
994
+ $.ajax({
995
+ url: '/d/column_list',
996
+ data: {
997
+ 'table' : table_name
998
+ },
999
+ dataType: 'json',
1000
+ success: function(d) {
1001
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
1002
+ d_col = d;
1003
+ if (d_sel) {
1004
+ GroongaAdmin.update_createrecord_loadcomplete(d_sel, d_col);
1005
+ }
1006
+ },
1007
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1008
+ GroongaAdmin.errorloading(XMLHttpRequest);
1009
+ }
1010
+ })
1011
+ );
1012
+ },
1013
+ createtable: function() {
1014
+ var flags = 0;
1015
+ $('#createtable-flags>input:checked').each(function() {
1016
+ flags |= Groonga[$(this).val()];
1017
+ });
1018
+ flags |= Groonga[$('#createtable-key-index').val()];
1019
+ GroongaAdmin.showloading(
1020
+ $.ajax({
1021
+ url: '/d/table_create',
1022
+ data: {
1023
+ name: $('#createtable-name').val(),
1024
+ 'flags': flags,
1025
+ key_type: $('#createtable-key-type').val(),
1026
+ value_type: $('#createtable-value-type').val(),
1027
+ default_tokenizer: $('#createtable-default-tokenizer').val()
1028
+ },
1029
+ dataType: 'json',
1030
+ success: function(d) {
1031
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
1032
+ GroongaAdmin.hideloading();
1033
+ alert('テーブルを作成しました。');
1034
+ GroongaAdmin.update_tablelist();
1035
+ },
1036
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1037
+ GroongaAdmin.errorloading(XMLHttpRequest);
1038
+ }
1039
+ })
1040
+ );
1041
+ },
1042
+ createcolumn: function() {
1043
+ var flags = 0;
1044
+ $('#createcolumn-flags>input:checked').each(function() {
1045
+ flags |= Groonga[$(this).val()];
1046
+ });
1047
+ $('#createcolumn-ii-flags>input:checked').each(function() {
1048
+ flags |= Groonga[$(this).val()];
1049
+ });
1050
+ flags |= Groonga[$('#createcolumn-column-type').val()];
1051
+ flags |= Groonga[$('#createcolumn-column-compress').val()];
1052
+ d = {
1053
+ table: GroongaAdmin.current_table,
1054
+ name: $('#createcolumn-name').val(),
1055
+ 'flags': flags,
1056
+ type: $('#createcolumn-type').val()
1057
+ };
1058
+ if ($('#createcolumn-source').val()) {
1059
+ d['source'] = $('#createcolumn-source').val();
1060
+ }
1061
+ GroongaAdmin.showloading(
1062
+ $.ajax({
1063
+ url: '/d/column_create',
1064
+ data: d,
1065
+ dataType: 'json',
1066
+ success: function(d) {
1067
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
1068
+ GroongaAdmin.hideloading();
1069
+ alert('カラムを作成しました。');
1070
+ },
1071
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1072
+ GroongaAdmin.errorloading(XMLHttpRequest);
1073
+ }
1074
+ })
1075
+ );
1076
+ },
1077
+ createrecord_getvalue: function(type, inputbox) {
1078
+ switch(type){
1079
+ case "Bool":
1080
+ if (inputbox.is('input:checked')) {
1081
+ return true;
1082
+ } else {
1083
+ return false;
1084
+ }
1085
+ default:
1086
+ return inputbox.val();
1087
+ }
1088
+ },
1089
+ createrecord: function() {
1090
+ var d = {};
1091
+ $('.create-record-columns').each(function() {
1092
+ if (!$(this).children('.columnval').children().attr('disabled')
1093
+ || $(this).children('.columnname').text() == "_key") {
1094
+ var type = $(this).children('.columntype').children().text();
1095
+ if ($(this).children('.columnval').children('span').length) {
1096
+ var arr = [];
1097
+ $(this).children('.columnval').children('.column_values').each(function() {
1098
+ arr.push(GroongaAdmin.createrecord_getvalue(type, $(this)));
1099
+ });
1100
+ d[$(this).children('.columnname').text()] = arr;
1101
+ } else {
1102
+ d[$(this).children('.columnname').text()] =
1103
+ GroongaAdmin.createrecord_getvalue(type, $(this).children('.columnval').children());
1104
+ }
1105
+ }
1106
+ });
1107
+ GroongaAdmin.showloading(
1108
+ $.ajax({
1109
+ url: '/d/load',
1110
+ data: {
1111
+ "table" : GroongaAdmin.current_table,
1112
+ "input_type" : "json",
1113
+ "output_type" : "json",
1114
+ "values" : $.toJSON([d])
1115
+ },
1116
+ dataType: 'json',
1117
+ success: function(d) {
1118
+ if (GroongaAdmin.validateajax(d) < 0) { return; }
1119
+ GroongaAdmin.hideloading();
1120
+ alert('レコードを作成しました。');
1121
+ },
1122
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1123
+ GroongaAdmin.errorloading(XMLHttpRequest);
1124
+ }
1125
+ })
1126
+ );
1127
+ },
1128
+ removerecord: function() {
1129
+ var checklist = $("#tab-recordlist-table").find("input:checked");
1130
+ var completecount = checklist.length;
1131
+ if (completecount > 0) {
1132
+ $('<div />')
1133
+ .append("選択した" + completecount + "件のレコードを削除しますか?")
1134
+ .dialog({
1135
+ modal: true,
1136
+ buttons: {
1137
+ 'いいえ': function() {
1138
+ $(this).dialog('close');
1139
+ },
1140
+ 'はい': function() {
1141
+ $(this).dialog('close');
1142
+ checklist.each(function(i, val) {
1143
+ GroongaAdmin.showloading(
1144
+ $.ajax({
1145
+ url: '/d/delete',
1146
+ data: {
1147
+ "table" : GroongaAdmin.current_table,
1148
+ "id" : val.value
1149
+ },
1150
+ dataType: 'json',
1151
+ success: function() {
1152
+ if (--completecount == 0) {
1153
+ $('#tab-recordlist-submit').click();
1154
+ alert('レコードを削除しました。');
1155
+ } else if (completecount < 0){
1156
+ GroongaAdmin.hideloading();
1157
+ }
1158
+ },
1159
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1160
+ completecount = 0;
1161
+ GroongaAdmin.errorloading(XMLHttpRequest);
1162
+ }
1163
+ })
1164
+ );
1165
+ });
1166
+ }
1167
+ }
1168
+ });
1169
+ }
1170
+ },
1171
+ removecolumn: function() {
1172
+ var checklist = $("#tab-columnlist-table").find("input:checked");
1173
+ var completecount = checklist.length;
1174
+ if (completecount) {
1175
+ $('<div />')
1176
+ .append("選択した" + completecount + "件のカラムを削除しますか?")
1177
+ .dialog({
1178
+ modal: true,
1179
+ buttons: {
1180
+ 'いいえ': function() {
1181
+ $(this).dialog('close');
1182
+ },
1183
+ 'はい': function() {
1184
+ $(this).dialog('close');
1185
+ checklist.each(function(i, val) {
1186
+ GroongaAdmin.showloading(
1187
+ $.ajax({
1188
+ url: '/d/column_remove',
1189
+ data: {
1190
+ "table" : GroongaAdmin.current_table,
1191
+ "name" : val.value
1192
+ },
1193
+ dataType: 'json',
1194
+ success: function() {
1195
+ if (!(--completecount)) {
1196
+ GroongaAdmin.columnlist(GroongaAdmin.current_table);
1197
+ alert('カラムを削除しました。');
1198
+ } else if (completecount < 0){
1199
+ GroongaAdmin.hideloading();
1200
+ }
1201
+ },
1202
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1203
+ completecount = 0;
1204
+ GroongaAdmin.errorloading(XMLHttpRequest);
1205
+ }
1206
+ })
1207
+ );
1208
+ });
1209
+ }
1210
+ }
1211
+ });
1212
+ }
1213
+ },
1214
+ removetable: function() {
1215
+ var checklist = $("#tab-tablelist-table").find("input:checked");
1216
+ var completecount = checklist.length;
1217
+ if (completecount > 0) {
1218
+ $('<div />')
1219
+ .append("選択した" + completecount + "件のテーブルを削除しますか?")
1220
+ .dialog({
1221
+ modal: true,
1222
+ buttons: {
1223
+ 'いいえ': function() {
1224
+ $(this).dialog('close');
1225
+ },
1226
+ 'はい': function() {
1227
+ $(this).dialog('close');
1228
+ checklist.each(function(i, val) {
1229
+ GroongaAdmin.showloading(
1230
+ $.ajax({
1231
+ url: '/d/table_remove',
1232
+ data: {
1233
+ "name" : val.value
1234
+ },
1235
+ dataType: 'json',
1236
+ success: function() {
1237
+ if (--completecount == 0) {
1238
+ GroongaAdmin.tablelist();
1239
+ GroongaAdmin.update_tablelist();
1240
+ alert('テーブルを削除しました。');
1241
+ } else if (completecount < 0){
1242
+ GroongaAdmin.hideloading();
1243
+ }
1244
+ },
1245
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
1246
+ completecount = 0;
1247
+ GroongaAdmin.errorloading(XMLHttpRequest);
1248
+ }
1249
+ })
1250
+ );
1251
+ });
1252
+ }
1253
+ }
1254
+ });
1255
+ }
1256
+ },
1257
+ showloading: function(obj, hide_dialog) {
1258
+ if (obj == null) { return; }
1259
+ GroongaAdmin.semaphore[GroongaAdmin.semaphore.length] = obj;
1260
+ if ( $("#loadingdialog").size() > 0 || hide_dialog) { return; }
1261
+ $("<div />")
1262
+ .attr("id", "loadingdialog")
1263
+ .attr("style", "text-align: center;")
1264
+ .append($("<img />").attr("src", "images/loading.gif"))
1265
+ .append(" Loading...")
1266
+ .dialog({
1267
+ title: "",
1268
+ width: 200,
1269
+ height: 110,
1270
+ minHeight: 110,
1271
+ modal: true,
1272
+ resizable: false,
1273
+ draggable: false,
1274
+ position: ["right", "bottom"],
1275
+ autoOpen: false,
1276
+ buttons: {
1277
+ '中止': function() {
1278
+ if (obj) { obj.abort(); }
1279
+ GroongaAdmin.hideloading();
1280
+ }
1281
+ }
1282
+ });
1283
+ $("#loadingdialog").parents(".ui-dialog").children(".ui-dialog-titlebar").remove();
1284
+ $("#loadingdialog").dialog("open");
1285
+ $(".ui-widget-overlay").css("opacity", "0.0");
1286
+ },
1287
+ hideloading: function() {
1288
+ for ( i = 0; i < GroongaAdmin.semaphore.length; i++) {
1289
+ if ( GroongaAdmin.semaphore[i].readyState == 4) {
1290
+ GroongaAdmin.semaphore.splice(i, 1);
1291
+ i--;
1292
+ }
1293
+ }
1294
+ if ( GroongaAdmin.semaphore.length == 0) {
1295
+ $("#loadingdialog").dialog("close");
1296
+ $("#loadingdialog").remove();
1297
+ }
1298
+ },
1299
+ errorloading: function(ajax, hide_dialog) {
1300
+ var json = null;
1301
+ if (ajax) {
1302
+ json = jQuery.parseJSON(ajax.responseText);
1303
+ }
1304
+ GroongaAdmin.hideloading();
1305
+ for ( i = 0; i < GroongaAdmin.semaphore.length; i++) {
1306
+ GroongaAdmin.semaphore[i].abort();
1307
+ GroongaAdmin.semaphore.splice(i, 1);
1308
+ i--;
1309
+ }
1310
+ if ( $("#loadingdialog").size() == 0 && !hide_dialog) {
1311
+ var errtext;
1312
+ if (json){
1313
+ errtext = "groongaでエラーが発生しました。<br>" + json[0][3] + "(" + json[0][0] + ")";
1314
+ } else if (ajax) {
1315
+ errtext = "通信エラーが発生しました。<br>" + ajax.status + ajax.statusText;
1316
+ } else {
1317
+ errtext = "通信エラーが発生しました。";
1318
+ }
1319
+ $("<div />")
1320
+ .append(errtext)
1321
+ .attr("id", "loadingdialog")
1322
+ .dialog({
1323
+ title: "",
1324
+ width: 340,
1325
+ height: 160,
1326
+ minHeight: 160,
1327
+ modal: true,
1328
+ resizable: false,
1329
+ draggable: false,
1330
+ open: function() {
1331
+ $(this).parents(".ui-dialog").children(".ui-dialog-titlebar").remove();
1332
+ },
1333
+ buttons: { OK: function() { GroongaAdmin.hideloading(); } }
1334
+ });
1335
+ }
1336
+ },
1337
+ validateajax: function(d, hide_dialog) {
1338
+ if (!d) {
1339
+ GroongaAdmin.errorloading(null, hide_dialog);
1340
+ return -1;
1341
+ }
1342
+ return 0;
1343
+ }
1344
+ };
1345
+ $(function() {
1346
+ GroongaAdmin.initialize();
1347
+ GroongaAdmin.tablelist();
1348
+ $.ajaxSetup({
1349
+ timeout: 10000,
1350
+ cache: false
1351
+ });
1352
+ });
1353
+ </script>
1354
+ </body>
1355
+ </html>