summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2006-10-13 21:09:10 +0000
committerBrian S. O'Neill <bronee@gmail.com>2006-10-13 21:09:10 +0000
commit2fd7b3fd77c8141f7fb21d2bd86eb839fa55ef6f (patch)
tree828dd9e9c0c0b8976aa2f4da253d26f7ae2e6861 /src
parentc43323482b8c93952743469c40c1c631e293c2a2 (diff)
Pass the internal query executor along when "with" is called, as an optimization.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/qe/QueryEngine.java13
-rw-r--r--src/main/java/com/amazon/carbonado/qe/StandardQuery.java12
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java13
-rw-r--r--src/test/java/com/amazon/carbonado/repo/toy/ToyStorage.java17
4 files changed, 35 insertions, 20 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/QueryEngine.java b/src/main/java/com/amazon/carbonado/qe/QueryEngine.java
index 59c9872..56f6145 100644
--- a/src/main/java/com/amazon/carbonado/qe/QueryEngine.java
+++ b/src/main/java/com/amazon/carbonado/qe/QueryEngine.java
@@ -50,12 +50,12 @@ public class QueryEngine<S extends Storable> extends StandardQueryFactory<S>
}
protected StandardQuery<S> createQuery(FilterValues<S> values, OrderingList<S> ordering) {
- return new Query(values, ordering);
+ return new Query(values, ordering, null);
}
private class Query extends StandardQuery<S> {
- Query(FilterValues<S> values, OrderingList<S> ordering) {
- super(values, ordering);
+ Query(FilterValues<S> values, OrderingList<S> ordering, QueryExecutor<S> executor) {
+ super(values, ordering, executor);
}
protected Transaction enterTransaction(IsolationLevel level) {
@@ -70,8 +70,11 @@ public class QueryEngine<S extends Storable> extends StandardQueryFactory<S>
return mExecutorFactory;
}
- protected StandardQuery<S> newInstance(FilterValues<S> values, OrderingList<S> ordering) {
- return new Query(values, ordering);
+ protected StandardQuery<S> newInstance(FilterValues<S> values,
+ OrderingList<S> ordering,
+ QueryExecutor<S> executor)
+ {
+ return new Query(values, ordering, executor);
}
}
}
diff --git a/src/main/java/com/amazon/carbonado/qe/StandardQuery.java b/src/main/java/com/amazon/carbonado/qe/StandardQuery.java
index 0a4c9d9..d7f5263 100644
--- a/src/main/java/com/amazon/carbonado/qe/StandardQuery.java
+++ b/src/main/java/com/amazon/carbonado/qe/StandardQuery.java
@@ -61,13 +61,18 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S>
/**
* @param values optional values object, defaults to open filter if null
* @param ordering optional order-by properties
+ * @param executor optional executor to use (by default lazily obtains and caches executor)
*/
- protected StandardQuery(FilterValues<S> values, OrderingList<S> ordering) {
+ protected StandardQuery(FilterValues<S> values,
+ OrderingList<S> ordering,
+ QueryExecutor<S> executor)
+ {
mValues = values;
if (ordering == null) {
ordering = OrderingList.emptyList();
}
mOrdering = ordering;
+ mExecutor = executor;
}
public Class<S> getStorableType() {
@@ -429,10 +434,11 @@ public abstract class StandardQuery<S extends Storable> extends AbstractQuery<S>
* @param ordering order-by properties, never null
*/
protected abstract StandardQuery<S> newInstance(FilterValues<S> values,
- OrderingList<S> ordering);
+ OrderingList<S> ordering,
+ QueryExecutor<S> executor);
private StandardQuery<S> newInstance(FilterValues<S> values) {
- return newInstance(values, mOrdering);
+ return newInstance(values, mOrdering, mExecutor);
}
private Query<S> createQuery(FilterValues<S> values, OrderingList<S> ordering)
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
index b7a732e..df61ecf 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
@@ -249,7 +249,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
}
protected StandardQuery<S> createQuery(FilterValues<S> values, OrderingList<S> ordering) {
- return new JDBCQuery(values, ordering);
+ return new JDBCQuery(values, ordering, null);
}
public S instantiate(ResultSet rs) throws SQLException {
@@ -611,8 +611,8 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
}
private class JDBCQuery extends StandardQuery<S> {
- JDBCQuery(FilterValues<S> values, OrderingList<S> ordering) {
- super(values, ordering);
+ JDBCQuery(FilterValues<S> values, OrderingList<S> ordering, QueryExecutor<S> executor) {
+ super(values, ordering, executor);
}
@Override
@@ -642,8 +642,11 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
return JDBCStorage.this.mExecutorFactory;
}
- protected StandardQuery<S> newInstance(FilterValues<S> values, OrderingList<S> ordering) {
- return new JDBCQuery(values, ordering);
+ protected StandardQuery<S> newInstance(FilterValues<S> values,
+ OrderingList<S> ordering,
+ QueryExecutor<S> executor)
+ {
+ return new JDBCQuery(values, ordering, executor);
}
}
diff --git a/src/test/java/com/amazon/carbonado/repo/toy/ToyStorage.java b/src/test/java/com/amazon/carbonado/repo/toy/ToyStorage.java
index bafa244..71a597d 100644
--- a/src/test/java/com/amazon/carbonado/repo/toy/ToyStorage.java
+++ b/src/test/java/com/amazon/carbonado/repo/toy/ToyStorage.java
@@ -94,7 +94,7 @@ public class ToyStorage<S extends Storable>
}
public Query<S> query() {
- return new ToyQuery(null, null);
+ return new ToyQuery(null, null, null);
}
public Query<S> query(String filter) {
@@ -102,11 +102,11 @@ public class ToyStorage<S extends Storable>
}
public Query<S> query(Filter<S> filter) {
- return new ToyQuery(filter.initialFilterValues(), null);
+ return new ToyQuery(filter.initialFilterValues(), null, null);
}
public Query<S> query(FilterValues<S> values, OrderingList<S> ordering) {
- return new ToyQuery(values, ordering);
+ return new ToyQuery(values, ordering, null);
}
public QueryExecutor<S> executor(Filter<S> filter, OrderingList<S> ordering) {
@@ -239,8 +239,8 @@ public class ToyStorage<S extends Storable>
}
private class ToyQuery extends StandardQuery<S> {
- ToyQuery(FilterValues<S> values, OrderingList<S> ordering) {
- super(values, ordering);
+ ToyQuery(FilterValues<S> values, OrderingList<S> ordering, QueryExecutor<S> executor) {
+ super(values, ordering, executor);
}
protected Transaction enterTransaction(IsolationLevel level) {
@@ -255,8 +255,11 @@ public class ToyStorage<S extends Storable>
return ToyStorage.this;
}
- protected StandardQuery<S> newInstance(FilterValues<S> values, OrderingList<S> ordering) {
- return new ToyQuery(values, ordering);
+ protected StandardQuery<S> newInstance(FilterValues<S> values,
+ OrderingList<S> ordering,
+ QueryExecutor<S> executor)
+ {
+ return new ToyQuery(values, ordering, executor);
}
}
}