Class VectorCodec

java.lang.Object
io.r2dbc.postgresql.codec.VectorCodec
All Implemented Interfaces:
Codec<Vector>, CodecMetadata

public class VectorCodec extends Object implements Codec<Vector>, CodecMetadata
Codec for pgvector.
Since:
1.0.3
  • Method Details

    • encodeNull

      public io.r2dbc.postgresql.client.EncodedParameter encodeNull()
      Description copied from interface: Codec
      Encode a null value.
      Specified by:
      encodeNull in interface Codec<Vector>
      Returns:
      the encoded null value
    • type

      public Class<?> type()
      Description copied from interface: CodecMetadata
      Returns the Java type of this codec.
      Specified by:
      type in interface CodecMetadata
      Returns:
      the Java type
    • getArrayDataType

      public PostgresTypeIdentifier getArrayDataType()
    • getDataTypes

      public Iterable<PostgresTypeIdentifier> getDataTypes()
      Description copied from interface: CodecMetadata
      Returns the collection of PostgresTypeIdentifier this codec can handle
      Specified by:
      getDataTypes in interface CodecMetadata
      Returns:
      the datatypes
    • canDecode

      public boolean canDecode(int dataType, io.r2dbc.postgresql.message.Format format, Class<?> type)
      Description copied from interface: Codec
      Determine whether this Codec is capable of decoding a value for the given dataType and Format and whether it can represent the decoded value as the desired type.
      Specified by:
      canDecode in interface Codec<Vector>
      Parameters:
      dataType - the Postgres OID to decode
      format - the data type Format, text or binary
      type - the desired value type
      Returns:
      true if this codec is able to decode values for tge given dataType and Format
    • canEncode

      public boolean canEncode(Object value)
      Description copied from interface: Codec
      Determine whether this Codec is capable of encoding the value.
      Specified by:
      canEncode in interface Codec<Vector>
      Parameters:
      value - the parameter value
      Returns:
      true if this Codec is able to encode the value.
      See Also:
    • canEncodeNull

      public boolean canEncodeNull(Class<?> type)
      Description copied from interface: Codec
      Determine whether this Codec is capable of encoding a null value for the given Class type.
      Specified by:
      canEncodeNull in interface Codec<Vector>
      Parameters:
      type - the desired value type
      Returns:
      true if this Codec is able to encode null values for the given Class type.
      See Also:
    • decode

      public Vector decode(io.netty.buffer.ByteBuf buffer, PostgresTypeIdentifier dataType, io.r2dbc.postgresql.message.Format format, Class<? extends Vector> type)
    • decode

      public Vector decode(@Nullable io.netty.buffer.ByteBuf buffer, int dataType, io.r2dbc.postgresql.message.Format format, Class<? extends Vector> type)
      Description copied from interface: Codec
      Decode the buffer and return it as the requested type.
      Specified by:
      decode in interface Codec<Vector>
      Parameters:
      buffer - the data buffer
      dataType - the Postgres OID to encode
      format - the data type Format, text or binary
      type - the desired value type
      Returns:
      the decoded value. Can be null if the value is null.
    • encode

      public io.r2dbc.postgresql.client.EncodedParameter encode(Object value)
      Description copied from interface: Codec
      Encode the value to be used as RPC parameter.
      Specified by:
      encode in interface Codec<Vector>
      Parameters:
      value - the value
      Returns:
      the encoded value
    • encode

      public io.r2dbc.postgresql.client.EncodedParameter encode(Object value, int dataType)
      Description copied from interface: Codec
      Encode the value to be used as RPC parameter.
      Specified by:
      encode in interface Codec<Vector>
      Parameters:
      value - the value
      dataType - the Postgres OID to encode
      Returns:
      the encoded value
    • encodeToText

      public String encodeToText(Vector value)