Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      FastHit()
      Creates an empty and temporarily invalid summary hit
      FastHit​(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 use
      void clearFields()
      Removes all fields of this
      int compareTo​(Hit other)
      Compares this hit to another hit
      FeatureData 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 this
      java.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 at
      java.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 it
      com.yahoo.net.URI getId()
      Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwise
      int getPartId()  
      byte[] getRawGlobalId()  
      protected boolean hasField​(java.lang.String name)
      Returns whether this field is present in the field map in the parent hit
      protected boolean hasFields()
      Returns whether any fields are present in the field map in the parent hit
      int hashCode()
      Returns the hashCode of this hit: The hashcode of its id
      boolean isMeta()
      Returns false - this is a concrete hit containing requested content
      java.lang.Object removeField​(java.lang.String name)
      Removes a field from this
      void setDistributionKey​(int distributionKey)
      Sets the index of the node this hit originated at
      java.lang.Object setField​(java.lang.String name, java.lang.Object value)
      Sets the value of a field
      void 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 list
      java.lang.String toString()  
      • Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass

        addFreezeListener, freeze
      • Methods inherited from class com.yahoo.component.provider.FreezableClass

        ensureNotFrozen, isFrozen
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.yahoo.component.provider.Freezable

        freeze, isFrozen
      • Methods inherited from interface com.yahoo.component.provider.ListenableFreezable

        addFreezeListener
    • 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
        Overrides:
        isMeta in class Hit
      • getId

        public com.yahoo.net.URI getId()
        Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwise
        Overrides:
        getId in class Hit
        Returns:
        uri of hit
      • 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
        Specified by:
        compareTo in interface java.lang.Comparable<Hit>
        Overrides:
        compareTo in class 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.
        Overrides:
        features in class Hit
      • 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 numeric NanNumber.NaN is returned.
        • raw fields: A RawData instance
        • tensor fields: A Tensor instance
        • multivalue fields: A Inspector instance
        Overrides:
        getField in class Hit
      • 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
        Overrides:
        setField in class Hit
        Returns:
        the previous value, or null if none
      • 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 class Hit
      • 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 class Hit
      • 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()
        Overrides:
        fields in class Hit
      • 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 class Hit
      • 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.
        Overrides:
        fieldKeys in class Hit
      • clearFields

        public void clearFields()
        Removes all fields of this
        Overrides:
        clearFields in class Hit
      • removeField

        public java.lang.Object removeField​(java.lang.String name)
        Removes a field from this
        Overrides:
        removeField in class Hit
        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
        Overrides:
        hasField in class Hit
      • hasFields

        protected boolean hasFields()
        Returns whether any fields are present in the field map in the parent hit
        Overrides:
        hasFields in class Hit
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Hit
      • hashCode

        public int hashCode()
        Description copied from class: Hit
        Returns the hashCode of this hit: The hashcode of its id
        Overrides:
        hashCode in class Hit