org.apache.lucene.codecs
Class DocValuesArraySource

java.lang.Object
  extended by org.apache.lucene.index.DocValues.Source
      extended by org.apache.lucene.codecs.DocValuesArraySource

public abstract class DocValuesArraySource
extends DocValues.Source

DocValues DocValues.Source implementation backed by simple arrays.

WARNING: This API is experimental and might change in incompatible ways in the next release.
NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

Field Summary
protected  int bytesPerValue
          Number of bytes to encode each doc value.
 
Fields inherited from class org.apache.lucene.index.DocValues.Source
type
 
Method Summary
static int asInt(BytesRef b)
          Converts 4 consecutive bytes from the current offset to an int.
static long asLong(BytesRef b)
          Converts 8 consecutive bytes from the current offset to a long.
static short asShort(BytesRef b)
          Converts 2 consecutive bytes from the current offset to a short.
static void copyInt(BytesRef ref, int value)
          Copies the given int value and encodes it as 4 byte Big-Endian.
static void copyLong(BytesRef ref, long value)
          Copies the given long value and encodes it as 8 byte Big-Endian.
static void copyShort(BytesRef ref, short value)
          Copies the given short value and encodes it as a 2 byte Big-Endian.
static DocValuesArraySource forType(DocValues.Type type)
          Returns the DocValuesArraySource for the given DocValues.Type.
abstract  BytesRef getBytes(int docID, BytesRef ref)
          Returns a BytesRef for the given document id or throws an UnsupportedOperationException if this source doesn't support byte[] values.
 boolean hasArray()
          Returns true iff this DocValues.Source exposes an array via DocValues.Source.getArray() otherwise false.
abstract  DocValuesArraySource newFromArray(Object array)
          Creates DocValuesArraySource from a native array.
abstract  DocValuesArraySource newFromInput(IndexInput input, int numDocs)
          Creates a DocValuesArraySource by loading a previously saved one from an IndexInput.
 void toBytes(double value, BytesRef bytesRef)
          Encode a double value into the provided BytesRef.
 void toBytes(long value, BytesRef bytesRef)
          Encode a long value into the provided BytesRef.
 
Methods inherited from class org.apache.lucene.index.DocValues.Source
asSortedSource, getArray, getFloat, getInt, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bytesPerValue

protected final int bytesPerValue
Number of bytes to encode each doc value.

Method Detail

forType

public static DocValuesArraySource forType(DocValues.Type type)
Returns the DocValuesArraySource for the given DocValues.Type.


getBytes

public abstract BytesRef getBytes(int docID,
                                  BytesRef ref)
Description copied from class: DocValues.Source
Returns a BytesRef for the given document id or throws an UnsupportedOperationException if this source doesn't support byte[] values.

Overrides:
getBytes in class DocValues.Source

newFromInput

public abstract DocValuesArraySource newFromInput(IndexInput input,
                                                  int numDocs)
                                           throws IOException
Creates a DocValuesArraySource by loading a previously saved one from an IndexInput.

Throws:
IOException

newFromArray

public abstract DocValuesArraySource newFromArray(Object array)
Creates DocValuesArraySource from a native array.


hasArray

public final boolean hasArray()
Description copied from class: DocValues.Source
Returns true iff this DocValues.Source exposes an array via DocValues.Source.getArray() otherwise false.

Overrides:
hasArray in class DocValues.Source
Returns:
true iff this DocValues.Source exposes an array via DocValues.Source.getArray() otherwise false.

toBytes

public void toBytes(long value,
                    BytesRef bytesRef)
Encode a long value into the provided BytesRef.


toBytes

public void toBytes(double value,
                    BytesRef bytesRef)
Encode a double value into the provided BytesRef.


copyLong

public static void copyLong(BytesRef ref,
                            long value)
Copies the given long value and encodes it as 8 byte Big-Endian.

NOTE: this method resets the offset to 0, length to 8 and resizes the reference array if needed.


copyInt

public static void copyInt(BytesRef ref,
                           int value)
Copies the given int value and encodes it as 4 byte Big-Endian.

NOTE: this method resets the offset to 0, length to 4 and resizes the reference array if needed.


copyShort

public static void copyShort(BytesRef ref,
                             short value)
Copies the given short value and encodes it as a 2 byte Big-Endian.

NOTE: this method resets the offset to 0, length to 2 and resizes the reference array if needed.


asShort

public static short asShort(BytesRef b)
Converts 2 consecutive bytes from the current offset to a short. Bytes are interpreted as Big-Endian (most significant bit first)

NOTE: this method does NOT check the bounds of the referenced array.


asInt

public static int asInt(BytesRef b)
Converts 4 consecutive bytes from the current offset to an int. Bytes are interpreted as Big-Endian (most significant bit first)

NOTE: this method does NOT check the bounds of the referenced array.


asLong

public static long asLong(BytesRef b)
Converts 8 consecutive bytes from the current offset to a long. Bytes are interpreted as Big-Endian (most significant bit first)

NOTE: this method does NOT check the bounds of the referenced array.



Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.