Class DatumUtils

java.lang.Object
org.postgresql.pljava.pg.DatumUtils

public class DatumUtils extends Object
Implementations of Datum.Accessor and a collection of related static methods.
  • Field Details

    • BIG_ENDIAN

      static final boolean BIG_ENDIAN
  • Constructor Details

    • DatumUtils

      public DatumUtils()
  • Method Details

    • indexedTupleSlot

      public static TupleTableSlot.Indexed indexedTupleSlot(RegType type, int elements, ByteBuffer nulls, ByteBuffer values)
    • addressOf

      public static long addressOf(ByteBuffer bb)
    • fetchPointer

      public static long fetchPointer(ByteBuffer bb, int offset)
    • storePointer

      public static void storePointer(ByteBuffer bb, int offset, long value)
    • asReadOnlyNativeOrder

      public static ByteBuffer asReadOnlyNativeOrder(ByteBuffer bb)
    • mapFixedLength

      static ByteBuffer mapFixedLength(long nativeAddress, int length)
    • mapFixedLength

      public static ByteBuffer mapFixedLength(ByteBuffer bb, int offset, int length)
    • mapCString

      static ByteBuffer mapCString(long nativeAddress)
    • mapCString

      public static ByteBuffer mapCString(ByteBuffer bb, int offset)
    • mapVarlena

      static Datum.Input mapVarlena(long nativeAddress, ResourceOwner resowner, MemoryContext memcontext)
    • mapVarlena

      static Datum.Input mapVarlena(ByteBuffer bb, long offset, ResourceOwner resowner, MemoryContext memcontext)
    • inspectVarlena

      public static int inspectVarlena(ByteBuffer bb, int offset)
      For now, just return the inline size (the size to be skipped if stepping over this varlena in a heap tuple).

      This is a reimplementation of some of the top of postgres.h, so that this common operation can be done without a JNI call to the C code.

    • asAlwaysCopiedDatum

      static Datum.Input asAlwaysCopiedDatum(ByteBuffer bb, int offset, int length)
    • toBitmapset

      static ByteBuffer toBitmapset(BitSet b)
      Turns a BitSet into a direct-allocated ByteBuffer whose address can be passed in C code to PostgreSQL's bms_copy and used as a bitmapset.

      While the ByteBuffer is direct-allocated, it is allocated by Java, not by palloc, and the PostgreSQL code must not be allowed to try to grow, shrink, or pfree it. Hence the bms_copy.

      If the result of operations in C will be wanted in Java, the fuss of allocating a different direct ByteBuffer for the result can be avoided by carefully letting the C code update this bitmapset in place, so that no resizing or freeing can occur. That can be done by OR-ing one extra bit into the Java BitSet in advance, at an index higher than the bits of interest, and having the C code manipulate only the lower-indexed bits (such as by using a bms_prev_member loop unrolled with one first call unused).

      While the ByteBuffer returned is read-only (as far as Java is concerned), if it is updated in place by C code, it can be passed afterward to fromBitmapset to recover the result.

    • fromBitmapset

      static BitSet fromBitmapset(ByteBuffer bb)
    • fromBitmapset

      static BitSet fromBitmapset(long nativeAddress)