diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-09-07 14:09:53 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-09-07 14:09:53 +0200 |
commit | 4f322fa06ca0a2431a0c7b29a7f8c089e33f4d6a (patch) | |
tree | eb3d2cfe8399385d2eb6c6fa28814fefc127ef5e /container-search | |
parent | 9c8162a9f042c5cf6bebe6771a74c851d0f419ad (diff) |
Nonfunctional changes only
Diffstat (limited to 'container-search')
4 files changed, 91 insertions, 85 deletions
diff --git a/container-search/src/main/java/com/yahoo/fs4/QueryPacketData.java b/container-search/src/main/java/com/yahoo/fs4/QueryPacketData.java index e54f526f709..673b9cc0c47 100644 --- a/container-search/src/main/java/com/yahoo/fs4/QueryPacketData.java +++ b/container-search/src/main/java/com/yahoo/fs4/QueryPacketData.java @@ -8,7 +8,7 @@ import java.nio.ByteBuffer; * fetch for a Vespa hit. Used to avoid to tagging Vespa summary hits with * the entire query as an immutable. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public final class QueryPacketData { diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/Docsum.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/Docsum.java index 07d62e242e7..8181787e909 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/Docsum.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/Docsum.java @@ -9,7 +9,7 @@ import java.nio.ByteOrder; * An instance of a document summary, backed by binary data, which decodes and returns fields on request, * using the (shared) definition of this docsum. * - * @author <a href="mailt:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public final class Docsum { 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 2eec7109722..1524a4da426 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 @@ -48,10 +48,7 @@ public class FastHit extends Hit { */ private boolean ignoreRowBits = false; - /** - * Whether to use the row number in the index uri, see FastSearcher for - * details - */ + /** Whether to use the row number in the index uri, see FastSearcher for details */ private boolean useRowInIndexUri = true; private transient QueryPacketData queryPacketData = null; @@ -111,8 +108,8 @@ public class FastHit extends Hit { } /** - * Returns the explicitly set uri if available, returns - * "index:[source]/[partid]/[id]" otherwise + * Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwise + * * @return uri of hit */ public URI getUri() { @@ -131,9 +128,9 @@ public class FastHit extends Hit { } /** - * The uri of the index location of this hit - * ("index:[source]/[partid]/[id]"). This is the uri if no other uri is - * assigned + * The uri of the index location of this hit ("index:[source]/[partid]/[id]"). + * This is the uri if no other uri is assigned + * * @return uri to the index. */ public URI getIndexUri() { @@ -182,7 +179,7 @@ public class FastHit extends Hit { } /** - * @return Returns the column number where this hit originated, or partId if not known + * Returns the column number where this hit originated, or partId if not known */ public int getColumn() { return partId >>> rowBits; @@ -263,6 +260,7 @@ public class FastHit extends Hit { /** * Only needed when fetching summaries in 2 phase. + * * @param distributionKey Of node where you find this hit. */ public void setDistributionKey(int distributionKey) { @@ -315,20 +313,6 @@ public class FastHit extends Hit { setField(fieldName, new LazyString(new StringField(fieldName), new StringValue(value))); } - public static final class RawField { - private final boolean needXmlEscape; - - private final byte[] contents; - - public RawField(DocsumField fieldType, byte[] contents) { - needXmlEscape = ! (fieldType instanceof XMLField); - this.contents = contents; - } - - public byte [] getUtf8() { return contents; } - public boolean needXmlEscape() { return needXmlEscape; } - } - /** * 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 @@ -386,6 +370,22 @@ public class FastHit extends Hit { } } + public static final class RawField { + + private final boolean needXmlEscape; + + private final byte[] contents; + + public RawField(DocsumField fieldType, byte[] contents) { + needXmlEscape = ! (fieldType instanceof XMLField); + this.contents = contents; + } + + public byte [] getUtf8() { return contents; } + public boolean needXmlEscape() { return needXmlEscape; } + + } + private static abstract class LazyValue { abstract Object getValue(String fieldName); abstract RawField getFieldAsUtf8(String fieldName); @@ -395,6 +395,7 @@ public class FastHit extends Hit { * Represents a value that resides in the docsum. */ private static class LazyDocsumValue extends LazyValue { + private final Docsum docsum; LazyDocsumValue(Docsum docsum) { @@ -414,9 +415,11 @@ public class FastHit extends Hit { RawField getFieldAsUtf8(String fieldName) { return docsum.fetchFieldAsUtf8(getFieldIndex(fieldName)); } + } private static class LazyString extends LazyValue { + private final Inspector value; private final DocsumField fieldType; @@ -433,6 +436,7 @@ public class FastHit extends Hit { RawField getFieldAsUtf8(String fieldName) { return new RawField(fieldType, value.asUtf8()); } + } } diff --git a/container-search/src/main/java/com/yahoo/search/result/Hit.java b/container-search/src/main/java/com/yahoo/search/result/Hit.java index 0bfbecfd9ab..3cc7378de5c 100644 --- a/container-search/src/main/java/com/yahoo/search/result/Hit.java +++ b/container-search/src/main/java/com/yahoo/search/result/Hit.java @@ -58,7 +58,7 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi /** The relevance of this hit */ private Relevance relevance; - /** Says whether this hit is cached or not */ + /** Says whether this hit is cached */ private boolean cached = false; /** @@ -95,59 +95,11 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi private boolean auxiliary=false; /** - * The hit field used to store rank features. TODO: Remove + * The hit field used to store rank features. TODO: Remove on Vespa 7 */ public static final String RANKFEATURES_FIELD = "rankfeatures"; public static final String SDDOCNAME_FIELD = "sddocname"; - private Map<String,Object> getFieldMap() { - return getFieldMap(16); - } - private Map<String,Object> getFieldMap(int minSize) { - if (fields == null) { - // Compensate for loadfactor and then some, rounded up.... - fields = new LinkedHashMap<>(2*minSize); - } - return fields; - } - - private Map<String,Object> getUnmodifiableFieldMap() { - if (unmodifiableFieldMap == null) { - if (fields == null) { - return Collections.emptyMap(); - } else { - unmodifiableFieldMap = Collections.unmodifiableMap(fields); - } - } - return unmodifiableFieldMap; - } - - public static String stripCharacter(char strip, String toStripFrom) { - StringBuilder builder = null; - - int lastBadChar = 0; - for (int i = 0; i < toStripFrom.length(); i++) { - if (toStripFrom.charAt(i) == strip) { - if (builder == null) { - builder = new StringBuilder(toStripFrom.length()); - } - - builder.append(toStripFrom, lastBadChar, i); - lastBadChar = i + 1; - } - } - - if (builder == null) { - return toStripFrom; - } else { - if (lastBadChar < toStripFrom.length()) { - builder.append(toStripFrom, lastBadChar, toStripFrom.length()); - } - - return builder.toString(); - } - } - /** Creates an (invalid) empty hit. Id and relevance must be set before handoff */ protected Hit() {} @@ -461,8 +413,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi /** * Fields - * @return An iterator for traversing the fields - * @since 5.1.3 + * + * @return an iterator for traversing the fields of this hit */ public final Iterator<Map.Entry<String,Object>> fieldIterator() { return getFieldMap().entrySet().iterator(); } @@ -470,21 +422,23 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi public Object getField(String value) { return fields != null ? fields.get(value) : null; } /** - * Generate a HitField from a field if the field exists. Does the - * same as getField() in earlier versions. - * - * @since 3.0 + * Generate a HitField from a field if the field exists. + * + * @deprecated do not use */ + // TODO: Remove on Vespa 7 + @Deprecated public HitField buildHitField(String key) { return buildHitField(key, false); } /** - * Generate a HitField from a field if the field exists. Does the - * same as getField() in earlier versions. + * Generate a HitField from a field if the field exists. * - * @since 3.0 + * @deprecated do not use */ + // TODO: Remove on Vespa 7 + @Deprecated public HitField buildHitField(String key, boolean forceNoPreTokenize) { return buildHitField(key, forceNoPreTokenize, false); } @@ -798,4 +752,52 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi return filled; } + private Map<String,Object> getFieldMap() { + return getFieldMap(16); + } + private Map<String,Object> getFieldMap(int minSize) { + if (fields == null) { + // Compensate for loadfactor and then some, rounded up.... + fields = new LinkedHashMap<>(2*minSize); + } + return fields; + } + + private Map<String,Object> getUnmodifiableFieldMap() { + if (unmodifiableFieldMap == null) { + if (fields == null) { + return Collections.emptyMap(); + } else { + unmodifiableFieldMap = Collections.unmodifiableMap(fields); + } + } + return unmodifiableFieldMap; + } + + public static String stripCharacter(char strip, String toStripFrom) { + StringBuilder builder = null; + + int lastBadChar = 0; + for (int i = 0; i < toStripFrom.length(); i++) { + if (toStripFrom.charAt(i) == strip) { + if (builder == null) { + builder = new StringBuilder(toStripFrom.length()); + } + + builder.append(toStripFrom, lastBadChar, i); + lastBadChar = i + 1; + } + } + + if (builder == null) { + return toStripFrom; + } else { + if (lastBadChar < toStripFrom.length()) { + builder.append(toStripFrom, lastBadChar, toStripFrom.length()); + } + + return builder.toString(); + } + } + } |