rroonga 6.0.2 → 6.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 475b1c66414213ee96bd581c7de7a6689abf3863
4
- data.tar.gz: bec353bd58e2ab048f379cd73a33be130690242e
3
+ metadata.gz: 63fc245a4ac5578801876a163c130181f438c5c4
4
+ data.tar.gz: 79adf7a48032d18952be5fcb0ae97b710cdf5e00
5
5
  SHA512:
6
- metadata.gz: b091a21fe716b530d6c6d3d044fe164efe746665a4a0ef106a24cd4c1ffcc0c78dc4029edc1e755cade63286aa890f49654840c3a2aee67ce742a9d58a843095
7
- data.tar.gz: 8876710a8d73dc06b1255800cd0b67203d74bdfe525c5b24c767126e79d4102aaa4d1acba4f0bf81012bb8bfb762466dbfa1488fc73fe7303fa62f0b9bbdeac9
6
+ metadata.gz: 4783b0f4fcaf4cfff8decea7df6dccef726f4d46f074e11a68e81777699c8d42a77d9efc1911ec1a03c33bd2ab92499ece866d35b5970fe2f63e91c5938ee160
7
+ data.tar.gz: a3e0d9eebbd09b672650b2261bcc16ee1ebed5e05f92e501244963b27782cfdbae096c6aa5a9b945e9a73552aac1ec5d41ee7f0855d05bf1b93f9245cd9b834b
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8; mode: ruby -*-
2
2
  #
3
- # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -1,6 +1,23 @@
1
1
  # NEWS
2
2
 
3
- ## 6.0.2 2016-05-18 {#version-6-0-2}
3
+ ## 6.0.4: 2016-06-14 {#version-6-0-4}
4
+
5
+ ### Improvements
6
+
7
+ * Supported Groonga 6.0.4. Groonga 6.0.3 or older aren't supported.
8
+
9
+ * {Groonga::WindowFunctionError}: Added a new error class.
10
+
11
+ * {Groonga::ProcedureType::WINDOW_FUNCTION}: Added a new procedure
12
+ type for window function.
13
+
14
+ * {Groonga::Object#window_function_procedure?}: Added a new
15
+ predicate for window function.
16
+
17
+ * {Groonga::DataColumn#apply_window_function}: Added a new
18
+ method to apply a window function.
19
+
20
+ ## 6.0.2: 2016-05-18 {#version-6-0-2}
4
21
 
5
22
  ### Improvements
6
23
 
@@ -846,7 +846,6 @@ rb_grn_init_column (VALUE mGrn)
846
846
 
847
847
  rb_define_method(rb_cGrnColumn, "rename", rb_grn_column_rename, 1);
848
848
 
849
- rb_grn_init_fix_size_column(mGrn);
850
- rb_grn_init_variable_size_column(mGrn);
849
+ rb_grn_init_data_column(mGrn);
851
850
  rb_grn_init_index_column(mGrn);
852
851
  }
@@ -0,0 +1,157 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /* vim: set sts=4 sw=4 ts=8 noet: */
3
+ /*
4
+ Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
5
+
6
+ This library is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU Lesser General Public
8
+ License version 2.1 as published by the Free Software Foundation.
9
+
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+ #include "rb-grn.h"
21
+
22
+ #define SELF(object) ((RbGrnColumn *)DATA_PTR(object))
23
+
24
+ VALUE rb_cGrnDataColumn;
25
+
26
+ /*
27
+ * Document-class: Groonga::DataColumn < Groonga::Column
28
+ *
29
+ * The superclass for data columns such as {Groonga::FixSizeColumn}
30
+ * and {Groonga::VariableSizeColumn}.
31
+ */
32
+
33
+ /*
34
+ * Applies the window function to records in the table of the
35
+ * column. Results are stored into the column.
36
+ *
37
+ * @example Set the nth record.
38
+ *
39
+ * Groonga::Schema.define do |schema|
40
+ * schema.create_table("Comments") do |table|
41
+ * # The column for storing window function result.
42
+ * table.uint32("nth")
43
+ * end
44
+ * end
45
+ * comments = Groonga["Comments"]
46
+ * nth = Groonga["Comments.nth"]
47
+ *
48
+ * 5.times do
49
+ * comments.add
50
+ * end
51
+ *
52
+ * options = {
53
+ * # Sort by _id in descending order.
54
+ * :sort_keys => [["_id", "desc"]],
55
+ * }
56
+ * nth.apply_window_function(options) do |record|
57
+ * # record_number() returns Nth record in the sorted order.
58
+ * record.call("record_number")
59
+ * end
60
+ *
61
+ * comments.each do |comment|
62
+ * p [comment.id, comment.nth]
63
+ * # -> [1, 5]
64
+ * # -> [2, 4]
65
+ * # -> [3, 3]
66
+ * # -> [4, 2]
67
+ * # -> [5, 1]
68
+ * end
69
+ *
70
+ * @overload apply_window_function(options={}) {|record| }
71
+ * @param options [::Hash] The name and value pairs.
72
+ * @option options [::Array<String>] :sort_keys
73
+ *
74
+ * @yield [record]
75
+ * It yields an object that builds expression. The block must
76
+ * build an expression that calls a window function.
77
+ * @yieldparam [Groonga::RecordExpressionBuilder] record
78
+ * The expression builder to create a window function call.
79
+ * @yieldreturn [Groonga::ExpressionBuilder]
80
+ * It must be an expression that calls a window function.
81
+ *
82
+ * @since 6.0.4
83
+ */
84
+ static VALUE
85
+ rb_grn_data_column_apply_window_function (int argc, VALUE *argv, VALUE self)
86
+ {
87
+ grn_rc rc;
88
+ grn_ctx *context;
89
+ grn_obj *column;
90
+ grn_obj *table;
91
+ VALUE rb_table;
92
+ grn_window_definition definition;
93
+ grn_obj *window_function_call = NULL;
94
+ VALUE rb_options;
95
+ VALUE rb_sort_keys;
96
+ VALUE rb_builder;
97
+ VALUE rb_window_function_call;
98
+
99
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
100
+ NULL, &table,
101
+ NULL, NULL, NULL);
102
+ rb_table = GRNOBJECT2RVAL(Qnil, context, table, GRN_FALSE);
103
+
104
+ memset(&definition, 0, sizeof(grn_window_definition));
105
+
106
+ rb_scan_args(argc, argv, "01", &rb_options);
107
+ rb_grn_scan_options(rb_options,
108
+ "sort_keys", &rb_sort_keys,
109
+ NULL);
110
+
111
+ if (!NIL_P(rb_sort_keys)) {
112
+ VALUE rb_table;
113
+
114
+ if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_sort_keys, rb_cArray)))
115
+ rb_raise(rb_eArgError, ":sort_keys should be an array of key: <%s>",
116
+ rb_grn_inspect(rb_sort_keys));
117
+
118
+ definition.n_sort_keys = RARRAY_LEN(rb_sort_keys);
119
+ definition.sort_keys = ALLOCA_N(grn_table_sort_key,
120
+ definition.n_sort_keys);
121
+ rb_table = GRNOBJECT2RVAL(Qnil, context, table, GRN_FALSE);
122
+ rb_grn_table_sort_keys_fill(context,
123
+ definition.sort_keys,
124
+ definition.n_sort_keys,
125
+ rb_sort_keys,
126
+ rb_table);
127
+ }
128
+
129
+ rb_builder = rb_grn_record_expression_builder_new(rb_table, Qnil);
130
+ rb_window_function_call =
131
+ rb_grn_record_expression_builder_build(rb_builder);
132
+ rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_window_function_call)),
133
+ &window_function_call, NULL,
134
+ NULL, NULL, NULL, NULL);
135
+
136
+ rc = grn_table_apply_window_function(context,
137
+ table,
138
+ column,
139
+ &definition,
140
+ window_function_call);
141
+ rb_grn_context_check(context, self);
142
+ rb_grn_rc_check(rc, self);
143
+
144
+ return self;
145
+ }
146
+
147
+ void
148
+ rb_grn_init_data_column (VALUE mGrn)
149
+ {
150
+ rb_cGrnDataColumn = rb_define_class_under(mGrn, "DataColumn", rb_cGrnColumn);
151
+
152
+ rb_define_method(rb_cGrnDataColumn, "apply_window_function",
153
+ rb_grn_data_column_apply_window_function, -1);
154
+
155
+ rb_grn_init_fix_size_column(mGrn);
156
+ rb_grn_init_variable_size_column(mGrn);
157
+ }
@@ -101,6 +101,7 @@ static VALUE eGrnCommandError;
101
101
  static VALUE eGrnPluginError;
102
102
  static VALUE eGrnScorerError;
103
103
  static VALUE eGrnCancel;
104
+ static VALUE eGrnWindowFunctionError;
104
105
 
105
106
  VALUE
106
107
  rb_grn_rc_to_exception (grn_rc rc)
@@ -345,6 +346,9 @@ rb_grn_rc_to_exception (grn_rc rc)
345
346
  case GRN_CANCEL:
346
347
  exception = eGrnCancel;
347
348
  break;
349
+ case GRN_WINDOW_FUNCTION_ERROR:
350
+ exception = eGrnWindowFunctionError;
351
+ break;
348
352
  }
349
353
 
350
354
  if (NIL_P(exception))
@@ -596,6 +600,9 @@ rb_grn_rc_to_message (grn_rc rc)
596
600
  case GRN_CANCEL:
597
601
  message = "cancel";
598
602
  break;
603
+ case GRN_WINDOW_FUNCTION_ERROR:
604
+ message = "window function error";
605
+ break;
599
606
  }
600
607
 
601
608
  if (!message)
@@ -1295,4 +1302,14 @@ rb_grn_init_exception (VALUE mGrn)
1295
1302
  */
1296
1303
  eGrnCancel =
1297
1304
  rb_define_class_under(mGrn, "Cancel", rb_eGrnError);
1305
+
1306
+ /*
1307
+ * Document-class: Groonga::WindowFunctionError
1308
+ *
1309
+ * It is used when window function causes an error.
1310
+ *
1311
+ * @since 6.0.4
1312
+ */
1313
+ eGrnWindowFunctionError =
1314
+ rb_define_class_under(mGrn, "WindowFunctionError", rb_eGrnError);
1298
1315
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
4
4
  Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
@@ -227,7 +227,7 @@ void
227
227
  rb_grn_init_fix_size_column (VALUE mGrn)
228
228
  {
229
229
  rb_cGrnFixSizeColumn =
230
- rb_define_class_under(mGrn, "FixSizeColumn", rb_cGrnColumn);
230
+ rb_define_class_under(mGrn, "FixSizeColumn", rb_cGrnDataColumn);
231
231
 
232
232
  rb_define_method(rb_cGrnFixSizeColumn, "[]",
233
233
  rb_grn_fix_size_column_array_reference, 1);
@@ -1678,6 +1678,33 @@ rb_grn_object_scorer_procedure_p (VALUE self)
1678
1678
  return CBOOL2RVAL(scorer_procedure_p);
1679
1679
  }
1680
1680
 
1681
+ /*
1682
+ * Checks whether the object is windows function procedure or not.
1683
+ *
1684
+ * @overload window_function_procedure?
1685
+ * @return [Boolean] `true` if the object is window function procedure,
1686
+ * `false` otherwise.
1687
+ *
1688
+ * @since 6.0.4
1689
+ */
1690
+ static VALUE
1691
+ rb_grn_object_window_function_procedure_p (VALUE self)
1692
+ {
1693
+ grn_ctx *context;
1694
+ grn_obj *object;
1695
+ grn_bool window_function_procedure_p = GRN_FALSE;
1696
+
1697
+ rb_grn_object_deconstruct(SELF(self), &object, &context,
1698
+ NULL, NULL, NULL, NULL);
1699
+
1700
+ if (context && object) {
1701
+ window_function_procedure_p =
1702
+ grn_obj_is_window_function_proc(context, object);
1703
+ }
1704
+
1705
+ return CBOOL2RVAL(window_function_procedure_p);
1706
+ }
1707
+
1681
1708
  /*
1682
1709
  * Checks whether the object is accessor or not.
1683
1710
  *
@@ -1785,6 +1812,8 @@ rb_grn_init_object (VALUE mGrn)
1785
1812
  rb_grn_object_selector_only_procedure_p, 0);
1786
1813
  rb_define_method(rb_cGrnObject, "scorer_procedure?",
1787
1814
  rb_grn_object_scorer_procedure_p, 0);
1815
+ rb_define_method(rb_cGrnObject, "window_function_procedure?",
1816
+ rb_grn_object_window_function_procedure_p, 0);
1788
1817
  rb_define_method(rb_cGrnObject, "accessor?",
1789
1818
  rb_grn_object_accessor_p, 0);
1790
1819
  rb_define_method(rb_cGrnObject, "key_accessor?",
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2014-2016 Kouhei Sutou <kou@clear-code.com>
4
4
 
5
5
  This library is free software; you can redistribute it and/or
6
6
  modify it under the terms of the GNU Lesser General Public
@@ -41,4 +41,12 @@ rb_grn_init_procedure_type (VALUE mGrn)
41
41
  "TOKEN_FILTER", INT2NUM(GRN_PROC_TOKEN_FILTER));
42
42
  rb_define_const(rb_mGrnProcedureType,
43
43
  "SCORER", INT2NUM(GRN_PROC_SCORER));
44
+
45
+ /*
46
+ * It's a type for window function.
47
+ *
48
+ * @since 6.0.4
49
+ */
50
+ rb_define_const(rb_mGrnProcedureType,
51
+ "WINDOW_FUNCTION", INT2NUM(GRN_PROC_WINDOW_FUNCTION));
44
52
  }
@@ -0,0 +1,85 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /*
3
+ Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License version 2.1 as published by the Free Software Foundation.
8
+
9
+ This library is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public
15
+ License along with this library; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ #include "rb-grn.h"
20
+
21
+ void
22
+ rb_grn_table_sort_keys_fill (grn_ctx *context,
23
+ grn_table_sort_key *sort_keys,
24
+ size_t n_sort_keys,
25
+ VALUE rb_sort_keys,
26
+ VALUE rb_table)
27
+ {
28
+ int i;
29
+
30
+ for (i = 0; i < n_sort_keys; i++) {
31
+ VALUE rb_sort_key;
32
+ VALUE rb_sort_options;
33
+ VALUE rb_key;
34
+ VALUE rb_resolved_key;
35
+ VALUE rb_order;
36
+
37
+ rb_sort_key = RARRAY_PTR(rb_sort_keys)[i];
38
+ if (RVAL2CBOOL(rb_obj_is_kind_of(rb_sort_key, rb_cHash))) {
39
+ rb_sort_options = rb_sort_key;
40
+ } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_sort_key, rb_cArray))) {
41
+ rb_sort_options = rb_hash_new();
42
+ rb_hash_aset(rb_sort_options,
43
+ RB_GRN_INTERN("key"),
44
+ rb_ary_entry(rb_sort_key, 0));
45
+ rb_hash_aset(rb_sort_options,
46
+ RB_GRN_INTERN("order"),
47
+ rb_ary_entry(rb_sort_key, 1));
48
+ } else {
49
+ rb_sort_options = rb_hash_new();
50
+ rb_hash_aset(rb_sort_options,
51
+ RB_GRN_INTERN("key"),
52
+ rb_sort_key);
53
+ }
54
+ rb_grn_scan_options(rb_sort_options,
55
+ "key", &rb_key,
56
+ "order", &rb_order,
57
+ NULL);
58
+ if (RVAL2CBOOL(rb_obj_is_kind_of(rb_key, rb_cString))) {
59
+ rb_resolved_key = rb_grn_table_get_column(rb_table, rb_key);
60
+ } else {
61
+ rb_resolved_key = rb_key;
62
+ }
63
+ sort_keys[i].key = RVAL2GRNOBJECT(rb_resolved_key, &context);
64
+ if (!sort_keys[i].key) {
65
+ rb_raise(rb_eGrnNoSuchColumn,
66
+ "no such column: <%s>: <%s>",
67
+ rb_grn_inspect(rb_key),
68
+ rb_grn_inspect(rb_table));
69
+ }
70
+ if (NIL_P(rb_order) ||
71
+ rb_grn_equal_option(rb_order, "asc") ||
72
+ rb_grn_equal_option(rb_order, "ascending")) {
73
+ sort_keys[i].flags = GRN_TABLE_SORT_ASC;
74
+ } else if (rb_grn_equal_option(rb_order, "desc") ||
75
+ rb_grn_equal_option(rb_order, "descending")) {
76
+ sort_keys[i].flags = GRN_TABLE_SORT_DESC;
77
+ } else {
78
+ rb_raise(rb_eArgError,
79
+ "order should be one of "
80
+ "[nil, :desc, :descending, :asc, :ascending]: %s",
81
+ rb_grn_inspect(rb_order));
82
+ }
83
+ }
84
+
85
+ }
@@ -19,12 +19,6 @@
19
19
 
20
20
  #include "rb-grn.h"
21
21
 
22
- grn_obj *grn_table_open(grn_ctx *ctx,
23
- const char *name, unsigned name_size, const char *path);
24
- grn_obj *grn_column_open(grn_ctx *ctx, grn_obj *table,
25
- const char *name, unsigned name_size,
26
- const char *path, grn_obj *type);
27
-
28
22
  #define SELF(object) ((RbGrnTable *)DATA_PTR(object))
29
23
 
30
24
  VALUE rb_cGrnTable;
@@ -1218,11 +1212,10 @@ rb_grn_table_sort (int argc, VALUE *argv, VALUE self)
1218
1212
  grn_obj *table;
1219
1213
  grn_obj *result;
1220
1214
  grn_table_sort_key *keys;
1221
- int i, n_keys;
1215
+ int n_keys;
1222
1216
  int offset = 0, limit = -1;
1223
1217
  VALUE rb_keys, options;
1224
1218
  VALUE rb_offset, rb_limit;
1225
- VALUE *rb_sort_keys;
1226
1219
  VALUE exception;
1227
1220
 
1228
1221
  rb_grn_table_deconstruct(SELF(self), &table, &context,
@@ -1237,56 +1230,8 @@ rb_grn_table_sort (int argc, VALUE *argv, VALUE self)
1237
1230
  rb_grn_inspect(rb_keys));
1238
1231
 
1239
1232
  n_keys = RARRAY_LEN(rb_keys);
1240
- rb_sort_keys = RARRAY_PTR(rb_keys);
1241
1233
  keys = ALLOCA_N(grn_table_sort_key, n_keys);
1242
- for (i = 0; i < n_keys; i++) {
1243
- VALUE rb_sort_options, rb_key, rb_resolved_key, rb_order;
1244
-
1245
- if (RVAL2CBOOL(rb_obj_is_kind_of(rb_sort_keys[i], rb_cHash))) {
1246
- rb_sort_options = rb_sort_keys[i];
1247
- } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_sort_keys[i], rb_cArray))) {
1248
- rb_sort_options = rb_hash_new();
1249
- rb_hash_aset(rb_sort_options,
1250
- RB_GRN_INTERN("key"),
1251
- rb_ary_entry(rb_sort_keys[i], 0));
1252
- rb_hash_aset(rb_sort_options,
1253
- RB_GRN_INTERN("order"),
1254
- rb_ary_entry(rb_sort_keys[i], 1));
1255
- } else {
1256
- rb_sort_options = rb_hash_new();
1257
- rb_hash_aset(rb_sort_options,
1258
- RB_GRN_INTERN("key"),
1259
- rb_sort_keys[i]);
1260
- }
1261
- rb_grn_scan_options(rb_sort_options,
1262
- "key", &rb_key,
1263
- "order", &rb_order,
1264
- NULL);
1265
- if (RVAL2CBOOL(rb_obj_is_kind_of(rb_key, rb_cString))) {
1266
- rb_resolved_key = rb_grn_table_get_column(self, rb_key);
1267
- } else {
1268
- rb_resolved_key = rb_key;
1269
- }
1270
- keys[i].key = RVAL2GRNOBJECT(rb_resolved_key, &context);
1271
- if (!keys[i].key) {
1272
- rb_raise(rb_eGrnNoSuchColumn,
1273
- "no such column: <%s>: <%s>",
1274
- rb_grn_inspect(rb_key), rb_grn_inspect(self));
1275
- }
1276
- if (NIL_P(rb_order) ||
1277
- rb_grn_equal_option(rb_order, "asc") ||
1278
- rb_grn_equal_option(rb_order, "ascending")) {
1279
- keys[i].flags = GRN_TABLE_SORT_ASC;
1280
- } else if (rb_grn_equal_option(rb_order, "desc") ||
1281
- rb_grn_equal_option(rb_order, "descending")) {
1282
- keys[i].flags = GRN_TABLE_SORT_DESC;
1283
- } else {
1284
- rb_raise(rb_eArgError,
1285
- "order should be one of "
1286
- "[nil, :desc, :descending, :asc, :ascending]: %s",
1287
- rb_grn_inspect(rb_order));
1288
- }
1289
- }
1234
+ rb_grn_table_sort_keys_fill(context, keys, n_keys, rb_keys, self);
1290
1235
 
1291
1236
  rb_grn_scan_options(options,
1292
1237
  "offset", &rb_offset,
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
4
4
  Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
@@ -648,7 +648,7 @@ void
648
648
  rb_grn_init_variable_size_column (VALUE mGrn)
649
649
  {
650
650
  rb_cGrnVariableSizeColumn =
651
- rb_define_class_under(mGrn, "VariableSizeColumn", rb_cGrnColumn);
651
+ rb_define_class_under(mGrn, "VariableSizeColumn", rb_cGrnDataColumn);
652
652
 
653
653
  rb_define_method(rb_cGrnVariableSizeColumn, "[]",
654
654
  rb_grn_variable_size_column_array_reference, 1);
@@ -99,7 +99,7 @@ RB_GRN_BEGIN_DECLS
99
99
 
100
100
  #define RB_GRN_MAJOR_VERSION 6
101
101
  #define RB_GRN_MINOR_VERSION 0
102
- #define RB_GRN_MICRO_VERSION 2
102
+ #define RB_GRN_MICRO_VERSION 4
103
103
 
104
104
  #define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
105
105
  #define RB_GRN_NAMED_OBJECT(object) ((RbGrnNamedObject *)(object))
@@ -179,17 +179,23 @@ struct _RbGrnColumn
179
179
  grn_obj *value;
180
180
  };
181
181
 
182
+ typedef struct _RbGrnDataColumn RbGrnDataColumn;
183
+ struct _RbGrnDataColumn
184
+ {
185
+ RbGrnColumn parent;
186
+ };
187
+
182
188
  typedef struct _RbGrnVariableSizeColumn RbGrnVariableSizeColumn;
183
189
  struct _RbGrnVariableSizeColumn
184
190
  {
185
- RbGrnColumn parent;
191
+ RbGrnDataColumn parent;
186
192
  grn_obj *element_value;
187
193
  };
188
194
 
189
195
  typedef struct _RbGrnIndexColumn RbGrnIndexColumn;
190
196
  struct _RbGrnIndexColumn
191
197
  {
192
- RbGrnColumn parent;
198
+ RbGrnDataColumn parent;
193
199
  grn_obj *old_value;
194
200
  grn_obj *set_value;
195
201
  grn_obj *id_query;
@@ -268,6 +274,7 @@ RB_GRN_VAR VALUE rb_cGrnArrayCursor;
268
274
  RB_GRN_VAR VALUE rb_cGrnType;
269
275
  RB_GRN_VAR VALUE rb_cGrnProcedure;
270
276
  RB_GRN_VAR VALUE rb_cGrnColumn;
277
+ RB_GRN_VAR VALUE rb_cGrnDataColumn;
271
278
  RB_GRN_VAR VALUE rb_cGrnFixSizeColumn;
272
279
  RB_GRN_VAR VALUE rb_cGrnVariableSizeColumn;
273
280
  RB_GRN_VAR VALUE rb_cGrnIndexColumn;
@@ -324,6 +331,7 @@ void rb_grn_init_type (VALUE mGrn);
324
331
  void rb_grn_init_procedure (VALUE mGrn);
325
332
  void rb_grn_init_procedure_type (VALUE mGrn);
326
333
  void rb_grn_init_column (VALUE mGrn);
334
+ void rb_grn_init_data_column (VALUE mGrn);
327
335
  void rb_grn_init_fix_size_column (VALUE mGrn);
328
336
  void rb_grn_init_variable_size_column (VALUE mGrn);
329
337
  void rb_grn_init_index_column (VALUE mGrn);
@@ -510,6 +518,12 @@ VALUE rb_grn_table_set_column_value (VALUE self,
510
518
  VALUE rb_grn_table_inspect_content (VALUE object,
511
519
  VALUE inspected);
512
520
 
521
+ void rb_grn_table_sort_keys_fill (grn_ctx *context,
522
+ grn_table_sort_key *sort_keys,
523
+ size_t n_sort_keys,
524
+ VALUE rb_sort_keys,
525
+ VALUE rb_table);
526
+
513
527
  grn_ctx *rb_grn_table_cursor_ensure_context (VALUE cursor,
514
528
  VALUE *rb_context);
515
529
  int rb_grn_table_cursor_order_to_flag (VALUE rb_order);
@@ -1,6 +1,4 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
4
2
  # Copyright (C) 2015-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
3
  #
6
4
  # This library is free software; you can redistribute it and/or
@@ -20,15 +18,15 @@ module RroongaBuild
20
18
  module RequiredGroongaVersion
21
19
  MAJOR = 6
22
20
  MINOR = 0
23
- MICRO = 2
21
+ MICRO = 4
24
22
  VERSION = [MAJOR, MINOR, MICRO]
25
- RELEASED_DATE = Time.utc(2016, 4, 29)
23
+ RELEASED_DATE = Time.utc(2016, 6, 6)
26
24
  end
27
25
 
28
26
  module LatestGroongaVersion
29
27
  MAJOR = 6
30
28
  MINOR = 0
31
- MICRO = 2
29
+ MICRO = 4
32
30
  VERSION = [MAJOR, MINOR, MICRO]
33
31
  end
34
32
 
@@ -0,0 +1,53 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
+
16
+ class DataColumnTest < Test::Unit::TestCase
17
+ include GroongaTestUtils
18
+
19
+ def setup
20
+ setup_database
21
+ end
22
+
23
+ sub_test_case "#apply_window_function" do
24
+ def test_no_argument
25
+ Groonga::Schema.define do |schema|
26
+ schema.create_table("Comments") do |table|
27
+ table.uint32("nth")
28
+ end
29
+ end
30
+ comments = Groonga["Comments"]
31
+ nth = Groonga["Comments.nth"]
32
+
33
+ 5.times do
34
+ comments.add
35
+ end
36
+
37
+ options = {
38
+ :sort_keys => [["_id", "desc"]],
39
+ }
40
+ nth.apply_window_function(options) do |record|
41
+ record.call("record_number")
42
+ end
43
+ assert_equal([
44
+ [1, 5],
45
+ [2, 4],
46
+ [3, 3],
47
+ [4, 2],
48
+ [5, 1],
49
+ ],
50
+ comments.collect {|comment| [comment.id, comment.nth]})
51
+ end
52
+ end
53
+ end
@@ -52,6 +52,12 @@ class ProcedureTest < Test::Unit::TestCase
52
52
  end
53
53
  end
54
54
 
55
+ def test_window_function_procedure?
56
+ assert do
57
+ Groonga["record_number"].window_function_procedure?
58
+ end
59
+ end
60
+
55
61
  private
56
62
  def assert_equal_procedure(expected_name, id, options={})
57
63
  procedure = Groonga::Context.default[id]
@@ -70,6 +76,12 @@ class ProcedureTest < Test::Unit::TestCase
70
76
  scorer = Groonga["scorer_tf_idf"]
71
77
  assert_equal(Groonga::ProcedureType::SCORER, scorer.type)
72
78
  end
79
+
80
+ def test_window_function
81
+ record_number = Groonga["record_number"]
82
+ assert_equal(Groonga::ProcedureType::WINDOW_FUNCTION,
83
+ record_number.type)
84
+ end
73
85
  end
74
86
 
75
87
  class SelectorOnlyProcedureTest < self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-05-18 00:00:00.000000000 Z
15
+ date: 2016-06-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pkg-config
@@ -237,6 +237,7 @@ files:
237
237
  - ext/groonga/rb-grn-column.c
238
238
  - ext/groonga/rb-grn-config.c
239
239
  - ext/groonga/rb-grn-context.c
240
+ - ext/groonga/rb-grn-data-column.c
240
241
  - ext/groonga/rb-grn-database.c
241
242
  - ext/groonga/rb-grn-double-array-trie-cursor.c
242
243
  - ext/groonga/rb-grn-double-array-trie.c
@@ -281,6 +282,7 @@ files:
281
282
  - ext/groonga/rb-grn-table-cursor-key-support.c
282
283
  - ext/groonga/rb-grn-table-cursor.c
283
284
  - ext/groonga/rb-grn-table-key-support.c
285
+ - ext/groonga/rb-grn-table-sort-keys.c
284
286
  - ext/groonga/rb-grn-table.c
285
287
  - ext/groonga/rb-grn-thread.c
286
288
  - ext/groonga/rb-grn-type.c
@@ -327,6 +329,7 @@ files:
327
329
  - test/test-config.rb
328
330
  - test/test-context.rb
329
331
  - test/test-convert.rb
332
+ - test/test-data-column.rb
330
333
  - test/test-database-dumper.rb
331
334
  - test/test-database-inspector.rb
332
335
  - test/test-database.rb
@@ -427,6 +430,7 @@ test_files:
427
430
  - test/test-hash.rb
428
431
  - test/test-gqtp.rb
429
432
  - test/test-table-dumper.rb
433
+ - test/test-data-column.rb
430
434
  - test/test-pagination.rb
431
435
  - test/test-column.rb
432
436
  - test/test-table-traverse.rb