Interface Datum.Accessor<B,L extends Datum.Layout>

Type Parameters:
B - type of the memory abstraction used. Accessors will be available supporting ByteBuffer, and may be available supporting a newer abstraction like MemorySegment.
L - a subinterface of Layout, either Deformed or Heap, indicating which TupleTableSlot layout the Accessor is intended for, chiefly as a tool for compile-time checking that they haven't been mixed up.
Enclosing interface:
Datum

public static interface Datum.Accessor<B,L extends Datum.Layout>
Accessor for a Datum located, at some offset, in memory represented by a <B> object.

<B> is a type variable to anticipate future memory abstractions like the incubating MemorySegment from JEP 412. The present implementation will work with any <B> that you want as long as it is java.nio.ByteBuffer.

Given an Accessor instance properly selected for the memory layout, datum width, type length, and by-value/by-reference passing convention declared for a given Attribute, methods on the Accessor are available to retrieve the individual datum in Datum form (essentially another <B> of exactly the length of the datum, wrapped with methods to avoid access outside of its lifetime), or as any Java primitive type appropriate to the datum's width. A get method of the datum's exact width or wider may be used (except for float and double, which only work for width exactly 4 or 8 bytes, respectively).

PostgreSQL only allows power-of-two widths up to SIZEOF_DATUM for a type that specifies the by-value convention, and so an Accessor for the by-value case only supports those widths. An Accessor for the by-reference case supports any size, with direct access as a Java primitive supported for any size up to the width of a Java long.

getBoolean can be used for any width the Accessor supports up to the width of Java long, and the result will be true if the value has any 1 bits.

Java long and int are always treated as signed by the language (though unsigned operations are available as methods), but have paired methods here to explicitly indicate which treatment is intended. The choice can affect the returned value when fetching a value as a primitive type that is wider than its type's declared length. Paired methods for byte are not provided because a byte is not wider than any type's length. When a type narrower than SIZEOF_DATUM is stored (in the Deformed layout), unused high bits are stored as zero. This should not strictly matter, as PostgreSQL strictly ignores the unused high bits, but it is consistent with the way PostgreSQL declares Datum as an unsigned integral type.

  • Method Details

    • getDatum

      Datum.Input getDatum(B buffer, int offset, Attribute a)
    • getLongSignExtended

      long getLongSignExtended(B buffer, int offset)
    • getLongZeroExtended

      long getLongZeroExtended(B buffer, int offset)
    • getDouble

      double getDouble(B buffer, int offset)
    • getIntSignExtended

      int getIntSignExtended(B buffer, int offset)
    • getIntZeroExtended

      int getIntZeroExtended(B buffer, int offset)
    • getFloat

      float getFloat(B buffer, int offset)
    • getShort

      short getShort(B buffer, int offset)
    • getChar

      char getChar(B buffer, int offset)
    • getByte

      byte getByte(B buffer, int offset)
    • getBoolean

      boolean getBoolean(B buffer, int offset)