FixedLengthBytesRefArray (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.util, class: FixedLengthBytesRefArray

Package org.apache.lucene.util

# Class FixedLengthBytesRefArray

java.lang.Object
org.apache.lucene.util.FixedLengthBytesRefArray

public final class FixedLengthBytesRefArray extends Object
Just like `BytesRefArray` except all values have the same length.

Note: This class is not Thread-Safe!

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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FixedLengthBytesRefArray(int valueLength)`
  Creates a new `BytesRefArray` with a counter to track allocated bytes

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `append(BytesRef bytes)`
  Appends a copy of the given `BytesRef` to this `BytesRefArray`.
  `void`
  `clear()`
  Clears this `BytesRefArray`
  `BytesRef`
  `get(BytesRef spare, int index)`
  Returns the n'th element of this `FixedLengthBytesRefArray`
  `BytesRefIterator`
  `iterator(Comparator<BytesRef> comp)`
  Returns a `BytesRefIterator` with point in time semantics.
  `int`
  `size()`
  Returns the current size of this `FixedLengthBytesRefArray`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FixedLengthBytesRefArray

    public FixedLengthBytesRefArray(int valueLength)
    Creates a new `BytesRefArray` with a counter to track allocated bytes

- ## Method Details

  - ### clear

    public void clear()
    Clears this `BytesRefArray`

  - ### append

    public int append(BytesRef bytes)
    Appends a copy of the given `BytesRef` to this `BytesRefArray`.
    Parameters:
      `bytes` - the bytes to append
    Returns:
      the index of the appended bytes

  - ### get

    public BytesRef get(BytesRef spare, int index)
    Returns the n'th element of this `FixedLengthBytesRefArray`
    Parameters:
      `spare` - a spare `BytesRef` instance. The length of this spare should be equal to the fixed length.
      `index` - the elements index to retrieve
    Returns:
      the n'th element of this `FixedLengthBytesRefArray`

  - ### size

    public int size()
    Returns the current size of this `FixedLengthBytesRefArray`
    Returns:
      the current size of this `FixedLengthBytesRefArray`

  - ### iterator

    public BytesRefIterator iterator(Comparator<BytesRef> comp)
    Returns a `BytesRefIterator` with point in time semantics. The iterator provides access to all so far appended `BytesRef` instances.

    The iterator will iterate the byte values in the order specified by the comparator.

    This is a non-destructive operation.