binary

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2022 License: UPL-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads byte sequences from the underlying io.Reader and decodes the bytes to construct in-memory representations according to the Binary Protocol which defines the data exchange format between the Oracle NoSQL Database proxy and drivers.

Reader implements the io.Reader and io.ByteReader interfaces.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader creates a reader for the binary protocol. If the provided io.Reader is already a binary protocol Reader, it returns the provided one without creating a new Reader.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.

func (*Reader) ReadArray

func (r *Reader) ReadArray() ([]types.FieldValue, error)

ReadArray reads a structured byte sequences that represent the encoding of an array, decodes the bytes and returns as a slice of types.FieldValue.

func (*Reader) ReadBoolean

func (r *Reader) ReadBoolean() (bool, error)

ReadBoolean reads and decodes a single byte as a bool value. A zero byte is decoded as false, and any other non-zero byte is decoded as true.

func (*Reader) ReadByte

func (r *Reader) ReadByte() (byte, error)

ReadByte reads and returns a single byte or any error encountered.

func (*Reader) ReadByteArray

func (r *Reader) ReadByteArray() ([]byte, error)

ReadByteArray reads byte sequences and returns as a slice of byte or any error encountered. The returned bytes could be nil.

func (*Reader) ReadByteArrayWithInt

func (r *Reader) ReadByteArrayWithInt() ([]byte, error)

ReadByteArrayWithInt reads byte sequences and returns as a slice of byte or any error encountered. The returned bytes is non-nil.

func (*Reader) ReadDouble

func (r *Reader) ReadDouble() (float64, error)

ReadDouble reads and decodes 8 bytes as a float64 value.

func (*Reader) ReadFieldValue

func (r *Reader) ReadFieldValue() (types.FieldValue, error)

ReadFieldValue reads a fixed or variable length of bytes, decodes them as a value of a table field and returns the value or any error encountered.

func (*Reader) ReadInt

func (r *Reader) ReadInt() (int, error)

ReadInt reads and decodes 4 bytes as an int32 value.

func (*Reader) ReadInt16

func (r *Reader) ReadInt16() (int16, error)

ReadInt16 reads and decodes 2 bytes as an int16 value.

func (*Reader) ReadMap

func (r *Reader) ReadMap() (*types.MapValue, error)

ReadMap reads a structured byte sequences that represent the encoding of a Map value, decodes the bytes and returns as an ordered *types.MapValue.

func (*Reader) ReadPackedInt

func (r *Reader) ReadPackedInt() (int, error)

ReadPackedInt reads a variable length of bytes that is an encoding of packed integer, decodes the bytes as an int32 value.

func (*Reader) ReadPackedLong

func (r *Reader) ReadPackedLong() (int64, error)

ReadPackedLong reads a variable length of bytes that is an encoding of packed long value, decodes the bytes as an int64 value.

func (*Reader) ReadString

func (r *Reader) ReadString() (*string, error)

ReadString reads a variable length of bytes that is an encoding of packed UTF-8 string value, decodes the bytes as a string. It returns a pointer to the string value or any error encountered.

func (*Reader) ReadVersion

func (r *Reader) ReadVersion() (types.Version, error)

ReadVersion reads byte sequences and decodes as a types.Version.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer encodes data into the wire format for the Binary Protocol and writes to a buffer. The Binary Protocol defines the data exchange format between the Oracle NoSQL Database proxy and drivers.

Writer implements the io.Write and io.ByteWriter interfaces.

func NewWriter

func NewWriter() *Writer

NewWriter creates a writer for the binary protocol.

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

Bytes returns a slice of bytes in the buffer.

func (*Writer) Reset

func (w *Writer) Reset()

Reset resets the buffer.

func (*Writer) Size

func (w *Writer) Size() int

Size returns the number of bytes in the buffer.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write writes len(p) bytes from p to the buffer.

func (*Writer) WriteArray

func (w *Writer) WriteArray(value []types.FieldValue) (n int, err error)

WriteArray encodes and writes an array of FieldValues to the buffer.

func (*Writer) WriteBoolean

func (w *Writer) WriteBoolean(value bool) (int, error)

WriteBoolean encodes and writes the bool value to the buffer. A true value is encoded as 1 while a false value is encoded as 0.

func (*Writer) WriteByte

func (w *Writer) WriteByte(b byte) error

WriteByte writes a single byte.

This implements io.ByteWriter.

func (*Writer) WriteByteArray

func (w *Writer) WriteByteArray(value []byte) (n int, err error)

WriteByteArray encodes and writes a slice of bytes to the buffer. The slice of bytes could be nil.

func (*Writer) WriteByteArrayWithInt

func (w *Writer) WriteByteArrayWithInt(value []byte) (n int, err error)

WriteByteArrayWithInt encodes and writes a slice of bytes to the buffer. The slice of bytes must be non-nil.

func (*Writer) WriteCapacityMode added in v1.3.0

func (w *Writer) WriteCapacityMode(lm types.CapacityMode, serialVersion int16) (int, error)

WriteCapacityMode encodes and writes the limits mode value to the buffer.

func (*Writer) WriteConsistency

func (w *Writer) WriteConsistency(c types.Consistency) (int, error)

WriteConsistency encodes and writes the consistency value to the buffer.

func (*Writer) WriteDouble

func (w *Writer) WriteDouble(value float64) (int, error)

WriteDouble encodes and writes the float64 value to the buffer.

func (*Writer) WriteDurability added in v1.3.0

func (w *Writer) WriteDurability(c types.Durability, serialVersion int16) (int, error)

WriteDurability encodes and writes the Durability value to the buffer.

func (*Writer) WriteFieldRange

func (w *Writer) WriteFieldRange(fieldRange *types.FieldRange) (n int, err error)

WriteFieldRange encodes and writes the FieldRange to the buffer.

func (*Writer) WriteFieldValue

func (w *Writer) WriteFieldValue(value types.FieldValue) (int, error)

WriteFieldValue encodes and writes the specified field value to the buffer.

func (*Writer) WriteInt

func (w *Writer) WriteInt(value int) (int, error)

WriteInt encodes and writes the int value to the buffer. It assumes the provided value fits into a signed 32-bit integer.

func (*Writer) WriteInt16

func (w *Writer) WriteInt16(value int16) (int, error)

WriteInt16 encodes and writes the int16 value to the buffer.

func (*Writer) WriteMap

func (w *Writer) WriteMap(value *types.MapValue) (n int, err error)

WriteMap encodes and writes the map value to the buffer.

func (*Writer) WriteOpCode

func (w *Writer) WriteOpCode(op proto.OpCode) (int, error)

WriteOpCode encodes and writes the OpCode op to the buffer.

func (*Writer) WritePackedInt

func (w *Writer) WritePackedInt(value int) (int, error)

WritePackedInt encodes the int value using packed integer encoding and writes to the buffer. It assumes the provided value fits into a signed 32-bit integer.

func (*Writer) WritePackedLong

func (w *Writer) WritePackedLong(value int64) (int, error)

WritePackedLong encodes the int64 value using packed long encoding and writes to the buffer.

func (*Writer) WriteSerialVersion

func (w *Writer) WriteSerialVersion(v int16) (int, error)

WriteSerialVersion encodes and writes the SerialVersion v to the buffer.

func (*Writer) WriteString

func (w *Writer) WriteString(value *string) (n int, err error)

WriteString encodes and writes the string value to the buffer.

func (*Writer) WriteTTL

func (w *Writer) WriteTTL(ttl *types.TimeToLive) (n int, err error)

WriteTTL encodes and writes the TTL value to the buffer.

func (*Writer) WriteTimeout

func (w *Writer) WriteTimeout(timeout time.Duration) (int, error)

WriteTimeout encodes and writes the timeout value to the buffer.

func (*Writer) WriteVersion

func (w *Writer) WriteVersion(version types.Version) (int, error)

WriteVersion encodes and writes the specified version to the buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL