spankeys

package module
v0.0.0-...-9be5905 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 12 Imported by: 0

README

spankeys

convenient methods for Cloud Spanner

Testing

Set following environment variables.

  • SPANNER_PROJECT_ID
  • SPANNER_INSTANCE_ID
  • SPANNER_DATABASE_ID
go test ./...

Documentation

Index

Constants

View Source
const (
	IndexTypeIndex                    IndexType  = "INDEX"
	IndexTypePrimaryKey               IndexType  = "PRIMARY_KEY"
	IndexStatePrepare                 IndexState = "PREPARE"
	IndexStateUnknown                 IndexState = ""
	IndexStateWriteOnly               IndexState = "WRITE_ONLY"
	IndexStateWriteOnlyCleanup        IndexState = "WRITE_ONLY_CLEANUP"
	IndexStateWriteOnlyValidateUnique IndexState = "WRITE_ONLY_VALIDATE_UNIQUE"
	IndexStateReadWrite               IndexState = "READ_WRITE"
)

Variables

This section is empty.

Functions

func CalcMutationBatchSize

func CalcMutationBatchSize(ctx context.Context, client *spanner.Client, tableName string) (int, error)

func CountIndexesWithChildren

func CountIndexesWithChildren(ctx context.Context, client *spanner.Client, tableName string) (int, error)

func DecodeToInterface

func DecodeToInterface(gcv *spanner.GenericColumnValue, ptr interface{}) error

Types

type Column

type Column struct {
	Name string

	// ORDINAL_POSITION is nullable
	// https://cloud.google.com/spanner/docs/information-schema#information_schemaindex_columns
	OrdinalPosition spanner.NullInt64
}

func GetColumns

func GetColumns(ctx context.Context, client *spanner.Client, table string) ([]*Column, error)

func GetPrimaryKeyColumns

func GetPrimaryKeyColumns(ctx context.Context, client *spanner.Client, table string) ([]*Column, error)

type CountableKeyRange

type CountableKeyRange struct {
	spanner.KeyRange
	RowCount int64
}

func PartitionsKeyRanges

func PartitionsKeyRanges(ctx context.Context, client *spanner.Client, tableName string, pkColumns []*Column, mutationBatchSize, selectLimit int) ([]*CountableKeyRange, error)

type DSN

type DSN string

DSN is name of Cloud Spanner database has the form projects/PROJECT_ID/instances/INSTANCE_ID/databases/DATABASE_ID

func NewDSN

func NewDSN(s string) (DSN, error)

func (DSN) DatabaseID

func (d DSN) DatabaseID() string

func (DSN) InstanceID

func (d DSN) InstanceID() string

func (DSN) Parent

func (d DSN) Parent() string

func (DSN) ProjectID

func (d DSN) ProjectID() string

type Index

type Index struct {
	Name           string
	Type           IndexType
	Table          string
	ParentTable    string
	IsPrimaryKey   bool
	IsUnique       bool
	IsNullFiltered bool
	State          IndexState
	Columns        []*IndexColumn
}

func GetIndexes

func GetIndexes(ctx context.Context, client *spanner.Client) ([]*Index, error)

func GetSecondaryIndexes

func GetSecondaryIndexes(ctx context.Context, client *spanner.Client, table string) ([]*Index, error)

func GetTableIndexes

func GetTableIndexes(ctx context.Context, client *spanner.Client, table string) ([]*Index, error)

type IndexColumn

type IndexColumn struct {
	Column
}

type IndexState

type IndexState string

type IndexType

type IndexType string

type Interleave

type Interleave struct {
	Table    string
	OnDelete OnDelete
}

func GetInterleaveChildren

func GetInterleaveChildren(ctx context.Context, client *spanner.Client, parentTable string) ([]*Interleave, error)

type OnDelete

type OnDelete int
const (
	OnDeleteNoAction OnDelete = iota
	OnDeleteCascade
)

type Table

type Table struct {
	Name       string
	Interleave *Interleave
}

func GetTables

func GetTables(ctx context.Context, client *spanner.Client) ([]*Table, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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