responsehandler

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertCivilDateToTime

func ConvertCivilDateToTime(cDate civil.Date) time.Time

ConvertCivilDateToTime converts a civil.Date to a time.Time set to midnight UTC.

func ConvertToCQLDate

func ConvertToCQLDate(t time.Time) int32

ConvertToCQLDate converts a time.Time to a CQL date as an int32 representing days since the Unix epoch.

Types

type JsonStringGetter

type JsonStringGetter interface {
	GetJsonString(i int, row *spanner.Row) (string, error)
}

Only used for unit testing

type QueryMetadata

type QueryMetadata struct {
	Query                string
	QueryType            string
	TableName            string
	KeyspaceName         string
	ProtocalV            primitive.ProtocolVersion
	Params               map[string]interface{}
	SelectedColumns      []tableConfig.SelectedColumns
	Paramkeys            []string
	ParamValues          []interface{}
	UsingTSCheck         string
	HasIfNotExists       bool
	SelectQueryForDelete string
	PrimaryKeys          []string
	SelectQueryMapUpdate string // select Query for map update by key Scenario
	UpdateSetValues      []translator.UpdateSetValue
	MutationKeyRange     []interface{}
	AliasMap             map[string]tableConfig.AsKeywordMeta
	ExecuteOptions       utilities.ExecuteOptions
}

type TypeHandler

type TypeHandler struct {
	Logger      *zap.Logger
	TableConfig *tableConfig.TableConfig
	JsonStringGetter
	ProtocalV primitive.ProtocolVersion
}

func (*TypeHandler) BuildColumnMetadata

func (th *TypeHandler) BuildColumnMetadata(rowType *spannerpb.StructType,
	protocalV primitive.ProtocolVersion,
	aliasMap map[string]tableConfig.AsKeywordMeta,
	tableName, keyspace string) ([]func(int, *spanner.Row) ([]byte, error), []*message.ColumnMetadata, error)

BuildColumnMetadata constructs metadata for columns based on the given Spanner row type and query metadata. It returns a slice of functions to process each column and a slice of column metadata.

Parameters: - rowType: The Spanner row type containing field definitions. - protocalV: primitive.ProtocolVersion - aliasMap: map[string]translator.AsKeywordMeta - tableName string - keyspace string Returns: - A slice of functions to process each column. - A slice of column metadata. - An error if any issues arise during processing.

func (*TypeHandler) BuildResponseForSystemQueries

func (th *TypeHandler) BuildResponseForSystemQueries(rows [][]interface{}, protocalV primitive.ProtocolVersion) ([]message.Row, error)

function to encode rows - [][]interface{} to cassandra supported response formate [][][]bytes

func (*TypeHandler) BuildResponseRow

func (th *TypeHandler) BuildResponseRow(row *spanner.Row, rowFuncs []func(int, *spanner.Row) ([]byte, error)) (message.Row, error)

BuildResponseRow constructs a response row by applying a series of functions to each column of a Spanner row. It uses the provided row functions to encode each column and constructs a message row.

Parameters: - row: The Spanner row to be processed. - rowFuncs: A slice of functions to process each column in the row. Returns: - A message.Row, which is a slice of byte slices representing the encoded columns. - An error if any issues arise during processing.

func (*TypeHandler) GetColumnMeta

func (th *TypeHandler) GetColumnMeta(columnName string, tableName string) (string, error)

GetColumnMeta retrieves the metadata for a column based on the provided query metadata. Parameters:

  • columnName: Name of the column to get metadata for.
  • query: QueryMetadata containing details about the query.

Returns: Column metadata as a string and an error if any.

func (*TypeHandler) GetJsonString

func (th *TypeHandler) GetJsonString(i int, row *spanner.Row) (string, error)

func (*TypeHandler) HandleArrayType

func (th *TypeHandler) HandleArrayType(dt datatype.PrimitiveType) (func(int, *spanner.Row) ([]byte, error), error)

func (*TypeHandler) HandleBoolArrayType

func (th *TypeHandler) HandleBoolArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleBoolSetType

func (th *TypeHandler) HandleBoolSetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleByteArrayType

func (th *TypeHandler) HandleByteArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleByteSetType

func (th *TypeHandler) HandleByteSetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleCassandraBigintType

func (th *TypeHandler) HandleCassandraBigintType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra Bigint type

func (*TypeHandler) HandleCassandraBlobType

func (th *TypeHandler) HandleCassandraBlobType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra blob type

func (*TypeHandler) HandleCassandraBoolType

func (th *TypeHandler) HandleCassandraBoolType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra bool type

func (*TypeHandler) HandleCassandraDateType

func (th *TypeHandler) HandleCassandraDateType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra date type

func (*TypeHandler) HandleCassandraDoubleType

func (th *TypeHandler) HandleCassandraDoubleType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra Double type

func (*TypeHandler) HandleCassandraFloatType

func (th *TypeHandler) HandleCassandraFloatType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra float type

func (*TypeHandler) HandleCassandraIntType

func (th *TypeHandler) HandleCassandraIntType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra Int type

func (*TypeHandler) HandleCassandraTextType

func (th *TypeHandler) HandleCassandraTextType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra text type

func (*TypeHandler) HandleCassandraTimestampType

func (th *TypeHandler) HandleCassandraTimestampType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra timestamp type

func (*TypeHandler) HandleCassandraUuidType

func (th *TypeHandler) HandleCassandraUuidType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra Uuid type

func (*TypeHandler) HandleCassandraWriteTimeFuncType

func (th *TypeHandler) HandleCassandraWriteTimeFuncType(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner timestamp to cassandra Bigint type

func (*TypeHandler) HandleDateArrayType

func (th *TypeHandler) HandleDateArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleDateSetType

func (th *TypeHandler) HandleDateSetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleFloat64ArrayType

func (th *TypeHandler) HandleFloat64ArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleFloat64SetType

func (th *TypeHandler) HandleFloat64SetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleFloatArrayType

func (th *TypeHandler) HandleFloatArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleFloatSetType

func (th *TypeHandler) HandleFloatSetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleInt32ArrayType

func (th *TypeHandler) HandleInt32ArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleInt32SetType

func (th *TypeHandler) HandleInt32SetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleInt64ArrayType

func (th *TypeHandler) HandleInt64ArrayType(i int, row *spanner.Row) ([]byte, error)

The following functions (HandleInt64ArrayType, HandleStringArrayType, handle**ArrayType etc.) follow a similar pattern: They handle the conversion of specific array types from Spanner to Cassandra. Parameters are similar, involving the row reference, column index. Each returns a Cassandra datatype, the converted bytes, and an error if any.

func (*TypeHandler) HandleInt64SetType

func (th *TypeHandler) HandleInt64SetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleMapStringBool

func (th *TypeHandler) HandleMapStringBool(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra map<varchar, bool> type

func (*TypeHandler) HandleMapStringDate

func (th *TypeHandler) HandleMapStringDate(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra map<varchar, date> type

func (*TypeHandler) HandleMapStringFloat64

func (th *TypeHandler) HandleMapStringFloat64(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra map<varchar, double> type

func (*TypeHandler) HandleMapStringInt64

func (th *TypeHandler) HandleMapStringInt64(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra map<varchar, bigint> type

func (*TypeHandler) HandleMapStringString

func (th *TypeHandler) HandleMapStringString(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra map<varchar, varchar> type

func (*TypeHandler) HandleMapStringTimestamp

func (th *TypeHandler) HandleMapStringTimestamp(i int, row *spanner.Row) ([]byte, error)

handle encoding spanner data to cassandra map<varchar, timestamp> type

func (*TypeHandler) HandleMapType

func (th *TypeHandler) HandleMapType(dt datatype.DataType) (func(int, *spanner.Row) ([]byte, error), error)

func (*TypeHandler) HandleStringArrayType

func (th *TypeHandler) HandleStringArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleStringSetType

func (th *TypeHandler) HandleStringSetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleTimestampArrayType

func (th *TypeHandler) HandleTimestampArrayType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) HandleTimestampSetType

func (th *TypeHandler) HandleTimestampSetType(i int, row *spanner.Row) ([]byte, error)

func (*TypeHandler) TypeConversionForWriteTime

func (th *TypeHandler) TypeConversionForWriteTime(s time.Time) ([]byte, error)

TypeConversionForWriteTime converts a time.Time value to a byte slice for write operations, encoding it into a format compatible with the specified protocol version.

Parameters: - s: The time.Time value to be converted.

Returns: - []byte: The encoded byte slice representing the time value. - error: Any error encountered during the encoding process.

Jump to

Keyboard shortcuts

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