List:Commits« Previous MessageNext Message »
From:John David Duncan Date:May 17 2011 5:26am
Subject:bzr commit into mysql-5.1-telco-7.2 branch (john.duncan:4181)
View as plain text  
#At file:///Users/jdd/bzr-repo/working/cluster-7.2-labs-memcached/ based on revid:john.duncan@stripped

 4181 John David Duncan	2011-05-16
      Support writing multiple columns from tab-separated values

    modified:
      storage/ndb/memcache/src/ndb_worker.cc
=== modified file 'storage/ndb/memcache/src/ndb_worker.cc'
--- a/storage/ndb/memcache/src/ndb_worker.cc	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/src/ndb_worker.cc	2011-05-17 05:25:51 +0000
@@ -41,6 +41,7 @@
 #include "workitem.h"
 #include "Configuration.h"
 #include "DataTypeHandler.h"
+#include "TabSeparatedValues.h"
 #include "debug.h"
 #include "Operation.h"
 #include "NdbInstance.h"
@@ -128,9 +129,18 @@ op_status_t worker_prepare_operation(wor
   /* Jump table */
   switch(newitem->base.verb) {
     case OP_READ:
+      r = worker_do_read(newitem, server_cas);
+      break;
+      
     case OPERATION_APPEND:
     case OPERATION_PREPEND:
-      r = worker_do_read(newitem, server_cas);
+      if(newitem->plan->spec->nvaluecols > 1) {
+        /* APPEND/PREPEND is currently not supported for tsv */
+        r = op_not_supported;
+      }
+      else {
+        r = worker_do_read(newitem, server_cas);
+      }
       break;
 
     case OP_DELETE: 
@@ -215,12 +225,33 @@ op_status_t worker_do_write(workitem *wq
 
   /* Set the row */
   op.clearNullBits();
-  op.setColumn(COL_STORE_KEY, dbkey, wqitem->base.nsuffix);    
-  op.setColumn(COL_STORE_VALUE, hash_item_get_data(wqitem->cache_item),
-               wqitem->cache_item->nbytes);                        // the value
+  op.setColumn(COL_STORE_KEY, dbkey, wqitem->base.nsuffix);
+  
+  if(plan->spec->nvaluecols > 1) {
+    /* Multiple Value Columns */
+    TabSeparatedValues tsv(hash_item_get_data(wqitem->cache_item), 
+                           plan->spec->nvaluecols, wqitem->cache_item->nbytes); 
+    int idx = 0;
+    do {
+      if(tsv.getLength()) {
+        op.setColumn(COL_STORE_VALUE+idx, tsv.getPointer(), tsv.getLength());
+      }
+      else {
+        op.setColumnNull(COL_STORE_VALUE+idx);
+      }
+      idx++;
+    } while (tsv.advance());
+  }
+  else {
+    /* Just one value column */
+    op.setColumn(COL_STORE_VALUE, hash_item_get_data(wqitem->cache_item),
+                 wqitem->cache_item->nbytes);
+  }
+
   if(server_cas) {
     op.setColumnBigUnsigned(COL_STORE_CAS, * wqitem->cas);   // the cas
   }
+
   if(wqitem->plan->dup_numbers) {
     if(isdigit(* hash_item_get_data(wqitem->cache_item)) && 
        wqitem->cache_item->nbytes < 32) {      // Copy string representation 


Attachment: [text/bzr-bundle] bzr/john.duncan@oracle.com-20110517052551-23qc6paiavucscrk.bundle
Thread
bzr commit into mysql-5.1-telco-7.2 branch (john.duncan:4181) John David Duncan17 May