diff options
author | Eike Stepper | 2012-12-30 17:39:31 +0000 |
---|---|---|
committer | Eike Stepper | 2012-12-30 17:39:31 +0000 |
commit | 4b532ef33bc8fcfa968830333130a380496698c1 (patch) | |
tree | 1f9be30cabb7712cff93847b1797a0fd09f3db75 | |
parent | c67e2080c4f2dba075c6f6ebe3150403fec4727b (diff) | |
download | cdo-4b532ef33bc8fcfa968830333130a380496698c1.tar.gz cdo-4b532ef33bc8fcfa968830333130a380496698c1.tar.xz cdo-4b532ef33bc8fcfa968830333130a380496698c1.zip |
[369359] Improve performance of QueryRequest/Indication
https://bugs.eclipse.org/bugs/show_bug.cgi?id=369359
2 files changed, 26 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java index c87ad81216..6a9f6d4e76 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java @@ -20,7 +20,7 @@ import java.util.Map; /** * Encapsulates all the transferrable information that fully specifies a query from a {@link CDOCommonView view} to a * {@link CDOCommonRepository repository}. - * + * * @author Simon McDuff * @since 3.0 * @noextend This interface is not intended to be extended by clients. @@ -31,6 +31,13 @@ public interface CDOQueryInfo public static final int UNLIMITED_RESULTS = -1; /** + * The name of a {@link Boolean} typed {@link #getParameters() parameter} to influence automatic response flushing (the default) after each query result. + * + * @since 4.2 + */ + public static final String PARAM_DISABLE_RESPONSE_FLUSHING = "disable.response.flushing"; + + /** * Returns the language identifier of this query, never <code>null</code>. */ public String getQueryLanguage(); @@ -47,7 +54,7 @@ public interface CDOQueryInfo /** * Returns the context object, or <code>null</code> if no context is bound. - * + * * @since 4.0 */ public Object getContext(); @@ -60,7 +67,7 @@ public interface CDOQueryInfo /** * Returns <code>true</code> if the view of this query had legacy mode enabled at the time this query was created, * <code>false</code> otherwise. - * + * * @since 4.0 */ public boolean isLegacyModeEnabled(); @@ -68,7 +75,7 @@ public interface CDOQueryInfo /** * Returns the {@link CDOChangeSetData change set} to be considered if this query has been created by a dirty * transaction, <code>null</code> otherwise. - * + * * @since 4.0 */ public CDOChangeSetData getChangeSetData(); diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java index f72aed1aab..2748a84269 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java @@ -35,6 +35,8 @@ public class QueryIndication extends CDOServerReadIndication private boolean xrefs; + private boolean disableResponseFlushing; + private InternalQueryResult queryResult; public QueryIndication(CDOServerProtocol protocol) @@ -51,6 +53,9 @@ public class QueryIndication extends CDOServerReadIndication CDOQueryInfo queryInfo = new CDOQueryInfoImpl(in); xrefs = queryInfo.getQueryLanguage().equals(CDOProtocolConstants.QUERY_LANGUAGE_XREFS); + Object param = queryInfo.getParameters().get(CDOQueryInfo.PARAM_DISABLE_RESPONSE_FLUSHING); + disableResponseFlushing = xrefs || Boolean.TRUE.equals(param); + InternalQueryManager queryManager = getRepository().getQueryManager(); queryResult = queryManager.execute(view, queryInfo); } @@ -60,7 +65,7 @@ public class QueryIndication extends CDOServerReadIndication { // Return queryID immediately. out.writeInt(queryResult.getQueryID()); - flush(); + flushUnlessDisabled(); int numberOfResults = 0; while (queryResult.hasNext()) @@ -83,7 +88,7 @@ public class QueryIndication extends CDOServerReadIndication if (queryResult.peek() == null) { - flush(); + flushUnlessDisabled(); } } @@ -95,4 +100,12 @@ public class QueryIndication extends CDOServerReadIndication // Query is done successfully out.writeBoolean(false); } + + private void flushUnlessDisabled() throws IOException + { + if (!disableResponseFlushing) + { + flush(); + } + } } |