database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	SetKeyPrefix byte = iota
	SortedSetKeyPrefix
	SQLPrefix
)
View Source
const (
	PlainValuePrefix = iota
	ReferenceValuePrefix
)
View Source
const MaxKeyResolutionLimit = 1
View Source
const MaxKeyScanLimit = 1000

Variables

View Source
var (
	ErrIndexKeyMismatch      = status.New(codes.InvalidArgument, "mismatch between provided index and key").Err()
	ErrNoReferenceProvided   = status.New(codes.InvalidArgument, "provided argument is not a reference").Err()
	ErrReferenceKeyMissing   = status.New(codes.InvalidArgument, "reference key not provided").Err()
	ErrZAddIndexMissing      = status.New(codes.InvalidArgument, "zAdd index not provided").Err()
	ErrReferenceIndexMissing = status.New(codes.InvalidArgument, "reference index not provided").Err()
	ErrDatabaseNotExists     = status.New(codes.NotFound, "database does not exist").Err()
)
View Source
var ErrFinalKeyCannotBeConvertedIntoReference = errors.New("final key cannot be converted into a reference")
View Source
var ErrIllegalArguments = store.ErrIllegalArguments
View Source
var ErrIllegalState = store.ErrIllegalState
View Source
var ErrMaxKeyResolutionLimitReached = errors.New("max key resolution limit reached. It may be due to cyclic references")
View Source
var ErrMaxKeyScanLimitExceeded = errors.New("max key scan limit exceeded")
View Source
var ErrReferencedKeyCannotBeAReference = errors.New("referenced key cannot be a reference")

Functions

func EncodeKV

func EncodeKV(key []byte, value []byte) *store.KV

func EncodeKey

func EncodeKey(key []byte) []byte

func EncodeReference

func EncodeReference(key, referencedKey []byte, atTx uint64) *store.KV

func EncodeZAdd

func EncodeZAdd(set []byte, score float64, key []byte, atTx uint64) *store.KV

func TrimPrefix added in v0.9.1

func TrimPrefix(prefixed []byte) []byte

func WrapReferenceValueAt

func WrapReferenceValueAt(key []byte, atTx uint64) []byte

func WrapWithPrefix

func WrapWithPrefix(b []byte, prefix byte) []byte

WrapWithPrefix ...

func WrapZAddReferenceAt

func WrapZAddReferenceAt(set []byte, score float64, key []byte, atTx uint64) []byte

Types

type DB

type DB interface {
	Health(e *empty.Empty) (*schema.HealthResponse, error)
	CurrentState() (*schema.ImmutableState, error)
	Set(req *schema.SetRequest) (*schema.TxMetadata, error)
	Get(req *schema.KeyRequest) (*schema.Entry, error)
	VerifiableSet(req *schema.VerifiableSetRequest) (*schema.VerifiableTx, error)
	VerifiableGet(req *schema.VerifiableGetRequest) (*schema.VerifiableEntry, error)
	GetAll(req *schema.KeyListRequest) (*schema.Entries, error)
	ExecAll(operations *schema.ExecAllRequest) (*schema.TxMetadata, error)
	Size() (uint64, error)
	Count(prefix *schema.KeyPrefix) (*schema.EntryCount, error)
	CountAll() (*schema.EntryCount, error)
	TxByID(req *schema.TxRequest) (*schema.Tx, error)
	VerifiableTxByID(req *schema.VerifiableTxRequest) (*schema.VerifiableTx, error)
	TxScan(req *schema.TxScanRequest) (*schema.TxList, error)
	History(req *schema.HistoryRequest) (*schema.Entries, error)
	SetReference(req *schema.ReferenceRequest) (*schema.TxMetadata, error)
	VerifiableSetReference(req *schema.VerifiableReferenceRequest) (*schema.VerifiableTx, error)
	ZAdd(req *schema.ZAddRequest) (*schema.TxMetadata, error)
	ZScan(req *schema.ZScanRequest) (*schema.ZEntries, error)
	VerifiableZAdd(req *schema.VerifiableZAddRequest) (*schema.VerifiableTx, error)
	Scan(req *schema.ScanRequest) (*schema.Entries, error)
	Close() error
	GetOptions() *DbOptions
	CompactIndex() error
	VerifiableSQLGet(req *schema.VerifiableSQLGetRequest) (*schema.VerifiableSQLEntry, error)
	SQLExec(req *schema.SQLExecRequest) (*schema.SQLExecResult, error)
	SQLExecPrepared(stmts []sql.SQLStmt, namedParams []*schema.NamedParam, waitForIndexing bool) (*schema.SQLExecResult, error)
	UseSnapshot(req *schema.UseSnapshotRequest) error
	SQLQuery(req *schema.SQLQueryRequest) (*schema.SQLQueryResult, error)
	SQLQueryPrepared(stmt *sql.SelectStmt, namedParams []*schema.NamedParam, renewSnapshot bool) (*schema.SQLQueryResult, error)
	ListTables() (*schema.SQLQueryResult, error)
	DescribeTable(table string) (*schema.SQLQueryResult, error)
	GetName() string
}

func NewDb

func NewDb(op *DbOptions, catalogDB DB, log logger.Logger) (DB, error)

NewDb Creates a new Database along with it's directories and files

func OpenDb

func OpenDb(op *DbOptions, catalogDB DB, log logger.Logger) (DB, error)

OpenDb Opens an existing Database from disk

type DatabaseList added in v1.0.0

type DatabaseList interface {
	Append(database DB)
	GetByIndex(index int64) DB
	GetByName(string) (DB, error)
	GetId(dbname string) int64
	Length() int
}

DatabaseList interface

func NewDatabaseList added in v1.0.0

func NewDatabaseList() DatabaseList

NewDatabaseList constructs a new database list

type DbOptions

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

DbOptions database instance options

func DefaultOption

func DefaultOption() *DbOptions

DefaultOption Initialise Db Optionts to default values

func (*DbOptions) GetCorruptionChecker

func (o *DbOptions) GetCorruptionChecker() bool

GetCorruptionChecker returns if corruption checker should start for this database instance

func (*DbOptions) GetDbName

func (o *DbOptions) GetDbName() string

GetDbName Returns Database name which is also db instance directory

func (*DbOptions) GetDbRootPath

func (o *DbOptions) GetDbRootPath() string

GetDbRootPath returns the directory in which this database resides

func (*DbOptions) GetStoreOptions

func (o *DbOptions) GetStoreOptions() *store.Options

GetStoreOptions returns backing store options

func (*DbOptions) WithCorruptionChecker

func (o *DbOptions) WithCorruptionChecker(cc bool) *DbOptions

WithCorruptionChecker sets if corruption checker should start for this database instance

func (*DbOptions) WithDbName

func (o *DbOptions) WithDbName(dbName string) *DbOptions

WithDbName sets dbName, which is also db instance directory

func (*DbOptions) WithDbRootPath

func (o *DbOptions) WithDbRootPath(Path string) *DbOptions

WithDbRootPath sets the directory in which this database will reside

func (*DbOptions) WithStoreOptions

func (o *DbOptions) WithStoreOptions(storeOpts *store.Options) *DbOptions

WithStoreOptions sets backing store options

Jump to

Keyboard shortcuts

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