rroonga 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +13 -5
  2. data/Gemfile +1 -1
  3. data/README.textile +1 -1
  4. data/Rakefile +8 -1
  5. data/bin/grndump +1 -1
  6. data/bin/grntest-log-analyze +1 -1
  7. data/bin/groonga-database-inspect +1 -1
  8. data/bin/groonga-index-dump +1 -1
  9. data/doc/text/news.textile +28 -0
  10. data/ext/groonga/extconf.rb +12 -2
  11. data/ext/groonga/rb-grn-accessor.c +2 -1
  12. data/ext/groonga/rb-grn-array-cursor.c +1 -1
  13. data/ext/groonga/rb-grn-array.c +1 -1
  14. data/ext/groonga/rb-grn-column.c +1 -1
  15. data/ext/groonga/rb-grn-context.c +7 -5
  16. data/ext/groonga/rb-grn-database.c +1 -1
  17. data/ext/groonga/rb-grn-double-array-trie-cursor.c +1 -1
  18. data/ext/groonga/rb-grn-double-array-trie.c +1 -1
  19. data/ext/groonga/rb-grn-encoding-support.c +1 -1
  20. data/ext/groonga/rb-grn-encoding.c +1 -1
  21. data/ext/groonga/rb-grn-exception.c +1 -1
  22. data/ext/groonga/rb-grn-expression-builder.c +1 -1
  23. data/ext/groonga/rb-grn-expression.c +1 -1
  24. data/ext/groonga/rb-grn-fix-size-column.c +1 -1
  25. data/ext/groonga/rb-grn-geo-point.c +1 -1
  26. data/ext/groonga/rb-grn-hash-cursor.c +1 -1
  27. data/ext/groonga/rb-grn-hash.c +1 -1
  28. data/ext/groonga/rb-grn-index-column.c +1 -1
  29. data/ext/groonga/rb-grn-index-cursor.c +1 -1
  30. data/ext/groonga/rb-grn-logger.c +1 -1
  31. data/ext/groonga/rb-grn-normalizer.c +1 -1
  32. data/ext/groonga/rb-grn-object.c +71 -45
  33. data/ext/groonga/rb-grn-operator.c +1 -1
  34. data/ext/groonga/rb-grn-patricia-trie-cursor.c +1 -1
  35. data/ext/groonga/rb-grn-patricia-trie.c +1 -1
  36. data/ext/groonga/rb-grn-plugin.c +1 -1
  37. data/ext/groonga/rb-grn-posting.c +1 -1
  38. data/ext/groonga/rb-grn-procedure-type.c +40 -0
  39. data/ext/groonga/rb-grn-procedure.c +17 -4
  40. data/ext/groonga/rb-grn-query-logger.c +1 -1
  41. data/ext/groonga/rb-grn-record.c +1 -1
  42. data/ext/groonga/rb-grn-snippet.c +1 -1
  43. data/ext/groonga/rb-grn-table-cursor-key-support.c +1 -1
  44. data/ext/groonga/rb-grn-table-cursor.c +1 -1
  45. data/ext/groonga/rb-grn-table-key-support.c +1 -1
  46. data/ext/groonga/rb-grn-table.c +3 -2
  47. data/ext/groonga/rb-grn-type.c +1 -1
  48. data/ext/groonga/rb-grn-utils.c +1 -1
  49. data/ext/groonga/rb-grn-variable-size-column.c +55 -27
  50. data/ext/groonga/rb-grn-variable.c +1 -1
  51. data/ext/groonga/rb-grn.h +4 -2
  52. data/ext/groonga/rb-groonga.c +3 -2
  53. data/extconf.rb +1 -1
  54. data/lib/groonga.rb +1 -1
  55. data/lib/groonga/column.rb +1 -1
  56. data/lib/groonga/context.rb +1 -1
  57. data/lib/groonga/context/command-executor.rb +1 -1
  58. data/lib/groonga/database-inspector.rb +1 -1
  59. data/lib/groonga/database.rb +1 -1
  60. data/lib/groonga/dumper.rb +1 -1
  61. data/lib/groonga/expression-builder-19.rb +1 -1
  62. data/lib/groonga/expression-builder.rb +1 -1
  63. data/lib/groonga/geo-point.rb +1 -1
  64. data/lib/groonga/grntest-log.rb +1 -1
  65. data/lib/groonga/index-column.rb +1 -1
  66. data/lib/groonga/logger.rb +1 -1
  67. data/lib/groonga/memory-pool.rb +1 -2
  68. data/lib/groonga/pagination.rb +1 -1
  69. data/lib/groonga/patricia-trie.rb +1 -1
  70. data/lib/groonga/posting.rb +1 -1
  71. data/lib/groonga/query-logger.rb +1 -1
  72. data/lib/groonga/record.rb +6 -2
  73. data/lib/groonga/schema.rb +1 -1
  74. data/lib/groonga/statistic-measurer.rb +1 -1
  75. data/lib/groonga/sub-records.rb +1 -1
  76. data/lib/groonga/table.rb +1 -1
  77. data/misc/grnop2ruby.rb +1 -1
  78. data/rroonga-build.rb +4 -4
  79. data/rroonga.gemspec +3 -3
  80. data/test/groonga-test-utils.rb +4 -4
  81. data/test/run-test.rb +1 -1
  82. data/test/test-accessor.rb +1 -1
  83. data/test/test-array.rb +1 -1
  84. data/test/test-column.rb +1 -1
  85. data/test/test-command-select.rb +1 -1
  86. data/test/test-context.rb +21 -16
  87. data/test/test-convert.rb +1 -1
  88. data/test/test-database-dumper.rb +1 -1
  89. data/test/test-database-inspector.rb +1 -1
  90. data/test/test-database.rb +38 -25
  91. data/test/test-double-array-trie.rb +1 -1
  92. data/test/test-encoding.rb +1 -1
  93. data/test/test-exception.rb +12 -7
  94. data/test/test-expression-builder.rb +1 -1
  95. data/test/test-expression.rb +1 -1
  96. data/test/test-fix-size-column.rb +1 -1
  97. data/test/test-geo-point.rb +1 -1
  98. data/test/test-gqtp.rb +1 -1
  99. data/test/test-hash.rb +1 -1
  100. data/test/test-index-column.rb +1 -1
  101. data/test/test-index-cursor.rb +1 -1
  102. data/test/test-lock-timeout.rb +1 -1
  103. data/test/test-logger.rb +1 -1
  104. data/test/test-memory-pool.rb +1 -1
  105. data/test/test-normalizer.rb +1 -1
  106. data/test/test-pagination.rb +1 -1
  107. data/test/test-patricia-trie.rb +1 -1
  108. data/test/test-plugin.rb +1 -1
  109. data/test/test-procedure.rb +9 -2
  110. data/test/test-record.rb +1 -1
  111. data/test/test-remote.rb +1 -1
  112. data/test/test-schema-create-table.rb +1 -1
  113. data/test/test-schema-dumper.rb +1 -1
  114. data/test/test-schema-type.rb +1 -1
  115. data/test/test-schema.rb +1 -1
  116. data/test/test-snippet.rb +1 -1
  117. data/test/test-statistic-measurer.rb +1 -1
  118. data/test/test-sub-records.rb +1 -1
  119. data/test/test-table-dumper.rb +1 -1
  120. data/test/test-table-key-support.rb +1 -1
  121. data/test/test-table-offset-and-limit.rb +1 -1
  122. data/test/test-table-select-mecab.rb +1 -1
  123. data/test/test-table-select-normalize.rb +1 -1
  124. data/test/test-table-select-weight.rb +1 -1
  125. data/test/test-table-select.rb +1 -1
  126. data/test/test-table-traverse.rb +1 -1
  127. data/test/test-table.rb +1 -1
  128. data/test/test-type.rb +1 -1
  129. data/test/test-variable-size-column.rb +136 -67
  130. data/test/test-variable.rb +1 -1
  131. data/test/test-vector-column.rb +1 -1
  132. data/test/test-version.rb +1 -1
  133. metadata +83 -80
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8d5670d6f858be2364f027b3bcd907de5e18d342
4
- data.tar.gz: 5e5aed82c913c8f8a50c865d17b867f680d5677f
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWE2YmYxNmUyYjY1N2M0Mjk3NjA4OTIyNjIyNzY2ODgxODY4MTkwYg==
5
+ data.tar.gz: !binary |-
6
+ ZWU1ODAxN2JjNjAwNzQ3M2UzMmEzNzVjM2RiODM5NmRhMDVmYjQ1Mw==
5
7
  SHA512:
6
- metadata.gz: f7634917933dbf137843426de92eef2db163c7bc0b8cc51511a99d5ca53e43a745d50f48ad8fbbd3b6a43ef38329861f08e322daefb81085844f1bc741915a6c
7
- data.tar.gz: c9f30a3b12dc1021014dbcb3999635b5d63dc7693d97a3fb521daec3aaebe45f41d0abdcb195067ce4ecc4fc39a899517fb7fe15faeccedc1be88d497d75a359
8
+ metadata.gz: !binary |-
9
+ YmZkNjU3ZGVlYjM2YTNlMTQ2NDdhY2MxZWZhZjIwZWM2MjBhNzUyNWU4YWI4
10
+ NmYzYTkxZDAxNzNhMTk4ZGZiMmRlMjIyM2U1ODZlNTlkYjUzMzIxZDc0YmY1
11
+ MzQ4NzY2OGFhMWU3NDM3Mjk3OTExOGNlZWMwN2FkYzU2M2M5ZDI=
12
+ data.tar.gz: !binary |-
13
+ Mjg5Yjk4ZGRiNjJjNWVmOTdjODNkM2MyYTE2YzYwMDQ2YWQ5ODRmNDIwNWI5
14
+ NGY2NTAwMmYyMzU0ZjdmM2ZiNjllZTY4MDZkZjBjMWFhNjMxZDk3ZjE0MjE0
15
+ ZDVlNTIwYzBkNTI4Y2Y2YzdkMGJjYzk4NmQ4ZmQxYWYyYTg1ZjE=
data/Gemfile CHANGED
@@ -13,7 +13,7 @@
13
13
  #
14
14
  # You should have received a copy of the GNU Lesser General Public
15
15
  # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
  source "https://rubygems.org/"
19
19
 
@@ -37,7 +37,7 @@ contributed patches.)
37
37
  h2. Dependencies
38
38
 
39
39
  * Ruby >= 1.9.3
40
- * Groonga >= 3.0.8
40
+ * Groonga >= 4.0.4
41
41
 
42
42
  h2. Install
43
43
 
data/Rakefile CHANGED
@@ -13,7 +13,7 @@
13
13
  #
14
14
  # You should have received a copy of the GNU Lesser General Public
15
15
  # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
  require "find"
19
19
  require "fileutils"
@@ -156,4 +156,11 @@ namespace :test do
156
156
  end
157
157
  end
158
158
 
159
+ desc "Remove Groonga binary directory"
160
+ namespace :clean do
161
+ task :groonga do
162
+ rm_rf binary_dir
163
+ end
164
+ end
165
+
159
166
  task :default => :test
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # You should have received a copy of the GNU Lesser General Public
16
16
  # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  require "ostruct"
20
20
  require "optparse"
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # You should have received a copy of the GNU Lesser General Public
16
16
  # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  require "ostruct"
20
20
  require "optparse"
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # You should have received a copy of the GNU Lesser General Public
16
16
  # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  require "ostruct"
20
20
  require "optparse"
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # You should have received a copy of the GNU Lesser General Public
16
16
  # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  require "ostruct"
20
20
  require "optparse"
@@ -1,5 +1,33 @@
1
1
  h1. NEWS
2
2
 
3
+ h2(#4-0-4). 4.0.4: 2014-08-29 (planned)
4
+
5
+ h3. Improvements
6
+
7
+ * Supported Groonga 4.0.4. Groonga 4.0.3 or older are not supported.
8
+ * Added {Groonga::ProcedureType} that has constants as GRN_PROC_XXX.
9
+ * Added {Groonga::Procedure#type} as grn_proc_get_type().
10
+ <pre>
11
+ procedure = Groonga["TokenBigram"]
12
+ p procedure.type == Groonga::ProcedureType::TOKENIZER #=> true
13
+ </pre>
14
+ * Avoided a crash when {Groonga::Record#inspct} is called on exit.
15
+ [GitHub#18] [Reported by Ippei Obayashi]
16
+ * Updated Free Software Foundation address. [Masafumi Yokoyama]
17
+ * Supported reference weight vector. It requires Groonga 4.0.4 or later.
18
+ * Updated homepage in gemspec to use ranguba.org. [Masafumi Yokoyama]
19
+ * Reduce memory usage without GC.
20
+
21
+ h3. Fixes
22
+
23
+ * Fixed a GC related crash when GC is run while {Groonga::Table#group}.
24
+
25
+ h3. Thanks
26
+
27
+ * Ippei Obayashi
28
+ * uu59
29
+ * cosmo0920
30
+
3
31
  h2(#4-0-3). 4.0.3: 2014-06-04
4
32
 
5
33
  h3. Fixes
@@ -13,7 +13,7 @@
13
13
  #
14
14
  # You should have received a copy of the GNU Lesser General Public
15
15
  # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
  require "English"
19
19
  require "pathname"
@@ -231,7 +231,7 @@ def build_groonga(major, minor, micro)
231
231
  end
232
232
  end
233
233
 
234
- unless PKGConfig.have_package(package_name, major, minor, micro)
234
+ def install_local_groonga(package_name, major, minor, micro)
235
235
  unless have_local_groonga?(package_name, major, minor, micro)
236
236
  required_version = [major, minor, micro]
237
237
  if (required_version <=> LatestGroongaVersion::VERSION) < 0
@@ -247,6 +247,16 @@ unless PKGConfig.have_package(package_name, major, minor, micro)
247
247
  add_rpath_for_local_groonga
248
248
  end
249
249
 
250
+ if win32?
251
+ unless have_local_groonga?(package_name, major, minor, micro)
252
+ install_local_groonga(package_name, major, minor, micro)
253
+ end
254
+ else
255
+ unless PKGConfig.have_package(package_name, major, minor, micro)
256
+ install_local_groonga(package_name, major, minor, micro)
257
+ end
258
+ end
259
+
250
260
  real_version = PKGConfig.modversion(package_name)
251
261
  real_major, real_minor, real_micro = real_version.split(/\./)
252
262
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -66,6 +66,7 @@ void
66
66
  rb_grn_accessor_finalizer (grn_ctx *context, grn_obj *grn_object,
67
67
  RbGrnAccessor *rb_accessor)
68
68
  {
69
+ rb_grn_context_unregister_floating_object(RB_GRN_OBJECT(rb_accessor));
69
70
  rb_grn_named_object_finalizer(context, grn_object,
70
71
  RB_GRN_NAMED_OBJECT(rb_accessor));
71
72
  if (context && rb_accessor->value)
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -14,7 +14,7 @@
14
14
 
15
15
  You should have received a copy of the GNU Lesser General Public
16
16
  License along with this library; if not, write to the Free Software
17
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
  */
19
19
 
20
20
  #include "rb-grn.h"
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2010-2012 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2010-2014 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
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -79,6 +79,8 @@ rb_grn_context_register_floating_object (RbGrnObject *rb_grn_object)
79
79
  (const void *)(&rb_grn_object), sizeof(RbGrnObject *),
80
80
  NULL, NULL);
81
81
  rb_grn_object->floating = GRN_TRUE;
82
+
83
+ rb_grn_context_object_created(rb_grn_context->self, rb_grn_object->self);
82
84
  }
83
85
 
84
86
  void
@@ -117,9 +119,9 @@ rb_grn_context_close_floating_objects (RbGrnContext *rb_grn_context)
117
119
 
118
120
  rb_grn_context->floating_objects = NULL;
119
121
  GRN_HASH_EACH(context, floating_objects, id, &floating_object, NULL, NULL, {
120
- (*floating_object)->floating = GRN_FALSE;
121
- grn_obj_close(context, RB_GRN_OBJECT(*floating_object)->object);
122
- });
122
+ (*floating_object)->floating = GRN_FALSE;
123
+ rb_grn_object_close_raw(*floating_object);
124
+ });
123
125
  grn_hash_close(context, floating_objects);
124
126
  }
125
127
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -14,7 +14,7 @@
14
14
 
15
15
  You should have received a copy of the GNU Lesser General Public
16
16
  License along with this library; if not, write to the Free Software
17
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
  */
19
19
 
20
20
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -14,7 +14,7 @@
14
14
 
15
15
  You should have received a copy of the GNU Lesser General Public
16
16
  License along with this library; if not, write to the Free Software
17
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
  */
19
19
 
20
20
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  #include "rb-grn.h"
@@ -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-2013 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2009-2014 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
@@ -13,7 +13,7 @@
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public
15
15
  License along with this library; if not, write to the Free Software
16
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
19
  /*
@@ -52,7 +52,7 @@ rb_grn_object_from_ruby_object (VALUE object, grn_ctx **context)
52
52
  rb_grn_context_check(*context, object);
53
53
  if (!grn_object)
54
54
  rb_raise(rb_eArgError,
55
- "unregistered groonga object: name: <%s>",
55
+ "unregistered Groonga object: name: <%s>",
56
56
  rb_grn_inspect(object));
57
57
  return grn_object;
58
58
  } else if (RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cInteger))) {
@@ -60,24 +60,24 @@ rb_grn_object_from_ruby_object (VALUE object, grn_ctx **context)
60
60
  rb_grn_context_check(*context, object);
61
61
  if (!grn_object)
62
62
  rb_raise(rb_eArgError,
63
- "unregistered groonga object: ID: <%s>",
63
+ "unregistered Groonga object: ID: <%s>",
64
64
  rb_grn_inspect(object));
65
65
  return grn_object;
66
66
  }
67
67
  }
68
68
 
69
69
  if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnObject))) {
70
- rb_raise(rb_eTypeError, "not a groonga object: <%s>",
70
+ rb_raise(rb_eTypeError, "not a Groonga object: <%s>",
71
71
  rb_grn_inspect(object));
72
72
  }
73
73
 
74
74
  Data_Get_Struct(object, RbGrnObject, rb_grn_object);
75
75
  if (!rb_grn_object)
76
- rb_raise(rb_eGrnError, "groonga object is NULL");
76
+ rb_raise(rb_eGrnError, "Groonga object is NULL");
77
77
 
78
78
  if (!rb_grn_object->object) {
79
79
  rb_raise(rb_eGrnClosed,
80
- "can't access already closed groonga object: %s",
80
+ "can't access already closed Groonga object: %s",
81
81
  rb_grn_inspect(CLASS_OF(rb_grn_object->self)));
82
82
  }
83
83
 
@@ -87,6 +87,19 @@ rb_grn_object_from_ruby_object (VALUE object, grn_ctx **context)
87
87
  return rb_grn_object->object;
88
88
  }
89
89
 
90
+ static void
91
+ rb_grn_object_unbind (RbGrnObject *rb_grn_object)
92
+ {
93
+ debug("unbind: %p:%p:%p %s(%#x)\n",
94
+ rb_grn_object->context, rb_grn_object->object, rb_grn_object,
95
+ rb_grn_inspect_type(rb_grn_object->object->header.type),
96
+ rb_grn_object->object->header.type);
97
+
98
+ rb_grn_object->rb_grn_context = NULL;
99
+ rb_grn_object->context = NULL;
100
+ rb_grn_object->object = NULL;
101
+ }
102
+
90
103
  static void
91
104
  rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object,
92
105
  RbGrnObject *rb_grn_object)
@@ -109,61 +122,59 @@ rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object,
109
122
  rb_grn_object->have_finalizer = GRN_FALSE;
110
123
 
111
124
  switch (grn_object->header.type) {
112
- case GRN_DB:
125
+ case GRN_DB:
113
126
  rb_grn_database_finalizer(context, rb_grn_context,
114
127
  grn_object, rb_grn_object);
115
128
  break;
116
- case GRN_TYPE:
117
- case GRN_PROC:
118
- case GRN_CURSOR_TABLE_HASH_KEY:
119
- case GRN_CURSOR_TABLE_PAT_KEY:
120
- case GRN_CURSOR_TABLE_DAT_KEY:
121
- case GRN_CURSOR_TABLE_NO_KEY:
129
+ case GRN_TYPE:
130
+ case GRN_PROC:
131
+ case GRN_CURSOR_TABLE_HASH_KEY:
132
+ case GRN_CURSOR_TABLE_PAT_KEY:
133
+ case GRN_CURSOR_TABLE_DAT_KEY:
134
+ case GRN_CURSOR_TABLE_NO_KEY:
122
135
  break;
123
- case GRN_TABLE_HASH_KEY:
124
- case GRN_TABLE_PAT_KEY:
125
- case GRN_TABLE_DAT_KEY:
136
+ case GRN_TABLE_HASH_KEY:
137
+ case GRN_TABLE_PAT_KEY:
138
+ case GRN_TABLE_DAT_KEY:
126
139
  rb_grn_table_key_support_finalizer(context, grn_object,
127
140
  RB_GRN_TABLE_KEY_SUPPORT(rb_grn_object));
128
141
  break;
129
- case GRN_TABLE_NO_KEY:
142
+ case GRN_TABLE_NO_KEY:
130
143
  rb_grn_table_finalizer(context, grn_object,
131
144
  RB_GRN_TABLE(rb_grn_object));
132
145
  break;
133
- case GRN_CURSOR_COLUMN_INDEX:
134
- break;
135
- case GRN_COLUMN_FIX_SIZE:
136
- case GRN_COLUMN_VAR_SIZE:
146
+ case GRN_CURSOR_COLUMN_INDEX:
147
+ break;
148
+ case GRN_COLUMN_FIX_SIZE:
149
+ case GRN_COLUMN_VAR_SIZE:
137
150
  rb_grn_column_finalizer(context, grn_object,
138
151
  RB_GRN_COLUMN(rb_grn_object));
139
152
  break;
140
- case GRN_COLUMN_INDEX:
153
+ case GRN_COLUMN_INDEX:
141
154
  rb_grn_index_column_finalizer(context, grn_object,
142
155
  RB_GRN_INDEX_COLUMN(rb_grn_object));
143
156
  break;
144
- case GRN_ACCESSOR:
157
+ case GRN_ACCESSOR:
145
158
  rb_grn_accessor_finalizer(context, grn_object,
146
159
  RB_GRN_ACCESSOR(rb_grn_object));
147
160
  break;
148
- case GRN_EXPR:
161
+ case GRN_EXPR:
149
162
  rb_grn_expression_finalizer(context, grn_object,
150
163
  RB_GRN_EXPRESSION(rb_grn_object));
151
164
  break;
152
- case GRN_SNIP:
165
+ case GRN_SNIP:
153
166
  rb_grn_snippet_finalizer(context, grn_object,
154
167
  RB_GRN_SNIPPET(rb_grn_object));
155
168
  break;
156
- default:
169
+ default:
157
170
  rb_raise(rb_eTypeError,
158
- "unsupported groonga object type for finalizer: %s(%#x)",
171
+ "unsupported Groonga object type for finalizer: %s(%#x)",
159
172
  rb_grn_inspect_type(grn_object->header.type),
160
173
  grn_object->header.type);
161
174
  break;
162
175
  }
163
176
 
164
- rb_grn_object->rb_grn_context = NULL;
165
- rb_grn_object->context = NULL;
166
- rb_grn_object->object = NULL;
177
+ rb_grn_object_unbind(rb_grn_object);
167
178
  }
168
179
 
169
180
  static grn_obj *
@@ -213,6 +224,8 @@ rb_grn_object_free (RbGrnObject *rb_grn_object)
213
224
  } else {
214
225
  rb_grn_object_run_finalizer(context, grn_object, rb_grn_object);
215
226
  }
227
+ } else {
228
+ rb_grn_object_unbind(rb_grn_object);
216
229
  }
217
230
  if (rb_grn_object->need_close) {
218
231
  grn_obj_unlink(context, grn_object);
@@ -280,7 +293,7 @@ rb_grn_object_to_ruby_class (grn_obj *object)
280
293
  break;
281
294
  default:
282
295
  rb_raise(rb_eTypeError,
283
- "unsupported groonga object type for class detection: 0x%x",
296
+ "unsupported Groonga object type for class detection: 0x%x",
284
297
  object->header.type);
285
298
  break;
286
299
  }
@@ -314,11 +327,14 @@ rb_grn_object_to_ruby_object (VALUE klass, grn_ctx *context, grn_obj *object,
314
327
  rb_grn_object_assign(klass, rb_object, rb_context, context, object);
315
328
 
316
329
  switch (object->header.type) {
330
+ case GRN_ACCESSOR:
331
+ case GRN_SNIP:
317
332
  case GRN_TABLE_NO_KEY:
318
333
  case GRN_TABLE_HASH_KEY:
319
334
  case GRN_TABLE_PAT_KEY:
320
335
  case GRN_TABLE_DAT_KEY:
321
336
  rb_grn_context_object_created(rb_context, rb_object);
337
+ break;
322
338
  default:
323
339
  break;
324
340
  }
@@ -368,14 +384,12 @@ rb_grn_object_bind_common (VALUE klass, VALUE self, VALUE rb_context,
368
384
  context, object, rb_grn_object,
369
385
  rb_grn_inspect_type(object->header.type),
370
386
  object->header.type);
371
- /* TODO: We want to call finalizer for GRN_ACCESSOR. */
372
- rb_grn_object->have_finalizer = GRN_FALSE;
387
+ rb_grn_object->have_finalizer = GRN_TRUE;
373
388
  }
374
389
 
375
390
  switch (object->header.type) {
376
391
  case GRN_PROC:
377
392
  case GRN_TYPE:
378
- case GRN_ACCESSOR: /* TODO: We want to close GRN_ACCESSOR. */
379
393
  rb_grn_object->need_close = GRN_FALSE;
380
394
  break;
381
395
  default:
@@ -475,7 +489,7 @@ rb_grn_object_assign (VALUE klass, VALUE self, VALUE rb_context,
475
489
  context, object);
476
490
  } else {
477
491
  rb_raise(rb_eTypeError,
478
- "unsupported groonga object type for assignment: %s(%#x)",
492
+ "unsupported Groonga object type for assignment: %s(%#x)",
479
493
  rb_grn_inspect_type(object->header.type),
480
494
  object->header.type);
481
495
  }
@@ -557,6 +571,24 @@ rb_grn_object_deconstruct (RbGrnObject *rb_grn_object,
557
571
  *range = rb_grn_object->range;
558
572
  }
559
573
 
574
+ void
575
+ rb_grn_object_close_raw (RbGrnObject *rb_grn_object)
576
+ {
577
+ grn_obj *object;
578
+ grn_ctx *context;
579
+
580
+ rb_grn_object_deconstruct(rb_grn_object, &object, &context,
581
+ NULL, NULL, NULL, NULL);
582
+ if (object && context) {
583
+ if (rb_grn_object->have_finalizer) {
584
+ rb_grn_object_run_finalizer(context, object, rb_grn_object);
585
+ } else {
586
+ rb_grn_object_unbind(rb_grn_object);
587
+ }
588
+ grn_obj_close(context, object);
589
+ }
590
+ }
591
+
560
592
  /*
561
593
  * _object_ が使用しているリソースを開放する。これ以降 _object_ を
562
594
  * 使うことはできない。
@@ -567,16 +599,9 @@ VALUE
567
599
  rb_grn_object_close (VALUE self)
568
600
  {
569
601
  RbGrnObject *rb_grn_object;
570
- grn_obj *object;
571
- grn_ctx *context;
572
602
 
573
603
  rb_grn_object = SELF(self);
574
- rb_grn_object_deconstruct(rb_grn_object, &object, &context,
575
- NULL, NULL, NULL, NULL);
576
- if (object && context) {
577
- rb_grn_object_run_finalizer(context, object, rb_grn_object);
578
- grn_obj_close(context, object);
579
- }
604
+ rb_grn_object_close_raw(rb_grn_object);
580
605
 
581
606
  return Qnil;
582
607
  }
@@ -599,6 +624,7 @@ rb_grn_object_unlink (VALUE self)
599
624
  if (object && context) {
600
625
  if (!(rb_grn_object->object->header.flags & GRN_OBJ_PERSISTENT)) {
601
626
  rb_grn_object_run_finalizer(context, object, rb_grn_object);
627
+ rb_grn_object_unbind(rb_grn_object);
602
628
  }
603
629
  grn_obj_unlink(context, object);
604
630
  }
@@ -1174,7 +1200,7 @@ rb_grn_object_get_range (VALUE self)
1174
1200
  }
1175
1201
 
1176
1202
  /*
1177
- * _object_ と _other_ が同じgroongaのオブジェクトなら +true+ を返
1203
+ * _object_ と _other_ が同じGroongaのオブジェクトなら +true+ を返
1178
1204
  * し、そうでなければ +false+ を返す。
1179
1205
  *
1180
1206
  * @overload ==(other)