db

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToJSONQuery

func ConvertToJSONQuery(query string) string

ConvertToJSONQuery converts a SELECT query to SELECT JSON format This is now a public method so it can be called from the router/UI layer when needed

func FormatMapForCQL added in v0.0.11

func FormatMapForCQL(m map[string]string) string

FormatMapForCQL formats a map for CQL output (for keyspaces, indexes, etc.)

func FormatTableCreateStatement added in v0.0.11

func FormatTableCreateStatement(tableInfo *TableInfo, includeHeader bool) string

FormatTableCreateStatement formats a CREATE TABLE statement If includeHeader is true, adds "Table: keyspace.table" header (for DESCRIBE TABLE)

func FormatValue added in v0.0.5

func FormatValue(val interface{}) string

FormatValue formats any value for display, handling nested structures This is called for top-level values, so strings should NOT be quoted

func TypeInfoToString

func TypeInfoToString(typeInfo gocql.TypeInfo) string

TypeInfoToString converts a gocql.TypeInfo to its string representation

func TypeToString

func TypeToString(t gocql.Type) string

TypeToString converts a gocql.Type to its string representation

Types

type AggregateInfo

type AggregateInfo struct {
	Name          string
	ArgumentTypes []string
	StateFunc     string
	StateType     string
	FinalFunc     string
	InitCond      string
	ReturnType    string
}

AggregateInfo holds aggregate information for manual describe

type AggregateListInfo

type AggregateListInfo struct {
	Name          string
	ArgumentTypes []string
	StateType     string
	ReturnType    string
}

AggregateListInfo holds aggregate list information for manual describe

type BinaryDecoder added in v0.0.5

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

BinaryDecoder handles decoding of Cassandra binary protocol data

func NewBinaryDecoder added in v0.0.5

func NewBinaryDecoder(registry *UDTRegistry) *BinaryDecoder

NewBinaryDecoder creates a new binary decoder with the given UDT registry

func (*BinaryDecoder) Decode added in v0.0.5

func (d *BinaryDecoder) Decode(data []byte, typeInfo *CQLTypeInfo, keyspace string) (interface{}, error)

Decode decodes binary data based on the type information

type CQLTypeHandler

type CQLTypeHandler struct {
	// Configuration options
	TimeFormat      string // Format for time display (default RFC3339)
	HexPrefix       string // Prefix for hex values (default "0x")
	NullString      string // String to display for null values (default "null")
	CollectionLimit int    // Max items to display in collections (0 = unlimited)
	TruncateStrings int    // Max length for strings (0 = no truncation)
}

CQLTypeHandler provides standardized handling for all Cassandra/CQL data types

func NewCQLTypeHandler

func NewCQLTypeHandler() *CQLTypeHandler

NewCQLTypeHandler creates a new type handler with default settings

func (*CQLTypeHandler) FormatValue

func (h *CQLTypeHandler) FormatValue(val interface{}, typeInfo gocql.TypeInfo) string

FormatValue formats any CQL value for display

type CQLTypeInfo added in v0.0.5

type CQLTypeInfo struct {
	BaseType   string         // "text", "int", "list", "map", "udt", etc.
	Frozen     bool           // Whether the type is frozen
	Parameters []*CQLTypeInfo // For collections/tuples - element types
	UDTName    string         // For UDT types - the name of the UDT
	Keyspace   string         // For UDT types - optional keyspace qualifier
}

CQLTypeInfo represents parsed CQL type information

func ParseCQLType added in v0.0.5

func ParseCQLType(typeStr string) (*CQLTypeInfo, error)

ParseCQLType parses a CQL type string into structured type information

func (*CQLTypeInfo) String added in v0.0.5

func (t *CQLTypeInfo) String() string

String returns a string representation of the TypeInfo

type CachedTableInfo

type CachedTableInfo struct {
	TableInfo
	RowCount    int64 // Optional: cached approximate count
	LastUpdated time.Time
}

CachedTableInfo extends TableInfo with cache-specific fields

type ClusterInfo

type ClusterInfo struct {
	ClusterName string
	Partitioner string
	Version     string
}

ClusterInfo holds cluster information for manual describe

type ColumnInfo

type ColumnInfo struct {
	Name     string
	DataType string
	Kind     string
	Position int
}

ColumnInfo holds column information

type ColumnSchema

type ColumnSchema struct {
	Name     string
	Type     string
	Kind     string // 'partition_key', 'clustering', 'regular', 'static'
	Position int    // Position for partition/clustering keys
}

ColumnSchema represents a column's schema

type FunctionDetails

type FunctionDetails struct {
	Name          string
	ArgumentTypes []string
	ArgumentNames []string
	ReturnType    string
	Language      string
	Body          string
	CalledOnNull  bool
}

FunctionDetails holds the details of a function for describe operations

type IndexInfo

type IndexInfo struct {
	TableName string
	IndexName string
	Kind      string
	Options   map[string]string
}

IndexInfo holds index information for manual describe

type KeyColumnInfo

type KeyColumnInfo struct {
	Kind     string // "partition_key" or "clustering"
	Position int
}

KeyColumnInfo holds information about key columns

type KeyspaceInfo

type KeyspaceInfo struct {
	Name          string
	DurableWrites bool
	Replication   map[string]string
}

KeyspaceInfo holds keyspace information for manual describe

type KeyspaceListInfo

type KeyspaceListInfo struct {
	Name        string
	Replication map[string]string
}

KeyspaceListInfo holds keyspace list information for manual describe

type KeyspaceSchema

type KeyspaceSchema struct {
	Name   string
	Tables map[string]*TableSchema
}

KeyspaceSchema represents a keyspace's schema

type MaterializedViewInfo

type MaterializedViewInfo struct {
	Name                    string
	BaseTable               string
	WhereClause             string
	BloomFilterFpChance     float64
	Caching                 string
	Comment                 string
	Compaction              map[string]string
	Compression             map[string]string
	CrcCheckChance          float64
	DclocalReadRepairChance float64
	DefaultTTL              int
	GcGrace                 int
	MaxIndexInterval        int
	MemtableFlushPeriod     int
	MinIndexInterval        int
	ReadRepairChance        float64
	SpeculativeRetry        string
	PartitionKeys           []string
	ClusteringKeys          []string
}

MaterializedViewInfo holds materialized view information for manual describe

type PermissionInfo

type PermissionInfo struct {
	Role        string
	Resource    string
	Permissions []string
}

PermissionInfo holds permission information from system_auth.role_permissions

type QueryResult

type QueryResult struct {
	Data            [][]string               // Formatted strings for display
	RawData         []map[string]interface{} // Raw values for JSON export (preserves types)
	Duration        time.Duration
	RowCount        int
	ColumnTypes     []string         // Data types of each column
	ColumnTypeInfos []gocql.TypeInfo // TypeInfo objects for each column (for UDT support)
	Headers         []string         // Column names without PK/C indicators
}

QueryResult wraps query results with metadata

type RawBytes added in v0.0.5

type RawBytes []byte

RawBytes is a custom type to capture raw bytes from gocql for types like UDTs that gocql cannot decode without compile-time type information

func (RawBytes) MarshalCQL added in v0.0.5

func (r RawBytes) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL implements gocql.Marshaler interface

func (*RawBytes) UnmarshalCQL added in v0.0.5

func (r *RawBytes) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL implements gocql.Unmarshaler interface This allows us to get the raw bytes instead of gocql's automatic decoding

type RoleInfo

type RoleInfo struct {
	Role        string
	CanLogin    bool
	IsSuperuser bool
	MemberOf    []string
	SaltedHash  string
}

RoleInfo holds role information from system_auth.roles

type SchemaCache

type SchemaCache struct {
	Keyspaces   []string
	Tables      map[string][]CachedTableInfo       // keyspace -> tables
	Columns     map[string]map[string][]ColumnInfo // keyspace -> table -> columns
	SearchIndex *SearchIndex                       // Pre-computed fuzzy search index
	LastRefresh time.Time
	Mu          sync.RWMutex
	// contains filtered or unexported fields
}

SchemaCache provides schema information using gocql's metadata API This replaces the old implementation that maintained its own cache

func NewSchemaCache

func NewSchemaCache(session *Session) *SchemaCache

NewSchemaCache creates a new schema cache using gocql metadata

func (*SchemaCache) CountTotalTables

func (sc *SchemaCache) CountTotalTables() int

CountTotalTables returns the total number of tables across all keyspaces

func (*SchemaCache) GetAllKeyspaces added in v0.0.5

func (sc *SchemaCache) GetAllKeyspaces() ([]string, error)

GetAllKeyspaces returns all non-system keyspaces Note: gocql doesn't provide a direct method to list all keyspaces, so we need to query system tables for this specific case

func (*SchemaCache) GetCachedTableCount added in v0.0.5

func (sc *SchemaCache) GetCachedTableCount(keyspace string) int

GetCachedTableCount returns approximate count (not cached with metadata API)

func (*SchemaCache) GetKeyspaceTables added in v0.0.5

func (sc *SchemaCache) GetKeyspaceTables(keyspace string) ([]CachedTableInfo, error)

GetKeyspaceTables returns all tables for a specific keyspace using gocql metadata

func (*SchemaCache) GetTableColumns added in v0.0.5

func (sc *SchemaCache) GetTableColumns(keyspace, table string) ([]ColumnInfo, error)

GetTableColumns returns columns for a specific table using gocql metadata

func (*SchemaCache) GetTableInfo added in v0.0.5

func (sc *SchemaCache) GetTableInfo(keyspace, table string) (*TableInfo, error)

GetTableInfo retrieves information about a specific table

func (*SchemaCache) GetTableSchema

func (sc *SchemaCache) GetTableSchema(keyspace, table string) (*TableSchema, error)

GetTableSchema returns schema information for a specific table This method is used by AI components for query context

func (*SchemaCache) IsInitialized added in v0.0.5

func (sc *SchemaCache) IsInitialized() bool

IsInitialized checks if the schema cache has been populated

func (*SchemaCache) Refresh

func (sc *SchemaCache) Refresh() error

Refresh loads or refreshes the schema metadata With gocql's metadata API, this mainly updates the search index

func (*SchemaCache) RefreshIfNeeded added in v0.0.5

func (sc *SchemaCache) RefreshIfNeeded(maxAge time.Duration) error

RefreshIfNeeded refreshes the cache if it's older than the specified duration

type SchemaCatalog

type SchemaCatalog struct {
	Keyspaces map[string]*KeyspaceSchema
}

SchemaCatalog holds all schema information

type SearchIndex

type SearchIndex struct {
	TableTokens map[string][]string // table -> tokens for fuzzy matching
}

SearchIndex contains pre-computed data for fuzzy searching

type Session

type Session struct {
	*gocql.Session
	// contains filtered or unexported fields
}

Session is a wrapper around the gocql.Session.

func NewSession

func NewSession() (*Session, error)

NewSession creates a new Cassandra session.

func NewSessionWithOptions

func NewSessionWithOptions(options SessionOptions) (*Session, error)

NewSessionWithOptions creates a new Cassandra session with command-line overrides.

func (*Session) AddToBatch

func (s *Session) AddToBatch(batch *gocql.Batch, query string)

AddToBatch adds a query to the current batch

func (*Session) AutoFetch added in v0.0.9

func (s *Session) AutoFetch() bool

AutoFetch returns whether auto-fetch is enabled

func (*Session) CassandraVersion

func (s *Session) CassandraVersion() string

CassandraVersion returns the Cassandra version

func (*Session) Consistency

func (s *Session) Consistency() string

Consistency returns the current consistency level

func (*Session) CreateBatch

func (s *Session) CreateBatch(batchType gocql.BatchType) *gocql.Batch

CreateBatch creates a new batch with the specified type

func (*Session) DBDescribeAggregate

func (s *Session) DBDescribeAggregate(sessionMgr *session.Manager, aggregateName string) (interface{}, *AggregateInfo, error)

DBDescribeAggregate handles version detection and returns appropriate data

func (*Session) DBDescribeAggregates

func (s *Session) DBDescribeAggregates(sessionMgr *session.Manager) (interface{}, []AggregateListInfo, error)

DBDescribeAggregates handles version detection and returns appropriate data

func (*Session) DBDescribeCluster

func (s *Session) DBDescribeCluster() (interface{}, *ClusterInfo, error)

DBDescribeCluster handles version detection and returns appropriate data

func (*Session) DBDescribeFullSchema added in v0.0.11

func (s *Session) DBDescribeFullSchema(sessionMgr *session.Manager, keyspace string) (interface{}, error)

DBDescribeFullSchema returns all CREATE statements for a keyspace and its objects If keyspace is empty, returns schema for all keyspaces

func (*Session) DBDescribeFunction

func (s *Session) DBDescribeFunction(sessionMgr *session.Manager, functionName string) (interface{}, []FunctionDetails, error)

DBDescribeFunction handles version detection and returns appropriate data

func (*Session) DBDescribeFunctionByName added in v0.0.11

func (s *Session) DBDescribeFunctionByName(functionName string, keyspaceName string) (interface{}, error)

DBDescribeFunctionByName returns raw query results for a function with optional keyspace

func (*Session) DBDescribeFunctions

func (s *Session) DBDescribeFunctions(sessionMgr *session.Manager) (interface{}, bool, error)

DBDescribeFunctions handles version detection and returns appropriate data

func (*Session) DBDescribeIndex

func (s *Session) DBDescribeIndex(sessionMgr *session.Manager, indexName string) (interface{}, *IndexInfo, error)

DBDescribeIndex handles version detection and returns appropriate data

func (*Session) DBDescribeKeyspace

func (s *Session) DBDescribeKeyspace(keyspaceName string) (interface{}, *KeyspaceInfo, error)

DBDescribeKeyspace handles version detection and returns appropriate data

func (*Session) DBDescribeKeyspaces

func (s *Session) DBDescribeKeyspaces() (interface{}, []KeyspaceListInfo, error)

DBDescribeKeyspaces handles version detection and returns appropriate data

func (*Session) DBDescribeMaterializedView

func (s *Session) DBDescribeMaterializedView(sessionMgr *session.Manager, viewName string) (interface{}, *MaterializedViewInfo, error)

DBDescribeMaterializedView handles version detection and returns appropriate data

func (*Session) DBDescribeMaterializedViews added in v0.0.11

func (s *Session) DBDescribeMaterializedViews(sessionMgr *session.Manager) (interface{}, error)

DBDescribeMaterializedViews lists all materialized views

func (*Session) DBDescribeTable

func (s *Session) DBDescribeTable(sessionMgr *session.Manager, tableName string) (interface{}, *TableInfo, error)

DBDescribeTable handles version detection and returns appropriate data

func (*Session) DBDescribeTables

func (s *Session) DBDescribeTables(sessionMgr *session.Manager) (interface{}, []TableListInfo, error)

DBDescribeTables handles version detection and returns appropriate data

func (*Session) DBDescribeType

func (s *Session) DBDescribeType(sessionMgr *session.Manager, typeName string) (interface{}, *TypeInfo, error)

DBDescribeType handles version detection and returns appropriate data

func (*Session) DBDescribeTypes

func (s *Session) DBDescribeTypes(sessionMgr *session.Manager) (interface{}, []TypeListInfo, error)

DBDescribeTypes handles version detection and returns appropriate data

func (*Session) DescribeAggregateQuery

func (s *Session) DescribeAggregateQuery(keyspace string, aggregateName string) (*AggregateInfo, error)

DescribeAggregateQuery executes the query to get aggregate information (for pre-4.0)

func (*Session) DescribeAggregatesQuery

func (s *Session) DescribeAggregatesQuery(keyspace string) ([]AggregateListInfo, error)

DescribeAggregatesQuery executes the query to list all aggregates (for pre-4.0)

func (*Session) DescribeAllTablesQuery added in v0.0.7

func (s *Session) DescribeAllTablesQuery() ([]TableListInfo, error)

DescribeAllTablesQuery executes queries to list all tables from all keyspaces

func (*Session) DescribeClusterQuery

func (s *Session) DescribeClusterQuery() (*ClusterInfo, error)

DescribeClusterQuery executes the query to get cluster information (for pre-4.0)

func (*Session) DescribeFunctionQuery

func (s *Session) DescribeFunctionQuery(currentKeyspace string, functionName string) ([]FunctionDetails, error)

DescribeFunctionQuery executes the query to get detailed information about a specific function

func (*Session) DescribeFunctionsQuery

func (s *Session) DescribeFunctionsQuery(currentKeyspace string) ([][]string, error)

DescribeFunctionsQuery executes the query to list all functions in the current keyspace (for pre-4.0)

func (*Session) DescribeIndexQuery

func (s *Session) DescribeIndexQuery(keyspace string, indexName string) (*IndexInfo, error)

DescribeIndexQuery executes the query to get index information (for pre-4.0)

func (*Session) DescribeIndexQueryWithTable added in v0.0.11

func (s *Session) DescribeIndexQueryWithTable(keyspace string, tableName string, indexName string) (*IndexInfo, error)

DescribeIndexQueryWithTable executes the query to get index information when table is known

func (*Session) DescribeKeyspaceQuery

func (s *Session) DescribeKeyspaceQuery(keyspaceName string) (*KeyspaceInfo, error)

DescribeKeyspaceQuery executes the query to get keyspace information (for pre-4.0)

func (*Session) DescribeKeyspacesQuery

func (s *Session) DescribeKeyspacesQuery() ([]KeyspaceListInfo, error)

DescribeKeyspacesQuery executes the query to list all keyspaces (for pre-4.0)

func (*Session) DescribeMaterializedViewQuery

func (s *Session) DescribeMaterializedViewQuery(keyspace string, viewName string) (*MaterializedViewInfo, error)

DescribeMaterializedViewQuery executes the query to get materialized view information (for pre-4.0)

func (*Session) DescribeTableQuery

func (s *Session) DescribeTableQuery(keyspace string, tableName string) (*TableInfo, error)

DescribeTableQuery executes queries to get table information (for pre-4.0)

func (*Session) DescribeTablesQuery

func (s *Session) DescribeTablesQuery(keyspace string) ([]TableListInfo, error)

DescribeTablesQuery executes queries to list all tables (for pre-4.0)

func (*Session) DescribeTypeQuery

func (s *Session) DescribeTypeQuery(keyspace string, typeName string) (*TypeInfo, error)

DescribeTypeQuery executes the query to get type information (for pre-4.0)

func (*Session) DescribeTypesQuery

func (s *Session) DescribeTypesQuery(keyspace string) ([]TypeListInfo, error)

DescribeTypesQuery executes the query to list all types (for pre-4.0)

func (*Session) ExecuteBatch

func (s *Session) ExecuteBatch(batch *gocql.Batch) error

ExecuteBatch executes a batch of statements

func (*Session) ExecuteCQLQuery

func (s *Session) ExecuteCQLQuery(query string) interface{}

ExecuteCQLQuery executes a regular CQL query

func (*Session) ExecuteDMLCommand

func (s *Session) ExecuteDMLCommand(query string) error

ExecuteDMLCommand executes a DML command (INSERT, UPDATE, DELETE, TRUNCATE)

func (*Session) ExecuteRoleCommand

func (s *Session) ExecuteRoleCommand(query string) error

ExecuteRoleCommand executes a role-related command (CREATE/ALTER/DROP USER/ROLE, GRANT/REVOKE)

func (*Session) ExecuteSelectQuery

func (s *Session) ExecuteSelectQuery(query string) interface{}

ExecuteSelectQuery executes a SELECT query and returns formatted results

func (*Session) ExecuteStreamingQuery

func (s *Session) ExecuteStreamingQuery(query string) interface{}

ExecuteStreamingQuery executes a query and returns a streaming result

func (*Session) GetColumnTypeFromSystemTable added in v0.0.5

func (s *Session) GetColumnTypeFromSystemTable(keyspace, table, column string) string

GetColumnTypeFromSystemTable gets the full type definition for a column This method uses the metadata API when possible, falling back to system tables

func (*Session) GetCurrentKeyspaceSchema

func (s *Session) GetCurrentKeyspaceSchema(sessionMgr *session.Manager) (*KeyspaceSchema, error)

GetCurrentKeyspaceSchema retrieves schema for the current keyspace

func (*Session) GetCurrentKeyspaceSchemaUsingMetadata added in v0.0.5

func (s *Session) GetCurrentKeyspaceSchemaUsingMetadata(sessionMgr *session.Manager) (*KeyspaceSchema, error)

GetCurrentKeyspaceSchemaUsingMetadata retrieves schema for the current keyspace using metadata

func (*Session) GetKeyColumns

func (s *Session) GetKeyColumns(query string) map[string]KeyColumnInfo

GetKeyColumns returns information about partition and clustering columns for a table

func (*Session) GetKeyspaceMetadata added in v0.0.5

func (s *Session) GetKeyspaceMetadata(keyspace string) (*gocql.KeyspaceMetadata, error)

GetKeyspaceMetadata retrieves keyspace metadata using gocql's built-in API

func (*Session) GetKeyspaceSchema

func (s *Session) GetKeyspaceSchema(keyspace string) (*KeyspaceSchema, error)

GetKeyspaceSchema retrieves schema for a specific keyspace

func (*Session) GetKeyspaceSchemaUsingMetadata added in v0.0.5

func (s *Session) GetKeyspaceSchemaUsingMetadata(keyspace string) (*KeyspaceSchema, error)

GetKeyspaceSchemaUsingMetadata retrieves keyspace schema using gocql metadata

func (*Session) GetMaterializedViewMetadata added in v0.0.5

func (s *Session) GetMaterializedViewMetadata(keyspace, viewName string) (*gocql.MaterializedViewMetadata, error)

GetMaterializedViewMetadata retrieves materialized view metadata

func (*Session) GetSchemaCache

func (s *Session) GetSchemaCache() *SchemaCache

GetSchemaCache returns the schema cache

func (*Session) GetSchemaCatalog

func (s *Session) GetSchemaCatalog() (*SchemaCatalog, error)

GetSchemaCatalog retrieves the complete schema catalog from Cassandra

func (*Session) GetSchemaContext

func (s *Session) GetSchemaContext(limit int) (string, error)

GetSchemaContext returns a compact representation for AI context

func (*Session) GetTableMetadata added in v0.0.5

func (s *Session) GetTableMetadata(keyspace, table string) (*gocql.TableMetadata, error)

GetTableMetadata retrieves table metadata for a specific table

func (*Session) GetTableSchema

func (s *Session) GetTableSchema(keyspace, table string) (*TableSchema, error)

GetTableSchema retrieves schema for a specific table

func (*Session) GetTableSchemaUsingMetadata added in v0.0.5

func (s *Session) GetTableSchemaUsingMetadata(keyspace, table string) (*TableSchema, error)

GetTableSchemaUsingMetadata retrieves table schema using gocql metadata

func (*Session) GetTraceData

func (s *Session) GetTraceData() ([][]string, []string, *TraceInfo, error)

GetTraceData retrieves trace data for the last executed query

func (*Session) GetUDTRegistry added in v0.0.5

func (s *Session) GetUDTRegistry() *UDTRegistry

GetUDTRegistry returns the UDT registry

func (*Session) GetUserTypeMetadata added in v0.0.5

func (s *Session) GetUserTypeMetadata(keyspace, typeName string) (*gocql.UserTypeMetadata, error)

GetUserTypeMetadata retrieves UDT metadata for a specific type

func (*Session) IsVersion3OrHigher

func (s *Session) IsVersion3OrHigher() bool

IsVersion3OrHigher checks if the Cassandra version is 3.0 or higher

func (*Session) IsVersion4OrHigher

func (s *Session) IsVersion4OrHigher() bool

IsVersion4OrHigher checks if the Cassandra version is 4.0 or higher

func (*Session) Keyspace added in v0.0.5

func (s *Session) Keyspace() string

Keyspace returns the current keyspace

func (*Session) ListPermissions

func (s *Session) ListPermissions() ([]PermissionInfo, error)

ListPermissions queries system_auth.role_permissions for all permissions

func (*Session) ListPermissionsForRole

func (s *Session) ListPermissionsForRole(roleName string) ([]PermissionInfo, error)

ListPermissionsForRole queries system_auth.role_permissions for a specific role

func (*Session) ListRoles

func (s *Session) ListRoles() ([]RoleInfo, error)

ListRoles queries system_auth.roles for role information

func (*Session) LoadKeyspaceUDTsUsingMetadata added in v0.0.5

func (s *Session) LoadKeyspaceUDTsUsingMetadata(keyspace string) error

LoadKeyspaceUDTsUsingMetadata delegates to the registry's simplified method

func (*Session) PageSize

func (s *Session) PageSize() int

PageSize returns the current page size

func (*Session) ProcessStreamingQuery added in v0.0.12

func (s *Session) ProcessStreamingQuery(result StreamingQueryResult) *StreamingResult

ProcessStreamingQuery creates a StreamingResult that loads data on demand

func (*Session) Query

func (s *Session) Query(stmt string, values ...interface{}) *gocql.Query

Query creates a new query with session defaults applied

func (*Session) SetAutoFetch added in v0.0.9

func (s *Session) SetAutoFetch(enabled bool)

SetAutoFetch enables or disables auto-fetching all pages

func (*Session) SetConsistency

func (s *Session) SetConsistency(level string) error

SetConsistency sets the consistency level

func (*Session) SetKeyspace

func (s *Session) SetKeyspace(keyspace string) error

SetKeyspace changes the current keyspace by recreating the session

func (*Session) SetPageSize

func (s *Session) SetPageSize(size int)

SetPageSize sets the page size

func (*Session) SetTracing

func (s *Session) SetTracing(enabled bool)

SetTracing enables or disables tracing

func (*Session) SetUDTRegistry added in v0.0.5

func (s *Session) SetUDTRegistry(registry *UDTRegistry)

SetUDTRegistry sets the UDT registry

func (*Session) Tracing

func (s *Session) Tracing() bool

Tracing returns whether tracing is enabled

func (*Session) Username added in v0.0.9

func (s *Session) Username() string

Username returns the current connection username

type SessionOptions

type SessionOptions struct {
	Host           string
	Port           int
	Keyspace       string
	Username       string
	Password       string
	Consistency    string // Default consistency level (e.g., "LOCAL_ONE", "QUORUM")
	SSL            *config.SSLConfig
	BatchMode      bool   // Skip schema caching for batch mode
	ConnectTimeout int    // Connection timeout in seconds (0 = use default)
	RequestTimeout int    // Request timeout in seconds (0 = use default)
	ConfigFile     string // Path to custom config file
}

SessionOptions represents options for creating a session with command-line overrides

type StreamingProcessor added in v0.0.12

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

StreamingProcessor handles progressive loading and formatting of query results

func NewStreamingProcessor added in v0.0.12

func NewStreamingProcessor(result StreamingQueryResult, session *Session) *StreamingProcessor

NewStreamingProcessor creates a new streaming processor for progressive result loading

func (*StreamingProcessor) Close added in v0.0.12

func (sp *StreamingProcessor) Close() error

Close closes the iterator if it's still open

func (*StreamingProcessor) GetColumnNames added in v0.0.12

func (sp *StreamingProcessor) GetColumnNames() []string

GetColumnNames returns the raw column names (without PK/C indicators)

func (*StreamingProcessor) GetHeaders added in v0.0.12

func (sp *StreamingProcessor) GetHeaders() []string

GetHeaders returns the column headers

func (*StreamingProcessor) LoadResults added in v0.0.12

func (sp *StreamingProcessor) LoadResults(ctx context.Context, maxRows int) ([][]string, bool, error)

LoadResults loads a batch of results from the iterator Returns the formatted rows, whether more results exist, and any error

type StreamingQueryResult

type StreamingQueryResult struct {
	Headers         []string         // Column headers (with PK/C indicators)
	ColumnNames     []string         // Original column names (for data lookup)
	ColumnTypes     []string         // Data types of each column
	ColumnTypeInfos []gocql.TypeInfo // TypeInfo objects for each column (for UDT support)
	Iterator        *gocql.Iter      // Iterator for fetching more rows
	StartTime       time.Time        // Query start time for duration calculation
	Keyspace        string           // Keyspace extracted from query or session
}

StreamingQueryResult wraps query results for progressive loading

type StreamingResult added in v0.0.12

type StreamingResult struct {
	Headers     []string
	Rows        [][]string
	HasMore     bool
	LoadMore    func(ctx context.Context, count int) ([][]string, bool, error)
	Close       func() error
	ElapsedTime time.Duration
}

StreamingResult represents a complete result that can be loaded progressively

type TableInfo

type TableInfo struct {
	KeyspaceName   string
	TableName      string
	TableProps     map[string]interface{}
	Columns        []ColumnInfo
	PartitionKeys  []string
	ClusteringKeys []string
}

TableInfo holds table information for manual describe

type TableListInfo

type TableListInfo struct {
	Name           string
	GcGrace        int
	Compaction     map[string]string
	Compression    map[string]string
	PartitionKeys  []string
	ClusteringKeys []string
}

TableListInfo holds table list information for manual describe

type TableSchema

type TableSchema struct {
	Keyspace       string
	TableName      string
	Columns        []ColumnSchema
	PartitionKeys  []string
	ClusteringKeys []string
}

TableSchema represents a table's schema information

type TraceInfo

type TraceInfo struct {
	Coordinator string
	Duration    int
}

TraceInfo holds trace session summary information

type TypeInfo

type TypeInfo struct {
	Name       string
	FieldNames []string
	FieldTypes []string
}

TypeInfo holds user-defined type information for manual describe

type TypeListInfo

type TypeListInfo struct {
	Name string
}

TypeListInfo holds type list information for manual describe

type UDTDefinition added in v0.0.5

type UDTDefinition struct {
	Keyspace string
	Name     string
	Fields   []UDTField
}

UDTDefinition represents a complete User-Defined Type definition

func (*UDTDefinition) GetFieldByName added in v0.0.5

func (d *UDTDefinition) GetFieldByName(name string) (*UDTField, int, error)

GetFieldByName returns a field by name from the UDT definition

func (*UDTDefinition) String added in v0.0.5

func (d *UDTDefinition) String() string

String returns a string representation of a UDT definition

type UDTField added in v0.0.5

type UDTField struct {
	Name     string
	TypeStr  string
	TypeInfo *CQLTypeInfo // Parsed type information
}

UDTField represents a field within a User-Defined Type

type UDTRegistry added in v0.0.5

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

UDTRegistry manages UDT definitions using gocql's cached metadata This simplified version relies on gocql's internal caching instead of maintaining our own cache

func NewUDTRegistry added in v0.0.5

func NewUDTRegistry(session *gocql.Session) *UDTRegistry

NewUDTRegistry creates a new UDT registry with the given session

func (*UDTRegistry) Clear added in v0.0.5

func (r *UDTRegistry) Clear()

Clear is a no-op since we don't maintain our own cache gocql's cache is managed internally

func (*UDTRegistry) ClearKeyspace added in v0.0.5

func (r *UDTRegistry) ClearKeyspace(keyspace string)

ClearKeyspace is a no-op since we don't maintain our own cache

func (*UDTRegistry) GetAllUDTs added in v0.0.5

func (r *UDTRegistry) GetAllUDTs(keyspace string) map[string]*UDTDefinition

GetAllUDTs returns all UDT definitions for a keyspace from gocql's cached metadata

func (*UDTRegistry) GetUDTDefinition added in v0.0.5

func (r *UDTRegistry) GetUDTDefinition(keyspace, udtName string) (*UDTDefinition, error)

GetUDTDefinition retrieves a UDT definition from gocql's cached metadata

func (*UDTRegistry) GetUDTDefinitionOrLoad added in v0.0.5

func (r *UDTRegistry) GetUDTDefinitionOrLoad(keyspace, udtName string) (*UDTDefinition, error)

GetUDTDefinitionOrLoad is now just an alias for GetUDTDefinition since gocql handles the loading and caching internally

func (*UDTRegistry) HasUDT added in v0.0.5

func (r *UDTRegistry) HasUDT(keyspace, udtName string) bool

HasUDT checks if a UDT exists in the keyspace

func (*UDTRegistry) LoadKeyspaceUDTs added in v0.0.5

func (r *UDTRegistry) LoadKeyspaceUDTs(keyspace string) error

LoadKeyspaceUDTs is now a no-op since gocql handles loading automatically Kept for backward compatibility

func (*UDTRegistry) LoadKeyspaceUDTsUsingMetadata added in v0.0.5

func (r *UDTRegistry) LoadKeyspaceUDTsUsingMetadata(keyspace string) error

LoadKeyspaceUDTsUsingMetadata is now a no-op since we always use metadata Kept for backward compatibility

Jump to

Keyboard shortcuts

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