Documentation of 'org.apache.lucene.index.Payload' Java class
Payload
org.apache.lucene.index

Class Payload

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class Payload
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    A Payload is metadata that can be stored together with each occurrence of a term. This metadata is stored inline in the posting list of the specific term.

    To store payloads in the index a TokenStream has to be used that produces Tokens containing payload data.

    Use TermPositions.getPayloadLength() and TermPositions.getPayload(byte[], int) to retrieve the payloads from the index.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Payload()
      Creates an empty payload and does not allocate a byte array.
      Payload(byte[] data)
      Creates a new payload with the the given array as data.
      Payload(byte[] data, int offset, int length)
      Creates a new payload with the the given array as data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      byte byteAt(int index)
      Returns the byte at the given index.
      java.lang.Object clone()
      Clones this payload by creating a copy of the underlying byte array.
      void copyTo(byte[] target, int targetOffset)
      Copies the payload data to a byte array.
      byte[] getData()
      Returns a reference to the underlying byte array that holds this payloads data.
      int getOffset()
      Returns the offset in the underlying byte array
      int length()
      Returns the length of the payload data.
      void setData(byte[] data)
      Sets this payloads data.
      void setData(byte[] data, int offset, int length)
      Sets this payloads data.
      byte[] toByteArray()
      Allocates a new byte array, copies the payload data into it and returns it.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Payload

        public Payload()
        Creates an empty payload and does not allocate a byte array.
      • Payload

        public Payload(byte[] data)
        Creates a new payload with the the given array as data. A reference to the passed-in array is held, i. e. no copy is made.
        Parameters:
        data - the data of this payload
      • Payload

        public Payload(byte[] data,
                       int offset,
                       int length)
        Creates a new payload with the the given array as data. A reference to the passed-in array is held, i. e. no copy is made.
        Parameters:
        data - the data of this payload
        offset - the offset in the data byte array
        length - the length of the data
    • Method Detail

      • setData

        public void setData(byte[] data)
        Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.
      • setData

        public void setData(byte[] data,
                            int offset,
                            int length)
        Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.
      • getData

        public byte[] getData()
        Returns a reference to the underlying byte array that holds this payloads data.
      • getOffset

        public int getOffset()
        Returns the offset in the underlying byte array
      • length

        public int length()
        Returns the length of the payload data.
      • byteAt

        public byte byteAt(int index)
        Returns the byte at the given index.
      • toByteArray

        public byte[] toByteArray()
        Allocates a new byte array, copies the payload data into it and returns it.
      • copyTo

        public void copyTo(byte[] target,
                           int targetOffset)
        Copies the payload data to a byte array.
        Parameters:
        target - the target byte array
        targetOffset - the offset in the target byte array
      • clone

        public java.lang.Object clone()
        Clones this payload by creating a copy of the underlying byte array.
        Overrides:
        clone in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.