LongColumn (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.document.column, class: LongColumn

Package org.apache.lucene.document.column

# Class LongColumn

java.lang.Object
org.apache.lucene.document.column.Column
org.apache.lucene.document.column.LongColumn

public abstract class LongColumn extends Column
A `Column` that provides long values. Used for `NUMERIC` and `SORTED_NUMERIC` doc values and for stored numeric fields.

Iteration is performed via cursors. `tuples()` is always available and yields `(docID, longValue)` pairs. `values()` is a bulk cursor over consecutive doc-ids; it must be overridden when `Column.density()` is `DENSE` and is only consulted in that case.

`numericKind()` marks how the long bits should be interpreted. Defaults to `LONG`; pass `INT` (low 32 bits, sign-extended), `FLOAT` (low 32 bits encoded via `NumericUtils.floatToSortableInt(float)`), or `DOUBLE` (full 64 bits encoded via `NumericUtils.doubleToSortableLong(double)`) to the constructor to select another interpretation. Callers are responsible for producing the sortable encoding; doc values writes the long unchanged, points consumes it as sortable bytes, and stored fields round-trips it back to `float`/`double` via `NumericUtils.sortableIntToFloat(int)` / `NumericUtils.sortableLongToDouble(long)`. The numeric kind drives the default `storedType()`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `LongColumn.NumericKind`
  The numeric interpretation of the column's long values.

  ## Nested classes/interfaces inherited from class org.apache.lucene.document.column.Column

  `Column.Density`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `LongColumn(String name, IndexableFieldType fieldType, Column.Density density)`
  Creates a LongColumn with `LongColumn.NumericKind.LONG`.
  `protected`
  `LongColumn(String name, IndexableFieldType fieldType, Column.Density density, LongColumn.NumericKind numericKind)`
  Creates a LongColumn with the given numeric interpretation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final LongColumn.NumericKind`
  `numericKind()`
  The numeric interpretation of the column's long values.
  `final StoredValue.Type`
  `storedType()`
  The stored-field variant emitted for this column.
  `abstract LongTupleCursor`
  `tuples()`
  Returns a fresh tuple cursor starting at the beginning of the batch.
  `LongValuesCursor`
  `values()`
  Returns a fresh values cursor iterating dense long values for doc-ids `[0, numDocs)`.

  ### Methods inherited from class org.apache.lucene.document.column.Column

  `density, fieldType, name`

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

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

- ## Constructor Details

  - ### LongColumn

    protected LongColumn(String name, IndexableFieldType fieldType, Column.Density density)
    Creates a LongColumn with `LongColumn.NumericKind.LONG`.

  - ### LongColumn

    protected LongColumn(String name, IndexableFieldType fieldType, Column.Density density, LongColumn.NumericKind numericKind)
    Creates a LongColumn with the given numeric interpretation.

- ## Method Details

  - ### tuples

    public abstract LongTupleCursor tuples()
    Returns a fresh tuple cursor starting at the beginning of the batch.

  - ### values

    public LongValuesCursor values()
    Returns a fresh values cursor iterating dense long values for doc-ids `[0, numDocs)`. Must be overridden when `Column.density()` is `DENSE`; the default implementation throws `UnsupportedOperationException` and is never called for `SPARSE` columns.

  - ### numericKind

    public final LongColumn.NumericKind numericKind()
    The numeric interpretation of the column's long values.

  - ### storedType

    public final StoredValue.Type storedType()
    The stored-field variant emitted for this column. The default derives from `numericKind()` — `INT→INTEGER`, `LONG→LONG`, `FLOAT→FLOAT`, `DOUBLE→DOUBLE` — so a caller that wants the natural numeric variant does not need to override this method. Only numeric `StoredValue.Type` values are permitted; non-numeric stored data should use a `BinaryColumn`.