org.apache.lucene.index

Class Payload

public class Payload extends Object implements Serializable

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 getPayloadLength and (byte[], int) to retrieve the payloads from the index.

WARNING: The status of the Payloads feature is experimental. The APIs introduced here might change in the future and will not be supported anymore in such a case.

Field Summary
protected byte[]data
the byte array containing the payload data
protected intlength
the length of the payload data
protected intoffset
the offset within the byte array
Constructor Summary
protected 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
bytebyteAt(int index)
Returns the byte at the given index.
voidcopyTo(byte[] target, int targetOffset)
Copies the payload data to a byte array.
intlength()
Returns the length of the payload data.
byte[]toByteArray()
Allocates a new byte array, copies the payload data into it and returns it.

Field Detail

data

protected byte[] data
the byte array containing the payload data

length

protected int length
the length of the payload data

offset

protected int offset
the offset within the byte array

Constructor Detail

Payload

protected 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.

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.

Parameters: data the data of this payload offset the offset in the data byte array length the length of the data

Method Detail

byteAt

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

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

length

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

toByteArray

public byte[] toByteArray()
Allocates a new byte array, copies the payload data into it and returns it.
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.