Class ShortDocValuesField

java.lang.Object
org.elasticsearch.script.field.ShortDocValuesField
All Implemented Interfaces:
Iterable<Short>, ScriptDocValues.Supplier<Long>, DocValuesField<Short>, Field<Short>

public class ShortDocValuesField extends Object implements DocValuesField<Short>, ScriptDocValues.Supplier<Long>
  • Field Details

    • input

      protected final org.apache.lucene.index.SortedNumericDocValues input
    • name

      protected final String name
    • values

      protected short[] values
    • count

      protected int count
  • Constructor Details

    • ShortDocValuesField

      public ShortDocValuesField(org.apache.lucene.index.SortedNumericDocValues input, String name)
  • Method Details

    • setNextDocId

      public void setNextDocId(int docId) throws IOException
      Description copied from interface: DocValuesField
      Set the current document ID.
      Specified by:
      setNextDocId in interface DocValuesField<Short>
      Specified by:
      setNextDocId in interface ScriptDocValues.Supplier<Long>
      Throws:
      IOException
    • resize

      protected void resize(int newSize)
    • getScriptDocValues

      public ScriptDocValues<Long> getScriptDocValues()
      Returns a ScriptDocValues of the appropriate type for this field. This is used to support backwards compatibility for accessing field values through the doc variable.
      Specified by:
      getScriptDocValues in interface DocValuesField<Short>
    • getInternal

      public Long getInternal(int index)
      Specified by:
      getInternal in interface ScriptDocValues.Supplier<Long>
    • getName

      public String getName()
      Returns the name of this field.
      Specified by:
      getName in interface Field<Short>
    • isEmpty

      public boolean isEmpty()
      Returns true if this field has no values, otherwise false.
      Specified by:
      isEmpty in interface Field<Short>
    • size

      public int size()
      Returns the number of values this field has.
      Specified by:
      size in interface Field<Short>
      Specified by:
      size in interface ScriptDocValues.Supplier<Long>
    • iterator

      public Iterator<Short> iterator()
      Specified by:
      iterator in interface Iterable<Short>
    • get

      public short get(int defaultValue)
    • get

      public short get(int index, int defaultValue)
      Note: Constants in java and painless are ints, so letting the defaultValue be an int allows users to call this without casting. A short variable will be automatically widened to an int. If the user does pass a value outside the range, it will be cast down to a short.