#411 - Refactor AutoFetch, rename to "AutoTune", store/load tuning and profiling as XML

This commit is contained in:
Robin Bygrave committed 2015-09-10 23:20:57 +12:00
1 parent 9632279c2f
commit 0a8c902790
111 files changed
+255 -341

No files matched your search

@@ -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;
@@ -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,4 +1,4 @@
package com.avaje.ebeaninternal.server.autofetch;
package com.avaje.ebeaninternal.server.autotune;
/**
*
@@ -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,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,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,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,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,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,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;
@@ -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 {
@@ -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;
@@ -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;
@@ -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);
}
}
}
@@ -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;
@@ -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;
@@ -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;
@@ -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());
@@ -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;
@@ -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() {
@@ -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() {
@@ -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() {
@@ -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) {