openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r686462 - in /openjpa/branches/1.2.x/openjpa-slice/src: main/java/org/apache/openjpa/slice/jdbc/DistributedStoreManager.java main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java test/java/org/apache/openjpa/slice/TestQuery.java
Date Sat, 16 Aug 2008 08:13:26 GMT
Author: ppoddar
Date: Sat Aug 16 01:13:25 2008
New Revision: 686462

URL: http://svn.apache.org/viewvc?rev=686462&view=rev
Log:
merge 686453 for hint processing changes required due to eager compilation of Query in OPENJPA-678

Modified:
    openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreManager.java
    openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java
    openjpa/branches/1.2.x/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java

Modified: openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreManager.java?rev=686462&r1=686461&r2=686462&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreManager.java
(original)
+++ openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreManager.java
Sat Aug 16 01:13:25 2008
@@ -102,6 +102,10 @@
     public DistributedJDBCConfiguration getConfiguration() {
         return _conf;
     }
+    
+    public SliceStoreManager getSlice(int i) {
+    	return _slices.get(i);
+    }
 
     /**
      * Decides the index of the StoreManager by first looking at the

Modified: openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java?rev=686462&r1=686461&r2=686462&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java
(original)
+++ openjpa/branches/1.2.x/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java
Sat Aug 16 01:13:25 2008
@@ -32,6 +32,7 @@
 import org.apache.openjpa.kernel.FetchConfiguration;
 import org.apache.openjpa.kernel.OrderingMergedResultObjectProvider;
 import org.apache.openjpa.kernel.QueryContext;
+import org.apache.openjpa.kernel.StoreManager;
 import org.apache.openjpa.kernel.StoreQuery;
 import org.apache.openjpa.kernel.exps.ExpressionParser;
 import org.apache.openjpa.lib.rop.MergedResultObjectProvider;
@@ -61,17 +62,15 @@
 		_queries.add(q);
 	}
 	
+	public DistributedStoreManager getDistributedStore() {
+		return (DistributedStoreManager)getStore();
+	}
+	
     public Executor newDataStoreExecutor(ClassMetaData meta, boolean subs) {
     	ParallelExecutor ex = new ParallelExecutor(this, meta, subs, _parser, 
     			ctx.getCompilation());
-    	
-    	FetchConfiguration fetch = getContext().getFetchConfiguration();
-    	DistributedStoreManager store = (DistributedStoreManager)getContext()
-    	    .getStoreContext().getStoreManager().getInnermostDelegate();
-        List<SliceStoreManager> targets = store.getTargets(fetch);
-        for (StoreQuery q:_queries) {
-            if (targets.contains(((JDBCStoreQuery)q).getStore()))
-                ex.addExecutor(q.newDataStoreExecutor(meta, subs));
+        for (StoreQuery q : _queries) {
+            ex.addExecutor(q.newDataStoreExecutor(meta, subs));
         }
         return ex;
     }
@@ -117,19 +116,23 @@
          */
         public ResultObjectProvider executeQuery(StoreQuery q,
                 final Object[] params, final Range range) {
-        	ResultObjectProvider[] tmp = new ResultObjectProvider[executors.size()];
-        	final Iterator<StoreQuery> qs = owner._queries.iterator();
         	final List<Future<ResultObjectProvider>> futures = 
         		new ArrayList<Future<ResultObjectProvider>>();
-        	int i = 0;
-        	for (Executor ex:executors)  {
+        	List<SliceStoreManager> targets = findTargets();
+        	for (int i = 0; i < owner._queries.size(); i++) {
+        		StoreQuery query = owner._queries.get(i);
+        		StoreManager sm  = owner.getDistributedStore().getSlice(i);
+        		if (!targets.contains(sm))
+        			continue;
         		QueryExecutor call = new QueryExecutor();
-        		call.executor = ex;
-        		call.query    = qs.next();
+        		call.executor = executors.get(i);
+        		call.query    = query;
         		call.params   = params;
         		call.range    = range;
         		futures.add(threadPool.submit(call)); 
         	}
+        	int i = 0;
+        	ResultObjectProvider[] tmp = new ResultObjectProvider[futures.size()];
         	for (Future<ResultObjectProvider> future:futures) {
         		try {
 					tmp[i++] = future.get();
@@ -210,6 +213,11 @@
         	}
         	return new Integer(N);
         }
+        
+        List<SliceStoreManager> findTargets() {
+        	FetchConfiguration fetch = owner.getContext().getFetchConfiguration();
+        	return owner.getDistributedStore().getTargets(fetch);
+        }
 
 	}
 	

Modified: openjpa/branches/1.2.x/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java?rev=686462&r1=686461&r2=686462&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java
(original)
+++ openjpa/branches/1.2.x/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java
Sat Aug 16 01:13:25 2008
@@ -111,10 +111,6 @@
         em.getTransaction().rollback();
     }
     
-    /**
-     * Retired temporarily. Most likely side-effect of eager compilation of
-     * query introduced recently.
-     */
     public void testHint() {
         List<String> targets = new ArrayList<String>();
         targets.add("Even");



Mime
View raw message