#566 - Refactor internals - SpiExpression, add prepareExpression() to merge queryAutoTuneHash() and queryPlanHash() - move to protected calculateQueryPlanHash()

This commit is contained in:
Robin Bygrave
2016-02-13 21:22:52 +13:00
parent ca944eb756
commit 076f8a03b9
4 changed files with 42 additions and 109 deletions
@@ -466,16 +466,6 @@ public interface SpiQuery<T> extends Query<T> {
*/
String getName();
/**
* Calculate a hash used by AutoTune to identify when a query has changed
* (and hence potentially needs a new tuned query plan to be developed).
* <p>
* Excludes bind values and occurs prior to AutoTune potentially
* tuning/modifying the query.
* </p>
*/
HashQueryPlan queryAutoTuneHash(HashQueryPlanBuilder builder);
/**
* Identifies queries that are the same bar the bind variables.
* <p>
@@ -759,13 +759,10 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
/**
* Calculate the query hash for either AutoTune query tuning or Query Plan caching.
*/
private HashQueryPlan calculateHash(HashQueryPlanBuilder builder) {
HashQueryPlan calculateQueryPlanHash() {
// exclude bind values and things unrelated to the sql being generated
if (builder == null) {
builder = new HashQueryPlanBuilder();
}
HashQueryPlanBuilder builder = new HashQueryPlanBuilder();
builder.add((type == null ? 0 : type.ordinal() + 1));
builder.add(autoTuned).add(distinct).add(sqlDistinct).add(query);
@@ -796,15 +793,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return builder.build();
}
/**
* Calculate a hash used by AutoTune to identify when a query has changed (and hence potentially
* needs a new tuned query plan to be developed).
*/
public HashQueryPlan queryAutoTuneHash(HashQueryPlanBuilder builder) {
return calculateHash(builder);
}
/**
* Calculate a hash that should be unique for the generated SQL across a given bean type.
* <p>
@@ -818,7 +806,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
prepareExpressions(request);
queryPlanHash = calculateHash(null);
queryPlanHash = calculateQueryPlanHash();
return queryPlanHash;
}