rroonga 5.0.4 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
4
- Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
4
+ Copyright (C) 2014-2015 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU Lesser General Public
@@ -1604,6 +1604,32 @@ rb_grn_object_selector_procedure_p (VALUE self)
1604
1604
  return CBOOL2RVAL(selector_procedure_p);
1605
1605
  }
1606
1606
 
1607
+ /*
1608
+ * Checks whether the object is selector only procedure or not.
1609
+ *
1610
+ * @overload selector_only_procedure?
1611
+ * @return [Boolean] `true` if the object is selector only procedure,
1612
+ * `false` otherwise.
1613
+ *
1614
+ * @since 5.0.5
1615
+ */
1616
+ static VALUE
1617
+ rb_grn_object_selector_only_procedure_p (VALUE self)
1618
+ {
1619
+ grn_ctx *context;
1620
+ grn_obj *object;
1621
+ grn_bool selector_only_procedure_p = GRN_FALSE;
1622
+
1623
+ rb_grn_object_deconstruct(SELF(self), &object, &context,
1624
+ NULL, NULL, NULL, NULL);
1625
+
1626
+ if (context && object) {
1627
+ selector_only_procedure_p = grn_obj_is_selector_only_proc(context, object);
1628
+ }
1629
+
1630
+ return CBOOL2RVAL(selector_only_procedure_p);
1631
+ }
1632
+
1607
1633
  /*
1608
1634
  * Checks whether the object is scorer procedure or not.
1609
1635
  *
@@ -1671,6 +1697,8 @@ rb_grn_init_object (VALUE mGrn)
1671
1697
  rb_grn_object_function_procedure_p, 0);
1672
1698
  rb_define_method(rb_cGrnObject, "selector_procedure?",
1673
1699
  rb_grn_object_selector_procedure_p, 0);
1700
+ rb_define_method(rb_cGrnObject, "selector_only_procedure?",
1701
+ rb_grn_object_selector_only_procedure_p, 0);
1674
1702
  rb_define_method(rb_cGrnObject, "scorer_procedure?",
1675
1703
  rb_grn_object_scorer_procedure_p, 0);
1676
1704
  }
@@ -565,17 +565,10 @@ rb_grn_patricia_trie_open_grn_prefix_cursor (int argc, VALUE *argv, VALUE self,
565
565
  } else if (rb_grn_equal_option(rb_order_by, "id")) {
566
566
  flags |= GRN_CURSOR_BY_ID;
567
567
  } else if (rb_grn_equal_option(rb_order_by, "key")) {
568
- if (table->header.type != GRN_TABLE_PAT_KEY) {
569
- rb_raise(rb_eArgError,
570
- "order_by => :key is available "
571
- "only for Groonga::PatriciaTrie: %s",
572
- rb_grn_inspect(self));
573
- }
574
568
  flags |= GRN_CURSOR_BY_KEY;
575
569
  } else {
576
570
  rb_raise(rb_eArgError,
577
- "order_by should be one of [:id%s]: %s",
578
- table->header.type == GRN_TABLE_PAT_KEY ? ", :key" : "",
571
+ "order_by should be one of [:id, :key]: %s",
579
572
  rb_grn_inspect(rb_order_by));
580
573
  }
581
574
 
@@ -107,11 +107,16 @@ rb_grn_table_cursor_order_by_to_flag (unsigned char table_type,
107
107
  } else if (rb_grn_equal_option(rb_order_by, "id")) {
108
108
  flag |= GRN_CURSOR_BY_ID;
109
109
  } else if (rb_grn_equal_option(rb_order_by, "key")) {
110
- if (table_type != GRN_TABLE_PAT_KEY) {
110
+ switch (table_type) {
111
+ case GRN_TABLE_PAT_KEY:
112
+ case GRN_TABLE_DAT_KEY:
113
+ break;
114
+ default:
111
115
  rb_raise(rb_eArgError,
112
- "order_by => :key is available "
113
- "only for Groonga::PatriciaTrie: %s",
116
+ "order_by => :key is available only for "
117
+ "Groonga::PatriciaTrie and Groonga::DoubleArrayTrie: %s",
114
118
  rb_grn_inspect(rb_table));
119
+ break;
115
120
  }
116
121
  flag |= GRN_CURSOR_BY_KEY;
117
122
  } else {
@@ -819,11 +819,16 @@ rb_grn_table_open_grn_cursor (int argc, VALUE *argv, VALUE self,
819
819
  * +:desc+ または +:descending+ を指定すると降順にレコードを
820
820
  * 取り出す。
821
821
  * @option options :order_by
822
- * +:id+ を指定するとID順にレコードを取り出す。(Arrayと
823
- * Hashのデフォルト)
824
- * +:key+ 指定するとキー順にレコードを取り出す。ただし、
825
- * Groonga::PatriciaTrieにしか使えない。(PatriciaTrieのデ
826
- * フォルト)
822
+ *
823
+ * `:id` means that the cursor returns the next record by ID
824
+ * order. It's the default for `Groonga::Array` and
825
+ * `Groonga::Hash`.
826
+ *
827
+ * `:key` means that the cursor returns the next record by key
828
+ * order. You can use it only for `Groonga::PatriciaTrie` and
829
+ * `Groonga::DoubleArrayTrie`. It's the default for
830
+ * `Groonga::PatriciaTrie` and `Groonga::DoubleArrayTrie`.
831
+ *
827
832
  * @option options :greater_than
828
833
  * +true+ を指定すると +:min+ で指定した値に一致した [ +key+ ] を
829
834
  * 範囲に含まない。
@@ -0,0 +1,160 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /*
3
+ Copyright (C) 2015 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
+ static ID id_call;
22
+
23
+ /*
24
+ * Document-class: Groonga::Thread
25
+ *
26
+ * It's a namespace for thread related features.
27
+ */
28
+
29
+ /*
30
+ * @overload limit()
31
+ *
32
+ * @return [Integer] the max number of threads. `0` means that
33
+ * thread isn't supported.
34
+ *
35
+ * @since 5.0.5
36
+ */
37
+ static VALUE
38
+ rb_grn_thread_s_get_limit (VALUE self)
39
+ {
40
+ uint32_t limit;
41
+
42
+ limit = grn_thread_get_limit();
43
+
44
+ return UINT2NUM(limit);
45
+ }
46
+
47
+ /*
48
+ * @overload limit=(new_limit)
49
+ *
50
+ * Sets the max number of threads.
51
+ *
52
+ * @param new_limit [Integer] The new max number of threads.
53
+ *
54
+ * @return [void]
55
+ *
56
+ * @since 5.0.5
57
+ */
58
+ static VALUE
59
+ rb_grn_thread_s_set_limit (VALUE self, VALUE rb_new_limit)
60
+ {
61
+ uint32_t new_limit;
62
+
63
+ new_limit = NUM2UINT(rb_new_limit);
64
+ grn_thread_set_limit(new_limit);
65
+
66
+ return Qnil;
67
+ }
68
+
69
+ static uint32_t
70
+ rb_grn_thread_get_limit_func (void *data)
71
+ {
72
+ VALUE callable = (VALUE)data;
73
+ VALUE rb_limit;
74
+
75
+ rb_limit = rb_funcall(callable, id_call, 0);
76
+
77
+ return NUM2UINT(rb_limit);
78
+ }
79
+
80
+ /*
81
+ * @overload limit_getter=(getter)
82
+ *
83
+ * Sets a callable object that returns the max number of threads.
84
+ *
85
+ * @param getter [#call] Callable object that returns the max number
86
+ * of threads.
87
+ *
88
+ * @return [void]
89
+ *
90
+ * @since 5.0.5
91
+ */
92
+ static VALUE
93
+ rb_grn_thread_s_set_limit_getter (VALUE self, VALUE rb_getter)
94
+ {
95
+ rb_iv_set(self, "@limit_getter", rb_getter);
96
+
97
+ if (NIL_P(rb_getter)) {
98
+ grn_thread_set_get_limit_func(NULL, NULL);
99
+ } else {
100
+ grn_thread_set_get_limit_func(rb_grn_thread_get_limit_func,
101
+ (void *)rb_getter);
102
+ }
103
+
104
+ return Qnil;
105
+ }
106
+
107
+ static void
108
+ rb_grn_thread_set_limit_func (uint32_t new_limit, void *data)
109
+ {
110
+ VALUE callable = (VALUE)data;
111
+
112
+ rb_funcall(callable, id_call, 1, UINT2NUM(new_limit));
113
+ }
114
+
115
+ /*
116
+ * @overload limit_setter=(setter)
117
+ *
118
+ * Sets a callable object that sets the max number of threads.
119
+ *
120
+ * @param setter [#call] Callable object that sets the max number
121
+ * of threads.
122
+ *
123
+ * @return [void]
124
+ *
125
+ * @since 5.0.5
126
+ */
127
+ static VALUE
128
+ rb_grn_thread_s_set_limit_setter (VALUE self, VALUE rb_setter)
129
+ {
130
+ rb_iv_set(self, "@limit_setter", rb_setter);
131
+
132
+ if (NIL_P(rb_setter)) {
133
+ grn_thread_set_set_limit_func(NULL, NULL);
134
+ } else {
135
+ grn_thread_set_set_limit_func(rb_grn_thread_set_limit_func,
136
+ (void *)rb_setter);
137
+ }
138
+
139
+ return Qnil;
140
+ }
141
+
142
+ void
143
+ rb_grn_init_thread (VALUE mGrn)
144
+ {
145
+ VALUE rb_mGrnThread;
146
+
147
+ CONST_ID(id_call, "call");
148
+
149
+ rb_mGrnThread = rb_define_module_under(mGrn, "Thread");
150
+
151
+ rb_define_singleton_method(rb_mGrnThread, "limit",
152
+ rb_grn_thread_s_get_limit, 0);
153
+ rb_define_singleton_method(rb_mGrnThread, "limit=",
154
+ rb_grn_thread_s_set_limit, 1);
155
+
156
+ rb_define_singleton_method(rb_mGrnThread, "limit_getter=",
157
+ rb_grn_thread_s_set_limit_getter, 1);
158
+ rb_define_singleton_method(rb_mGrnThread, "limit_setter=",
159
+ rb_grn_thread_s_set_limit_setter, 1);
160
+ }
@@ -0,0 +1,79 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /*
3
+ Copyright (C) 2015 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
+ /*
22
+ * Document-class: Groonga::WindowsEventLogger
23
+ *
24
+ * It's a module for using Windows Event Log as log output.
25
+ */
26
+
27
+ /*
28
+ * @overload register(event_source_name, options={})
29
+ *
30
+ * Registers Windows Event Log based logger that uses
31
+ * `event_source_name` as event source name.
32
+ *
33
+ * @param event_source_name [String] The event source name.
34
+ * @param options [::Hash]
35
+ * @option options :context [Groonga::Context] (Groonga::Context.default)
36
+ * The context to be set logger.
37
+ *
38
+ * @return [void]
39
+ *
40
+ * @since 5.0.5
41
+ */
42
+ static VALUE
43
+ rb_grn_windows_event_logger_s_register (int argc,
44
+ VALUE *argv,
45
+ VALUE klass)
46
+ {
47
+ VALUE rb_event_source_name;
48
+ VALUE rb_options;
49
+ VALUE rb_context;
50
+ const char *event_source_name;
51
+ grn_ctx *context;
52
+ grn_rc rc;
53
+
54
+ rb_scan_args(argc, argv, "11", &rb_event_source_name, &rb_options);
55
+ rb_event_source_name = rb_grn_convert_to_string(rb_event_source_name);
56
+ event_source_name = StringValueCStr(rb_event_source_name);
57
+
58
+ rb_grn_scan_options(rb_options,
59
+ "context", &rb_context,
60
+ NULL);
61
+ context = rb_grn_context_ensure(&rb_context);
62
+
63
+ rc = grn_windows_event_logger_set(context, event_source_name);
64
+ rb_grn_context_check(context, rb_event_source_name);
65
+ rb_grn_rc_check(rc, rb_event_source_name);
66
+
67
+ return Qnil;
68
+ }
69
+
70
+ void
71
+ rb_grn_init_windows_event_logger (VALUE mGrn)
72
+ {
73
+ VALUE mGrnWindowsEventLogger;
74
+
75
+ mGrnWindowsEventLogger = rb_define_module_under(mGrn, "WindowsEventLogger");
76
+
77
+ rb_define_singleton_method(mGrnWindowsEventLogger, "register",
78
+ rb_grn_windows_event_logger_s_register, -1);
79
+ }
@@ -101,7 +101,7 @@ RB_GRN_BEGIN_DECLS
101
101
 
102
102
  #define RB_GRN_MAJOR_VERSION 5
103
103
  #define RB_GRN_MINOR_VERSION 0
104
- #define RB_GRN_MICRO_VERSION 4
104
+ #define RB_GRN_MICRO_VERSION 5
105
105
 
106
106
  #define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
107
107
 
@@ -349,9 +349,11 @@ void rb_grn_init_expression (VALUE mGrn);
349
349
  void rb_grn_init_expression_builder (VALUE mGrn);
350
350
  void rb_grn_init_logger (VALUE mGrn);
351
351
  void rb_grn_init_query_logger (VALUE mGrn);
352
+ void rb_grn_init_windows_event_logger (VALUE mGrn);
352
353
  void rb_grn_init_snippet (VALUE mGrn);
353
354
  void rb_grn_init_plugin (VALUE mGrn);
354
355
  void rb_grn_init_normalizer (VALUE mGrn);
356
+ void rb_grn_init_thread (VALUE mGrn);
355
357
 
356
358
  VALUE rb_grn_rc_to_exception (grn_rc rc);
357
359
  const char *rb_grn_rc_to_message (grn_rc rc);
@@ -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-2015 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
@@ -187,7 +187,9 @@ Init_groonga (void)
187
187
  rb_grn_init_expression_builder(mGrn);
188
188
  rb_grn_init_logger(mGrn);
189
189
  rb_grn_init_query_logger(mGrn);
190
+ rb_grn_init_windows_event_logger(mGrn);
190
191
  rb_grn_init_snippet(mGrn);
191
192
  rb_grn_init_plugin(mGrn);
192
193
  rb_grn_init_normalizer(mGrn);
194
+ rb_grn_init_thread(mGrn);
193
195
  }
@@ -704,7 +704,12 @@ module Groonga
704
704
  end
705
705
 
706
706
  def dump_records(columns)
707
- @table.each(:order_by => @options[:order_by]) do |record|
707
+ order_by = @options[:order_by]
708
+ case @table
709
+ when Groonga::Array, Groonga::Hash
710
+ order_by = nil if order_by == :key
711
+ end
712
+ @table.each(:order_by => order_by) do |record|
708
713
  write(",\n")
709
714
  values = columns.collect do |column|
710
715
  resolve_value(record, column, column[record.id])
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
+ # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
3
4
  # Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
4
- # Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
5
5
  #
6
6
  # This library is free software; you can redistribute it and/or
7
7
  # modify it under the terms of the GNU Lesser General Public
@@ -20,15 +20,15 @@ module RroongaBuild
20
20
  module RequiredGroongaVersion
21
21
  MAJOR = 5
22
22
  MINOR = 0
23
- MICRO = 5
23
+ MICRO = 7
24
24
  VERSION = [MAJOR, MINOR, MICRO]
25
- RELEASED_DATE = Time.utc(2015, 6, 29)
25
+ RELEASED_DATE = Time.utc(2015, 8, 31)
26
26
  end
27
27
 
28
28
  module LatestGroongaVersion
29
29
  MAJOR = 5
30
30
  MINOR = 0
31
- MICRO = 5
31
+ MICRO = 7
32
32
  VERSION = [MAJOR, MINOR, MICRO]
33
33
  end
34
34
 
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
2
- # Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU Lesser General Public
@@ -174,6 +174,10 @@ module GroongaTestUtils
174
174
  omit("This test is only for Linux system.") unless linux?
175
175
  end
176
176
 
177
+ def windows?
178
+ /cygwin|mingw|mswin/ === RUBY_PLATFORM
179
+ end
180
+
177
181
  def support_self_recursive_equal?
178
182
  self_recursive_hash1 = {}
179
183
  self_recursive_hash1["next"] = self_recursive_hash1