diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/result/Hit.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/result/Hit.java | 176 |
1 files changed, 12 insertions, 164 deletions
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 c5132549d05..db5b3e69803 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 @@ -106,9 +106,7 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi /** If this is true, then this hit will not be counted as a concrete hit */ private boolean auxiliary = false; - /** - * The hit field used to store rank features. TODO: Remove on Vespa 7 - */ + /** The hit field used to store rank features */ public static final String RANKFEATURES_FIELD = "rankfeatures"; public static final String SDDOCNAME_FIELD = "sddocname"; @@ -420,7 +418,7 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi */ public void forEachFieldAsRaw(RawUtf8Consumer consumer) { if (fields == null) return; - fields.forEach(consumer); // No utf-8 fields available in Hit + fields.forEach(consumer); } /** Returns the fields of this as a read-only map. This is more costly than fieldIterator() */ @@ -478,20 +476,6 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi return fields != null && ! fields.isEmpty(); } - /** - * Changes the key under which a value is found. This is useful because it allows keys to be changed - * without accessing the value (which may be lazily created). - * - * @deprecated do not use - */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - public void changeFieldKey(String oldKey, String newKey) { - Map<String,Object> fieldMap = getFieldMap(); - Object value = fieldMap.remove(oldKey); - fieldMap.put(newKey, value); - } - private Map<String, Object> getFieldMap() { return getFieldMap(2); } @@ -515,42 +499,16 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi return unmodifiableFieldMap; } - /** Generate a HitField from a field if the field exists */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - public HitField buildHitField(String key) { - return buildHitField(key, false); - } - - /** Generate a HitField from a field if the field exists */ - @SuppressWarnings("deprecation") - // TODO: Remove on Vespa 7 - @Deprecated // OK public HitField buildHitField(String key, boolean forceNoPreTokenize) { - return buildHitField(key, forceNoPreTokenize, false); - } - - // TODO: Remove third parameter on Vespa 7 (set always true) - @Deprecated // OK - public HitField buildHitField(String key, boolean forceNoPreTokenize, boolean forceStringHandling) { Object o = getField(key); if (o == null) return null; if (o instanceof HitField) return (HitField)o; HitField h; - if (forceNoPreTokenize) { - if (o instanceof XMLString && !forceStringHandling) { - h = new HitField(key, (XMLString) o, false); - } else { - h = new HitField(key, o.toString(), false); - } - } else { - if (o instanceof XMLString && !forceStringHandling) { - h = new HitField(key, (XMLString) o); - } else { - h = new HitField(key, o.toString()); - } - } + if (forceNoPreTokenize) + h = new HitField(key, o.toString(), false); + else + h = new HitField(key, o.toString()); h.setOriginal(o); getFieldMap().put(key, h); return h; @@ -559,34 +517,19 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi /** Returns the types of this as a modifiable set. Modifications to this set are directly reflected in this hit */ public Set<String> types() { return types; } - /** @deprecated do not use */ - // TODO: FRemove on Vespa 7 - @Deprecated // OK - public String getTypeString() { - return types().stream().collect(Collectors.joining(" ")); - } - /** * Returns the add number, assigned when adding the hit to a Result. * * Used to order equal relevant hit by add order. -1 if this hit * has never been added to a result. - * - * @deprecated do not use */ - // TODO: Make package private on Vespa 7 - @Deprecated // OK - public int getAddNumber() { return addNumber; } + int getAddNumber() { return addNumber; } /** * Sets the add number, assigned when adding the hit to a Result, * used to order equal relevant hit by add order. - * - * @deprecated do not use */ - // TODO: Make package private on Vespa 7 - @Deprecated // OK - public void setAddNumber(int addNumber) { this.addNumber = addNumber; } + void setAddNumber(int addNumber) { this.addNumber = addNumber; } /** * Returns whether this is a concrete hit, containing content of the requested @@ -610,16 +553,6 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi public void setAuxiliary(boolean auxiliary) { this.auxiliary = auxiliary; } - /** @deprecated do not use */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - public int getSourceNumber() { return sourceNumber; } - - /** @deprecated do not use */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - public void setSourceNumber(int number) { this.sourceNumber = number; } - /** Returns the query which produced this hit, or null if not known */ public Query getQuery() { return query; } @@ -633,52 +566,6 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi } } - /** - * Returns a field of this hit XML escaped and without token - * delimiters. - * - * @deprecated do not use - * @return a field of this hit, or null if the property is not set - */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - public String getFieldXML(String key) { - Object p = getField(key); - - if (p == null) { - return null; - } else if (p instanceof HitField) { - return ((HitField)p).quotedContent(false); - } else if (p instanceof StructuredData || p instanceof XMLString || p instanceof JSONString) { - return p.toString(); - } else { - return XML.xmlEscape(p.toString(), false, '\u001f'); - } - } - - /** - * @deprecated do not use - */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - public String getUnboldedField(String key, boolean escape) { - Object p = getField(key); - - if (p == null) { - return null; - } else if (p instanceof HitField) { - return ((HitField) p).bareContent(escape, false); - } else if (p instanceof StructuredData) { - return p.toString(); - } else if (p instanceof XMLString || p instanceof JSONString) { - return p.toString(); - } else if (escape) { - return XML.xmlEscape(p.toString(), false, '\u001f'); - } else { - return stripCharacter('\u001F', p.toString()); - } - } - /** Attach some data to this hit for this searcher */ public void setSearcherSpecificMetaData(Searcher searcher, Object data) { if (searcherSpecificMetaData == null) { @@ -703,60 +590,21 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi return searcherSpecificMetaData != null ? searcherSpecificMetaData.get(searcher) : null; } - /** - * Internal - do not use - * - * @param filled the backing set - */ - // TODO: Make package private on Vespa 7 - protected final void setFilledInternal(Set<String> filled) { + final void setFilledInternal(Set<String> filled) { this.filled = filled; unmodifiableFilled = (filled != null) ? Collections.unmodifiableSet(filled) : null; } /** - * For internal use only. * Gives access to the modifiable backing set of filled summaries. * This set might be unmodifiable if the size is less than or equal to 1 * * @return the set of filled summaries. */ - // TODO: Make package private on Vespa 7 - protected final Set<String> getFilledInternal() { + final Set<String> getFilledInternal() { return filled; } - /** - * @deprecated do not use - */ - // TODO: Remove on Vespa 7 - @Deprecated // OK - 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(); - } - } - /** Releases the resources held by this, making it irreversibly unusable */ protected void close() { query = null; @@ -832,8 +680,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi * * @param fieldName the name of the field * @param utf8Data raw utf-8 data. The reciver <b>must not</b> modify this data - * @param offset the start index of the data to accept into the utf8Data array - * @param length the length of the data to accept into the utf8Data array + * @param offset the start index in the utf8Data array of the data to accept + * @param length the length starting from offset in the utf8Data array of the data to accept */ void accept(String fieldName, byte[] utf8Data, int offset, int length); |