Documentation ¶
Index ¶
- func ConvertCivilDateToTime(cDate civil.Date) time.Time
- func ConvertToCQLDate(t time.Time) int32
- type JsonStringGetter
- type QueryMetadata
- type TypeHandler
- func (th *TypeHandler) BuildColumnMetadata(rowType *spannerpb.StructType, protocalV primitive.ProtocolVersion, ...) ([]func(int, *spanner.Row) ([]byte, error), []*message.ColumnMetadata, error)
- func (th *TypeHandler) BuildResponseForSystemQueries(rows [][]interface{}, protocalV primitive.ProtocolVersion) ([]message.Row, error)
- func (th *TypeHandler) BuildResponseRow(row *spanner.Row, rowFuncs []func(int, *spanner.Row) ([]byte, error)) (message.Row, error)
- func (th *TypeHandler) GetColumnMeta(columnName string, tableName string) (string, error)
- func (th *TypeHandler) GetJsonString(i int, row *spanner.Row) (string, error)
- func (th *TypeHandler) HandleArrayType(dt datatype.PrimitiveType) (func(int, *spanner.Row) ([]byte, error), error)
- func (th *TypeHandler) HandleBoolArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleBoolSetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleByteArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleByteSetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraBigintType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraBlobType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraBoolType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraDateType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraDoubleType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraFloatType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraIntType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraTextType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraTimestampType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraUuidType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleCassandraWriteTimeFuncType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleDateArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleDateSetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleFloat64ArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleFloat64SetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleFloatArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleFloatSetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleInt32ArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleInt32SetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleInt64ArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleInt64SetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapStringBool(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapStringDate(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapStringFloat64(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapStringInt64(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapStringString(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapStringTimestamp(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleMapType(dt datatype.DataType) (func(int, *spanner.Row) ([]byte, error), error)
- func (th *TypeHandler) HandleStringArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleStringSetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleTimestampArrayType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) HandleTimestampSetType(i int, row *spanner.Row) ([]byte, error)
- func (th *TypeHandler) TypeConversionForWriteTime(s time.Time) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertCivilDateToTime ¶
ConvertCivilDateToTime converts a civil.Date to a time.Time set to midnight UTC.
func ConvertToCQLDate ¶
ConvertToCQLDate converts a time.Time to a CQL date as an int32 representing days since the Unix epoch.
Types ¶
type JsonStringGetter ¶
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 (*TypeHandler) HandleArrayType ¶
func (th *TypeHandler) HandleArrayType(dt datatype.PrimitiveType) (func(int, *spanner.Row) ([]byte, error), error)
func (*TypeHandler) HandleBoolArrayType ¶
func (*TypeHandler) HandleBoolSetType ¶
func (*TypeHandler) HandleByteArrayType ¶
func (*TypeHandler) HandleByteSetType ¶
func (*TypeHandler) HandleCassandraBigintType ¶
handle encoding spanner data to cassandra Bigint type
func (*TypeHandler) HandleCassandraBlobType ¶
handle encoding spanner data to cassandra blob type
func (*TypeHandler) HandleCassandraBoolType ¶
handle encoding spanner data to cassandra bool type
func (*TypeHandler) HandleCassandraDateType ¶
handle encoding spanner data to cassandra date type
func (*TypeHandler) HandleCassandraDoubleType ¶
handle encoding spanner data to cassandra Double type
func (*TypeHandler) HandleCassandraFloatType ¶
handle encoding spanner data to cassandra float type
func (*TypeHandler) HandleCassandraIntType ¶
handle encoding spanner data to cassandra Int type
func (*TypeHandler) HandleCassandraTextType ¶
handle encoding spanner data to cassandra text type
func (*TypeHandler) HandleCassandraTimestampType ¶
handle encoding spanner data to cassandra timestamp type
func (*TypeHandler) HandleCassandraUuidType ¶
handle encoding spanner data to cassandra Uuid type
func (*TypeHandler) HandleCassandraWriteTimeFuncType ¶
handle encoding spanner timestamp to cassandra Bigint type
func (*TypeHandler) HandleDateArrayType ¶
func (*TypeHandler) HandleDateSetType ¶
func (*TypeHandler) HandleFloat64ArrayType ¶
func (*TypeHandler) HandleFloat64SetType ¶
func (*TypeHandler) HandleFloatArrayType ¶
func (*TypeHandler) HandleFloatSetType ¶
func (*TypeHandler) HandleInt32ArrayType ¶
func (*TypeHandler) HandleInt32SetType ¶
func (*TypeHandler) HandleInt64ArrayType ¶
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 (*TypeHandler) HandleMapStringBool ¶
handle encoding spanner data to cassandra map<varchar, bool> type
func (*TypeHandler) HandleMapStringDate ¶
handle encoding spanner data to cassandra map<varchar, date> type
func (*TypeHandler) HandleMapStringFloat64 ¶
handle encoding spanner data to cassandra map<varchar, double> type
func (*TypeHandler) HandleMapStringInt64 ¶
handle encoding spanner data to cassandra map<varchar, bigint> type
func (*TypeHandler) HandleMapStringString ¶
handle encoding spanner data to cassandra map<varchar, varchar> type
func (*TypeHandler) HandleMapStringTimestamp ¶
handle encoding spanner data to cassandra map<varchar, timestamp> type
func (*TypeHandler) HandleMapType ¶
func (*TypeHandler) HandleStringArrayType ¶
func (*TypeHandler) HandleStringSetType ¶
func (*TypeHandler) HandleTimestampArrayType ¶
func (*TypeHandler) HandleTimestampSetType ¶
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.