From b845f7f86bfb7150924d968335535ce26c592b82 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 11 Sep 2006 04:48:34 +0000 Subject: Switch JDBC repository to use new query engine. --- .../amazon/carbonado/qe/QueryExecutorCache.java | 2 +- .../com/amazon/carbonado/qe/StandardQuery.java | 31 ++++++++++++---------- .../amazon/carbonado/qe/StandardQueryFactory.java | 23 ++++++++-------- 3 files changed, 30 insertions(+), 26 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/qe') diff --git a/src/main/java/com/amazon/carbonado/qe/QueryExecutorCache.java b/src/main/java/com/amazon/carbonado/qe/QueryExecutorCache.java index da944fa..2729851 100644 --- a/src/main/java/com/amazon/carbonado/qe/QueryExecutorCache.java +++ b/src/main/java/com/amazon/carbonado/qe/QueryExecutorCache.java @@ -42,7 +42,7 @@ public class QueryExecutorCache implements QueryExecutorFact // Maps filters to maps which map ordering lists to executors. private final Map, Map, QueryExecutor>> mFilterToExecutor; - protected QueryExecutorCache(QueryExecutorFactory factory) { + public QueryExecutorCache(QueryExecutorFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } diff --git a/src/main/java/com/amazon/carbonado/qe/StandardQuery.java b/src/main/java/com/amazon/carbonado/qe/StandardQuery.java index bb1dcc3..2e1cdfc 100644 --- a/src/main/java/com/amazon/carbonado/qe/StandardQuery.java +++ b/src/main/java/com/amazon/carbonado/qe/StandardQuery.java @@ -363,11 +363,23 @@ public abstract class StandardQuery extends AbstractQuery return values; } + /** + * Returns the executor in use by this query. + */ + protected QueryExecutor executor() throws RepositoryException { + QueryExecutor executor = mExecutor; + if (executor == null) { + Filter filter = mValues == null ? null : mValues.getFilter(); + mExecutor = executor = executorFactory().executor(filter, mOrdering); + } + return executor; + } + /** * Ensures that a cached query executor reference is available. If not, the * query executor factory is called and the executor is cached. */ - protected void setExecutorReference() throws RepositoryException { + protected void setExecutor() throws RepositoryException { executor(); } @@ -375,7 +387,7 @@ public abstract class StandardQuery extends AbstractQuery * Resets any cached reference to a query executor. If a reference is * available, it is replaced, but a clear reference is not set. */ - protected void resetExecutorReference() throws RepositoryException { + protected void resetExecutor() throws RepositoryException { if (mExecutor != null) { Filter filter = mValues == null ? null : mValues.getFilter(); mExecutor = executorFactory().executor(filter, mOrdering); @@ -387,7 +399,7 @@ public abstract class StandardQuery extends AbstractQuery * Query is used, it will get an executor from the query executor factory * and cache a reference to it. */ - protected void clearExecutorReference() { + protected void clearExecutor() { mExecutor = null; } @@ -415,10 +427,10 @@ public abstract class StandardQuery extends AbstractQuery * passed in the constructor. * * @param values optional values object, defaults to open filter if null - * @param orderings order-by properties, never null + * @param ordering order-by properties, never null */ protected abstract StandardQuery newInstance(FilterValues values, - OrderingList orderings); + OrderingList ordering); private StandardQuery newInstance(FilterValues values) { return newInstance(values, mOrdering); @@ -433,13 +445,4 @@ public abstract class StandardQuery extends AbstractQuery { return queryFactory().query(values, ordering); } - - private QueryExecutor executor() throws RepositoryException { - QueryExecutor executor = mExecutor; - if (executor == null) { - Filter filter = mValues == null ? null : mValues.getFilter(); - mExecutor = executor = executorFactory().executor(filter, mOrdering); - } - return executor; - } } diff --git a/src/main/java/com/amazon/carbonado/qe/StandardQueryFactory.java b/src/main/java/com/amazon/carbonado/qe/StandardQueryFactory.java index 8b9a3a9..c9b0557 100644 --- a/src/main/java/com/amazon/carbonado/qe/StandardQueryFactory.java +++ b/src/main/java/com/amazon/carbonado/qe/StandardQueryFactory.java @@ -135,7 +135,7 @@ public abstract class StandardQueryFactory implements QueryF StandardQuery standardQuery = createQuery(values, ordering); if (!mLazySetExecutor) { try { - standardQuery.setExecutorReference(); + standardQuery.setExecutor(); } catch (RepositoryException e) { throw e.toFetchException(); } @@ -168,33 +168,33 @@ public abstract class StandardQueryFactory implements QueryF } /** - * For each cached query, calls {@link StandardQuery#setExecutorReference}. + * For each cached query, calls {@link StandardQuery#setExecutor}. */ - public void setExecutorReferences() throws RepositoryException { + public void setExecutors() throws RepositoryException { for (StandardQuery query : gatherQueries()) { - query.setExecutorReference(); + query.setExecutor(); } } /** - * For each cached query, calls {@link StandardQuery#resetExecutorReference}. + * For each cached query, calls {@link StandardQuery#resetExecutor}. * This call can be used to rebuild all cached query plans after the set of * available indexes has changed. */ - public void resetExecutorReferences() throws RepositoryException { + public void resetExecutors() throws RepositoryException { for (StandardQuery query : gatherQueries()) { - query.resetExecutorReference(); + query.resetExecutor(); } } /** - * For each cached query, calls {@link StandardQuery#clearExecutorReference}. + * For each cached query, calls {@link StandardQuery#clearExecutor}. * This call can be used to clear all cached query plans after the set of * available indexes has changed. */ - public void clearExecutorReferences() { + public void clearExecutos() { for (StandardQuery query : gatherQueries()) { - query.clearExecutorReference(); + query.clearExecutor(); } } @@ -205,7 +205,8 @@ public abstract class StandardQueryFactory implements QueryF * @param ordering optional order-by properties */ protected abstract StandardQuery createQuery(FilterValues values, - OrderingList ordering); + OrderingList ordering) + throws FetchException; private ArrayList> gatherQueries() { // Copy all queries and operate on the copy instead of holding lock for -- cgit v1.2.3