element

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

go-etl Data Type Descriptions

This package primarily defines the data types used in go-etl.

Record

// Record represents a data record.
type Record interface {
 fmt.Stringer

 Add(Column) error                      // Adds a new column.
 GetByIndex(i int) (Column, error)      // Retrieves the column at the specified index.
 GetByName(name string) (Column, error) // Retrieves the column with the specified name.
 Set(i int, c Column) error             // Sets the column at the specified index.
 ColumnNumber() int                     // Returns the number of columns.
 ByteSize() int64                       // Returns the size of the record in bytes.
 MemorySize() int64                     // Returns the memory usage of the record.
}

Data Type Conversions

go-etl supports six internal data types:

  • bigInt: Fixed-point numbers (int64, int32, int16, int8, BigInt, etc.).
  • decimal: Floating-point numbers (float32, float64, BigDecimal (unlimited precision), etc.).
  • string: String type, with unlimited length and using a universal character set (Unicode).
  • time: Date and time type.
  • bool: Boolean value.
  • bytes: Binary data, which can store unstructured data such as MP3 files.

Correspondingly, there are six implementations of ColumnValue: TimeColumnValue, BigIntColumnValue, DecimalColumnValue, BytesColumnValue, StringColumnValue, and BoolColumnValue.

These ColumnValue interfaces provide a series of data type conversion methods that start with as.

// ColumnValue represents a value in a column.
type ColumnValue interface {
 fmt.Stringer

 Type() ColumnType                    // Returns the column type.
 IsNil() bool                         // Checks if the value is nil.
 AsBool() (bool, error)               // Converts the value to a boolean.
 AsBigInt() (*big.Int, error)         // Converts the value to a big integer.
 AsDecimal() (decimal.Decimal, error) // Converts the value to a decimal with unlimited precision.
 AsString() (string, error)           // Converts the value to a string.
 AsBytes() ([]byte, error)            // Converts the value to a byte array.
 AsTime() (time.Time, error)          // Converts the value to a time.
}

Based on the ColumnValue interface, the following methods are implemented:

// Column represents a data column.
type Column interface {
 ColumnValue
 AsInt64() (int64, error)     // Converts the value to a 64-bit integer.
 AsFloat64() (float64, error) // Converts the value to a 64-bit floating point number.
 Clone() (Column, error)      // Clones the column.
 Cmp(Column) (int, error)     // Compares the column with another column. Returns 1 if greater, 0 if equal, -1 if less.
 Name() string                // Returns the name of the column.
 ByteSize() int64             // Returns the size of the column in bytes.
 MemorySize() int64           // Returns the memory usage of the column.
}

The internal types of DataX are implemented using different Golang types: Currently, there are two implementation approaches, but the older approach has performance issues when dealing with large datasets. The new implementation is still in beta and has not been thoroughly validated through practical use.

  • Older Implementation Approach
Internal Type Implementation Type Notes
time time.Time
bigInt big.Int Uses arbitrary-precision integers to ensure no loss of precision.
decimal decimal.Decimal Represented using decimal.Decimal to ensure no loss of precision.
bytes []byte
string string
bool bool
  • Current Implementation Approach
Internal Type Implementation Type Notes
time time.Time
bigInt BigIntNumber Uses a hybrid approach of storing values as Int64 and BigIntStr to ensure no loss of precision.
decimal DecimalNumber Uses a hybrid approach of storing values as Float64, Int64, BigIntStr, DecimalStr, and Decimal to ensure no loss of precision.
bytes []byte
string string
bool bool

The gap between these two implementation methods mainly lies in numerical adjustments, which are integrated through the following interfaces:

// NumberConverter: Digital Converter
type NumberConverter interface {
 ConvertBigIntFromInt(i int64) (num BigIntNumber)
 ConvertDecimalFromFloat(f float64) (num DecimalNumber)
 ConvertBigInt(s string) (num BigIntNumber, err error)
 ConvertDecimal(s string) (num DecimalNumber, err error)
}

// Number: Represents a numeric value
type Number interface {
 Bool() (bool, error)
 String() string
}

// BigIntNumber: Represents a high-precision integer
type BigIntNumber interface {
 Number

 Int64() (int64, error)
 Decimal() DecimalNumber
 CloneBigInt() BigIntNumber
 AsBigInt() *big.Int
}

// DecimalNumber: Represents a high-precision decimal number
type DecimalNumber interface {
 Number

 Float64() (float64, error)
 BigInt() BigIntNumber
 CloneDecimal() DecimalNumber
 AsDecimal() decimal.Decimal
}

The main implementations are Converter (the current implementation method) and OldConverter (the previous implementation method). Converter outperforms OldConverter in terms of performance. The test results from number_bench_test.go are as follows:

BenchmarkConverter_ConvertFromBigInt-4                	34292768	        40.13 ns/op	       8 B/op	       0 allocs/op
BenchmarkOldConverter_ConvertFromBigInt-4             	19314712	        58.69 ns/op	      16 B/op	       1 allocs/op
BenchmarkConverter_ConvertDecimalFromloat-4           	100000000	        15.74 ns/op	       8 B/op	       0 allocs/op
BenchmarkOldConverter_ConvertDecimalFromFloat-4       	 1654504	       725.8 ns/op	      48 B/op	       2 allocs/op
BenchmarkConverter_ConvertBigInt_Int64-4              	 5020077	       230.0 ns/op	      39 B/op	       2 allocs/op
BenchmarkOldConverter_ConvertBigInt_Int64-4           	 2232102	       627.3 ns/op	     111 B/op	       5 allocs/op
BenchmarkCoventor_ConvertBigInt_large_number-4        	   50010	     21211 ns/op	    8064 B/op	     216 allocs/op
BenchmarkOldCoventor_ConvertBigInt_large_number-4     	   23709	     51818 ns/op	    9216 B/op	     360 allocs/op
BenchmarkConverter_ConvertDecimal_Int64-4             	 3830624	       312.6 ns/op	      39 B/op	       2 allocs/op
BenchmarkOldConverter_ConvertDecimal_Int64-4          	 1995441	       611.4 ns/op	     116 B/op	       4 allocs/op
BenchmarkConverter_ConvertDecimal_Float64-4           	 1707649	       671.4 ns/op	     178 B/op	       5 allocs/op
BenchmarkOldConverter_ConvertDecimal_Float64-4        	 1229505	       991.1 ns/op	     191 B/op	       6 allocs/op
BenchmarkConverter_ConvertDecimal-4                   	   80113	     15009 ns/op	    2280 B/op	     144 allocs/op
BenchmarkOldConverter_ConvertDecimal-4                	   56880	     26496 ns/op	    4608 B/op	     288 allocs/op
BenchmarkConverter_ConvertDecimal_large_number-4      	   45754	     22387 ns/op	    5184 B/op	     144 allocs/op
BenchmarkOldConverter_ConvertDecimal_large_number-4   	   16726	     69543 ns/op	   13248 B/op	     432 allocs/op
BenchmarkConverter_ConvertDecimal_Exp-4               	   15516	     86355 ns/op	   18432 B/op	     648 allocs/op
BenchmarkOldConverter_ConvertDecimal_Exp-4            	   17992	     56777 ns/op	   11520 B/op	     432 allocs/op
BenchmarkDecimal_Decmial_String-4                     	 3443062	       361.0 ns/op	      88 B/op	       5 allocs/op
BenchmarkDecimal_DecmialStr_String-4                  	1000000000	         0.6694 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecimal_Float64_String-4                     	 5254669	       260.7 ns/op	      48 B/op	       2 allocs/op
BenchmarkDecimal_Int64_String-4                       	13537401	        89.62 ns/op	      24 B/op	       1 allocs/op
BenchmarkDecimal_BigInt_String-4                      	 4664106	       247.4 ns/op	      56 B/op	       3 allocs/op
BenchmarkDecimal_BigIntStr_String-4                   	1000000000	         0.6873 ns/op	       0 B/op	       0 allocs/op

Additionally, if any issues arise, you can revert to the old implementation by modifying the _DefaultNumberConverter value in number.go.

The relationship between the types and their conversions is as follows:

from\to time bigInt decimal bytes string bool
time - Not supported Not supported Supports conversion of specified time formats (generally supports default time format) Supports conversion of specified time formats (generally supports default time format) Not supported
bigInt Not supported - Supported Supported Supported Converts non-zero values to true, and zero to false
decimal Not supported Rounds to the nearest integer, truncating the decimal part - Supported Supported Converts non-zero values to true, and zero to false
bytes Only supports conversion of specified time formats (generally supports default time format) Real numbers and scientific notation strings are rounded Real numbers and scientific notation strings - Supported Supports conversion of "1", "t", "T", "TRUE", "true", "True" to true, and "0", "f", "F", "FALSE", "false", "False" to false
string Only supports conversion of specified time formats (generally supports default time format) Real numbers and scientific notation strings are rounded Real numbers and scientific notation strings Supported - Supports conversion of "1", "t", "T", "TRUE", "true", "True" to "true", and "0", "f", "F", "FALSE", "false", "False" to false
bool Not supported true converts to 1, false converts to 0 true converts to 1.0, false converts to 0.0 true converts to "true", false converts to "false" true converts to "true", false converts to "false" -

Note: The default time format is 2006-01-02 15:04:05.999999999Z07:00

This table provides an overview of data type conversions between different formats, including time, bigInt, decimal, bytes, string, and bool. It specifies which conversions are supported and which are not, as well as any specific behavior or limitations associated with each conversion.

Documentation

Overview

Package element provides various types of column values, columns, records, and record channels

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrColumnExist              = errors.New("column exist")                  // Column exists error
	ErrColumnNotExist           = errors.New("column does not exist")         // Column does not exist error
	ErrNilValue                 = errors.New("column value is nil")           // Null value error
	ErrIndexOutOfRange          = errors.New("column index is out of range")  // Index value out of range
	ErrValueNotInt64            = errors.New("value is not int64")            // Not an int64 error
	ErrValueInfinity            = errors.New("value is infinity")             // Infinite real number error
	ErrNotColumnValueClonable   = errors.New("columnValue is not clonable")   // Not a clonable column value
	ErrNotColumnValueComparable = errors.New("columnValue is not comparable") // Not a comparable column value
	ErrColumnNameNotEqual       = errors.New("column name is not equal")      // Column names differ
)

Error

View Source
var DefaultTimeFormat = "2006-01-02 15:04:05.999999999Z07:00"

DefaultTimeFormat - Default time format

Functions

func ByteSize added in v0.1.2

func ByteSize(src interface{}) int

ByteSize: Byte size

Types

type BigInt

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

BigInt - Big integer

func (*BigInt) AsBigInt

func (b *BigInt) AsBigInt() *big.Int

AsBigInt - Convert to high-precision integer

func (*BigInt) AsDecimal

func (b *BigInt) AsDecimal() decimal.Decimal

AsDecimal - Convert to high-precision decimal

func (*BigInt) BigInt

func (b *BigInt) BigInt() BigIntNumber

BigInt - Convert to high-precision integer

func (*BigInt) Bool

func (b *BigInt) Bool() (bool, error)

Bool - Convert to boolean

func (*BigInt) CloneBigInt

func (b *BigInt) CloneBigInt() BigIntNumber

CloneBigInt - Clone high-precision integer

func (*BigInt) CloneDecimal

func (b *BigInt) CloneDecimal() DecimalNumber

CloneDecimal - Clone high-precision decimal

func (*BigInt) Decimal

func (b *BigInt) Decimal() DecimalNumber

Decimal - Convert to high-precision decimal

func (*BigInt) Float64

func (b *BigInt) Float64() (v float64, err error)

Float64 - Convert to 64-bit floating-point number

func (*BigInt) Int64

func (b *BigInt) Int64() (int64, error)

Int64 - Convert to 64-bit integer

func (*BigInt) String

func (b *BigInt) String() string

Decimal - Convert to string

type BigIntColumnValue

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

BigIntColumnValue - Value for a big integer column

func (*BigIntColumnValue) AsBigInt

func (b *BigIntColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt - Convert to a big integer

func (*BigIntColumnValue) AsBool

func (b *BigIntColumnValue) AsBool() (bool, error)

AsBool - Convert to a boolean value, where non-zero becomes true and zero becomes false

func (*BigIntColumnValue) AsBytes

func (b *BigIntColumnValue) AsBytes() ([]byte, error)

AsBytes - Convert to a byte stream, e.g., 1234556790 becomes [49, 50, 51, 52, 53, 54, 55, 56, 57, 48]

func (*BigIntColumnValue) AsDecimal

func (b *BigIntColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal - Convert to a high-precision decimal number

func (*BigIntColumnValue) AsString

func (b *BigIntColumnValue) AsString() (string, error)

AsString - Convert to a string, e.g., 1234556790 becomes 1234556790

func (*BigIntColumnValue) AsTime

func (b *BigIntColumnValue) AsTime() (time.Time, error)

AsTime - Currently, integers cannot be converted to time

func (*BigIntColumnValue) Clone

func (b *BigIntColumnValue) Clone() ColumnValue

Clone - Clone the big integer column value

func (*BigIntColumnValue) Cmp

func (b *BigIntColumnValue) Cmp(right ColumnValue) (int, error)

Cmp - Return 1 for greater than, 0 for equal, and -1 for less than

func (*BigIntColumnValue) IsNil

func (n *BigIntColumnValue) IsNil() bool

IsNil: Whether it is null

func (*BigIntColumnValue) String

func (b *BigIntColumnValue) String() string

func (*BigIntColumnValue) Type

func (b *BigIntColumnValue) Type() ColumnType

Type - Return the type of the column

type BigIntNumber

type BigIntNumber interface {
	Number

	Int64() (int64, error)
	Decimal() DecimalNumber
	CloneBigInt() BigIntNumber
	AsBigInt() *big.Int
}

BigIntNumber - High-precision integer

type BigIntStr

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

BigIntStr - High-precision integer string

func (*BigIntStr) AsBigInt

func (b *BigIntStr) AsBigInt() *big.Int

AsBigInt - Convert to high-precision integer

func (*BigIntStr) AsDecimal

func (b *BigIntStr) AsDecimal() decimal.Decimal

AsDecimal - Convert to high-precision decimal

func (*BigIntStr) BigInt

func (b *BigIntStr) BigInt() BigIntNumber

BigInt - Convert to high-precision integer

func (*BigIntStr) Bool

func (b *BigIntStr) Bool() (bool, error)

Bool - Convert to boolean

func (*BigIntStr) CloneBigInt

func (b *BigIntStr) CloneBigInt() BigIntNumber

CloneBigInt - Clone high-precision integer

func (*BigIntStr) CloneDecimal

func (b *BigIntStr) CloneDecimal() DecimalNumber

CloneDecimal - Clone high-precision decimal

func (*BigIntStr) Decimal

func (b *BigIntStr) Decimal() DecimalNumber

Decimal - Convert to high-precision decimal

func (*BigIntStr) Float64

func (b *BigIntStr) Float64() (v float64, err error)

Float64 - Convert to 64-bit floating-point number

func (*BigIntStr) Int64

func (b *BigIntStr) Int64() (int64, error)

Int64 - Convert to 64-bit integer

func (*BigIntStr) String

func (b *BigIntStr) String() string

Decimal - Convert to string

type BoolColumnValue

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

BoolColumnValue represents a Boolean column value

func (*BoolColumnValue) AsBigInt

func (b *BoolColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt converts it to a big integer, where true becomes 1 and false becomes 0

func (*BoolColumnValue) AsBool

func (b *BoolColumnValue) AsBool() (bool, error)

AsBool converts it to a boolean value

func (*BoolColumnValue) AsBytes

func (b *BoolColumnValue) AsBytes() ([]byte, error)

AsBytes converts it to a byte stream, where true becomes true and false becomes false

func (*BoolColumnValue) AsDecimal

func (b *BoolColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal converts it to a high-precision decimal number, where true becomes 1.0 and false becomes 0.0

func (*BoolColumnValue) AsString

func (b *BoolColumnValue) AsString() (string, error)

AsString converts it to a string, where true becomes true and false becomes false

func (*BoolColumnValue) AsTime

func (b *BoolColumnValue) AsTime() (time.Time, error)

AsTime: Currently, a Boolean cannot be converted to a time value

func (*BoolColumnValue) Clone

func (b *BoolColumnValue) Clone() ColumnValue

Clone clones a Boolean column value

func (*BoolColumnValue) Cmp

func (b *BoolColumnValue) Cmp(right ColumnValue) (int, error)

Cmp: Returns 1 for greater than, 0 for equal, and -1 for less than

func (*BoolColumnValue) IsNil

func (n *BoolColumnValue) IsNil() bool

IsNil: Whether it is null

func (*BoolColumnValue) String

func (b *BoolColumnValue) String() string

func (*BoolColumnValue) Type

func (b *BoolColumnValue) Type() ColumnType

Type returns the type of the column

type BytesColumnValue

type BytesColumnValue struct {
	TimeEncoder // Time Encoder
	// contains filtered or unexported fields
}

BytesColumnValue - Byte stream column value

func (*BytesColumnValue) AsBigInt

func (b *BytesColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt - Convert to an integer. Real numbers and scientific notation strings will be rounded. Non-numeric values will report an error. E.g., 123.67 is converted to 123, and 123.12 is converted to 123.

func (*BytesColumnValue) AsBool

func (b *BytesColumnValue) AsBool() (bool, error)

AsBool - Convert 1, t, T, TRUE, true, True to true Convert 0, f, F, FALSE, false, False to false. If none of the above, an error is reported.

func (*BytesColumnValue) AsBytes

func (b *BytesColumnValue) AsBytes() ([]byte, error)

AsBytes - Convert to a byte stream

func (*BytesColumnValue) AsDecimal

func (b *BytesColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal - Convert to a high-precision decimal. Real numbers and scientific notation strings can be converted. Non-numeric values will report an error.

func (*BytesColumnValue) AsString

func (b *BytesColumnValue) AsString() (string, error)

AsString - Convert to a string

func (*BytesColumnValue) AsTime

func (b *BytesColumnValue) AsTime() (t time.Time, err error)

AsTime - Convert to time based on the time encoder. If it does not match the time encoder format, an error is reported.

func (*BytesColumnValue) Clone

func (b *BytesColumnValue) Clone() ColumnValue

Clone - Clone the byte stream column value

func (*BytesColumnValue) Cmp

func (b *BytesColumnValue) Cmp(right ColumnValue) (int, error)

Cmp - Return 1 for greater than, 0 for equal, and -1 for less than

func (*BytesColumnValue) IsNil

func (n *BytesColumnValue) IsNil() bool

IsNil: Whether it is null

func (*BytesColumnValue) String

func (b *BytesColumnValue) String() string

func (*BytesColumnValue) Type

func (b *BytesColumnValue) Type() ColumnType

Type - Return the column type

type Column

type Column interface {
	ColumnValue
	AsInt64() (int64, error)     // ToInt64: Convert to 64-bit integer
	AsFloat64() (float64, error) // ToFloat64: Convert to 64-bit real number
	Clone() (Column, error)      // Clone: Clone
	Cmp(Column) (int, error)     // Compare: 1 represents greater than, 0 represents equal, -1 represents less than
	Name() string                // Name: Column name
	ByteSize() int64             // ByteSize: Byte stream size
	MemorySize() int64           // MemorySize: Memory size
}

Column: Column

func NewDefaultColumn

func NewDefaultColumn(v ColumnValue, name string, byteSize int) Column

NewDefaultColumn: Create a new default column based on column value v, column name name, and byte stream size byteSize

type ColumnType

type ColumnType string

ColumnType: Column Type

const (
	TypeUnknown ColumnType = "unknown" // UnknownType: Unknown type
	TypeBool    ColumnType = "bool"    // BoolType: Boolean type
	TypeBigInt  ColumnType = "bigInt"  // IntType: Integer type
	TypeDecimal ColumnType = "decimal" // DecimalType: High-precision real number type
	TypeString  ColumnType = "string"  // StringType: String type
	TypeBytes   ColumnType = "bytes"   // BytesType: Byte stream type
	TypeTime    ColumnType = "time"    // TimeType: Time type
)

ColumnTypeEnum: Enumeration of column types

func (ColumnType) String

func (c ColumnType) String() string

String: Printing display

type ColumnValue

type ColumnValue interface {
	fmt.Stringer

	Type() ColumnType                  // ColumnType: Column type
	IsNil() bool                       // IsNull: Whether it is null
	AsBool() (bool, error)             // ToBool: Convert to boolean
	AsBigInt() (BigIntNumber, error)   // ToInt: Convert to integer
	AsDecimal() (DecimalNumber, error) // ToDecimal: Convert to high-precision real number
	AsString() (string, error)         // ToString: Convert to string
	AsBytes() ([]byte, error)          // ToBytes: Convert to byte stream
	AsTime() (time.Time, error)        // ToTime: Convert to time
}

ColumnValue: Column Value

func NewBigIntColumnValue

func NewBigIntColumnValue(v *big.Int) ColumnValue

NewBigIntColumnValue - Create a big integer column value from a big.Int v

func NewBigIntColumnValueFromInt64

func NewBigIntColumnValueFromInt64(v int64) ColumnValue

NewBigIntColumnValueFromInt64 - Create a big integer column value from an int64 v

func NewBigIntColumnValueFromString

func NewBigIntColumnValueFromString(v string) (ColumnValue, error)

NewBigIntColumnValueFromString - Create a big integer column value from a string v If the string v is not an integer, an error is returned

func NewBoolColumnValue

func NewBoolColumnValue(v bool) ColumnValue

NewBoolColumnValue creates a Boolean column value from the boolean value v

func NewBytesColumnValue

func NewBytesColumnValue(v []byte) ColumnValue

NewBytesColumnValue - Generate a byte stream column value from byte stream v, making a copy

func NewBytesColumnValueNoCopy

func NewBytesColumnValueNoCopy(v []byte) ColumnValue

NewBytesColumnValueNoCopy - Generate a byte stream column value from byte stream v, without making a copy

func NewBytesColumnValueWithEncoder

func NewBytesColumnValueWithEncoder(v []byte, e TimeEncoder) ColumnValue

NewBytesColumnValueWithEncoder - Generate a byte stream column value from byte stream v and time encoder e, making a copy

func NewBytesColumnValueWithEncoderNoCopy

func NewBytesColumnValueWithEncoderNoCopy(v []byte, e TimeEncoder) ColumnValue

NewBytesColumnValueWithEncoderNoCopy - Generate a byte stream column value from byte stream v and time encoder e, without making a copy

func NewDecimalColumnValue

func NewDecimalColumnValue(d decimal.Decimal) ColumnValue

NewDecimalColumnValue creates a high-precision decimal column value from a high-precision decimal value.

func NewDecimalColumnValueFromFloat

func NewDecimalColumnValueFromFloat(f float64) ColumnValue

NewDecimalColumnValueFromFloat creates a high-precision decimal column value from a float64 value.

func NewDecimalColumnValueFromString

func NewDecimalColumnValueFromString(s string) (ColumnValue, error)

NewDecimalColumnValueFromString creates a high-precision decimal column value from a string. If the string is not a numeric value or in scientific notation, an error will be reported.

func NewNilBigIntColumnValue

func NewNilBigIntColumnValue() ColumnValue

NewNilBigIntColumnValue - Create a null value for a big integer column

func NewNilBoolColumnValue

func NewNilBoolColumnValue() ColumnValue

NewNilBoolColumnValue creates an empty Boolean column value

func NewNilBytesColumnValue

func NewNilBytesColumnValue() ColumnValue

NewNilBytesColumnValue - Create a null byte stream column value

func NewNilDecimalColumnValue

func NewNilDecimalColumnValue() ColumnValue

NewNilDecimalColumnValue creates a null value for a high-precision decimal column.

func NewNilStringColumnValue

func NewNilStringColumnValue() ColumnValue

NewNilStringColumnValue - Create a null value for a string column

func NewNilTimeColumnValue

func NewNilTimeColumnValue() ColumnValue

NewNilTimeColumnValue creates an empty time column value

func NewStringColumnValue

func NewStringColumnValue(s string) ColumnValue

NewStringColumnValue - Create a string column value based on the string s

func NewStringColumnValueWithEncoder

func NewStringColumnValueWithEncoder(s string, e TimeEncoder) ColumnValue

NewStringColumnValueWithEncoder - Create a string column value based on the string s and time encoder e

func NewTimeColumnValue

func NewTimeColumnValue(t time.Time) ColumnValue

NewTimeColumnValue creates a time column value from the time t

func NewTimeColumnValueWithDecoder

func NewTimeColumnValueWithDecoder(t time.Time, d TimeDecoder) ColumnValue

NewTimeColumnValueWithDecoder creates a time column value from the time t and the time decoder

type ColumnValueClonable

type ColumnValueClonable interface {
	Clone() ColumnValue // Clone: Clone
}

ColumnValueClonable: Cloneable column value

type ColumnValueComparabale

type ColumnValueComparabale interface {
	// Compare: 1 represents greater than, 0 represents equal, -1 represents less than
	Cmp(ColumnValue) (int, error)
}

ColumnValueComparabale: Comparable column value

type Converter

type Converter struct{}

Converter - Number converter

func (*Converter) ConvertBigInt

func (c *Converter) ConvertBigInt(s string) (num BigIntNumber, err error)

ConvertBigInt converts a string to an integer

func (*Converter) ConvertBigIntFromInt

func (c *Converter) ConvertBigIntFromInt(i int64) (num BigIntNumber)

ConvertBigIntFromInt - Convert to decimal from integer

func (*Converter) ConvertDecimal

func (c *Converter) ConvertDecimal(s string) (num DecimalNumber, err error)

ConvertDecimal - Convert string to decimal

func (*Converter) ConvertDecimalFromFloat

func (c *Converter) ConvertDecimalFromFloat(f float64) (num DecimalNumber)

ConvertDecimalFromFloat - Convert to decimal from floating-point number

type Decimal

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

Decimal - High-precision decimal

func (*Decimal) AsDecimal

func (d *Decimal) AsDecimal() decimal.Decimal

AsDecimal - Convert to high-precision decimal

func (*Decimal) BigInt

func (d *Decimal) BigInt() BigIntNumber

BigInt - Convert to high-precision integer

func (*Decimal) Bool

func (d *Decimal) Bool() (bool, error)

Bool - Convert to boolean

func (*Decimal) CloneDecimal

func (d *Decimal) CloneDecimal() DecimalNumber

CloneDecimal - Clone high-precision decimal

func (*Decimal) Decimal

func (d *Decimal) Decimal() DecimalNumber

Decimal - Convert to high-precision decimal

func (*Decimal) Float64

func (d *Decimal) Float64() (float64, error)

Float64 - Convert to 64-bit floating-point number

func (*Decimal) String

func (d *Decimal) String() string

Decimal - Convert to string

type DecimalColumnValue

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

DecimalColumnValue represents a high-precision decimal column value.

func (*DecimalColumnValue) AsBigInt

func (d *DecimalColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt rounds down the high-precision decimal value, e.g., 123.67 becomes 123, and 123.12 becomes 123.

func (*DecimalColumnValue) AsBool

func (d *DecimalColumnValue) AsBool() (bool, error)

AsBool converts non-zero values to true and zero values to false.

func (*DecimalColumnValue) AsBytes

func (d *DecimalColumnValue) AsBytes() ([]byte, error)

AsBytes converts to a byte stream, e.g., 10.123 becomes the byte representation of 10.123.

func (*DecimalColumnValue) AsDecimal

func (d *DecimalColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal converts to a high-precision decimal.

func (*DecimalColumnValue) AsString

func (d *DecimalColumnValue) AsString() (string, error)

AsString converts to a string, e.g., 10.123 becomes 10.123.

func (*DecimalColumnValue) AsTime

func (d *DecimalColumnValue) AsTime() (time.Time, error)

AsTime currently cannot convert to a time value.

func (*DecimalColumnValue) Clone

func (d *DecimalColumnValue) Clone() ColumnValue

Clone creates a copy (clone) of a high-precision decimal column value.

func (*DecimalColumnValue) Cmp

func (d *DecimalColumnValue) Cmp(right ColumnValue) (int, error)

Cmp returns 1 for greater than, 0 for equal, and -1 for less than.

func (*DecimalColumnValue) IsNil

func (n *DecimalColumnValue) IsNil() bool

IsNil: Whether it is null

func (*DecimalColumnValue) String

func (d *DecimalColumnValue) String() string

func (*DecimalColumnValue) Type

func (d *DecimalColumnValue) Type() ColumnType

Type represents the type of the column.

type DecimalNumber

type DecimalNumber interface {
	Number

	Float64() (float64, error)
	BigInt() BigIntNumber
	CloneDecimal() DecimalNumber
	AsDecimal() decimal.Decimal
}

DecimalNumber - High-precision decimal

type DecimalStr

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

DecimalStr - High-precision decimal string

func (*DecimalStr) AsDecimal

func (d *DecimalStr) AsDecimal() decimal.Decimal

AsDecimal - Convert to high-precision decimal

func (*DecimalStr) BigInt

func (d *DecimalStr) BigInt() BigIntNumber

BigInt - Convert to high-precision integer

func (*DecimalStr) Bool

func (d *DecimalStr) Bool() (bool, error)

Bool - Convert to boolean

func (*DecimalStr) CloneDecimal

func (d *DecimalStr) CloneDecimal() DecimalNumber

CloneDecimal - Clone high-precision decimal

func (*DecimalStr) Decimal

func (d *DecimalStr) Decimal() DecimalNumber

Decimal - Convert to high-precision decimal

func (*DecimalStr) Float64

func (d *DecimalStr) Float64() (v float64, err error)

Float64 - Convert to 64-bit floating-point number

func (*DecimalStr) String

func (d *DecimalStr) String() string

Decimal - Convert to string

type DefaultColumn

type DefaultColumn struct {
	ColumnValue // ColumnValue: Column value
	// contains filtered or unexported fields
}

DefaultColumn: Default value

func (*DefaultColumn) AsFloat64

func (d *DefaultColumn) AsFloat64() (float64, error)

AsFloat64: Convert to 64-bit real number

func (*DefaultColumn) AsInt64

func (d *DefaultColumn) AsInt64() (int64, error)

AsInt64: Convert to 64-bit integer

func (*DefaultColumn) ByteSize

func (d *DefaultColumn) ByteSize() int64

ByteSize: Byte stream size

func (*DefaultColumn) Clone

func (d *DefaultColumn) Clone() (Column, error)

Clone: Clone a column. If it's not a cloneable column value, an error will occur.

func (*DefaultColumn) Cmp

func (d *DefaultColumn) Cmp(c Column) (int, error)

Cmp: Compare columns. If it's not a comparable column value, an error will occur.

func (*DefaultColumn) MemorySize

func (d *DefaultColumn) MemorySize() int64

MemorySize: Memory size

func (*DefaultColumn) Name

func (d *DefaultColumn) Name() string

Name: Column name

type DefaultRecord

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

DefaultRecord represents a default record.

func NewDefaultRecord

func NewDefaultRecord() *DefaultRecord

NewDefaultRecord creates a new default record.

func (*DefaultRecord) Add

func (r *DefaultRecord) Add(c Column) error

AddColumn adds a new column c. If column c already exists, an error is reported.

func (*DefaultRecord) ByteSize

func (r *DefaultRecord) ByteSize() int64

ByteSize represents the size of the record in bytes.

func (*DefaultRecord) ColumnNumber

func (r *DefaultRecord) ColumnNumber() int

ColumnNumber represents the number of columns in the record.

func (*DefaultRecord) GetByIndex

func (r *DefaultRecord) GetByIndex(i int) (Column, error)

GetByIndex gets the column at index i. If the index is out of range or doesn't exist, an error is reported.

func (*DefaultRecord) GetByName

func (r *DefaultRecord) GetByName(name string) (Column, error)

GetByName gets the column with the specified name. If the column doesn't exist, an error is reported.

func (*DefaultRecord) MemorySize

func (r *DefaultRecord) MemorySize() int64

MemorySize represents the size of the record in memory.

func (*DefaultRecord) Put

func (r *DefaultRecord) Put(c Column) error

PutColumn sets the value of the column with the specified name. If the column name doesn't exist, an error is reported.

func (*DefaultRecord) Set

func (r *DefaultRecord) Set(i int, c Column) error

SetColumnByIndex sets the value of the column at index i. If the index is out of range, an error is reported.

func (*DefaultRecord) String

func (r *DefaultRecord) String() string

String is an empty method placeholder.

type Float64

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

Float64 - 64-bit floating-point number

func (*Float64) AsDecimal

func (f *Float64) AsDecimal() decimal.Decimal

AsDecimal - Convert to high-precision decimal

func (*Float64) BigInt

func (f *Float64) BigInt() BigIntNumber

BigInt - Convert to high-precision integer

func (*Float64) Bool

func (f *Float64) Bool() (bool, error)

Bool - Convert to boolean

func (*Float64) CloneDecimal

func (f *Float64) CloneDecimal() DecimalNumber

CloneDecimal - Clone high-precision decimal

func (*Float64) Decimal

func (f *Float64) Decimal() DecimalNumber

Decimal - Convert to high-precision decimal

func (*Float64) Float64

func (f *Float64) Float64() (float64, error)

Float64 - Convert to 64-bit floating-point number

func (*Float64) String

func (f *Float64) String() string

Decimal - Convert to string

type Int64

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

Int64 - 64-bit integer

func (*Int64) AsBigInt

func (i *Int64) AsBigInt() *big.Int

AsBigInt - Convert to high-precision integer

func (*Int64) AsDecimal

func (i *Int64) AsDecimal() decimal.Decimal

AsDecimal - Convert to high-precision decimal

func (*Int64) BigInt

func (i *Int64) BigInt() BigIntNumber

BigInt - Convert to high-precision integer

func (*Int64) Bool

func (i *Int64) Bool() (bool, error)

Bool - Convert to boolean

func (*Int64) CloneBigInt

func (i *Int64) CloneBigInt() BigIntNumber

CloneBigInt - Clone high-precision integer

func (*Int64) CloneDecimal

func (i *Int64) CloneDecimal() DecimalNumber

CloneDecimal - Clone high-precision decimal

func (*Int64) Decimal

func (i *Int64) Decimal() DecimalNumber

Decimal - Convert to high-precision decimal

func (*Int64) Float64

func (i *Int64) Float64() (float64, error)

Float64 - Convert to 64-bit floating-point number

func (*Int64) Int64

func (i *Int64) Int64() (int64, error)

Int64 - Convert to 64-bit integer

func (*Int64) String

func (i *Int64) String() string

Decimal - Convert to string

type NilBigIntColumnValue

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

NilBigIntColumnValue - Null value for a big integer column

func (NilBigIntColumnValue) AsBigInt

func (n NilBigIntColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Failed to convert to integer

func (NilBigIntColumnValue) AsBool

func (n NilBigIntColumnValue) AsBool() (bool, error)

AsBool: Failed to convert to boolean

func (NilBigIntColumnValue) AsBytes

func (n NilBigIntColumnValue) AsBytes() ([]byte, error)

AsBytes: Failed to convert to byte stream

func (NilBigIntColumnValue) AsDecimal

func (n NilBigIntColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Failed to convert to high-precision real number

func (NilBigIntColumnValue) AsString

func (n NilBigIntColumnValue) AsString() (string, error)

AsString: Failed to convert to string

func (NilBigIntColumnValue) AsTime

func (n NilBigIntColumnValue) AsTime() (time.Time, error)

AsTime: Failed to convert to time

func (*NilBigIntColumnValue) Clone

func (n *NilBigIntColumnValue) Clone() ColumnValue

Clone - Clone the null value for a big integer column

func (NilBigIntColumnValue) IsNil

func (n NilBigIntColumnValue) IsNil() bool

IsNil: Whether it is null

func (NilBigIntColumnValue) String

func (n NilBigIntColumnValue) String() string

String: Printing display

func (*NilBigIntColumnValue) Type

func (n *NilBigIntColumnValue) Type() ColumnType

Type - Return the type of the column

type NilBoolColumnValue

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

NilBoolColumnValue represents an empty Boolean column value

func (NilBoolColumnValue) AsBigInt

func (n NilBoolColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Failed to convert to integer

func (NilBoolColumnValue) AsBool

func (n NilBoolColumnValue) AsBool() (bool, error)

AsBool: Failed to convert to boolean

func (NilBoolColumnValue) AsBytes

func (n NilBoolColumnValue) AsBytes() ([]byte, error)

AsBytes: Failed to convert to byte stream

func (NilBoolColumnValue) AsDecimal

func (n NilBoolColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Failed to convert to high-precision real number

func (NilBoolColumnValue) AsString

func (n NilBoolColumnValue) AsString() (string, error)

AsString: Failed to convert to string

func (NilBoolColumnValue) AsTime

func (n NilBoolColumnValue) AsTime() (time.Time, error)

AsTime: Failed to convert to time

func (*NilBoolColumnValue) Clone

func (n *NilBoolColumnValue) Clone() ColumnValue

Clone clones an empty Boolean column value

func (NilBoolColumnValue) IsNil

func (n NilBoolColumnValue) IsNil() bool

IsNil: Whether it is null

func (NilBoolColumnValue) String

func (n NilBoolColumnValue) String() string

String: Printing display

func (*NilBoolColumnValue) Type

func (n *NilBoolColumnValue) Type() ColumnType

Type returns the type of the column

type NilBytesColumnValue

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

NilBytesColumnValue - Null byte stream column value

func (NilBytesColumnValue) AsBigInt

func (n NilBytesColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Failed to convert to integer

func (NilBytesColumnValue) AsBool

func (n NilBytesColumnValue) AsBool() (bool, error)

AsBool: Failed to convert to boolean

func (NilBytesColumnValue) AsBytes

func (n NilBytesColumnValue) AsBytes() ([]byte, error)

AsBytes: Failed to convert to byte stream

func (NilBytesColumnValue) AsDecimal

func (n NilBytesColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Failed to convert to high-precision real number

func (NilBytesColumnValue) AsString

func (n NilBytesColumnValue) AsString() (string, error)

AsString: Failed to convert to string

func (NilBytesColumnValue) AsTime

func (n NilBytesColumnValue) AsTime() (time.Time, error)

AsTime: Failed to convert to time

func (*NilBytesColumnValue) Clone

func (n *NilBytesColumnValue) Clone() ColumnValue

Clone - Clone the null byte stream column value

func (NilBytesColumnValue) IsNil

func (n NilBytesColumnValue) IsNil() bool

IsNil: Whether it is null

func (NilBytesColumnValue) String

func (n NilBytesColumnValue) String() string

String: Printing display

func (*NilBytesColumnValue) Type

func (n *NilBytesColumnValue) Type() ColumnType

Type - Return the column type

type NilDecimalColumnValue

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

NilDecimalColumnValue represents a null value for a high-precision decimal column.

func (NilDecimalColumnValue) AsBigInt

func (n NilDecimalColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Failed to convert to integer

func (NilDecimalColumnValue) AsBool

func (n NilDecimalColumnValue) AsBool() (bool, error)

AsBool: Failed to convert to boolean

func (NilDecimalColumnValue) AsBytes

func (n NilDecimalColumnValue) AsBytes() ([]byte, error)

AsBytes: Failed to convert to byte stream

func (NilDecimalColumnValue) AsDecimal

func (n NilDecimalColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Failed to convert to high-precision real number

func (NilDecimalColumnValue) AsString

func (n NilDecimalColumnValue) AsString() (string, error)

AsString: Failed to convert to string

func (NilDecimalColumnValue) AsTime

func (n NilDecimalColumnValue) AsTime() (time.Time, error)

AsTime: Failed to convert to time

func (*NilDecimalColumnValue) Clone

Clone creates a copy (clone) of a high-precision decimal column value.

func (NilDecimalColumnValue) IsNil

func (n NilDecimalColumnValue) IsNil() bool

IsNil: Whether it is null

func (NilDecimalColumnValue) String

func (n NilDecimalColumnValue) String() string

String: Printing display

func (*NilDecimalColumnValue) Type

Type represents the type of the column.

type NilStringColumnValue

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

NilStringColumnValue - Null value for a string column

func (NilStringColumnValue) AsBigInt

func (n NilStringColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Failed to convert to integer

func (NilStringColumnValue) AsBool

func (n NilStringColumnValue) AsBool() (bool, error)

AsBool: Failed to convert to boolean

func (NilStringColumnValue) AsBytes

func (n NilStringColumnValue) AsBytes() ([]byte, error)

AsBytes: Failed to convert to byte stream

func (NilStringColumnValue) AsDecimal

func (n NilStringColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Failed to convert to high-precision real number

func (NilStringColumnValue) AsString

func (n NilStringColumnValue) AsString() (string, error)

AsString: Failed to convert to string

func (NilStringColumnValue) AsTime

func (n NilStringColumnValue) AsTime() (time.Time, error)

AsTime: Failed to convert to time

func (*NilStringColumnValue) Clone

func (n *NilStringColumnValue) Clone() ColumnValue

Clone - Clone the null string value

func (NilStringColumnValue) IsNil

func (n NilStringColumnValue) IsNil() bool

IsNil: Whether it is null

func (NilStringColumnValue) String

func (n NilStringColumnValue) String() string

String: Printing display

func (*NilStringColumnValue) Type

func (n *NilStringColumnValue) Type() ColumnType

Type - Column type

type NilTimeColumnValue

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

NilTimeColumnValue represents an empty time column value

func (NilTimeColumnValue) AsBigInt

func (n NilTimeColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Failed to convert to integer

func (NilTimeColumnValue) AsBool

func (n NilTimeColumnValue) AsBool() (bool, error)

AsBool: Failed to convert to boolean

func (NilTimeColumnValue) AsBytes

func (n NilTimeColumnValue) AsBytes() ([]byte, error)

AsBytes: Failed to convert to byte stream

func (NilTimeColumnValue) AsDecimal

func (n NilTimeColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Failed to convert to high-precision real number

func (NilTimeColumnValue) AsString

func (n NilTimeColumnValue) AsString() (string, error)

AsString: Failed to convert to string

func (NilTimeColumnValue) AsTime

func (n NilTimeColumnValue) AsTime() (time.Time, error)

AsTime: Failed to convert to time

func (*NilTimeColumnValue) Clone

func (n *NilTimeColumnValue) Clone() ColumnValue

Clone clones an empty time column value

func (NilTimeColumnValue) IsNil

func (n NilTimeColumnValue) IsNil() bool

IsNil: Whether it is null

func (NilTimeColumnValue) String

func (n NilTimeColumnValue) String() string

String: Printing display

func (*NilTimeColumnValue) Type

func (n *NilTimeColumnValue) Type() ColumnType

Type returns the type of the column

type Number

type Number interface {
	Bool() (bool, error)
	String() string
}

Number - Numeric value

type NumberConverter

type NumberConverter interface {
	ConvertBigIntFromInt(i int64) (num BigIntNumber)
	ConvertDecimalFromFloat(f float64) (num DecimalNumber)
	ConvertBigInt(s string) (num BigIntNumber, err error)
	ConvertDecimal(s string) (num DecimalNumber, err error)
}

NumberConverter - Number converter

type OldConverter

type OldConverter struct{}

OldConverter - Unchecked conversion

func (*OldConverter) ConvertBigInt

func (c *OldConverter) ConvertBigInt(s string) (num BigIntNumber, err error)

ConvertBigInt - Convert string to integer

func (*OldConverter) ConvertBigIntFromInt

func (c *OldConverter) ConvertBigIntFromInt(i int64) (num BigIntNumber)

ConvertBigIntFromInt - Convert to decimal from integer

func (*OldConverter) ConvertDecimal

func (c *OldConverter) ConvertDecimal(s string) (num DecimalNumber, err error)

ConvertDecimal - Convert string to decimal

func (*OldConverter) ConvertDecimalFromFloat

func (c *OldConverter) ConvertDecimalFromFloat(f float64) (num DecimalNumber)

ConvertDecimalFromFloat - Convert to decimal from floating-point number

type Record

type Record interface {
	fmt.Stringer

	Add(Column) error                      // AddColumn adds a new column to the record.
	GetByIndex(i int) (Column, error)      // GetColumnByIndex gets the column at index i.
	GetByName(name string) (Column, error) // GetColumnByName gets the column with the specified name.
	Set(i int, c Column) error             // SetColumnByIndex sets the value of the column at index i.
	Put(c Column) error                    // SetColumn sets the value of the specified column.
	ColumnNumber() int                     // GetColumnCount returns the number of columns in the record.
	ByteSize() int64                       // ByteSize returns the size of the record in bytes.
	MemorySize() int64                     // MemorySize returns the size of the record in memory.
}

Record represents a record in a dataset.

func GetTerminateRecord

func GetTerminateRecord() Record

GetTerminateRecord gets the termination record.

type RecordChan

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

RecordChan: Record channel. Fixes memory overflow issues.

func NewRecordChan

func NewRecordChan(ctx context.Context) *RecordChan

NewRecordChan: Create a new record channel.

func NewRecordChanBuffer

func NewRecordChanBuffer(ctx context.Context, n int) *RecordChan

NewRecordChanBuffer: Create a new record channel with a capacity of n.

func (*RecordChan) Buffered

func (c *RecordChan) Buffered() int

Buffered: Number of elements currently buffered in the record channel.

func (*RecordChan) Close

func (c *RecordChan) Close()

Close: Close the channel.

func (*RecordChan) PopFront

func (c *RecordChan) PopFront() (r Record, ok bool)

PopFront: Remove and return the record at the front of the channel, and indicate whether there are more values remaining.

func (*RecordChan) PopFrontAll

func (c *RecordChan) PopFrontAll(onRecord func(Record) error) error

PopFrontAll: Remove and return all records from the front of the channel using the onRecord function.

func (*RecordChan) PushBack

func (c *RecordChan) PushBack(r Record) int

PushBack: Append a record r to the end of the channel and return the current size of the queue.

func (*RecordChan) PushBackAll

func (c *RecordChan) PushBackAll(fetchRecord func() (Record, error)) error

PushBackAll: Append multiple records obtained through the fetchRecord function to the end of the channel.

type SetError

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

SetError: Sets an error

func NewSetError

func NewSetError(i interface{}, other ColumnType, err error) *SetError

NewSetError: Generates a setting error by setting the value i to the specified other type with the error err

func (*SetError) Error

func (e *SetError) Error() string

func (*SetError) Unwrap

func (e *SetError) Unwrap() error

type StringColumnValue

type StringColumnValue struct {
	TimeEncoder
	// contains filtered or unexported fields
}

StringColumnValue - Value for a string column. Note: Decimal 123.0 (val:1230, exp:-1) is not equivalent to 123 (val:123, exp:0)

func (*StringColumnValue) AsBigInt

func (s *StringColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt - Convert to a big integer. Floating-point numbers and scientific notation strings will be rounded. Non-numeric values will throw an error. E.g., 123.67 is converted to 123, and 123.12 is converted to 123.

func (*StringColumnValue) AsBool

func (s *StringColumnValue) AsBool() (v bool, err error)

AsBool - Convert 1, t, T, TRUE, true, True to true Convert 0, f, F, FALSE, false, False to false. If none of the above, an error is thrown.

func (*StringColumnValue) AsBytes

func (s *StringColumnValue) AsBytes() ([]byte, error)

AsBytes - Convert to a byte stream

func (*StringColumnValue) AsDecimal

func (s *StringColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal - Convert to a decimal. Floating-point numbers and scientific notation strings can be converted. Non-numeric values will throw an error.

func (*StringColumnValue) AsString

func (s *StringColumnValue) AsString() (string, error)

AsString - Convert to a string

func (*StringColumnValue) AsTime

func (s *StringColumnValue) AsTime() (t time.Time, err error)

AsTime - Convert to a time based on the time encoder. If the format does not match the time encoder, an error is thrown.

func (*StringColumnValue) Clone

func (s *StringColumnValue) Clone() ColumnValue

Clone - Clone the string column value

func (*StringColumnValue) Cmp

func (s *StringColumnValue) Cmp(right ColumnValue) (int, error)

Cmp - Return 1 for greater than, 0 for equal, -1 for less than

func (*StringColumnValue) IsNil

func (n *StringColumnValue) IsNil() bool

IsNil: Whether it is null

func (*StringColumnValue) String

func (s *StringColumnValue) String() string

func (*StringColumnValue) Type

func (s *StringColumnValue) Type() ColumnType

Type - Column type

type StringTimeDecoder

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

StringTimeDecoder - String time decoder

func (*StringTimeDecoder) Layout added in v0.1.1

func (d *StringTimeDecoder) Layout() string

Layout - Time format

func (*StringTimeDecoder) TimeDecode

func (d *StringTimeDecoder) TimeDecode(t time.Time) (interface{}, error)

TimeDecode - Decode a string time based on the layout of the go time format into a string

type StringTimeEncoder

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

StringTimeEncoder - String time encoder

func (*StringTimeEncoder) TimeEncode

func (e *StringTimeEncoder) TimeEncode(i interface{}) (time.Time, error)

TimeEncode - Encode to time. If 'i' is not a string or not in the layout format, an error will be reported.

type TerminateRecord

type TerminateRecord struct{}

TerminateRecord represents a termination record.

func (*TerminateRecord) Add

func (t *TerminateRecord) Add(Column) error

Add is an empty method placeholder.

func (*TerminateRecord) ByteSize

func (t *TerminateRecord) ByteSize() int64

ByteSize is an empty method placeholder.

func (*TerminateRecord) ColumnNumber

func (t *TerminateRecord) ColumnNumber() int

ColumnNumber is an empty method placeholder.

func (*TerminateRecord) GetByIndex

func (t *TerminateRecord) GetByIndex(i int) (Column, error)

GetByIndex is an empty method placeholder.

func (*TerminateRecord) GetByName

func (t *TerminateRecord) GetByName(name string) (Column, error)

GetByName is an empty method placeholder.

func (*TerminateRecord) MemorySize

func (t *TerminateRecord) MemorySize() int64

MemorySize is an empty method placeholder.

func (*TerminateRecord) Put

func (t *TerminateRecord) Put(c Column) error

Put is an empty method placeholder.

func (*TerminateRecord) Set

func (t *TerminateRecord) Set(i int, c Column) error

Set is an empty method placeholder.

func (*TerminateRecord) String

func (t *TerminateRecord) String() string

String is an empty method placeholder.

type TimeColumnValue

type TimeColumnValue struct {
	TimeDecoder // Time decoder
	// contains filtered or unexported fields
}

TimeColumnValue represents a time column value

func (*TimeColumnValue) AsBigInt

func (t *TimeColumnValue) AsBigInt() (BigIntNumber, error)

AsBigInt: Cannot convert to a big integer

func (*TimeColumnValue) AsBool

func (t *TimeColumnValue) AsBool() (bool, error)

AsBool: Cannot convert to a boolean value

func (*TimeColumnValue) AsBytes

func (t *TimeColumnValue) AsBytes() (b []byte, err error)

AsBytes: Converts to a byte stream

func (*TimeColumnValue) AsDecimal

func (t *TimeColumnValue) AsDecimal() (DecimalNumber, error)

AsDecimal: Cannot convert to a high-precision decimal number

func (*TimeColumnValue) AsString

func (t *TimeColumnValue) AsString() (s string, err error)

AsString: Converts to a string

func (*TimeColumnValue) AsTime

func (t *TimeColumnValue) AsTime() (time.Time, error)

AsTime: Converts to a time value

func (*TimeColumnValue) Clone

func (t *TimeColumnValue) Clone() ColumnValue

Clone clones a time column value

func (*TimeColumnValue) Cmp

func (t *TimeColumnValue) Cmp(right ColumnValue) (int, error)

Cmp: Returns 1 for greater than, 0 for equal, and -1 for less than

func (*TimeColumnValue) IsNil

func (n *TimeColumnValue) IsNil() bool

IsNil: Whether it is null

func (*TimeColumnValue) String

func (t *TimeColumnValue) String() string

func (*TimeColumnValue) Type

func (t *TimeColumnValue) Type() ColumnType

Type returns the type of the column

type TimeDecoder

type TimeDecoder interface {
	TimeDecode(t time.Time) (interface{}, error)
	Layout() string
}

TimeDecoder - Time decoder

func NewStringTimeDecoder

func NewStringTimeDecoder(layout string) TimeDecoder

NewStringTimeDecoder - A string time decoder based on the layout of the go time format

type TimeEncoder

type TimeEncoder interface {
	TimeEncode(i interface{}) (time.Time, error)
}

TimeEncoder - Time encoder

func NewStringTimeEncoder

func NewStringTimeEncoder(layout string) TimeEncoder

NewStringTimeEncoder - A string time encoder based on the layout of the go time format

type TransformError

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

TransformError: Conversion error

func NewTransformError

func NewTransformError(msg string, err error) *TransformError

NewTransformError: Creates a conversion error based on the message msg and error err

func NewTransformErrorFormColumnTypes

func NewTransformErrorFormColumnTypes(one, other ColumnType, err error) *TransformError

NewTransformErrorFromColumnTypes: Generates a conversion error from the error err when converting from type one to type other

func NewTransformErrorFormString

func NewTransformErrorFormString(one, other string, err error) *TransformError

NewTransformErrorFromString: Generates a conversion error from the error err when converting from one to other

func (*TransformError) Error

func (e *TransformError) Error() string

func (*TransformError) Unwrap

func (e *TransformError) Unwrap() error

Jump to

Keyboard shortcuts

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