utils

package
v0.0.6-rc.5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package utils contains various helpers and utility functions

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTableDoesNotExist                   = fmt.Errorf("table does not exist")
	ErrDataSourceNotSupported              = fmt.Errorf("data source not supported")
	ErrDataTypeNotSupported                = fmt.Errorf("data type not supported")
	ErrMethodNotSupported                  = fmt.Errorf("method not supported")
	ErrReadLimitExceeded                   = fmt.Errorf("read limit exceeded")
	ErrInvalidRequest                      = fmt.Errorf("invalid request")
	ErrValueOutOfTypeBounds                = fmt.Errorf("value is out of possible range of values for the type")
	ErrUnimplemented                       = fmt.Errorf("unimplemented")
	ErrUnimplementedTypedValue             = fmt.Errorf("unimplemented typed value")
	ErrUnimplementedExpression             = fmt.Errorf("unimplemented expression")
	ErrUnsupportedExpression               = fmt.Errorf("expression is not supported")
	ErrUnimplementedOperation              = fmt.Errorf("unimplemented operation")
	ErrUnimplementedPredicateType          = fmt.Errorf("unimplemented predicate type")
	ErrInvariantViolation                  = fmt.Errorf("implementation error (invariant violation)")
	ErrUnimplementedArithmeticalExpression = fmt.Errorf("unimplemented arithmetical expression")
	ErrEmptyTableName                      = fmt.Errorf("empty table name")
	ErrPageSizeExceeded                    = fmt.Errorf("page size exceeded, check service configuration")
)

Functions

func APIErrorToLogFields

func APIErrorToLogFields(apiErr *api_service_protos.TError) []log.Field

func AnnotateLogger

func AnnotateLogger(logger log.Logger, method string, dsi *api_common.TDataSourceInstance) log.Logger

func DumpProtoMessageToJSON

func DumpProtoMessageToJSON(msg proto.Message, stream io.Writer) error

func DumpReadSplitsResponse

func DumpReadSplitsResponse(logger log.Logger, resp *api_service_protos.TReadSplitsResponse)

func EndpointToString

func EndpointToString(ep *api_common.TEndpoint) string

func IsSuccess

func IsSuccess(apiErr *api_service_protos.TError) bool

func LogCloserError

func LogCloserError(logger log.Logger, closer io.Closer, msg string)

func MakeTestSplit

func MakeTestSplit() *api_service_protos.TSplit

func NewAPIErrorFromStdError

func NewAPIErrorFromStdError(err error) *api_service_protos.TError

func NewColumnExpression

func NewColumnExpression(name string) *api_service_protos.TExpression

func NewDefaultLogger

func NewDefaultLogger() (log.Logger, error)

func NewDefaultWhat

func NewDefaultWhat() *api_service_protos.TSelect_TWhat

NewDefaultWhat generates default What field with a pair of columns

func NewInt32ValueExpression

func NewInt32ValueExpression(val int32) *api_service_protos.TExpression

func NewLoggerFromConfig

func NewLoggerFromConfig(cfg *config.TLoggerConfig) (log.Logger, error)

func NewPrimitiveType

func NewPrimitiveType(t Ydb.Type_PrimitiveTypeId) *Ydb.Type

func NewSTDErrorFromAPIError

func NewSTDErrorFromAPIError(apiErr *api_service_protos.TError) error

func NewSuccess

func NewSuccess() *api_service_protos.TError

func NewTestLogger

func NewTestLogger(t *testing.T) log.Logger

func NewTextValueExpression

func NewTextValueExpression(val string) *api_service_protos.TExpression

func NewUint64ValueExpression

func NewUint64ValueExpression(val uint64) *api_service_protos.TExpression

func SelectToFields

func SelectToFields(slct *api_service_protos.TSelect) []log.Field

func SelectWhatToArrowSchema

func SelectWhatToArrowSchema(selectWhat *api_service_protos.TSelect_TWhat) (*arrow.Schema, error)

func SelectWhatToYDBTypes

func SelectWhatToYDBTypes(selectWhat *api_service_protos.TSelect_TWhat) ([]*Ydb.Type, error)

func TimeToYDBDate

func TimeToYDBDate(t *time.Time) (uint16, error)

func TimeToYDBDatetime

func TimeToYDBDatetime(t *time.Time) (uint32, error)

func TimeToYDBTimestamp

func TimeToYDBTimestamp(t *time.Time) (uint64, error)

func YdbTypeToYdbPrimitiveTypeID

func YdbTypeToYdbPrimitiveTypeID(ydbType *Ydb.Type) (Ydb.Type_PrimitiveTypeId, error)

func YdbTypesToArrowBuilders

func YdbTypesToArrowBuilders(ydbTypes []*Ydb.Type, arrowAllocator memory.Allocator) ([]array.Builder, error)

Types

type Acceptor

type Acceptor interface {
	any | string
}

Acceptor is a fundamental type class that is used during data extraction from the data source

type ArrowBuilder

type ArrowBuilder[VT ValueType] interface {
	AppendNull()
	Append(value VT)
}

type BoolConverter

type BoolConverter struct{}

func (BoolConverter) Convert

func (BoolConverter) Convert(in bool) (uint8, error)

type BytesConverter

type BytesConverter struct{}

func (BytesConverter) Convert

func (BytesConverter) Convert(in []byte) ([]byte, error)

type Counter

type Counter[T number] struct {
	// contains filtered or unexported fields
}

func NewCounter

func NewCounter[T number]() *Counter[T]

func (*Counter[T]) Add

func (c *Counter[T]) Add(delta T)

func (*Counter[T]) MakeChild

func (c *Counter[T]) MakeChild() *Counter[T]

func (*Counter[T]) Value

func (c *Counter[T]) Value() T

type DataConverter

type DataConverter struct{}

DataConverter should be used only from unit tests

func (DataConverter) RowsToColumnBlocks

func (dc DataConverter) RowsToColumnBlocks(input [][]any, rowsPerBlock int) [][][]any

type DateConverter

type DateConverter struct{}

func (DateConverter) Convert

func (DateConverter) Convert(in time.Time) (uint16, error)

type DateToStringConverter

type DateToStringConverter struct{}

func (DateToStringConverter) Convert

func (DateToStringConverter) Convert(in time.Time) (string, error)

type DatetimeConverter

type DatetimeConverter struct{}

func (DatetimeConverter) Convert

func (DatetimeConverter) Convert(in time.Time) (uint32, error)

type DatetimeToStringConverter

type DatetimeToStringConverter struct{}

func (DatetimeToStringConverter) Convert

type Float32Converter

type Float32Converter struct{}

func (Float32Converter) Convert

func (Float32Converter) Convert(in float32) (float32, error)

type Float64Converter

type Float64Converter struct{}

func (Float64Converter) Convert

func (Float64Converter) Convert(in float64) (float64, error)

type Int16Converter

type Int16Converter struct{}

func (Int16Converter) Convert

func (Int16Converter) Convert(in int16) (int16, error)

type Int32Converter

type Int32Converter struct{}

func (Int32Converter) Convert

func (Int32Converter) Convert(in int32) (int32, error)

type Int64Converter

type Int64Converter struct{}

func (Int64Converter) Convert

func (Int64Converter) Convert(in int64) (int64, error)

type Int8Converter

type Int8Converter struct{}

func (Int8Converter) Convert

func (Int8Converter) Convert(in int8) (int8, error)

type QueryLogger

type QueryLogger struct {
	log.Logger
	// contains filtered or unexported fields
}

func (*QueryLogger) Dump

func (ql *QueryLogger) Dump(query string, args ...any)

type QueryLoggerFactory

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

func NewQueryLoggerFactory

func NewQueryLoggerFactory(cfg *config.TLoggerConfig) QueryLoggerFactory

func (*QueryLoggerFactory) Make

func (f *QueryLoggerFactory) Make(logger log.Logger) QueryLogger

type RowTransformer

type RowTransformer[T Acceptor] interface {
	AppendToArrowBuilders(builders []array.Builder) error
	SetAcceptors(acceptors []T)
	GetAcceptors() []T
}

RowTransformer is a container for values taken extracted from a single table row. RowTransformer also knows how to convert them into columnar reprsentation with Arrow builders.

func NewRowTransformer

func NewRowTransformer[T Acceptor](
	acceptors []T,
	appenders []func(acceptor T, builder array.Builder) error,
	wantedColumnIDs []int,
) RowTransformer[T]

type RowTransformerDefault

type RowTransformerDefault[T Acceptor] struct {
	// contains filtered or unexported fields
}

func (*RowTransformerDefault[T]) AppendToArrowBuilders

func (rt *RowTransformerDefault[T]) AppendToArrowBuilders(builders []array.Builder) error

func (*RowTransformerDefault[T]) GetAcceptors

func (rt *RowTransformerDefault[T]) GetAcceptors() []T

func (*RowTransformerDefault[T]) SetAcceptors

func (rt *RowTransformerDefault[T]) SetAcceptors(acceptors []T)

type StringConverter

type StringConverter struct{}

func (StringConverter) Convert

func (StringConverter) Convert(in string) (string, error)

type StringToBytesConverter

type StringToBytesConverter struct{}

func (StringToBytesConverter) Convert

func (StringToBytesConverter) Convert(in string) ([]byte, error)

type TimestampConverter

type TimestampConverter struct{}

func (TimestampConverter) Convert

func (TimestampConverter) Convert(in time.Time) (uint64, error)

type TimestampToStringConverter

type TimestampToStringConverter struct{}

func (TimestampToStringConverter) Convert

type TypeMapper

type TypeMapper interface {
	SQLTypeToYDBColumn(columnName, typeName string, rules *api_service_protos.TTypeMappingSettings) (*Ydb.Column, error)
}

type Uint16Converter

type Uint16Converter struct{}

func (Uint16Converter) Convert

func (Uint16Converter) Convert(in uint16) (uint16, error)

type Uint32Converter

type Uint32Converter struct{}

func (Uint32Converter) Convert

func (Uint32Converter) Convert(in uint32) (uint32, error)

type Uint64Converter

type Uint64Converter struct{}

func (Uint64Converter) Convert

func (Uint64Converter) Convert(in uint64) (uint64, error)

type Uint8Converter

type Uint8Converter struct{}

func (Uint8Converter) Convert

func (Uint8Converter) Convert(in uint8) (uint8, error)

type ValueConverter

type ValueConverter[IN ValueType, OUT ValueType] interface {
	Convert(in IN) (OUT, error)
}

type ValueType

type ValueType interface {
	bool | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | float32 | float64 | string | []byte | time.Time
}

Jump to

Keyboard shortcuts

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