List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:December 26 2007 10:16pm
Subject:Rev 391: Added NdbOperationFactory to aid in the creation of NdbOperations in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel

------------------------------------------------------------
revno: 391
revision-id:mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Wed 2007-12-26 16:16:21 -0600
message:
  Added NdbOperationFactory to aid in the creation of NdbOperations
added:
  java/com/mysql/cluster/ndbj/NdbOperationFactory.java
ndboperationfactory.-20071226221617-cmpu229u8hgoepto-2
  java/com/mysql/cluster/ndbj/NdbOperationFactoryImpl.java
ndboperationfactoryi-20071226221617-cmpu229u8hgoepto-1
=== added file 'java/com/mysql/cluster/ndbj/NdbOperationFactory.java'
--- a/java/com/mysql/cluster/ndbj/NdbOperationFactory.java	1970-01-01 00:00:00 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbOperationFactory.java	2007-12-26 22:16:21 +0000
@@ -0,0 +1,121 @@
+package com.mysql.cluster.ndbj;
+
+public interface NdbOperationFactory {
+
+	public abstract NdbOperation getNdbOperation(String tableName)
+			throws NdbApiException;
+
+	public abstract NdbOperation getNdbOperation(NdbTable aTable)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getSelectOperation(String tableName,
+			NdbOperation.LockMode theLockMode) throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getSelectOperation(NdbTable table,
+			NdbOperation.LockMode theLockMode) throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getUpdateOperation(String tableName)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getUpdateOperation(NdbTable table)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getInsertOperation(String tableName)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getInsertOperation(NdbTable table)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getDeleteOperation(String tableName)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbOperation getDeleteOperation(NdbTable table)
+			throws NdbApiException;
+
+	/**
+	 * Creates a NdbScanOperation (table scan operation) and adds it to the transaction.
+	 * Scans are inefficient, and, where possible, an index scan should be used instead of a
scan.
+     * @param tableName the table to be operated upon
+     * @param mode
+     * LM_Read Read with shared lock
+     * LM_Exclusive Read with exclusive lock
+     * LM_CommittedRead Ignore locks; read last committed
+     * @param scanFlag A ScanFlag value.
+     * @param parallel The number of fragments to scan in parallel; use 0 to require that
the maximum possible number be used.
+     * @param batch  The batch parameter specifies how many records will be returned to
the client from the server by the next
+     * NdbResultSet.next() method call.
+     * Use 0 to specify the maximum automatically.
+	 * @return an NdbScanOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbScanOperation getSelectScanOperation(String tableName,
+			NdbOperation.LockMode theLockMode) throws NdbApiException;
+
+	/**
+	 * Creates a NdbScanOperation (table scan operation) and adds it to the transaction.
+	 * Scans are inefficient, and, where possible, an index scan should be used instead of a
scan.
+	 * @param table the table to be operated upon
+     * @param mode
+     * LM_Read Read with shared lock
+     * LM_Exclusive Read with exclusive lock
+     * LM_CommittedRead Ignore locks; read last committed
+     * @param scanFlag A ScanFlag value.
+     * @param parallel The number of fragments to scan in parallel; use 0 to require that
the maximum possible number be used.
+     * @param batch  The batch parameter specifies how many records will be returned to
the client from the server by the next
+     * NdbResultSet.next() method call.
+     * Use 0 to specify the maximum automatically.
+	 * @return an NdbScanOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public abstract NdbScanOperation getSelectScanOperation(NdbTable table,
+			NdbOperation.LockMode theLockMode) throws NdbApiException;
+
+}
\ No newline at end of file

=== added file 'java/com/mysql/cluster/ndbj/NdbOperationFactoryImpl.java'
--- a/java/com/mysql/cluster/ndbj/NdbOperationFactoryImpl.java	1970-01-01 00:00:00 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbOperationFactoryImpl.java	2007-12-26 22:16:21 +0000
@@ -0,0 +1,175 @@
+package com.mysql.cluster.ndbj;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public abstract class NdbOperationFactoryImpl implements NdbOperationFactory {
+
+	private final Map<Long,NdbOperationImpl> createdOperations = new
HashMap<Long,NdbOperationImpl>();
+	
+	public abstract NdbOperation getNdbOperation(String tableName) throws NdbApiException;
+	public abstract NdbOperation getNdbOperation(NdbTable aTable) throws NdbApiException;
+	public abstract NdbScanOperation getNdbScanOperation(NdbTable aTable) throws
NdbApiException;
+	public abstract NdbScanOperation getNdbScanOperation(String tableName) throws
NdbApiException;
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getSelectOperation(String tableName, NdbOperation.LockMode
theLockMode) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(tableName);
+		theOperation.readTuple(theLockMode);
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getSelectOperation(NdbTable table, NdbOperation.LockMode
theLockMode) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(table);
+		theOperation.readTuple(theLockMode);
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getUpdateOperation(String tableName) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(tableName);
+		theOperation.updateTuple();
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getUpdateOperation(NdbTable table) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(table);
+		theOperation.updateTuple();
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getInsertOperation(String tableName) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(tableName);
+		theOperation.insertTuple();
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getInsertOperation(NdbTable table) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(table);
+		theOperation.insertTuple();
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getDeleteOperation(String tableName) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(tableName);
+		theOperation.deleteTuple();
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbOperation (primary key operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbOperation getDeleteOperation(NdbTable table) throws NdbApiException { 
+		NdbOperationImpl theOperation = (NdbOperationImpl)getNdbOperation(table);
+		theOperation.deleteTuple();
+		createdOperations.put(new Long(NdbOperationImpl.getCPtr(theOperation)), theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbScanOperation (table scan operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbScanOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbScanOperation getSelectScanOperation(String tableName, NdbOperation.LockMode
theLockMode) throws NdbApiException { 
+		NdbScanOperationImpl theOperation =
(NdbScanOperationImpl)getNdbScanOperation(tableName);
+		theOperation.readTuples(theLockMode);
+		createdOperations.put(new Long(NdbScanOperationImpl.getCPtr(theOperation)),
theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbScanOperation (table scan operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbScanOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbScanOperation getSelectScanOperation(NdbTable table, NdbOperation.LockMode
theLockMode) 
+	throws NdbApiException { 
+		NdbScanOperationImpl theOperation = (NdbScanOperationImpl)getNdbScanOperation(table);
+		theOperation.readTuples(theLockMode);
+		createdOperations.put(new Long(NdbScanOperationImpl.getCPtr(theOperation)),
theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbScanOperation (table scan operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbScanOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbScanOperation getSelectScanOperation(NdbTable table, NdbOperation.LockMode
theLockMode, long scanFlag, long parallel,
+            long batch)
+	throws NdbApiException {
+		NdbScanOperationImpl theOperation = (NdbScanOperationImpl)getNdbScanOperation(table);
+		theOperation.readTuples(theLockMode,scanFlag,parallel,batch);
+		createdOperations.put(new Long(NdbScanOperationImpl.getCPtr(theOperation)),
theOperation);
+		return theOperation;
+	}
+	
+	/**
+	 * Creates a NdbScanOperation (table scan operation) and adds it to the transaction.
+	 * @param aTable the table to be operated upon
+	 * @return an NdbScanOperation object
+	 * @throws NdbApiException if tableName is null or empty, the object has been closed, or
the Operation object could not be created
+	 */
+	public NdbScanOperation getSelectScanOperation(String tableName, NdbOperation.LockMode
theLockMode, long scanFlag, long parallel,
+            long batch)
+	throws NdbApiException {
+		NdbScanOperationImpl theOperation =
(NdbScanOperationImpl)getNdbScanOperation(tableName);
+		theOperation.readTuples(theLockMode,scanFlag,parallel,batch);
+		createdOperations.put(new Long(NdbScanOperationImpl.getCPtr(theOperation)),
theOperation);
+		return theOperation;
+	}
+}
\ No newline at end of file

Thread
Rev 391: Added NdbOperationFactory to aid in the creation of NdbOperations in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/develMonty Taylor26 Dec