common

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

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) []zap.Field

func AllStreamResponsesSuccessfull

func AllStreamResponsesSuccessfull[T StreamResponse](responses []T) bool

func AnnotateLoggerForUnaryCall

func AnnotateLoggerForUnaryCall(l *zap.Logger, method string, dsi *api_common.TDataSourceInstance) *zap.Logger

func AnnotateLoggerWithDataSourceInstance

func AnnotateLoggerWithDataSourceInstance(l *zap.Logger, dsi *api_common.TDataSourceInstance) *zap.Logger

func AnnotateLoggerWithMethod

func AnnotateLoggerWithMethod(l *zap.Logger, method string) *zap.Logger

func EndpointToString

func EndpointToString(ep *api_common.TEndpoint) string

func IsSuccess

func IsSuccess(apiErr *api_service_protos.TError) bool

func LogCloserError

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

func MakeOptionalType

func MakeOptionalType(ydbType *Ydb.Type) *Ydb.Type

func MakePrimitiveType

func MakePrimitiveType(typeId Ydb.Type_PrimitiveTypeId) *Ydb.Type

func MakeTypedValue

func MakeTypedValue(ydbType *Ydb.Type, value any) *Ydb.TypedValue

func MakeYdbDateTimeType added in v0.1.2

func MakeYdbDateTimeType(ydbTypeID Ydb.Type_PrimitiveTypeId, format api_service_protos.EDateTimeFormat) (*Ydb.Type, error)

func MustTimeToYDBType

func MustTimeToYDBType[OUT ydbTime](f func(t *time.Time) (OUT, error), t time.Time) OUT

func NewAPIErrorFromStdError

func NewAPIErrorFromStdError(err error) *api_service_protos.TError

func NewConfigFromPrototextFile added in v0.1.2

func NewConfigFromPrototextFile[T AppConfig](configPath string, dst T) error

func NewDefaultLogger

func NewDefaultLogger() *zap.Logger

func NewLoggerFromConfig

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

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) *zap.Logger

func ReadResponsesToArrowRecords

func ReadResponsesToArrowRecords(responses []*api_service_protos.TReadSplitsResponse) ([]arrow.Record, error)

func SchemaToSelectWhatItems

func SchemaToSelectWhatItems(
	schema *api_service_protos.TSchema,
	whitelist map[string]struct{},
) *api_service_protos.TSelect_TWhat

func SelectToFields

func SelectToFields(slct *api_service_protos.TSelect) []zap.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 AppConfig added in v0.1.2

type AppConfig interface {
	*config.TClientConfig | *config.TBenchmarkConfig
	proto.Message
}

type ArrowArrayType

type ArrowArrayType[VT ValueType] interface {
	*array.Boolean |
		*array.Int8 | *array.Int16 | *array.Int32 | *array.Int64 |
		*array.Uint8 | *array.Uint16 | *array.Uint32 | *array.Uint64 |
		*array.Float32 | *array.Float64 |
		*array.String | *array.Binary

	Len() int
	Value(int) VT
	IsNull(int) bool
}

type ArrowBuilder

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

type ClientBuffering added in v0.1.2

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

func NewClientBufferingFromClientConfig added in v0.1.2

func NewClientBufferingFromClientConfig(logger *zap.Logger, clientCfg *config.TClientConfig) (*ClientBuffering, error)

func NewClientBufferingFromServerConfig added in v0.1.2

func NewClientBufferingFromServerConfig(logger *zap.Logger, serverCfg *config.TServerConfig) (*ClientBuffering, error)

func (*ClientBuffering) Close added in v0.1.2

func (c *ClientBuffering) Close()

func (*ClientBuffering) DescribeTable added in v0.1.2

func (c *ClientBuffering) DescribeTable(
	ctx context.Context,
	dsi *api_common.TDataSourceInstance,
	typeMappingSettings *api_service_protos.TTypeMappingSettings,
	tableName string,
) (*api_service_protos.TDescribeTableResponse, error)

func (*ClientBuffering) ListSplits added in v0.1.2

func (*ClientBuffering) ReadSplits added in v0.1.2

type ClientStreaming added in v0.1.2

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

func NewClientStreamingFromClientConfig added in v0.1.2

func NewClientStreamingFromClientConfig(logger *zap.Logger, clientCfg *config.TClientConfig) (*ClientStreaming, error)

func NewClientStreamingFromServerConfig added in v0.1.2

func NewClientStreamingFromServerConfig(logger *zap.Logger, serverCfg *config.TServerConfig) (*ClientStreaming, error)

func (*ClientStreaming) Close added in v0.1.2

func (c *ClientStreaming) Close()

func (*ClientStreaming) DescribeTable added in v0.1.2

func (c *ClientStreaming) DescribeTable(
	ctx context.Context,
	dsi *api_common.TDataSourceInstance,
	typeMappingSettings *api_service_protos.TTypeMappingSettings,
	tableName string,
) (*api_service_protos.TDescribeTableResponse, error)

func (*ClientStreaming) ListSplits added in v0.1.2

func (*ClientStreaming) ReadSplits added in v0.1.2

type QueryLogger

type QueryLogger struct {
	*zap.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 *zap.Logger) QueryLogger

type StreamResult added in v0.1.2

type StreamResult[T StreamResponse] struct {
	Response T
	Err      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