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

This commit is contained in:
Robin Bygrave committed 2016-02-13 21:22:52 +13:00
1 parent ca944eb756
commit 076f8a03b9
4 files changed
+42 -109

No files matched your search

@@ -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;
}