[jOOQ/jOOQ#7527] Added consecutiveAggregation()
This commit is contained in:
parent
8c8efd6042
commit
5bed0b0e88
@ -53,7 +53,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface DiagnosticsContext extends Scope {
|
||||
|
||||
/**
|
||||
* The object that was diagnosed if available, or <code>null</code>, if there was no specific {@link QueryPart} to attach the diagnostic to.
|
||||
* The object that was diagnosed if available, or <code>null</code>, if
|
||||
* there was no specific {@link QueryPart} to attach the diagnostic to.
|
||||
*/
|
||||
@Nullable
|
||||
QueryPart part();
|
||||
@ -94,8 +95,8 @@ public interface DiagnosticsContext extends Scope {
|
||||
int resultSetFetchedRows();
|
||||
|
||||
/**
|
||||
* The number of columns that were consumed from the {@link #resultSet()}, or
|
||||
* <code>-1</code> if there was no result set.
|
||||
* The number of columns that were consumed from the {@link #resultSet()},
|
||||
* or <code>-1</code> if there was no result set.
|
||||
* <p>
|
||||
* If the result set is still being consumed (i.e. prior to the
|
||||
* {@link ResultSet#close()} call), then this will return the number of
|
||||
@ -111,8 +112,8 @@ public interface DiagnosticsContext extends Scope {
|
||||
int resultSetFetchedColumnCount();
|
||||
|
||||
/**
|
||||
* The number of columns that were consumed from the {@link #resultSet()}, or
|
||||
* <code>-1</code> if there was no result set.
|
||||
* The number of columns that were consumed from the {@link #resultSet()},
|
||||
* or <code>-1</code> if there was no result set.
|
||||
* <p>
|
||||
* If the result set is still being consumed (i.e. prior to the
|
||||
* {@link ResultSet#close()} call), then this will return the number of
|
||||
@ -174,6 +175,11 @@ public interface DiagnosticsContext extends Scope {
|
||||
/**
|
||||
* The duplicate statements that all correspond to a single normalised
|
||||
* statement.
|
||||
* <p>
|
||||
* This set is used by at least:
|
||||
* <ul>
|
||||
* <li>{@link DiagnosticsListener#duplicateStatements(DiagnosticsContext)}</li>
|
||||
* </ul>
|
||||
*/
|
||||
@NotNull
|
||||
Set<String> duplicateStatements();
|
||||
@ -181,6 +187,12 @@ public interface DiagnosticsContext extends Scope {
|
||||
/**
|
||||
* The repeated statements that all correspond to a single normalised
|
||||
* statement.
|
||||
* <p>
|
||||
* This set is used by at least:
|
||||
* <ul>
|
||||
* <li>{@link DiagnosticsListener#repeatedStatements(DiagnosticsContext)}</li>
|
||||
* <li>{@link DiagnosticsListener#consecutiveAggregation(DiagnosticsContext)}</li>
|
||||
* </ul>
|
||||
*/
|
||||
@NotNull
|
||||
List<String> repeatedStatements();
|
||||
|
||||
@ -222,6 +222,47 @@ public interface DiagnosticsListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -125,6 +125,8 @@ public class Settings
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsRepeatedStatements = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsConsecutiveAggregation = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsTooManyColumnsFetched = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsTooManyRowsFetched = true;
|
||||
@ -1362,6 +1364,35 @@ public class Settings
|
||||
this.diagnosticsRepeatedStatements = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to run the {@link org.jooq.DiagnosticsListener#consecutiveAggregation(org.jooq.DiagnosticsContext) diagnostic.
|
||||
* <p>
|
||||
* Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured.
|
||||
* Once configured, this diagnostic is turned on by default.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isDiagnosticsConsecutiveAggregation() {
|
||||
return diagnosticsConsecutiveAggregation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the diagnosticsConsecutiveAggregation property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setDiagnosticsConsecutiveAggregation(Boolean value) {
|
||||
this.diagnosticsConsecutiveAggregation = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to run the {@link org.jooq.DiagnosticsListener#tooManyColumnsFetched(org.jooq.DiagnosticsContext) diagnostic.
|
||||
* <p>
|
||||
@ -4869,6 +4900,11 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withDiagnosticsConsecutiveAggregation(Boolean value) {
|
||||
setDiagnosticsConsecutiveAggregation(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withDiagnosticsTooManyColumnsFetched(Boolean value) {
|
||||
setDiagnosticsTooManyColumnsFetched(value);
|
||||
return this;
|
||||
@ -5927,6 +5963,7 @@ public class Settings
|
||||
builder.append("diagnosticsDuplicateStatementsUsingTransformPatterns", diagnosticsDuplicateStatementsUsingTransformPatterns);
|
||||
builder.append("diagnosticsMissingWasNullCall", diagnosticsMissingWasNullCall);
|
||||
builder.append("diagnosticsRepeatedStatements", diagnosticsRepeatedStatements);
|
||||
builder.append("diagnosticsConsecutiveAggregation", diagnosticsConsecutiveAggregation);
|
||||
builder.append("diagnosticsTooManyColumnsFetched", diagnosticsTooManyColumnsFetched);
|
||||
builder.append("diagnosticsTooManyRowsFetched", diagnosticsTooManyRowsFetched);
|
||||
builder.append("diagnosticsUnnecessaryWasNullCall", diagnosticsUnnecessaryWasNullCall);
|
||||
@ -6418,6 +6455,15 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (diagnosticsConsecutiveAggregation == null) {
|
||||
if (other.diagnosticsConsecutiveAggregation!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!diagnosticsConsecutiveAggregation.equals(other.diagnosticsConsecutiveAggregation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (diagnosticsTooManyColumnsFetched == null) {
|
||||
if (other.diagnosticsTooManyColumnsFetched!= null) {
|
||||
return false;
|
||||
@ -7695,6 +7741,7 @@ public class Settings
|
||||
result = ((prime*result)+((diagnosticsDuplicateStatementsUsingTransformPatterns == null)? 0 :diagnosticsDuplicateStatementsUsingTransformPatterns.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsMissingWasNullCall == null)? 0 :diagnosticsMissingWasNullCall.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsRepeatedStatements == null)? 0 :diagnosticsRepeatedStatements.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsConsecutiveAggregation == null)? 0 :diagnosticsConsecutiveAggregation.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsTooManyColumnsFetched == null)? 0 :diagnosticsTooManyColumnsFetched.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsTooManyRowsFetched == null)? 0 :diagnosticsTooManyRowsFetched.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsUnnecessaryWasNullCall == null)? 0 :diagnosticsUnnecessaryWasNullCall.hashCode()));
|
||||
|
||||
@ -38,15 +38,20 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.synchronizedMap;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.FORCE_INDEXED;
|
||||
import static org.jooq.impl.DSL.count;
|
||||
import static org.jooq.impl.DSL.noCondition;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -55,14 +60,17 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jooq.AggregateFunction;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Parser;
|
||||
// ...
|
||||
import org.jooq.Queries;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.RenderContext;
|
||||
// ...
|
||||
import org.jooq.Select;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.impl.QOM.Eq;
|
||||
import org.jooq.tools.jdbc.DefaultConnection;
|
||||
@ -73,15 +81,16 @@ import org.jooq.tools.jdbc.DefaultConnection;
|
||||
final class DiagnosticsConnection extends DefaultConnection {
|
||||
|
||||
// TODO: Make these configurable
|
||||
static final int LRU_SIZE_GLOBAL = 50000;
|
||||
static final int LRU_SIZE_LOCAL = 500;
|
||||
static final int DUP_SIZE = 500;
|
||||
static final int LRU_SIZE_GLOBAL = 50000;
|
||||
static final int LRU_SIZE_LOCAL = 500;
|
||||
static final int DUP_SIZE = 500;
|
||||
|
||||
final Map<String, List<String>> repeatedSQL = new LRU<>(LRU_SIZE_LOCAL);
|
||||
final Configuration configuration;
|
||||
final RenderContext normalisingRenderer;
|
||||
final Parser parser;
|
||||
final DiagnosticsListeners listeners;
|
||||
final Map<String, List<String>> repeatedSQL = new LRU<>(LRU_SIZE_LOCAL);
|
||||
final Map<String, List<String>> consecutiveAgg = new LRU<>(LRU_SIZE_LOCAL);
|
||||
final Configuration configuration;
|
||||
final RenderContext normalisingRenderer;
|
||||
final Parser parser;
|
||||
final DiagnosticsListeners listeners;
|
||||
|
||||
DiagnosticsConnection(Configuration configuration) {
|
||||
super(configuration.connectionProvider().acquire());
|
||||
@ -223,6 +232,7 @@ final class DiagnosticsConnection extends DefaultConnection {
|
||||
));
|
||||
}
|
||||
|
||||
if (queries != null) {
|
||||
|
||||
|
||||
|
||||
@ -248,6 +258,22 @@ final class DiagnosticsConnection extends DefaultConnection {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Error e) {
|
||||
throw e;
|
||||
|
||||
@ -121,6 +121,13 @@ final class DiagnosticsListeners implements DiagnosticsListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -313,6 +313,15 @@ Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListen
|
||||
Once configured, this diagnostic is turned on by default.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="diagnosticsConsecutiveAggregation" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether to run the {@link org.jooq.DiagnosticsListener#consecutiveAggregation(org.jooq.DiagnosticsContext) diagnostic.
|
||||
<p>
|
||||
Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured.
|
||||
Once configured, this diagnostic is turned on by default.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="diagnosticsTooManyColumnsFetched" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether to run the {@link org.jooq.DiagnosticsListener#tooManyColumnsFetched(org.jooq.DiagnosticsContext) diagnostic.
|
||||
<p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user