You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2015/07/07 15:10:35 UTC
svn commit: r1689652 - in /lucene/dev/trunk/solr: CHANGES.txt
core/src/java/org/apache/solr/handler/component/QueryComponent.java
Author: andyetitmoves
Date: Tue Jul 7 13:10:34 2015
New Revision: 1689652
URL: http://svn.apache.org/r1689652
Log:
SOLR-7751: Minor optimizations to QueryComponent.process
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1689652&r1=1689651&r2=1689652&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Jul 7 13:10:34 2015
@@ -221,6 +221,9 @@ Optimizations
from one for each shard and the federator, to just one for the federator.
(Christine Poerschke via Ramkumar Aiyengar)
+* SOLR-7751: Minor optimizations to QueryComponent.process (reduce eager instantiations,
+ cache method calls) (Christine Poerschke via Ramkumar Aiyengar)
+
Other Changes
----------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1689652&r1=1689651&r2=1689652&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java Tue Jul 7 13:10:34 2015
@@ -297,7 +297,6 @@ public class QueryComponent extends Sear
LOG.debug("process: {}", rb.req.getParams());
SolrQueryRequest req = rb.req;
- SolrQueryResponse rsp = rb.rsp;
SolrParams params = req.getParams();
if (!params.getBool(COMPONENT_NAME, true)) {
return;
@@ -317,13 +316,8 @@ public class QueryComponent extends Sear
statsCache.receiveGlobalStats(req);
}
- // -1 as flag if not set.
- long timeAllowed = params.getLong(CommonParams.TIME_ALLOWED, -1L);
- if (null != rb.getCursorMark() && 0 < timeAllowed) {
- // fundamentally incompatible
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Can not search using both " +
- CursorMarkParams.CURSOR_MARK_PARAM + " and " + CommonParams.TIME_ALLOWED);
- }
+ SolrQueryResponse rsp = rb.rsp;
+ IndexSchema schema = searcher.getSchema();
// Optional: This could also be implemented by the top-level searcher sending
// a filter that lists the ids... that would be transparent to
@@ -331,12 +325,12 @@ public class QueryComponent extends Sear
// too if desired).
String ids = params.get(ShardParams.IDS);
if (ids != null) {
- SchemaField idField = searcher.getSchema().getUniqueKeyField();
+ SchemaField idField = schema.getUniqueKeyField();
List<String> idArr = StrUtils.splitSmart(ids, ",", true);
int[] luceneIds = new int[idArr.size()];
int docs = 0;
for (int i=0; i<idArr.size(); i++) {
- int id = req.getSearcher().getFirstMatch(
+ int id = searcher.getFirstMatch(
new Term(idField.getName(), idField.getType().toInternal(idArr.get(i))));
if (id >= 0)
luceneIds[docs++] = id;
@@ -361,6 +355,14 @@ public class QueryComponent extends Sear
return;
}
+ // -1 as flag if not set.
+ long timeAllowed = params.getLong(CommonParams.TIME_ALLOWED, -1L);
+ if (null != rb.getCursorMark() && 0 < timeAllowed) {
+ // fundamentally incompatible
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Can not search using both " +
+ CursorMarkParams.CURSOR_MARK_PARAM + " and " + CommonParams.TIME_ALLOWED);
+ }
+
SolrIndexSearcher.QueryCommand cmd = rb.getQueryCommand();
cmd.setTimeAllowed(timeAllowed);
@@ -384,7 +386,7 @@ public class QueryComponent extends Sear
for (String field : groupingSpec.getFields()) {
topsGroupsActionBuilder.addCommandField(new SearchGroupsFieldCommand.Builder()
- .setField(searcher.getSchema().getField(field))
+ .setField(schema.getField(field))
.setGroupSort(groupingSpec.getGroupSort())
.setTopNGroups(cmd.getOffset() + cmd.getLen())
.setIncludeGroupCount(groupingSpec.isIncludeGroupCount())
@@ -406,6 +408,7 @@ public class QueryComponent extends Sear
.setSearcher(searcher);
for (String field : groupingSpec.getFields()) {
+ SchemaField schemaField = schema.getField(field);
String[] topGroupsParam = params.getParams(GroupParams.GROUP_DISTRIBUTED_TOPGROUPS_PREFIX + field);
if (topGroupsParam == null) {
topGroupsParam = new String[0];
@@ -415,14 +418,14 @@ public class QueryComponent extends Sear
for (String topGroup : topGroupsParam) {
SearchGroup<BytesRef> searchGroup = new SearchGroup<>();
if (!topGroup.equals(TopGroupsShardRequestFactory.GROUP_NULL_VALUE)) {
- searchGroup.groupValue = new BytesRef(searcher.getSchema().getField(field).getType().readableToIndexed(topGroup));
+ searchGroup.groupValue = new BytesRef(schemaField.getType().readableToIndexed(topGroup));
}
topGroups.add(searchGroup);
}
secondPhaseBuilder.addCommandField(
new TopGroupsFieldCommand.Builder()
- .setField(searcher.getSchema().getField(field))
+ .setField(schemaField)
.setGroupSort(groupingSpec.getGroupSort())
.setSortWithinGroup(groupingSpec.getSortWithinGroup())
.setFirstPhaseGroups(topGroups)