Documentation
¶
Overview ¶
Package types 提供所有数据类型的定义和转换工具。
本包包含:
- protobuf 生成的消息类型(来自 mts.proto)
- 类型转换工具函数
类型分类:
基础类型:Point, PointRow, FieldValue, FieldType gRPC 消息:WriteRequest, WriteResponse, QueryRangeRequest, etc. 配置类型:Config, MemTableConfig 元数据类型:MeasurementMeta, FieldDef
时间单位:
所有时间戳和时间间隔都使用纳秒(int64)。 转换辅助函数提供帮助从 time.Duration 转换。
Index ¶
- Constants
- Variables
- func AppendFieldData(dst []byte, fields map[string]*FieldValue) []byte
- func FieldDataSize(fields map[string]*FieldValue) int
- func InternalFieldsToMap(fields []InternalField) map[string]*FieldValue
- func RegisterMTSServer(s grpc.ServiceRegistrar, srv MTSServer)
- func ReleaseFieldData(data []byte)
- type AggFunction
- func (*AggFunction) Descriptor() ([]byte, []int)deprecated
- func (x *AggFunction) GetField() string
- func (x *AggFunction) GetFunction() string
- func (x *AggFunction) GetWindowNanos() int64
- func (*AggFunction) ProtoMessage()
- func (x *AggFunction) ProtoReflect() protoreflect.Message
- func (x *AggFunction) Reset()
- func (x *AggFunction) String() string
- type AggregateSpec
- type CompactionConfig
- func (*CompactionConfig) Descriptor() ([]byte, []int)deprecated
- func (x *CompactionConfig) GetCheckIntervalNanos() int64
- func (x *CompactionConfig) GetMaxCompactionBatch() int32
- func (x *CompactionConfig) GetMaxSstableCount() int32
- func (x *CompactionConfig) GetShardSizeLimit() int64
- func (x *CompactionConfig) GetTimeoutNanos() int64
- func (*CompactionConfig) ProtoMessage()
- func (x *CompactionConfig) ProtoReflect() protoreflect.Message
- func (x *CompactionConfig) Reset()
- func (x *CompactionConfig) String() string
- type CompressionAlgorithm
- func (CompressionAlgorithm) Descriptor() protoreflect.EnumDescriptor
- func (x CompressionAlgorithm) Enum() *CompressionAlgorithm
- func (CompressionAlgorithm) EnumDescriptor() ([]byte, []int)deprecated
- func (x CompressionAlgorithm) Number() protoreflect.EnumNumber
- func (x CompressionAlgorithm) String() string
- func (CompressionAlgorithm) Type() protoreflect.EnumType
- type Config
- func (*Config) Descriptor() ([]byte, []int)deprecated
- func (x *Config) GetCompactionCfg() *CompactionConfig
- func (x *Config) GetCompressionAlgorithm() CompressionAlgorithm
- func (x *Config) GetDataDir() string
- func (x *Config) GetMemTableCfg() *MemTableConfig
- func (x *Config) GetRetentionCheckIntervalNanos() int64
- func (x *Config) GetRetentionPeriodNanos() int64
- func (c *Config) GetShardDuration() time.Duration
- func (x *Config) GetShardDurationNanos() int64
- func (*Config) ProtoMessage()
- func (x *Config) ProtoReflect() protoreflect.Message
- func (x *Config) Reset()
- func (c *Config) SetShardDuration(d time.Duration)
- func (x *Config) String() string
- type CreateDatabaseRequest
- func (*CreateDatabaseRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateDatabaseRequest) GetDatabase() string
- func (x *CreateDatabaseRequest) GetDownsampleConfig() *DownsampleConfig
- func (x *CreateDatabaseRequest) GetRetentionPeriodNanos() int64
- func (*CreateDatabaseRequest) ProtoMessage()
- func (x *CreateDatabaseRequest) ProtoReflect() protoreflect.Message
- func (x *CreateDatabaseRequest) Reset()
- func (x *CreateDatabaseRequest) String() string
- type CreateDatabaseResponse
- func (*CreateDatabaseResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CreateDatabaseResponse) GetError() string
- func (x *CreateDatabaseResponse) GetSuccess() bool
- func (*CreateDatabaseResponse) ProtoMessage()
- func (x *CreateDatabaseResponse) ProtoReflect() protoreflect.Message
- func (x *CreateDatabaseResponse) Reset()
- func (x *CreateDatabaseResponse) String() string
- type CreateMeasurementRequest
- func (*CreateMeasurementRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateMeasurementRequest) GetDatabase() string
- func (x *CreateMeasurementRequest) GetMeasurement() string
- func (*CreateMeasurementRequest) ProtoMessage()
- func (x *CreateMeasurementRequest) ProtoReflect() protoreflect.Message
- func (x *CreateMeasurementRequest) Reset()
- func (x *CreateMeasurementRequest) String() string
- type CreateMeasurementResponse
- func (*CreateMeasurementResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CreateMeasurementResponse) GetError() string
- func (x *CreateMeasurementResponse) GetSuccess() bool
- func (*CreateMeasurementResponse) ProtoMessage()
- func (x *CreateMeasurementResponse) ProtoReflect() protoreflect.Message
- func (x *CreateMeasurementResponse) Reset()
- func (x *CreateMeasurementResponse) String() string
- type DownsampleConfig
- func (*DownsampleConfig) Descriptor() ([]byte, []int)deprecated
- func (x *DownsampleConfig) GetCheckIntervalNanos() int64
- func (x *DownsampleConfig) GetEnabled() bool
- func (x *DownsampleConfig) GetRules() []*DownsampleRule
- func (*DownsampleConfig) ProtoMessage()
- func (x *DownsampleConfig) ProtoReflect() protoreflect.Message
- func (x *DownsampleConfig) Reset()
- func (x *DownsampleConfig) String() string
- type DownsampleRule
- func (*DownsampleRule) Descriptor() ([]byte, []int)deprecated
- func (x *DownsampleRule) GetFunctions() []string
- func (x *DownsampleRule) GetRetentionNanos() int64
- func (x *DownsampleRule) GetWindowNanos() int64
- func (*DownsampleRule) ProtoMessage()
- func (x *DownsampleRule) ProtoReflect() protoreflect.Message
- func (x *DownsampleRule) Reset()
- func (x *DownsampleRule) String() string
- type DropDatabaseRequest
- func (*DropDatabaseRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DropDatabaseRequest) GetDatabase() string
- func (*DropDatabaseRequest) ProtoMessage()
- func (x *DropDatabaseRequest) ProtoReflect() protoreflect.Message
- func (x *DropDatabaseRequest) Reset()
- func (x *DropDatabaseRequest) String() string
- type DropDatabaseResponse
- func (*DropDatabaseResponse) Descriptor() ([]byte, []int)deprecated
- func (x *DropDatabaseResponse) GetError() string
- func (x *DropDatabaseResponse) GetSuccess() bool
- func (*DropDatabaseResponse) ProtoMessage()
- func (x *DropDatabaseResponse) ProtoReflect() protoreflect.Message
- func (x *DropDatabaseResponse) Reset()
- func (x *DropDatabaseResponse) String() string
- type DropMeasurementRequest
- func (*DropMeasurementRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DropMeasurementRequest) GetDatabase() string
- func (x *DropMeasurementRequest) GetMeasurement() string
- func (*DropMeasurementRequest) ProtoMessage()
- func (x *DropMeasurementRequest) ProtoReflect() protoreflect.Message
- func (x *DropMeasurementRequest) Reset()
- func (x *DropMeasurementRequest) String() string
- type DropMeasurementResponse
- func (*DropMeasurementResponse) Descriptor() ([]byte, []int)deprecated
- func (x *DropMeasurementResponse) GetError() string
- func (x *DropMeasurementResponse) GetSuccess() bool
- func (*DropMeasurementResponse) ProtoMessage()
- func (x *DropMeasurementResponse) ProtoReflect() protoreflect.Message
- func (x *DropMeasurementResponse) Reset()
- func (x *DropMeasurementResponse) String() string
- type FieldEntry
- type FieldValue
- func (*FieldValue) Descriptor() ([]byte, []int)deprecated
- func (x *FieldValue) GetBoolValue() bool
- func (x *FieldValue) GetFloatValue() float64
- func (x *FieldValue) GetIntValue() int64
- func (x *FieldValue) GetStringValue() string
- func (x *FieldValue) GetValue() isFieldValue_Value
- func (*FieldValue) ProtoMessage()
- func (x *FieldValue) ProtoReflect() protoreflect.Message
- func (x *FieldValue) Reset()
- func (x *FieldValue) String() string
- type FieldValue_BoolValue
- type FieldValue_FloatValue
- type FieldValue_IntValue
- type FieldValue_StringValue
- type FilterCondition
- func (*FilterCondition) Descriptor() ([]byte, []int)deprecated
- func (x *FilterCondition) GetField() string
- func (x *FilterCondition) GetOp() FilterOp
- func (x *FilterCondition) GetTag() string
- func (x *FilterCondition) GetValue() *FieldValue
- func (*FilterCondition) ProtoMessage()
- func (x *FilterCondition) ProtoReflect() protoreflect.Message
- func (x *FilterCondition) Reset()
- func (x *FilterCondition) String() string
- type FilterOp
- type FilterSpec
- type GroupBySpec
- type HealthRequest
- type HealthResponse
- func (*HealthResponse) Descriptor() ([]byte, []int)deprecated
- func (x *HealthResponse) GetHealthy() bool
- func (x *HealthResponse) GetVersion() string
- func (*HealthResponse) ProtoMessage()
- func (x *HealthResponse) ProtoReflect() protoreflect.Message
- func (x *HealthResponse) Reset()
- func (x *HealthResponse) String() string
- type InternalField
- type InternalPoint
- type LimitSpec
- type ListDatabasesRequest
- type ListDatabasesResponse
- func (*ListDatabasesResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ListDatabasesResponse) GetDatabases() []string
- func (*ListDatabasesResponse) ProtoMessage()
- func (x *ListDatabasesResponse) ProtoReflect() protoreflect.Message
- func (x *ListDatabasesResponse) Reset()
- func (x *ListDatabasesResponse) String() string
- type ListMeasurementsRequest
- func (*ListMeasurementsRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ListMeasurementsRequest) GetDatabase() string
- func (*ListMeasurementsRequest) ProtoMessage()
- func (x *ListMeasurementsRequest) ProtoReflect() protoreflect.Message
- func (x *ListMeasurementsRequest) Reset()
- func (x *ListMeasurementsRequest) String() string
- type ListMeasurementsResponse
- func (*ListMeasurementsResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ListMeasurementsResponse) GetMeasurements() []string
- func (*ListMeasurementsResponse) ProtoMessage()
- func (x *ListMeasurementsResponse) ProtoReflect() protoreflect.Message
- func (x *ListMeasurementsResponse) Reset()
- func (x *ListMeasurementsResponse) String() string
- type MTSClient
- type MTSServer
- type MTS_QueryRangeClient
- type MTS_QueryRangeServer
- type MemPoint
- type MemTableConfig
- func (*MemTableConfig) Descriptor() ([]byte, []int)deprecated
- func (c *MemTableConfig) GetFlushIdle() time.Duration
- func (x *MemTableConfig) GetFlushIdleNanos() int64
- func (x *MemTableConfig) GetFlushMemorySize() int64
- func (x *MemTableConfig) GetFlushPointCount() int32
- func (*MemTableConfig) ProtoMessage()
- func (x *MemTableConfig) ProtoReflect() protoreflect.Message
- func (x *MemTableConfig) Reset()
- func (c *MemTableConfig) SetFlushIdle(d time.Duration)
- func (x *MemTableConfig) String() string
- type OperatorSpec
- func (*OperatorSpec) Descriptor() ([]byte, []int)deprecated
- func (x *OperatorSpec) GetAggregate() *AggregateSpec
- func (x *OperatorSpec) GetFilter() *FilterSpec
- func (x *OperatorSpec) GetGroupBy() *GroupBySpec
- func (x *OperatorSpec) GetLimit() *LimitSpec
- func (x *OperatorSpec) GetOp() isOperatorSpec_Op
- func (x *OperatorSpec) GetProject() *ProjectSpec
- func (x *OperatorSpec) GetScan() *ScanSpec
- func (x *OperatorSpec) GetSort() *SortSpec
- func (*OperatorSpec) ProtoMessage()
- func (x *OperatorSpec) ProtoReflect() protoreflect.Message
- func (x *OperatorSpec) Reset()
- func (x *OperatorSpec) String() string
- type OperatorSpec_Aggregate
- type OperatorSpec_Filter
- type OperatorSpec_GroupBy
- type OperatorSpec_Limit
- type OperatorSpec_Project
- type OperatorSpec_Scan
- type OperatorSpec_Sort
- type Point
- func (*Point) Descriptor() ([]byte, []int)deprecated
- func (x *Point) GetDatabase() string
- func (p *Point) GetField(name string) any
- func (x *Point) GetFields() map[string]*FieldValue
- func (x *Point) GetMeasurement() string
- func (x *Point) GetTags() map[string]string
- func (x *Point) GetTimestamp() int64
- func (*Point) ProtoMessage()
- func (x *Point) ProtoReflect() protoreflect.Message
- func (x *Point) Reset()
- func (p *Point) SetField(name string, value any)
- func (x *Point) String() string
- type PointRow
- func (*PointRow) Descriptor() ([]byte, []int)deprecated
- func (p *PointRow) GetField(name string) any
- func (p *PointRow) GetFieldValue(name string) *FieldValue
- func (x *PointRow) GetFields() []*FieldEntry
- func (x *PointRow) GetSid() uint64
- func (x *PointRow) GetTags() map[string]string
- func (x *PointRow) GetTimestamp() int64
- func (*PointRow) ProtoMessage()
- func (x *PointRow) ProtoReflect() protoreflect.Message
- func (x *PointRow) Reset()
- func (p *PointRow) SetField(name string, value any)
- func (x *PointRow) String() string
- func (p *PointRow) ToPoint(database, measurement string) *Point
- type ProjectSpec
- type QueryPlan
- func (*QueryPlan) Descriptor() ([]byte, []int)deprecated
- func (x *QueryPlan) GetDatabase() string
- func (x *QueryPlan) GetEndTime() int64
- func (x *QueryPlan) GetMeasurement() string
- func (x *QueryPlan) GetOps() []*OperatorSpec
- func (x *QueryPlan) GetStartTime() int64
- func (*QueryPlan) ProtoMessage()
- func (x *QueryPlan) ProtoReflect() protoreflect.Message
- func (x *QueryPlan) Reset()
- func (x *QueryPlan) String() string
- type QueryRangeRequest
- func (*QueryRangeRequest) Descriptor() ([]byte, []int)deprecated
- func (x *QueryRangeRequest) GetDatabase() string
- func (x *QueryRangeRequest) GetDownsampleWindowNanos() int64
- func (x *QueryRangeRequest) GetEndTime() int64
- func (x *QueryRangeRequest) GetFields() []string
- func (x *QueryRangeRequest) GetLimit() int64
- func (x *QueryRangeRequest) GetMeasurement() string
- func (x *QueryRangeRequest) GetOffset() int64
- func (x *QueryRangeRequest) GetStartTime() int64
- func (x *QueryRangeRequest) GetTags() map[string]string
- func (*QueryRangeRequest) ProtoMessage()
- func (x *QueryRangeRequest) ProtoReflect() protoreflect.Message
- func (x *QueryRangeRequest) Reset()
- func (x *QueryRangeRequest) String() string
- type QueryRangeResponse
- func (*QueryRangeResponse) Descriptor() ([]byte, []int)deprecated
- func (x *QueryRangeResponse) GetHasMore() bool
- func (x *QueryRangeResponse) GetRows() []*Row
- func (*QueryRangeResponse) ProtoMessage()
- func (x *QueryRangeResponse) ProtoReflect() protoreflect.Message
- func (x *QueryRangeResponse) Reset()
- func (x *QueryRangeResponse) String() string
- type Row
- func (*Row) Descriptor() ([]byte, []int)deprecated
- func (r *Row) GetFieldValue(name string) *FieldValue
- func (x *Row) GetFields() []*FieldEntry
- func (x *Row) GetTags() map[string]string
- func (x *Row) GetTimestamp() int64
- func (*Row) ProtoMessage()
- func (x *Row) ProtoReflect() protoreflect.Message
- func (x *Row) Reset()
- func (x *Row) String() string
- type ScanSpec
- type SortDirection
- func (SortDirection) Descriptor() protoreflect.EnumDescriptor
- func (x SortDirection) Enum() *SortDirection
- func (SortDirection) EnumDescriptor() ([]byte, []int)deprecated
- func (x SortDirection) Number() protoreflect.EnumNumber
- func (x SortDirection) String() string
- func (SortDirection) Type() protoreflect.EnumType
- type SortField
- type SortSpec
- type UnimplementedMTSServer
- func (UnimplementedMTSServer) CreateDatabase(context.Context, *CreateDatabaseRequest) (*CreateDatabaseResponse, error)
- func (UnimplementedMTSServer) CreateMeasurement(context.Context, *CreateMeasurementRequest) (*CreateMeasurementResponse, error)
- func (UnimplementedMTSServer) DropDatabase(context.Context, *DropDatabaseRequest) (*DropDatabaseResponse, error)
- func (UnimplementedMTSServer) DropMeasurement(context.Context, *DropMeasurementRequest) (*DropMeasurementResponse, error)
- func (UnimplementedMTSServer) Health(context.Context, *HealthRequest) (*HealthResponse, error)
- func (UnimplementedMTSServer) ListDatabases(context.Context, *ListDatabasesRequest) (*ListDatabasesResponse, error)
- func (UnimplementedMTSServer) ListMeasurements(context.Context, *ListMeasurementsRequest) (*ListMeasurementsResponse, error)
- func (UnimplementedMTSServer) QueryRange(*QueryRangeRequest, grpc.ServerStreamingServer[Row]) error
- func (UnimplementedMTSServer) Write(context.Context, *WriteRequest) (*WriteResponse, error)
- func (UnimplementedMTSServer) WriteBatch(context.Context, *WriteBatchRequest) (*WriteBatchResponse, error)
- type UnsafeMTSServer
- type WriteBatchRequest
- func (*WriteBatchRequest) Descriptor() ([]byte, []int)deprecated
- func (x *WriteBatchRequest) GetPoints() []*WriteRequest
- func (*WriteBatchRequest) ProtoMessage()
- func (x *WriteBatchRequest) ProtoReflect() protoreflect.Message
- func (x *WriteBatchRequest) Reset()
- func (x *WriteBatchRequest) String() string
- type WriteBatchResponse
- func (*WriteBatchResponse) Descriptor() ([]byte, []int)deprecated
- func (x *WriteBatchResponse) GetCount() int32
- func (x *WriteBatchResponse) GetError() string
- func (x *WriteBatchResponse) GetSuccess() bool
- func (*WriteBatchResponse) ProtoMessage()
- func (x *WriteBatchResponse) ProtoReflect() protoreflect.Message
- func (x *WriteBatchResponse) Reset()
- func (x *WriteBatchResponse) String() string
- type WriteRequest
- func (*WriteRequest) Descriptor() ([]byte, []int)deprecated
- func (x *WriteRequest) GetDatabase() string
- func (x *WriteRequest) GetFields() map[string]*FieldValue
- func (x *WriteRequest) GetMeasurement() string
- func (x *WriteRequest) GetTags() map[string]string
- func (x *WriteRequest) GetTimestamp() int64
- func (*WriteRequest) ProtoMessage()
- func (x *WriteRequest) ProtoReflect() protoreflect.Message
- func (x *WriteRequest) Reset()
- func (x *WriteRequest) String() string
- type WriteResponse
- func (*WriteResponse) Descriptor() ([]byte, []int)deprecated
- func (x *WriteResponse) GetError() string
- func (x *WriteResponse) GetSuccess() bool
- func (*WriteResponse) ProtoMessage()
- func (x *WriteResponse) ProtoReflect() protoreflect.Message
- func (x *WriteResponse) Reset()
- func (x *WriteResponse) String() string
Constants ¶
const ( CompressionNone = CompressionAlgorithm_NONE CompressionSnappy = CompressionAlgorithm_SNAPPY CompressionLZ4 = CompressionAlgorithm_LZ4 )
const ( MTS_Write_FullMethodName = "/mts.v1.MTS/Write" MTS_WriteBatch_FullMethodName = "/mts.v1.MTS/WriteBatch" MTS_QueryRange_FullMethodName = "/mts.v1.MTS/QueryRange" MTS_ListMeasurements_FullMethodName = "/mts.v1.MTS/ListMeasurements" MTS_CreateMeasurement_FullMethodName = "/mts.v1.MTS/CreateMeasurement" MTS_DropMeasurement_FullMethodName = "/mts.v1.MTS/DropMeasurement" MTS_ListDatabases_FullMethodName = "/mts.v1.MTS/ListDatabases" MTS_CreateDatabase_FullMethodName = "/mts.v1.MTS/CreateDatabase" MTS_DropDatabase_FullMethodName = "/mts.v1.MTS/DropDatabase" MTS_Health_FullMethodName = "/mts.v1.MTS/Health" )
Variables ¶
var ( CompressionAlgorithm_name = map[int32]string{ 0: "NONE", 1: "SNAPPY", 2: "LZ4", } CompressionAlgorithm_value = map[string]int32{ "NONE": 0, "SNAPPY": 1, "LZ4": 2, } )
Enum value maps for CompressionAlgorithm.
var ( FilterOp_name = map[int32]string{ 0: "EQ", 1: "NE", 2: "GT", 3: "GTE", 4: "LT", 5: "LTE", } FilterOp_value = map[string]int32{ "EQ": 0, "NE": 1, "GT": 2, "GTE": 3, "LT": 4, "LTE": 5, } )
Enum value maps for FilterOp.
var ( SortDirection_name = map[int32]string{ 0: "ASC", 1: "DESC", } SortDirection_value = map[string]int32{ "ASC": 0, "DESC": 1, } )
Enum value maps for SortDirection.
var File_mts_proto protoreflect.FileDescriptor
var MTS_ServiceDesc = grpc.ServiceDesc{ ServiceName: "mts.v1.MTS", HandlerType: (*MTSServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Write", Handler: _MTS_Write_Handler, }, { MethodName: "WriteBatch", Handler: _MTS_WriteBatch_Handler, }, { MethodName: "ListMeasurements", Handler: _MTS_ListMeasurements_Handler, }, { MethodName: "CreateMeasurement", Handler: _MTS_CreateMeasurement_Handler, }, { MethodName: "DropMeasurement", Handler: _MTS_DropMeasurement_Handler, }, { MethodName: "ListDatabases", Handler: _MTS_ListDatabases_Handler, }, { MethodName: "CreateDatabase", Handler: _MTS_CreateDatabase_Handler, }, { MethodName: "DropDatabase", Handler: _MTS_DropDatabase_Handler, }, { MethodName: "Health", Handler: _MTS_Health_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "QueryRange", Handler: _MTS_QueryRange_Handler, ServerStreams: true, }, }, Metadata: "mts.proto", }
MTS_ServiceDesc is the grpc.ServiceDesc for MTS service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func AppendFieldData ¶
func AppendFieldData(dst []byte, fields map[string]*FieldValue) []byte
AppendFieldData 将 fields 序列化为 FieldData 格式并追加到 dst。 格式: FieldCount(2B BE) + [KeyLen(2B BE) + Key + Type(1B) + Value]...
func FieldDataSize ¶
func FieldDataSize(fields map[string]*FieldValue) int
FieldDataSize 返回 fields 序列化后的字节数。
func InternalFieldsToMap ¶
func InternalFieldsToMap(fields []InternalField) map[string]*FieldValue
InternalFieldsToMap 将 []InternalField 还原为 map[string]*FieldValue。
func RegisterMTSServer ¶
func RegisterMTSServer(s grpc.ServiceRegistrar, srv MTSServer)
func ReleaseFieldData ¶
func ReleaseFieldData(data []byte)
ReleaseFieldData 将池化的 FieldData 归还到缓冲区池。 仅对 serializeFieldsFromMap 返回的非 nil FieldData 有效。
Types ¶
type AggFunction ¶
type AggFunction struct {
Function string `protobuf:"bytes,1,opt,name=function,proto3" json:"function,omitempty"`
Field string `protobuf:"bytes,2,opt,name=field,proto3" json:"field,omitempty"`
WindowNanos int64 `protobuf:"varint,3,opt,name=window_nanos,json=windowNanos,proto3" json:"window_nanos,omitempty"`
// contains filtered or unexported fields
}
聚合函数定义
func (*AggFunction) Descriptor
deprecated
func (*AggFunction) Descriptor() ([]byte, []int)
Deprecated: Use AggFunction.ProtoReflect.Descriptor instead.
func (*AggFunction) GetField ¶
func (x *AggFunction) GetField() string
func (*AggFunction) GetFunction ¶
func (x *AggFunction) GetFunction() string
func (*AggFunction) GetWindowNanos ¶
func (x *AggFunction) GetWindowNanos() int64
func (*AggFunction) ProtoMessage ¶
func (*AggFunction) ProtoMessage()
func (*AggFunction) ProtoReflect ¶
func (x *AggFunction) ProtoReflect() protoreflect.Message
func (*AggFunction) Reset ¶
func (x *AggFunction) Reset()
func (*AggFunction) String ¶
func (x *AggFunction) String() string
type AggregateSpec ¶
type AggregateSpec struct {
Functions []*AggFunction `protobuf:"bytes,1,rep,name=functions,proto3" json:"functions,omitempty"`
// contains filtered or unexported fields
}
Aggregate 算子
func (*AggregateSpec) Descriptor
deprecated
func (*AggregateSpec) Descriptor() ([]byte, []int)
Deprecated: Use AggregateSpec.ProtoReflect.Descriptor instead.
func (*AggregateSpec) GetFunctions ¶
func (x *AggregateSpec) GetFunctions() []*AggFunction
func (*AggregateSpec) ProtoMessage ¶
func (*AggregateSpec) ProtoMessage()
func (*AggregateSpec) ProtoReflect ¶
func (x *AggregateSpec) ProtoReflect() protoreflect.Message
func (*AggregateSpec) Reset ¶
func (x *AggregateSpec) Reset()
func (*AggregateSpec) String ¶
func (x *AggregateSpec) String() string
type CompactionConfig ¶
type CompactionConfig struct {
// 最大 SSTable 数量,超过此值触发 compaction
MaxSstableCount int32 `protobuf:"varint,1,opt,name=max_sstable_count,json=maxSstableCount,proto3" json:"max_sstable_count,omitempty"`
// 单次 compaction 最大文件数(0 表示不限制)
MaxCompactionBatch int32 `protobuf:"varint,2,opt,name=max_compaction_batch,json=maxCompactionBatch,proto3" json:"max_compaction_batch,omitempty"`
// 单个 Shard 数据大小上限(字节),超过后不参与 compaction
ShardSizeLimit int64 `protobuf:"varint,3,opt,name=shard_size_limit,json=shardSizeLimit,proto3" json:"shard_size_limit,omitempty"`
// 定时触发间隔(纳秒),0 表示禁用定时触发
CheckIntervalNanos int64 `protobuf:"varint,4,opt,name=check_interval_nanos,json=checkIntervalNanos,proto3" json:"check_interval_nanos,omitempty"`
// Compaction 超时时间(纳秒)
TimeoutNanos int64 `protobuf:"varint,5,opt,name=timeout_nanos,json=timeoutNanos,proto3" json:"timeout_nanos,omitempty"`
// contains filtered or unexported fields
}
Compaction 配置
CompactionConfig 控制 SSTable 合并(compaction)行为。 Compaction 是 LSM 存储引擎的核心维护操作,通过合并多个 SSTable 减少文件数量、 提升查询性能并清理过期或已删除数据。
触发条件:
- SSTable 数量达到 max_sstable_count 阈值
- 定时检查间隔 check_interval_nanos
默认值:
- max_sstable_count: 4
- max_compaction_batch: 0(不限制)
- shard_size_limit: 1GB
- check_interval_nanos: 1 小时(3600000000000 纳秒)
- timeout_nanos: 30 分钟(1800000000000 纳秒)
func (*CompactionConfig) Descriptor
deprecated
func (*CompactionConfig) Descriptor() ([]byte, []int)
Deprecated: Use CompactionConfig.ProtoReflect.Descriptor instead.
func (*CompactionConfig) GetCheckIntervalNanos ¶
func (x *CompactionConfig) GetCheckIntervalNanos() int64
func (*CompactionConfig) GetMaxCompactionBatch ¶
func (x *CompactionConfig) GetMaxCompactionBatch() int32
func (*CompactionConfig) GetMaxSstableCount ¶
func (x *CompactionConfig) GetMaxSstableCount() int32
func (*CompactionConfig) GetShardSizeLimit ¶
func (x *CompactionConfig) GetShardSizeLimit() int64
func (*CompactionConfig) GetTimeoutNanos ¶
func (x *CompactionConfig) GetTimeoutNanos() int64
func (*CompactionConfig) ProtoMessage ¶
func (*CompactionConfig) ProtoMessage()
func (*CompactionConfig) ProtoReflect ¶
func (x *CompactionConfig) ProtoReflect() protoreflect.Message
func (*CompactionConfig) Reset ¶
func (x *CompactionConfig) Reset()
func (*CompactionConfig) String ¶
func (x *CompactionConfig) String() string
type CompressionAlgorithm ¶
type CompressionAlgorithm int32
块压缩算法
SSTable 块压缩算法,对编码后的数据块应用压缩以减少磁盘占用。
算法说明:
- NONE: 无压缩,CRC32C 校验和直接追加
- SNAPPY: Google Snappy 压缩,速度快、压缩比适中
- LZ4: LZ4 压缩,速度极快、压缩比略低于 Snappy
默认使用 NONE(无压缩)。压缩开启后每块独立压缩,查询时按需解压。
const ( // 无压缩(默认) CompressionAlgorithm_NONE CompressionAlgorithm = 0 // Snappy 压缩 CompressionAlgorithm_SNAPPY CompressionAlgorithm = 1 // LZ4 压缩 CompressionAlgorithm_LZ4 CompressionAlgorithm = 2 )
func (CompressionAlgorithm) Descriptor ¶
func (CompressionAlgorithm) Descriptor() protoreflect.EnumDescriptor
func (CompressionAlgorithm) Enum ¶
func (x CompressionAlgorithm) Enum() *CompressionAlgorithm
func (CompressionAlgorithm) EnumDescriptor
deprecated
func (CompressionAlgorithm) EnumDescriptor() ([]byte, []int)
Deprecated: Use CompressionAlgorithm.Descriptor instead.
func (CompressionAlgorithm) Number ¶
func (x CompressionAlgorithm) Number() protoreflect.EnumNumber
func (CompressionAlgorithm) String ¶
func (x CompressionAlgorithm) String() string
func (CompressionAlgorithm) Type ¶
func (CompressionAlgorithm) Type() protoreflect.EnumType
type Config ¶
type Config struct {
// 数据目录
DataDir string `protobuf:"bytes,1,opt,name=data_dir,json=dataDir,proto3" json:"data_dir,omitempty"`
// Shard 时间窗口(纳秒)
ShardDurationNanos int64 `protobuf:"varint,2,opt,name=shard_duration_nanos,json=shardDurationNanos,proto3" json:"shard_duration_nanos,omitempty"`
// 内存表配置
MemTableCfg *MemTableConfig `protobuf:"bytes,3,opt,name=mem_table_cfg,json=memTableCfg,proto3" json:"mem_table_cfg,omitempty"`
// Compaction 配置
CompactionCfg *CompactionConfig `protobuf:"bytes,4,opt,name=compaction_cfg,json=compactionCfg,proto3" json:"compaction_cfg,omitempty"`
// 压缩算法
CompressionAlgorithm CompressionAlgorithm `` /* 155-byte string literal not displayed */
// 数据保留期(纳秒),0 表示不自动删除过期数据
RetentionPeriodNanos int64 `protobuf:"varint,6,opt,name=retention_period_nanos,json=retentionPeriodNanos,proto3" json:"retention_period_nanos,omitempty"`
// Retention 检查间隔(纳秒)
RetentionCheckIntervalNanos int64 `` /* 147-byte string literal not displayed */
// contains filtered or unexported fields
}
引擎配置
Config 是数据库的完整配置结构。 包含数据目录、分片时长、内存表配置、压缩算法和数据保留策略。
字段说明:
- data_dir: 数据存储目录路径
- shard_duration_nanos: Shard 时间窗口(纳秒),最小 1 小时
- mem_table_cfg: 内存表配置
- compaction_cfg: Compaction 配置
- compression_algorithm: 压缩算法
- retention_period_nanos: 数据保留期(纳秒),0 表示不自动删除
- retention_check_interval_nanos: retention 检查间隔(纳秒)
ShardDuration 说明:
ShardDuration 控制数据在磁盘上的分片大小。 较小的值会产生更多小文件,利于过期数据快速清理。 较大的值减少文件数量,提高大时间范围查询效率。 建议值:1小时(3600000000000) - 7天(604800000000000)。
func (*Config) Descriptor
deprecated
func (*Config) GetCompactionCfg ¶
func (x *Config) GetCompactionCfg() *CompactionConfig
func (*Config) GetCompressionAlgorithm ¶
func (x *Config) GetCompressionAlgorithm() CompressionAlgorithm
func (*Config) GetDataDir ¶
func (*Config) GetMemTableCfg ¶
func (x *Config) GetMemTableCfg() *MemTableConfig
func (*Config) GetRetentionCheckIntervalNanos ¶
func (*Config) GetRetentionPeriodNanos ¶
func (*Config) GetShardDuration ¶
GetShardDuration 返回 ShardDurationNanos 的 time.Duration 形式。
func (*Config) GetShardDurationNanos ¶
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) ProtoReflect ¶
func (x *Config) ProtoReflect() protoreflect.Message
func (*Config) SetShardDuration ¶
SetShardDuration 设置 ShardDurationNanos。
type CreateDatabaseRequest ¶
type CreateDatabaseRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
// 数据保留期(纳秒),0 表示不自动删除过期数据
RetentionPeriodNanos int64 `protobuf:"varint,2,opt,name=retention_period_nanos,json=retentionPeriodNanos,proto3" json:"retention_period_nanos,omitempty"`
// 降采样配置(可选)
DownsampleConfig *DownsampleConfig `protobuf:"bytes,3,opt,name=downsample_config,json=downsampleConfig,proto3" json:"downsample_config,omitempty"`
// contains filtered or unexported fields
}
创建数据库请求
func (*CreateDatabaseRequest) Descriptor
deprecated
func (*CreateDatabaseRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateDatabaseRequest.ProtoReflect.Descriptor instead.
func (*CreateDatabaseRequest) GetDatabase ¶
func (x *CreateDatabaseRequest) GetDatabase() string
func (*CreateDatabaseRequest) GetDownsampleConfig ¶
func (x *CreateDatabaseRequest) GetDownsampleConfig() *DownsampleConfig
func (*CreateDatabaseRequest) GetRetentionPeriodNanos ¶
func (x *CreateDatabaseRequest) GetRetentionPeriodNanos() int64
func (*CreateDatabaseRequest) ProtoMessage ¶
func (*CreateDatabaseRequest) ProtoMessage()
func (*CreateDatabaseRequest) ProtoReflect ¶
func (x *CreateDatabaseRequest) ProtoReflect() protoreflect.Message
func (*CreateDatabaseRequest) Reset ¶
func (x *CreateDatabaseRequest) Reset()
func (*CreateDatabaseRequest) String ¶
func (x *CreateDatabaseRequest) String() string
type CreateDatabaseResponse ¶
type CreateDatabaseResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
// contains filtered or unexported fields
}
创建数据库响应
func (*CreateDatabaseResponse) Descriptor
deprecated
func (*CreateDatabaseResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreateDatabaseResponse.ProtoReflect.Descriptor instead.
func (*CreateDatabaseResponse) GetError ¶
func (x *CreateDatabaseResponse) GetError() string
func (*CreateDatabaseResponse) GetSuccess ¶
func (x *CreateDatabaseResponse) GetSuccess() bool
func (*CreateDatabaseResponse) ProtoMessage ¶
func (*CreateDatabaseResponse) ProtoMessage()
func (*CreateDatabaseResponse) ProtoReflect ¶
func (x *CreateDatabaseResponse) ProtoReflect() protoreflect.Message
func (*CreateDatabaseResponse) Reset ¶
func (x *CreateDatabaseResponse) Reset()
func (*CreateDatabaseResponse) String ¶
func (x *CreateDatabaseResponse) String() string
type CreateMeasurementRequest ¶
type CreateMeasurementRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
Measurement string `protobuf:"bytes,2,opt,name=measurement,proto3" json:"measurement,omitempty"`
// contains filtered or unexported fields
}
创建 Measurement 请求
func (*CreateMeasurementRequest) Descriptor
deprecated
func (*CreateMeasurementRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateMeasurementRequest.ProtoReflect.Descriptor instead.
func (*CreateMeasurementRequest) GetDatabase ¶
func (x *CreateMeasurementRequest) GetDatabase() string
func (*CreateMeasurementRequest) GetMeasurement ¶
func (x *CreateMeasurementRequest) GetMeasurement() string
func (*CreateMeasurementRequest) ProtoMessage ¶
func (*CreateMeasurementRequest) ProtoMessage()
func (*CreateMeasurementRequest) ProtoReflect ¶
func (x *CreateMeasurementRequest) ProtoReflect() protoreflect.Message
func (*CreateMeasurementRequest) Reset ¶
func (x *CreateMeasurementRequest) Reset()
func (*CreateMeasurementRequest) String ¶
func (x *CreateMeasurementRequest) String() string
type CreateMeasurementResponse ¶
type CreateMeasurementResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
// contains filtered or unexported fields
}
创建 Measurement 响应
func (*CreateMeasurementResponse) Descriptor
deprecated
func (*CreateMeasurementResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreateMeasurementResponse.ProtoReflect.Descriptor instead.
func (*CreateMeasurementResponse) GetError ¶
func (x *CreateMeasurementResponse) GetError() string
func (*CreateMeasurementResponse) GetSuccess ¶
func (x *CreateMeasurementResponse) GetSuccess() bool
func (*CreateMeasurementResponse) ProtoMessage ¶
func (*CreateMeasurementResponse) ProtoMessage()
func (*CreateMeasurementResponse) ProtoReflect ¶
func (x *CreateMeasurementResponse) ProtoReflect() protoreflect.Message
func (*CreateMeasurementResponse) Reset ¶
func (x *CreateMeasurementResponse) Reset()
func (*CreateMeasurementResponse) String ¶
func (x *CreateMeasurementResponse) String() string
type DownsampleConfig ¶
type DownsampleConfig struct {
Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
CheckIntervalNanos int64 `protobuf:"varint,2,opt,name=check_interval_nanos,json=checkIntervalNanos,proto3" json:"check_interval_nanos,omitempty"`
Rules []*DownsampleRule `protobuf:"bytes,3,rep,name=rules,proto3" json:"rules,omitempty"`
// contains filtered or unexported fields
}
降采样配置
控制数据库是否启用降采样以及降采样规则链。
字段说明:
- enabled: 是否启用降采样
- check_interval_nanos: 降采样服务扫描间隔(纳秒),默认 5 分钟
- rules: 降采样规则链,按窗口从小到大排序
func (*DownsampleConfig) Descriptor
deprecated
func (*DownsampleConfig) Descriptor() ([]byte, []int)
Deprecated: Use DownsampleConfig.ProtoReflect.Descriptor instead.
func (*DownsampleConfig) GetCheckIntervalNanos ¶
func (x *DownsampleConfig) GetCheckIntervalNanos() int64
func (*DownsampleConfig) GetEnabled ¶
func (x *DownsampleConfig) GetEnabled() bool
func (*DownsampleConfig) GetRules ¶
func (x *DownsampleConfig) GetRules() []*DownsampleRule
func (*DownsampleConfig) ProtoMessage ¶
func (*DownsampleConfig) ProtoMessage()
func (*DownsampleConfig) ProtoReflect ¶
func (x *DownsampleConfig) ProtoReflect() protoreflect.Message
func (*DownsampleConfig) Reset ¶
func (x *DownsampleConfig) Reset()
func (*DownsampleConfig) String ¶
func (x *DownsampleConfig) String() string
type DownsampleRule ¶
type DownsampleRule struct {
WindowNanos int64 `protobuf:"varint,1,opt,name=window_nanos,json=windowNanos,proto3" json:"window_nanos,omitempty"`
Functions []string `protobuf:"bytes,2,rep,name=functions,proto3" json:"functions,omitempty"`
RetentionNanos int64 `protobuf:"varint,3,opt,name=retention_nanos,json=retentionNanos,proto3" json:"retention_nanos,omitempty"`
// contains filtered or unexported fields
}
降采样规则
定义单层降采样规则的聚合窗口、函数和数据保留期。
字段说明:
- window_nanos: 聚合窗口大小(纳秒),如 5m = 300_000_000_000
- functions: 聚合函数名列表,支持 avg / max / min / sum / count / first / last
- retention_nanos: 该层级降采样数据保留期(纳秒)
func (*DownsampleRule) Descriptor
deprecated
func (*DownsampleRule) Descriptor() ([]byte, []int)
Deprecated: Use DownsampleRule.ProtoReflect.Descriptor instead.
func (*DownsampleRule) GetFunctions ¶
func (x *DownsampleRule) GetFunctions() []string
func (*DownsampleRule) GetRetentionNanos ¶
func (x *DownsampleRule) GetRetentionNanos() int64
func (*DownsampleRule) GetWindowNanos ¶
func (x *DownsampleRule) GetWindowNanos() int64
func (*DownsampleRule) ProtoMessage ¶
func (*DownsampleRule) ProtoMessage()
func (*DownsampleRule) ProtoReflect ¶
func (x *DownsampleRule) ProtoReflect() protoreflect.Message
func (*DownsampleRule) Reset ¶
func (x *DownsampleRule) Reset()
func (*DownsampleRule) String ¶
func (x *DownsampleRule) String() string
type DropDatabaseRequest ¶
type DropDatabaseRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
// contains filtered or unexported fields
}
删除数据库请求
func (*DropDatabaseRequest) Descriptor
deprecated
func (*DropDatabaseRequest) Descriptor() ([]byte, []int)
Deprecated: Use DropDatabaseRequest.ProtoReflect.Descriptor instead.
func (*DropDatabaseRequest) GetDatabase ¶
func (x *DropDatabaseRequest) GetDatabase() string
func (*DropDatabaseRequest) ProtoMessage ¶
func (*DropDatabaseRequest) ProtoMessage()
func (*DropDatabaseRequest) ProtoReflect ¶
func (x *DropDatabaseRequest) ProtoReflect() protoreflect.Message
func (*DropDatabaseRequest) Reset ¶
func (x *DropDatabaseRequest) Reset()
func (*DropDatabaseRequest) String ¶
func (x *DropDatabaseRequest) String() string
type DropDatabaseResponse ¶
type DropDatabaseResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
// contains filtered or unexported fields
}
删除数据库响应
func (*DropDatabaseResponse) Descriptor
deprecated
func (*DropDatabaseResponse) Descriptor() ([]byte, []int)
Deprecated: Use DropDatabaseResponse.ProtoReflect.Descriptor instead.
func (*DropDatabaseResponse) GetError ¶
func (x *DropDatabaseResponse) GetError() string
func (*DropDatabaseResponse) GetSuccess ¶
func (x *DropDatabaseResponse) GetSuccess() bool
func (*DropDatabaseResponse) ProtoMessage ¶
func (*DropDatabaseResponse) ProtoMessage()
func (*DropDatabaseResponse) ProtoReflect ¶
func (x *DropDatabaseResponse) ProtoReflect() protoreflect.Message
func (*DropDatabaseResponse) Reset ¶
func (x *DropDatabaseResponse) Reset()
func (*DropDatabaseResponse) String ¶
func (x *DropDatabaseResponse) String() string
type DropMeasurementRequest ¶
type DropMeasurementRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
Measurement string `protobuf:"bytes,2,opt,name=measurement,proto3" json:"measurement,omitempty"`
// contains filtered or unexported fields
}
删除 Measurement 请求
func (*DropMeasurementRequest) Descriptor
deprecated
func (*DropMeasurementRequest) Descriptor() ([]byte, []int)
Deprecated: Use DropMeasurementRequest.ProtoReflect.Descriptor instead.
func (*DropMeasurementRequest) GetDatabase ¶
func (x *DropMeasurementRequest) GetDatabase() string
func (*DropMeasurementRequest) GetMeasurement ¶
func (x *DropMeasurementRequest) GetMeasurement() string
func (*DropMeasurementRequest) ProtoMessage ¶
func (*DropMeasurementRequest) ProtoMessage()
func (*DropMeasurementRequest) ProtoReflect ¶
func (x *DropMeasurementRequest) ProtoReflect() protoreflect.Message
func (*DropMeasurementRequest) Reset ¶
func (x *DropMeasurementRequest) Reset()
func (*DropMeasurementRequest) String ¶
func (x *DropMeasurementRequest) String() string
type DropMeasurementResponse ¶
type DropMeasurementResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
// contains filtered or unexported fields
}
删除 Measurement 响应
func (*DropMeasurementResponse) Descriptor
deprecated
func (*DropMeasurementResponse) Descriptor() ([]byte, []int)
Deprecated: Use DropMeasurementResponse.ProtoReflect.Descriptor instead.
func (*DropMeasurementResponse) GetError ¶
func (x *DropMeasurementResponse) GetError() string
func (*DropMeasurementResponse) GetSuccess ¶
func (x *DropMeasurementResponse) GetSuccess() bool
func (*DropMeasurementResponse) ProtoMessage ¶
func (*DropMeasurementResponse) ProtoMessage()
func (*DropMeasurementResponse) ProtoReflect ¶
func (x *DropMeasurementResponse) ProtoReflect() protoreflect.Message
func (*DropMeasurementResponse) Reset ¶
func (x *DropMeasurementResponse) Reset()
func (*DropMeasurementResponse) String ¶
func (x *DropMeasurementResponse) String() string
type FieldEntry ¶
type FieldEntry struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Value *FieldValue `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
// contains filtered or unexported fields
}
字段条目(键值对,用于替代 map<string, FieldValue>)
用于 PointRow 和 Row 消息的字段列表。 相比 map,repeated FieldEntry 的优势:
- 确定性遍历顺序
- 更低的内存开销(无哈希表元数据)
- 更好的缓存局部性
func InternalFieldsToFieldEntry ¶
func InternalFieldsToFieldEntry(fields []InternalField) []*FieldEntry
InternalFieldsToFieldEntry 将 []InternalField 转换为 []*FieldEntry(用于构建 PointRow)。
func (*FieldEntry) Descriptor
deprecated
func (*FieldEntry) Descriptor() ([]byte, []int)
Deprecated: Use FieldEntry.ProtoReflect.Descriptor instead.
func (*FieldEntry) GetKey ¶
func (x *FieldEntry) GetKey() string
func (*FieldEntry) GetValue ¶
func (x *FieldEntry) GetValue() *FieldValue
func (*FieldEntry) ProtoMessage ¶
func (*FieldEntry) ProtoMessage()
func (*FieldEntry) ProtoReflect ¶
func (x *FieldEntry) ProtoReflect() protoreflect.Message
func (*FieldEntry) Reset ¶
func (x *FieldEntry) Reset()
func (*FieldEntry) String ¶
func (x *FieldEntry) String() string
type FieldValue ¶
type FieldValue struct {
// Types that are valid to be assigned to Value:
//
// *FieldValue_IntValue
// *FieldValue_FloatValue
// *FieldValue_StringValue
// *FieldValue_BoolValue
Value isFieldValue_Value `protobuf_oneof:"value"`
// contains filtered or unexported fields
}
字段值
Point 的字段值使用 oneof 支持多种数据类型。 存储引擎会根据值的实际类型进行相应的编码和处理。
支持的类型:
- int_value: 64位有符号整数,适用于计数器、ID 等
- float_value: 64位浮点数,适用于温度、电压等连续值
- string_value: 可变长度字符串,适用于状态描述
- bool_value: 布尔值,适用于开关状态
类型说明:
写入时根据值的类型自动选择对应的字段。 查询时根据实际存储的类型返回相应值。
func NewFieldValue ¶
func NewFieldValue(v any) *FieldValue
NewFieldValue 从任何值创建 FieldValue。
支持的类型:int64, float64, string, bool。 如果类型不支持,返回 nil。
func (*FieldValue) Descriptor
deprecated
func (*FieldValue) Descriptor() ([]byte, []int)
Deprecated: Use FieldValue.ProtoReflect.Descriptor instead.
func (*FieldValue) GetBoolValue ¶
func (x *FieldValue) GetBoolValue() bool
func (*FieldValue) GetFloatValue ¶
func (x *FieldValue) GetFloatValue() float64
func (*FieldValue) GetIntValue ¶
func (x *FieldValue) GetIntValue() int64
func (*FieldValue) GetStringValue ¶
func (x *FieldValue) GetStringValue() string
func (*FieldValue) GetValue ¶
func (x *FieldValue) GetValue() isFieldValue_Value
func (*FieldValue) ProtoMessage ¶
func (*FieldValue) ProtoMessage()
func (*FieldValue) ProtoReflect ¶
func (x *FieldValue) ProtoReflect() protoreflect.Message
func (*FieldValue) Reset ¶
func (x *FieldValue) Reset()
func (*FieldValue) String ¶
func (x *FieldValue) String() string
type FieldValue_BoolValue ¶
type FieldValue_BoolValue struct {
BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"`
}
type FieldValue_FloatValue ¶
type FieldValue_FloatValue struct {
FloatValue float64 `protobuf:"fixed64,2,opt,name=float_value,json=floatValue,proto3,oneof"`
}
type FieldValue_IntValue ¶
type FieldValue_IntValue struct {
IntValue int64 `protobuf:"varint,1,opt,name=int_value,json=intValue,proto3,oneof"`
}
type FieldValue_StringValue ¶
type FieldValue_StringValue struct {
StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"`
}
type FilterCondition ¶
type FilterCondition struct {
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
Field string `protobuf:"bytes,2,opt,name=field,proto3" json:"field,omitempty"`
Op FilterOp `protobuf:"varint,3,opt,name=op,proto3,enum=mts.v1.FilterOp" json:"op,omitempty"`
Value *FieldValue `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
// contains filtered or unexported fields
}
过滤条件
func (*FilterCondition) Descriptor
deprecated
func (*FilterCondition) Descriptor() ([]byte, []int)
Deprecated: Use FilterCondition.ProtoReflect.Descriptor instead.
func (*FilterCondition) GetField ¶
func (x *FilterCondition) GetField() string
func (*FilterCondition) GetOp ¶
func (x *FilterCondition) GetOp() FilterOp
func (*FilterCondition) GetTag ¶
func (x *FilterCondition) GetTag() string
func (*FilterCondition) GetValue ¶
func (x *FilterCondition) GetValue() *FieldValue
func (*FilterCondition) ProtoMessage ¶
func (*FilterCondition) ProtoMessage()
func (*FilterCondition) ProtoReflect ¶
func (x *FilterCondition) ProtoReflect() protoreflect.Message
func (*FilterCondition) Reset ¶
func (x *FilterCondition) Reset()
func (*FilterCondition) String ¶
func (x *FilterCondition) String() string
type FilterOp ¶
type FilterOp int32
过滤操作符
func (FilterOp) Descriptor ¶
func (FilterOp) Descriptor() protoreflect.EnumDescriptor
func (FilterOp) EnumDescriptor
deprecated
func (FilterOp) Number ¶
func (x FilterOp) Number() protoreflect.EnumNumber
func (FilterOp) Type ¶
func (FilterOp) Type() protoreflect.EnumType
type FilterSpec ¶
type FilterSpec struct {
Conditions []*FilterCondition `protobuf:"bytes,1,rep,name=conditions,proto3" json:"conditions,omitempty"`
// contains filtered or unexported fields
}
Filter 算子
func (*FilterSpec) Descriptor
deprecated
func (*FilterSpec) Descriptor() ([]byte, []int)
Deprecated: Use FilterSpec.ProtoReflect.Descriptor instead.
func (*FilterSpec) GetConditions ¶
func (x *FilterSpec) GetConditions() []*FilterCondition
func (*FilterSpec) ProtoMessage ¶
func (*FilterSpec) ProtoMessage()
func (*FilterSpec) ProtoReflect ¶
func (x *FilterSpec) ProtoReflect() protoreflect.Message
func (*FilterSpec) Reset ¶
func (x *FilterSpec) Reset()
func (*FilterSpec) String ¶
func (x *FilterSpec) String() string
type GroupBySpec ¶
type GroupBySpec struct {
Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"`
// contains filtered or unexported fields
}
GroupBy 算子
func (*GroupBySpec) Descriptor
deprecated
func (*GroupBySpec) Descriptor() ([]byte, []int)
Deprecated: Use GroupBySpec.ProtoReflect.Descriptor instead.
func (*GroupBySpec) GetTags ¶
func (x *GroupBySpec) GetTags() []string
func (*GroupBySpec) ProtoMessage ¶
func (*GroupBySpec) ProtoMessage()
func (*GroupBySpec) ProtoReflect ¶
func (x *GroupBySpec) ProtoReflect() protoreflect.Message
func (*GroupBySpec) Reset ¶
func (x *GroupBySpec) Reset()
func (*GroupBySpec) String ¶
func (x *GroupBySpec) String() string
type HealthRequest ¶
type HealthRequest struct {
// contains filtered or unexported fields
}
健康检查请求
func (*HealthRequest) Descriptor
deprecated
func (*HealthRequest) Descriptor() ([]byte, []int)
Deprecated: Use HealthRequest.ProtoReflect.Descriptor instead.
func (*HealthRequest) ProtoMessage ¶
func (*HealthRequest) ProtoMessage()
func (*HealthRequest) ProtoReflect ¶
func (x *HealthRequest) ProtoReflect() protoreflect.Message
func (*HealthRequest) Reset ¶
func (x *HealthRequest) Reset()
func (*HealthRequest) String ¶
func (x *HealthRequest) String() string
type HealthResponse ¶
type HealthResponse struct {
Healthy bool `protobuf:"varint,1,opt,name=healthy,proto3" json:"healthy,omitempty"`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
// contains filtered or unexported fields
}
健康检查响应
func (*HealthResponse) Descriptor
deprecated
func (*HealthResponse) Descriptor() ([]byte, []int)
Deprecated: Use HealthResponse.ProtoReflect.Descriptor instead.
func (*HealthResponse) GetHealthy ¶
func (x *HealthResponse) GetHealthy() bool
func (*HealthResponse) GetVersion ¶
func (x *HealthResponse) GetVersion() string
func (*HealthResponse) ProtoMessage ¶
func (*HealthResponse) ProtoMessage()
func (*HealthResponse) ProtoReflect ¶
func (x *HealthResponse) ProtoReflect() protoreflect.Message
func (*HealthResponse) Reset ¶
func (x *HealthResponse) Reset()
func (*HealthResponse) String ¶
func (x *HealthResponse) String() string
type InternalField ¶
type InternalField struct {
Key string
Value *FieldValue
}
InternalField 紧凑字段条目,避免每行分配 map。
func FieldEntryToInternalFields ¶
func FieldEntryToInternalFields(fields []*FieldEntry) []InternalField
FieldEntryToInternalFields 将 []*FieldEntry 转换为 []InternalField(用于 Compaction 路径)。
func MapToInternalFields ¶
func MapToInternalFields(m map[string]*FieldValue) []InternalField
MapToInternalFields 将 map[string]*FieldValue 转换为 []InternalField(用于写路径)。
type InternalPoint ¶
type InternalPoint struct {
Timestamp int64
Fields []InternalField
Sid uint64
}
InternalPoint 内部管线中的数据点,保留用于 compaction 和短暂需要解码字段的场景。
func MemPointToInternal ¶
func MemPointToInternal(mp MemPoint) (InternalPoint, error)
MemPointToInternal 将 MemPoint 解码为 InternalPoint(惰性解码)。
func PointToInternal ¶
func PointToInternal(p *Point, sid uint64) InternalPoint
PointToInternal 将外部 Point 转换为 InternalPoint。
type LimitSpec ¶
type LimitSpec struct {
Offset int64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"`
Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
// contains filtered or unexported fields
}
Limit 算子
func (*LimitSpec) Descriptor
deprecated
func (*LimitSpec) ProtoMessage ¶
func (*LimitSpec) ProtoMessage()
func (*LimitSpec) ProtoReflect ¶
func (x *LimitSpec) ProtoReflect() protoreflect.Message
type ListDatabasesRequest ¶
type ListDatabasesRequest struct {
// contains filtered or unexported fields
}
列出数据库请求
func (*ListDatabasesRequest) Descriptor
deprecated
func (*ListDatabasesRequest) Descriptor() ([]byte, []int)
Deprecated: Use ListDatabasesRequest.ProtoReflect.Descriptor instead.
func (*ListDatabasesRequest) ProtoMessage ¶
func (*ListDatabasesRequest) ProtoMessage()
func (*ListDatabasesRequest) ProtoReflect ¶
func (x *ListDatabasesRequest) ProtoReflect() protoreflect.Message
func (*ListDatabasesRequest) Reset ¶
func (x *ListDatabasesRequest) Reset()
func (*ListDatabasesRequest) String ¶
func (x *ListDatabasesRequest) String() string
type ListDatabasesResponse ¶
type ListDatabasesResponse struct {
Databases []string `protobuf:"bytes,1,rep,name=databases,proto3" json:"databases,omitempty"`
// contains filtered or unexported fields
}
列出数据库响应
func (*ListDatabasesResponse) Descriptor
deprecated
func (*ListDatabasesResponse) Descriptor() ([]byte, []int)
Deprecated: Use ListDatabasesResponse.ProtoReflect.Descriptor instead.
func (*ListDatabasesResponse) GetDatabases ¶
func (x *ListDatabasesResponse) GetDatabases() []string
func (*ListDatabasesResponse) ProtoMessage ¶
func (*ListDatabasesResponse) ProtoMessage()
func (*ListDatabasesResponse) ProtoReflect ¶
func (x *ListDatabasesResponse) ProtoReflect() protoreflect.Message
func (*ListDatabasesResponse) Reset ¶
func (x *ListDatabasesResponse) Reset()
func (*ListDatabasesResponse) String ¶
func (x *ListDatabasesResponse) String() string
type ListMeasurementsRequest ¶
type ListMeasurementsRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
// contains filtered or unexported fields
}
列出 Measurement 请求
func (*ListMeasurementsRequest) Descriptor
deprecated
func (*ListMeasurementsRequest) Descriptor() ([]byte, []int)
Deprecated: Use ListMeasurementsRequest.ProtoReflect.Descriptor instead.
func (*ListMeasurementsRequest) GetDatabase ¶
func (x *ListMeasurementsRequest) GetDatabase() string
func (*ListMeasurementsRequest) ProtoMessage ¶
func (*ListMeasurementsRequest) ProtoMessage()
func (*ListMeasurementsRequest) ProtoReflect ¶
func (x *ListMeasurementsRequest) ProtoReflect() protoreflect.Message
func (*ListMeasurementsRequest) Reset ¶
func (x *ListMeasurementsRequest) Reset()
func (*ListMeasurementsRequest) String ¶
func (x *ListMeasurementsRequest) String() string
type ListMeasurementsResponse ¶
type ListMeasurementsResponse struct {
Measurements []string `protobuf:"bytes,1,rep,name=measurements,proto3" json:"measurements,omitempty"`
// contains filtered or unexported fields
}
列出 Measurement 响应
func (*ListMeasurementsResponse) Descriptor
deprecated
func (*ListMeasurementsResponse) Descriptor() ([]byte, []int)
Deprecated: Use ListMeasurementsResponse.ProtoReflect.Descriptor instead.
func (*ListMeasurementsResponse) GetMeasurements ¶
func (x *ListMeasurementsResponse) GetMeasurements() []string
func (*ListMeasurementsResponse) ProtoMessage ¶
func (*ListMeasurementsResponse) ProtoMessage()
func (*ListMeasurementsResponse) ProtoReflect ¶
func (x *ListMeasurementsResponse) ProtoReflect() protoreflect.Message
func (*ListMeasurementsResponse) Reset ¶
func (x *ListMeasurementsResponse) Reset()
func (*ListMeasurementsResponse) String ¶
func (x *ListMeasurementsResponse) String() string
type MTSClient ¶
type MTSClient interface {
// 单点写入
//
// 将单个数据点写入时序数据库。
// 数据首先写入 WAL,然后写入 MemTable。
Write(ctx context.Context, in *WriteRequest, opts ...grpc.CallOption) (*WriteResponse, error)
// 批量写入
//
// 批量写入多个数据点,吞吐量通常比单点写入高。
// 批量写入不是原子操作,部分失败不会回滚已写入的点。
WriteBatch(ctx context.Context, in *WriteBatchRequest, opts ...grpc.CallOption) (*WriteBatchResponse, error)
// 范围查询
//
// 查询指定时间范围内的数据,支持字段过滤、标签过滤和分页。
// 数据按时间戳升序返回。
QueryRange(ctx context.Context, in *QueryRangeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Row], error)
// 列出 Measurement
//
// 返回指定数据库中的所有 Measurement 名称。
// 如果数据库不存在,返回空列表。
ListMeasurements(ctx context.Context, in *ListMeasurementsRequest, opts ...grpc.CallOption) (*ListMeasurementsResponse, error)
// 创建 Measurement
//
// 在指定数据库中创建一个新的 Measurement。
// 如果数据库不存在,会自动创建。
// 如果 Measurement 已存在,不会返回错误。
CreateMeasurement(ctx context.Context, in *CreateMeasurementRequest, opts ...grpc.CallOption) (*CreateMeasurementResponse, error)
// 删除 Measurement
//
// 删除指定的 Measurement 及其所有元数据。
// 注意:磁盘上的数据文件不会被立即删除。
DropMeasurement(ctx context.Context, in *DropMeasurementRequest, opts ...grpc.CallOption) (*DropMeasurementResponse, error)
// 列出数据库
//
// 返回所有数据库名称列表。
ListDatabases(ctx context.Context, in *ListDatabasesRequest, opts ...grpc.CallOption) (*ListDatabasesResponse, error)
// 创建数据库
//
// 创建一个新的数据库。
// 如果数据库已存在,不会返回错误。
CreateDatabase(ctx context.Context, in *CreateDatabaseRequest, opts ...grpc.CallOption) (*CreateDatabaseResponse, error)
// 删除数据库
//
// 删除指定的数据库及其所有 Measurement。
// 警告:此操作会永久删除元数据,且不可恢复。
DropDatabase(ctx context.Context, in *DropDatabaseRequest, opts ...grpc.CallOption) (*DropDatabaseResponse, error)
// 健康检查
//
// 返回服务的健康状态,用于负载均衡器健康检查和监控。
Health(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*HealthResponse, error)
}
MTSClient is the client API for MTS service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
MTS 时序数据库服务 ¶
提供完整的时序数据库远程访问接口,包括:
- 数据写入:单点写入、批量写入
- 数据查询:范围查询、分页支持
- 元数据管理:数据库和 Measurement 的增删改查
- 健康检查:服务状态查询
并发安全:
所有 RPC 方法都可以从多个 goroutine 并发调用。 gRPC 框架保证每个请求在独立的 goroutine 中处理。
func NewMTSClient ¶
func NewMTSClient(cc grpc.ClientConnInterface) MTSClient
type MTSServer ¶
type MTSServer interface {
// 单点写入
//
// 将单个数据点写入时序数据库。
// 数据首先写入 WAL,然后写入 MemTable。
Write(context.Context, *WriteRequest) (*WriteResponse, error)
// 批量写入
//
// 批量写入多个数据点,吞吐量通常比单点写入高。
// 批量写入不是原子操作,部分失败不会回滚已写入的点。
WriteBatch(context.Context, *WriteBatchRequest) (*WriteBatchResponse, error)
// 范围查询
//
// 查询指定时间范围内的数据,支持字段过滤、标签过滤和分页。
// 数据按时间戳升序返回。
QueryRange(*QueryRangeRequest, grpc.ServerStreamingServer[Row]) error
// 列出 Measurement
//
// 返回指定数据库中的所有 Measurement 名称。
// 如果数据库不存在,返回空列表。
ListMeasurements(context.Context, *ListMeasurementsRequest) (*ListMeasurementsResponse, error)
// 创建 Measurement
//
// 在指定数据库中创建一个新的 Measurement。
// 如果数据库不存在,会自动创建。
// 如果 Measurement 已存在,不会返回错误。
CreateMeasurement(context.Context, *CreateMeasurementRequest) (*CreateMeasurementResponse, error)
// 删除 Measurement
//
// 删除指定的 Measurement 及其所有元数据。
// 注意:磁盘上的数据文件不会被立即删除。
DropMeasurement(context.Context, *DropMeasurementRequest) (*DropMeasurementResponse, error)
// 列出数据库
//
// 返回所有数据库名称列表。
ListDatabases(context.Context, *ListDatabasesRequest) (*ListDatabasesResponse, error)
// 创建数据库
//
// 创建一个新的数据库。
// 如果数据库已存在,不会返回错误。
CreateDatabase(context.Context, *CreateDatabaseRequest) (*CreateDatabaseResponse, error)
// 删除数据库
//
// 删除指定的数据库及其所有 Measurement。
// 警告:此操作会永久删除元数据,且不可恢复。
DropDatabase(context.Context, *DropDatabaseRequest) (*DropDatabaseResponse, error)
// 健康检查
//
// 返回服务的健康状态,用于负载均衡器健康检查和监控。
Health(context.Context, *HealthRequest) (*HealthResponse, error)
}
MTSServer is the server API for MTS service. All implementations should embed UnimplementedMTSServer for forward compatibility.
MTS 时序数据库服务 ¶
提供完整的时序数据库远程访问接口,包括:
- 数据写入:单点写入、批量写入
- 数据查询:范围查询、分页支持
- 元数据管理:数据库和 Measurement 的增删改查
- 健康检查:服务状态查询
并发安全:
所有 RPC 方法都可以从多个 goroutine 并发调用。 gRPC 框架保证每个请求在独立的 goroutine 中处理。
type MTS_QueryRangeClient ¶
type MTS_QueryRangeClient = grpc.ServerStreamingClient[Row]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type MTS_QueryRangeServer ¶
type MTS_QueryRangeServer = grpc.ServerStreamingServer[Row]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type MemPoint ¶
type MemPoint struct {
Database string
Measurement string
Timestamp int64
Sid uint64
FieldData []byte
}
MemPoint 是 MemTable 中存储的紧凑数据点。 FieldData 使用 WAL v2 格式的字段部分(不含 version/ts/sid 头), 避免 []InternalField 切片分配。
内存布局:FieldData 是单块连续内存,对 GC 友好。
func PointToMemPoint ¶
PointToMemPoint 将外部 Point 直接序列化为 MemPoint(写入路径入口)。
type MemTableConfig ¶
type MemTableConfig struct {
// 触发刷盘的内存大小阈值(字节),默认 64MB
FlushMemorySize int64 `protobuf:"varint,1,opt,name=flush_memory_size,json=flushMemorySize,proto3" json:"flush_memory_size,omitempty"`
// 触发刷盘的条目数阈值,默认 50000
FlushPointCount int32 `protobuf:"varint,2,opt,name=flush_point_count,json=flushPointCount,proto3" json:"flush_point_count,omitempty"`
// 触发刷盘的空闲时间阈值(纳秒),默认 60秒
FlushIdleNanos int64 `protobuf:"varint,3,opt,name=flush_idle_nanos,json=flushIdleNanos,proto3" json:"flush_idle_nanos,omitempty"`
// contains filtered or unexported fields
}
内存表配置
内存表(MemTable)是写入缓冲区,数据先写入 MemTable, 当满足任一条件时刷新到 SSTable。
刷新条件(满足任一即触发):
- flush_memory_size: 内存占用(估算)达到此值
- flush_point_count: 条目数达到此值
- flush_idle_nanos: 超过此空闲时间没有新数据写入(纳秒)
性能调优建议:
增加 flush_memory_size 可以减少刷盘频率,但会增加内存占用和恢复时间。 减少 flush_idle_nanos 可以更快释放内存,但会增加小文件数量。 flush_point_count 主要作为后备保护。
默认值:
- flush_memory_size: 64MB
- flush_point_count: 50000
- flush_idle_nanos: 60秒(60000000000纳秒)
func DefaultMemTableConfig ¶
func DefaultMemTableConfig() *MemTableConfig
DefaultMemTableConfig 返回默认的 MemTableConfig。
默认配置:
- FlushMemorySize: 64MB
- FlushPointCount: 50000
- FlushIdle: 1分钟
func (*MemTableConfig) Descriptor
deprecated
func (*MemTableConfig) Descriptor() ([]byte, []int)
Deprecated: Use MemTableConfig.ProtoReflect.Descriptor instead.
func (*MemTableConfig) GetFlushIdle ¶
func (c *MemTableConfig) GetFlushIdle() time.Duration
GetFlushIdle 返回 FlushIdleNanos 的 time.Duration 形式。
func (*MemTableConfig) GetFlushIdleNanos ¶
func (x *MemTableConfig) GetFlushIdleNanos() int64
func (*MemTableConfig) GetFlushMemorySize ¶
func (x *MemTableConfig) GetFlushMemorySize() int64
func (*MemTableConfig) GetFlushPointCount ¶
func (x *MemTableConfig) GetFlushPointCount() int32
func (*MemTableConfig) ProtoMessage ¶
func (*MemTableConfig) ProtoMessage()
func (*MemTableConfig) ProtoReflect ¶
func (x *MemTableConfig) ProtoReflect() protoreflect.Message
func (*MemTableConfig) Reset ¶
func (x *MemTableConfig) Reset()
func (*MemTableConfig) SetFlushIdle ¶
func (c *MemTableConfig) SetFlushIdle(d time.Duration)
SetFlushIdle 设置 FlushIdleNanos。
func (*MemTableConfig) String ¶
func (x *MemTableConfig) String() string
type OperatorSpec ¶
type OperatorSpec struct {
// Types that are valid to be assigned to Op:
//
// *OperatorSpec_Scan
// *OperatorSpec_Filter
// *OperatorSpec_GroupBy
// *OperatorSpec_Aggregate
// *OperatorSpec_Sort
// *OperatorSpec_Project
// *OperatorSpec_Limit
Op isOperatorSpec_Op `protobuf_oneof:"op"`
// contains filtered or unexported fields
}
算子规格(oneof 实现多选一)
func (*OperatorSpec) Descriptor
deprecated
func (*OperatorSpec) Descriptor() ([]byte, []int)
Deprecated: Use OperatorSpec.ProtoReflect.Descriptor instead.
func (*OperatorSpec) GetAggregate ¶
func (x *OperatorSpec) GetAggregate() *AggregateSpec
func (*OperatorSpec) GetFilter ¶
func (x *OperatorSpec) GetFilter() *FilterSpec
func (*OperatorSpec) GetGroupBy ¶
func (x *OperatorSpec) GetGroupBy() *GroupBySpec
func (*OperatorSpec) GetLimit ¶
func (x *OperatorSpec) GetLimit() *LimitSpec
func (*OperatorSpec) GetOp ¶
func (x *OperatorSpec) GetOp() isOperatorSpec_Op
func (*OperatorSpec) GetProject ¶
func (x *OperatorSpec) GetProject() *ProjectSpec
func (*OperatorSpec) GetScan ¶
func (x *OperatorSpec) GetScan() *ScanSpec
func (*OperatorSpec) GetSort ¶
func (x *OperatorSpec) GetSort() *SortSpec
func (*OperatorSpec) ProtoMessage ¶
func (*OperatorSpec) ProtoMessage()
func (*OperatorSpec) ProtoReflect ¶
func (x *OperatorSpec) ProtoReflect() protoreflect.Message
func (*OperatorSpec) Reset ¶
func (x *OperatorSpec) Reset()
func (*OperatorSpec) String ¶
func (x *OperatorSpec) String() string
type OperatorSpec_Aggregate ¶
type OperatorSpec_Aggregate struct {
Aggregate *AggregateSpec `protobuf:"bytes,4,opt,name=aggregate,proto3,oneof"`
}
type OperatorSpec_Filter ¶
type OperatorSpec_Filter struct {
Filter *FilterSpec `protobuf:"bytes,2,opt,name=filter,proto3,oneof"`
}
type OperatorSpec_GroupBy ¶
type OperatorSpec_GroupBy struct {
GroupBy *GroupBySpec `protobuf:"bytes,3,opt,name=group_by,json=groupBy,proto3,oneof"`
}
type OperatorSpec_Limit ¶
type OperatorSpec_Limit struct {
Limit *LimitSpec `protobuf:"bytes,7,opt,name=limit,proto3,oneof"`
}
type OperatorSpec_Project ¶
type OperatorSpec_Project struct {
Project *ProjectSpec `protobuf:"bytes,6,opt,name=project,proto3,oneof"`
}
type OperatorSpec_Scan ¶
type OperatorSpec_Scan struct {
Scan *ScanSpec `protobuf:"bytes,1,opt,name=scan,proto3,oneof"`
}
type OperatorSpec_Sort ¶
type OperatorSpec_Sort struct {
Sort *SortSpec `protobuf:"bytes,5,opt,name=sort,proto3,oneof"`
}
type Point ¶
type Point struct {
// 数据库名称
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
// 测量名称(类似表名)
Measurement string `protobuf:"bytes,2,opt,name=measurement,proto3" json:"measurement,omitempty"`
// 标签键值对,用于标识时间序列
Tags map[string]string `` /* 135-byte string literal not displayed */
// 时间戳,纳秒级 Unix 时间戳
Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// 字段值,存储实际的数据
Fields map[string]*FieldValue `` /* 139-byte string literal not displayed */
// contains filtered or unexported fields
}
数据点
Point 是写入时序数据库的基本数据单元。 每个 Point 代表时间序列中的一个数据点。
必需字段:
- database: 数据库名称,用于隔离不同业务的数据
- measurement: 测量名称,类似关系数据库的表名
- timestamp: 纳秒级 Unix 时间戳
- tags: 标签键值对,用于标识时间序列
- fields: 字段值,存储实际的数据
标签与字段的区别:
标签用于索引和分组,会被存储在 Series Key 中,查询效率高。 字段存储实际数据值,不会被索引,但可以存储大量不同的值。
最佳实践:
标签建议使用 host, region, service 等维度信息。 时间戳推荐使用 time.Now().UnixNano() 获取。
func (*Point) Descriptor
deprecated
func (*Point) GetDatabase ¶
func (*Point) GetFields ¶
func (x *Point) GetFields() map[string]*FieldValue
func (*Point) GetMeasurement ¶
func (*Point) GetTimestamp ¶
func (*Point) ProtoMessage ¶
func (*Point) ProtoMessage()
func (*Point) ProtoReflect ¶
func (x *Point) ProtoReflect() protoreflect.Message
type PointRow ¶
type PointRow struct {
// Series ID,用于内部标识唯一的标签组合
Sid uint64 `protobuf:"varint,1,opt,name=sid,proto3" json:"sid,omitempty"`
// 时间戳
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// 标签键值对
Tags map[string]string `` /* 135-byte string literal not displayed */
// 字段值(按名访问使用 GetField 辅助方法)
Fields []*FieldEntry `protobuf:"bytes,4,rep,name=fields,proto3" json:"fields,omitempty"`
// contains filtered or unexported fields
}
查询结果行
PointRow 是查询结果的单行数据。 相比 Point,PointRow 增加了 SID 字段用于内部标识。
字段说明:
- sid: Series ID,内部生成的序列标识符(从1开始递增)
- timestamp: 数据点的时间戳(纳秒)
- tags: 标签键值对
- fields: 字段值
SID 说明:
SID 由存储引擎为每个唯一的标签组合分配。 相同的标签组合始终对应同一个 SID。 用户通常不需要直接使用此字段。
func (*PointRow) Descriptor
deprecated
func (*PointRow) GetFieldValue ¶
func (p *PointRow) GetFieldValue(name string) *FieldValue
GetFieldValue 获取 PointRow 的字段值(返回 *FieldValue,方便链式调用 GetFloatValue 等)。
func (*PointRow) GetFields ¶
func (x *PointRow) GetFields() []*FieldEntry
func (*PointRow) GetTimestamp ¶
func (*PointRow) ProtoMessage ¶
func (*PointRow) ProtoMessage()
func (*PointRow) ProtoReflect ¶
func (x *PointRow) ProtoReflect() protoreflect.Message
type ProjectSpec ¶
type ProjectSpec struct {
Fields []string `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty"`
// contains filtered or unexported fields
}
Project 算子
func (*ProjectSpec) Descriptor
deprecated
func (*ProjectSpec) Descriptor() ([]byte, []int)
Deprecated: Use ProjectSpec.ProtoReflect.Descriptor instead.
func (*ProjectSpec) GetFields ¶
func (x *ProjectSpec) GetFields() []string
func (*ProjectSpec) ProtoMessage ¶
func (*ProjectSpec) ProtoMessage()
func (*ProjectSpec) ProtoReflect ¶
func (x *ProjectSpec) ProtoReflect() protoreflect.Message
func (*ProjectSpec) Reset ¶
func (x *ProjectSpec) Reset()
func (*ProjectSpec) String ¶
func (x *ProjectSpec) String() string
type QueryPlan ¶
type QueryPlan struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
Measurement string `protobuf:"bytes,2,opt,name=measurement,proto3" json:"measurement,omitempty"`
StartTime int64 `protobuf:"varint,3,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
EndTime int64 `protobuf:"varint,4,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
Ops []*OperatorSpec `protobuf:"bytes,5,rep,name=ops,proto3" json:"ops,omitempty"`
// contains filtered or unexported fields
}
查询计划
func (*QueryPlan) Descriptor
deprecated
func (*QueryPlan) GetDatabase ¶
func (*QueryPlan) GetEndTime ¶
func (*QueryPlan) GetMeasurement ¶
func (*QueryPlan) GetOps ¶
func (x *QueryPlan) GetOps() []*OperatorSpec
func (*QueryPlan) GetStartTime ¶
func (*QueryPlan) ProtoMessage ¶
func (*QueryPlan) ProtoMessage()
func (*QueryPlan) ProtoReflect ¶
func (x *QueryPlan) ProtoReflect() protoreflect.Message
type QueryRangeRequest ¶
type QueryRangeRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
Measurement string `protobuf:"bytes,2,opt,name=measurement,proto3" json:"measurement,omitempty"`
StartTime int64 `protobuf:"varint,3,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
EndTime int64 `protobuf:"varint,4,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
Fields []string `protobuf:"bytes,5,rep,name=fields,proto3" json:"fields,omitempty"`
Tags map[string]string `` /* 135-byte string literal not displayed */
Offset int64 `protobuf:"varint,7,opt,name=offset,proto3" json:"offset,omitempty"`
Limit int64 `protobuf:"varint,8,opt,name=limit,proto3" json:"limit,omitempty"`
// 降采样查询窗口(纳秒),0 或不设置表示查询原始数据
DownsampleWindowNanos int64 `` /* 127-byte string literal not displayed */
// contains filtered or unexported fields
}
范围查询请求
func (*QueryRangeRequest) Descriptor
deprecated
func (*QueryRangeRequest) Descriptor() ([]byte, []int)
Deprecated: Use QueryRangeRequest.ProtoReflect.Descriptor instead.
func (*QueryRangeRequest) GetDatabase ¶
func (x *QueryRangeRequest) GetDatabase() string
func (*QueryRangeRequest) GetDownsampleWindowNanos ¶
func (x *QueryRangeRequest) GetDownsampleWindowNanos() int64
func (*QueryRangeRequest) GetEndTime ¶
func (x *QueryRangeRequest) GetEndTime() int64
func (*QueryRangeRequest) GetFields ¶
func (x *QueryRangeRequest) GetFields() []string
func (*QueryRangeRequest) GetLimit ¶
func (x *QueryRangeRequest) GetLimit() int64
func (*QueryRangeRequest) GetMeasurement ¶
func (x *QueryRangeRequest) GetMeasurement() string
func (*QueryRangeRequest) GetOffset ¶
func (x *QueryRangeRequest) GetOffset() int64
func (*QueryRangeRequest) GetStartTime ¶
func (x *QueryRangeRequest) GetStartTime() int64
func (*QueryRangeRequest) GetTags ¶
func (x *QueryRangeRequest) GetTags() map[string]string
func (*QueryRangeRequest) ProtoMessage ¶
func (*QueryRangeRequest) ProtoMessage()
func (*QueryRangeRequest) ProtoReflect ¶
func (x *QueryRangeRequest) ProtoReflect() protoreflect.Message
func (*QueryRangeRequest) Reset ¶
func (x *QueryRangeRequest) Reset()
func (*QueryRangeRequest) String ¶
func (x *QueryRangeRequest) String() string
type QueryRangeResponse ¶
type QueryRangeResponse struct {
Rows []*Row `protobuf:"bytes,1,rep,name=rows,proto3" json:"rows,omitempty"`
HasMore bool `protobuf:"varint,2,opt,name=has_more,json=hasMore,proto3" json:"has_more,omitempty"`
// contains filtered or unexported fields
}
范围查询响应
封装范围查询的结果,包含所有查询到的数据行。
func (*QueryRangeResponse) Descriptor
deprecated
func (*QueryRangeResponse) Descriptor() ([]byte, []int)
Deprecated: Use QueryRangeResponse.ProtoReflect.Descriptor instead.
func (*QueryRangeResponse) GetHasMore ¶
func (x *QueryRangeResponse) GetHasMore() bool
func (*QueryRangeResponse) GetRows ¶
func (x *QueryRangeResponse) GetRows() []*Row
func (*QueryRangeResponse) ProtoMessage ¶
func (*QueryRangeResponse) ProtoMessage()
func (*QueryRangeResponse) ProtoReflect ¶
func (x *QueryRangeResponse) ProtoReflect() protoreflect.Message
func (*QueryRangeResponse) Reset ¶
func (x *QueryRangeResponse) Reset()
func (*QueryRangeResponse) String ¶
func (x *QueryRangeResponse) String() string
type Row ¶
type Row struct {
Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Tags map[string]string `` /* 135-byte string literal not displayed */
Fields []*FieldEntry `protobuf:"bytes,3,rep,name=fields,proto3" json:"fields,omitempty"`
// contains filtered or unexported fields
}
一行数据(用于查询响应)
func (*Row) Descriptor
deprecated
func (*Row) GetFieldValue ¶
func (r *Row) GetFieldValue(name string) *FieldValue
GetFieldValue 获取 Row 的字段值(返回 *FieldValue)。
func (*Row) GetFields ¶
func (x *Row) GetFields() []*FieldEntry
func (*Row) GetTimestamp ¶
func (*Row) ProtoMessage ¶
func (*Row) ProtoMessage()
func (*Row) ProtoReflect ¶
func (x *Row) ProtoReflect() protoreflect.Message
type ScanSpec ¶
type ScanSpec struct {
DownsampleWindowNanos int64 `` /* 127-byte string literal not displayed */
// contains filtered or unexported fields
}
Scan 算子
func (*ScanSpec) Descriptor
deprecated
func (*ScanSpec) GetDownsampleWindowNanos ¶
func (*ScanSpec) ProtoMessage ¶
func (*ScanSpec) ProtoMessage()
func (*ScanSpec) ProtoReflect ¶
func (x *ScanSpec) ProtoReflect() protoreflect.Message
type SortDirection ¶
type SortDirection int32
排序方向
const ( SortDirection_ASC SortDirection = 0 SortDirection_DESC SortDirection = 1 )
func (SortDirection) Descriptor ¶
func (SortDirection) Descriptor() protoreflect.EnumDescriptor
func (SortDirection) Enum ¶
func (x SortDirection) Enum() *SortDirection
func (SortDirection) EnumDescriptor
deprecated
func (SortDirection) EnumDescriptor() ([]byte, []int)
Deprecated: Use SortDirection.Descriptor instead.
func (SortDirection) Number ¶
func (x SortDirection) Number() protoreflect.EnumNumber
func (SortDirection) String ¶
func (x SortDirection) String() string
func (SortDirection) Type ¶
func (SortDirection) Type() protoreflect.EnumType
type SortField ¶
type SortField struct {
Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"`
Direction SortDirection `protobuf:"varint,2,opt,name=direction,proto3,enum=mts.v1.SortDirection" json:"direction,omitempty"`
// contains filtered or unexported fields
}
排序字段
func (*SortField) Descriptor
deprecated
func (*SortField) GetDirection ¶
func (x *SortField) GetDirection() SortDirection
func (*SortField) ProtoMessage ¶
func (*SortField) ProtoMessage()
func (*SortField) ProtoReflect ¶
func (x *SortField) ProtoReflect() protoreflect.Message
type SortSpec ¶
type SortSpec struct {
Fields []*SortField `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty"`
// contains filtered or unexported fields
}
Sort 算子
func (*SortSpec) Descriptor
deprecated
func (*SortSpec) ProtoMessage ¶
func (*SortSpec) ProtoMessage()
func (*SortSpec) ProtoReflect ¶
func (x *SortSpec) ProtoReflect() protoreflect.Message
type UnimplementedMTSServer ¶
type UnimplementedMTSServer struct{}
UnimplementedMTSServer should be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedMTSServer) CreateDatabase ¶
func (UnimplementedMTSServer) CreateDatabase(context.Context, *CreateDatabaseRequest) (*CreateDatabaseResponse, error)
func (UnimplementedMTSServer) CreateMeasurement ¶
func (UnimplementedMTSServer) CreateMeasurement(context.Context, *CreateMeasurementRequest) (*CreateMeasurementResponse, error)
func (UnimplementedMTSServer) DropDatabase ¶
func (UnimplementedMTSServer) DropDatabase(context.Context, *DropDatabaseRequest) (*DropDatabaseResponse, error)
func (UnimplementedMTSServer) DropMeasurement ¶
func (UnimplementedMTSServer) DropMeasurement(context.Context, *DropMeasurementRequest) (*DropMeasurementResponse, error)
func (UnimplementedMTSServer) Health ¶
func (UnimplementedMTSServer) Health(context.Context, *HealthRequest) (*HealthResponse, error)
func (UnimplementedMTSServer) ListDatabases ¶
func (UnimplementedMTSServer) ListDatabases(context.Context, *ListDatabasesRequest) (*ListDatabasesResponse, error)
func (UnimplementedMTSServer) ListMeasurements ¶
func (UnimplementedMTSServer) ListMeasurements(context.Context, *ListMeasurementsRequest) (*ListMeasurementsResponse, error)
func (UnimplementedMTSServer) QueryRange ¶
func (UnimplementedMTSServer) QueryRange(*QueryRangeRequest, grpc.ServerStreamingServer[Row]) error
func (UnimplementedMTSServer) Write ¶
func (UnimplementedMTSServer) Write(context.Context, *WriteRequest) (*WriteResponse, error)
func (UnimplementedMTSServer) WriteBatch ¶
func (UnimplementedMTSServer) WriteBatch(context.Context, *WriteBatchRequest) (*WriteBatchResponse, error)
type UnsafeMTSServer ¶
type UnsafeMTSServer interface {
// contains filtered or unexported methods
}
UnsafeMTSServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MTSServer will result in compilation errors.
type WriteBatchRequest ¶
type WriteBatchRequest struct {
Points []*WriteRequest `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"`
// contains filtered or unexported fields
}
批量写入请求
func (*WriteBatchRequest) Descriptor
deprecated
func (*WriteBatchRequest) Descriptor() ([]byte, []int)
Deprecated: Use WriteBatchRequest.ProtoReflect.Descriptor instead.
func (*WriteBatchRequest) GetPoints ¶
func (x *WriteBatchRequest) GetPoints() []*WriteRequest
func (*WriteBatchRequest) ProtoMessage ¶
func (*WriteBatchRequest) ProtoMessage()
func (*WriteBatchRequest) ProtoReflect ¶
func (x *WriteBatchRequest) ProtoReflect() protoreflect.Message
func (*WriteBatchRequest) Reset ¶
func (x *WriteBatchRequest) Reset()
func (*WriteBatchRequest) String ¶
func (x *WriteBatchRequest) String() string
type WriteBatchResponse ¶
type WriteBatchResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
Count int32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
// contains filtered or unexported fields
}
批量写入响应
func (*WriteBatchResponse) Descriptor
deprecated
func (*WriteBatchResponse) Descriptor() ([]byte, []int)
Deprecated: Use WriteBatchResponse.ProtoReflect.Descriptor instead.
func (*WriteBatchResponse) GetCount ¶
func (x *WriteBatchResponse) GetCount() int32
func (*WriteBatchResponse) GetError ¶
func (x *WriteBatchResponse) GetError() string
func (*WriteBatchResponse) GetSuccess ¶
func (x *WriteBatchResponse) GetSuccess() bool
func (*WriteBatchResponse) ProtoMessage ¶
func (*WriteBatchResponse) ProtoMessage()
func (*WriteBatchResponse) ProtoReflect ¶
func (x *WriteBatchResponse) ProtoReflect() protoreflect.Message
func (*WriteBatchResponse) Reset ¶
func (x *WriteBatchResponse) Reset()
func (*WriteBatchResponse) String ¶
func (x *WriteBatchResponse) String() string
type WriteRequest ¶
type WriteRequest struct {
Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
Measurement string `protobuf:"bytes,2,opt,name=measurement,proto3" json:"measurement,omitempty"`
Tags map[string]string `` /* 135-byte string literal not displayed */
Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Fields map[string]*FieldValue `` /* 139-byte string literal not displayed */
// contains filtered or unexported fields
}
写入请求
func (*WriteRequest) Descriptor
deprecated
func (*WriteRequest) Descriptor() ([]byte, []int)
Deprecated: Use WriteRequest.ProtoReflect.Descriptor instead.
func (*WriteRequest) GetDatabase ¶
func (x *WriteRequest) GetDatabase() string
func (*WriteRequest) GetFields ¶
func (x *WriteRequest) GetFields() map[string]*FieldValue
func (*WriteRequest) GetMeasurement ¶
func (x *WriteRequest) GetMeasurement() string
func (*WriteRequest) GetTags ¶
func (x *WriteRequest) GetTags() map[string]string
func (*WriteRequest) GetTimestamp ¶
func (x *WriteRequest) GetTimestamp() int64
func (*WriteRequest) ProtoMessage ¶
func (*WriteRequest) ProtoMessage()
func (*WriteRequest) ProtoReflect ¶
func (x *WriteRequest) ProtoReflect() protoreflect.Message
func (*WriteRequest) Reset ¶
func (x *WriteRequest) Reset()
func (*WriteRequest) String ¶
func (x *WriteRequest) String() string
type WriteResponse ¶
type WriteResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
// contains filtered or unexported fields
}
写入响应
func (*WriteResponse) Descriptor
deprecated
func (*WriteResponse) Descriptor() ([]byte, []int)
Deprecated: Use WriteResponse.ProtoReflect.Descriptor instead.
func (*WriteResponse) GetError ¶
func (x *WriteResponse) GetError() string
func (*WriteResponse) GetSuccess ¶
func (x *WriteResponse) GetSuccess() bool
func (*WriteResponse) ProtoMessage ¶
func (*WriteResponse) ProtoMessage()
func (*WriteResponse) ProtoReflect ¶
func (x *WriteResponse) ProtoReflect() protoreflect.Message
func (*WriteResponse) Reset ¶
func (x *WriteResponse) Reset()
func (*WriteResponse) String ¶
func (x *WriteResponse) String() string