basebigt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BigIntColumnReader = ColumnReaderFunc(func(row bigtable.Row, familyColumn string) (interface{}, error) {
	bytes, err := BytesColumnReader(row, familyColumn)
	if err != nil {
		return nil, err
	}

	return new(big.Int).SetBytes(bytes.([]byte)), nil
})
View Source
var BytesColumnReader = ColumnReaderFunc(func(row bigtable.Row, familyColumn string) (interface{}, error) {
	item, present := ColumnItem(row, familyColumn)
	if !present {
		return false, NewErrColumnNotPresent(familyColumn)
	}

	return item.Value, nil
})
View Source
var Uint64ColumnReader = ColumnReaderFunc(func(row bigtable.Row, familyColumn string) (interface{}, error) {
	return Uint64ColumnItem(row, familyColumn)
})

Functions

func BoolColumnItem

func BoolColumnItem(row bigtable.Row, familyColumn string) (bool, error)

func ColumnItem

func ColumnItem(row bigtable.Row, familyColumn string) (item *bigtable.ReadItem, present bool)

func IsEmptyRow

func IsEmptyRow(row bigtable.Row) bool

func IsErrColumnNotPresent

func IsErrColumnNotPresent(err error) bool

func IsErrEmptyValue

func IsErrEmptyValue(err error) bool

func JSONColumnItem

func JSONColumnItem(row bigtable.Row, familyColumn string, v interface{}) error

func ProtoColumnItem

func ProtoColumnItem(row bigtable.Row, familyColumn string, protoResolver func() proto.Message) error

ProtoColumnItem turns the familyColumn on row into a proper unmarshalled Proto structure. The `protoResolver` exists so that it's possible to implement lazy loading of the actual proto structure to implement. Instead of directly passing the proto, you pass a resolver function that returns the proto to unserialized. Since the resolver is called only when the actual row data exists, we save useless deallocation at the expense of an extra function call.

func StringColumnItem

func StringColumnItem(row bigtable.Row, familyColumn string) (string, error)

func StringListColumnItem

func StringListColumnItem(row bigtable.Row, familyColumn string, separator string) ([]string, error)

func Uint64ColumnItem

func Uint64ColumnItem(row bigtable.Row, familyColumn string) (uint64, error)

Types

type BaseTable

type BaseTable struct {
	// We "inherit" from `Table` so that `ReadRows` and `ReadRow` is available directly on the instance.
	*bigtable.Table

	Name     string
	Families []string
	// contains filtered or unexported fields
}

func NewBaseTable

func NewBaseTable(name string, families []string, client *bigtable.Client) *BaseTable

func (*BaseTable) EnsureTableAndFamiliesExist

func (b *BaseTable) EnsureTableAndFamiliesExist(admin *bigtable.AdminClient)

func (*BaseTable) FlushMutations

func (b *BaseTable) FlushMutations(ctx context.Context) error

func (*BaseTable) PendingSets

func (b *BaseTable) PendingSets() []*SetEntry

func (*BaseTable) SetKey

func (b *BaseTable) SetKey(key string, familyColumn string, value []byte)

type Bigtable

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

func New

func New(tablePrefix, project, instance string, tables []*BaseTable, createTables bool, opts ...option.ClientOption) (*Bigtable, error)

func NewWithClient

func NewWithClient(tablePrefix string, tables []*BaseTable, client *bigtable.Client) *Bigtable

func (*Bigtable) Close

func (b *Bigtable) Close() error

func (*Bigtable) CreateTables

func (b *Bigtable) CreateTables(ctx context.Context, project, instance string, opts ...option.ClientOption)

func (*Bigtable) Flush

func (b *Bigtable) Flush(ctx context.Context) error

func (*Bigtable) FlushAllMutations

func (b *Bigtable) FlushAllMutations(ctx context.Context) error

func (*Bigtable) IncrementPutBlockCounter

func (b *Bigtable) IncrementPutBlockCounter()

func (*Bigtable) ShouldFlushMutations

func (b *Bigtable) ShouldFlushMutations() bool

func (*Bigtable) StartSpan

func (b *Bigtable) StartSpan(ctx context.Context, protocol string, name string, attributes ...trace.Attribute) (context.Context, *trace.Span)

type ColumnReader

type ColumnReader interface {
	Read(row bigtable.Row, familyColumn string) (interface{}, error)
}

type ColumnReaderFunc

type ColumnReaderFunc func(row bigtable.Row, familyColumn string) (interface{}, error)

func (ColumnReaderFunc) Read

func (r ColumnReaderFunc) Read(row bigtable.Row, familyColumn string) (interface{}, error)

type ConnectionInfo

type ConnectionInfo struct {
	Project     string
	Instance    string
	TablePrefix string
}

DEPRECATED, use DSN instead

func NewConnectionInfo deprecated

func NewConnectionInfo(connection string) (info *ConnectionInfo, err error)

Deprecated: Use DSN instead. Explode connection string `connection` into its three parts.

type DSN

type DSN struct {
	Project                string
	Instance               string
	TablePrefix            string
	CreateTables           bool
	MaxBlocksBeforeFlush   uint64
	MaxDurationBeforeFlush time.Duration
}

func ParseDSN

func ParseDSN(dsn string) (*DSN, error)

type ErrColumnNotPresent

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

func NewErrColumnNotPresent

func NewErrColumnNotPresent(familyColumn string) *ErrColumnNotPresent

func (*ErrColumnNotPresent) Error

func (e *ErrColumnNotPresent) Error() string

type ErrEmptyValue

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

func NewErrEmptyValue

func NewErrEmptyValue(familyColumn string) *ErrEmptyValue

func (*ErrEmptyValue) Error

func (e *ErrEmptyValue) Error() string

type SetEntry

type SetEntry struct {
	Key    string
	Family string
	Column string
	Value  []byte
}

Jump to

Keyboard shortcuts

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