model

package
v1.30.24 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MinInt8 is the minimum int8 of type uint8.
	MinInt8 uint8 = 128
	// MinInt32 is minimum int32 of type uint32.
	MinInt32 uint32 = 2147483648
)

Variables

View Source
var (
	// Null value for DtString, DtSymbol.
	NullString = ""
	// Null value for DtAny.
	NullAny = nullDataForm
	// Null value for DtUUID.
	NullUUID = "00000000-0000-0000-0000-000000000000"
	// Null value for DtInt128.
	NullInt128 = "00000000000000000000000000000000"
	// Null value for DtIP.
	NullIP = "0.0.0.0"
	// Null value for DTShort.
	NullShort = int16(math.MinInt16)
	// Null value for DtDate,DtDateHour,DtDatetime,DtMinute,DtNanoTime,DtNanoTimestamp,DtSecond,DtMonth,DtTimestamp.
	NullTime = emptyTime
	// Null value for DtLong.
	NullLong = int64(math.MinInt64)
	// Null value for DtDuration.
	NullDuration = ""
	// Null value for DtFloat.
	NullFloat = float32(-math.MaxFloat32)
	// Null value for DtDouble.
	NullDouble = -math.MaxFloat64
	// Null value for DtDecimal32.
	NullDecimal32Value = float64(NullInt)

	// Null value for DtDecimal64.
	NullDecimal64Value = float64(NullLong)

	// Null value for DtDecimal128.
	NullDecimal128Value = "-170141183460469231731687303715884105728"

	// Null value for DtInt.
	NullInt = int32(math.MinInt32)
	// Null value for DtComplex.
	NullComplex = [2]float64{-math.MaxFloat64, -math.MaxFloat64}
	// Null value for DtPoint.
	NullPoint = [2]float64{-math.MaxFloat64, -math.MaxFloat64}
	// Null value for DtBlob.
	NullBlob = []byte{}
	// Null value for DtBool.
	NullBool = MinInt8
	// Null value for DtChar.
	NullChar = MinInt8
	// Null value for DtCompress.
	NullCompress = MinInt8
)
View Source
var ChartType = map[string]string{
	"0": "CT_AREA",
	"1": "CT_BAR",
	"2": "CT_COLUMN",
	"3": "CT_HISTOGRAM",
	"4": "CT_LINE",
	"5": "CT_PIE",
	"6": "CT_SCATTER",
	"7": "CT_TREND",
	"8": "CT_KLINE",
	"9": "CT_STACK",
}

ChartType is a map storing the mapping relationship.

Functions

func GetDataFormString

func GetDataFormString(t DataFormByte) string

GetDataFormString returns the data form in the string format based on its byte format.

func GetDataTypeString

func GetDataTypeString(t DataTypeByte) string

GetDataTypeString returns the data type in the string format based on its byte format.

Types

type ArrayVector

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

ArrayVector is an element type of Vector.

func NewArrayVector

func NewArrayVector(vl []*Vector) []*ArrayVector

NewArrayVector returns an object of ArrayVector with specified data. You can initialize the data by using NewDataTypeList or NewDataTypeListWithRaw.

type Category

type Category struct {
	DataForm DataFormByte
	DataType DataTypeByte
}

Category stores the DataFormByte and the DataTypeByte of a DataForm.

type CategoryString

type CategoryString string

CategoryString is the string type of Category.

const (
	// LOGICAL is the string type of category LOGICAL.
	LOGICAL CategoryString = "LOGICAL"
	// NOTHING is the string type of category NOTHING.
	NOTHING CategoryString = "NOTHING"
	// INTEGRAL is the string type of category INTEGRAL.
	INTEGRAL CategoryString = "INTEGRAL"
	// FLOATING is the string type of category FLOATING.
	FLOATING CategoryString = "FLOATING"
	// TEMPORAL is the string type of category TEMPORAL.
	TEMPORAL CategoryString = "TEMPORAL"
	// LITERAL is the string type of category LITERAL.
	LITERAL CategoryString = "LITERAL"
	// SYSTEM is the string type of category SYSTEM.
	SYSTEM CategoryString = "SYSTEM"
	// MIXED is the string type of category MIXED.
	MIXED CategoryString = "MIXED"
	// BINARY is the string type of category BINARY.
	BINARY CategoryString = "BINARY"
	// ARRAY is the string type of category ARRAY.
	ARRAY CategoryString = "ARRAY"
	// DECIMAL is the string type of category ARRAY.
	DENARY CategoryString = "DENARY"
)

func GetCategory

func GetCategory(d DataTypeByte) CategoryString

GetCategory returns the category string according to the dt.

type Chart

type Chart struct {
	Title     DataForm
	ChartType *Scalar
	Stacking  *Scalar
	Data      *Matrix
	Extras    *Dictionary
	// contains filtered or unexported fields
}

Chart is a DataForm.

func NewChart

func NewChart(in map[string]DataForm) *Chart

NewChart returns an object of chart according to in.

func (*Chart) GetChartType

func (ch *Chart) GetChartType() string

GetChartType returns the string type of the ChartType.

func (*Chart) GetDataForm

func (ch *Chart) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Chart) GetDataFormString added in v1.30.21

func (ch *Chart) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Chart) GetDataType

func (ch *Chart) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Chart) GetDataTypeString

func (ch *Chart) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Chart) GetTitle

func (ch *Chart) GetTitle() string

GetTitle returns the string type of the title.

func (*Chart) GetXAxisName

func (ch *Chart) GetXAxisName() string

GetXAxisName returns the XAxisName of the title.

func (*Chart) GetYAxisName

func (ch *Chart) GetYAxisName() string

GetYAxisName returns the YAxisName of the title.

func (*Chart) Render

func (ch *Chart) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Chart) Rows

func (ch *Chart) Rows() int

Rows returns the row num of the DataForm.

func (*Chart) String

func (ch *Chart) String() string

type DataForm

type DataForm interface {
	// Render serializes the DataForm with bo and input it into w
	Render(w *protocol.Writer, bo protocol.ByteOrder) error

	// GetDataForm returns the byte type of the DataForm
	GetDataForm() DataFormByte
	// GetDataFormString returns the string format of the DataForm
	GetDataFormString() string
	// GetDataType returns the byte type of the DataType
	GetDataType() DataTypeByte
	// GetDataTypeString returns the string format of the DataType
	GetDataTypeString() string

	// String returns the string of the DataForm
	String() string
	// Rows returns the row num of the DataForm
	Rows() int
}

DataForm interface declares functions to handle DataForm data.

func CastDateTime

func CastDateTime(src DataForm, d DataTypeByte) (DataForm, error)

CastDateTime casts src to other DataForm according to the dt.

func ParseDataForm

func ParseDataForm(r protocol.Reader, bo protocol.ByteOrder) (DataForm, error)

ParseDataForm parses the raw bytes in r with bo and return a DataForm object.

type DataFormByte

type DataFormByte byte

DataFormByte is the byte type of DataForm.

const (
	// DfScalar is the byte type of Scalar.
	DfScalar DataFormByte = iota
	// DfVector is the byte type of Vector.
	DfVector
	// DfPair is the byte type of Pair.
	DfPair
	// DfMatrix is the byte type of Matrix.
	DfMatrix
	// DfSet is the byte type of Set.
	DfSet
	// DfDictionary is the byte type of Dictionary.
	DfDictionary
	// DfTable is the byte type of Table.
	DfTable
	// DfChart is the byte type of Chart.
	DfChart
	// DfChunk is the byte type of Chunk.
	DfChunk
)

type DataType

type DataType interface {
	// DataType returns the byte type of DataType
	DataType() DataTypeByte
	// Render serializes the DataType into w with the bo
	Render(w *protocol.Writer, bo protocol.ByteOrder) error

	// String returns the string format of the DataType
	String() string
	// Bool returns the bool value of the DataType.
	// Only when th DataType is DtBool, you can call the func successful
	Bool() (bool, error)

	// Value returns an interface value of DataType, you can assert it to get the real value
	Value() interface{}

	// HashBucket calculates the hashcode with the value of DataType and buckets
	HashBucket(buckets int) int

	// IsNull checks whether the value of DataType is null
	IsNull() bool
	// SetNull sets the value of DataType to null
	SetNull()
	// contains filtered or unexported methods
}

DataType interface declares functions to handle DataType data.

func NewDataType

func NewDataType(datatype DataTypeByte, arg interface{}) (DataType, error)

NewDataType returns an object of DataType according to datatype and arg. You should input in according to the datatype. See README.md for more details.

func ParseDataType added in v1.30.22

func ParseDataType(r protocol.Reader, t DataTypeByte, bo protocol.ByteOrder) (DataType, error)

ParseDataType parses raw data to DataType

type DataTypeByte

type DataTypeByte byte

DataTypeByte is the byte type of DataType.

const (
	// DtVoid is the byte type of Void.
	DtVoid DataTypeByte = iota
	// DtBool is the byte type of Bool.
	DtBool
	// DtChar is the byte type of Char.
	DtChar
	// DtShort is the byte type of Short.
	DtShort
	// DtInt is the byte type of Int.
	DtInt
	// DtLong is the byte type of Long.
	DtLong
	// DtDate is the byte type of Date.
	DtDate
	// DtMonth is the byte type of Month.
	DtMonth
	// DtTime is the byte type of Time.
	DtTime
	// DtMinute is the byte type of Minute.
	DtMinute
	// DtSecond is the byte type of Second.
	DtSecond
	// DtDatetime is the byte type of Datetime.
	DtDatetime
	// DtTimestamp is the byte type of Timestamp.
	DtTimestamp
	// DtNanoTime is the byte type of NanoTime.
	DtNanoTime
	// DtNanoTimestamp is the byte type of NanoTimestamp.
	DtNanoTimestamp
	// DtFloat is the byte type of Float.
	DtFloat
	// DtDouble is the byte type of Double.
	DtDouble
	// DtSymbol is the byte type of Symbol.
	DtSymbol
	// DtString is the byte type of String.
	DtString
	// DtUUID is the byte type of UUID.
	DtUUID
	// DtFunction is the byte type of Function.
	DtFunction
	// DtHandle is the byte type of Handle.
	DtHandle
	// DtCode is the byte type of Code.
	DtCode
	// DtDatasource is the byte type of Datasource.
	DtDatasource
	// DtResource is the byte type of Resource.
	DtResource
	// DtAny is the byte type of Any.
	DtAny
	// DtCompress is the byte type of Compress.
	DtCompress
	// DtDictionary is the byte type of Dictionary.
	DtDictionary
	// DtDateHour is the byte type of DateHour.
	DtDateHour
	// DtDateMinute is the byte type of DateMinute.
	DtDateMinute
	// DtIP is the byte type of IP.
	DtIP
	// DtInt128 is the byte type of Int128.
	DtInt128
	// DtBlob is the byte type of Blob.
	DtBlob

	// DtComplex is the byte type of Complex.
	DtComplex
	// DtPoint is the byte type of Point.
	DtPoint
	// DtDuration is the byte type of Duration.
	DtDuration
	// DtDecimal32 is the byte type of Decimal32.
	DtDecimal32
	// DtDecimal64 is the byte type of Decimal64.
	DtDecimal64
	// DtDecimal128 is the byte type of Decimal128.
	DtDecimal128
	// DtObject is the byte type of Object.
	DtObject
)

type DataTypeExtend

type DataTypeExtend struct {
	BaseID   uint32
	BaseSize uint32

	Base DataTypeList
}

DataTypeExtend is only valid for Symbol DataType.

type DataTypeList

type DataTypeList interface {
	// DataType returns the byte type of the DataTypeList
	DataType() DataTypeByte
	// Render serializes the DataForm with bo and input it into w
	Render(w *protocol.Writer, bo protocol.ByteOrder) error

	// Len returns the length of DataTypeList
	Len() int
	// Get returns a DataType value in DataTypeList according to the ind
	// which must be less than len(DataTypeList)
	Get(ind int) DataType
	// Set inserts dt into DataTypeList according to the ind
	// which must be less than or equal to len(DataTypeList).
	// If ind < len(DataTypeList), cover the original value in DataTypeList
	Set(ind int, t DataType) error
	// Deprecated.
	// Use SetWithRawData instead.
	SetWithRaw(ind int, arg interface{}) error
	// SetWithRaw inserts raw data into DataTypeList according to the ind
	// which must be less than or equal to len(DataTypeList).
	// If ind < len(DataTypeList), cover the original value in DataTypeList
	// Refer to README.md for the valid type of arg.
	SetWithRawData(ind int, arg interface{}) error
	// Append inserts a DataType value to the end of DataTypeList.
	// The type of d must be the same as DataTypeList's
	Append(t DataType) DataTypeList
	// Sub returns the len end-st of DataTypeList.
	// End must be larger than st,
	// but less than the len of DataTypeList.
	// St must be large than -1
	Sub(st, end int) DataTypeList
	// AsOf returns the index of the d in DataTypeList.
	// If d is not in DataTypeList, returns -1
	AsOf(d DataType) int

	// StringList returns the string array of Datatype list
	StringList() []string

	// Value returns the value of Datatype list
	Value() []interface{}

	// IsNull checks whether the value of DataType is null based on the index
	IsNull(ind int) bool
	// SetNull sets the value of DataType with index ind to null
	SetNull(ind int)
	// GetSubList instantiates a DataTypeList with the values in indexes which is a list of index.
	// Value in indexes should be less than the length of DataTypeList
	GetSubList(indexes []int) DataTypeList
	// ElementValue returns the value of Datatype list element according to the ind
	ElementValue(ind int) interface{}
	// ElementString returns the string value of Datatype list element according to the ind
	ElementString(ind int) string
	// contains filtered or unexported methods
}

DataTypeList interface declares functions to handle DataType list.

func NewDataTypeList

func NewDataTypeList(datatype DataTypeByte, data []DataType) DataTypeList

NewDataTypeList instantiates a DataTypeList according to the datatype and data. The DataType byte of element in data should be equal to datatype.

func NewDataTypeListFromRawData added in v1.30.20

func NewDataTypeListFromRawData(datatype DataTypeByte, args interface{}) (DataTypeList, error)

NewDataTypeListFromRawData instantiates a DataTypeList with specified datatype and args. Refer to README_CN.md for the valid type of args.

func NewDataTypeListWithRaw

func NewDataTypeListWithRaw(datatype DataTypeByte, args interface{}) (DataTypeList, error)

Deprecated. Use NewDataTypeListFromRawData instead.

func NewEmptyDataTypeList

func NewEmptyDataTypeList(datatype DataTypeByte, size int) DataTypeList

NewEmptyDataTypeList instantiates an empty DataTypeList.

type Decimal128 added in v1.30.22

type Decimal128 struct {
	Scale int32
	Value string
}

func (*Decimal128) String added in v1.30.22

func (d *Decimal128) String() string

type Decimal128s added in v1.30.22

type Decimal128s struct {
	Scale int32
	Value []string
}

func (*Decimal128s) String added in v1.30.22

func (d *Decimal128s) String() string

type Decimal32 added in v1.30.20

type Decimal32 struct {
	Scale int32
	Value float64
}

func (*Decimal32) String added in v1.30.21

func (d *Decimal32) String() string

type Decimal32s added in v1.30.20

type Decimal32s struct {
	Scale int32
	Value []float64
}

func (*Decimal32s) String added in v1.30.21

func (d *Decimal32s) String() string

type Decimal64 added in v1.30.20

type Decimal64 struct {
	Scale int32
	Value float64
}

func (*Decimal64) String added in v1.30.21

func (d *Decimal64) String() string

type Decimal64s added in v1.30.20

type Decimal64s struct {
	Scale int32
	Value []float64
}

func (*Decimal64s) String added in v1.30.21

func (d *Decimal64s) String() string

type Dictionary

type Dictionary struct {
	Keys   *Vector
	Values *Vector
	// contains filtered or unexported fields
}

Dictionary is a DataForm. Refer to https://www.dolphindb.com/help/DataTypesandStructures/DataForms/Dictionary.html for more details.

func NewDictionary

func NewDictionary(keys, val *Vector) *Dictionary

NewDictionary returns an object of Dictionary according to keys and values. You can instantiate the Vector object by NewVector.

func (*Dictionary) Get

func (dict *Dictionary) Get(key string) (DataType, error)

Get returns the value in dictionary based on the specified key.

func (*Dictionary) GetDataForm

func (dict *Dictionary) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Dictionary) GetDataFormString added in v1.30.21

func (dict *Dictionary) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Dictionary) GetDataType

func (dict *Dictionary) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Dictionary) GetDataTypeString

func (dict *Dictionary) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Dictionary) KeyStrings

func (dict *Dictionary) KeyStrings() []string

KeyStrings returns the string list of dictionary keys.

func (*Dictionary) Render

func (dict *Dictionary) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Dictionary) Rows

func (dict *Dictionary) Rows() int

Rows returns the row num of the DataForm.

func (*Dictionary) Set

func (dict *Dictionary) Set(key, value DataType)

Set sets the key and value of a dictionary. If a key already exists, update the value, otherwise append the key-value pair.

func (*Dictionary) String

func (dict *Dictionary) String() string

type Matrix

type Matrix struct {
	RowLabels    *Vector
	ColumnLabels *Vector
	Data         *Vector
	// contains filtered or unexported fields
}

Matrix is a DataForm. Refer to https://www.dolphindb.cn/cn/help/130/DataTypesandStructures/DataForms/Matrix.html for details.

func NewMatrix

func NewMatrix(data, rowLabels, columnLabels *Vector) *Matrix

NewMatrix returns an object of matrix according to data, rowLabels and columnLabels. RowLabels and columnLabels are optional. You can instantiate the Vector object by using NewVector.

func (*Matrix) Get

func (mtx *Matrix) Get(row, col int) DataType

Get gets DataType from matrix.

func (*Matrix) GetDataForm

func (mtx *Matrix) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Matrix) GetDataFormString added in v1.30.21

func (mtx *Matrix) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Matrix) GetDataType

func (mtx *Matrix) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Matrix) GetDataTypeString

func (mtx *Matrix) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Matrix) IsNull

func (mtx *Matrix) IsNull(row, col int) bool

IsNull checks whether the value located by row and col is null.

func (*Matrix) Render

func (mtx *Matrix) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Matrix) Rows

func (mtx *Matrix) Rows() int

Rows returns the row num of the DataForm.

func (*Matrix) Set

func (mtx *Matrix) Set(row, col int, d DataType) error

Set sets DataType for mtx according to the row and col. index = col*row + row. If index >= len(mtx.Data), return an error. If index < len(mtx.Data), cover the original value.

func (*Matrix) SetNull

func (mtx *Matrix) SetNull(row, col int)

SetNull set the DataType in Matrix to null according to the row and col.

func (*Matrix) String

func (mtx *Matrix) String() string

type Pair

type Pair struct {
	Vector *Vector
	// contains filtered or unexported fields
}

Pair is a DataForm. Refer to https://www.dolphindb.cn/cn/help/130/DataTypesandStructures/DataForms/Pair.html for details.

func NewPair

func NewPair(v *Vector) *Pair

NewPair returns an object of pair with specified vector v. You can instantiate it by NewVector.

func (*Pair) GetDataForm

func (p *Pair) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Pair) GetDataFormString added in v1.30.21

func (p *Pair) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Pair) GetDataType

func (p *Pair) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Pair) GetDataTypeString

func (p *Pair) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Pair) Render

func (p *Pair) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Pair) Rows

func (p *Pair) Rows() int

Rows returns the row num of the DataForm.

func (*Pair) String

func (p *Pair) String() string

type Scalar

type Scalar struct {
	DataType
	// contains filtered or unexported fields
}

Scalar is a DataForm. Refer to https://www.dolphindb.cn/cn/help/130/DataTypesandStructures/DataForms/Scalar.html for more details.

func NewScalar

func NewScalar(d DataType) *Scalar

NewScalar returns an object of scalar with d. You can instantiate the d by NewDataType.

func (*Scalar) GetDataForm

func (s *Scalar) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Scalar) GetDataFormString added in v1.30.21

func (s *Scalar) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Scalar) GetDataType

func (s *Scalar) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Scalar) GetDataTypeString

func (s *Scalar) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Scalar) IsNull

func (s *Scalar) IsNull() bool

IsNull checks whether the value of scalar is null.

func (*Scalar) Render

func (s *Scalar) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Scalar) Rows

func (s *Scalar) Rows() int

Rows returns the row num of the DataForm.

func (*Scalar) SetNull

func (s *Scalar) SetNull()

SetNull sets the value of scalar to null.

func (*Scalar) String

func (s *Scalar) String() string

type Set

type Set struct {
	Vector *Vector
	// contains filtered or unexported fields
}

Set is a DataForm. Refer to https://www.dolphindb.cn/cn/help/130/DataTypesandStructures/DataForms/Set.html for more details.

func NewSet

func NewSet(v *Vector) *Set

NewSet returns an object of Set based on vector v. You can instantiate v by NewVector.

func (*Set) GetDataForm

func (s *Set) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Set) GetDataFormString added in v1.30.21

func (s *Set) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Set) GetDataType

func (s *Set) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Set) GetDataTypeString

func (s *Set) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Set) Render

func (s *Set) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Set) Rows

func (s *Set) Rows() int

Rows returns the row num of the DataForm.

func (*Set) String

func (s *Set) String() string

type Table

type Table struct {
	ColNames []string
	// contains filtered or unexported fields
}

Table is a DataForm. Refer to https://www.dolphindb.cn/cn/help/130/DataTypesandStructures/DataForms/Table.html for more details.

func NewTable

func NewTable(colNames []string, colValues []*Vector) *Table

NewTable returns an object of Table with colNames and colValues. You can instantiate the vector object by NewVector.

func NewTableFromRawData added in v1.30.20

func NewTableFromRawData(colNames []string, colTypes []DataTypeByte, colValues []interface{}) (*Table, error)

NewTableFromRawData returns an object of Table with colNames, colTypes and colValues. The parameter colTypes determines the data types of colValues. Refer to README.md for more details.

func NewTableFromStruct added in v1.30.20

func NewTableFromStruct(obj interface{}) (tb *Table, err error)

NewTableFromStruct returns the table object according to the val which is a struct object with special tags. Refer to README.md for more details.

func (*Table) Columns

func (t *Table) Columns() int

Columns returns the column num of the DataForm.

func (*Table) GetColumnByIndex

func (t *Table) GetColumnByIndex(ind int) *Vector

GetColumnByIndex returns the column in table with the column index.

func (*Table) GetColumnByName

func (t *Table) GetColumnByName(colName string) *Vector

GetColumnByName returns the column in table with the column name.

func (*Table) GetColumnNames

func (t *Table) GetColumnNames() []string

GetColumnNames returns all column names of the table.

func (*Table) GetDataForm

func (t *Table) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Table) GetDataFormString added in v1.30.21

func (t *Table) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Table) GetDataType

func (t *Table) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Table) GetDataTypeString

func (t *Table) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Table) GetRowJSON added in v1.30.20

func (t *Table) GetRowJSON(ind int) string

GetRowJSON returns the string format of the row in the table according to the ind. ArrayVector does not support GetRowJSON.

func (*Table) GetSubtable

func (t *Table) GetSubtable(indexes []int) *Table

GetSubtable instantiates a table with the values in indexes. The specified indexes should be less than the number of columns.

func (*Table) Render

func (t *Table) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Table) Rows

func (t *Table) Rows() int

Rows returns the row num of the DataForm.

func (*Table) String

func (t *Table) String() string

String returns the string of the DataForm.

type Vector

type Vector struct {
	RowCount    uint32
	ColumnCount uint32

	// If the DataTypeByte of the Vector is less than 64, Data stores the values of the vector.
	// If the DataTypeByte of the Vector is greater than 64 and less than 128, Data is invalid.
	// If the DataTypeByte of the Vector is greater than 128, Data stores the indexs of the values and
	// the value are stored in the Base of Extend.
	// You can call GetDataType() to get the DataTypeByte of the Vector.
	Data DataTypeList
	// ArrayVector is a special form of data for DolphinDB. Unlike a regular vector,
	// each of its elements is an array with the same DataType, but the length can vary.
	// ArrayVector is only valid when the DataTypeByte of the Vector is greater than 64 and less than 128.
	// You can call GetDataType() to get the DataTypeByte of the Vector.
	ArrayVector []*ArrayVector
	// Extend is only valid when the DataTypeByte of the Vector is greater than 128.
	// The Base of the Extend stores the values of the vector.
	// You can call GetDataType() to get the DataTypeByte of the Vector.
	Extend *DataTypeExtend
	// contains filtered or unexported fields
}

Vector is a DataForm. Refer to https://www.dolphindb.cn/cn/help/130/DataTypesandStructures/DataForms/Vector/index.html for more details.

func NewVector

func NewVector(data DataTypeList) *Vector

NewVector returns an object of vector with specified data. You can instantiate the data by NewDataTypeList or NewDataTypeListWithRaw.

func NewVectorWithArrayVector

func NewVectorWithArrayVector(data []*ArrayVector) *Vector

NewVectorWithArrayVector returns an object of vector according to the data. You can instantiates the data by NewArrayVector.

func ParseArrayVector added in v1.30.23

func ParseArrayVector(r protocol.Reader, t DataTypeByte, bo protocol.ByteOrder) (*Vector, error)

func (*Vector) Append added in v1.30.22

func (vct *Vector) Append(value DataType) (err error)

Append appends the DataType to the vector. ArrayVector not support append value

func (*Vector) AppendVectorValue added in v1.30.23

func (vct *Vector) AppendVectorValue(data *Vector) (err error)

AppendVectorValue appends the vector to arrayVector.

func (*Vector) AsOf

func (vct *Vector) AsOf(d DataType) int

AsOf returns the index of the d in vct. ArrayVector does not support AsOf. If d is not in vct, returns -1.

func (*Vector) Combine

func (vct *Vector) Combine(in *Vector) (*Vector, error)

Combine combines two Vectors and returns a new one. ArrayVector does not support Combine.

func (*Vector) Get

func (vct *Vector) Get(ind int) DataType

Get gets DataType from vct. If ind exceeds the size of Vector, return nil. ArrayVector does not support Combine.

func (*Vector) GetDataForm

func (vct *Vector) GetDataForm() DataFormByte

GetDataForm returns the byte type of the DataForm.

func (*Vector) GetDataFormString added in v1.30.21

func (vct *Vector) GetDataFormString() string

GetDataFormString returns the string format of the DataForm.

func (*Vector) GetDataType

func (vct *Vector) GetDataType() DataTypeByte

GetDataType returns the byte type of the DataType.

func (*Vector) GetDataTypeString

func (vct *Vector) GetDataTypeString() string

GetDataTypeString returns the string format of the DataType.

func (*Vector) GetRawValue added in v1.30.21

func (vct *Vector) GetRawValue() []interface{}

GetRawValue returns an array of values of the elements in the Vector.

func (*Vector) GetSubvector

func (vct *Vector) GetSubvector(indexes []int) *Vector

GetSubvector instantiates a Vector with the values in indexes. The specified indexes should be less than the length of Vector.

func (*Vector) GetVectorValue

func (vct *Vector) GetVectorValue(ind int) *Vector

GetVectorValue returns the element of the ArrayVector based on the ind.

func (*Vector) HashBucket

func (vct *Vector) HashBucket(ind, bucket int) int

HashBucket calculates the hash with the bucket and the value whose index is ind in vct.

func (*Vector) IsNull

func (vct *Vector) IsNull(ind int) bool

IsNull checks whether the value of DataType in vector is null based on the index. ArrayVector does not support IsNull.

func (*Vector) Render

func (vct *Vector) Render(w *protocol.Writer, bo protocol.ByteOrder) error

Render serializes the DataForm with bo and input it into w.

func (*Vector) Rows

func (vct *Vector) Rows() int

Rows returns the row num of the DataForm.

func (*Vector) Set

func (vct *Vector) Set(ind int, d DataType) error

Set sets DataType of the vct with ind. ArrayVector does not support Set. If ind >= len(vct.Data), return an error, otherwise cover the original value.

func (*Vector) SetNull

func (vct *Vector) SetNull(ind int)

SetNull sets the value of DataType in vector to null based on ind. ArrayVector does not support SetNull.

func (*Vector) String

func (vct *Vector) String() string

String returns the string of the DataForm.

Jump to

Keyboard shortcuts

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