Tokyocabinet Ruby gem - adbopen patch

12 views
Skip to first unread message

shmul

unread,
Nov 5, 2013, 8:25:40 AM11/5/13
to tokyocabi...@googlegroups.com, eldan....@trusteer.com
Hi,

The enclosed patch adds to the tokyocabinet.c gem (tested with 1.31) support for reading adb files using their common naming scheme that starts with "%" .

Cheers,
Shmul

--- tokyocabinet.c    2010-07-19 01:13:03.000000000 -0500
+++ ../../tokyocabinet-ruby-1.31/tokyocabinet.c    2011-07-14 06:29:21.000000000 -0500
@@ -3419,10 +3419,22 @@
 static VALUE adb_open(VALUE vself, VALUE vname){
   VALUE vadb;
   TCADB *adb;
+  const char* name;
   Check_Type(vname, T_STRING);
   vadb = rb_iv_get(vself, ADBVNDATA);
   Data_Get_Struct(vadb, TCADB, adb);
-  return tcadbopen(adb, RSTRING_PTR(vname)) ? Qtrue : Qfalse;
+
+
+  name = RSTRING_PTR(vname);
+  if(*name == '%'){
+    if(!tcadbsetskelmulti(adb, 8)){
+      tcadbdel(adb);
+      return Qfalse;
+    }
+    name++;
+  }
+  return tcadbopen(adb, name) ? Qtrue : Qfalse;
+
 }

Reply all
Reply to author
Forward
0 new messages