ruby-tokyotyrant 0.5 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ CLEAN.include('pkg', 'tmp')
20
20
 
21
21
  gemspec = Gem::Specification.new do |s|
22
22
  s.name = 'ruby-tokyotyrant'
23
- s.version = '0.5'
23
+ s.version = '0.5.1'
24
24
  s.authors = [ 'Flinn' ]
25
25
  s.email = 'flinn@actsasflinn.com'
26
26
  s.homepage = 'http://github.com/actsasflinn/ruby-tokyotyrant/'
@@ -1,7 +1,7 @@
1
1
  #include <tokyo_tyrant_bdb.h>
2
2
 
3
3
  static VALUE cBDB_put_method(VALUE vself, VALUE vkey, VALUE vval, char *command, bool bang){
4
- VALUE vres;
4
+ VALUE vres = Qfalse;
5
5
  TCLIST *list, *result;
6
6
  TCRDB *db = mTokyoTyrant_getdb(vself);
7
7
 
@@ -17,16 +17,16 @@ static VALUE cBDB_put_method(VALUE vself, VALUE vkey, VALUE vval, char *command,
17
17
  } else {
18
18
  vres = listtovary(result);
19
19
  }
20
+ tclistdel(result);
20
21
  } else {
21
22
  if (bang) mTokyoTyrant_exception(vself, NULL);
22
- vres = Qfalse;
23
23
  }
24
24
  tclistdel(list);
25
25
  return vres;
26
26
  }
27
27
 
28
28
  static VALUE cBDB_putlist(VALUE vself, VALUE vhash){
29
- VALUE vary;
29
+ VALUE vary = rb_ary_new();
30
30
  TCLIST *list, *result;
31
31
  TCRDB *db = mTokyoTyrant_getdb(vself);
32
32
  Check_Type(vhash, T_HASH);
@@ -35,8 +35,6 @@ static VALUE cBDB_putlist(VALUE vself, VALUE vhash){
35
35
  if ((result = tcrdbmisc(db, "putlist", 0, list)) != NULL){
36
36
  vary = listtovary(result);
37
37
  tclistdel(result);
38
- } else {
39
- vary = rb_ary_new();
40
38
  }
41
39
  tclistdel(list);
42
40
 
@@ -44,43 +42,44 @@ static VALUE cBDB_putlist(VALUE vself, VALUE vhash){
44
42
  }
45
43
 
46
44
  static VALUE cBDB_getlist(int argc, VALUE *argv, VALUE vself){
47
- VALUE vkeys, vvalue, vhash;
45
+ VALUE vkeys, vval;
46
+ VALUE vhash = rb_hash_new();
48
47
  TCLIST *list, *result;
49
48
  TCRDB *db = mTokyoTyrant_getdb(vself);
50
49
  rb_scan_args(argc, argv, "*", &vkeys);
51
50
 
52
51
  // I really hope there is a better way to do this
53
52
  if (RARRAY_LEN(vkeys) == 1) {
54
- vvalue = rb_ary_entry(vkeys, 0);
55
- switch (TYPE(vvalue)){
53
+ vval = rb_ary_entry(vkeys, 0);
54
+ switch (TYPE(vval)){
56
55
  case T_STRING:
57
56
  case T_FIXNUM:
58
57
  break;
59
58
  case T_ARRAY:
60
- vkeys = vvalue;
59
+ vkeys = vval;
61
60
  break;
62
61
  case T_OBJECT:
63
- vkeys = rb_convert_type(vvalue, T_ARRAY, "Array", "to_a");
62
+ vkeys = rb_convert_type(vval, T_ARRAY, "Array", "to_a");
64
63
  break;
65
64
  }
66
65
  }
67
66
  Check_Type(vkeys, T_ARRAY);
68
67
 
69
68
  list = varytolist(vkeys);
70
- result = tcrdbmisc(db, "getlist", RDBMONOULOG, list);
69
+ if ((result = tcrdbmisc(db, "getlist", RDBMONOULOG, list)) != NULL){
70
+ vhash = listtovhash(result);
71
+ tclistdel(result);
72
+ }
71
73
  tclistdel(list);
72
- vhash = listtovhash(result);
73
- tclistdel(result);
74
74
  return vhash;
75
75
  }
76
76
 
77
77
  static VALUE cBDB_each(VALUE vself){
78
- VALUE vrv;
78
+ VALUE vrv = Qnil;
79
79
  const char *kbuf, *vbuf;
80
80
  int ksiz, vsiz;
81
81
  TCLIST *result;
82
82
  TCRDB *db = mTokyoTyrant_getdb(vself);
83
- vrv = Qnil;
84
83
 
85
84
  if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
86
85
 
@@ -98,13 +97,12 @@ static VALUE cBDB_each(VALUE vself){
98
97
  }
99
98
 
100
99
  static VALUE cBDB_values(VALUE vself){
101
- VALUE vary;
100
+ VALUE vary = rb_ary_new();
102
101
  const char *vbuf;
103
102
  int vsiz;
104
103
  TCLIST *result;
105
104
  TCRDB *db = mTokyoTyrant_getdb(vself);
106
105
 
107
- vary = rb_ary_new();
108
106
  tcrdbiterinit(db);
109
107
  tcrdbmisc(db, "iterinit", RDBMONOULOG, tclistnew());
110
108
  while((result = tcrdbmisc(db, "iternext", RDBMONOULOG, tclistnew())) != NULL){
@@ -35,15 +35,16 @@ static VALUE cDB_put(VALUE vself, VALUE vkey, VALUE vstr){
35
35
  }
36
36
 
37
37
  static VALUE cDB_mput(VALUE vself, VALUE vhash){
38
- VALUE vary;
38
+ VALUE vary = Qnil;
39
39
  TCLIST *list, *args;
40
40
  TCRDB *db = mTokyoTyrant_getdb(vself);
41
41
 
42
42
  args = vhashtolist(vhash);
43
- list = tcrdbmisc(db, "putlist", 0, args);
44
- vary = listtovary(list);
43
+ if ((list = tcrdbmisc(db, "putlist", 0, args)) != NULL){
44
+ vary = listtovary(list);
45
+ tclistdel(list);
46
+ }
45
47
  tclistdel(args);
46
- tclistdel(list);
47
48
  return vary;
48
49
  }
49
50
 
@@ -74,45 +75,45 @@ static VALUE cDB_putshl(VALUE vself, VALUE vkey, VALUE vstr, VALUE vwidth){
74
75
  }
75
76
 
76
77
  static VALUE cDB_get(VALUE vself, VALUE vkey){
77
- VALUE vval;
78
+ VALUE vval = Qnil;
78
79
  char *buf;
79
80
  int bsiz, ecode;
80
81
  TCRDB *db = mTokyoTyrant_getdb(vself);
81
82
 
82
83
  // this is ugly
83
84
  vkey = StringValueEx(vkey);
84
- if(!(buf = tcrdbget(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), &bsiz))){
85
+ if((buf = tcrdbget(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), &bsiz)) == NULL){
85
86
  if ((ecode = tcrdbecode(db))) {
86
87
  if (ecode != TTENOREC) mTokyoTyrant_exception(vself, NULL);
87
88
  }
88
- return Qnil;
89
89
  } else {
90
90
  vval = StringRaw(buf, bsiz);
91
+ tcfree(buf);
91
92
  }
92
93
 
93
- tcfree(buf);
94
94
  return vval;
95
95
  }
96
96
 
97
97
  static VALUE cDB_mget(int argc, VALUE *argv, VALUE vself){
98
- VALUE vkeys, vhash, vvalue;
98
+ VALUE vkeys, vval;
99
+ VALUE vhash = Qnil;
99
100
  TCMAP *recs;
100
101
  TCRDB *db = mTokyoTyrant_getdb(vself);
101
102
  rb_scan_args(argc, argv, "*", &vkeys);
102
103
 
103
104
  // I really hope there is a better way to do this
104
105
  if (RARRAY_LEN(vkeys) == 1) {
105
- vvalue = rb_ary_entry(vkeys, 0);
106
- switch (TYPE(vvalue)){
106
+ vval = rb_ary_entry(vkeys, 0);
107
+ switch (TYPE(vval)){
107
108
  case T_STRING:
108
109
  case T_FIXNUM:
109
110
  break;
110
111
  case T_ARRAY:
111
- vkeys = vvalue;
112
+ vkeys = vval;
112
113
  break;
113
114
  case T_STRUCT: // range is not a T_STRUCT instead of a T_OBJECT in ruby1.9?
114
115
  case T_OBJECT:
115
- vkeys = rb_convert_type(vvalue, T_ARRAY, "Array", "to_a");
116
+ vkeys = rb_convert_type(vval, T_ARRAY, "Array", "to_a");
116
117
  break;
117
118
  }
118
119
  }
@@ -120,8 +121,9 @@ static VALUE cDB_mget(int argc, VALUE *argv, VALUE vself){
120
121
  Check_Type(vkeys, T_ARRAY);
121
122
 
122
123
  recs = varytomap(vkeys);
123
- if(!tcrdbget3(db, recs)) return Qnil;
124
- vhash = maptovhash(recs);
124
+ if(tcrdbget3(db, recs)){
125
+ vhash = maptovhash(recs);
126
+ }
125
127
  tcmapdel(recs);
126
128
  return vhash;
127
129
  }
@@ -154,11 +156,12 @@ static VALUE cDB_each(VALUE vself){
154
156
  tcrdbiterinit(db);
155
157
  int ksiz;
156
158
  char *kbuf;
159
+
157
160
  while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
158
- int vsiz;
159
- char *vbuf = tcrdbget(db, kbuf, ksiz, &vsiz);
160
- vrv = rb_yield_values(2, rb_str_new2(kbuf), StringRaw(vbuf, vsiz));
161
- tcfree(vbuf);
161
+ VALUE vkey = rb_str_new(kbuf, ksiz);
162
+ VALUE vval = cDB_get(vself, vkey);
163
+
164
+ vrv = rb_yield_values(2, vkey, vval);
162
165
  tcfree(kbuf);
163
166
  }
164
167
  return vrv;
@@ -172,11 +175,12 @@ static VALUE cDB_each_value(VALUE vself){
172
175
  tcrdbiterinit(db);
173
176
  int ksiz;
174
177
  char *kbuf;
178
+
175
179
  while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
176
- int vsiz;
177
- char *vbuf = tcrdbget(db, kbuf, ksiz, &vsiz);
178
- vrv = rb_yield_values(1, StringRaw(vbuf, vsiz));
179
- tcfree(vbuf);
180
+ VALUE vkey = rb_str_new(kbuf, ksiz);
181
+ VALUE vval = cDB_get(vself, vkey);
182
+
183
+ vrv = rb_yield_values(1, vval);
180
184
  tcfree(kbuf);
181
185
  }
182
186
  return vrv;
@@ -189,11 +193,12 @@ static VALUE cDB_values(VALUE vself){
189
193
  tcrdbiterinit(db);
190
194
  int ksiz;
191
195
  char *kbuf;
196
+
192
197
  while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
193
- int vsiz;
194
- char *vbuf = tcrdbget(db, kbuf, ksiz, &vsiz);
195
- rb_ary_push(vary, StringRaw(vbuf, vsiz));
196
- tcfree(vbuf);
198
+ VALUE vkey = rb_str_new(kbuf, ksiz);
199
+ VALUE vval = cDB_get(vself, vkey);
200
+
201
+ rb_ary_push(vary, vval);
197
202
  tcfree(kbuf);
198
203
  }
199
204
  return vary;
@@ -146,7 +146,8 @@ static VALUE mTokyoTyrant_out(VALUE vself, VALUE vkey){
146
146
 
147
147
  // TODO: merge out and mout?
148
148
  static VALUE mTokyoTyrant_outlist(int argc, VALUE *argv, VALUE vself){
149
- VALUE vkeys, vary, vvalue;
149
+ VALUE vkeys, vvalue;
150
+ VALUE vary = rb_ary_new();
150
151
  TCLIST *list, *result;
151
152
  TCRDB *db = mTokyoTyrant_getdb(vself);
152
153
  rb_scan_args(argc, argv, "*", &vkeys);
@@ -169,10 +170,11 @@ static VALUE mTokyoTyrant_outlist(int argc, VALUE *argv, VALUE vself){
169
170
  Check_Type(vkeys, T_ARRAY);
170
171
 
171
172
  list = varytolist(vkeys);
172
- result = tcrdbmisc(db, "outlist", 0, list);
173
+ if ((result = tcrdbmisc(db, "outlist", 0, list)) != NULL){
174
+ vary = listtovary(result);
175
+ tclistdel(result);
176
+ }
173
177
  tclistdel(list);
174
- vary = listtovary(result);
175
- tclistdel(result);
176
178
  return vary;
177
179
  }
178
180
 
@@ -190,14 +192,14 @@ static VALUE mTokyoTyrant_iterinit(VALUE vself){
190
192
  }
191
193
 
192
194
  static VALUE mTokyoTyrant_iternext(VALUE vself){
193
- VALUE vval;
195
+ VALUE vval = Qnil;
194
196
  char *vbuf;
195
197
  TCRDB *db = mTokyoTyrant_getdb(vself);
196
198
 
197
- if(!(vbuf = tcrdbiternext2(db))) return Qnil;
198
- vval = rb_str_new2(vbuf);
199
- tcfree(vbuf);
200
-
199
+ if((vbuf = tcrdbiternext2(db)) != NULL){
200
+ vval = rb_str_new2(vbuf);
201
+ tcfree(vbuf);
202
+ }
201
203
  return vval;
202
204
  }
203
205
 
@@ -387,7 +389,8 @@ static VALUE mTokyoTyrant_stat(VALUE vself){
387
389
  }
388
390
 
389
391
  static VALUE mTokyoTyrant_misc(int argc, VALUE *argv, VALUE vself){
390
- VALUE vname, vopts, vargs, vary;
392
+ VALUE vname, vopts, vargs;
393
+ VALUE vary = rb_ary_new();
391
394
  TCLIST *list, *args;
392
395
  TCRDB *db = mTokyoTyrant_getdb(vself);
393
396
  rb_scan_args(argc, argv, "13", &vname, &vopts, &vargs);
@@ -401,38 +404,41 @@ static VALUE mTokyoTyrant_misc(int argc, VALUE *argv, VALUE vself){
401
404
  if ((list = tcrdbmisc(db, RSTRING_PTR(vname), NUM2INT(vopts), args)) != NULL){
402
405
  vary = listtovary(list);
403
406
  tclistdel(list);
404
- } else {
405
- vary = rb_ary_new();
406
407
  }
407
408
  tclistdel(args);
408
409
 
409
410
  return vary;
410
411
  }
411
412
 
412
- static VALUE mTokyoTyrant_ext(VALUE vself, VALUE vext, VALUE vkey, VALUE vvalue){
413
- int vsiz;
414
- char *vbuf;
413
+ static VALUE mTokyoTyrant_ext(VALUE vself, VALUE vext, VALUE vkey, VALUE vval){
414
+ int rsiz;
415
+ char *rbuf, *kbuf, *vbuf, *xbuf;
415
416
  TCRDB *db = mTokyoTyrant_getdb(vself);
417
+ VALUE vres = Qnil;
416
418
  vext = StringValueEx(vext);
417
419
  vkey = StringValueEx(vkey);
418
- vvalue = StringValueEx(vvalue);
419
-
420
- if(!(vbuf = tcrdbext(db, RSTRING_PTR(vext), 0, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vvalue), RSTRING_LEN(vvalue), &vsiz))){
421
- return Qnil;
422
- } else {
423
- return rb_str_new(vbuf, vsiz);
420
+ vval = StringValueEx(vval);
421
+ xbuf = RSTRING_PTR(vext);
422
+ kbuf = RSTRING_PTR(vkey);
423
+ vbuf = RSTRING_PTR(vval);
424
+
425
+ if((rbuf = tcrdbext(db, xbuf, 0, kbuf, RSTRING_LEN(vkey), vbuf, RSTRING_LEN(vval), &rsiz)) != NULL){
426
+ vres = rb_str_new(rbuf, rsiz);
427
+ tcfree(rbuf);
424
428
  }
429
+ return vres;
425
430
  }
426
431
 
427
432
  static VALUE mTokyoTyrant_each_key(VALUE vself){
428
- VALUE vrv;
429
- char *kxstr;
433
+ VALUE vrv = Qnil;
434
+ char *kbuf;
430
435
  if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
431
436
  TCRDB *db = mTokyoTyrant_getdb(vself);
432
- vrv = Qnil;
437
+
433
438
  tcrdbiterinit(db);
434
- while((kxstr = tcrdbiternext2(db)) != NULL){
435
- vrv = rb_yield_values(1, rb_str_new2(kxstr));
439
+ while((kbuf = tcrdbiternext2(db)) != NULL){
440
+ vrv = rb_yield_values(1, rb_str_new2(kbuf));
441
+ tcfree(kbuf);
436
442
  }
437
443
  return vrv;
438
444
  }
@@ -36,7 +36,8 @@ static VALUE cTable_put(VALUE vself, VALUE vkey, VALUE vcols){
36
36
 
37
37
  static VALUE cTable_mput(VALUE vself, VALUE vhash){
38
38
  int i, num, j;
39
- VALUE vary, vkeys, vkey, vval;
39
+ VALUE vkeys, vkey, vval;
40
+ VALUE vary = Qnil;
40
41
  TCLIST *list, *result;
41
42
  TCRDB *db = mTokyoTyrant_getdb(vself);
42
43
 
@@ -63,10 +64,12 @@ static VALUE cTable_mput(VALUE vself, VALUE vhash){
63
64
  tclistdel(cols);
64
65
  tcxstrdel(xstr);
65
66
  }
66
- result = tcrdbmisc(db, "putlist", 0, list);
67
+
68
+ if ((result = tcrdbmisc(db, "putlist", 0, list)) != NULL){
69
+ vary = listtovary(result);
70
+ tclistdel(result);
71
+ }
67
72
  tclistdel(list);
68
- vary = listtovary(result);
69
- tclistdel(result);
70
73
  return vary;
71
74
  }
72
75
 
@@ -86,61 +89,61 @@ static VALUE cTable_out(VALUE vself, VALUE vkey){
86
89
  }
87
90
 
88
91
  static VALUE cTable_get(VALUE vself, VALUE vkey){
89
- VALUE vcols;
92
+ VALUE vcols = Qnil;
90
93
  int ecode;
91
94
  TCMAP *cols;
92
95
  TCRDB *db = mTokyoTyrant_getdb(vself);
93
96
 
94
97
  vkey = StringValueEx(vkey);
95
- if(!(cols = tcrdbtblget(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey)))){
98
+ if((cols = tcrdbtblget(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey))) == NULL){
96
99
  if ((ecode = tcrdbecode(db))) {
97
100
  if (ecode != TTENOREC) mTokyoTyrant_exception(vself, NULL);
98
101
  }
99
- return Qnil;
100
102
  } else {
101
103
  vcols = maptovhash(cols);
104
+ tcmapdel(cols);
102
105
  }
103
-
104
- tcmapdel(cols);
105
106
  return vcols;
106
107
  }
107
108
 
108
109
  static VALUE cTable_mget(int argc, VALUE *argv, VALUE vself){
109
110
  const char *kbuf;
110
111
  int ksiz, vsiz;
111
- VALUE vkeys, vhash, vcols, vvalue;
112
+ VALUE vkeys, vcols, vval;
113
+ VALUE vhash = Qnil;
112
114
  TCMAP *recs, *cols;
113
115
  TCRDB *db = mTokyoTyrant_getdb(vself);
114
116
  rb_scan_args(argc, argv, "*", &vkeys);
115
117
 
116
118
  // I really hope there is a better way to do this
117
119
  if (RARRAY_LEN(vkeys) == 1) {
118
- vvalue = rb_ary_entry(vkeys, 0);
119
- switch (TYPE(vvalue)){
120
+ vval = rb_ary_entry(vkeys, 0);
121
+ switch (TYPE(vval)){
120
122
  case T_STRING:
121
123
  case T_FIXNUM:
122
124
  break;
123
125
  case T_ARRAY:
124
- vkeys = vvalue;
126
+ vkeys = vval;
125
127
  break;
126
128
  case T_STRUCT: // range is not a T_STRUCT instead of a T_OBJECT in ruby1.9?
127
129
  case T_OBJECT:
128
- vkeys = rb_convert_type(vvalue, T_ARRAY, "Array", "to_a");
130
+ vkeys = rb_convert_type(vval, T_ARRAY, "Array", "to_a");
129
131
  break;
130
132
  }
131
133
  }
132
134
  Check_Type(vkeys, T_ARRAY);
133
135
 
134
136
  recs = varytomap(vkeys);
135
- if(!tcrdbget3(db, recs)) return Qnil;
136
- vhash = rb_hash_new();
137
- tcmapiterinit(recs);
138
- while((kbuf = tcmapiternext(recs, &ksiz)) != NULL){
139
- const char *vbuf = tcmapiterval(kbuf, &vsiz);
140
- cols = tcstrsplit4(vbuf, vsiz);
141
- vcols = maptovhash(cols);
142
- tcmapdel(cols);
143
- rb_hash_aset(vhash, StringRaw(kbuf, ksiz), vcols);
137
+ if(tcrdbget3(db, recs)){
138
+ vhash = rb_hash_new();
139
+ tcmapiterinit(recs);
140
+ while((kbuf = tcmapiternext(recs, &ksiz)) != NULL){
141
+ const char *vbuf = tcmapiterval(kbuf, &vsiz);
142
+ cols = tcstrsplit4(vbuf, vsiz);
143
+ vcols = maptovhash(cols);
144
+ tcmapdel(cols);
145
+ rb_hash_aset(vhash, StringRaw(kbuf, ksiz), vcols);
146
+ }
144
147
  }
145
148
  tcmapdel(recs);
146
149
  return vhash;
@@ -177,65 +180,59 @@ static VALUE cTable_fetch(int argc, VALUE *argv, VALUE vself){
177
180
  vrv = rb_yield(vkey);
178
181
  cTable_put(vself, vkey, vrv);
179
182
  }
180
-
181
183
  return vrv;
182
184
  }
183
185
 
184
186
  static VALUE cTable_each(VALUE vself){
185
- VALUE vrv;
186
- TCMAP *cols;
187
+ VALUE vrv = Qnil;
187
188
  char *kbuf;
188
189
  int ksiz;
189
190
  if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
190
191
  TCRDB *db = mTokyoTyrant_getdb(vself);
191
- vrv = Qnil;
192
+
192
193
  tcrdbiterinit(db);
193
194
  while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
194
- if((cols = tcrdbtblget(db, kbuf, ksiz)) != NULL){
195
- vrv = rb_yield_values(2, rb_str_new(kbuf, ksiz), maptovhash(cols));
196
- tcmapdel(cols);
197
- } else {
198
- vrv = rb_yield_values(2, rb_str_new(kbuf, ksiz), Qnil);
199
- }
195
+ VALUE vkey = rb_str_new(kbuf, ksiz);
196
+ VALUE vval = cTable_get(vself, vkey);
197
+
198
+ vrv = rb_yield_values(2, vkey, vval);
200
199
  tcfree(kbuf);
201
200
  }
202
201
  return vrv;
203
202
  }
204
203
 
205
204
  static VALUE cTable_each_value(VALUE vself){
206
- VALUE vrv;
207
- TCMAP *cols;
205
+ VALUE vrv = Qnil;
208
206
  char *kbuf;
209
207
  int ksiz;
210
208
  if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
211
209
  TCRDB *db = mTokyoTyrant_getdb(vself);
212
- vrv = Qnil;
210
+
213
211
  tcrdbiterinit(db);
214
212
  while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
215
- if((cols = tcrdbtblget(db, kbuf, ksiz)) != NULL){
216
- vrv = rb_yield(maptovhash(cols));
217
- tcmapdel(cols);
218
- } else {
219
- vrv = rb_yield(Qnil);
220
- }
213
+ VALUE vkey = rb_str_new(kbuf, ksiz);
214
+ VALUE vval = cTable_get(vself, vkey);
215
+
216
+ vrv = rb_yield_values(1, vval);
221
217
  tcfree(kbuf);
222
218
  }
223
219
  return vrv;
224
220
  }
225
221
 
226
222
  static VALUE cTable_values(VALUE vself){
227
- VALUE vary;
228
- TCMAP *cols;
229
- char *kxstr;
223
+ VALUE vary = rb_ary_new();;
224
+ char *kbuf;
230
225
  int ksiz;
231
226
  TCRDB *db = mTokyoTyrant_getdb(vself);
227
+
232
228
  vary = rb_ary_new2(tcrdbrnum(db));
233
229
  tcrdbiterinit(db);
234
- while((kxstr = tcrdbiternext(db, &ksiz)) != NULL){
235
- cols = tcrdbtblget(db, kxstr, ksiz);
236
- rb_ary_push(vary, maptovhash(cols));
237
- tcmapdel(cols);
238
- tcfree(kxstr);
230
+ while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
231
+ VALUE vkey = rb_str_new(kbuf, ksiz);
232
+ VALUE vval = cTable_get(vself, vkey);
233
+
234
+ rb_ary_push(vary, vval);
235
+ tcfree(kbuf);
239
236
  }
240
237
  return vary;
241
238
  }
metadata CHANGED
@@ -1,11 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-tokyotyrant
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- version: "0.5"
4
+ version: 0.5.1
9
5
  platform: ruby
10
6
  authors:
11
7
  - Flinn
@@ -13,7 +9,7 @@ autorequire:
13
9
  bindir: bin
14
10
  cert_chain: []
15
11
 
16
- date: 2010-03-31 00:00:00 -04:00
12
+ date: 2010-05-22 00:00:00 -04:00
17
13
  default_executable:
18
14
  dependencies: []
19
15
 
@@ -75,20 +71,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
71
  requirements:
76
72
  - - ">="
77
73
  - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
74
  version: "0"
75
+ version:
81
76
  required_rubygems_version: !ruby/object:Gem::Requirement
82
77
  requirements:
83
78
  - - ">="
84
79
  - !ruby/object:Gem::Version
85
- segments:
86
- - 0
87
80
  version: "0"
81
+ version:
88
82
  requirements: []
89
83
 
90
84
  rubyforge_project:
91
- rubygems_version: 1.3.6
85
+ rubygems_version: 1.3.5
92
86
  signing_key:
93
87
  specification_version: 3
94
88
  summary: A C based TokyoTyrant Ruby binding