Revision: 16974
http://sourceforge.net/p/datanucleus/code/16974
Author: andy_jefferson
Date: 2013-05-06 10:50:16 +0000 (Mon, 06 May 2013)
Log Message:
-----------
[NUCCORE-1038] Move "scoOperationQueue" to "operationQueue" so that it could contain PERSISTs, DELETEs, UPDATEs.
Modified Paths:
--------------
platform/core/trunk/META-INF/MANIFEST.MF
platform/core/trunk/src/java/org/datanucleus/ExecutionContext.java
platform/core/trunk/src/java/org/datanucleus/ExecutionContextImpl.java
platform/core/trunk/src/java/org/datanucleus/FlushNonReferential.java
platform/core/trunk/src/java/org/datanucleus/FlushOrdered.java
platform/core/trunk/src/java/org/datanucleus/FlushProcess.java
platform/core/trunk/src/java/org/datanucleus/Localisation.properties
platform/core/trunk/src/java/org/datanucleus/store/types/backed/ArrayList.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Collection.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashMap.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashSet.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Hashtable.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashMap.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashSet.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedList.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/List.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Map.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/PriorityQueue.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Properties.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Queue.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Set.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/SortedMap.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/SortedSet.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Stack.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/TreeMap.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/TreeSet.java
platform/core/trunk/src/java/org/datanucleus/store/types/backed/Vector.java
platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/FlushReferential.java
platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/mapping/java/CollectionMapping.java
platform/store.types.google.collections/trunk/src/java/org/datanucleus/store/types/backed/Multiset.java
Added Paths:
-----------
platform/core/trunk/src/java/org/datanucleus/flush/
platform/core/trunk/src/java/org/datanucleus/flush/CollectionAddOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/CollectionClearOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/CollectionRemoveOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/DeleteOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/ListAddAtOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/ListRemoveAtOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/ListSetOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/MapClearOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/MapPutOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/MapRemoveOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/Operation.java
platform/core/trunk/src/java/org/datanucleus/flush/OperationQueue.java
platform/core/trunk/src/java/org/datanucleus/flush/PersistOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/SCOOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/UpdateMemberOperation.java
platform/core/trunk/src/java/org/datanucleus/flush/package.html
Removed Paths:
-------------
platform/core/trunk/src/java/org/datanucleus/store/types/queued/
Modified: platform/core/trunk/META-INF/MANIFEST.MF
===================================================================
--- platform/core/trunk/META-INF/MANIFEST.MF 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/META-INF/MANIFEST.MF 2013-05-06 10:50:16 UTC (rev 16974)
@@ -12,6 +12,7 @@
org.datanucleus.enhancer;version="3.2.3",
org.datanucleus.enhancer.jdo;version="3.2.3",
org.datanucleus.exceptions;version="3.2.3",
+ org.datanucleus.flush;version="3.2.3",
org.datanucleus.identity;version="3.2.3",
org.datanucleus.management;version="3.2.3",
org.datanucleus.management.jmx;version="3.2.3",
@@ -46,7 +47,6 @@
org.datanucleus.store.types;version="3.2.3",
org.datanucleus.store.types.backed;version="3.2.3",
org.datanucleus.store.types.converters;version="3.2.3",
- org.datanucleus.store.types.queued;version="3.2.3",
org.datanucleus.store.types.simple;version="3.2.3",
org.datanucleus.store.valuegenerator;version="3.2.3",
org.datanucleus.transaction;version="3.2.3",
Modified: platform/core/trunk/src/java/org/datanucleus/ExecutionContext.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/ExecutionContext.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/ExecutionContext.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -27,6 +27,8 @@
import org.datanucleus.exceptions.NoPersistenceInformationException;
import org.datanucleus.exceptions.NucleusObjectNotFoundException;
import org.datanucleus.exceptions.NucleusOptimisticException;
+import org.datanucleus.flush.Operation;
+import org.datanucleus.flush.OperationQueue;
import org.datanucleus.management.ManagerStatistics;
import org.datanucleus.metadata.AbstractClassMetaData;
import org.datanucleus.metadata.AbstractMemberMetaData;
@@ -42,8 +44,6 @@
import org.datanucleus.store.query.Query;
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.TypeManager;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.SCOOperationQueue;
/**
* Context of execution for persistence operations.
@@ -812,24 +812,24 @@
void flushInternal(boolean flushToDatastore);
/**
- * Accessor for the SCO operation queue.
+ * Accessor for the operation queue.
* The queue can be null if
- * @return The operation queue for SCO collections/maps
+ * @return The operation queue (typically for collections/maps)
*/
- SCOOperationQueue getSCOOperationQueue();
+ OperationQueue getOperationQueue();
/**
- * Method to add a SCO backing store operation to the queue.
+ * Method to add an operation to the queue.
* @param oper The operation to add
*/
- void addSCOOperationToQueue(QueuedOperation oper);
+ void addOperationToQueue(Operation oper);
/**
* Method to flush all queued operations for the specified backing store (if any).
* @param backingStore The backing store
* @param op ObjectProvider
*/
- void flushSCOOperationsForBackingStore(Store backingStore, ObjectProvider op);
+ void flushOperationsForBackingStore(Store backingStore, ObjectProvider op);
/**
* Accessor for whether this context is multithreaded.
Modified: platform/core/trunk/src/java/org/datanucleus/ExecutionContextImpl.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/ExecutionContextImpl.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/ExecutionContextImpl.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -56,6 +56,8 @@
import org.datanucleus.exceptions.RollbackStateTransitionException;
import org.datanucleus.exceptions.TransactionActiveOnCloseException;
import org.datanucleus.exceptions.TransactionNotActiveException;
+import org.datanucleus.flush.Operation;
+import org.datanucleus.flush.OperationQueue;
import org.datanucleus.identity.DatastoreUniqueOID;
import org.datanucleus.identity.IdentityKeyTranslator;
import org.datanucleus.identity.IdentityReference;
@@ -88,8 +90,6 @@
import org.datanucleus.store.query.Query;
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.TypeManager;
-import org.datanucleus.store.types.queued.SCOOperationQueue;
-import org.datanucleus.store.types.queued.QueuedOperation;
import org.datanucleus.util.Localiser;
import org.datanucleus.util.NucleusLogger;
import org.datanucleus.util.StringUtils;
@@ -169,7 +169,7 @@
/** List of ObjectProviders for all current dirty objects made dirty by reachability. */
private List<ObjectProvider> indirectDirtyOPs = new ArrayList();
- private SCOOperationQueue scoOperationQueue = null;
+ private OperationQueue operationQueue = null;
private Set<ObjectProvider> nontxProcessedOPs = null;
@@ -4023,7 +4023,7 @@
// Retrieve the appropriate flush process, and execute it
FlushProcess flusher = getStoreManager().getFlushProcess();
List<NucleusOptimisticException> optimisticFailures =
- flusher.execute(this, dirtyOPs, indirectDirtyOPs, scoOperationQueue);
+ flusher.execute(this, dirtyOPs, indirectDirtyOPs, operationQueue);
if (flushToDatastore)
{
@@ -4049,33 +4049,33 @@
}
/* (non-Javadoc)
- * @see org.datanucleus.ExecutionContext#getSCOOperationQueue()
+ * @see org.datanucleus.ExecutionContext#getOperationQueue()
*/
- public SCOOperationQueue getSCOOperationQueue()
+ public OperationQueue getOperationQueue()
{
- return scoOperationQueue;
+ return operationQueue;
}
/* (non-Javadoc)
- * @see org.datanucleus.ExecutionContext#addSCOOperationToQueue(org.datanucleus.store.types.queued.QueuedOperation)
+ * @see org.datanucleus.ExecutionContext#addOperationToQueue(org.datanucleus.flush.Operation)
*/
- public void addSCOOperationToQueue(QueuedOperation oper)
+ public void addOperationToQueue(Operation oper)
{
- if (scoOperationQueue == null)
+ if (operationQueue == null)
{
- scoOperationQueue = new SCOOperationQueue();
+ operationQueue = new OperationQueue();
}
- scoOperationQueue.enqueue(oper);
+ operationQueue.enqueue(oper);
}
/* (non-Javadoc)
* @see org.datanucleus.ExecutionContext#flushSCOOperationsForBackingStore(org.datanucleus.store.scostore.Store, org.datanucleus.state.ObjectProvider)
*/
- public void flushSCOOperationsForBackingStore(Store backingStore, ObjectProvider op)
+ public void flushOperationsForBackingStore(Store backingStore, ObjectProvider op)
{
- if (scoOperationQueue != null)
+ if (operationQueue != null)
{
- scoOperationQueue.performAll(backingStore, op);
+ operationQueue.performAll(backingStore, op);
}
}
@@ -4780,13 +4780,13 @@
{
txCachedFieldsToUpdateById.clear();
}
- if (scoOperationQueue != null)
+ if (operationQueue != null)
{
- if (!scoOperationQueue.getOperations().isEmpty())
+ if (!operationQueue.getOperations().isEmpty())
{
NucleusLogger.PERSISTENCE.warn("Queue of operations for SCO fields is not empty! Ignoring unprocessed operations. Generate a testcase and report this");
}
- scoOperationQueue.clear();
+ operationQueue.clear();
}
attachDetachObjectReferenceMap = null;
}
Modified: platform/core/trunk/src/java/org/datanucleus/FlushNonReferential.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/FlushNonReferential.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/FlushNonReferential.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -24,9 +24,9 @@
import java.util.Set;
import org.datanucleus.exceptions.NucleusOptimisticException;
+import org.datanucleus.flush.OperationQueue;
import org.datanucleus.state.ObjectProvider;
import org.datanucleus.store.StorePersistenceHandler;
-import org.datanucleus.store.types.queued.SCOOperationQueue;
import org.datanucleus.util.NucleusLogger;
/**
@@ -36,10 +36,10 @@
public class FlushNonReferential implements FlushProcess
{
/* (non-Javadoc)
- * @see org.datanucleus.FlushProcess#execute(org.datanucleus.ExecutionContext, java.util.List, java.util.List, org.datanucleus.store.types.queued.SCOOperationQueue)
+ * @see org.datanucleus.FlushProcess#execute(org.datanucleus.ExecutionContext, java.util.List, java.util.List, org.datanucleus.flush.OperationQueue)
*/
public List<NucleusOptimisticException> execute(ExecutionContext ec, List<ObjectProvider> primaryOPs,
- List<ObjectProvider> secondaryOPs, SCOOperationQueue scoQueue)
+ List<ObjectProvider> secondaryOPs, OperationQueue opQueue)
{
// Note that scoOperationQueue is not processed here since all datastores this is used with don't use backed SCOs
Modified: platform/core/trunk/src/java/org/datanucleus/FlushOrdered.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/FlushOrdered.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/FlushOrdered.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -25,8 +25,8 @@
import org.datanucleus.FlushProcess;
import org.datanucleus.exceptions.NucleusOptimisticException;
+import org.datanucleus.flush.OperationQueue;
import org.datanucleus.state.ObjectProvider;
-import org.datanucleus.store.types.queued.SCOOperationQueue;
import org.datanucleus.util.NucleusLogger;
/**
@@ -36,10 +36,10 @@
public class FlushOrdered implements FlushProcess
{
/* (non-Javadoc)
- * @see org.datanucleus.FlushProcess#execute(org.datanucleus.ExecutionContext, java.util.List, java.util.List, org.datanucleus.store.types.queued.SCOOperationQueue)
+ * @see org.datanucleus.FlushProcess#execute(org.datanucleus.ExecutionContext, java.util.List, java.util.List, org.datanucleus.flush.OperationQueue)
*/
public List<NucleusOptimisticException> execute(ExecutionContext ec, List<ObjectProvider> primaryOPs,
- List<ObjectProvider> secondaryOPs, SCOOperationQueue scoQueue)
+ List<ObjectProvider> secondaryOPs, OperationQueue opQueue)
{
// Note that scoOperationQueue is not processed directly here, but instead will be processed
// via callbacks from the persistence of other objects
Modified: platform/core/trunk/src/java/org/datanucleus/FlushProcess.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/FlushProcess.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/FlushProcess.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -20,8 +20,8 @@
import java.util.List;
import org.datanucleus.exceptions.NucleusOptimisticException;
+import org.datanucleus.flush.OperationQueue;
import org.datanucleus.state.ObjectProvider;
-import org.datanucleus.store.types.queued.SCOOperationQueue;
import org.datanucleus.util.Localiser;
/**
@@ -39,9 +39,9 @@
* @param ec ExecutionContext
* @param primaryOPs ObjectProviders that were made dirty by direct API calls. Cleared during this method
* @param secondaryOPs ObjectProviders that were made dirty by reachability. Cleared during this method
- * @param scoQueue Queue of SCO operations
+ * @param opQueue Queue of operations
* @return Any optimistic exceptions during the deletes/inserts/updates
*/
List<NucleusOptimisticException> execute(ExecutionContext ec,
- List<ObjectProvider> primaryOPs, List<ObjectProvider> secondaryOPs, SCOOperationQueue scoQueue);
+ List<ObjectProvider> primaryOPs, List<ObjectProvider> secondaryOPs, OperationQueue opQueue);
}
\ No newline at end of file
Modified: platform/core/trunk/src/java/org/datanucleus/Localisation.properties
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/Localisation.properties 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/Localisation.properties 2013-05-06 10:50:16 UTC (rev 16974)
@@ -492,7 +492,7 @@
023002=SCO Collection/Map is not queryable since it is not currently owned by any first-class object.
023003=Created SCO wrapper for object "{0}" field "{1}" with {2} entries, using options="{3}"
023004=Object "{0}" field "{1}" is replaced by a SCO wrapper of type "{2}" {3}
-023005=Object "{0}" field "{1}" flushing changes to SCO wrapper to the datastore
+023005=Object "{0}" field "{1}" flushing changes to the datastore
023006=Object "{0}" field "{1}" loading contents to SCO wrapper from the datastore
023007=Object "{0}" field "{1}" is having its SCO wrapper initialised with a container with {2} values
023008=Object "{0}" field "{1}" is having its SCO wrapper updated with a container with {2} values
Added: platform/core/trunk/src/java/org/datanucleus/flush/CollectionAddOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/CollectionAddOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/CollectionAddOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,76 @@
+/**********************************************************************
+Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.CollectionStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Add operation for a collection.
+ */
+public class CollectionAddOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final CollectionStore store;
+
+ /** The value to add. */
+ private final Object value;
+
+ public CollectionAddOperation(ObjectProvider op, CollectionStore store, Object value)
+ {
+ this.op = op;
+ this.store = store;
+ this.value = value;
+ }
+
+ /**
+ * Accessor for the value being added.
+ * @return Value being added
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Perform the add(Object) operation to the backing store.
+ */
+ public void perform()
+ {
+ store.add(op, value, -1);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "COLLECTION ADD : " + op + " field=" + store.getOwnerMemberMetaData().getName();
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/CollectionClearOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/CollectionClearOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/CollectionClearOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,63 @@
+/**********************************************************************
+Copyright (c) 2010 Peter Dettman and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.CollectionStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Clear operation for a collection.
+ */
+public class CollectionClearOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final CollectionStore store;
+
+ public CollectionClearOperation(ObjectProvider op, CollectionStore store)
+ {
+ this.op = op;
+ this.store = store;
+ }
+
+ /**
+ * Perform the clear() operation on the specified backing store.
+ */
+ public void perform()
+ {
+ store.clear(op);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "COLLECTION CLEAR : " + op + " field=" + store.getOwnerMemberMetaData().getName();
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/CollectionRemoveOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/CollectionRemoveOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/CollectionRemoveOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,80 @@
+/**********************************************************************
+Copyright (c) 2010 Peter Dettman and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.CollectionStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Remove operation for a collection.
+ */
+public class CollectionRemoveOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final CollectionStore store;
+
+ /** The value to remove. */
+ private final Object value;
+
+ /** Whether to allow cascade-delete checks. */
+ private final boolean allowCascadeDelete;
+
+ public CollectionRemoveOperation(ObjectProvider op, CollectionStore store, Object value, boolean allowCascadeDelete)
+ {
+ this.op = op;
+ this.store = store;
+ this.value = value;
+ this.allowCascadeDelete = allowCascadeDelete;
+ }
+
+ /**
+ * Accessor for the value being removed.
+ * @return Value being removed
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Perform the remove(Object) operation on the specified container.
+ */
+ public void perform()
+ {
+ store.remove(op, value, -1, allowCascadeDelete);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "COLLECTION REMOVE : " + op + " field=" + store.getOwnerMemberMetaData().getName();
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/DeleteOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/DeleteOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/DeleteOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,54 @@
+/**********************************************************************
+Copyright (c) 2013 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+
+/**
+ * Flush operation for a delete of the specified object.
+ */
+public class DeleteOperation implements Operation
+{
+ ObjectProvider op;
+
+ public DeleteOperation(ObjectProvider op)
+ {
+ this.op = op;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#perform()
+ */
+ public void perform()
+ {
+ // TODO Call delete of this object. Currently handled by FlushProcess
+ }
+
+ public String toString()
+ {
+ return "DELETE : " + op;
+ }
+}
Added: platform/core/trunk/src/java/org/datanucleus/flush/ListAddAtOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/ListAddAtOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/ListAddAtOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,71 @@
+/**********************************************************************
+Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.ListStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Add operation at a position for a list.
+ */
+public class ListAddAtOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final ListStore store;
+
+ /** The value to add. */
+ private final Object value;
+
+ /** Index to add the object at. */
+ private final int index;
+
+ public ListAddAtOperation(ObjectProvider op, ListStore store, int index, Object value)
+ {
+ this.op = op;
+ this.store = store;
+ this.index = index;
+ this.value = value;
+ }
+
+ /**
+ * Perform the add(int, Object) operation on the specified list.
+ */
+ public void perform()
+ {
+ store.add(op, value, index, -1);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "COLLECTION ADD-AT : " + op + " field=" + store.getOwnerMemberMetaData().getName() + " index=" + index;
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/ListRemoveAtOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/ListRemoveAtOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/ListRemoveAtOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,67 @@
+/**********************************************************************
+Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.ListStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Remove operation for a list at a particular index.
+ */
+public class ListRemoveAtOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final ListStore store;
+
+ /** The index to remove. */
+ private final int index;
+
+ public ListRemoveAtOperation(ObjectProvider op, ListStore store, int index)
+ {
+ this.op = op;
+ this.store = store;
+ this.index = index;
+ }
+
+ /**
+ * Perform the remove(int) operation on the specified container.
+ */
+ public void perform()
+ {
+ store.remove(op, index, -1);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "COLLECTION REMOVE-AT : " + op + " field=" + store.getOwnerMemberMetaData().getName() + " index=" + index;
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/ListSetOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/ListSetOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/ListSetOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,75 @@
+/**********************************************************************
+Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.ListStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Set operation for a list.
+ */
+public class ListSetOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final ListStore store;
+
+ /** The position to set the value at. */
+ private final int index;
+
+ /** The value to set. */
+ private final Object value;
+
+ /** Whether to allow cascade-delete checks. */
+ boolean allowCascadeDelete = true;
+
+ public ListSetOperation(ObjectProvider op, ListStore store, int index, Object value, boolean allowCascadeDelete)
+ {
+ this.op = op;
+ this.store = store;
+ this.index = index;
+ this.value = value;
+ this.allowCascadeDelete = allowCascadeDelete;
+ }
+
+ /**
+ * Perform the set(int, Object) operation to the backing store.
+ */
+ public void perform()
+ {
+ store.set(op, index, value, allowCascadeDelete);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "COLLECTION SET : " + op + " field=" + store.getOwnerMemberMetaData().getName() + " index=" + index;
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/MapClearOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/MapClearOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/MapClearOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,63 @@
+/**********************************************************************
+Copyright (c) 2010 Peter Dettman and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.MapStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Clear operation for a map.
+ */
+public class MapClearOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final MapStore store;
+
+ public MapClearOperation(ObjectProvider op, MapStore store)
+ {
+ this.op = op;
+ this.store = store;
+ }
+
+ /**
+ * Perform the clear() operation on the specified backing store.
+ */
+ public void perform()
+ {
+ store.clear(op);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "MAP CLEAR : " + op + " field=" + store.getOwnerMemberMetaData().getName();
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/MapPutOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/MapPutOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/MapPutOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,89 @@
+/**********************************************************************
+Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.MapStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Put operation for a map.
+ */
+public class MapPutOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final MapStore store;
+
+ /** The key to add. */
+ private final Object key;
+
+ /** The value to add. */
+ private final Object value;
+
+ public MapPutOperation(ObjectProvider op, MapStore store, Object key, Object value)
+ {
+ this.op = op;
+ this.store = store;
+ this.key = key;
+ this.value = value;
+ }
+
+ /**
+ * Accessor for the key being put.
+ * @return Key being put
+ */
+ public Object getKey()
+ {
+ return key;
+ }
+
+ /**
+ * Accessor for the value being put against this key.
+ * @return Value being put against the key
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Perform the put(Object, Object) operation to the backing store.
+ */
+ public void perform()
+ {
+ store.put(op, key, value);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "MAP PUT : " + op + " field=" + store.getOwnerMemberMetaData().getName();
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/MapRemoveOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/MapRemoveOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/MapRemoveOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,76 @@
+/**********************************************************************
+Copyright (c) 2010 Peter Dettman and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.MapStore;
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * Remove operation for a map.
+ */
+public class MapRemoveOperation implements SCOOperation
+{
+ final ObjectProvider op;
+ final MapStore store;
+
+ /** The value to remove. */
+ private final Object value;
+
+ public MapRemoveOperation(ObjectProvider op, MapStore store, Object value)
+ {
+ this.op = op;
+ this.store = store;
+ this.value = value;
+ }
+
+ /**
+ * Accessor for the value being removed.
+ * @return Value being removed
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Perform the remove(Object) operation on the specified container.
+ */
+ public void perform()
+ {
+ store.remove(op, value);
+ }
+
+ public Store getStore()
+ {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ public String toString()
+ {
+ return "MAP REMOVE : " + op + " field=" + store.getOwnerMemberMetaData().getName();
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/Operation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/Operation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/Operation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,37 @@
+/**********************************************************************
+Copyright (c) 2013 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+
+/**
+ * Interface for an operation to be flushed.
+ */
+public interface Operation
+{
+ /**
+ * Accessor for the ObjectProvider of the object that this operation is performed on.
+ * @return The ObjectProvider
+ */
+ ObjectProvider getObjectProvider();
+
+ /**
+ * Method to perform the operation.
+ */
+ void perform();
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/OperationQueue.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/OperationQueue.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/OperationQueue.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,298 @@
+/**********************************************************************
+Copyright (c) 2010 Peter Dettman and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+2013 Andy Jefferson - converted to general purpose queue for all operations
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.datanucleus.state.ObjectProvider;
+import org.datanucleus.store.scostore.CollectionStore;
+import org.datanucleus.store.scostore.ListStore;
+import org.datanucleus.store.scostore.MapStore;
+import org.datanucleus.store.scostore.Store;
+import org.datanucleus.util.Localiser;
+import org.datanucleus.util.NucleusLogger;
+import org.datanucleus.util.StringUtils;
+
+/**
+ * Queue of operations to be performed when operating in MANUAL FlushMode.
+ * This queue will typically contain operations on second class objects, such as Collections or Maps.
+ * They are queued in the order they are invoked by the user.
+ * The queue will contain all operations to be performed for an ExecutionContext. There are two methods for
+ * processing them, one processing all (for use in the future when we support that mode in full), and one
+ * that processes all for a particular SCO (backing store).
+ * TODO Pass operations for PERSIST, DELETE, UPDATE through here too so they can be processed more efficiently?
+ */
+public class OperationQueue
+{
+ protected static final Localiser LOCALISER = Localiser.getInstance("org.datanucleus.Localisation",
+ org.datanucleus.ClassConstants.NUCLEUS_CONTEXT_LOADER);
+
+ protected List<Operation> queuedOperations = new ArrayList<Operation>();
+
+ /**
+ * Method to add the specified operation to the operation queue.
+ * @param oper Operation
+ */
+ public synchronized void enqueue(Operation oper)
+ {
+ queuedOperations.add(oper);
+ }
+
+ /**
+ * Convenience method to log the current operation queue.
+ */
+ public synchronized void log()
+ {
+ NucleusLogger.GENERAL.debug(">> OperationQueue :");
+ for (Operation op : queuedOperations)
+ {
+ NucleusLogger.GENERAL.debug(">> " + op);
+ }
+ }
+
+ public void clear()
+ {
+ queuedOperations.clear();
+ }
+
+ /**
+ * Method to provide access to inspect the queued operations. The returned list is unmodifiable.
+ * @return The queued operations
+ */
+ public List<Operation> getOperations()
+ {
+ return Collections.unmodifiableList(queuedOperations);
+ }
+
+ /**
+ * Method to perform all operations queued.
+ * Those operations are then removed from the queue.
+ */
+ public synchronized void performAll()
+ {
+ for (Operation op : queuedOperations)
+ {
+ op.perform();
+ }
+ queuedOperations.clear();
+ }
+
+ /**
+ * Method to perform all operations queued for the specified ObjectProvider and backing store.
+ * Those operations are then removed from the queue.
+ * @param store The backing store
+ * @param op ObjectProvider
+ */
+ public synchronized void performAll(Store store, ObjectProvider op)
+ {
+ if (NucleusLogger.PERSISTENCE.isDebugEnabled())
+ {
+ NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("023005",
+ op.getObjectAsPrintable(), store.getOwnerMemberMetaData().getFullFieldName()));
+ }
+
+ // Extract those operations for the specified backing store
+ List<Operation> flushOperations = new ArrayList<Operation>();
+ ListIterator<Operation> operIter = queuedOperations.listIterator();
+ while (operIter.hasNext())
+ {
+ Operation oper = operIter.next();
+ if (oper instanceof SCOOperation && ((SCOOperation)oper).getStore() == store)
+ {
+ flushOperations.add(oper);
+ operIter.remove();
+ }
+ }
+
+ ListIterator<Operation> flushOperIter = flushOperations.listIterator();
+ while (flushOperIter.hasNext())
+ {
+ Operation oper = flushOperIter.next();
+ if (store instanceof CollectionStore)
+ {
+ if (!(store instanceof ListStore))
+ {
+ if (isAddFollowedByRemoveOnSameSCO(store, op, oper, flushOperIter))
+ {
+ // add+remove of the same element - ignore this and the next one
+ flushOperIter.next();
+ }
+ else if (isRemoveFollowedByAddOnSameSCO(store, op, oper, flushOperIter))
+ {
+ // remove+add of the same element - ignore this and the next one
+ flushOperIter.next();
+ }
+ else
+ {
+ oper.perform();
+ }
+ }
+ else
+ {
+ oper.perform();
+ }
+ }
+ else if (store instanceof MapStore)
+ {
+ if (isPutFollowedByRemoveOnSameSCO(store, op, oper, flushOperIter))
+ {
+ // put+remove of the same key - ignore this and the next one
+ flushOperIter.next();
+ }
+ else
+ {
+ oper.perform();
+ }
+ }
+ else
+ {
+ oper.perform();
+ }
+ }
+ }
+
+ /**
+ * Convenience optimisation checker to return if the current operation is ADD of an element that is
+ * immediately REMOVED. Always leaves the iterator at the same position as starting
+ * @param store The backing store
+ * @param op The object provider
+ * @param currentOper The current operation
+ * @param listIter The iterator of operations
+ * @return Whether this is an ADD that has a REMOVE of the same element immediately after
+ */
+ protected static boolean isAddFollowedByRemoveOnSameSCO(Store store, ObjectProvider op,
+ Operation currentOper, ListIterator<Operation> listIter)
+ {
+ if (CollectionAddOperation.class.isInstance(currentOper))
+ {
+ // Optimisation to check that we aren't doing add+remove of the same element consecutively
+ boolean addThenRemove = false;
+ if (listIter.hasNext())
+ {
+ // Get next element
+ Operation operNext = listIter.next();
+ if (CollectionRemoveOperation.class.isInstance(operNext))
+ {
+ Object value = CollectionAddOperation.class.cast(currentOper).getValue();
+ if (value == CollectionRemoveOperation.class.cast(operNext).getValue())
+ {
+ addThenRemove = true;
+ NucleusLogger.PERSISTENCE.info(
+ "Member " + store.getOwnerMemberMetaData().getFullFieldName() +
+ " of " + StringUtils.toJVMIDString(op.getObject()) +
+ " had an add then a remove of element " +
+ StringUtils.toJVMIDString(value) + " - operations ignored");
+ }
+ }
+
+ // Go back
+ listIter.previous();
+ }
+ return addThenRemove;
+ }
+ return false;
+ }
+
+ /**
+ * Convenience optimisation checker to return if the current operation is REMOVE of an element that is
+ * immediately ADDed. Always leaves the iterator at the same position as starting
+ * @param store The backing store
+ * @param op The object provider
+ * @param currentOper The current operation
+ * @param listIter The iterator of operations
+ * @return Whether this is a REMOVE that has an ADD of the same element immediately after
+ */
+ protected static boolean isRemoveFollowedByAddOnSameSCO(Store store, ObjectProvider op,
+ Operation currentOper, ListIterator<Operation> listIter)
+ {
+ if (CollectionRemoveOperation.class.isInstance(currentOper))
+ {
+ // Optimisation to check that we aren't doing add+remove of the same element consecutively
+ boolean removeThenAdd = false;
+ if (listIter.hasNext())
+ {
+ // Get next element
+ Operation opNext = listIter.next();
+ if (CollectionAddOperation.class.isInstance(opNext))
+ {
+ Object value = CollectionRemoveOperation.class.cast(currentOper).getValue();
+ if (value == CollectionAddOperation.class.cast(opNext).getValue())
+ {
+ removeThenAdd = true;
+ NucleusLogger.PERSISTENCE.info(
+ "Member" + store.getOwnerMemberMetaData().getFullFieldName() +
+ " of " + StringUtils.toJVMIDString(op.getObject()) +
+ " had a remove then add of element " +
+ StringUtils.toJVMIDString(value) + " - operations ignored");
+ }
+ }
+
+ // Go back
+ listIter.previous();
+ }
+ return removeThenAdd;
+ }
+ return false;
+ }
+
+ /**
+ * Convenience optimisation checker to return if the current operation is PUT of a key that is
+ * immediately REMOVED. Always leaves the iterator at the same position as starting
+ * @param store The backing store
+ * @param op The object provider
+ * @param currentOper The current operation
+ * @param listIter The iterator of operations
+ * @return Whether this is a PUT that has a REMOVE of the same key immediately after
+ */
+ protected static boolean isPutFollowedByRemoveOnSameSCO(Store store, ObjectProvider op,
+ Operation currentOper, ListIterator<Operation> listIter)
+ {
+ if (MapPutOperation.class.isInstance(currentOper))
+ {
+ // Optimisation to check that we aren't doing put+remove of the same key consecutively
+ boolean putThenRemove = false;
+ if (listIter.hasNext())
+ {
+ // Get next element
+ Operation operNext = listIter.next();
+ if (MapRemoveOperation.class.isInstance(operNext))
+ {
+ Object key = MapPutOperation.class.cast(currentOper).getKey();
+ if (key == MapRemoveOperation.class.cast(operNext).getValue())
+ {
+ putThenRemove = true;
+ NucleusLogger.PERSISTENCE.info(
+ "Member " + store.getOwnerMemberMetaData().getFullFieldName() +
+ " of " + StringUtils.toJVMIDString(op.getObject()) +
+ " had a put then a remove of key " +
+ StringUtils.toJVMIDString(key) + " - operations ignored");
+ }
+ }
+
+ // Go back
+ listIter.previous();
+ }
+ return putThenRemove;
+ }
+ return false;
+ }
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/PersistOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/PersistOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/PersistOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,54 @@
+/**********************************************************************
+Copyright (c) 2013 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+
+/**
+ * Flush operation for a persist of the specified object.
+ */
+public class PersistOperation implements Operation
+{
+ ObjectProvider op;
+
+ public PersistOperation(ObjectProvider op)
+ {
+ this.op = op;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#perform()
+ */
+ public void perform()
+ {
+ // TODO Call persist of this object. Currently handled by FlushProcess
+ }
+
+ public String toString()
+ {
+ return "PERSIST : " + op;
+ }
+}
Added: platform/core/trunk/src/java/org/datanucleus/flush/SCOOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/SCOOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/SCOOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,32 @@
+/**********************************************************************
+Copyright (c) 2013 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.store.scostore.Store;
+
+/**
+ * (Queued) operation performed on a backing store.
+ */
+public interface SCOOperation extends Operation
+{
+ /**
+ * Accessor for the backing store for this operation.
+ * @return The backing store
+ */
+ Store getStore();
+}
\ No newline at end of file
Added: platform/core/trunk/src/java/org/datanucleus/flush/UpdateMemberOperation.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/UpdateMemberOperation.java (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/UpdateMemberOperation.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,58 @@
+/**********************************************************************
+Copyright (c) 2013 Andy Jefferson and others. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+ ...
+**********************************************************************/
+package org.datanucleus.flush;
+
+import org.datanucleus.state.ObjectProvider;
+
+/**
+ * Flush operation for an update of the value of a member of the specified object.
+ */
+public class UpdateMemberOperation implements Operation
+{
+ ObjectProvider op;
+ int fieldNumber;
+ Object newValue;
+
+ public UpdateMemberOperation(ObjectProvider op, int fieldNum, Object newVal)
+ {
+ this.op = op;
+ this.fieldNumber = fieldNum;
+ this.newValue = newVal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#getObjectProvider()
+ */
+ public ObjectProvider getObjectProvider()
+ {
+ return op;
+ }
+
+ /* (non-Javadoc)
+ * @see org.datanucleus.flush.Operation#perform()
+ */
+ public void perform()
+ {
+ // TODO Call update of the field of this object. Currently handled by FlushProcess
+ }
+
+ public String toString()
+ {
+ return "UPDATE : " + op + " field=" + op.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber).getName();
+ }
+}
Added: platform/core/trunk/src/java/org/datanucleus/flush/package.html
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/flush/package.html (rev 0)
+++ platform/core/trunk/src/java/org/datanucleus/flush/package.html 2013-05-06 10:50:16 UTC (rev 16974)
@@ -0,0 +1,7 @@
+<body>
+ <p>
+ This package provides classes managing the flush process when using MANUAL flush. In this mode
+ all operations are queued up and then flushed either by a user call to flush() or by commit() of
+ the transaction.
+ </p>
+</body>
\ No newline at end of file
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/ArrayList.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/ArrayList.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/ArrayList.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -25,6 +25,12 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
import org.datanucleus.exceptions.NucleusDataStoreException;
+import org.datanucleus.flush.ListAddAtOperation;
+import org.datanucleus.flush.CollectionAddOperation;
+import org.datanucleus.flush.CollectionClearOperation;
+import org.datanucleus.flush.ListRemoveAtOperation;
+import org.datanucleus.flush.CollectionRemoveOperation;
+import org.datanucleus.flush.ListSetOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -33,13 +39,6 @@
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOListIterator;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.AddAtOperation;
-import org.datanucleus.store.types.queued.AddOperation;
-import org.datanucleus.store.types.queued.ClearCollectionOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveAtOperation;
-import org.datanucleus.store.types.queued.RemoveCollectionOperation;
-import org.datanucleus.store.types.queued.SetOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -153,7 +152,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -184,7 +183,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -202,7 +201,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -311,15 +310,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded element in this list.
* @param element The element
* @param fieldNumber Number of field in the element
@@ -660,7 +650,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddAtOperation(ownerOP, backingStore, index, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListAddAtOperation(ownerOP, backingStore, index, element));
}
else
{
@@ -710,7 +700,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
else
{
@@ -758,7 +748,7 @@
{
for (Object element : elements)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -809,7 +799,7 @@
int pos = index;
for (Object element : elements)
{
- addQueuedOperation(new AddAtOperation(ownerOP, backingStore, pos++, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListAddAtOperation(ownerOP, backingStore, pos++, element));
}
}
else
@@ -851,7 +841,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -901,7 +891,7 @@
backingSuccess = contained;
if (backingSuccess)
{
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, allowCascadeDelete));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, allowCascadeDelete));
}
}
else
@@ -949,7 +939,7 @@
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
backingObject = delegateObject;
- addQueuedOperation(new RemoveAtOperation(ownerOP, backingStore, index));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, backingStore, index));
}
else
{
@@ -1012,7 +1002,7 @@
for (Object element : contained)
{
backingSuccess = true;
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, true));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, true));
}
}
else
@@ -1107,7 +1097,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new SetOperation(ownerOP, backingStore, index, element, allowDependentField));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListSetOperation(ownerOP, backingStore, index, element, allowDependentField));
}
else
{
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/Collection.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/Collection.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/Collection.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -29,6 +29,9 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
import org.datanucleus.exceptions.NucleusDataStoreException;
+import org.datanucleus.flush.CollectionAddOperation;
+import org.datanucleus.flush.CollectionClearOperation;
+import org.datanucleus.flush.CollectionRemoveOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -38,10 +41,6 @@
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOCollectionIterator;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.AddOperation;
-import org.datanucleus.store.types.queued.ClearCollectionOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveCollectionOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -181,7 +180,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -258,7 +257,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -285,7 +284,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -395,15 +394,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded element in this collection.
* @param element The element
* @param fieldNumber Number of field in the element
@@ -669,7 +659,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
else
{
@@ -727,7 +717,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -769,7 +759,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -823,7 +813,7 @@
backingSuccess = contained;
if (backingSuccess)
{
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, allowCascadeDelete));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, allowCascadeDelete));
}
}
else
@@ -898,7 +888,7 @@
for (Object element : contained)
{
backingSuccess = true;
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, true));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, true));
}
}
else
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashMap.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashMap.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashMap.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -25,6 +25,9 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
+import org.datanucleus.flush.MapClearOperation;
+import org.datanucleus.flush.MapPutOperation;
+import org.datanucleus.flush.MapRemoveOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -32,10 +35,6 @@
import org.datanucleus.store.scostore.MapStore;
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.ClearMapOperation;
-import org.datanucleus.store.types.queued.PutOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveMapOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -150,7 +149,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -175,7 +174,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearMapOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapClearOperation(ownerOP, backingStore));
}
else
{
@@ -196,7 +195,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -293,15 +292,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded key in this map.
* @param key The key
* @param fieldNumber Number of field in the key
@@ -566,7 +556,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearMapOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapClearOperation(ownerOP, backingStore));
}
else
{
@@ -614,7 +604,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new PutOperation(ownerOP, backingStore, key, value));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, key, value));
}
else
{
@@ -660,7 +650,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -697,7 +687,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new RemoveMapOperation(ownerOP, backingStore, key));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapRemoveOperation(ownerOP, backingStore, key));
removed = delegateRemoved;
}
else
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashSet.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashSet.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/HashSet.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -29,6 +29,9 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
import org.datanucleus.exceptions.NucleusDataStoreException;
+import org.datanucleus.flush.CollectionAddOperation;
+import org.datanucleus.flush.CollectionClearOperation;
+import org.datanucleus.flush.CollectionRemoveOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -38,10 +41,6 @@
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOCollectionIterator;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.AddOperation;
-import org.datanucleus.store.types.queued.ClearCollectionOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveCollectionOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -165,7 +164,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -324,15 +323,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded element in this collection.
* @param element The element
* @param fieldNumber Number of field in the element
@@ -570,7 +560,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
else
{
@@ -629,7 +619,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -671,7 +661,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -725,7 +715,7 @@
backingSuccess = contained;
if (backingSuccess)
{
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, allowCascadeDelete));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, allowCascadeDelete));
}
}
else
@@ -801,7 +791,7 @@
for (Object element : contained)
{
backingSuccess = true;
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, true));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, true));
}
}
else
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/Hashtable.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/Hashtable.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/Hashtable.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -24,6 +24,9 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
+import org.datanucleus.flush.MapClearOperation;
+import org.datanucleus.flush.MapPutOperation;
+import org.datanucleus.flush.MapRemoveOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -31,10 +34,6 @@
import org.datanucleus.store.scostore.MapStore;
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.ClearMapOperation;
-import org.datanucleus.store.types.queued.PutOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveMapOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -148,7 +147,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -171,7 +170,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearMapOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapClearOperation(ownerOP, backingStore));
}
else
{
@@ -191,7 +190,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -289,15 +288,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded key in this map.
* @param key The key
* @param fieldNumber Number of field in the key
@@ -561,7 +551,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearMapOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapClearOperation(ownerOP, backingStore));
}
else
{
@@ -609,7 +599,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new PutOperation(ownerOP, backingStore, key, value));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, key, value));
}
else
{
@@ -655,7 +645,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -692,7 +682,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new RemoveMapOperation(ownerOP, backingStore, key));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapRemoveOperation(ownerOP, backingStore, key));
removed = delegateRemoved;
}
else
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashMap.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashMap.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashMap.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -25,6 +25,9 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
+import org.datanucleus.flush.MapClearOperation;
+import org.datanucleus.flush.MapPutOperation;
+import org.datanucleus.flush.MapRemoveOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -32,10 +35,6 @@
import org.datanucleus.store.scostore.MapStore;
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.ClearMapOperation;
-import org.datanucleus.store.types.queued.PutOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveMapOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -151,7 +150,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -174,7 +173,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearMapOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapClearOperation(ownerOP, backingStore));
}
else
{
@@ -194,7 +193,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -292,15 +291,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded key in this map.
* @param key The key
* @param fieldNumber Number of field in the key
@@ -565,7 +555,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearMapOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapClearOperation(ownerOP, backingStore));
}
else
{
@@ -613,7 +603,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new PutOperation(ownerOP, backingStore, key, value));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, key, value));
}
else
{
@@ -659,7 +649,7 @@
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
- addQueuedOperation(new PutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapPutOperation(ownerOP, backingStore, entry.getKey(), entry.getValue()));
}
}
else
@@ -696,7 +686,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new RemoveMapOperation(ownerOP, backingStore, key));
+ ownerOP.getExecutionContext().addOperationToQueue(new MapRemoveOperation(ownerOP, backingStore, key));
removed = delegateRemoved;
}
else
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashSet.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashSet.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedHashSet.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -25,6 +25,9 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
import org.datanucleus.exceptions.NucleusDataStoreException;
+import org.datanucleus.flush.CollectionAddOperation;
+import org.datanucleus.flush.CollectionClearOperation;
+import org.datanucleus.flush.CollectionRemoveOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -34,10 +37,6 @@
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOCollectionIterator;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.AddOperation;
-import org.datanucleus.store.types.queued.ClearCollectionOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveCollectionOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -162,7 +161,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -321,15 +320,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded element in this collection.
* @param element The element
* @param fieldNumber Number of field in the element
@@ -559,7 +549,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
else
{
@@ -617,7 +607,7 @@
{
for (Object element : elements)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -659,7 +649,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -713,7 +703,7 @@
backingSuccess = contained;
if (backingSuccess)
{
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, allowCascadeDelete));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, allowCascadeDelete));
}
}
else
@@ -788,7 +778,7 @@
for (Object element : contained)
{
backingSuccess = true;
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, true));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, true));
}
}
else
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedList.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedList.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/LinkedList.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -25,6 +25,12 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
import org.datanucleus.exceptions.NucleusDataStoreException;
+import org.datanucleus.flush.ListAddAtOperation;
+import org.datanucleus.flush.CollectionAddOperation;
+import org.datanucleus.flush.CollectionClearOperation;
+import org.datanucleus.flush.ListRemoveAtOperation;
+import org.datanucleus.flush.CollectionRemoveOperation;
+import org.datanucleus.flush.ListSetOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -33,13 +39,6 @@
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOListIterator;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.AddAtOperation;
-import org.datanucleus.store.types.queued.AddOperation;
-import org.datanucleus.store.types.queued.ClearCollectionOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveAtOperation;
-import org.datanucleus.store.types.queued.RemoveCollectionOperation;
-import org.datanucleus.store.types.queued.SetOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -153,7 +152,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -184,7 +183,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -201,7 +200,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -310,15 +309,6 @@
}
/**
- * Convenience method to add a queued operation to the operations we perform at commit.
- * @param oper The operation
- */
- protected void addQueuedOperation(QueuedOperation oper)
- {
- ownerOP.getExecutionContext().addSCOOperationToQueue(oper);
- }
-
- /**
* Method to update an embedded element in this collection.
* @param element The element
* @param fieldNumber Number of field in the element
@@ -676,7 +666,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddAtOperation(ownerOP, backingStore, index, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListAddAtOperation(ownerOP, backingStore, index, element));
}
else
{
@@ -726,7 +716,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
else
{
@@ -774,7 +764,7 @@
{
for (Object element : elements)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionAddOperation(ownerOP, backingStore, element));
}
}
else
@@ -825,7 +815,7 @@
int pos = index;
for (Object element : elements)
{
- addQueuedOperation(new AddAtOperation(ownerOP, backingStore, pos++, element));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListAddAtOperation(ownerOP, backingStore, pos++, element));
}
}
else
@@ -885,7 +875,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new ClearCollectionOperation(ownerOP, backingStore));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionClearOperation(ownerOP, backingStore));
}
else
{
@@ -922,7 +912,7 @@
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
backingObject = delegateObject;
- addQueuedOperation(new RemoveAtOperation(ownerOP, backingStore, index));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, backingStore, index));
}
else
{
@@ -982,7 +972,7 @@
backingSuccess = contained;
if (backingSuccess)
{
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, allowCascadeDelete));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, allowCascadeDelete));
}
}
else
@@ -1046,7 +1036,7 @@
for (Object element : contained)
{
backingSuccess = true;
- addQueuedOperation(new RemoveCollectionOperation(ownerOP, backingStore, element, true));
+ ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, backingStore, element, true));
}
}
else
@@ -1159,7 +1149,7 @@
{
if (SCOUtils.useQueuedUpdate(queued, ownerOP))
{
- addQueuedOperation(new SetOperation(ownerOP, backingStore, index, element, allowDependentField));
+ ownerOP.getExecutionContext().addOperationToQueue(new ListSetOperation(ownerOP, backingStore, index, element, allowDependentField));
}
else
{
Modified: platform/core/trunk/src/java/org/datanucleus/store/types/backed/List.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/types/backed/List.java 2013-05-02 09:45:07 UTC (rev 16973)
+++ platform/core/trunk/src/java/org/datanucleus/store/types/backed/List.java 2013-05-06 10:50:16 UTC (rev 16974)
@@ -29,6 +29,12 @@
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.ExecutionContext;
import org.datanucleus.exceptions.NucleusDataStoreException;
+import org.datanucleus.flush.ListAddAtOperation;
+import org.datanucleus.flush.CollectionAddOperation;
+import org.datanucleus.flush.CollectionClearOperation;
+import org.datanucleus.flush.ListRemoveAtOperation;
+import org.datanucleus.flush.CollectionRemoveOperation;
+import org.datanucleus.flush.ListSetOperation;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.FieldPersistenceModifier;
import org.datanucleus.state.ObjectProvider;
@@ -37,13 +43,6 @@
import org.datanucleus.store.scostore.Store;
import org.datanucleus.store.types.SCOListIterator;
import org.datanucleus.store.types.SCOUtils;
-import org.datanucleus.store.types.queued.AddAtOperation;
-import org.datanucleus.store.types.queued.AddOperation;
-import org.datanucleus.store.types.queued.ClearCollectionOperation;
-import org.datanucleus.store.types.queued.QueuedOperation;
-import org.datanucleus.store.types.queued.RemoveAtOperation;
-import org.datanucleus.store.types.queued.RemoveCollectionOperation;
-import org.datanucleus.store.types.queued.SetOperation;
import org.datanucleus.util.NucleusLogger;
/**
@@ -158,7 +157,7 @@
{
for (Object element : c)
{
- addQueuedOperation(new AddOperation(ownerOP, backingStore, element));
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|