Interface Datum.Accessor<B,L extends Datum.Layout>
- Type Parameters:
B
- type of the memory abstraction used. Accessors will be available supportingByteBuffer
, and may be available supporting a newer abstraction likeMemorySegment
.L
- a subinterface ofLayout
, eitherDeformed
orHeap
, indicating whichTupleTableSlot
layout theAccessor
is intended for, chiefly as a tool for compile-time checking that they haven't been mixed up.
- Enclosing interface:
Datum
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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An accessor for use with a 'deformed' (array-of-Datum
) memory layout.static interface
An accessor for use with a heap-tuple styled, flattened, memory layout. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getBoolean
(B buffer, int offset) byte
char
double
float
int
getIntSignExtended
(B buffer, int offset) int
getIntZeroExtended
(B buffer, int offset) long
getLongSignExtended
(B buffer, int offset) long
getLongZeroExtended
(B buffer, int offset) short
-
Method Details
-
getDatum
-
getLongSignExtended
-
getLongZeroExtended
-
getDouble
-
getIntSignExtended
-
getIntZeroExtended
-
getFloat
-
getShort
-
getChar
-
getByte
-
getBoolean
-