Interface Datum.Input<T extends InputStream & Datum>
- All Superinterfaces:
AutoCloseable
,Closeable
,Datum
- Enclosing interface:
Datum
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.postgresql.pljava.adt.spi.Datum
Datum.Accessor<B,
L extends Datum.Layout>, Datum.Input<T extends InputStream & Datum>, Datum.Layout -
Method Summary
Modifier and TypeMethodDescriptionbuffer()
Returns a read-onlyByteBuffer
covering the content of the datum.Returns anInputStream
that presents the same bytes contained in the buffer returned bybuffer()
.default void
pin()
default boolean
default void
unpin()
-
Method Details
-
pin
- Throws:
SQLException
-
pinUnlessReleased
default boolean pinUnlessReleased() -
unpin
default void unpin() -
buffer
Returns a read-onlyByteBuffer
covering the content of the datum.When the datum is a
varlena
, the "content" does not include the four-byte header. When implementing an adapter for a varlena datatype, note carefully whether offsets used in the PostgreSQL C code are relative to the start of the content or the start of the varlena overall. If the latter, they will need adjustment when indexing into theByteBuffer
.If the byte order of the buffer will matter, it should be explicitly set.
The buffer may window native memory allocated by PostgreSQL, so
pin()
andunpin()
should surround accesses through it. LikeDatum
itself, theByteBuffer
should be used only within anAdapter
, and not exposed to other code.- Throws:
SQLException
-
inputStream
Returns anInputStream
that presents the same bytes contained in the buffer returned bybuffer()
.When necessary, the
InputStream
will handle pinning the buffer when reading, so theInputStream
can safely be exposed to other code, if it is a reasonable way to present the contents of the datatype in question.The stream supports
mark
andreset
.- Throws:
SQLException
-