Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.util.packed
Class GrowableWriter

    java.lang.Object
      org.apache.lucene.util.packed.GrowableWriter

All Implemented Interfaces:
  PackedInts.Mutable, PackedInts.Reader

    public class GrowableWriter

extends Object
implements PackedInts.Mutable

Implements `PackedInts.Mutable`, but grows the bit count of the underlying packed ints on-demand.

@lucene.internal

Constructor Summary
`GrowableWriter(int startBitsPerValue, int valueCount, float acceptableOverheadRatio)`

Method Summary
`void` | `clear()` Sets all values to 0.
`void` | `fill(int fromIndex, int toIndex, long val)` Fill the mutable from `fromIndex` (inclusive) to `toIndex` (exclusive) with `val`.
`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()`
`PackedInts.Mutable` | `getMutable()`
`boolean` | `hasArray()` Returns true if this implementation is backed by a native java array.
`long` | `ramBytesUsed()` Return the in-memory size in bytes.
`GrowableWriter` | `resize(int newSize)`
`void` | `save(DataOutput out)` Save this mutable into `out`.
`void` | `set(int index, long value)` Set the value at the given index in the array.
`int` | `set(int index, long[] arr, int off, int len)` Bulk set: set at least one and at most `len` longs starting at `off` in `arr` into this mutable, starting at `index`.
`int` | `size()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GrowableWriter

    public GrowableWriter(int startBitsPerValue,
                          int valueCount,
                          float acceptableOverheadRatio)

Method Detail

### get

    public long get(int index)

  Specified by:
    `get` in interface `PackedInts.Reader`
  Parameters:
    `index` - the position of the wanted value.
  Returns:
    the value at the stated index.

### size

    public int size()

  Specified by:
    `size` in interface `PackedInts.Reader`
  Returns:
    the number of values.

### getBitsPerValue

    public int getBitsPerValue()

  Specified by:
    `getBitsPerValue` in interface `PackedInts.Reader`
  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.

### getMutable

    public PackedInts.Mutable getMutable()

### getArray

    public Object getArray()

  Description copied from interface: `PackedInts.Reader`
  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.

  Specified by:
    `getArray` in interface `PackedInts.Reader`

### hasArray

    public boolean hasArray()

  Description copied from interface: `PackedInts.Reader`
  Returns true if this implementation is backed by a native java array.

  Specified by:
    `hasArray` in interface `PackedInts.Reader`
  See Also:
    `PackedInts.Reader.getArray()`

### set

    public void set(int index,
                    long value)

  Description copied from interface: `PackedInts.Mutable`
  Set the value at the given index in the array.

  Specified by:
    `set` in interface `PackedInts.Mutable`
  Parameters:
    `index` - where the value should be positioned.
    `value` - a value conforming to the constraints set by the array.

### clear

    public void clear()

  Description copied from interface: `PackedInts.Mutable`
  Sets all values to 0.

  Specified by:
    `clear` in interface `PackedInts.Mutable`

### resize

    public GrowableWriter resize(int newSize)

### get

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

  Description copied from interface: `PackedInts.Reader`
  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.

  Specified by:
    `get` in interface `PackedInts.Reader`

### set

    public int set(int index,
                   long[] arr,
                   int off,
                   int len)

  Description copied from interface: `PackedInts.Mutable`
  Bulk set: set at least one and at most `len` longs starting at `off` in `arr` into this mutable, starting at `index`. Returns the actual number of values that have been set.

  Specified by:
    `set` in interface `PackedInts.Mutable`

### fill

    public void fill(int fromIndex,
                     int toIndex,
                     long val)

  Description copied from interface: `PackedInts.Mutable`
  Fill the mutable from `fromIndex` (inclusive) to `toIndex` (exclusive) with `val`.

  Specified by:
    `fill` in interface `PackedInts.Mutable`

### ramBytesUsed

    public long ramBytesUsed()

  Description copied from interface: `PackedInts.Reader`
  Return the in-memory size in bytes.

  Specified by:
    `ramBytesUsed` in interface `PackedInts.Reader`

### save

    public void save(DataOutput out)
              throws IOException

  Description copied from interface: `PackedInts.Mutable`
  Save this mutable into `out`. Instantiating a reader from the generated data will return a reader with the same number of bits per value.

  Specified by:
    `save` in interface `PackedInts.Mutable`
  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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