diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado/qe')
3 files changed, 30 insertions, 26 deletions
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<S extends Storable> implements QueryExecutorFact // Maps filters to maps which map ordering lists to executors.
private final Map<Filter<S>, Map<OrderingList<S>, QueryExecutor<S>>> mFilterToExecutor;
- protected QueryExecutorCache(QueryExecutorFactory<S> factory) {
+ public QueryExecutorCache(QueryExecutorFactory<S> 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 @@ -364,10 +364,22 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S> }
/**
+ * Returns the executor in use by this query.
+ */
+ protected QueryExecutor<S> executor() throws RepositoryException {
+ QueryExecutor<S> executor = mExecutor;
+ if (executor == null) {
+ Filter<S> 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<S extends Storable> extends AbstractQuery<S> * 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<S> filter = mValues == null ? null : mValues.getFilter();
mExecutor = executorFactory().executor(filter, mOrdering);
@@ -387,7 +399,7 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S> * 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<S extends Storable> extends AbstractQuery<S> * 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<S> newInstance(FilterValues<S> values,
- OrderingList<S> orderings);
+ OrderingList<S> ordering);
private StandardQuery<S> newInstance(FilterValues<S> values) {
return newInstance(values, mOrdering);
@@ -433,13 +445,4 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S> {
return queryFactory().query(values, ordering);
}
-
- private QueryExecutor<S> executor() throws RepositoryException {
- QueryExecutor<S> executor = mExecutor;
- if (executor == null) {
- Filter<S> 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<S extends Storable> implements QueryF StandardQuery<S> 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<S extends Storable> 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<S> 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<S> 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<S> query : gatherQueries()) {
- query.clearExecutorReference();
+ query.clearExecutor();
}
}
@@ -205,7 +205,8 @@ public abstract class StandardQueryFactory<S extends Storable> implements QueryF * @param ordering optional order-by properties
*/
protected abstract StandardQuery<S> createQuery(FilterValues<S> values,
- OrderingList<S> ordering);
+ OrderingList<S> ordering)
+ throws FetchException;
private ArrayList<StandardQuery<S>> gatherQueries() {
// Copy all queries and operate on the copy instead of holding lock for
|