convert

package
v0.0.0-...-9f8137b Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeysKeyDefault string = "ENV_KEYS_KEY"
)

Variables

View Source
var (
	ErrUnsupportedType   error = errors.New("unsupported type")
	ErrConverterNotFound error = errors.New("converter missing")
)
View Source
var (
	ErrInvalidUtf8 error = errors.New("invalid utf8")
)

Functions

func BytesFromBytesNew

func BytesFromBytesNew() func([]byte) (*ps.PgcopyBytes, error)

func BytesToBoolNew

func BytesToBoolNew() func([]byte) (*ps.PgcopyBool, error)

func BytesToBoolNewN

func BytesToBoolNewN() func([]byte) (*ps.PgcopyBoolN, error)

func BytesToDoubleNew

func BytesToDoubleNew() func([]byte) (*ps.PgcopyDouble, error)

func BytesToDoubleNewN

func BytesToDoubleNewN() func([]byte) (*ps.PgcopyDoubleN, error)

func BytesToFloatNew

func BytesToFloatNew() func([]byte) (*ps.PgcopyFloat, error)

func BytesToFloatNewN

func BytesToFloatNewN() func([]byte) (*ps.PgcopyFloatN, error)

func BytesToIntNew

func BytesToIntNew() func([]byte) (*ps.PgcopyInt, error)

func BytesToIntNewN

func BytesToIntNewN() func([]byte) (*ps.PgcopyIntN, error)

func BytesToLongNew

func BytesToLongNew() func([]byte) (*ps.PgcopyLong, error)

func BytesToLongNewN

func BytesToLongNewN() func([]byte) (*ps.PgcopyLongN, error)

func BytesToShortNew

func BytesToShortNew() func([]byte) (*ps.PgcopyShort, error)

func BytesToShortNewN

func BytesToShortNewN() func([]byte) (*ps.PgcopyShortN, error)

func CheckStringUtf8

func CheckStringUtf8(s string) error

func ConfigToConverterBool

func ConfigToConverterBool(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterBoolN

func ConfigToConverterBoolN(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterDouble

func ConfigToConverterDouble(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterDoubleN

func ConfigToConverterDoubleN(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterFloat

func ConfigToConverterFloat(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterFloatN

func ConfigToConverterFloatN(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterInt

func ConfigToConverterInt(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterIntN

func ConfigToConverterIntN(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterLong

func ConfigToConverterLong(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterLongN

func ConfigToConverterLongN(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterShort

func ConfigToConverterShort(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func ConfigToConverterShortN

func ConfigToConverterShortN(
	_ ConvertConfig,
) func([]byte) util.IO[ps.Value]

func NullBytesFromBytesNew

func NullBytesFromBytesNew() func([]byte) (*ps.PgcopyBytesN, error)

func NullStringFromBytesNew

func NullStringFromBytesNew(
	checker func(string) error,
) func([]byte) (*ps.PgcopyStringN, error)

func NullStringFromBytesNewDefault

func NullStringFromBytesNewDefault() func([]byte) (*ps.PgcopyStringN, error)

func StringFromBytesNew

func StringFromBytesNew(
	checker func(string) error,
) func([]byte) (*ps.PgcopyString, error)

func StringFromBytesNewDefault

func StringFromBytesNewDefault() func([]byte) (*ps.PgcopyString, error)

func TimeFromBytesNew

func TimeFromBytesNew() func([]byte) (*ps.PgcopyTime, error)

func TimeFromBytesNewN

func TimeFromBytesNewN() func([]byte) (*ps.PgcopyTimeN, error)

func TypeToConverter

func TypeToConverter(
	typ ps.ColumnType,
	cfg ConvertConfig,
) func([]byte) util.IO[ps.Value]

func UuidFromBytesNew

func UuidFromBytesNew() func([]byte) (*ps.PgcopyUuid, error)

func UuidFromBytesNewN

func UuidFromBytesNewN() func([]byte) (*ps.PgcopyUuidN, error)

Types

type CfgToConv

type CfgToConv func(ConvertConfig) func([]byte) util.IO[ps.Value]

type ConvertConfig

type ConvertConfig struct {
	// contains filtered or unexported fields
}
var ConvertConfigDefault ConvertConfig = ConvertConfig{}.
	WithStringChecker(CheckStringUtf8)

func (ConvertConfig) WithStringChecker

func (c ConvertConfig) WithStringChecker(
	checker func(string) error,
) ConvertConfig

type ConverterIx

type ConverterIx func(int16, []byte) util.IO[ps.Value]

type IndexedTypeInfo

type IndexedTypeInfo struct {
	Index int16  `json:"index"`
	Type  string `json:"type"`
}

type Input

type Input struct {
	ps.ColumnType
	Raw []byte
}

type PgcopyBytesBool

type PgcopyBytesBool []byte

func (PgcopyBytesBool) Convert

func (t PgcopyBytesBool) Convert() (*ps.PgcopyBool, error)

Slow converter which may use heap allocation.

type PgcopyBytesDouble

type PgcopyBytesDouble []byte

func (PgcopyBytesDouble) Convert

func (t PgcopyBytesDouble) Convert() (*ps.PgcopyDouble, error)

Slow converter which may use heap allocation.

type PgcopyBytesFloat

type PgcopyBytesFloat []byte

func (PgcopyBytesFloat) Convert

func (t PgcopyBytesFloat) Convert() (*ps.PgcopyFloat, error)

Slow converter which may use heap allocation.

type PgcopyBytesInt

type PgcopyBytesInt []byte

func (PgcopyBytesInt) Convert

func (t PgcopyBytesInt) Convert() (*ps.PgcopyInt, error)

Slow converter which may use heap allocation.

type PgcopyBytesLong

type PgcopyBytesLong []byte

func (PgcopyBytesLong) Convert

func (t PgcopyBytesLong) Convert() (*ps.PgcopyLong, error)

Slow converter which may use heap allocation.

type PgcopyBytesShort

type PgcopyBytesShort []byte

func (PgcopyBytesShort) Convert

func (t PgcopyBytesShort) Convert() (*ps.PgcopyShort, error)

Slow converter which may use heap allocation.

type TypeInfo

type TypeInfo map[int16]ps.ColumnType

func TypeInfoFromEnvVar

func TypeInfoFromEnvVar(
	ctx context.Context,
	getenv func(string) util.IO[string],
	keysKey string,
) TypeInfo

Gets type info from env vars.

Arguments

  • getenv: Gets env var.
  • keysKey: env var key of keys of env vars.

func TypeInfoFromEnvVarAndKeys

func TypeInfoFromEnvVarAndKeys(
	ctx context.Context,
	getenv func(string) util.IO[string],
	keys []string,
) TypeInfo

Gets type info from env vars and keys of env vars.

Arguments

  • getenv: Gets env var.
  • keys: env var keys for vars which contains type string.

func TypeInfoFromEnvVarDefault

func TypeInfoFromEnvVarDefault(
	ctx context.Context,
	getenv func(string) util.IO[string],
) TypeInfo

Gets type info from env vars using default env vars key.

Arguments

  • getenv: Gets env var.

func TypeInfoFromIndexIter

func TypeInfoFromIndexIter(
	i iter.Seq[IndexedTypeInfo],
) TypeInfo

func TypeInfoFromIter

func TypeInfoFromIter(
	i iter.Seq2[int16, ps.ColumnType],
) TypeInfo

func TypeInfoFromJsonIter

func TypeInfoFromJsonIter(
	i iter.Seq[string],
) TypeInfo

Gets type info from strings(JSONs).

JSON sample:

{"index":0, "type": "string"}
{"index":1, "type": "string-null"}
{"index":2, "type": "int"}
{"index":3, "type": "int-null"}

func TypeInfoFromJsonReadable

func TypeInfoFromJsonReadable(
	rdr io.Reader,
) TypeInfo

Gets type info from the reader(JSON lines).

func (TypeInfo) ToConverterIx

func (t TypeInfo) ToConverterIx(cfg ConvertConfig) ConverterIx

func (TypeInfo) ToConverterIxDefault

func (t TypeInfo) ToConverterIxDefault() ConverterIx

Jump to

Keyboard shortcuts

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