rroonga 4.0.4 → 4.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +73 -0
- data/Rakefile +13 -0
- data/doc/text/news.textile +26 -2
- data/ext/groonga/extconf.rb +3 -1
- data/ext/groonga/rb-grn-context.c +1 -1
- data/ext/groonga/rb-grn-double-array-trie.c +160 -4
- data/ext/groonga/rb-grn-object.c +10 -1
- data/ext/groonga/rb-grn-posting.c +4 -4
- data/ext/groonga/rb-grn-table-key-support.c +9 -4
- data/ext/groonga/rb-grn-table.c +1 -1
- data/ext/groonga/rb-grn-utils.c +2 -6
- data/ext/groonga/rb-grn-variable-size-column.c +2 -2
- data/ext/groonga/rb-grn.h +27 -2
- data/lib/groonga/record.rb +19 -2
- data/lib/groonga/schema.rb +2 -2
- data/rroonga-build.rb +1 -1
- data/rroonga.gemspec +5 -5
- data/test/test-column.rb +6 -6
- data/test/test-database.rb +6 -2
- data/test/test-double-array-trie.rb +18 -0
- data/test/test-expression-builder.rb +3 -2
- data/test/test-hash.rb +13 -1
- data/test/test-plugin.rb +3 -1
- data/test/test-record.rb +10 -0
- data/test/test-variable-size-column.rb +4 -4
- metadata +79 -81
- data/README.textile +0 -73
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZWU1ODAxN2JjNjAwNzQ3M2UzMmEzNzVjM2RiODM5NmRhMDVmYjQ1Mw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 503d0a50ec18bb2f348918e9604d3d741789b742
|
4
|
+
data.tar.gz: e22349e0fc515632567417b2ac6a1da1d026a0ff
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NmYzYTkxZDAxNzNhMTk4ZGZiMmRlMjIyM2U1ODZlNTlkYjUzMzIxZDc0YmY1
|
11
|
-
MzQ4NzY2OGFhMWU3NDM3Mjk3OTExOGNlZWMwN2FkYzU2M2M5ZDI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Mjg5Yjk4ZGRiNjJjNWVmOTdjODNkM2MyYTE2YzYwMDQ2YWQ5ODRmNDIwNWI5
|
14
|
-
NGY2NTAwMmYyMzU0ZjdmM2ZiNjllZTY4MDZkZjBjMWFhNjMxZDk3ZjE0MjE0
|
15
|
-
ZDVlNTIwYzBkNTI4Y2Y2YzdkMGJjYzk4NmQ4ZmQxYWYyYTg1ZjE=
|
6
|
+
metadata.gz: a50ee57fe8bad9362b36745e062026045e019784a87fc23c45f157ed4d1c618b890939b112f484315ee8f24379604a2f77f9ac38569cd92e5a3167c2c9ff34c2
|
7
|
+
data.tar.gz: 5038e0c3e321b54d00e8675727cbde1dd6a2590f1a30d9b82f86c725e54cbc98b991a014a10fdd9b8b8b6f425a83bf98e3863c8a73f5ebd1c0218e4844df6a09
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rroonga.svg)](http://badge.fury.io/rb/rroonga)
|
4
|
+
[![Build Status](https://travis-ci.org/ranguba/rroonga.svg?branch=master)](https://travis-ci.org/ranguba/rroonga)
|
5
|
+
|
6
|
+
## Name
|
7
|
+
|
8
|
+
Rroonga
|
9
|
+
|
10
|
+
## Description
|
11
|
+
|
12
|
+
Ruby bindings for Groonga that provide full text search and
|
13
|
+
column store features.
|
14
|
+
|
15
|
+
Rroonga is an extension library to use Groonga's DB-API
|
16
|
+
layer. Rroonga provides Rubyish readable and writable API
|
17
|
+
not C like API. You can use Groonga's fast and highly
|
18
|
+
functional features from Ruby with Rubyish form.
|
19
|
+
|
20
|
+
See the following URL about Groonga.
|
21
|
+
|
22
|
+
* [The Groonga official site](http://groonga.org/)
|
23
|
+
|
24
|
+
## Authors
|
25
|
+
|
26
|
+
* Kouhei Sutou `<kou@clear-code.com>`
|
27
|
+
* Tasuku SUENAGA `<a@razil.jp>`
|
28
|
+
* Daijiro MORI `<morita@razil.jp>`
|
29
|
+
* Yuto HAYAMIZU `<y.hayamizu@gmail.com>`
|
30
|
+
* SHIDARA Yoji `<dara@shidara.net>`
|
31
|
+
* yoshihara haruka `<yoshihara@clear-code.com>`
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
LGPL 2.1. See license/LGPL for details.
|
36
|
+
|
37
|
+
(Kouhei Sutou has a right to change the license including
|
38
|
+
contributed patches.)
|
39
|
+
|
40
|
+
## Dependencies
|
41
|
+
|
42
|
+
* Ruby >= 1.9.3
|
43
|
+
* Groonga >= 4.0.4
|
44
|
+
|
45
|
+
## Install
|
46
|
+
|
47
|
+
% sudo gem install rroonga
|
48
|
+
|
49
|
+
## Documents
|
50
|
+
|
51
|
+
* [Reference manual in English](http://ranguba.org/rroonga/en/)
|
52
|
+
* [Reference manual in Japanese](http://ranguba.org/rroonga/ja/)
|
53
|
+
|
54
|
+
## Mailing list
|
55
|
+
|
56
|
+
* English: [groonga-talk](http://lists.sourceforge.net/mailman/listinfo/groonga-talk)
|
57
|
+
* Japanese: [groonga-dev](http://lists.sourceforge.jp/mailman/listinfo/groonga-dev)
|
58
|
+
|
59
|
+
## Thanks
|
60
|
+
|
61
|
+
* Daijiro MORI: sent patches to support the latest Groonga.
|
62
|
+
* Tasuku SUENAGA: sent bug reports.
|
63
|
+
* niku: sent bug reports.
|
64
|
+
* dara:
|
65
|
+
* wrote tests.
|
66
|
+
* fixed bugs.
|
67
|
+
* id:mat_aki: sent bug reports.
|
68
|
+
* @yune_kotomi: sent a bug report.
|
69
|
+
* m_seki: sent bug reports.
|
70
|
+
* ono matope: sent bug reports.
|
71
|
+
* @kamipo: send a bug report.
|
72
|
+
* ongaeshi: sent a patch to build gem on Windows.
|
73
|
+
* mallowlabs: send a patch.
|
data/Rakefile
CHANGED
@@ -163,4 +163,17 @@ namespace :clean do
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
+
desc "Build cross compile binary with Vagrant"
|
167
|
+
namespace :build do
|
168
|
+
task :windows do
|
169
|
+
pkg_dir = "#{base_dir}/pkg"
|
170
|
+
mkdir pkg_dir unless File.exist?(pkg_dir)
|
171
|
+
cd "build/windows" do
|
172
|
+
sh("vagrant", "up")
|
173
|
+
cp(Dir.glob("pkg/rroonga-*-mingw32.gem"), pkg_dir)
|
174
|
+
sh("vagrant", "destroy", "-f")
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
166
179
|
task :default => :test
|
data/doc/text/news.textile
CHANGED
@@ -1,10 +1,34 @@
|
|
1
1
|
h1. NEWS
|
2
2
|
|
3
|
-
h2(#4-0-
|
3
|
+
h2(#4-0-5). 4.0.5: 2014-10-05
|
4
4
|
|
5
5
|
h3. Improvements
|
6
6
|
|
7
|
-
*
|
7
|
+
* [windows] Added cross build task.
|
8
|
+
* Added {Groonga::DoubleArrayTrie#update}.
|
9
|
+
[GitHub#24] [Patch by Masafumi Yokoyama]
|
10
|
+
* Added {Groonga::Record#rename}.
|
11
|
+
* [windows] Disabled debug flags.
|
12
|
+
|
13
|
+
h3. Fixes
|
14
|
+
|
15
|
+
* Added @:id => true@ option to {Groonga::Table::KeySupport#delete}.
|
16
|
+
@Groonga::Table::KeySupport#delete@ accepts both ID and key. If passed
|
17
|
+
value is integer, it is handled as ID. But we can use @Int32@ as key.
|
18
|
+
In the case, we can't delete a record by key. Therefore, we added
|
19
|
+
@Groonga::Table::KeySupport#delete(id, :id => true)@ API. It introduces
|
20
|
+
a backward incompatibility, but it is OK because the current API is a
|
21
|
+
bug.
|
22
|
+
|
23
|
+
h3. Thanks
|
24
|
+
|
25
|
+
* Masafumi Yokoyama
|
26
|
+
|
27
|
+
h2(#4-0-4). 4.0.4: 2014-08-29
|
28
|
+
|
29
|
+
h3. Improvements
|
30
|
+
|
31
|
+
* Supported Groonga 4.0.4 or later. Groonga 4.0.3 or older are not supported.
|
8
32
|
* Added {Groonga::ProcedureType} that has constants as GRN_PROC_XXX.
|
9
33
|
* Added {Groonga::Procedure#type} as grn_proc_get_type().
|
10
34
|
<pre>
|
data/ext/groonga/extconf.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (C) 2009-
|
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
|
@@ -268,6 +268,8 @@ $defs << "-DGRN_MICRO_VERSION=#{real_micro}"
|
|
268
268
|
|
269
269
|
have_header("ruby/st.h") unless have_macro("HAVE_RUBY_ST_H", "ruby.h")
|
270
270
|
have_func("rb_errinfo", "ruby.h")
|
271
|
+
have_func("rb_sym2str", "ruby.h")
|
272
|
+
have_func("rb_to_symbol", "ruby.h")
|
271
273
|
have_type("enum ruby_value_type", "ruby.h")
|
272
274
|
|
273
275
|
checking_for(checking_message("--enable-debug-log option")) do
|
@@ -902,7 +902,7 @@ rb_grn_context_array_reference (VALUE self, VALUE name_or_id)
|
|
902
902
|
context = SELF(self);
|
903
903
|
switch (TYPE(name_or_id)) {
|
904
904
|
case T_SYMBOL:
|
905
|
-
name =
|
905
|
+
name = RSYMBOL2CSTR(name_or_id);
|
906
906
|
name_size = strlen(name);
|
907
907
|
object = rb_grn_context_get_backward_compatibility(context,
|
908
908
|
name, name_size);
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/* vim: set sts=4 sw=4 ts=8 noet: */
|
3
3
|
/*
|
4
|
-
Copyright (C)
|
4
|
+
Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
|
5
|
+
Copyright (C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
|
5
6
|
|
6
7
|
This library is free software; you can redistribute it and/or
|
7
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -19,7 +20,7 @@
|
|
19
20
|
|
20
21
|
#include "rb-grn.h"
|
21
22
|
|
22
|
-
#define SELF(object) ((
|
23
|
+
#define SELF(object) ((RbGrnDoubleArrayTrie *)DATA_PTR(object))
|
23
24
|
|
24
25
|
VALUE rb_cGrnDoubleArrayTrie;
|
25
26
|
|
@@ -42,6 +43,74 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
42
43
|
* {Groonga::PatriciaTrie} . It also supports cursor API.
|
43
44
|
*/
|
44
45
|
|
46
|
+
static void
|
47
|
+
rb_grn_double_array_trie_deconstruct (RbGrnDoubleArrayTrie *rb_grn_double_array_trie,
|
48
|
+
grn_obj **double_array_trie,
|
49
|
+
grn_ctx **context,
|
50
|
+
grn_obj **key,
|
51
|
+
grn_obj **new_key,
|
52
|
+
grn_id *domain_id,
|
53
|
+
grn_obj **domain,
|
54
|
+
grn_obj **value,
|
55
|
+
grn_id *range_id,
|
56
|
+
grn_obj **range,
|
57
|
+
VALUE *columns)
|
58
|
+
{
|
59
|
+
RbGrnTableKeySupport *rb_grn_table_key_support;
|
60
|
+
|
61
|
+
rb_grn_table_key_support =
|
62
|
+
RB_GRN_TABLE_KEY_SUPPORT(rb_grn_double_array_trie);
|
63
|
+
|
64
|
+
rb_grn_table_key_support_deconstruct(rb_grn_table_key_support,
|
65
|
+
double_array_trie, context,
|
66
|
+
key, domain_id, domain,
|
67
|
+
value, range_id, range,
|
68
|
+
columns);
|
69
|
+
|
70
|
+
if (new_key)
|
71
|
+
*new_key = rb_grn_double_array_trie->new_key;
|
72
|
+
}
|
73
|
+
|
74
|
+
void
|
75
|
+
rb_grn_double_array_trie_finalizer (grn_ctx *context,
|
76
|
+
grn_obj *grn_object,
|
77
|
+
RbGrnDoubleArrayTrie *rb_grn_double_array_trie)
|
78
|
+
{
|
79
|
+
RbGrnTableKeySupport *rb_grn_table_key_support;
|
80
|
+
|
81
|
+
if (!context)
|
82
|
+
return;
|
83
|
+
|
84
|
+
if (rb_grn_double_array_trie->new_key)
|
85
|
+
grn_obj_unlink(context, rb_grn_double_array_trie->new_key);
|
86
|
+
rb_grn_double_array_trie->new_key = NULL;
|
87
|
+
|
88
|
+
rb_grn_table_key_support =
|
89
|
+
RB_GRN_TABLE_KEY_SUPPORT(rb_grn_double_array_trie);
|
90
|
+
rb_grn_table_key_support_finalizer(context, grn_object,
|
91
|
+
rb_grn_table_key_support);
|
92
|
+
}
|
93
|
+
|
94
|
+
void
|
95
|
+
rb_grn_double_array_trie_bind (RbGrnDoubleArrayTrie *rb_grn_double_array_trie,
|
96
|
+
grn_ctx *context,
|
97
|
+
grn_obj *double_array_trie)
|
98
|
+
{
|
99
|
+
RbGrnObject *rb_grn_object;
|
100
|
+
RbGrnTableKeySupport *rb_grn_table_key_support;
|
101
|
+
|
102
|
+
rb_grn_object = RB_GRN_OBJECT(rb_grn_double_array_trie);
|
103
|
+
|
104
|
+
rb_grn_table_key_support =
|
105
|
+
RB_GRN_TABLE_KEY_SUPPORT(rb_grn_double_array_trie);
|
106
|
+
rb_grn_table_key_support_bind(rb_grn_table_key_support,
|
107
|
+
context,
|
108
|
+
double_array_trie);
|
109
|
+
|
110
|
+
rb_grn_double_array_trie->new_key =
|
111
|
+
grn_obj_open(context, GRN_BULK, 0, rb_grn_object->domain_id);
|
112
|
+
}
|
113
|
+
|
45
114
|
/*
|
46
115
|
* It creates a table that manages records by double array trie.
|
47
116
|
* ブロックを指定すると、そのブロックに生成したテーブルが渡さ
|
@@ -307,8 +376,8 @@ rb_grn_double_array_trie_search (int argc, VALUE *argv, VALUE self)
|
|
307
376
|
grn_bool search_options_is_set = GRN_FALSE;
|
308
377
|
VALUE rb_key, options, rb_result, rb_operator, rb_type;
|
309
378
|
|
310
|
-
|
311
|
-
&key, &domain_id, &domain,
|
379
|
+
rb_grn_double_array_trie_deconstruct(SELF(self), &table, &context,
|
380
|
+
&key, NULL, &domain_id, &domain,
|
312
381
|
NULL, NULL, NULL,
|
313
382
|
NULL);
|
314
383
|
|
@@ -495,6 +564,90 @@ rb_grn_double_array_trie_open_prefix_cursor (int argc, VALUE *argv, VALUE self)
|
|
495
564
|
return rb_cursor;
|
496
565
|
}
|
497
566
|
|
567
|
+
static VALUE
|
568
|
+
rb_grn_double_array_trie_update_by_id (VALUE self, VALUE rb_id, VALUE rb_new_key)
|
569
|
+
{
|
570
|
+
grn_ctx *context;
|
571
|
+
grn_obj *table;
|
572
|
+
grn_id id, domain_id;
|
573
|
+
grn_obj *new_key, *domain;
|
574
|
+
grn_rc rc;
|
575
|
+
|
576
|
+
rb_grn_double_array_trie_deconstruct(SELF(self), &table, &context,
|
577
|
+
NULL, &new_key, &domain_id, &domain,
|
578
|
+
NULL, NULL, NULL,
|
579
|
+
NULL);
|
580
|
+
|
581
|
+
id = NUM2UINT(rb_id);
|
582
|
+
RVAL2GRNKEY(rb_new_key, context, new_key, domain_id, domain, self);
|
583
|
+
rc = grn_table_update_by_id(context, table, id,
|
584
|
+
GRN_BULK_HEAD(new_key), GRN_BULK_VSIZE(new_key));
|
585
|
+
rb_grn_rc_check(rc, self);
|
586
|
+
|
587
|
+
return Qnil;
|
588
|
+
}
|
589
|
+
|
590
|
+
static VALUE
|
591
|
+
rb_grn_double_array_trie_update_by_key (VALUE self,
|
592
|
+
VALUE rb_current_key,
|
593
|
+
VALUE rb_new_key)
|
594
|
+
{
|
595
|
+
grn_ctx *context;
|
596
|
+
grn_obj *table;
|
597
|
+
grn_id domain_id;
|
598
|
+
grn_obj *current_key, *new_key, *domain;
|
599
|
+
grn_rc rc;
|
600
|
+
|
601
|
+
rb_grn_double_array_trie_deconstruct(SELF(self), &table, &context,
|
602
|
+
¤t_key, &new_key,
|
603
|
+
&domain_id, &domain,
|
604
|
+
NULL, NULL, NULL,
|
605
|
+
NULL);
|
606
|
+
|
607
|
+
RVAL2GRNKEY(rb_current_key, context, current_key, domain_id, domain, self);
|
608
|
+
RVAL2GRNKEY(rb_new_key, context, new_key, domain_id, domain, self);
|
609
|
+
rc = grn_table_update(context, table,
|
610
|
+
GRN_BULK_HEAD(current_key),
|
611
|
+
GRN_BULK_VSIZE(current_key),
|
612
|
+
GRN_BULK_HEAD(new_key),
|
613
|
+
GRN_BULK_VSIZE(new_key));
|
614
|
+
rb_grn_rc_check(rc, self);
|
615
|
+
|
616
|
+
return Qnil;
|
617
|
+
}
|
618
|
+
|
619
|
+
/*
|
620
|
+
* Renames key of a record.
|
621
|
+
*
|
622
|
+
* @overload update(current_key, new_key)
|
623
|
+
* @overload update(id, new_key, :id=>true)
|
624
|
+
*
|
625
|
+
* @since 4.0.5
|
626
|
+
*/
|
627
|
+
static VALUE
|
628
|
+
rb_grn_double_array_trie_update (int argc, VALUE *argv, VALUE self)
|
629
|
+
{
|
630
|
+
VALUE rb_current_key_or_id, rb_new_key, rb_options;
|
631
|
+
VALUE rb_option_id;
|
632
|
+
|
633
|
+
rb_scan_args(argc, argv, "21",
|
634
|
+
&rb_current_key_or_id, &rb_new_key, &rb_options);
|
635
|
+
rb_grn_scan_options(rb_options,
|
636
|
+
"id", &rb_option_id,
|
637
|
+
NULL);
|
638
|
+
if (RVAL2CBOOL(rb_option_id)) {
|
639
|
+
VALUE rb_id;
|
640
|
+
rb_id = rb_current_key_or_id;
|
641
|
+
return rb_grn_double_array_trie_update_by_id(self, rb_id, rb_new_key);
|
642
|
+
} else {
|
643
|
+
VALUE rb_current_key;
|
644
|
+
rb_current_key = rb_current_key_or_id;
|
645
|
+
return rb_grn_double_array_trie_update_by_key(self,
|
646
|
+
rb_current_key,
|
647
|
+
rb_new_key);
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
498
651
|
void
|
499
652
|
rb_grn_init_double_array_trie (VALUE mGrn)
|
500
653
|
{
|
@@ -510,4 +663,7 @@ rb_grn_init_double_array_trie (VALUE mGrn)
|
|
510
663
|
|
511
664
|
rb_define_method(rb_cGrnDoubleArrayTrie, "open_prefix_cursor",
|
512
665
|
rb_grn_double_array_trie_open_prefix_cursor, -1);
|
666
|
+
|
667
|
+
rb_define_method(rb_cGrnDoubleArrayTrie, "update",
|
668
|
+
rb_grn_double_array_trie_update, -1);
|
513
669
|
}
|
data/ext/groonga/rb-grn-object.c
CHANGED
@@ -135,10 +135,13 @@ rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object,
|
|
135
135
|
break;
|
136
136
|
case GRN_TABLE_HASH_KEY:
|
137
137
|
case GRN_TABLE_PAT_KEY:
|
138
|
-
case GRN_TABLE_DAT_KEY:
|
139
138
|
rb_grn_table_key_support_finalizer(context, grn_object,
|
140
139
|
RB_GRN_TABLE_KEY_SUPPORT(rb_grn_object));
|
141
140
|
break;
|
141
|
+
case GRN_TABLE_DAT_KEY:
|
142
|
+
rb_grn_double_array_trie_finalizer(context, grn_object,
|
143
|
+
RB_GRN_DOUBLE_ARRAY_TRIE(rb_grn_object));
|
144
|
+
break;
|
142
145
|
case GRN_TABLE_NO_KEY:
|
143
146
|
rb_grn_table_finalizer(context, grn_object,
|
144
147
|
RB_GRN_TABLE(rb_grn_object));
|
@@ -441,6 +444,12 @@ rb_grn_object_assign (VALUE klass, VALUE self, VALUE rb_context,
|
|
441
444
|
rb_grn_object = ALLOC(RbGrnObject);
|
442
445
|
rb_grn_object_bind_common(klass, self, rb_context, rb_grn_object,
|
443
446
|
context, object);
|
447
|
+
} else if (klass == rb_cGrnDoubleArrayTrie) {
|
448
|
+
rb_grn_object = ALLOC(RbGrnDoubleArrayTrie);
|
449
|
+
rb_grn_object_bind_common(klass, self, rb_context, rb_grn_object,
|
450
|
+
context, object);
|
451
|
+
rb_grn_double_array_trie_bind(RB_GRN_DOUBLE_ARRAY_TRIE(rb_grn_object),
|
452
|
+
context, object);
|
444
453
|
} else if (RVAL2CBOOL(rb_obj_is_kind_of(self, rb_mGrnTableKeySupport))) {
|
445
454
|
rb_grn_object = ALLOC(RbGrnTableKeySupport);
|
446
455
|
rb_grn_object_bind_common(klass, self, rb_context, rb_grn_object,
|
@@ -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) 2011 Haruka Yoshihara <yoshihara@clear-code.com>
|
4
|
-
Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
Copyright (C) 2012-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
|
@@ -30,7 +30,7 @@ rb_grn_posting_new (grn_posting *posting, grn_id term_id,
|
|
30
30
|
parameters = rb_hash_new();
|
31
31
|
|
32
32
|
#define SET_PARAMETER(key, value) \
|
33
|
-
rb_hash_aset(parameters,
|
33
|
+
rb_hash_aset(parameters, RB_GRN_INTERN(key), INT2NUM((value)))
|
34
34
|
|
35
35
|
SET_PARAMETER("record_id", posting->rid);
|
36
36
|
SET_PARAMETER("section_id", posting->sid);
|
@@ -42,8 +42,8 @@ rb_grn_posting_new (grn_posting *posting, grn_id term_id,
|
|
42
42
|
|
43
43
|
#undef SET_PARAMETER
|
44
44
|
|
45
|
-
rb_hash_aset(parameters,
|
46
|
-
rb_hash_aset(parameters,
|
45
|
+
rb_hash_aset(parameters, RB_GRN_INTERN("table"), rb_table);
|
46
|
+
rb_hash_aset(parameters, RB_GRN_INTERN("lexicon"), rb_lexicon);
|
47
47
|
|
48
48
|
return rb_funcall(rb_cGrnPosting, rb_intern("new"), 1,
|
49
49
|
parameters);
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
+
Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
|
3
4
|
Copyright (C) 2009-2013 Kouhei Sutou <kou@clear-code.com>
|
4
5
|
|
5
6
|
This library is free software; you can redistribute it and/or
|
@@ -378,7 +379,7 @@ rb_grn_table_key_support_delete_by_key (VALUE self, VALUE rb_key)
|
|
378
379
|
}
|
379
380
|
|
380
381
|
/*
|
381
|
-
* @overload delete(id)
|
382
|
+
* @overload delete(id, :id=>true)
|
382
383
|
* Delete a record that has ID @id@.
|
383
384
|
*
|
384
385
|
* @param id [Integer] The ID of delete target record.
|
@@ -405,14 +406,18 @@ rb_grn_table_key_support_delete_by_key (VALUE self, VALUE rb_key)
|
|
405
406
|
static VALUE
|
406
407
|
rb_grn_table_key_support_delete (int argc, VALUE *argv, VALUE self)
|
407
408
|
{
|
408
|
-
VALUE rb_id_or_key;
|
409
|
+
VALUE rb_id_or_key, rb_options;
|
410
|
+
VALUE rb_option_id;
|
409
411
|
|
410
412
|
if (rb_block_given_p()) {
|
411
413
|
return rb_grn_table_delete_by_expression(self);
|
412
414
|
}
|
413
415
|
|
414
|
-
rb_scan_args(argc, argv, "
|
415
|
-
|
416
|
+
rb_scan_args(argc, argv, "11", &rb_id_or_key, &rb_options);
|
417
|
+
rb_grn_scan_options(rb_options,
|
418
|
+
"id", &rb_option_id,
|
419
|
+
NULL);
|
420
|
+
if (RVAL2CBOOL(rb_option_id)) {
|
416
421
|
return rb_grn_table_delete_by_id(self, rb_id_or_key);
|
417
422
|
} else {
|
418
423
|
return rb_grn_table_key_support_delete_by_key(self, rb_id_or_key);
|