org.apache.lucene.util.packed

## Interface PackedInts.Reader

- All Known Subinterfaces:
    PackedInts.Mutable
  All Known Implementing Classes:
    GrowableWriter, PackedInts.NullReader
  Enclosing class:
    PackedInts

      public static interface PackedInts.Reader

  A read-only random access array of positive integers.
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `get(int index)`
    `int` | `get(int index, long[] arr, int off, int len)` Bulk get: read at least one and at most `len` longs starting from `index` into `arr[off:off+len]` and return the actual number of values that have been read.
    `Object` | `getArray()` Expert: if the bit-width of this reader matches one of java's native types, returns the underlying array (ie, byte[], short[], int[], long[]); else, returns null.
    `int` | `getBitsPerValue()`
    `boolean` | `hasArray()` Returns true if this implementation is backed by a native java array.
    `long` | `ramBytesUsed()` Return the in-memory size in bytes.
    `int` | `size()`

- - ### Method Detail

    - #### get

          long get(int index)

      Parameters:
        `index` - the position of the wanted value.
      Returns:
        the value at the stated index.

    - #### get

          int get(int index,
                long[] arr,
                int off,
                int len)

      Bulk get: read at least one and at most `len` longs starting from `index` into `arr[off:off+len]` and return the actual number of values that have been read.

    - #### getBitsPerValue

          int getBitsPerValue()

      Returns:
        the number of bits used to store any given value. Note: This does not imply that memory usage is `bitsPerValue * #values` as implementations are free to use non-space-optimal packing of bits.

    - #### size

          int size()

      Returns:
        the number of values.

    - #### ramBytesUsed

          long ramBytesUsed()

      Return the in-memory size in bytes.

    - #### getArray

          Object getArray()

      Expert: if the bit-width of this reader matches one of java's native types, returns the underlying array (ie, byte[], short[], int[], long[]); else, returns null. Note that when accessing the array you must upgrade the type (bitwise AND with all ones), to interpret the full value as unsigned. Ie, bytes[idx]&0xFF, shorts[idx]&0xFFFF, etc.

    - #### hasArray

          boolean hasArray()

      Returns true if this implementation is backed by a native java array.
      See Also:
        `getArray()`

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