mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-09 08:42:18 +00:00
#411 - Refactor AutoFetch, rename to "AutoTune", store/load tuning and profiling as XML
This commit is contained in:
1 parent
9632279c2f
commit
0a8c902790
111 files changed
+255
-341
No files matched your search
@@ -36,7 +36,7 @@ import java.util.Set;
|
||||
* .sort("avgTimeMicros desc")
|
||||
* .gt("executionCount", 0)
|
||||
* .gt("lastQueryTime", nowMinus24Hrs)
|
||||
* .eq("autofetchTuned", true)
|
||||
* .eq("autoTuned", true)
|
||||
* .maxRows(10)
|
||||
* .filter(list);
|
||||
*
|
||||
|
||||
@@ -836,10 +836,10 @@ public abstract class Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a query with explicit 'Autofetch' use.
|
||||
* Create a query with explicit 'AutoTune' use.
|
||||
*/
|
||||
public Query<T> setAutofetch(boolean autofetch) {
|
||||
return query().setAutofetch(autofetch);
|
||||
public Query<T> setAutoTune(boolean autoTune) {
|
||||
return query().setAutoTune(autoTune);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,9 +67,9 @@ import java.util.Set;
|
||||
* ...
|
||||
* }</pre>
|
||||
*
|
||||
* <h3>Autofetch</h3>
|
||||
* <h3>AutoTune</h3>
|
||||
* <p>
|
||||
* Ebean has built in support for "Autofetch". This is a mechanism where a query
|
||||
* Ebean has built in support for "AutoTune". This is a mechanism where a query
|
||||
* can be automatically tuned based on profiling information that is collected.
|
||||
* </p>
|
||||
* <p>
|
||||
@@ -78,7 +78,7 @@ import java.util.Set;
|
||||
* more.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is expected that Autofetch will be the default approach for many queries
|
||||
* It is expected that AutoTune will be the default approach for many queries
|
||||
* in a system. It is possibly not as useful where the result of a query is sent
|
||||
* to a remote client or where there is some requirement for "Read Consistency"
|
||||
* guarantees.
|
||||
@@ -338,23 +338,23 @@ public interface Query<T> extends Serializable {
|
||||
ExpressionFactory getExpressionFactory();
|
||||
|
||||
/**
|
||||
* Returns true if this query was tuned by autoFetch.
|
||||
* Returns true if this query was tuned by autoTune.
|
||||
*/
|
||||
boolean isAutofetchTuned();
|
||||
boolean isAutoTuned();
|
||||
|
||||
/**
|
||||
* Explicitly specify whether to use Autofetch for this query.
|
||||
* Explicitly specify whether to use AutoTune for this query.
|
||||
* <p>
|
||||
* If you do not call this method on a query the "Implicit Autofetch mode" is
|
||||
* used to determine if Autofetch should be used for a given query.
|
||||
* If you do not call this method on a query the "Implicit AutoTune mode" is
|
||||
* used to determine if AutoTune should be used for a given query.
|
||||
* </p>
|
||||
* <p>
|
||||
* Autofetch can add additional fetch paths to the query and specify which
|
||||
* AutoTune can add additional fetch paths to the query and specify which
|
||||
* properties are included for each path. If you have explicitly defined some
|
||||
* fetch paths Autofetch will not remove.
|
||||
* fetch paths AutoTune will not remove them.
|
||||
* </p>
|
||||
*/
|
||||
Query<T> setAutofetch(boolean autofetch);
|
||||
Query<T> setAutoTune(boolean autoTune);
|
||||
|
||||
/**
|
||||
* Set the default lazy loading batch size to use.
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Represent the call stack (stack trace elements).
|
||||
* <p>
|
||||
* Used with a query to identify a CallStackQuery for AutoFetch automatic query
|
||||
* Used with a query to identify a CallStackQuery for AutoTune automatic query
|
||||
* tuning.
|
||||
* </p>
|
||||
* <p>
|
||||
|
||||
@@ -5,10 +5,9 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Collects profile information for a bean (or reference/proxy bean) at a given
|
||||
* AutoFetchNode.
|
||||
* Collects profile information for a bean (or reference/proxy bean) at a given node.
|
||||
* <p>
|
||||
* The AutoFetchNode identifies the location of the bean in the object graph.
|
||||
* The node identifies the location of the bean in the object graph.
|
||||
* </p>
|
||||
* <p>
|
||||
* It has to use a weak reference so as to ensure that it does not stop the
|
||||
|
||||
@@ -9,7 +9,7 @@ public interface NodeUsageListener {
|
||||
* Collect node usage "profiling" information.
|
||||
* <p>
|
||||
* This is the properties that are used for a given bean in the object graph.
|
||||
* This information is used by autoFetch to tune queries.
|
||||
* This information is used by autoTune to tune queries.
|
||||
* </p>
|
||||
*/
|
||||
void collectNodeUsage(NodeUsageCollector collector);
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||
* The call stack is included so that the query can have different tuned fetches
|
||||
* for each unique call stack. For example, a query to fetch a customer could be
|
||||
* called by three different methods and each can be treated as a separate
|
||||
* origin point (and autoFetch can tune each one separately).
|
||||
* origin point (and autoTune can tune each one separately).
|
||||
* </p>
|
||||
*/
|
||||
public final class ObjectGraphOrigin implements Serializable {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AutoTuneConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if the queries should be tuned by autofetch.
|
||||
* Set to true if the queries should be tuned by autoTune.
|
||||
*/
|
||||
public void setQueryTuning(boolean queryTuning) {
|
||||
this.queryTuning = queryTuning;
|
||||
@@ -123,7 +123,7 @@ public class AutoTuneConfig {
|
||||
* Set to true if profiling information should be collected.
|
||||
* <p>
|
||||
* The profiling information is collected and then used to generate the tuned
|
||||
* queries for autofetch.
|
||||
* queries for autoTune.
|
||||
* </p>
|
||||
*/
|
||||
public void setProfiling(boolean profiling) {
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.avaje.ebean.config;
|
||||
import com.avaje.ebean.Query;
|
||||
|
||||
/**
|
||||
* The mode for determining if Autofetch will be used for a given query when
|
||||
* {@link Query#setAutofetch(boolean)} has not been explicitly set on a query.
|
||||
* The mode for determining if AutoTune will be used for a given query when
|
||||
* {@link Query#setAutoTune(boolean)} has not been explicitly set on a query.
|
||||
* <p>
|
||||
* The explicit control of {@link Query#setAutofetch(boolean)} will always take
|
||||
* The explicit control of {@link Query#setAutoTune(boolean)} will always take
|
||||
* precedence. This mode is used when this has not been explicitly set on a
|
||||
* query.
|
||||
* </p>
|
||||
@@ -14,17 +14,17 @@ import com.avaje.ebean.Query;
|
||||
public enum AutoTuneMode {
|
||||
|
||||
/**
|
||||
* Don't implicitly use Autofetch. Must explicitly turn it on.
|
||||
* Don't implicitly use AutoTune. Must explicitly turn it on.
|
||||
*/
|
||||
DEFAULT_OFF,
|
||||
|
||||
/**
|
||||
* Use Autofetch implicitly. Must explicitly turn it off.
|
||||
* Use AutoTune implicitly. Must explicitly turn it off.
|
||||
*/
|
||||
DEFAULT_ON,
|
||||
|
||||
/**
|
||||
* Implicitly use Autofetch if the query has not got either select() or join()
|
||||
* Implicitly use AutoTune if the query has not got either select() or join()
|
||||
* defined.
|
||||
*/
|
||||
DEFAULT_ONIFEMPTY
|
||||
|
||||
@@ -130,7 +130,7 @@ public class ServerConfig {
|
||||
private CurrentUserProvider currentUserProvider;
|
||||
|
||||
/**
|
||||
* Config controlling the autofetch behaviour.
|
||||
* Config controlling the AutoTune behaviour.
|
||||
*/
|
||||
private AutoTuneConfig autoTuneConfig = new AutoTuneConfig();
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ public interface MetaQueryPlanStatistic {
|
||||
Class<?> getBeanType();
|
||||
|
||||
/**
|
||||
* Return true if this query plan was tuned by Autofetch.
|
||||
* Return true if this query plan was tuned by AutoTune.
|
||||
*/
|
||||
boolean isAutofetchTuned();
|
||||
boolean isAutoTuned();
|
||||
|
||||
/**
|
||||
* Return a string representation of the query plan hash.
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface LoadContext {
|
||||
void registerSecondaryQueries(SpiQuery<?> query);
|
||||
|
||||
/**
|
||||
* Return the node for a given path which is used by autofetch profiling.
|
||||
* Return the node for a given path which is used by AutoTune profiling.
|
||||
*/
|
||||
ObjectGraphNode getObjectGraphNode(String path);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionL
|
||||
/**
|
||||
* Create an object to represent the current CallStack.
|
||||
* <p>
|
||||
* Typically used to identify the origin of queries for Autofetch and object
|
||||
* Typically used to identify the origin of queries for AutoTune and object
|
||||
* graph costing.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
@@ -19,13 +19,13 @@ public interface SpiExpression extends Expression {
|
||||
void containsMany(BeanDescriptor<?> desc, ManyWhereJoins whereManyJoins);
|
||||
|
||||
/**
|
||||
* Calculate a hash value used to identify a query for AutoFetch tuning.
|
||||
* Calculate a hash value used to identify a query for AutoTune tuning.
|
||||
* <p>
|
||||
* That is, if the hash changes then the query will be considered different
|
||||
* from an AutoFetch perspective and get different tuning.
|
||||
* from an AutoTune perspective and get different tuning.
|
||||
* </p>
|
||||
*/
|
||||
void queryAutoFetchHash(HashQueryPlanBuilder builder);
|
||||
void queryAutoTuneHash(HashQueryPlanBuilder builder);
|
||||
|
||||
/**
|
||||
* Calculate a hash value for the expression.
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebean.event.readaudit.ReadEvent;
|
||||
import com.avaje.ebeaninternal.server.autofetch.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.deploy.TableJoin;
|
||||
@@ -345,10 +345,10 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
boolean isDetailEmpty();
|
||||
|
||||
/**
|
||||
* Return explicit autoFetch setting or null. If null then not explicitly
|
||||
* Return explicit AutoTune setting or null. If null then not explicitly
|
||||
* set so we use the default behaviour.
|
||||
*/
|
||||
Boolean isAutofetch();
|
||||
Boolean isAutoTune();
|
||||
|
||||
/**
|
||||
* Set to true if you want to capture executed secondary queries.
|
||||
@@ -423,14 +423,14 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
/**
|
||||
* Return false when this is a lazy load or refresh query for a bean.
|
||||
* <p>
|
||||
* We just take/copy the data from those beans and don't collect autoFetch
|
||||
* We just take/copy the data from those beans and don't collect AutoTune
|
||||
* usage profiling on those lazy load or refresh beans.
|
||||
* </p>
|
||||
*/
|
||||
boolean isUsageProfiling();
|
||||
|
||||
/**
|
||||
* Set to false if this query should not be included in the autoFetch usage
|
||||
* Set to false if this query should not be included in the AutoTune usage
|
||||
* profiling information.
|
||||
*/
|
||||
void setUsageProfiling(boolean usageProfiling);
|
||||
@@ -441,19 +441,19 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Calculate a hash used by AutoFetch to identify when a query has changed
|
||||
* 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 AutoFetch potentially
|
||||
* Excludes bind values and occurs prior to AutoTune potentially
|
||||
* tuning/modifying the query.
|
||||
* </p>
|
||||
*/
|
||||
HashQueryPlan queryAutofetchHash(HashQueryPlanBuilder builder);
|
||||
HashQueryPlan queryAutoTuneHash(HashQueryPlanBuilder builder);
|
||||
|
||||
/**
|
||||
* Identifies queries that are the same bar the bind variables.
|
||||
* <p>
|
||||
* This is used AFTER AutoFetch has potentially tuned the query. This is
|
||||
* This is used AFTER AutoTune has potentially tuned the query. This is
|
||||
* used to identify and reused query plans (the final SQL string and
|
||||
* associated SqlTree object).
|
||||
* </p>
|
||||
@@ -558,7 +558,7 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
String getQuery();
|
||||
|
||||
/**
|
||||
* Replace the query detail. This is used by the autoFetch feature to as a
|
||||
* Replace the query detail. This is used by the AutoTune feature to as a
|
||||
* fast way to set the query properties and joins.
|
||||
* <p>
|
||||
* Note care must be taken to keep the where, orderBy, firstRows and maxRows
|
||||
@@ -568,15 +568,15 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
void setDetail(OrmQueryDetail detail);
|
||||
|
||||
/**
|
||||
* Autofetch tune the detail specifying properties to select on already defined joins
|
||||
* AutoTune tune the detail specifying properties to select on already defined joins
|
||||
* and adding extra joins where they are missing.
|
||||
*/
|
||||
boolean tuneFetchProperties(OrmQueryDetail detail);
|
||||
|
||||
/**
|
||||
* Set to true if this query has been tuned by autoFetch.
|
||||
* Set to true if this query has been tuned by autoTune.
|
||||
*/
|
||||
void setAutoFetchTuned(boolean autoFetchTuned);
|
||||
void setAutoTuned(boolean autoTuned);
|
||||
|
||||
/**
|
||||
* Return the query detail.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch;
|
||||
package com.avaje.ebeaninternal.server.autotune;
|
||||
|
||||
import com.avaje.ebean.bean.ObjectGraphOrigin;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
+4
-9
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch;
|
||||
package com.avaje.ebeaninternal.server.autotune;
|
||||
|
||||
import com.avaje.ebean.AutoTune;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
@@ -7,7 +7,7 @@ import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
* Collects and manages the the profile information.
|
||||
* <p>
|
||||
* The profile information is periodically converted into "tuned query details" -
|
||||
* which is used to automatically tune the queries that use autoFetch.
|
||||
* which is used to automatically tune the queries that use AutoTune.
|
||||
* </p>
|
||||
* <p>
|
||||
* The "tuned query details" effectively are part of the query that has the
|
||||
@@ -23,14 +23,9 @@ public interface AutoTuneService extends AutoTune {
|
||||
void startup();
|
||||
|
||||
/**
|
||||
* Called when a query thinks it should be automatically tuned by autoFetch.
|
||||
* Called when a query thinks it should be automatically tuned by AutoTune.
|
||||
* <p>
|
||||
* This internally checks that autoFetch is enabled, there is a "tuned query
|
||||
* detail" to tune the query with and that the autoFetchMinThreshold has
|
||||
* been reached.
|
||||
* </p>
|
||||
* <p>
|
||||
* This will also determine if the query should be profiled.
|
||||
* Returns true if the query was tuned.
|
||||
* </p>
|
||||
*/
|
||||
boolean tuneQuery(SpiQuery<?> query);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch;
|
||||
package com.avaje.ebeaninternal.server.autotune;
|
||||
|
||||
/**
|
||||
*
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch;
|
||||
package com.avaje.ebeaninternal.server.autotune;
|
||||
|
||||
import com.avaje.ebean.bean.NodeUsageListener;
|
||||
import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package com.avaje.ebeaninternal.server.autofetch.model;
|
||||
package com.avaje.ebeaninternal.server.autotune.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
|
||||
package com.avaje.ebeaninternal.server.autofetch.model;
|
||||
package com.avaje.ebeaninternal.server.autotune.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
|
||||
@@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlRegistry;
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the com.avaje.ebeaninternal.server.autofetch.model package.
|
||||
* generated in the com.avaje.ebeaninternal.server.autotune.model package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
@@ -23,7 +23,7 @@ public class ObjectFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.server.autofetch.model
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.server.autotune.model
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package com.avaje.ebeaninternal.server.autofetch.model;
|
||||
package com.avaje.ebeaninternal.server.autotune.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package com.avaje.ebeaninternal.server.autofetch.model;
|
||||
package com.avaje.ebeaninternal.server.autotune.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package com.avaje.ebeaninternal.server.autofetch.model;
|
||||
package com.avaje.ebeaninternal.server.autotune.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://ebean-orm.github.io/xml/ns/autotune", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||
package com.avaje.ebeaninternal.server.autofetch.model;
|
||||
package com.avaje.ebeaninternal.server.autotune.model;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneService;
|
||||
|
||||
public class AutoTuneServiceFactory {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
|
||||
import com.avaje.ebeaninternal.server.autofetch.model.Autotune;
|
||||
import com.avaje.ebeaninternal.server.autotune.model.Autotune;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
|
||||
import com.avaje.ebeaninternal.server.autofetch.model.Autotune;
|
||||
import com.avaje.ebeaninternal.server.autotune.model.Autotune;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebean.bean.CallStack;
|
||||
import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
@@ -6,7 +6,7 @@ import com.avaje.ebean.config.AutoTuneConfig;
|
||||
import com.avaje.ebean.config.AutoTuneMode;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.autofetch.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
@@ -145,10 +145,10 @@ public class BaseQueryTuner {
|
||||
*/
|
||||
private boolean useTuning(SpiQuery<?> query) {
|
||||
|
||||
Boolean autoFetch = query.isAutofetch();
|
||||
if (autoFetch != null) {
|
||||
Boolean autoTune = query.isAutoTune();
|
||||
if (autoTune != null) {
|
||||
// explicitly set...
|
||||
return autoFetch;
|
||||
return autoTune;
|
||||
|
||||
} else {
|
||||
// determine using implicit mode...
|
||||
@@ -163,7 +163,7 @@ public class BaseQueryTuner {
|
||||
return query.isDetailEmpty();
|
||||
|
||||
default:
|
||||
throw new PersistenceException("Invalid autoFetchMode " + mode);
|
||||
throw new PersistenceException("Invalid AutoTuneMode " + mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebean.bean.ObjectGraphOrigin;
|
||||
import com.avaje.ebean.config.AutoTuneConfig;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.autofetch.model.Autotune;
|
||||
import com.avaje.ebeaninternal.server.autofetch.model.Origin;
|
||||
import com.avaje.ebeaninternal.server.autofetch.model.ProfileDiff;
|
||||
import com.avaje.ebeaninternal.server.autofetch.model.ProfileNew;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.autotune.model.Autotune;
|
||||
import com.avaje.ebeaninternal.server.autotune.model.Origin;
|
||||
import com.avaje.ebeaninternal.server.autotune.model.ProfileDiff;
|
||||
import com.avaje.ebeaninternal.server.autotune.model.ProfileNew;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetailParser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebean.bean.NodeUsageCollector;
|
||||
import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
@@ -6,8 +6,8 @@ import com.avaje.ebean.bean.ObjectGraphOrigin;
|
||||
import com.avaje.ebean.config.AutoTuneConfig;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.autofetch.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.util.Map;
|
||||
+2
-4
@@ -1,11 +1,11 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebean.bean.NodeUsageCollector;
|
||||
import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
import com.avaje.ebean.bean.ObjectGraphOrigin;
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import com.avaje.ebean.text.PathProperties.Props;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
|
||||
@@ -16,8 +16,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class ProfileOrigin {
|
||||
|
||||
//private static final Logger logger = LoggerFactory.getLogger(ProfileOrigin.class);
|
||||
|
||||
private static final long RESET_COUNT = -1000000000L;
|
||||
|
||||
private final ObjectGraphOrigin origin;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebean.bean.NodeUsageCollector;
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
@@ -70,7 +70,7 @@ public class ProfileOriginNodeUsage {
|
||||
} else {
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (beanProp.isLob() && !beanProp.isFetchEager()) {
|
||||
// AutoFetch will not include Lob's marked FetchLazy
|
||||
// AutoTune will not include Lob's marked FetchLazy
|
||||
// (which is the default for Lob's so typical).
|
||||
} else {
|
||||
pathProps.addToPath(path, beanProp.getName());
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneCollection;
|
||||
import com.avaje.ebeaninternal.server.util.LongAdder;
|
||||
|
||||
import java.io.Serializable;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.avaje.ebeaninternal.server.autofetch.service;
|
||||
package com.avaje.ebeaninternal.server.autotune.service;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
@@ -44,7 +44,7 @@ public class TunedQueryInfo implements Serializable {
|
||||
tuned = query.tuneFetchProperties(tunedDetail);
|
||||
}
|
||||
if (tuned) {
|
||||
query.setAutoFetchTuned(true);
|
||||
query.setAutoTuned(true);
|
||||
}
|
||||
return tuned;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class DefaultBeanLoader {
|
||||
query.select("id," + embeddedBeanPropertyName);
|
||||
}
|
||||
|
||||
// don't collect autoFetch usage profiling information
|
||||
// don't collect AutoTune usage profiling information
|
||||
// as we just copy the data out of these fetched beans
|
||||
// and put the data into the original bean
|
||||
query.setUsageProfiling(false);
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.avaje.ebeaninternal.api.SpiQuery.Type;
|
||||
import com.avaje.ebeaninternal.api.SpiSqlQuery;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.api.TransactionEventTable;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
@@ -222,7 +222,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
this.queryEngine = config.createOrmQueryEngine();
|
||||
this.relationalQueryEngine = config.createRelationalQueryEngine();
|
||||
|
||||
this.autoTuneService = config.createAutoFetchManager(this);
|
||||
this.autoTuneService = config.createAutoTuneService(this);
|
||||
this.readAuditPrepare = config.getReadAuditPrepare();
|
||||
this.readAuditLogger = config.getReadAuditLogger();
|
||||
|
||||
@@ -402,7 +402,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
shutdownPlugins();
|
||||
|
||||
// shutdown autofetch profile collection
|
||||
autoTuneService.shutdown();
|
||||
// shutdown background threads
|
||||
backgroundExecutor.shutdown();
|
||||
|
||||
@@ -15,8 +15,8 @@ import com.avaje.ebean.plugin.SpiServerPlugin;
|
||||
import com.avaje.ebean.text.json.JsonContext;
|
||||
import com.avaje.ebeaninternal.api.SpiBackgroundExecutor;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.autofetch.service.AutoTuneServiceFactory;
|
||||
import com.avaje.ebeaninternal.server.autotune.AutoTuneService;
|
||||
import com.avaje.ebeaninternal.server.autotune.service.AutoTuneServiceFactory;
|
||||
import com.avaje.ebeaninternal.server.changelog.DefaultChangeLogListener;
|
||||
import com.avaje.ebeaninternal.server.changelog.DefaultChangeLogPrepare;
|
||||
import com.avaje.ebeaninternal.server.changelog.DefaultChangeLogRegister;
|
||||
@@ -248,7 +248,7 @@ public class InternalConfiguration {
|
||||
return xmlConfig;
|
||||
}
|
||||
|
||||
public AutoTuneService createAutoFetchManager(SpiEbeanServer server) {
|
||||
public AutoTuneService createAutoTuneService(SpiEbeanServer server) {
|
||||
return AutoTuneServiceFactory.create(server, serverConfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements BeanQueryRe
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the query plan hash AFTER any potential AutoFetch tuning.
|
||||
* Calculate the query plan hash AFTER any potential AutoTune tuning.
|
||||
*/
|
||||
public void calculateQueryPlanHash() {
|
||||
this.queryPlanHash = query.queryPlanHash(this);
|
||||
|
||||
@@ -42,10 +42,10 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return true if we are profiling this query.
|
||||
*/
|
||||
boolean isAutoFetchProfiling();
|
||||
boolean isAutoTuneProfiling();
|
||||
|
||||
/**
|
||||
* Add autoFetch profiling for a loaded entity bean.
|
||||
* Add AutoTune profiling for a loaded entity bean.
|
||||
*/
|
||||
void profileBean(EntityBeanIntercept ebi, String prefix);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class AllEqualsExpression implements SpiExpression {
|
||||
* The null check is required due to the "is null" sql being generated.
|
||||
* </p>
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
|
||||
builder.add(AllEqualsExpression.class);
|
||||
|
||||
@@ -97,7 +97,7 @@ class AllEqualsExpression implements SpiExpression {
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -31,13 +31,13 @@ class BetweenExpression extends AbstractExpression {
|
||||
request.append(getPropertyName()).append(BETWEEN).append(" ? and ? ");
|
||||
}
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(BetweenExpression.class).add(propName);
|
||||
builder.bind(2);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
+2
-2
@@ -53,13 +53,13 @@ class BetweenPropertyExpression implements SpiExpression {
|
||||
request.append(" ? ").append(BETWEEN).append(name(lowProperty)).append(" and ").append(name(highProperty));
|
||||
}
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(BetweenPropertyExpression.class).add(lowProperty).add(highProperty);
|
||||
builder.bind(1);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
+2
-2
@@ -41,13 +41,13 @@ class CaseInsensitiveEqualExpression extends AbstractExpression {
|
||||
request.append("lower(").append(pname).append(") =? ");
|
||||
}
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(CaseInsensitiveEqualExpression.class).add(propName);
|
||||
builder.bind(1);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
+2
-2
@@ -153,9 +153,9 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hash for autoFetch query identification.
|
||||
* Return a hash for AutoTune query identification.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
// we have not yet built the list of expressions
|
||||
// so just based on the class name
|
||||
builder.add(DefaultExampleExpression.class);
|
||||
|
||||
@@ -27,10 +27,10 @@ public class ExistsExpression implements SpiExpression {
|
||||
this.not = not;
|
||||
}
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(ExistsExpression.class).add(not);
|
||||
|
||||
subQuery.queryAutofetchHash(builder);
|
||||
subQuery.queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
@@ -39,7 +39,7 @@ public class ExistsExpression implements SpiExpression {
|
||||
// ... so compiledQuery will exist
|
||||
compiledSubQuery = compileSubQuery(request);
|
||||
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,13 +50,13 @@ class IdExpression implements SpiExpression {
|
||||
/**
|
||||
* No properties so this is just a unique static number.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(IdExpression.class);
|
||||
builder.bind(1);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -68,13 +68,13 @@ public class IdInExpression implements SpiExpression {
|
||||
/**
|
||||
* Incorporates the number of Id values to bind.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(IdInExpression.class).add(idList.size());
|
||||
builder.bind(idList.size());
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -90,13 +90,13 @@ class InExpression extends AbstractExpression {
|
||||
/**
|
||||
* Based on the number of values in the in clause.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(InExpression.class).add(propName).add(values.length).add(not);
|
||||
builder.bind(values.length);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -28,9 +28,9 @@ class InQueryExpression extends AbstractExpression {
|
||||
this.not = not;
|
||||
}
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(InQueryExpression.class).add(propName).add(not);
|
||||
subQuery.queryAutofetchHash(builder);
|
||||
subQuery.queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
@@ -39,7 +39,7 @@ class InQueryExpression extends AbstractExpression {
|
||||
// ... so compiledQuery will exist
|
||||
compiledSubQuery = compileSubQuery(request);
|
||||
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -129,11 +129,11 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
|
||||
* Based on Junction type and all the expression contained.
|
||||
*/
|
||||
@Override
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(JunctionExpression.class).add(joinType);
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).queryAutoFetchHash(builder);
|
||||
list.get(i).queryAutoTuneHash(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,13 @@ class LikeExpression extends AbstractExpression {
|
||||
/**
|
||||
* Based on caseInsensitive and the property name.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(LikeExpression.class).add(caseInsensitive).add(propName);
|
||||
builder.bind(1);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -70,10 +70,10 @@ abstract class LogicExpression implements SpiExpression {
|
||||
/**
|
||||
* Based on the joinType plus the two expressions.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(LogicExpression.class).add(joinType);
|
||||
expOne.queryAutoFetchHash(builder);
|
||||
expTwo.queryAutoFetchHash(builder);
|
||||
expOne.queryAutoTuneHash(builder);
|
||||
expTwo.queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
|
||||
@@ -20,13 +20,13 @@ class NoopExpression implements SpiExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(NoopExpression.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,9 +37,9 @@ final class NotExpression implements SpiExpression {
|
||||
/**
|
||||
* Based on the expression.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(NotExpression.class);
|
||||
exp.queryAutoFetchHash(builder);
|
||||
exp.queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
|
||||
@@ -42,12 +42,12 @@ class NullExpression extends AbstractExpression {
|
||||
/**
|
||||
* Based on notNull flag and the propertyName.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(NullExpression.class).add(notNull).add(propName);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -39,12 +39,12 @@ class RawExpression implements SpiExpression {
|
||||
/**
|
||||
* Based on the sql.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(RawExpression.class).add(sql);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -86,13 +86,13 @@ public class SimpleExpression extends AbstractExpression {
|
||||
/**
|
||||
* Based on the type and propertyName.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(SimpleExpression.class).add(propName).add(type.name());
|
||||
builder.bind(1);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContex
|
||||
queryProps.configureBeanQuery(query);
|
||||
}
|
||||
if (parent.isUseAutoTune()) {
|
||||
query.setAutofetch(true);
|
||||
query.setAutoTune(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DLoadManyContext extends DLoadBaseContext implements LoadManyContex
|
||||
}
|
||||
|
||||
if (parent.isUseAutoTune()) {
|
||||
query.setAutofetch(true);
|
||||
query.setAutoTune(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ public final class DefaultPersister implements Persister {
|
||||
for (int i = 0; i < propImportDelete.length; i++) {
|
||||
sb.append(propImportDelete[i].getName()).append(",");
|
||||
}
|
||||
q.setAutofetch(false);
|
||||
q.setAutoTune(false);
|
||||
q.select(sb.toString());
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DeleteUnloadedForeignKeys {
|
||||
// run query in a separate persistence context
|
||||
q.setPersistenceContext(new DefaultPersistenceContext());
|
||||
q.setPersistenceContextScope(PersistenceContextScope.QUERY);
|
||||
q.setAutofetch(false);
|
||||
q.setAutoTune(false);
|
||||
q.select(sb.toString());
|
||||
q.where().idEq(id);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.avaje.ebean.event.readaudit.ReadEvent;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery.Mode;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.server.autofetch.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.core.Message;
|
||||
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest;
|
||||
@@ -673,7 +673,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
* This is true for all queries except lazy load bean queries.
|
||||
* </p>
|
||||
*/
|
||||
public boolean isAutoFetchProfiling() {
|
||||
public boolean isAutoTuneProfiling() {
|
||||
// need query.isProfiling() because we just take the data
|
||||
// from the lazy loaded or refreshed beans and put it into the already
|
||||
// existing beans which are already collecting usage information
|
||||
|
||||
@@ -404,7 +404,7 @@ public class CQueryEngine {
|
||||
msg.append("mode[").append(loadMode).append("] ");
|
||||
}
|
||||
msg.append("type[").append(q.getBeanName()).append("] ");
|
||||
if (query.isAutofetchTuned()) {
|
||||
if (query.isAutoTuned()) {
|
||||
msg.append("tuned[true] ");
|
||||
}
|
||||
if (originKey != null) {
|
||||
@@ -447,7 +447,7 @@ public class CQueryEngine {
|
||||
msg.append("mode[").append(loadMode).append("] ");
|
||||
}
|
||||
msg.append("type[").append(q.getBeanName()).append("] ");
|
||||
if (query.isAutofetchTuned()) {
|
||||
if (query.isAutoTuned()) {
|
||||
msg.append("tuned[true] ");
|
||||
}
|
||||
if (originKey != null) {
|
||||
|
||||
@@ -250,7 +250,7 @@ public class CQueryFetchIds {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAutoFetchProfiling() {
|
||||
public boolean isAutoTuneProfiling() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CQueryPlan {
|
||||
|
||||
private final SpiEbeanServer server;
|
||||
|
||||
private final boolean autofetchTuned;
|
||||
private final boolean autoTuned;
|
||||
|
||||
private final HashQueryPlan hash;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class CQueryPlan {
|
||||
this.beanType = request.getBeanDescriptor().getBeanType();
|
||||
this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins());
|
||||
this.hash = request.getQueryPlanHash();
|
||||
this.autofetchTuned = request.getQuery().isAutofetchTuned();
|
||||
this.autoTuned = request.getQuery().isAutoTuned();
|
||||
if (sqlRes != null) {
|
||||
this.sql = sqlRes.getSql();
|
||||
this.rowNumberIncluded = sqlRes.isIncludesRowNumberColumn();
|
||||
@@ -104,7 +104,7 @@ public class CQueryPlan {
|
||||
this.beanType = request.getBeanDescriptor().getBeanType();
|
||||
this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins());
|
||||
this.hash = buildHash(sql, rawSql, rowNumberIncluded, logWhereSql);
|
||||
this.autofetchTuned = false;
|
||||
this.autoTuned = false;
|
||||
this.sql = sql;
|
||||
this.sqlTree = sqlTree;
|
||||
this.rawSql = rawSql;
|
||||
@@ -143,8 +143,8 @@ public class CQueryPlan {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAutofetchTuned() {
|
||||
return autofetchTuned;
|
||||
public boolean isAutoTuned() {
|
||||
return autoTuned;
|
||||
}
|
||||
|
||||
public HashQueryPlan getHash() {
|
||||
|
||||
@@ -226,8 +226,8 @@ public final class CQueryPlanStats {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutofetchTuned() {
|
||||
return queryPlan.isAutofetchTuned();
|
||||
public boolean isAutoTuned() {
|
||||
return queryPlan.isAutoTuned();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -326,8 +326,8 @@ public class SqlTreeNodeBean implements SqlTreeNode {
|
||||
ebi.setFullyLoadedBean(true);
|
||||
}
|
||||
|
||||
if (ctx.isAutoFetchProfiling() && !disableLazyLoad) {
|
||||
// collect autofetch profiling for this bean...
|
||||
if (ctx.isAutoTuneProfiling() && !disableLazyLoad) {
|
||||
// collect autoTune profiling for this bean...
|
||||
ctx.profileBean(ebi, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionList;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.autofetch.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.deploy.DRawSqlSelect;
|
||||
@@ -199,7 +199,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
/**
|
||||
* Allow for explicit on off or null for default.
|
||||
*/
|
||||
private Boolean autoFetch;
|
||||
private Boolean autoTune;
|
||||
|
||||
/**
|
||||
* Allow to fetch a record "for update" which should lock it on read
|
||||
@@ -207,9 +207,9 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
private boolean forUpdate;
|
||||
|
||||
/**
|
||||
* Set to true if this query has been tuned by autoFetch.
|
||||
* Set to true if this query has been tuned by autoTune.
|
||||
*/
|
||||
private boolean autoFetchTuned;
|
||||
private boolean autoTuned;
|
||||
|
||||
private boolean logSecondaryQuery;
|
||||
|
||||
@@ -228,7 +228,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
private BeanPropertyAssocMany<?> lazyLoadForParentsProperty;
|
||||
|
||||
/**
|
||||
* Hash of final query after AutoFetch tuning.
|
||||
* Hash of final query after AutoTune tuning.
|
||||
*/
|
||||
private HashQueryPlan queryPlanHash;
|
||||
|
||||
@@ -477,13 +477,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
public DefaultOrmQuery<T> copy(EbeanServer server) {
|
||||
// Not including these in the copy:
|
||||
// contextAdditions
|
||||
// queryListener
|
||||
// transactionContext
|
||||
// autoFetchTuned
|
||||
// autoFetchQueryPlanHash
|
||||
// copy.generatedSql
|
||||
|
||||
DefaultOrmQuery<T> copy = new DefaultOrmQuery<T>(beanType, server, expressionFactory, (String) null);
|
||||
copy.name = name;
|
||||
@@ -524,7 +517,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
copy.persistenceContextScope = persistenceContextScope;
|
||||
copy.usageProfiling = usageProfiling;
|
||||
copy.autoFetch = autoFetch;
|
||||
copy.autoTune = autoTune;
|
||||
copy.parentNode = parentNode;
|
||||
copy.forUpdate = forUpdate;
|
||||
copy.rawSql = rawSql;
|
||||
@@ -602,24 +595,24 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return detail.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isAutofetchTuned() {
|
||||
return autoFetchTuned;
|
||||
public boolean isAutoTuned() {
|
||||
return autoTuned;
|
||||
}
|
||||
|
||||
public void setAutoFetchTuned(boolean autoFetchTuned) {
|
||||
this.autoFetchTuned = autoFetchTuned;
|
||||
public void setAutoTuned(boolean autoTuned) {
|
||||
this.autoTuned = autoTuned;
|
||||
}
|
||||
|
||||
public Boolean isAutofetch() {
|
||||
return sqlSelect ? Boolean.FALSE : autoFetch;
|
||||
public Boolean isAutoTune() {
|
||||
return sqlSelect ? Boolean.FALSE : autoTune;
|
||||
}
|
||||
|
||||
public boolean isForUpdate() {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
public DefaultOrmQuery<T> setAutofetch(boolean autoFetch) {
|
||||
this.autoFetch = autoFetch;
|
||||
public DefaultOrmQuery<T> setAutoTune(boolean autoTune) {
|
||||
this.autoTune = autoTune;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -721,7 +714,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the query hash for either AutoFetch query tuning or Query Plan caching.
|
||||
* Calculate the query hash for either AutoTune query tuning or Query Plan caching.
|
||||
*/
|
||||
private HashQueryPlan calculateHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
|
||||
@@ -732,7 +725,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
builder.add((type == null ? 0 : type.ordinal() + 1));
|
||||
builder.add(autoFetchTuned).add(distinct).add(sqlDistinct).add(query);
|
||||
builder.add(autoTuned).add(distinct).add(sqlDistinct).add(query);
|
||||
builder.add(firstRow).add(maxRows).add(orderBy).add(forUpdate);
|
||||
builder.add(rawWhereClause).add(additionalWhere).add(additionalHaving);
|
||||
builder.add(mapKey);
|
||||
@@ -752,13 +745,13 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
if (request == null) {
|
||||
// for AutoFetch...
|
||||
// for AutoTune...
|
||||
builder.add(true);
|
||||
if (whereExpressions != null) {
|
||||
whereExpressions.queryAutoFetchHash(builder);
|
||||
whereExpressions.queryAutoTuneHash(builder);
|
||||
}
|
||||
if (havingExpressions != null) {
|
||||
havingExpressions.queryAutoFetchHash(builder);
|
||||
havingExpressions.queryAutoTuneHash(builder);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -776,10 +769,10 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate a hash used by AutoFetch to identify when a query has changed (and hence potentially
|
||||
* 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 queryAutofetchHash(HashQueryPlanBuilder builder) {
|
||||
public HashQueryPlan queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
|
||||
return calculateHash(null, builder);
|
||||
}
|
||||
@@ -790,7 +783,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
* This can used to enable the caching and reuse of a 'query plan'.
|
||||
* </p>
|
||||
* <p>
|
||||
* This is calculated AFTER AutoFetch query tuning has occurred.
|
||||
* This is calculated AFTER AutoTune query tuning has occurred.
|
||||
* </p>
|
||||
*/
|
||||
public HashQueryPlan queryPlanHash(BeanQueryRequest<?> request) {
|
||||
@@ -824,7 +817,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
* </p>
|
||||
*/
|
||||
public HashQuery queryHash() {
|
||||
// calculateQueryPlanHash is called just after potential AutoFetch tuning
|
||||
// calculateQueryPlanHash is called just after potential AutoTune tuning
|
||||
// so queryPlanHash is calculated well before this method is called
|
||||
int hc = queryBindHash();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.avaje.ebeaninternal.server.query.SplitName;
|
||||
* Holds the select() and join() details of a ORM query.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is worth noting that for autoFetch a "tuned fetch info" builds an instance of OrmQueryDetail.
|
||||
* It is worth noting that for AutoTune a "tuned fetch info" builds an instance of OrmQueryDetail.
|
||||
* Tuning a query is a matter of replacing an instance of this class with one that has been tuned
|
||||
* with select() and join() set.
|
||||
* </p>
|
||||
|
||||
@@ -5,7 +5,7 @@ import javax.persistence.PersistenceException;
|
||||
/**
|
||||
* Parses a Object relational query statement into a OrmQueryDetail and OrmQueryAttributes.
|
||||
* <p>
|
||||
* The reason they are split into detail and attributes is that the autoFetch feature is used to
|
||||
* The reason they are split into detail and attributes is that the AutoTune feature is used to
|
||||
* replace the OrmQueryDetail leaving the attributes unchanged.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
@@ -212,7 +212,7 @@ public class OrmQueryProperties implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties from a matching autofetch tuned properties.
|
||||
* Set the properties from a matching AutoTune tuned properties.
|
||||
*/
|
||||
public void setTunedProperties(OrmQueryProperties tunedProperties) {
|
||||
if (tunedProperties.hasProperties()) {
|
||||
@@ -318,7 +318,7 @@ public class OrmQueryProperties implements Serializable {
|
||||
secondaryChildren.add(child);
|
||||
}
|
||||
|
||||
public int autofetchPlanHash() {
|
||||
public int autoTunePlanHash() {
|
||||
|
||||
int hc = (path != null ? path.hashCode() : 1);
|
||||
if (properties != null) {
|
||||
|
||||
@@ -330,11 +330,11 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
* Calculate a hash based on the expressions but excluding the actual bind
|
||||
* values.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
public void queryAutoTuneHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(DefaultExpressionList.class);
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
SpiExpression expression = list.get(i);
|
||||
expression.queryAutoFetchHash(builder);
|
||||
expression.queryAutoTuneHash(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user