systemcatalog

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIllegalValue = fmt.Errorf("illegal value for data type conversion")

ErrIllegalValue represents an illegal type conversion request for the given value

Functions

func BinaryMarshall

func BinaryMarshall(buffer encoding.WriteBuffer, oid uint32, value any) error

func BinaryUnmarshall

func BinaryUnmarshall(buffer encoding.ReadBuffer, oid uint32) (value any, err error)

func IsChunkEvent

func IsChunkEvent(relation *pgtypes.RelationMessage) bool

IsChunkEvent returns true if the given relation represents a chunk system catalog entry, otherwise false

func IsContinuousAggregateHypertable

func IsContinuousAggregateHypertable(hypertableName string) bool

IsContinuousAggregateHypertable returns true if the given hypertable name is a backing hypertable for a continuous aggregate, otherwise false

func IsHypertableEvent

func IsHypertableEvent(relation *pgtypes.RelationMessage) bool

IsHypertableEvent returns true if the given relation represents a hypertable system catalog entry, otherwise false

func MakeRelationKey

func MakeRelationKey(schemaName, tableName string) string

Types

type BinaryMarshaller

type BinaryMarshaller func(buffer encoding.WriteBuffer, oid uint32, value any) error

type BinaryUnmarshaller

type BinaryUnmarshaller func(buffer encoding.ReadBuffer, oid uint32) (value any, err error)

type Chunk

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

func NewChunk

func NewChunk(id, hypertableId int32, schemaName, tableName string, dropped bool,
	status int32, compressedChunkId *int32) *Chunk

func (*Chunk) ApplyChanges

func (c *Chunk) ApplyChanges(schemaName, tableName string, dropped bool,
	status int32, compressedChunkId *int32) (*Chunk, map[string]string)

func (Chunk) CanonicalName

func (bse Chunk) CanonicalName() string

func (*Chunk) CompressedChunkId

func (c *Chunk) CompressedChunkId() *int32

func (*Chunk) Dropped

func (c *Chunk) Dropped() bool

func (*Chunk) HypertableId

func (c *Chunk) HypertableId() int32

func (*Chunk) Id

func (c *Chunk) Id() int32

func (*Chunk) IsCompressed

func (c *Chunk) IsCompressed() bool

func (*Chunk) IsPartiallyCompressed

func (c *Chunk) IsPartiallyCompressed() bool

func (Chunk) SchemaName

func (bse Chunk) SchemaName() string

func (*Chunk) Status

func (c *Chunk) Status() int32

func (*Chunk) String added in v0.0.10

func (c *Chunk) String() string

func (Chunk) TableName

func (bse Chunk) TableName() string

type Column

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

Column represents a column from a hypertable or index

func NewColumn

func NewColumn(name string, dataType uint32, typeName string, nullable bool, defaultValue *string) Column

NewColumn instantiates a new Column instance which isn't part of any index. This method is a shorthand version of NewIndexColumn

func NewIndexColumn

func NewIndexColumn(name string, dataType uint32, typeName string, nullable, primaryKey bool,
	keySeq *int, defaultValue *string, isReplicaIdent bool, indexName *string,
	sortOrder IndexSortOrder, nullsOrder IndexNullsOrder,
	dimension bool, dimAligned bool, dimType *string, dimSeq *int) Column

NewIndexColumn instantiates a new Column instance

func (Column) DataType

func (c Column) DataType() uint32

DataType returns the PostgreSQL OID of the column

func (Column) DefaultValue

func (c Column) DefaultValue() *string

DefaultValue returns the default value of the column, otherwise nil if no default value is defined

func (Column) DimensionType

func (c Column) DimensionType() *string

DimensionType returns the type (`space` or `time`) of the dimension. If not a dimension, this function returns nil.

func (Column) IsDimension

func (c Column) IsDimension() bool

IsDimension returns true if the column is used as a dimension of the hypertable

func (Column) IsDimensionAligned

func (c Column) IsDimensionAligned() bool

IsDimensionAligned returns true if the range of the dimension is aligned

func (Column) IsNullable

func (c Column) IsNullable() bool

IsNullable returns true if the column is nullable

func (Column) IsPrimaryKey

func (c Column) IsPrimaryKey() bool

IsPrimaryKey returns true if the columns is part of a primary key index

func (Column) IsReplicaIdent

func (c Column) IsReplicaIdent() bool

IsReplicaIdent returns true if the columns is part of a replica identity index

func (Column) Name

func (c Column) Name() string

Name returns the column name

func (Column) String added in v0.0.10

func (c Column) String() string

func (Column) TypeName

func (c Column) TypeName() string

TypeName returns the data type name of the column

type Columns

type Columns []Column

Columns represents a collection of columns which may or may not represent an index

func (Columns) HasPrimaryKey

func (c Columns) HasPrimaryKey() bool

HasPrimaryKey returns true if the collection of columns contains one or more primary key column(s)

func (Columns) HasReplicaIdentity

func (c Columns) HasReplicaIdentity() bool

HasReplicaIdentity returns true if the collection of columns contains one or more replica identity column(s)

func (Columns) PrimaryKeyIndex

func (c Columns) PrimaryKeyIndex() (index *Index, present bool)

PrimaryKeyIndex returns an Index instance which represents the primary key definition of the collection of columns and true, otherwise present will be false, meaning, that there isn't a primary key available in this collection

func (Columns) ReplicaIdentityIndex

func (c Columns) ReplicaIdentityIndex() (index *Index, present bool)

ReplicaIdentityIndex returns an Index instance which represents the primary key definition of the collection of columns and true, otherwise present will be false, meaning, that there isn't a primary key available in this collection

func (Columns) SnapshotIndex

func (c Columns) SnapshotIndex() (index *Index, present bool)

SnapshotIndex returns the index used for snapshot watermarks. This can either be an actual index, such as a primary key, or a virtual index based on the dimensions of the hypertable.

type Converter

type Converter func(oid uint32, value any) (any, error)

Converter represents a conversion function to convert from a PostgreSQL internal OID number and value to a value according to the stream definition

func ConverterByOID

func ConverterByOID(oid uint32) (Converter, error)

ConverterByOID returns the Converter for a given OID, if no valid mapping is available, it will return an error

type DataType

type DataType string

DataType is a string like definition of the available event stream data types

const (
	INT8    DataType = "int8"
	INT16   DataType = "int16"
	INT32   DataType = "int32"
	INT64   DataType = "int64"
	FLOAT32 DataType = "float32"
	FLOAT64 DataType = "float64"
	BOOLEAN DataType = "boolean"
	STRING  DataType = "string"
	BYTES   DataType = "bytes"
	ARRAY   DataType = "array"
	MAP     DataType = "map"
	STRUCT  DataType = "struct"
)

func DataTypeByOID

func DataTypeByOID(oid uint32) (DataType, error)

DataTypeByOID returns the DataType for a given OID, if no valid mapping is available, it will return an error

type Hypertable

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

Hypertable represents a TimescaleDB hypertable definition in the system catalog

func NewHypertable

func NewHypertable(id int32,
	databaseName, schemaName, tableName, associatedSchemaName, associatedTablePrefix string,
	compressedHypertableId *int32, compressionState int16, distributed bool,
	viewSchema, viewName *string, replicaIdentity pgtypes.ReplicaIdentity) *Hypertable

NewHypertable instantiates a new Hypertable entity

func (*Hypertable) ApplyChanges

func (h *Hypertable) ApplyChanges(
	schemaName, tableName, associatedSchemaName, associatedTablePrefix string,
	compressedHypertableId *int32, compressionState int16,
	replicaIdentity pgtypes.ReplicaIdentity) (applied *Hypertable, changes map[string]string)

ApplyChanges applies catalog changes to a copy of the hypertable instance (not updating the current one) and returns the new instance and a collection of applied changes.

func (*Hypertable) ApplyTableSchema

func (h *Hypertable) ApplyTableSchema(newColumns []Column) (changes map[string]string)

ApplyTableSchema applies a new hypertable schema to this hypertable instance and returns changes to the previously known schema layout.

func (*Hypertable) CanonicalContinuousAggregateName

func (h *Hypertable) CanonicalContinuousAggregateName() string

CanonicalContinuousAggregateName returns the canonical continuous aggregate name of the hypertable in the form of <<schema.view>>. This method panics if the hypertable doesn't back a continuous aggregate. A check using IsContinuousAggregate before calling this method is adviced.

func (Hypertable) CanonicalName

func (bse Hypertable) CanonicalName() string

func (*Hypertable) Columns

func (h *Hypertable) Columns() Columns

Columns returns a slice with the column definitions of the hypertable

func (*Hypertable) CompressedHypertableId

func (h *Hypertable) CompressedHypertableId() (compressedHypertableId int32, present bool)

CompressedHypertableId returns the id of a hypertable which is used to represent the compressed chunks and true, otherwise present will be false

func (*Hypertable) DatabaseName

func (h *Hypertable) DatabaseName() string

DatabaseName returns the database name

func (*Hypertable) Id

func (h *Hypertable) Id() int32

Id returns the hypertable id

func (*Hypertable) IsCompressedTable

func (h *Hypertable) IsCompressedTable() bool

IsCompressedTable returns true if the hypertable is a compressed hypertable (not if the hypertable has compression enabled), otherwise false

func (*Hypertable) IsCompressionEnabled

func (h *Hypertable) IsCompressionEnabled() bool

IsCompressionEnabled returns true if the hypertable has compression enabled (not if the hypertable is a compressed hypertable), otherwise false

func (*Hypertable) IsContinuousAggregate

func (h *Hypertable) IsContinuousAggregate() bool

IsContinuousAggregate returns true if the hypertable is a backing hypertable for a continues aggregate, otherwise false

func (*Hypertable) IsDistributed

func (h *Hypertable) IsDistributed() bool

IsDistributed returns true if the hypertable is a distributed hypertable, otherwise false

func (*Hypertable) ReplicaIdentity

func (h *Hypertable) ReplicaIdentity() pgtypes.ReplicaIdentity

ReplicaIdentity returns the replica identity (if available), otherwise a pgtypes.UNKNOWN is returned

func (Hypertable) SchemaName

func (bse Hypertable) SchemaName() string

func (*Hypertable) String added in v0.0.10

func (h *Hypertable) String() string

func (Hypertable) TableName

func (bse Hypertable) TableName() string

func (*Hypertable) ViewName

func (h *Hypertable) ViewName() (viewName string, present bool)

ViewName returns the view name and true if the hypertable is a backing hypertable for a continuous aggregate, otherwise the present will be false

func (*Hypertable) ViewSchema

func (h *Hypertable) ViewSchema() (viewSchemaName string, present bool)

ViewSchema returns the view schema name and true if the hypertable is a backing hypertable for a continuous aggregate, otherwise the present will be false

type Index

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

Index represents either a (compound) primary key index or replica identity index in the database and attached to a hypertable (and its chunks)

func (*Index) AsSqlOrderBy

func (i *Index) AsSqlOrderBy(desc bool) string

AsSqlOrderBy creates a string for ORDER BY clauses with all parts of the index being ordered in descending direction

func (*Index) AsSqlTuple

func (i *Index) AsSqlTuple() string

AsSqlTuple creates a string to be used as a tuple definition in a WHERE-clause: (col1, col2, col3, ...)

func (*Index) Columns

func (i *Index) Columns() []Column

Columns returns an array of colum instances representing the columns of the index (in order of definition)

func (*Index) Name

func (i *Index) Name() string

Name returns the index name

func (*Index) PrimaryKey

func (i *Index) PrimaryKey() bool

PrimaryKey returns true if the index represents a primary key, otherwise false

func (*Index) ReplicaIdentity

func (i *Index) ReplicaIdentity() bool

ReplicaIdentity returns true if the index represents a replica identity index, otherwise false

func (*Index) String added in v0.0.10

func (i *Index) String() string

func (*Index) WhereTupleEQ

func (i *Index) WhereTupleEQ(params map[string]any) (string, bool)

WhereTupleEQ creates a WHERE-clause string which selects all values equal to the given set of index parameter values

func (*Index) WhereTupleGE

func (i *Index) WhereTupleGE(params map[string]any) (string, bool)

WhereTupleGE creates a WHERE-clause string which selects all values greater or equal to the given set of index parameter values

func (*Index) WhereTupleGT

func (i *Index) WhereTupleGT(params map[string]any) (string, bool)

WhereTupleGT creates a WHERE-clause string which selects all values greater than to the given set of index parameter values

func (*Index) WhereTupleLE

func (i *Index) WhereTupleLE(params map[string]any) (string, bool)

WhereTupleLE creates a WHERE-clause string which selects all values less or equal to the given set of index parameter values

func (*Index) WhereTupleLT

func (i *Index) WhereTupleLT(params map[string]any) (string, bool)

WhereTupleLT creates a WHERE-clause string which selects all values less than to the given set of index parameter values

type IndexNullsOrder

type IndexNullsOrder string
const (
	NULLS_FIRST IndexNullsOrder = "NULLS FIRST"
	NULLS_LAST  IndexNullsOrder = "NULLS LAST"
)

type IndexSortOrder

type IndexSortOrder string
const (
	ASC  IndexSortOrder = "ASC"
	DESC IndexSortOrder = "DESC"
)

type SystemEntity

type SystemEntity interface {
	// SchemaName returns the schema name of the entity
	SchemaName() string
	// TableName returns the table name of the entity
	TableName() string
	// CanonicalName returns the canonical name of the entity >>schema.table<<
	CanonicalName() string
}

SystemEntity represents an entity defined by its canonical elements (schema and table names)

func NewSystemEntity

func NewSystemEntity(schemaName, tableName string) SystemEntity

NewSystemEntity instantiates a new basic SystemEntity

Jump to

Keyboard shortcuts

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