summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java1
-rw-r--r--container-core/src/main/resources/configdefinitions/qr-searchers.def4
-rw-r--r--container-search/src/main/java/com/yahoo/fs4/GetDocSumsPacket.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java1
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/CacheParams.java1
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/ClusterParams.java23
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java162
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java21
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java41
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java14
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java96
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java40
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java57
-rw-r--r--container-search/src/test/java/com/yahoo/fs4/test/FastHitTestCase.java27
-rw-r--r--container-search/src/test/java/com/yahoo/fs4/test/GetDocSumsPacketTestCase.java21
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java20
-rw-r--r--document/src/main/java/com/yahoo/document/GlobalId.java8
23 files changed, 107 insertions, 449 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java
index db81191f0cf..5afba6fa373 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java
@@ -176,7 +176,6 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains>
scB.rankprofiles(new QrSearchersConfig.Searchcluster.Rankprofiles.Builder().configid(sys.getConfigId()));
scB.indexingmode(QrSearchersConfig.Searchcluster.Indexingmode.Enum.valueOf(sys.getIndexingModeName()));
if (sys instanceof IndexedSearchCluster) {
- scB.rowbits(sys.getRowBits());
for (Dispatch tld: ((IndexedSearchCluster)sys).getTLDs()) {
scB.dispatcher(new QrSearchersConfig.Searchcluster.Dispatcher.Builder().
host(tld.getHostname()).
diff --git a/container-core/src/main/resources/configdefinitions/qr-searchers.def b/container-core/src/main/resources/configdefinitions/qr-searchers.def
index a688749da6d..1f2906f45ff 100644
--- a/container-core/src/main/resources/configdefinitions/qr-searchers.def
+++ b/container-core/src/main/resources/configdefinitions/qr-searchers.def
@@ -80,9 +80,7 @@ searchcluster[].storagecluster.routespec string default=""
searchcluster[].dispatcher[].host string
searchcluster[].dispatcher[].port int
-## The number of least significant bits of the part id used to specify the
-## row number (the rest of the bits specifies the column). Don't touch
-## this unless you know why you are doing it.
+## Not used. TODO: Remove on Vespa 7
searchcluster[].rowbits int default=0
# Per dispatcher config-id might be nice to have, remove it until needed.
diff --git a/container-search/src/main/java/com/yahoo/fs4/GetDocSumsPacket.java b/container-search/src/main/java/com/yahoo/fs4/GetDocSumsPacket.java
index c1b0e9ccb37..19f8f9130dc 100644
--- a/container-search/src/main/java/com/yahoo/fs4/GetDocSumsPacket.java
+++ b/container-search/src/main/java/com/yahoo/fs4/GetDocSumsPacket.java
@@ -122,9 +122,6 @@ public class GetDocSumsPacket extends Packet {
Hit h = i.next();
if (h instanceof FastHit) {
FastHit hit = (FastHit)h;
- if (hit.shouldIgnoreRowBits()) {
- flags |= GDFLAG_IGNORE_ROW;
- }
QueryPacketData tag = hit.getQueryPacketData();
if (tag != null) {
this.queryPacketData = tag;
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
index 258f0dec9ff..40364824774 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
@@ -195,7 +195,6 @@ public class ClusterSearcher extends Searcher {
int dispatchIndex) {
return new ClusterParams(searchclusterIndex,
"sc" + searchclusterIndex + ".num" + dispatchIndex,
- searchClusterConfig.rowbits(),
emulConfig);
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/CacheParams.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/CacheParams.java
index ef87f684460..cad055d3512 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/CacheParams.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/CacheParams.java
@@ -9,6 +9,7 @@ package com.yahoo.prelude.fastsearch;
* @author arnej27959
*/
public class CacheParams {
+
public int cacheMegaBytes = 0;
public double cacheTimeOutSeconds = 0;
public CacheControl cacheControl = null;
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/ClusterParams.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/ClusterParams.java
index 54b0b1280f9..f95f303e87c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/ClusterParams.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/ClusterParams.java
@@ -10,32 +10,31 @@ import com.yahoo.container.search.LegacyEmulationConfig;
* @author arnej27959
*/
public class ClusterParams {
+
public final int clusterNumber;
public final String searcherName;
- public final int rowBits;
public final LegacyEmulationConfig emulation;
/**
- * for compatibility
- **/
- public ClusterParams(int number, String name, int rowbits) {
- this(number, name, rowbits, new LegacyEmulationConfig(new LegacyEmulationConfig.Builder()));
+ * For compatibility
+ */
+ public ClusterParams(int number, String name) {
+ this(number, name, new LegacyEmulationConfig(new LegacyEmulationConfig.Builder()));
}
/**
- * for testcases only
- **/
+ * For testcases only
+ */
public ClusterParams(String name) {
- this(0, name, 0);
+ this(0, name);
}
/**
- * make up full ClusterParams
- **/
- public ClusterParams(int number, String name, int rowbits, LegacyEmulationConfig cfg) {
+ * Make up full ClusterParams
+ */
+ public ClusterParams(int number, String name, LegacyEmulationConfig cfg) {
this.clusterNumber = number;
this.searcherName = name;
- this.rowBits = rowbits;
this.emulation = cfg;
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
index b3eaee8698a..288fd084d0b 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
@@ -19,38 +19,20 @@ import com.yahoo.data.access.simple.Value.StringValue;
*/
public class FastHit extends Hit {
- public static final String SUMMARY = "summary"; // TODO: Remove on Vespa 7
+ private static final GlobalId emptyGlobalId = new GlobalId(new byte[GlobalId.LENGTH]);
- private static final long serialVersionUID = 298098891191029589L;
-
- /** The global id of this document in the backend node which produced it */
- private GlobalId globalId = new GlobalId(new byte[GlobalId.LENGTH]);
+ /** The index of the content node this hit originated at */
+ private int distributionKey = 0;
- /** Part ID */
+ /** The local identifier of the content store for this hit on the node it originated at */
private int partId;
- /** DistributionKey (needed to generate getDocsumPacket, for two-phase search) */
- private int distributionKey = 0;
+ /** The global id of this document in the backend node which produced it */
+ private GlobalId globalId = emptyGlobalId;
- /** The index uri of this. Lazily set */
+ /** Full information pointing to the location of further data for this hit. Lazily set */
private URI indexUri = null;
- /**
- * The number of least significant bits in the part id which specifies the
- * row in the search cluster which produced this hit. The other bits
- * specifies the column. 0 if not known.
- */
- private int rowBits = 0;
-
- /**
- * Whether or not to ignore the row bits. If this is set, FastSearcher is
- * allowed to choose an appropriate row.
- */
- private boolean ignoreRowBits = false;
-
- /** Whether to use the row number in the index uri, see FastSearcher for details */
- private boolean useRowInIndexUri = true;
-
private transient QueryPacketData queryPacketData = null;
private transient CacheKey cacheKey = null;
@@ -70,8 +52,8 @@ public class FastHit extends Hit {
super.setField("uri", uri); // TODO: Remove on Vespa 7
setRelevance(new Relevance(relevance));
setSource(source);
- types().add(SUMMARY); // TODO: Remove on Vespa 7
- setPartId(0, 0);
+ types().add("summary");
+ setPartId(0);
}
@Override
@@ -117,7 +99,7 @@ public class FastHit extends Hit {
URI uri = super.getId();
if (uri != null) return uri;
- // TODO: Remove, this should be one of the last vestiges of URL field magic
+ // TODO: Remove on Vespa 7, this should be one of the last vestiges of URL field magic
if (fields().containsKey("uri")) {
// trigger decoding
Object o = getField("uri");
@@ -137,11 +119,7 @@ public class FastHit extends Hit {
public URI getIndexUri() {
if (indexUri != null) return indexUri;
- String rowString = "-";
- if (useRowInIndexUri)
- rowString = String.valueOf(getRow());
-
- indexUri = new URI("index:" + getSourceNumber() + "/" + getColumn() + "/" + rowString + "/" + asHexString(getGlobalId()));
+ indexUri = new URI("index:" + getSourceNumber() + "/" + getPartId() + "/" + asHexString(getGlobalId()));
return indexUri;
}
@@ -165,37 +143,8 @@ public class FastHit extends Hit {
* highest row number are the row bits, the rest are column bits.
*
* @param partId partition id
- * @param rowBits number of bits to encode row number
*/
- public void setPartId(int partId, int rowBits) {
- this.partId = partId;
- this.rowBits = rowBits;
- }
-
- /**
- * Sets whether to use the row in the index uri. See FastSearcher for details.
- */
- public void setUseRowInIndexUri(boolean useRowInIndexUri) {
- this.useRowInIndexUri = useRowInIndexUri;
- }
-
- /**
- * Returns the column number where this hit originated, or partId if not known
- */
- public int getColumn() {
- return partId >>> rowBits;
- }
-
- /**
- * Returns the row number where this hit originated, or 0 if not known
- * */
- public int getRow() {
- if (rowBits == 0) {
- return 0;
- }
-
- return partId & ((1 << rowBits) - 1);
- }
+ public void setPartId(int partId) { this.partId = partId; }
/**
* <p>Returns a field value from this Hit. The value is either a stored value from the Document represented by
@@ -230,19 +179,7 @@ public class FastHit extends Hit {
*/
@Override
public Object getField(String key) {
- Object value = super.getField(key);
-
- if (value instanceof LazyValue) {
- return getAndCacheLazyValue(key, (LazyValue) value);
- } else {
- return value;
- }
- }
-
- private Object getAndCacheLazyValue(String key, LazyValue value) {
- Object forcedValue = value.getValue(key);
- setField(key, forcedValue);
- return forcedValue;
+ return super.getField(key);
}
/** Returns false - this is a concrete hit containing requested content */
@@ -250,20 +187,12 @@ public class FastHit extends Hit {
return false;
}
- /**
- * Only needed when fetching summaries in 2 phase.
- *
- * @return distribution key of node where the hit originated from
- */
+ /** Returns the index of the node this hit originated at */
public int getDistributionKey() {
return distributionKey;
}
- /**
- * Only needed when fetching summaries in 2 phase.
- *
- * @param distributionKey Of node where you find this hit.
- */
+ /** Returns the index of the node this hit originated at */
public void setDistributionKey(int distributionKey) {
this.distributionKey = distributionKey;
}
@@ -287,20 +216,6 @@ public class FastHit extends Hit {
}
/**
- * Set a field to behave like a string type summary field, not decoding raw
- * data till actually used. Added to make testing lazy docsum functionality
- * easier. This is not a method to be used for efficiency, as it causes
- * object allocations.
- *
- * @param fieldName the name of the field to insert undecoded UTF-8 into
- * @param value an array of valid UTF-8 data
- */
- @Beta
- public void setLazyStringField(String fieldName, byte[] value) {
- setField(fieldName, new LazyString(new StringField(fieldName), new StringValue(value)));
- }
-
- /**
* Add the binary data common for the query packet to a Vespa backend and a
* summary fetch packet to a Vespa backend. This method can only be called
* once for a single hit.
@@ -336,27 +251,6 @@ public class FastHit extends Hit {
this.cacheKey = cacheKey;
}
- public void setIgnoreRowBits(boolean ignoreRowBits) {
- this.ignoreRowBits = ignoreRowBits;
- }
-
- public boolean shouldIgnoreRowBits() {
- return ignoreRowBits;
- }
-
- public boolean fieldIsNotDecoded(String name) {
- return super.getField(name) instanceof LazyValue;
- }
-
- public RawField fetchFieldAsUtf8(String fieldName) {
- Object value = super.getField(fieldName);
- if (value instanceof LazyValue) {
- return ((LazyValue) value).getFieldAsUtf8(fieldName);
- } else {
- throw new IllegalStateException("Field " + fieldName + " has already been decoded:" + value);
- }
- }
-
public static final class RawField {
private final boolean needXmlEscape;
@@ -373,30 +267,4 @@ public class FastHit extends Hit {
}
- private static abstract class LazyValue {
- abstract Object getValue(String fieldName);
- abstract RawField getFieldAsUtf8(String fieldName);
- }
-
- private static class LazyString extends LazyValue {
-
- private final Inspector value;
- private final DocsumField fieldType;
-
- LazyString(DocsumField fieldType, Inspector value) {
- assert(value.type() == Type.STRING);
- this.value = value;
- this.fieldType = fieldType;
- }
-
- Object getValue(String fieldName) {
- return value.asString();
- }
-
- RawField getFieldAsUtf8(String fieldName) {
- return new RawField(fieldType, value.asUtf8());
- }
-
- }
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
index 740deaa7ca1..7d5b91ab1e3 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
@@ -53,9 +53,6 @@ import java.util.logging.Level;
@SuppressWarnings("deprecation")
public abstract class VespaBackEndSearcher extends PingableSearcher {
- private static final CompoundName grouping=new CompoundName("grouping");
- private static final CompoundName combinerows=new CompoundName("combinerows");
-
protected static final CompoundName PACKET_COMPRESSION_LIMIT = new CompoundName("packetcompressionlimit");
protected static final CompoundName PACKET_COMPRESSION_TYPE = new CompoundName("packetcompressiontype");
protected static final CompoundName TRACE_DISABLE = new CompoundName("trace.disable");
@@ -77,12 +74,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
/** Cache wrapper */
protected CacheControl cacheControl = null;
- /**
- * The number of last significant bits in the partId which specifies the
- * row number in this backend,
- * the rest specifies the column. 0 if not known.
- */
- private int rowBits = 0;
+
/** Searchcluster number */
private int sourceNumber;
@@ -177,7 +169,6 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
DocumentdbInfoConfig documentdbInfoConfig) {
this.name = clusterParams.searcherName;
this.sourceNumber = clusterParams.clusterNumber;
- this.rowBits = clusterParams.rowBits;
Validator.ensureNotNull("Name of Vespa backend integration", getName());
@@ -535,7 +526,6 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
FastHit hit = new FastHit();
hit.setQuery(myQuery);
- hit.setUseRowInIndexUri(useRowInIndexUri(result));
hit.setFillable();
hit.setCached(true);
@@ -565,10 +555,6 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
return filledAllOfEm;
}
- private boolean useRowInIndexUri(Result result) {
- return ! ((result.getQuery().properties().getString(grouping) != null) || result.getQuery().properties().getBoolean(combinerows));
- }
-
private void extractDocumentInfo(FastHit hit, DocumentInfo document) {
hit.setSourceNumber(sourceNumber);
hit.setSource(getName());
@@ -579,7 +565,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
hit.setDistributionKey(document.getDistributionKey());
hit.setGlobalId(document.getGlobalId());
- hit.setPartId(document.getPartId(), rowBits);
+ hit.setPartId(document.getPartId());
}
protected PacketWrapper cacheLookupTwoPhase(CacheKey cacheKey, Result result, String summaryClass) {
@@ -637,7 +623,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
* @param queryPacketData binary data from first phase of search, or null
* @param cacheKey the key this hit should match in the packet cache, or null
*/
- protected boolean addUnfilledHits(Result result, List<DocumentInfo> documents, boolean fromCache, QueryPacketData queryPacketData, CacheKey cacheKey) {
+ boolean addUnfilledHits(Result result, List<DocumentInfo> documents, boolean fromCache, QueryPacketData queryPacketData, CacheKey cacheKey) {
boolean allHitsOK = true;
Query myQuery = result.getQuery();
@@ -650,7 +636,6 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
hit.setQueryPacketData(queryPacketData);
hit.setCacheKey(cacheKey);
- hit.setUseRowInIndexUri(useRowInIndexUri(result));
hit.setFillable();
hit.setCached(fromCache);
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java
index 4aa8dea355b..ba7388a11a0 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java
@@ -148,17 +148,17 @@ public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
}
@Override
- public void error(Context context, XMLWriter writer) throws IOException {
+ public void error(Context context, XMLWriter writer) {
ErrorMessage error=((Result)context.get("result")).hits().getError();
writer.openTag(ERROR).attribute(CODE,error.getCode()).content(error.getMessage(),false).closeTag();
}
@Override
- public void noHits(Context context, XMLWriter writer) throws IOException {
+ public void noHits(Context context, XMLWriter writer) {
// no hits, do nothing :)
}
- protected static void renderCoverageAttributes(Coverage coverage, XMLWriter writer) throws IOException {
+ protected static void renderCoverageAttributes(Coverage coverage, XMLWriter writer) {
if (coverage == null) return;
writer.attribute(COVERAGE_DOCS,coverage.getDocs());
writer.attribute(COVERAGE_NODES,coverage.getNodes());
@@ -211,7 +211,7 @@ public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
}
- protected void renderId(URI uri, XMLWriter writer) throws IOException {
+ protected void renderId(URI uri, XMLWriter writer) {
if (uri != null) {
writer.openTag(ID).content(uri.stringValue(),false).closeTag();
}
@@ -228,7 +228,7 @@ public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
}
}
- private void renderSyntheticRelevancyField(Hit hit, XMLWriter writer) throws IOException {
+ private void renderSyntheticRelevancyField(Hit hit, XMLWriter writer) {
final String relevancyFieldName = "relevancy";
final Relevance relevance = hit.getRelevance();
@@ -248,7 +248,7 @@ public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
writeCloseFieldElement(writer);
}
- private void writeOpenFieldElement(String fieldName, XMLWriter writer) throws IOException {
+ private void writeOpenFieldElement(String fieldName, XMLWriter writer) {
Utf8String utf8 = fieldNameMap.get(fieldName);
if (utf8 == null) {
utf8 = new Utf8String(fieldName);
@@ -258,34 +258,19 @@ public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
writer.closeStartTag();
}
- private void writeCloseFieldElement(XMLWriter writer) throws IOException { // TODO: Collapse
+ private void writeCloseFieldElement(XMLWriter writer) {
writer.closeTag();
}
- protected void renderFieldContent(Context context, Hit hit,
- String name, XMLWriter writer)
- throws IOException {
-
- boolean dumpedRaw = false;
- if (hit instanceof FastHit && ((FastHit)hit).fieldIsNotDecoded(name)) {
- writer.closeStartTag();
- if ((writer.getWriter() instanceof ByteWriter) && context.isUtf8Output()) {
- dumpedRaw = dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, name);
- }
- if (dumpedRaw) {
- writer.content("",false); // let the xml writer note that this tag had content
- }
- }
- if (!dumpedRaw) {
- String xmlval = hit.getFieldXML(name);
- if (xmlval == null) {
- xmlval = "(null)";
- }
- writer.escapedContent(xmlval,false);
+ protected void renderFieldContent(Context context, Hit hit, String name, XMLWriter writer) {
+ String xmlval = hit.getFieldXML(name);
+ if (xmlval == null) {
+ xmlval = "(null)";
}
+ writer.escapedContent(xmlval,false);
}
- private void renderSimpleField(String fieldName, Object fieldValue, XMLWriter writer) throws IOException {
+ private void renderSimpleField(String fieldName, Object fieldValue, XMLWriter writer) {
writeOpenFieldElement(fieldName, writer);
writer.content(fieldValue.toString(),false);
writeCloseFieldElement(writer);
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java b/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java
index ee058876d16..ac1583b0577 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java
@@ -292,20 +292,6 @@ public abstract class UserTemplate<T extends Writer> extends GenericTemplateSet
public static boolean dumpBytes(ByteWriter writer,
FastHit hit,
String fieldName) throws java.io.IOException {
- FastHit.RawField asBytes;
- try {
- asBytes = hit.fetchFieldAsUtf8(fieldName);
- } catch (RuntimeException e) {
- asBytes = null;
- }
- if (asBytes != null) {
- if (asBytes.needXmlEscape()) {
- dumpAndXMLQuoteUTF8(writer, asBytes.getUtf8());
- } else {
- writer.append(asBytes.getUtf8());
- }
- return true;
- }
return false;
}
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java
index d910c10c2be..a095f6dc686 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/HitConverter.java
@@ -47,7 +47,7 @@ class HitConverter implements ResultBuilder.HitConverter {
FastHit hit = new FastHit();
hit.setRelevance(groupHit.getRank());
hit.setGlobalId(groupHit.getGlobalId());
- hit.setPartId(groupHit.getPath(), 0);
+ hit.setPartId(groupHit.getPath());
hit.setDistributionKey(groupHit.getDistributionKey());
hit.setFillable();
hit.setSearcherSpecificMetaData(searcher, summaryClass);
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java
index 11dcafba7bf..7859358fe50 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java
@@ -73,8 +73,6 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
// this is shared between umpteen threads by design
private final CopyOnWriteHashMap<String, Utf8String> fieldNameMap = new CopyOnWriteHashMap<>();
- private boolean utf8Output = false;
-
private XMLWriter writer;
public DefaultRenderer() {
@@ -92,13 +90,11 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
@Override
public void init() {
super.init();
- utf8Output = false;
writer = null;
}
@Override
public String getEncoding() {
-
if (getResult() == null
|| getResult().getQuery() == null
|| getResult().getQuery().getModel().getEncoding() == null) {
@@ -119,7 +115,6 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
private void header(XMLWriter writer, Result result) throws IOException {
// TODO: move setting this to Result
- utf8Output = "utf-8".equalsIgnoreCase(getRequestedEncoding(result.getQuery()));
writer.xmlHeader(getRequestedEncoding(result.getQuery()));
writer.openTag(RESULT).attribute(TOTAL_HIT_COUNT, String.valueOf(result.getTotalHitCount()));
renderCoverageAttributes(result.getCoverage(false), writer);
@@ -128,9 +123,7 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
}
private void renderTime(XMLWriter writer, Result result) {
- if (!result.getQuery().getPresentation().getTiming()) {
- return;
- }
+ if ( ! result.getQuery().getPresentation().getTiming()) return;
final String threeDecimals = "%.3f";
final double milli = .001d;
@@ -159,13 +152,11 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
writer.attribute(RESULTS,coverage.getResultSets());
}
-
public void error(XMLWriter writer, Result result) throws IOException {
ErrorMessage error = result.hits().getError();
writer.openTag(ERROR).attribute(CODE,error.getCode()).content(error.getMessage(),false).closeTag();
}
-
@SuppressWarnings("UnusedParameters")
protected void emptyResult(XMLWriter writer, Result result) throws IOException {}
@@ -180,63 +171,43 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
}
}
-
- private void renderSingularHit(XMLWriter writer, Hit hit) throws IOException {
+ private void renderSingularHit(XMLWriter writer, Hit hit) {
writer.openTag(HIT);
renderHitAttributes(writer, hit);
writer.closeStartTag();
renderHitFields(writer, hit);
}
- private void renderHitFields(XMLWriter writer, Hit hit) throws IOException {
+ private void renderHitFields(XMLWriter writer, Hit hit) {
renderSyntheticRelevanceField(writer, hit);
for (Iterator<Map.Entry<String, Object>> it = hit.fieldIterator(); it.hasNext(); ) {
renderField(writer, hit, it);
}
}
- private void renderField(XMLWriter writer, Hit hit, Iterator<Map.Entry<String, Object>> it) throws IOException {
- Map.Entry<String, Object> entry = it.next();
- boolean isProbablyNotDecoded = false;
- if (hit instanceof FastHit) {
- FastHit f = (FastHit) hit;
- isProbablyNotDecoded = f.fieldIsNotDecoded(entry.getKey());
- }
- renderGenericFieldPossiblyNotDecoded(writer, hit, entry, isProbablyNotDecoded);
+ private void renderField(XMLWriter writer, Hit hit, Iterator<Map.Entry<String, Object>> it) {
+ renderGenericField(writer, hit, it.next());
}
- private void renderGenericFieldPossiblyNotDecoded(XMLWriter writer, Hit hit, Map.Entry<String, Object> entry, boolean probablyNotDecoded) throws IOException {
+ private void renderGenericField(XMLWriter writer, Hit hit, Map.Entry<String, Object> entry) {
String fieldName = entry.getKey();
// skip depending on hit type
if (fieldName.startsWith("$")) return; // Don't render fields that start with $ // TODO: Move to should render
writeOpenFieldElement(writer, fieldName);
- renderFieldContentPossiblyNotDecoded(writer, hit, probablyNotDecoded, fieldName);
+ renderFieldContent(writer, hit, fieldName);
writeCloseFieldElement(writer);
}
- private void renderFieldContentPossiblyNotDecoded(XMLWriter writer, Hit hit, boolean probablyNotDecoded, String fieldName) throws IOException {
- boolean dumpedRaw = false;
- if (probablyNotDecoded && (hit instanceof FastHit)) {
- writer.closeStartTag();
- if ((writer.getWriter() instanceof ByteWriter) && utf8Output) {
- dumpedRaw = UserTemplate.dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, fieldName);
- }
- if (dumpedRaw) {
- writer.content("", false); // let the xml writer note that this tag had content
- }
- }
- if (!dumpedRaw) {
- String xmlval = hit.getFieldXML(fieldName);
- if (xmlval == null) {
- xmlval = "(null)";
- }
- writer.escapedContent(xmlval, false);
- }
+ private void renderFieldContent(XMLWriter writer, Hit hit, String fieldName) {
+ String xmlval = hit.getFieldXML(fieldName);
+ if (xmlval == null)
+ xmlval = "(null)";
+ writer.escapedContent(xmlval, false);
}
- private void renderSyntheticRelevanceField(XMLWriter writer, Hit hit) throws IOException {
+ private void renderSyntheticRelevanceField(XMLWriter writer, Hit hit) {
final String relevancyFieldName = "relevancy";
final Relevance relevance = hit.getRelevance();
@@ -246,17 +217,17 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
}
}
- private void renderSimpleField(XMLWriter writer, String relevancyFieldName, Relevance relevance) throws IOException {
+ private void renderSimpleField(XMLWriter writer, String relevancyFieldName, Relevance relevance) {
writeOpenFieldElement(writer, relevancyFieldName);
writer.content(relevance.toString(), false);
writeCloseFieldElement(writer);
}
- private void writeCloseFieldElement(XMLWriter writer) throws IOException {
+ private void writeCloseFieldElement(XMLWriter writer) {
writer.closeTag();
}
- private void writeOpenFieldElement(XMLWriter writer, String relevancyFieldName) throws IOException {
+ private void writeOpenFieldElement(XMLWriter writer, String relevancyFieldName) {
Utf8String utf8 = fieldNameMap.get(relevancyFieldName);
if (utf8 == null) {
utf8 = new Utf8String(relevancyFieldName);
@@ -266,7 +237,7 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
writer.closeStartTag();
}
- private void renderHitAttributes(XMLWriter writer, Hit hit) throws IOException {
+ private void renderHitAttributes(XMLWriter writer, Hit hit) {
writer.attribute(TYPE, hit.getTypeString());
if (hit.getRelevance() != null) {
writer.attribute(RELEVANCY, hit.getRelevance().toString());
@@ -285,20 +256,20 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
}
}
- private void renderGroup(XMLWriter writer, HitGroup hit) throws IOException {
+ private void renderGroup(XMLWriter writer, HitGroup hit) {
writer.openTag(GROUP);
renderHitAttributes(writer, hit);
writer.closeStartTag();
}
- private void renderHitGroupOfTypeGroupHit(XMLWriter writer, HitGroup hit) throws IOException {
+ private void renderHitGroupOfTypeGroupHit(XMLWriter writer, HitGroup hit) {
writer.openTag(HIT);
renderHitAttributes(writer, hit);
renderId(writer, hit);
writer.closeStartTag();
}
- private void renderId(XMLWriter writer, HitGroup hit) throws IOException {
+ private void renderId(XMLWriter writer, HitGroup hit) {
URI uri = hit.getId();
if (uri != null) {
writer.openTag(ID).content(uri.stringValue(),false).closeTag();
@@ -420,17 +391,13 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
}
@Override
- public void beginList(DataList<?> list)
- throws IOException {
- if (getRecursionLevel() == 1) {
- return;
- }
+ public void beginList(DataList<?> list) throws IOException {
+ if (getRecursionLevel() == 1) return;
+
HitGroup hit = (HitGroup) list;
boolean renderedSimple = simpleRenderHit(writer, hit);
+ if (renderedSimple) return;
- if (renderedSimple) {
- return;
- }
renderHitGroup(writer, hit);
}
@@ -438,25 +405,20 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
public void data(Data data) throws IOException {
Hit hit = (Hit) data;
boolean renderedSimple = simpleRenderHit(writer, hit);
+ if (renderedSimple) return;
- if (renderedSimple) {
- return;
- }
renderSingularHit(writer, hit);
writer.closeTag();
}
@Override
- public void endList(DataList<?> list)
- throws IOException {
- if (getRecursionLevel() == 1) {
- return;
- }
- writer.closeTag();
+ public void endList(DataList<?> list) {
+ if (getRecursionLevel() > 1)
+ writer.closeTag();
}
@Override
- public void endResponse() throws IOException {
+ public void endResponse() {
writer.closeTag();
writer.close();
}
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
index c39f0387d46..34b02b1bee8 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
@@ -533,10 +533,6 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
if (fieldName.startsWith(VESPA_HIDDEN_FIELD_PREFIX)) return false;
- RenderDecision r = lazyRenderAwareCheck(fieldName, hit);
- if (r != RenderDecision.DO_NOT_KNOW) return r.booleanValue();
-
- // this will trigger field decoding, so it is important the lazy decoding magic is done first
Object field = hit.getField(fieldName);
if (field instanceof CharSequence && ((CharSequence) field).length() == 0) return false;
@@ -549,18 +545,6 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
return true;
}
- private RenderDecision lazyRenderAwareCheck(String fieldName, Hit hit) {
- if ( ! (hit instanceof FastHit)) return RenderDecision.DO_NOT_KNOW;
-
- FastHit asFastHit = (FastHit) hit;
- if (asFastHit.fieldIsNotDecoded(fieldName)) {
- FastHit.RawField rawField = asFastHit.fetchFieldAsUtf8(fieldName);
- if (rawField != null)
- return rawField.getUtf8().length == 0 ? RenderDecision.NO : RenderDecision.YES;
- }
- return RenderDecision.DO_NOT_KNOW;
- }
-
private void renderSpecialCasesForGrouping(Hit hit) throws IOException {
if (hit instanceof AbstractList) {
renderGroupingListSyntheticFields((AbstractList) hit);
@@ -633,9 +617,7 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
private void renderField(String fieldName, Hit hit) throws IOException {
generator.writeFieldName(fieldName);
- if ( ! tryDirectRendering(fieldName, hit)) {
- renderFieldContents(hit.getField(fieldName));
- }
+ renderFieldContents(hit.getField(fieldName));
}
private void renderFieldContents(Object field) throws IOException {
@@ -718,26 +700,6 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
generator.writeEndObject();
}
- /**
- * Really a private method, but package access for testability.
- */
- boolean tryDirectRendering(String fieldName, Hit hit) throws IOException {
- boolean renderedAsUtf8 = false;
- if (hit instanceof FastHit) {
- FastHit f = (FastHit) hit;
- if (f.fieldIsNotDecoded(fieldName)) {
- FastHit.RawField r = f.fetchFieldAsUtf8(fieldName);
- if (r != null) {
- byte[] utf8 = r.getUtf8();
-
- generator.writeUTF8String(utf8, 0, utf8.length);
- renderedAsUtf8 = true;
- }
- }
- }
- return renderedAsUtf8;
- }
-
@Override
public void data(Data data) throws IOException {
Preconditions.checkArgument(data instanceof Hit,
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java
index f63ff122b63..6613211a91e 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java
@@ -257,62 +257,41 @@ public final class SyncDefaultRenderer extends Renderer {
}
}
- private void renderSingularHit(XMLWriter writer, Hit hit) throws IOException {
+ private void renderSingularHit(XMLWriter writer, Hit hit) {
writer.openTag(HIT);
renderHitAttributes(writer, hit);
writer.closeStartTag();
renderHitFields(writer, hit);
}
- private void renderHitFields(XMLWriter writer, Hit hit) throws IOException {
+ private void renderHitFields(XMLWriter writer, Hit hit) {
renderSyntheticRelevanceField(writer, hit);
for (Iterator<Map.Entry<String, Object>> it = hit.fieldIterator(); it.hasNext(); ) {
renderField(writer, hit, it);
}
}
- private void renderField(XMLWriter writer, Hit hit, Iterator<Map.Entry<String, Object>> it) throws IOException {
+ private void renderField(XMLWriter writer, Hit hit, Iterator<Map.Entry<String, Object>> it) {
Map.Entry<String, Object> entry = it.next();
- boolean isProbablyNotDecoded = false;
- if (hit instanceof FastHit) {
- FastHit f = (FastHit) hit;
- isProbablyNotDecoded = f.fieldIsNotDecoded(entry.getKey());
- }
- renderGenericFieldPossiblyNotDecoded(writer, hit, entry, isProbablyNotDecoded);
- }
-
- private void renderGenericFieldPossiblyNotDecoded(XMLWriter writer, Hit hit, Map.Entry<String, Object> entry, boolean probablyNotDecoded) throws IOException {
String fieldName = entry.getKey();
- if (!shouldRenderField(hit, fieldName)) return;
+ if ( ! shouldRenderField(hit, fieldName)) return;
if (fieldName.startsWith("$")) return; // Don't render fields that start with $ // TODO: Move to should render
writeOpenFieldElement(writer, fieldName);
- renderFieldContentPossiblyNotDecoded(writer, hit, probablyNotDecoded, fieldName);
+ renderFieldContent(writer, hit, fieldName);
writeCloseFieldElement(writer);
}
- private void renderFieldContentPossiblyNotDecoded(XMLWriter writer, Hit hit, boolean probablyNotDecoded, String fieldName) throws IOException {
- boolean dumpedRaw = false;
- if (probablyNotDecoded && (hit instanceof FastHit)) {
- writer.closeStartTag();
- if ((writer.getWriter() instanceof ByteWriter) && context.isUtf8Output()) {
- dumpedRaw = UserTemplate.dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, fieldName);
- }
- if (dumpedRaw) {
- writer.content("", false); // let the xml writer note that this tag had content
- }
- }
- if (!dumpedRaw) {
- String xmlval = hit.getFieldXML(fieldName);
- if (xmlval == null) {
- xmlval = "(null)";
- }
- writer.escapedContent(xmlval, false);
+ private void renderFieldContent(XMLWriter writer, Hit hit, String fieldName) {
+ String xmlval = hit.getFieldXML(fieldName);
+ if (xmlval == null) {
+ xmlval = "(null)";
}
+ writer.escapedContent(xmlval, false);
}
- private void renderSyntheticRelevanceField(XMLWriter writer, Hit hit) throws IOException {
+ private void renderSyntheticRelevanceField(XMLWriter writer, Hit hit) {
final String relevancyFieldName = "relevancy";
final Relevance relevance = hit.getRelevance();
@@ -321,17 +300,17 @@ public final class SyncDefaultRenderer extends Renderer {
}
}
- private void renderSimpleField(XMLWriter writer, String relevancyFieldName, Relevance relevance) throws IOException {
+ private void renderSimpleField(XMLWriter writer, String relevancyFieldName, Relevance relevance) {
writeOpenFieldElement(writer, relevancyFieldName);
writer.content(relevance.toString(), false);
writeCloseFieldElement(writer);
}
- private void writeCloseFieldElement(XMLWriter writer) throws IOException {
+ private void writeCloseFieldElement(XMLWriter writer) {
writer.closeTag();
}
- private void writeOpenFieldElement(XMLWriter writer, String relevancyFieldName) throws IOException {
+ private void writeOpenFieldElement(XMLWriter writer, String relevancyFieldName) {
Utf8String utf8 = fieldNameMap.get(relevancyFieldName);
if (utf8 == null) {
utf8 = new Utf8String(relevancyFieldName);
@@ -346,7 +325,7 @@ public final class SyncDefaultRenderer extends Renderer {
return true;
}
- private void renderHitAttributes(XMLWriter writer, Hit hit) throws IOException {
+ private void renderHitAttributes(XMLWriter writer, Hit hit) {
writer.attribute(TYPE, hit.getTypeString());
if (hit.getRelevance() != null) {
writer.attribute(RELEVANCY, hit.getRelevance().toString());
@@ -365,20 +344,20 @@ public final class SyncDefaultRenderer extends Renderer {
}
}
- private void renderGroup(XMLWriter writer, HitGroup hit) throws IOException {
+ private void renderGroup(XMLWriter writer, HitGroup hit) {
writer.openTag(GROUP);
renderHitAttributes(writer, hit);
writer.closeStartTag();
}
- private void renderHitGroupOfTypeGroupHit(XMLWriter writer, HitGroup hit) throws IOException {
+ private void renderHitGroupOfTypeGroupHit(XMLWriter writer, HitGroup hit) {
writer.openTag(HIT);
renderHitAttributes(writer, hit);
renderId(writer, hit);
writer.closeStartTag();
}
- private void renderId(XMLWriter writer, HitGroup hit) throws IOException {
+ private void renderId(XMLWriter writer, HitGroup hit) {
URI uri = hit.getId();
if (uri != null) {
writer.openTag(ID).content(uri.stringValue(),false).closeTag();
diff --git a/container-search/src/test/java/com/yahoo/fs4/test/FastHitTestCase.java b/container-search/src/test/java/com/yahoo/fs4/test/FastHitTestCase.java
deleted file mode 100644
index c0223aab568..00000000000
--- a/container-search/src/test/java/com/yahoo/fs4/test/FastHitTestCase.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.fs4.test;
-
-import com.yahoo.prelude.fastsearch.FastHit;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
- */
-public class FastHitTestCase {
-
- @Test
- public void requireThatIgnoreRowBitsIsFalseByDefault() {
- FastHit hit = new FastHit();
- assertFalse(hit.shouldIgnoreRowBits());
- }
-
- @Test
- public void requireThatIgnoreRowBitsCanBeSet() {
- FastHit hit = new FastHit();
- hit.setIgnoreRowBits(true);
- assertTrue(hit.shouldIgnoreRowBits());
- }
-}
diff --git a/container-search/src/test/java/com/yahoo/fs4/test/GetDocSumsPacketTestCase.java b/container-search/src/test/java/com/yahoo/fs4/test/GetDocSumsPacketTestCase.java
index 679bc96c06b..c284a073704 100644
--- a/container-search/src/test/java/com/yahoo/fs4/test/GetDocSumsPacketTestCase.java
+++ b/container-search/src/test/java/com/yahoo/fs4/test/GetDocSumsPacketTestCase.java
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertNull;
/**
* Tests the GetDocsumsPacket
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class GetDocSumsPacketTestCase {
@@ -33,14 +33,7 @@ public class GetDocSumsPacketTestCase {
@Test
public void testEncodingWithQuery() throws BufferTooSmallException {
- FastHit hit = new FastHit();
- hit.setIgnoreRowBits(true);
- assertPacket(true, hit, new byte[] { 0, 0, 0, 57, 0, 0, 0, -37, 0, 0, 40, 21, 0, 0, 0, 0, IGNORE, IGNORE, IGNORE,
- IGNORE, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 0x03, 0, 0, 0, 7,
- 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 1, 0, 0, 0, 6, 4, 0, 3, 102, 111, 111, 0, 0, 0, 3 });
-
- hit = new FastHit();
- hit.setIgnoreRowBits(false);
+ Hit hit = new FastHit();
assertPacket(true, hit, new byte[] {0, 0, 0, 57, 0, 0, 0, -37, 0, 0, 40, 21, 0, 0, 0, 0, IGNORE, IGNORE, IGNORE,
IGNORE, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 0x03, 0, 0, 0, 7,
100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 1, 0, 0, 0, 6, 4, 0, 3, 102, 111, 111, 0, 0, 0, 2});
@@ -48,15 +41,7 @@ public class GetDocSumsPacketTestCase {
@Test
public void testEncodingWithoutQuery() throws BufferTooSmallException {
- FastHit hit = new FastHit();
- hit.setIgnoreRowBits(true);
- assertPacket(false, hit, new byte[] { 0, 0, 0, 43, 0, 0, 0, -37, 0, 0, 40, 17, 0, 0, 0, 0, IGNORE, IGNORE, IGNORE,
- IGNORE, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 0x03, 0, 0, 0, 7,
- 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 3
- });
-
- hit = new FastHit();
- hit.setIgnoreRowBits(false);
+ Hit hit = new FastHit();
assertPacket(false, hit, new byte[] { 0, 0, 0, 43, 0, 0, 0, -37, 0, 0, 40, 17, 0, 0, 0, 0, IGNORE, IGNORE, IGNORE,
IGNORE, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 0x03, 0, 0, 0, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 2
});
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java
index c2a50884b2b..c179851ba00 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java
@@ -107,7 +107,7 @@ public class SlimeSummaryTestCase {
DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf);
byte[] docsum = makeTimeout();
FastHit hit = new FastHit();
- assertEquals("Hit hit index:0/0/0/000000000000000000000000 (relevance null) [fasthit, globalid: 0 0 0 0 0 0 0 0 0 0 0 0, partId: 0, distributionkey: 0] failed: Timed out....", set.lazyDecode("default", docsum, hit));
+ assertEquals("Hit hit index:0/0/000000000000000000000000 (relevance null) [fasthit, globalid: 0 0 0 0 0 0 0 0 0 0 0 0, partId: 0, distributionkey: 0] failed: Timed out....", set.lazyDecode("default", docsum, hit));
}
@Test
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
index b0bbdda32df..f8aa5e01853 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
@@ -72,7 +72,7 @@ public class DocsumDefinitionTestCase {
assertEquals("1", hit.getField("EXTINFOSOURCE").toString());
assertEquals("10", hit.getField("LANG1").toString());
assertEquals("352", hit.getField("WORDS").toString());
- assertEquals("index:0/0/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
+ assertEquals("index:0/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
}
public static GlobalId createGlobalId(int docId) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
index 3cfd8b337fc..7d905d286fc 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
@@ -545,7 +545,7 @@ public class FastSearcherTestCase {
hit.getField("TITLE"));
assertEquals("352", hit.getField("WORDS").toString());
assertEquals(2003., hit.getRelevance().getScore(), 0.01d);
- assertEquals("index:0/234/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
+ assertEquals("index:0/234/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
assertEquals("9190", hit.getField("BYTES").toString());
assertEquals("testhittype", hit.getSource());
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java b/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java
index ed421be1947..0191b1a799b 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java
@@ -133,7 +133,7 @@ public class FillTestCase {
private FastHit createHit(int sourceNodeId, int hitId) {
FastHit hit = new FastHit("hit:" + hitId, 1.0);
- hit.setPartId(sourceNodeId, 0);
+ hit.setPartId(sourceNodeId);
hit.setDistributionKey(sourceNodeId);
hit.setGlobalId(client.globalIdFrom(hitId));
return hit;
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
index e5fe0111655..49f5642af4e 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
@@ -22,7 +22,7 @@ import org.junit.Test;
import static org.junit.Assert.*;
/**
- * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
+ * @author Simon Thoresen
*/
public class HitConverterTestCase {
@@ -35,11 +35,11 @@ public class HitConverterTestCase {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(new Hit("hit:ctx")));
assertNotNull(hit);
- assertEquals(new URI("index:0/1/0/" + FastHit.asHexString(createGlobalId(2))), hit.getId());
+ assertEquals(new URI("index:0/1/" + FastHit.asHexString(createGlobalId(2))), hit.getId());
hit = converter.toSearchHit("default", new FS4Hit(4, createGlobalId(5), 6).setContext(new Hit("hit:ctx")));
assertNotNull(hit);
- assertEquals(new URI("index:0/4/0/" + FastHit.asHexString(createGlobalId(5))), hit.getId());
+ assertEquals(new URI("index:0/4/" + FastHit.asHexString(createGlobalId(5))), hit.getId());
}
@Test
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
index 791e95403ab..defabc7463b 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
@@ -680,26 +680,6 @@ public class JsonRendererTestCase {
}
@Test
- public void testLazyDecoding() throws IOException {
- FastHit f = new FastHit("http://a.b/c", 0.5);
- String checkWeCanDecode = "bamse";
- String dontCare = "don't care";
- final String fieldName = "checkWeCanDecode";
- f.setLazyStringField(fieldName, Utf8.toBytes(checkWeCanDecode));
- final String fieldName2 = "dontCare";
- f.setLazyStringField(fieldName2, Utf8.toBytes(dontCare));
- assertEquals(checkWeCanDecode, f.getField(fieldName));
-
- JsonGenerator mock = Mockito.mock(JsonGenerator.class);
-
- renderer.setGenerator(mock);
- assertTrue(renderer.tryDirectRendering(fieldName2, f));
-
- byte[] expectedBytes = Utf8.toBytes(dontCare);
- Mockito.verify(mock, times(1)).writeUTF8String(expectedBytes, 0, expectedBytes.length);
- }
-
- @Test
public void testHitWithSource() throws IOException, InterruptedException, ExecutionException {
String expected = "{\n"
+ " \"root\": {\n"
diff --git a/document/src/main/java/com/yahoo/document/GlobalId.java b/document/src/main/java/com/yahoo/document/GlobalId.java
index e2d3e4510f4..95e35c9280c 100644
--- a/document/src/main/java/com/yahoo/document/GlobalId.java
+++ b/document/src/main/java/com/yahoo/document/GlobalId.java
@@ -12,6 +12,8 @@ import java.util.Arrays;
* Implements an incredibly light-weight version of the document global id. There is a lot of functionality in the C++
* version of this that is missing. However, this should be sufficient for now.
*
+ * This is immutable (by contract - not enforcable due to exposing the raw byte array).
+ *
* @author Simon Thoresen
*/
public class GlobalId implements Comparable {
@@ -72,21 +74,19 @@ public class GlobalId implements Comparable {
/**
* Returns the raw byte array that constitutes this global id.
- *
- * @return The byte array.
+ * The returned value MUST NOT be modified.
*/
public byte[] getRawId() {
return raw;
}
- // Inherit doc from Object.
@Override
public int hashCode() {
return Arrays.hashCode(raw);
}
public BucketId toBucketId() {
- /**
+ /*
* Explanation time: since Java was designed so mankind could suffer,
* shift ops on bytes have an implicit int conversion with sign-extend.
* When a byte is negative, you end up with an int/long with a 0xFFFFFF