common

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSplitAtEstimatedQuerySize = 8 * units.MiB

DefaultSplitAtEstimatedQuerySize is the default allowed estimated query size before the TupleQuery will split the query into multiple calls.

In Postgres, it appears to be 1GB: https://dba.stackexchange.com/questions/131399/is-there-a-maximum-length-constraint-for-a-postgres-query In CockroachDB, the maximum is 16MiB: https://www.cockroachlabs.com/docs/stable/known-limitations.html#size-limits-on-statement-input-from-sql-clients As a result, we go with half of that to be on the safe side, since the estimate doesn't include the field names or operators.

Variables

View Source
var (
	// NamespaceNameKey is the attribute name for namespaces in tracers.
	NamespaceNameKey = attribute.Key("authzed.com/spicedb/sql/namespaceName")
)

Functions

This section is empty.

Types

type ReverseTupleQuery

type ReverseTupleQuery struct {
	TupleQuery
}

ReverseTupleQuery is a common reverse tuple query implementation for SQL datastore implementations.

func (ReverseTupleQuery) WithObjectRelation

func (ctq ReverseTupleQuery) WithObjectRelation(namespaceName string, relationName string) datastore.ReverseTupleQuery

type SchemaInformation

type SchemaInformation struct {
	TableTuple          string
	ColNamespace        string
	ColObjectID         string
	ColRelation         string
	ColUsersetNamespace string
	ColUsersetObjectID  string
	ColUsersetRelation  string
}

SchemaInformation holds the schema information from the SQL datastore implementation.

type TransactionPreparer

type TransactionPreparer func(ctx context.Context, tx pgx.Tx, revision datastore.Revision) error

TransactionPreparer is a function provided by the datastore to prepare the transaction before the tuple query is run.

type TupleQuery

type TupleQuery struct {
	Conn               *pgxpool.Pool
	Schema             SchemaInformation
	PrepareTransaction TransactionPreparer

	InitialQuery sq.SelectBuilder
	Revision     datastore.Revision

	Tracer           trace.Tracer
	TracerAttributes []attribute.KeyValue

	DebugName                 string
	SplitAtEstimatedQuerySize units.Base2Bytes
	// contains filtered or unexported fields
}

TupleQuery is a tuple query builder and runner shared by SQL implementations of the datastore.

func (TupleQuery) Execute

func (ctq TupleQuery) Execute(ctx context.Context) (datastore.TupleIterator, error)

func (TupleQuery) Limit

func (ctq TupleQuery) Limit(limit uint64) datastore.CommonTupleQuery

func (TupleQuery) ReverseQueryTuplesFromSubject

func (ctq TupleQuery) ReverseQueryTuplesFromSubject(subject *v0.ObjectAndRelation) datastore.ReverseTupleQuery

ReverseQueryTuplesFromSubject constructs a ReverseTupleQuery from this tuple query.

func (TupleQuery) ReverseQueryTuplesFromSubjectRelation

func (ctq TupleQuery) ReverseQueryTuplesFromSubjectRelation(subjectNamespace, subjectRelation string) datastore.ReverseTupleQuery

ReverseQueryTuplesFromSubjectRelation constructs a ReverseTupleQuery from this tuple query.

func (TupleQuery) WithObjectID

func (ctq TupleQuery) WithObjectID(objectID string) datastore.TupleQuery

func (TupleQuery) WithRelation

func (ctq TupleQuery) WithRelation(relation string) datastore.TupleQuery

func (TupleQuery) WithUserset

func (ctq TupleQuery) WithUserset(userset *v0.ObjectAndRelation) datastore.TupleQuery

func (TupleQuery) WithUsersets

func (ctq TupleQuery) WithUsersets(usersets []*v0.ObjectAndRelation) datastore.TupleQuery

Jump to

Keyboard shortcuts

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