List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:October 28 2007 12:05am
Subject:Rev 212: Added NdbResultSet support to NdbEventOperation 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: 212
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Sun 2007-10-28 01:05:03 +0100
message:
  Added NdbResultSet support to NdbEventOperation
added:
  java/com/mysql/cluster/ndbj/NdbEventOperationResults.java
ndbeventoperationres-20071028000334-5d28pgcc7cw23w43-1
  java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java
ndbeventoperationres-20071028000322-kkhsnc2sdm53xm0q-1
modified:
  java/com/mysql/cluster/ndbj/Ndb.java ndb.java-20070517181935-98huwjarzuh25b30-2
  java/com/mysql/cluster/ndbj/NdbEventOperation.java
ndbeventoperation.ja-20070625182612-zsu6r68jih70efaq-1
  java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java
ndboperationresultsi-20071011074824-qn692jc6vcd81pxb-1
  java/com/mysql/cluster/ndbj/examples/TestEvent.java
testevent.java-20071026232217-5tigfbdmcudrnbbx-1
  java/ndbj.i                    ndbj.i-20070913223244-5938mztpztyn9sry-1
  swig/Ndb.i                     ndb.i-20070228021421-qkr4cbpxymyqdrf3-1
  swig/NdbClusterConnection.i    ndb_cluster_connecti-20070228021421-qkr4cbpxymyqdrf3-6
  swig/NdbEventOperation.i       ndbeventoperation.i-20070625162920-mfe5hei0d2x85mrk-1
=== added file 'java/com/mysql/cluster/ndbj/NdbEventOperationResults.java'
--- a/java/com/mysql/cluster/ndbj/NdbEventOperationResults.java	1970-01-01 00:00:00 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbEventOperationResults.java	2007-10-28 00:05:03 +0000
@@ -0,0 +1,11 @@
+package com.mysql.cluster.ndbj;
+
+public interface NdbEventOperationResults extends NdbOperationResults {
+
+
+	public abstract void getPreValue(String columnName) throws NdbApiException;
+	
+	public abstract void getPreBlob(String columnName) throws NdbApiException;
+	
+	public NdbResultSet preResultData();
+}

=== added file 'java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java'
--- a/java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java	1970-01-01 00:00:00
+0000
+++ b/java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java	2007-10-28 00:05:03
+0000
@@ -0,0 +1,51 @@
+package com.mysql.cluster.ndbj;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class NdbEventOperationResultsImpl extends NdbOperationResultsImpl implements
NdbEventOperationResults {
+
+	protected Map<String,NdbRecAttr> preResultSet;
+	protected Map<String,NdbBlob> preBlobResultSet;
+	protected NdbRecAttr realGetPreValue(long columnId) throws NdbApiException {
+		throw new RuntimeException("undefined class");
+	}
+	protected NdbRecAttr realGetPreValue(String columnName) throws NdbApiException { 
+		throw new RuntimeException("undefined class");
+	}
+	protected NdbBlob getPreBlobHandle(long columnId)
+	throws NdbApiException { 
+		throw new RuntimeException("undefined class");
+	}
+
+	protected NdbBlob getPreBlobHandle(String columnName)
+	throws NdbApiException{ 
+		throw new RuntimeException("undefined class");
+	}
+	
+	public NdbEventOperationResultsImpl() { 
+		super();
+		preResultSet = new HashMap<String, NdbRecAttr>();
+		preBlobResultSet = new HashMap<String,NdbBlob>();
+	}
+	/* (non-Javadoc)
+	 * @see com.mysql.cluster.ndbj.NdbEventOperationResults#getPreBlob(java.lang.String)
+	 */
+	public void getPreBlob(String columnName) throws NdbApiException {
+		NdbBlob theBlob = getPreBlobHandle(columnName);
+		preBlobResultSet.put(columnName,theBlob);
+	}
+
+	/* (non-Javadoc)
+	 * @see com.mysql.cluster.ndbj.NdbEventOperationResults#getPreValue(java.lang.String)
+	 */
+	public void getPreValue(String columnName) throws NdbApiException {
+
+		NdbRecAttr attr = realGetPreValue(columnName);
+		resultSet.put(columnName, attr);
+	}
+	
+	public NdbResultSet preResultData() { 
+		return NdbFactory.createNdbResultSet((NdbBaseOperation)this, preResultSet);
+	}
+}

=== modified file 'java/com/mysql/cluster/ndbj/Ndb.java'
--- a/java/com/mysql/cluster/ndbj/Ndb.java	2007-10-26 23:20:22 +0000
+++ b/java/com/mysql/cluster/ndbj/Ndb.java	2007-10-28 00:05:03 +0000
@@ -128,7 +128,7 @@
 
 	public int sendPollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup) throws
NdbApiException;
 
-	public NdbEventOperationImpl nextEvent() throws NdbApiException;
+	public NdbEventOperationImpl nextEvent();
 
 	public int pollEvents(int aMillisecondNumber) throws NdbApiException;
 

=== modified file 'java/com/mysql/cluster/ndbj/NdbEventOperation.java'
--- a/java/com/mysql/cluster/ndbj/NdbEventOperation.java	2007-10-01 19:55:09 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbEventOperation.java	2007-10-28 00:05:03 +0000
@@ -4,7 +4,7 @@
 
 import com.mysql.cluster.ndbj.NdbEvent.TableEvent;
 
-public interface NdbEventOperation extends NdbOperationResults {
+public interface NdbEventOperation extends NdbEventOperationResults {
 
 
 	/** 
@@ -19,13 +19,6 @@
 	 */
 	public abstract long getAnyValue();
 
-	/**
-	 * @param anAttrName
-	 * @return
-	 * @see com.mysql.cluster.ndbj.NdbEventOperation#getBlobHandle(java.lang.String)
-	 */
-	public abstract NdbBlob getBlobHandle(String anAttrName)
-			throws NdbApiException;
 
 	/**
 	 * @return
@@ -45,30 +38,6 @@
 	 */
 	public abstract BigInteger getLatestGCI();
 
-	/**
-	 * @param anAttrName
-	 * @return
-	 * @see com.mysql.cluster.ndbj.NdbEventOperation#getPreBlobHandle(java.lang.String)
-	 */
-	public abstract NdbBlob getPreBlobHandle(String anAttrName)
-			throws NdbApiException;
-
-	/**
-	 * @param anAttrName
-	 * @param aValue
-	 * @return
-	 * @see com.mysql.cluster.ndbj.NdbEventOperation#getPreValue(java.lang.String,
java.lang.String)
-	 */
-	public abstract NdbRecAttr getPreValue(String anAttrName, String aValue)
-			throws NdbApiException;
-
-	/**
-	 * @param anAttrName
-	 * @return
-	 * @see com.mysql.cluster.ndbj.NdbEventOperation#getPreValue(java.lang.String)
-	 */
-	public abstract NdbRecAttr getPreValue(String anAttrName)
-			throws NdbApiException;
 
 	/**
 	 * @return

=== modified file 'java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java'
--- a/java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java	2007-10-11 07:49:35 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java	2007-10-28 00:05:03 +0000
@@ -15,7 +15,6 @@
 	protected NdbRecAttr realGetValue(String columnName) throws NdbApiException { 
 		throw new RuntimeException("undefined class");
 	}
-	
 	public NdbBlob getBlobHandle(long columnId)
 	throws NdbApiException { 
 		throw new RuntimeException("undefined class");
@@ -31,6 +30,7 @@
 		resultSet = new HashMap<String, NdbRecAttr>();
 		blobResultSet = new HashMap<String,NdbBlob>();
 	}
+	
 	public void getValue(long columnId) throws NdbApiException {
 		
 		Long id = columnId-1;

=== modified file 'java/com/mysql/cluster/ndbj/examples/TestEvent.java'
--- a/java/com/mysql/cluster/ndbj/examples/TestEvent.java	2007-10-26 23:22:21 +0000
+++ b/java/com/mysql/cluster/ndbj/examples/TestEvent.java	2007-10-28 00:05:03 +0000
@@ -69,8 +69,6 @@
 
       NdbDictionary dict=myNdb.getDictionary();
       NdbTable table = dict.getTable(tableName);
-      NdbResultSet [] currRecAttr = new NdbResultSet[table.getNoOfColumns()];
-      NdbResultSet [] preRecAttr = new NdbResultSet[table.getNoOfColumns()];
 
       System.out.println("running tests:");
       
@@ -86,14 +84,12 @@
 	      System.out.println("Setting up column : " + name); 
 	      if(col==null)
 		  System.out.println("damn");
-	      currRecAttr[i] = eop.getValue(name);	      	      
-	      if(currRecAttr[i]==null)
-		  System.out.println("damn curr=null");
-	      preRecAttr[i] = eop.getPreValue(name);
-	      if(preRecAttr[i]==null)
-		  System.out.println("damn pre=null");
+	      eop.getValue(name);	      	      
+	      eop.getPreValue(name);
 	  }
-	      
+      NdbResultSet theResultSet = eop.resultData();
+      NdbResultSet preResultSet = eop.preResultData();
+      
       System.out.println("done");
 
       eop.execute();
@@ -128,21 +124,25 @@
 				  {
 				      System.out.println("Fook");
 				  }
-			      			    
+			      	
+			      NdbColumn colOne=table.getColumn(0);
+				  String nameOne=colOne.getName();
+
+			      NdbColumn colTwo=table.getColumn(0);
+				  String nameTwo=colTwo.getName();
 			      System.out.print("a_curr=" + 
-					       currRecAttr[0]. .getInt64());
+			    		  theResultSet.getInt(nameOne));
+			      System.out.print("a_pre=" + 
+			    		  preResultSet.getInt(nameOne));
 			      System.out.print("b_curr=" + 
-					       currRecAttr[1].getString());
-			     /* 
-				System.out.print(" b_curr=" + 
-				currRecAttr[1].getString());
-				System.out.print(" a_prev=" + 
-				preRecAttr[0].int32_value());
-			     */
+			    		  theResultSet.getString(nameTwo));
+			      System.out.print("b_pre=" + 
+			    		  preResultSet.getInt(nameTwo));
+	
 			      System.out.print("\n");
 			     
 
-			      String  x  = currRecAttr[1].getString();
+			      String  x  = theResultSet.getString(nameTwo);
 			      x=null;
 			      counter++;
 			  }

=== modified file 'java/ndbj.i'
--- a/java/ndbj.i	2007-10-24 04:03:28 +0000
+++ b/java/ndbj.i	2007-10-28 00:05:03 +0000
@@ -591,8 +591,12 @@
 %include "NdbIndexScanOperation.i"
 
 %javamethodmodifiers NdbEventOperation::getValue "protected";
+%javamethodmodifiers NdbEventOperation::getPreValue "protected";
+%javamethodmodifiers NdbEventOperation::getPreBlobHandle "protected";
+%rename(realGetPreValue) getPreValue(const char* anAttrName);
+%rename(realPreBlobHandle) getBlobHandle(const char* anAttrName);
 %typemap(javainterfaces) NdbEventOperation "NdbEventOperation";
-%typemap(javabase) NdbEventOperation "NdbOperationResultsImpl";
+%typemap(javabase) NdbEventOperation "NdbEventOperationResultsImpl";
 %typemap(jstype) NdbEventOperation::State "NdbEventOperation.State"
 %typemap(javaout) NdbEventOperation::State { 
         return
NdbEventOperation.State.swigToEnum(ndbjJNI.NdbEventOperationImpl_getState(swigCPtr,
this));

=== modified file 'swig/Ndb.i'
--- a/swig/Ndb.i	2007-10-24 02:07:06 +0000
+++ b/swig/Ndb.i	2007-10-28 00:05:03 +0000
@@ -39,7 +39,7 @@
 
   void closeTransaction(NdbTransaction*);
 
-
+  NdbEventOperation *nextEvent();
 
   %ndbexception("NdbApiException") { 
     $action
@@ -61,7 +61,6 @@
 	NDB_exception(NdbApiException,err.message);
       }
   }
-  NdbEventOperation *nextEvent();
   NdbTransaction* startTransaction(const NdbDictTable *table= 0,
                                    const char  *keyData = 0, 
                                    Uint32       keyLen = 0);

=== modified file 'swig/NdbClusterConnection.i'
--- a/swig/NdbClusterConnection.i	2007-10-23 23:47:41 +0000
+++ b/swig/NdbClusterConnection.i	2007-10-28 00:05:03 +0000
@@ -58,7 +58,7 @@
       NDB_exception(NdbClusterConnectionPermanentException,"Delay must be greater than or
equal to zero.");
     }
   }
-  int connect(int no_retries=0, int retry_delay_in_seconds=1, bool verbose=0);
+  int connect(int no_retries=0, int retry_delay_in_seconds=1, bool verbose=false);
 
   %ndbexception("NdbApiException") {
     $action

=== modified file 'swig/NdbEventOperation.i'
--- a/swig/NdbEventOperation.i	2007-09-30 02:06:41 +0000
+++ b/swig/NdbEventOperation.i	2007-10-28 00:05:03 +0000
@@ -114,7 +114,7 @@
   /**
    * See getValue().
    */
-  NdbRecAttr *getPreValue(const char *anAttrName, char *aValue = 0);
+//  NdbRecAttr *getPreValue(const char *anAttrName, char *aValue = 0);
   NdbBlob* getBlobHandle(const char *anAttrName);
   NdbBlob* getPreBlobHandle(const char *anAttrName);
 
@@ -165,6 +165,11 @@
     return self->getValue(anAttrName,NULL);
   }
 
+
+  NdbRecAttr* getPreValue(const char *anAttrName) { 
+    return self->getPreValue(anAttrName, NULL); 
+  }
+
   %ndbnoexception; 
 
 };

Thread
Rev 212: Added NdbResultSet support to NdbEventOperation in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmergeMonty Taylor28 Oct