gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12482 - in gnunet: . src/datastore


From: gnunet
Subject: [GNUnet-SVN] r12482 - in gnunet: . src/datastore
Date: Fri, 6 Aug 2010 13:35:50 +0200

Author: grothoff
Date: 2010-08-06 13:35:50 +0200 (Fri, 06 Aug 2010)
New Revision: 12482

Modified:
   gnunet/TODO
   gnunet/src/datastore/plugin_datastore_mysql.c
   gnunet/src/datastore/test_datastore_api.c
Log:
getting mysql to work

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-08-06 11:34:25 UTC (rev 12481)
+++ gnunet/TODO 2010-08-06 11:35:50 UTC (rev 12482)
@@ -52,7 +52,6 @@
   - integration with transport service
 * MYSQL database backends: [CG]
   - datacache
-  - datastore
 * FS: [CG]
   - library:
     + reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME 
in fs_download)

Modified: gnunet/src/datastore/plugin_datastore_mysql.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_mysql.c       2010-08-06 11:34:25 UTC 
(rev 12481)
+++ gnunet/src/datastore/plugin_datastore_mysql.c       2010-08-06 11:35:50 UTC 
(rev 12482)
@@ -1233,7 +1233,8 @@
     }
 #if DEBUG_MYSQL
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Calling iterator with value %llu of size %u with type %u, 
priority %u, anonymity %u and expiration %llu\n",
+             "Calling iterator with value `%s' number %llu of size %u with 
type %u, priority %u, anonymity %u and expiration %llu\n",
+             GNUNET_h2s (&key),
              vkey,
              size,
              type,
@@ -1445,7 +1446,8 @@
     }
 #if DEBUG_MYSQL
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Inserted value number %llu with size %u into gn080 table\n",
+             "Inserted value `%s' number %llu with size %u into gn080 table\n",
+             GNUNET_h2s (key),
              vkey,
              isize);
 #endif
@@ -1484,7 +1486,6 @@
 
   unsigned int prio;
   unsigned int anonymity;
-  unsigned int limit_off;
   unsigned long long expiration;
   unsigned long long vkey;
   unsigned long long total;
@@ -1492,7 +1493,6 @@
   int count;
   int have_vhash;
   unsigned long size; /* OBSOLETE! */
-  unsigned long hashSize;
 };
 
 
@@ -1503,6 +1503,8 @@
   struct GetContext *gc = cls;
   struct Plugin *plugin;
   int ret;
+  unsigned int limit_off;
+  unsigned long hashSize;
 
   if (NULL == nrc)
     {
@@ -1512,12 +1514,22 @@
   if (gc->count == gc->total)
     return GNUNET_NO;
   plugin = nrc->plugin;
-  gc->hashSize = sizeof (GNUNET_HashCode);
+  hashSize = sizeof (GNUNET_HashCode);
+  if (gc->count + gc->off == gc->total)
+    nrc->last_vkey = 0;          /* back to start */
   if (gc->count == 0)
-    gc->limit_off = gc->off;
+    limit_off = gc->off;
   else
-    gc->limit_off = 0;
-  
+    limit_off = 0;
+#if DEBUG_MYSQL
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Obtaining result number %d/%lld at offset %d with lvc %llu for 
GET `%s'\n",
+             gc->count+1,
+             gc->total,
+             limit_off,
+             nrc->last_vkey,
+             GNUNET_h2s (&gc->key));  
+#endif
   if (nrc->type != 0)
     {
       if (gc->have_vhash)
@@ -1526,10 +1538,10 @@
            prepared_statement_run_select
            (plugin,
             plugin->select_entry_by_hash_vhash_and_type, 7, nrc->rbind, 
&return_ok,
-            NULL, MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize,
-            MYSQL_TYPE_BLOB, &gc->vhash, gc->hashSize, &gc->hashSize,
+            NULL, MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize,
+            MYSQL_TYPE_BLOB, &gc->vhash, hashSize, &hashSize,
             MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG,
-            &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &gc->limit_off, 
GNUNET_YES,
+            &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &limit_off, GNUNET_YES,
             -1);
        }
       else
@@ -1538,9 +1550,9 @@
            prepared_statement_run_select
            (plugin,
             plugin->select_entry_by_hash_and_type, 7, nrc->rbind, &return_ok, 
NULL,
-            MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize,
+            MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize,
             MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG,
-            &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &gc->limit_off, 
GNUNET_YES,
+            &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &limit_off, GNUNET_YES,
             -1);
        }
     }
@@ -1552,9 +1564,9 @@
            prepared_statement_run_select
            (plugin,
             plugin->select_entry_by_hash_and_vhash, 7, nrc->rbind, &return_ok, 
NULL,
-            MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize, 
MYSQL_TYPE_BLOB,
-            &gc->vhash, gc->hashSize, &gc->hashSize, MYSQL_TYPE_LONGLONG,
-            &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, &gc->limit_off,
+            MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize, MYSQL_TYPE_BLOB,
+            &gc->vhash, hashSize, &hashSize, MYSQL_TYPE_LONGLONG,
+            &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, &limit_off,
             GNUNET_YES, -1);
        }
       else
@@ -1563,13 +1575,12 @@
            prepared_statement_run_select
            (plugin,
             plugin->select_entry_by_hash, 7, nrc->rbind, &return_ok, NULL,
-            MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize,
+            MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize,
             MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG,
-            &gc->limit_off, GNUNET_YES, -1);
+            &limit_off, GNUNET_YES, -1);
        }
     }
-  if (gc->count + gc->off == gc->total)
-    nrc->last_vkey = 0;          /* back to start */
+  gc->count++;
   return ret;
 }
 
@@ -1604,7 +1615,7 @@
   MYSQL_BIND cbind[1];
   struct GetContext *gc;
   struct NextRequestClosure *nrc;
-  unsigned long long total;
+  long long total;
   unsigned long hashSize;
 
   if (iter == NULL) 
@@ -1621,7 +1632,7 @@
   total = -1;
   cbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
   cbind[0].buffer = &total;
-  cbind[0].is_unsigned = GNUNET_YES;
+  cbind[0].is_unsigned = GNUNET_NO;
   if (type != 0)
     {
       if (vhash != NULL)
@@ -1668,13 +1679,19 @@
                                           &hashSize, -1);
         }
     }
-  if ((ret != GNUNET_OK) || (-1 == total) || (0 == total))
+  if ((ret != GNUNET_OK) || (0 >= total))
     {
       iter (iter_cls, 
            NULL, NULL, 0, NULL, 0, 0, 0, 
            GNUNET_TIME_UNIT_ZERO_ABS, 0);
       return;
     }
+#if DEBUG_MYSQL
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Iterating over %lld results for GET `%s'\n",
+             total,
+             GNUNET_h2s (key));
+#endif
   gc = GNUNET_malloc (sizeof (struct GetContext));
   gc->key = *key;
   if (vhash != NULL)
@@ -1694,7 +1711,7 @@
   nrc->dviter_cls = iter_cls;
   nrc->prep = &get_statement_prepare;
   nrc->prep_cls = gc;
-  nrc->last_vkey = 0; // FIXME: used to be 'vkey', why? where did vkey come 
from?
+  nrc->last_vkey = 0;
   mysql_plugin_next_request (nrc, GNUNET_NO);
 }
 

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2010-08-06 11:34:25 UTC (rev 
12481)
+++ gnunet/src/datastore/test_datastore_api.c   2010-08-06 11:35:50 UTC (rev 
12482)
@@ -111,10 +111,10 @@
     RP_PUT_MULTIPLE,
     RP_PUT_MULTIPLE_NEXT,
     RP_GET_MULTIPLE,
-    RP_GET_MULTIPLE_NEXT,
+    RP_GET_MULTIPLE_NEXT, /* 10 */
     RP_GET_MULTIPLE_DONE,
     RP_UPDATE,
-    RP_UPDATE_VALIDATE,
+    RP_UPDATE_VALIDATE, /* 13 */
     RP_UPDATE_DONE,
     RP_ERROR
   };




reply via email to

[Prev in Thread] Current Thread [Next in Thread]