Package com.yahoo.prelude.fastsearch
Class FastHit
- java.lang.Object
-
- com.yahoo.component.provider.FreezableClass
-
- com.yahoo.component.provider.ListenableFreezableClass
-
- com.yahoo.search.result.Hit
-
- com.yahoo.prelude.fastsearch.FastHit
-
- All Implemented Interfaces:
com.yahoo.component.provider.Freezable
,com.yahoo.component.provider.ListenableFreezable
,com.yahoo.processing.response.Data
,java.lang.Cloneable
,java.lang.Comparable<Hit>
public class FastHit extends Hit
A regular hit from a Vespa backend- Author:
- bratseth, Steinar Knutsen
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.yahoo.search.result.Hit
Hit.RawUtf8Consumer
-
-
Field Summary
-
Fields inherited from class com.yahoo.search.result.Hit
RANKFEATURES_FIELD, SDDOCNAME_FIELD
-
-
Constructor Summary
Constructors Constructor Description FastHit()
Creates an empty and temporarily invalid summary hitFastHit(byte[] gid, double relevance, int partId, int distributionKey)
FastHit(byte[] gid, Relevance relevance, int partId, int distributionKey)
FastHit(java.lang.String uri, double relevancy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSummary(DocsumDefinition docsumDef, com.yahoo.data.access.Inspector value)
For internal usevoid
clearFields()
Removes all fields of thisint
compareTo(Hit other)
Compares this hit to another hitFeatureData
features()
Returns values for the features listed in summary-features in the rank profile specified in the query producing this.java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Object>>
fieldIterator()
Returns a modifiable iterator over the fields of thisjava.util.Set<java.lang.String>
fieldKeys()
Returns the keys of the fields of this hit as a modifiable view.java.util.Map<java.lang.String,java.lang.Object>
fields()
Returns the fields of this as a read-only map.void
forEachField(java.util.function.BiConsumer<java.lang.String,java.lang.Object> consumer)
Receive a callback on the given object for each field in this hit.void
forEachFieldAsRaw(Hit.RawUtf8Consumer consumer)
Receive a callback on the given object for each field in this hit, where the callback will provide raw utf-8 byte data for strings whose data is already available at this form.int
getDistributionKey()
Returns the index of the node this hit originated atjava.lang.Object
getField(java.lang.String name)
Returns a field value from this Hit.com.yahoo.document.GlobalId
getGlobalId()
Returns the global id of this document in the backend node which produced itcom.yahoo.net.URI
getId()
Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwiseint
getPartId()
byte[]
getRawGlobalId()
protected boolean
hasField(java.lang.String name)
Returns whether this field is present in the field map in the parent hitprotected boolean
hasFields()
Returns whether any fields are present in the field map in the parent hitint
hashCode()
Returns the hashCode of this hit: The hashcode of its idboolean
isMeta()
Returns false - this is a concrete hit containing requested contentjava.lang.Object
removeField(java.lang.String name)
Removes a field from thisvoid
setDistributionKey(int distributionKey)
Sets the index of the node this hit originated atjava.lang.Object
setField(java.lang.String name, java.lang.Object value)
Sets the value of a fieldvoid
setGlobalId(byte[] globalId)
void
setPartId(int partId)
Sets the part id number, which specifies the node where this hit is found.void
setSortData(byte[] data, Sorting sorting)
java.util.List<com.yahoo.prelude.fastsearch.FastHit.SummaryData>
summaryData()
Returns the raw summary data available in this as an unmodifiable listjava.lang.String
toString()
-
Methods inherited from class com.yahoo.search.result.Hit
assignId, buildHitField, clone, close, equals, getDisplayId, getFilled, getQuery, getRelevance, getSearcherSpecificMetaData, getSource, isAuxiliary, isCached, isFillable, isFilled, request, reserve, setAuxiliary, setCached, setFillable, setFilled, setId, setId, setMeta, setQuery, setRelevance, setRelevance, setSearcherSpecificMetaData, setSource, types
-
Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass
addFreezeListener, freeze
-
-
-
-
Constructor Detail
-
FastHit
public FastHit()
Creates an empty and temporarily invalid summary hit
-
FastHit
public FastHit(byte[] gid, double relevance, int partId, int distributionKey)
-
FastHit
public FastHit(byte[] gid, Relevance relevance, int partId, int distributionKey)
-
FastHit
public FastHit(java.lang.String uri, double relevancy)
-
-
Method Detail
-
isMeta
public boolean isMeta()
Returns false - this is a concrete hit containing requested content
-
getId
public com.yahoo.net.URI getId()
Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwise
-
getGlobalId
public com.yahoo.document.GlobalId getGlobalId()
Returns the global id of this document in the backend node which produced it
-
getRawGlobalId
public byte[] getRawGlobalId()
-
setGlobalId
public void setGlobalId(byte[] globalId)
-
getPartId
public int getPartId()
-
setPartId
public void setPartId(int partId)
Sets the part id number, which specifies the node where this hit is found. The row count is used to decode the part id into a column and a row number: the number of n least significant bits required to hold the highest row number are the row bits, the rest are column bits. Note: Remove partId when all dispatching happens from the container dispatcher, not fdispatch
-
getDistributionKey
public int getDistributionKey()
Returns the index of the node this hit originated at
-
setDistributionKey
public void setDistributionKey(int distributionKey)
Sets the index of the node this hit originated at
-
setSortData
public void setSortData(byte[] data, Sorting sorting)
-
compareTo
public int compareTo(Hit other)
Description copied from class:Hit
Compares this hit to another hit
-
addSummary
public void addSummary(DocsumDefinition docsumDef, com.yahoo.data.access.Inspector value)
For internal use
-
summaryData
public java.util.List<com.yahoo.prelude.fastsearch.FastHit.SummaryData> summaryData()
Returns the raw summary data available in this as an unmodifiable list
-
features
public FeatureData features()
Returns values for the features listed in summary-features in the rank profile specified in the query producing this.
-
getField
public java.lang.Object getField(java.lang.String name)
Returns a field value from this Hit. The value is either a stored value from the Document represented by this Hit, or a generated value added during later processing.
The values available from the matching Document are a subset of the values set in the document, determined by the
filled
status of this Hit. More fields may be requested by requesting further filling.Lookups on names which does not exists in the document and is not added by later processing return null.
Lookups on fields which exist in the document, in a summary class which is already requested filled returns the following types, even when the field has no actual value:
- string and uri fields: A Java String.
The empty string ("") if no value is assigned in the document. - Dynamic summary string fields: A Java String before JuniperSearcher and a HitField after.
- Numerics: The corresponding numeric Java type.
If the field has no value assigned in the document, the special numericNanNumber.NaN
is returned. - raw fields: A
RawData
instance - tensor fields: A
Tensor
instance - multivalue fields: A
Inspector
instance
- string and uri fields: A Java String.
-
setField
public java.lang.Object setField(java.lang.String name, java.lang.Object value)
Description copied from class:Hit
Sets the value of a field
-
forEachField
public void forEachField(java.util.function.BiConsumer<java.lang.String,java.lang.Object> consumer)
Description copied from class:Hit
Receive a callback on the given object for each field in this hit. This is more efficient than accessing the fields as a map or iterator.- Overrides:
forEachField
in classHit
-
forEachFieldAsRaw
public void forEachFieldAsRaw(Hit.RawUtf8Consumer consumer)
Description copied from class:Hit
Receive a callback on the given object for each field in this hit, where the callback will provide raw utf-8 byte data for strings whose data is already available at this form. This is the most resource efficient way of traversing all the fields of a hit in renderers which produces utf-8.- Overrides:
forEachFieldAsRaw
in classHit
-
fields
public java.util.Map<java.lang.String,java.lang.Object> fields()
Description copied from class:Hit
Returns the fields of this as a read-only map. This is more costly than fieldIterator()
-
fieldIterator
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Object>> fieldIterator()
Description copied from class:Hit
Returns a modifiable iterator over the fields of this- Overrides:
fieldIterator
in classHit
-
fieldKeys
public java.util.Set<java.lang.String> fieldKeys()
Returns the keys of the fields of this hit as a modifiable view. This follows the rules of key sets returned from maps: Key removals are reflected in the map, add and addAll is not supported.
-
clearFields
public void clearFields()
Removes all fields of this- Overrides:
clearFields
in classHit
-
removeField
public java.lang.Object removeField(java.lang.String name)
Removes a field from this- Overrides:
removeField
in classHit
- Returns:
- the removed value of the field, or null if none
-
hasField
protected boolean hasField(java.lang.String name)
Returns whether this field is present in the field map in the parent hit
-
hasFields
protected boolean hasFields()
Returns whether any fields are present in the field map in the parent hit
-
-