typedef

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoCQLProtoDirectionMask = 0x80
	GoCQLProtoVersionMask   = 0x7F
	GoCQLProtoVersion1      = 0x01
	GoCQLProtoVersion2      = 0x02
	GoCQLProtoVersion3      = 0x03
	GoCQLProtoVersion4      = 0x04
	GoCQLProtoVersion5      = 0x05
)
View Source
const (
	TypeUdt   = "udt"
	TypeMap   = "map"
	TypeList  = "list"
	TypeSet   = "set"
	TypeTuple = "tuple"
)

nolint:revive

View Source
const (
	TypeAscii     = SimpleType("ascii")
	TypeBigint    = SimpleType("bigint")
	TypeBlob      = SimpleType("blob")
	TypeBoolean   = SimpleType("boolean")
	TypeDate      = SimpleType("date")
	TypeDecimal   = SimpleType("decimal")
	TypeDouble    = SimpleType("double")
	TypeDuration  = SimpleType("duration")
	TypeFloat     = SimpleType("float")
	TypeInet      = SimpleType("inet")
	TypeInt       = SimpleType("int")
	TypeSmallint  = SimpleType("smallint")
	TypeText      = SimpleType("text")
	TypeTime      = SimpleType("time")
	TypeTimestamp = SimpleType("timestamp")
	TypeTimeuuid  = SimpleType("timeuuid")
	TypeTinyint   = SimpleType("tinyint")
	TypeUuid      = SimpleType("uuid")
	TypeVarchar   = SimpleType("varchar")
	TypeVarint    = SimpleType("varint")
)

nolint:revive

View Source
const (
	KnownIssuesJSONWithTuples = "https://github.com/scylladb/scylla/issues/3708"
)

Variables

View Source
var (
	ErrSchemaConfigInvalidRangePK = errors.New(
		"max number of partition keys must be bigger than min number of partition keys",
	)
	ErrSchemaConfigInvalidRangeCK = errors.New(
		"max number of clustering keys must be bigger than min number of clustering keys",
	)
	ErrSchemaConfigInvalidRangeCols = errors.New(
		"max number of columns must be bigger than min number of columns",
	)
)
View Source
var CompatibleColumnTypes = map[SimpleType]SimpleTypes{
	TypeAscii: {
		TypeText,
		TypeBlob,
	},
	TypeBigint: {
		TypeBlob,
	},
	TypeBoolean: {
		TypeBlob,
	},
	TypeDecimal: {
		TypeBlob,
	},
	TypeFloat: {
		TypeBlob,
	},
	TypeInet: {
		TypeBlob,
	},
	TypeInt: {
		TypeVarint,
		TypeBlob,
	},
	TypeTimestamp: {
		TypeBlob,
	},
	TypeTimeuuid: {
		TypeUuid,
		TypeBlob,
	},
	TypeUuid: {
		TypeBlob,
	},
	TypeVarchar: {
		TypeText,
		TypeBlob,
	},
	TypeVarint: {
		TypeBlob,
	},
}
View Source
var ErrSchemaValidation = errors.New("validation failed")

Functions

This section is empty.

Types

type BagType added in v1.8.3

type BagType struct {
	ComplexType string     `json:"complex_type"` // We need to differentiate between sets and lists
	ValueType   SimpleType `json:"value_type"`
	Frozen      bool       `json:"frozen"`
}

func (*BagType) CQLDef added in v1.8.3

func (ct *BagType) CQLDef() string

func (*BagType) CQLHolder added in v1.8.3

func (ct *BagType) CQLHolder() string

func (*BagType) CQLPretty added in v1.8.3

func (ct *BagType) CQLPretty(builder *bytes.Buffer, value any) error

func (*BagType) CQLType added in v1.8.3

func (ct *BagType) CQLType() gocql.TypeInfo

func (*BagType) GenJSONValue added in v1.8.3

func (ct *BagType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any

func (*BagType) GenValue added in v1.8.3

func (ct *BagType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any

func (*BagType) Indexable added in v1.8.3

func (ct *BagType) Indexable() bool

func (*BagType) LenValue added in v1.8.3

func (ct *BagType) LenValue() int

func (*BagType) Name added in v1.8.3

func (ct *BagType) Name() string

func (*BagType) ValueVariationsNumber added in v1.8.7

func (ct *BagType) ValueVariationsNumber(p *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type CQLFeature

type CQLFeature int
const (
	CQL_FEATURE_BASIC CQLFeature = iota + 1
	CQL_FEATURE_NORMAL
	CQL_FEATURE_ALL
)

type ColumnDef added in v1.8.3

type ColumnDef struct {
	Type Type   `json:"type"`
	Name string `json:"name"`
}

func GetBagTypeColumn added in v1.8.3

func GetBagTypeColumn(data map[string]any) (out *ColumnDef, err error)

func GetMapTypeColumn added in v1.8.3

func GetMapTypeColumn(data map[string]any) (out *ColumnDef, err error)

func GetSimpleTypeColumn added in v1.8.3

func GetSimpleTypeColumn(data map[string]any) (*ColumnDef, error)

func GetTupleTypeColumn added in v1.8.3

func GetTupleTypeColumn(data map[string]any) (out *ColumnDef, err error)

func GetUDTTypeColumn added in v1.8.3

func GetUDTTypeColumn(data map[string]any) (out *ColumnDef, err error)

func (*ColumnDef) IsValidForPrimaryKey added in v1.8.3

func (cd *ColumnDef) IsValidForPrimaryKey() bool

func (*ColumnDef) UnmarshalJSON added in v1.8.3

func (cd *ColumnDef) UnmarshalJSON(data []byte) error

type Columns added in v1.8.3

type Columns []*ColumnDef

func (Columns) Len added in v1.8.3

func (c Columns) Len() int

func (Columns) LenValues added in v1.8.3

func (c Columns) LenValues() int

func (Columns) Names added in v1.8.3

func (c Columns) Names() []string

func (Columns) NonCounters added in v1.8.3

func (c Columns) NonCounters() Columns

func (Columns) Random added in v1.8.3

func (c Columns) Random(r *rand.Rand) *ColumnDef

func (Columns) Remove added in v1.8.3

func (c Columns) Remove(column *ColumnDef) Columns

func (Columns) ToJSONMap added in v1.8.3

func (c Columns) ToJSONMap(
	values map[string]any,
	r *rand.Rand,
	p *PartitionRangeConfig,
) map[string]any

func (Columns) ValidColumnsForPrimaryKey added in v1.8.3

func (c Columns) ValidColumnsForPrimaryKey() Columns

func (Columns) ValueVariationsNumber added in v1.8.7

func (c Columns) ValueVariationsNumber(p *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type CounterType added in v1.8.3

type CounterType struct {
	Value int64
}

func (*CounterType) CQLDef added in v1.8.3

func (ct *CounterType) CQLDef() string

func (*CounterType) CQLHolder added in v1.8.3

func (ct *CounterType) CQLHolder() string

func (*CounterType) CQLPretty added in v1.8.3

func (ct *CounterType) CQLPretty(builder *bytes.Buffer, value any) error

func (*CounterType) CQLType added in v1.8.3

func (ct *CounterType) CQLType() gocql.TypeInfo

func (*CounterType) GenJSONValue added in v1.8.3

func (ct *CounterType) GenJSONValue(r *rand.Rand, _ *PartitionRangeConfig) any

func (*CounterType) GenValue added in v1.8.3

func (ct *CounterType) GenValue(r *rand.Rand, _ *PartitionRangeConfig) []any

func (*CounterType) Indexable added in v1.8.3

func (ct *CounterType) Indexable() bool

func (*CounterType) LenValue added in v1.8.3

func (ct *CounterType) LenValue() int

func (*CounterType) Name added in v1.8.3

func (ct *CounterType) Name() string

func (*CounterType) ValueVariationsNumber added in v1.8.7

func (ct *CounterType) ValueVariationsNumber(_ *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type IndexDef

type IndexDef struct {
	Column     *ColumnDef
	IndexName  string `json:"index_name"`
	ColumnName string `json:"column_name"`
}

type Keyspace

type Keyspace struct {
	Replication       replication.Replication `json:"replication"`
	OracleReplication replication.Replication `json:"oracle_replication"`
	Name              string                  `json:"name"`
}

type KnownIssues added in v1.8.3

type KnownIssues map[string]bool

type MapType added in v1.8.3

type MapType struct {
	ComplexType string     `json:"complex_type"`
	KeyType     SimpleType `json:"key_type"`
	ValueType   SimpleType `json:"value_type"`
	Frozen      bool       `json:"frozen"`
}

func (*MapType) CQLDef added in v1.8.3

func (mt *MapType) CQLDef() string

func (*MapType) CQLHolder added in v1.8.3

func (mt *MapType) CQLHolder() string

func (*MapType) CQLPretty added in v1.8.3

func (mt *MapType) CQLPretty(builder *bytes.Buffer, value any) error

func (*MapType) CQLType added in v1.8.3

func (mt *MapType) CQLType() gocql.TypeInfo

func (*MapType) GenJSONValue added in v1.8.3

func (mt *MapType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any

func (*MapType) GenValue added in v1.8.3

func (mt *MapType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any

func (*MapType) Indexable added in v1.8.3

func (mt *MapType) Indexable() bool

func (*MapType) LenValue added in v1.8.3

func (mt *MapType) LenValue() int

func (*MapType) Name added in v1.8.3

func (mt *MapType) Name() string

func (*MapType) ValueVariationsNumber added in v1.8.7

func (mt *MapType) ValueVariationsNumber(p *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type MaterializedView added in v1.8.3

type MaterializedView struct {
	NonPrimaryKey  *ColumnDef
	Name           string  `json:"name"`
	PartitionKeys  Columns `json:"partition_keys"`
	ClusteringKeys Columns `json:"clustering_keys"`
	// contains filtered or unexported fields
}

func (*MaterializedView) HaveNonPrimaryKey added in v1.8.3

func (m *MaterializedView) HaveNonPrimaryKey() bool

func (*MaterializedView) PartitionKeysLenValues added in v1.8.3

func (m *MaterializedView) PartitionKeysLenValues() int

type OpType added in v1.8.8

type OpType uint8
const (
	OpSelect OpType = iota
	OpInsert
	OpUpdate
	OpDelete
	OpSchemaAlter
	OpSchemaDrop
	OpSchemaCreate
)

func (OpType) IsDelete added in v1.11.0

func (op OpType) IsDelete() bool

func (OpType) IsInsert added in v1.11.0

func (op OpType) IsInsert() bool

func (OpType) IsSchemaChange added in v1.11.0

func (op OpType) IsSchemaChange() bool

func (OpType) IsSelect added in v1.11.0

func (op OpType) IsSelect() bool

func (OpType) IsUpdate added in v1.11.0

func (op OpType) IsUpdate() bool

type PartitionRangeConfig

type PartitionRangeConfig struct {
	MaxBlobLength   int
	MinBlobLength   int
	MaxStringLength int
	MinStringLength int
	UseLWT          bool
}

type QueryCache added in v1.8.3

type QueryCache interface {
	GetQuery(qct StatementCacheType) StmtCache
	Reset()
	BindToTable(t *Table)
}

type Schema added in v1.8.3

type Schema struct {
	Keyspace Keyspace     `json:"keyspace"`
	Tables   []*Table     `json:"tables"`
	Config   SchemaConfig `json:"-"`
}

func (*Schema) GetHash added in v1.8.7

func (s *Schema) GetHash() string

type SchemaConfig

type SchemaConfig struct {
	ReplicationStrategy              replication.Replication
	OracleReplicationStrategy        replication.Replication
	TableOptions                     []tableopts.Option
	MaxTables                        int
	MaxPartitionKeys                 int
	MinPartitionKeys                 int
	MaxClusteringKeys                int
	MinClusteringKeys                int
	MaxColumns                       int
	MinColumns                       int
	MaxUDTParts                      int
	MaxTupleParts                    int
	MaxBlobLength                    int
	MaxStringLength                  int
	MinBlobLength                    int
	MinStringLength                  int
	UseCounters                      bool
	UseLWT                           bool
	UseMaterializedViews             bool
	CQLFeature                       CQLFeature
	AsyncObjectStabilizationAttempts int
	AsyncObjectStabilizationDelay    time.Duration
}

func (*SchemaConfig) GetMaxClusteringKeys

func (sc *SchemaConfig) GetMaxClusteringKeys() int

func (*SchemaConfig) GetMaxColumns

func (sc *SchemaConfig) GetMaxColumns() int

func (*SchemaConfig) GetMaxPartitionKeys

func (sc *SchemaConfig) GetMaxPartitionKeys() int

func (*SchemaConfig) GetMaxTables

func (sc *SchemaConfig) GetMaxTables() int

func (*SchemaConfig) GetMinClusteringKeys

func (sc *SchemaConfig) GetMinClusteringKeys() int

func (*SchemaConfig) GetMinColumns

func (sc *SchemaConfig) GetMinColumns() int

func (*SchemaConfig) GetMinPartitionKeys

func (sc *SchemaConfig) GetMinPartitionKeys() int

func (*SchemaConfig) GetPartitionRangeConfig added in v1.8.5

func (sc *SchemaConfig) GetPartitionRangeConfig() PartitionRangeConfig

func (*SchemaConfig) Valid

func (sc *SchemaConfig) Valid() error

type SimpleQuery added in v1.8.8

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

func (SimpleQuery) ToCql added in v1.8.8

func (q SimpleQuery) ToCql() (stmt string, names []string)

type SimpleType added in v1.8.3

type SimpleType string

func (SimpleType) CQLDef added in v1.8.3

func (st SimpleType) CQLDef() string

func (SimpleType) CQLHolder added in v1.8.3

func (st SimpleType) CQLHolder() string

func (SimpleType) CQLPretty added in v1.8.3

func (st SimpleType) CQLPretty(builder *bytes.Buffer, value any) error

func (SimpleType) CQLType added in v1.8.3

func (st SimpleType) CQLType() gocql.TypeInfo

func (SimpleType) GenJSONValue added in v1.8.3

func (st SimpleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any

func (SimpleType) GenValue added in v1.8.3

func (st SimpleType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any

func (SimpleType) Indexable added in v1.8.3

func (st SimpleType) Indexable() bool

func (SimpleType) LenValue added in v1.8.3

func (st SimpleType) LenValue() int

func (SimpleType) Name added in v1.8.3

func (st SimpleType) Name() string

func (SimpleType) ValueVariationsNumber added in v1.8.7

func (st SimpleType) ValueVariationsNumber(p *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type SimpleTypes added in v1.8.3

type SimpleTypes []SimpleType

func (SimpleTypes) Contains added in v1.8.3

func (l SimpleTypes) Contains(colType Type) bool

func (SimpleTypes) Random added in v1.8.3

func (l SimpleTypes) Random(r *rand.Rand) SimpleType

type Statement added in v1.8.8

type Statement interface {
	ToCql() (stmt string, names []string)
	PrettyCQL() (string, error)
}

type StatementCacheType

type StatementCacheType uint8
const (
	CacheInsert StatementCacheType = iota
	CacheInsertIfNotExists
	CacheUpdate
	CacheDelete
	CacheArrayLen
)

func (StatementCacheType) String added in v1.11.0

func (t StatementCacheType) String() string

type StatementType

type StatementType uint8
const (
	SelectStatementType StatementType = iota
	SelectRangeStatementType
	SelectByIndexStatementType
	SelectFromMaterializedViewStatementType
	DeleteStatementType
	InsertStatementType
	InsertJSONStatementType
	UpdateStatementType
	AlterColumnStatementType
	DropColumnStatementType
	AddColumnStatementType
	DropKeyspaceStatementType
	CreateKeyspaceStatementType
	CreateSchemaStatementType
	CreateIndexStatementType
	DropIndexStatementType
	CreateTypeStatementType
	DropTypeStatementType
	CreateTableStatementType
	DropTableStatementType
)

func ParseStatementTypeFromQuery added in v1.9.3

func ParseStatementTypeFromQuery(query string) StatementType

func (StatementType) OpType added in v1.8.8

func (st StatementType) OpType() OpType

func (StatementType) PossibleAsyncOperation

func (st StatementType) PossibleAsyncOperation() bool

func (StatementType) String added in v1.8.9

func (st StatementType) String() string

type Stmt

type Stmt struct {
	ValuesWithToken []ValueWithToken
	Values          Values
	StmtCache
}

func SimpleStmt added in v1.8.8

func SimpleStmt(query string, queryType StatementType) *Stmt

func (*Stmt) Clone added in v1.8.9

func (s *Stmt) Clone() *Stmt

func (*Stmt) PrettyCQL

func (s *Stmt) PrettyCQL() (string, error)

func (*Stmt) PrettyCQLBuffered added in v1.8.9

func (s *Stmt) PrettyCQLBuffered(buffer *bytes.Buffer) error

func (*Stmt) ToCql added in v1.8.9

func (s *Stmt) ToCql() (string, []string)

type StmtCache

type StmtCache struct {
	Query     qb.Builder
	Types     Types
	QueryType StatementType
	LenValue  int
}

type Stmts

type Stmts struct {
	PostStmtHook func()
	List         []*Stmt
	QueryType    StatementType
}

type Table added in v1.8.3

type Table struct {
	Name              string             `json:"name"`
	PartitionKeys     Columns            `json:"partition_keys"`
	ClusteringKeys    Columns            `json:"clustering_keys"`
	Columns           Columns            `json:"columns"`
	Indexes           []IndexDef         `json:"indexes,omitempty"`
	MaterializedViews []MaterializedView `json:"materialized_views,omitempty"`
	KnownIssues       KnownIssues        `json:"known_issues"`
	TableOptions      []string           `json:"table_options,omitempty"`
	// contains filtered or unexported fields
}

func (*Table) GetQueryCache added in v1.8.3

func (t *Table) GetQueryCache(st StatementCacheType) StmtCache

func (*Table) Init added in v1.8.3

func (t *Table) Init(s *Schema, c QueryCache)

func (*Table) IsCounterTable added in v1.8.3

func (t *Table) IsCounterTable() bool

func (*Table) LinkIndexAndColumns added in v1.8.4

func (t *Table) LinkIndexAndColumns()

func (*Table) Lock added in v1.8.3

func (t *Table) Lock()

func (*Table) PartitionKeysLenValues added in v1.8.3

func (t *Table) PartitionKeysLenValues() int

func (*Table) RLock added in v1.8.3

func (t *Table) RLock()

func (*Table) RUnlock added in v1.8.3

func (t *Table) RUnlock()

func (*Table) ResetQueryCache added in v1.8.3

func (t *Table) ResetQueryCache()

func (*Table) Unlock added in v1.8.3

func (t *Table) Unlock()

func (*Table) ValidColumnsForDelete added in v1.8.3

func (t *Table) ValidColumnsForDelete() Columns

type TupleType added in v1.8.3

type TupleType struct {
	ComplexType string       `json:"complex_type"`
	ValueTypes  []SimpleType `json:"value_types"`
	Frozen      bool         `json:"frozen"`
}

func (*TupleType) CQLDef added in v1.8.3

func (t *TupleType) CQLDef() string

func (*TupleType) CQLHolder added in v1.8.3

func (t *TupleType) CQLHolder() string

func (*TupleType) CQLPretty added in v1.8.3

func (t *TupleType) CQLPretty(builder *bytes.Buffer, value any) error

func (*TupleType) CQLType added in v1.8.3

func (t *TupleType) CQLType() gocql.TypeInfo

func (*TupleType) GenJSONValue added in v1.8.3

func (t *TupleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any

func (*TupleType) GenValue added in v1.8.3

func (t *TupleType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any

func (*TupleType) Indexable added in v1.8.3

func (t *TupleType) Indexable() bool

func (*TupleType) LenValue added in v1.8.3

func (t *TupleType) LenValue() int

func (*TupleType) Name added in v1.8.3

func (t *TupleType) Name() string

func (*TupleType) ValueVariationsNumber added in v1.8.7

func (t *TupleType) ValueVariationsNumber(p *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type Type

type Type interface {
	Name() string
	CQLDef() string
	CQLHolder() string
	CQLPretty(*bytes.Buffer, any) error
	GenValue(*rand.Rand, *PartitionRangeConfig) []any
	GenJSONValue(*rand.Rand, *PartitionRangeConfig) any
	LenValue() int
	// ValueVariationsNumber returns number of bytes generated value holds
	ValueVariationsNumber(*PartitionRangeConfig) float64
	Indexable() bool
	CQLType() gocql.TypeInfo
}

type Types

type Types []Type

func (Types) LenValue

func (l Types) LenValue() int

func (Types) ValueVariationsNumber added in v1.8.7

func (l Types) ValueVariationsNumber(p *PartitionRangeConfig) float64

type UDTType added in v1.8.3

type UDTType struct {
	ComplexType string                `json:"complex_type"`
	ValueTypes  map[string]SimpleType `json:"value_types"`
	TypeName    string                `json:"type_name"`
	Frozen      bool                  `json:"frozen"`
}

func (*UDTType) CQLDef added in v1.8.3

func (t *UDTType) CQLDef() string

func (*UDTType) CQLHolder added in v1.8.3

func (t *UDTType) CQLHolder() string

func (*UDTType) CQLPretty added in v1.8.3

func (t *UDTType) CQLPretty(builder *bytes.Buffer, value any) error

func (*UDTType) CQLType added in v1.8.3

func (t *UDTType) CQLType() gocql.TypeInfo

func (*UDTType) GenJSONValue added in v1.8.3

func (t *UDTType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any

func (*UDTType) GenValue added in v1.8.3

func (t *UDTType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any

func (*UDTType) Indexable added in v1.8.3

func (t *UDTType) Indexable() bool

func (*UDTType) LenValue added in v1.8.3

func (t *UDTType) LenValue() int

func (*UDTType) Name added in v1.8.3

func (t *UDTType) Name() string

func (*UDTType) ValueVariationsNumber added in v1.8.7

func (t *UDTType) ValueVariationsNumber(p *PartitionRangeConfig) float64

ValueVariationsNumber returns number of bytes generated value holds

type ValueWithToken

type ValueWithToken struct {
	Value Values
	Token uint64
}

func (ValueWithToken) MemoryFootprint added in v1.9.3

func (v ValueWithToken) MemoryFootprint() uint64

type Values

type Values []any

func (Values) Copy

func (v Values) Copy() Values

func (Values) CopyFrom

func (v Values) CopyFrom(src Values) Values

func (Values) MemoryFootprint added in v1.9.3

func (v Values) MemoryFootprint() uint64

Jump to

Keyboard shortcuts

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