diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-01-08 12:33:15 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-01-08 12:33:15 +0100 |
commit | 2091f9f141a8ec47fd81aae413ee51f9d8a86c98 (patch) | |
tree | 1267c85ca4993961b8359f18964e09a85cb48c30 /vespaclient-container-plugin | |
parent | 5e8c5a3c96de79f24be3edda651d08128d98e357 (diff) |
Use compundname for faster processing and no need to validate non-indexed id= as long as they are ignored anyway.
Diffstat (limited to 'vespaclient-container-plugin')
2 files changed, 18 insertions, 10 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/GetSearcher.java b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/GetSearcher.java index afae7211b64..5405f33f1aa 100755 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/GetSearcher.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/GetSearcher.java @@ -63,6 +63,14 @@ public class GetSearcher extends Searcher { private static final Logger log = Logger.getLogger(GetSearcher.class.getName()); + private static final CompoundName ID = new CompoundName("id"); + private static final CompoundName HEADERS_ONLY = new CompoundName("headersonly"); + private static final CompoundName POPULATE_HIT_FIELDS = new CompoundName("populatehitfields"); + private static final CompoundName FIELDSET = new CompoundName("fieldset"); + private static final CompoundName FIELD = new CompoundName("field"); + private static final CompoundName CONTENT_TYPE = new CompoundName("contenttype"); + private static final CompoundName TIEMOUT = new CompoundName("timeout"); + FeedContext context; private final long defaultTimeoutMillis; @@ -195,7 +203,7 @@ public class GetSearcher extends Searcher { this.defaultTimeoutMillis = defaultTimeoutMillis; } - private void postValidateDocumentIdParameters(Properties properties, int arrayIdsFound) throws Exception { + private static void postValidateDocumentIdParameters(Properties properties, int arrayIdsFound) throws Exception { for (Map.Entry<String, Object> kv : properties.listProperties().entrySet()) { if (!kv.getKey().startsWith("id[")) { continue; @@ -218,7 +226,7 @@ public class GetSearcher extends Searcher { // First check for regular "id=XX" syntax. If found, return vector with that // document id only - String singleId = properties.getString("id"); + String singleId = properties.getString(ID); int index = 0; if (singleId != null) { @@ -234,8 +242,8 @@ public class GetSearcher extends Searcher { docIds.add(docId); ++index; } + postValidateDocumentIdParameters(properties, index); } - postValidateDocumentIdParameters(properties, index); handleData(query.getHttpRequest(), docIds); return docIds; @@ -350,12 +358,12 @@ public class GetSearcher extends Searcher { GetResponse response = new GetResponse(documentIds); Properties properties = query.properties(); - boolean headersOnly = properties.getBoolean("headersonly", false); - boolean populateHitFields = properties.getBoolean("populatehitfields", false); - String fieldSet = properties.getString("fieldset"); - String fieldName = properties.getString("field"); - String contentType = properties.getString("contenttype"); - long timeoutMillis = properties.getString("timeout") != null ? query.getTimeout() : defaultTimeoutMillis; + boolean headersOnly = properties.getBoolean(HEADERS_ONLY, false); + boolean populateHitFields = properties.getBoolean(POPULATE_HIT_FIELDS, false); + String fieldSet = properties.getString(FIELDSET); + String fieldName = properties.getString(FIELD); + String contentType = properties.getString(CONTENT_TYPE); + long timeoutMillis = properties.getString(TIEMOUT) != null ? query.getTimeout() : defaultTimeoutMillis; if (fieldSet == null) { fieldSet = headersOnly ? "[header]" : "[all]"; diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java index d762797765b..bdd48949146 100755 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java @@ -477,7 +477,7 @@ public class GetSearcherTestCase { { Result result = new Execution(searchChain, Execution.Context.createContextStub()).search( - newQuery("?id=userdoc:kittens:1:2&id[1]=userdoc:kittens:2:3")); + newQuery("?id[1]=userdoc:kittens:2:3")); assertNotNull(result.hits().getErrorHit()); |