List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:July 26 2007 12:20am
Subject:Rev 128: Fixed python example programs. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge

------------------------------------------------------------
revno: 128
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Wed 2007-07-25 17:19:55 -0700
message:
  Fixed python example programs.
modified:
  python/testasynch.py           testasynch.py-20070227185119-f8ow9m7i9zfgr5jr-1
  python/testcol.py              testcol.py-20070506023415-o1g4qsz3fyfle5iq-1
  python/testdt.py               testdt.py-20070506023415-o1g4qsz3fyfle5iq-2
  python/teststr.py             
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fteststr.py
  python/teststr2.py            
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fteststr2.py
  python/teststrwrite.py        
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fteststrwrite.py
=== modified file 'python/testasynch.py'
--- a/python/testasynch.py	2007-07-25 17:20:31 +0000
+++ b/python/testasynch.py	2007-07-26 00:19:55 +0000
@@ -60,7 +60,7 @@
   print e
   sys.exit(-1)
 
-if (connection.wait_until_ready(30,30)):
+if (connection.waitUntilReady(30,30)):
     print "Cluster was not ready within 30 secs."
     sys.exit(-1);
 
@@ -93,7 +93,7 @@
     myOperation.insertTuple()
     auto_id = myNdb.getAutoIncrementValue("mytablename",BATCH_SIZE)
    
-    myOperation.equal("ATTR1",auto_id);
+    myOperation.equalUint64("ATTR1",auto_id);
     myOperation.setValue("ATTR2", i);
       
   ret = myTransaction.execute( ndbapi.Commit )
@@ -169,7 +169,7 @@
     mydata.myOper = mydata.myTrans.getNdbOperation("mytablename")
     mydata.myOper.readTuple(ndbapi.NdbOperation.LM_Read)
 
-    mydata.myOper.equal("ATTR1",mydata.id_num)
+    mydata.myOper.equalUint64("ATTR1",mydata.id_num)
             
     mydata.myRecAttr= mydata.myOper.getValue("ATTR2")
 

=== modified file 'python/testcol.py'
--- a/python/testcol.py	2007-05-07 07:59:37 +0000
+++ b/python/testcol.py	2007-07-26 00:19:55 +0000
@@ -3,7 +3,7 @@
 
 c=ndbapi.NdbFactory.createNdbClusterConnection()
 c.connect(1,1,1)
-c.wait_until_ready(5,5)
+c.waitUntilReady(5,5)
 
 ndb=c.createNdb('test')
 ndb.init(1)

=== modified file 'python/testdt.py'
--- a/python/testdt.py	2007-05-07 07:59:37 +0000
+++ b/python/testdt.py	2007-07-26 00:19:55 +0000
@@ -5,7 +5,7 @@
 mtdate=datetime.now()
 c=ndbapi.NdbFactory.createNdbClusterConnection()
 c.connect(1,1,1)
-c.wait_until_ready(5,5)
+c.waitUntilReady(5,5)
 
 ndb=c.createNdb('test')
 ndb.init(1)

=== modified file 'python/teststr.py'
--- a/python/teststr.py	2007-04-03 04:06:47 +0000
+++ b/python/teststr.py	2007-07-26 00:19:55 +0000
@@ -35,7 +35,8 @@
 
 print "connecting to cluster\n"
     
-connection = ndbapi.Ndb_cluster_connection()
+connection = ndbapi.NdbFactory.createNdbClusterConnection() 
+#NdbClusterConnection()
 
 if (connection.connect(5,3,1)):
 
@@ -43,7 +44,7 @@
     sys.exit(-1)
     
     
-if (connection.wait_until_ready(30,30)):
+if (connection.waitUntilReady(30,30)):
     print "Cluster was not ready within 30 secs."
     sys.exit(-1);
 
@@ -72,14 +73,15 @@
       
     auto_id = myNdb.getAutoIncrementValue("mytablename",0)
         
-    myOperation.equal("ATTR1",auto_id);
-    myOperation.setValue("ATTR2", str(i),len(str(i)));
+    print auto_id
+    myOperation.equalUint64("ATTR1",auto_id);
+    myOperation.setValue("ATTR2", i);
       
     ret = myTransaction.execute( ndbapi.Commit )
     if ret == -1:
 	print myTransaction.getNdbError().message
         
-    myNdb.closeTransaction(myTransaction)
+    myTransaction.close()
 
 after_t = time.time()
 print "Insert time for %s: %s -- %s" % ( INSERT_NUM, after_t, before_t)
@@ -114,11 +116,11 @@
     if (myScanOperation.nextResult(True) != 0) :
         break
       
-    random_id = myRecAttr.u_32_value()
+    random_id = myRecAttr.getValue()
     ids.append(random_id)
       
     
-myNdb.closeTransaction(myTransaction)
+myTransaction.close()
 
 
 ### Fetch ids using ndbapi
@@ -135,17 +137,17 @@
     myOper.readTuple(ndbapi.NdbOperation.LM_Read)
 
     id_num = ids[random.randrange(0,len(ids))]
-    myOper.equal("ATTR1",id_num)
+    myOper.equalUint64("ATTR1",id_num)
             
-    myRecAttr= myOper.getValue("ATTR2", "")
+    myRecAttr= myOper.getValue("ATTR2")
 
     
     if myTrans.execute( ndbapi.Commit ) == -1:
         print myTrans.getNdbError()
-    #foo=myRecAttr.u_32_value()
-    foo=myRecAttr.get_value()
-    print foo, myRecAttr.getColType(), myRecAttr.get_value()
-    myNdb.closeTransaction(myTrans)
+    #foo=myRecAttr.getValue()
+    foo=myRecAttr.getValue()
+    print foo, myRecAttr.getColType(), myRecAttr.getValue()
+    myTrans.close()
       
 
 after_t = time.time()

=== modified file 'python/teststr2.py'
--- a/python/teststr2.py	2007-03-21 22:34:57 +0000
+++ b/python/teststr2.py	2007-07-26 00:19:55 +0000
@@ -1,5 +1,5 @@
 import sys,time,random
-import ndb
+from mysql.cluster import ndbapi
 
 if len(sys.argv) != 3:
   print "Usage:\n\ttest.py NUM_OF_ITERATIONS NUM_OF_ROWS "
@@ -11,9 +11,9 @@
 
 print "connecting to cluster\n"
 
-ndb.ndb_init()
+#ndb.ndb_init()
 
-connection = ndb.Ndb_cluster_connection()
+connection = ndbapi.NdbFactory.createNdbClusterConnection()
 
 if (connection.connect(5,3,1)):
 
@@ -21,12 +21,12 @@
     sys.exit(-1)
     
     
-if (connection.wait_until_ready(30,30)):
+if (connection.waitUntilReady(30,30)):
     print "Cluster was not ready within 30 secs."
     sys.exit(-1);
 
 
-myNdb = ndb.Ndb(connection,"test" )
+myNdb = connection.createNdb("test" )
 
 if (myNdb.init(4) == -1):
     print myNdb.getNdbError()
@@ -47,7 +47,7 @@
     print myTransaction.getNdbError();
 
 
-if myScanOperation.readTuples(ndb.NdbOperation.LM_CommittedRead):
+if myScanOperation.readTuples(ndbapi.NdbOperation.LM_CommittedRead):
     print myScanOperation.getNdbError();
 
 
@@ -55,7 +55,7 @@
 myRecAttr=myScanOperation.getValue("ATTR1");
     
     
-myTransaction.execute(ndb.NoCommit);
+myTransaction.execute(ndbapi.NoCommit);
 
 ids=[]
 while 1:
@@ -63,12 +63,12 @@
     if (myScanOperation.nextResult(True) != 0) :
         break
       
-    random_id = myRecAttr.u_32_value()
+    random_id = myRecAttr.getValue()
     ids.append(random_id)
 
 print ids
     
-myNdb.closeTransaction(myTransaction)
+myTransaction.close()
 
 
 ### Fetch ids using ndb
@@ -82,22 +82,22 @@
         print myNdb.getNdbError()
 
     myOper = myTrans.getNdbOperation("mytablename")
-    myOper.readTuple(ndb.NdbOperation.LM_Read)
+    myOper.readTuple(ndbapi.NdbOperation.LM_Read)
 
     id_num = ids[random.randrange(0,len(ids))]
-    myOper.equal("ATTR1",id_num)
+    myOper.equalUint64("ATTR1",id_num)
             
     myRecAttr= myOper.getValue("ATTR2")
     
-    if myTrans.execute( ndb.Commit ) == -1:
+    if myTrans.execute( ndbapi.Commit ) == -1:
         print myTrans.getNdbError()
     bar=myRecAttr.aRef()
     print "bar:", bar
-    #foo=myRecAttr.char_value()
-    myNdb.closeTransaction(myTrans)
+    #foo=myRecAttr.getValue()
+    myTrans.close()
       
 
-ndb.ndb_end(0)
+#ndb.ndb_end(0)
 after_t = time.time()
 print "NDBAPI time for %s: %s -- %s" % ( num_iter, after_t, before_t)
 print "\t %s" % (after_t - before_t)

=== modified file 'python/teststrwrite.py'
--- a/python/teststrwrite.py	2006-12-15 18:05:32 +0000
+++ b/python/teststrwrite.py	2007-07-26 00:19:55 +0000
@@ -1,13 +1,13 @@
 import sys,time,random,struct
-import ndb
+from mysql.cluster import ndbapi
 
 
 
 print "connecting to cluster\n"
 
-ndb.ndb_init()
+#ndb.ndb_init()
 
-connection = ndb.Ndb_cluster_connection()
+connection = ndbapi.NdbFactory.createNdbClusterConnection()
 
 if (connection.connect(5,3,1)):
 
@@ -15,12 +15,12 @@
     sys.exit(-1)
     
     
-if (connection.wait_until_ready(30,30)):
+if (connection.waitUntilReady(30,30)):
     print "Cluster was not ready within 30 secs."
     sys.exit(-1);
 
 
-myNdb = ndb.Ndb(connection,"sfndb" )
+myNdb = connection.createNdb( "sfndb" )
 
 if (myNdb.init(4) == -1):
     print myNdb.getNdbError()
@@ -42,7 +42,7 @@
 
 id=myNdb.getAutoIncrementValue("ContentObject",0)
 print id
-op.equal("id",id)
+op.equalUint64("id",id)
 
 # set value option three is col length+1 if param is string
 value = "hello"
@@ -58,7 +58,7 @@
     print myTransaction.getNdbError().message
     raise "crap"
 print "execute"
-myNdb.closeTransaction(myTransaction)
+myTransaction.close()
 print "close"
 ### Fetch ids using ndb
 

Thread
Rev 128: Fixed python example programs. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmergeMonty Taylor26 Jul