schema

package
v25.0.0-custom-qt-impr... Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IsWrite           contextKey = iota
	IsUniqueDgraphXid            = true
)

Variables

This section is empty.

Functions

func CheckAndModifyPreDefPredicate

func CheckAndModifyPreDefPredicate(update *pb.SchemaUpdate) bool

CheckAndModifyPreDefPredicate returns true if the initial update for the pre-defined predicate is different from the passed update. It may also modify certain predicates under specific conditions. If the passed update is not a pre-defined predicate, it returns false.

func CompleteInitialSchema

func CompleteInitialSchema(namespace uint64) []*pb.SchemaUpdate

CompleteInitialSchema returns all the schema updates regardless of the worker options. This is useful in situations where the worker options are not known in advance and it's better to create all the reserved predicates and remove them later than miss some of them. An example of such situation is during bulk loading.

func CompleteInitialTypes

func CompleteInitialTypes(namespace uint64) []*pb.TypeUpdate

CompleteInitialTypes returns all the type updates regardless of the worker options. This is useful in situations where the worker options are not known in advance or it is required to consider all initial pre-defined types. An example of such situation is while allowing type updates to go through during alter if they are same as existing pre-defined types. This is useful for live loading a previously exported schema.

func GetIndexingPredicates

func GetIndexingPredicates() []string

GetIndexingPredicates returns the list of predicates for which we are building indexes.

func GetWriteContext

func GetWriteContext(ctx context.Context) context.Context

GetWriteContext returns a context that sets the schema context for writing.

func HasTokenizerOrVectorIndexSpec

func HasTokenizerOrVectorIndexSpec(update *pb.SchemaUpdate) bool

func Init

func Init(ps *badger.DB)

Init resets the schema state, setting the underlying DB to the given pointer.

func InitialSchema

func InitialSchema(namespace uint64) []*pb.SchemaUpdate

InitialSchema returns the schema updates to insert at the beginning of Dgraph's execution. It looks at the worker options to determine which attributes to insert.

func InitialTypes

func InitialTypes(namespace uint64) []*pb.TypeUpdate

InitialTypes returns the type updates to insert at the beginning of Dgraph's execution. It looks at the worker options to determine which types to insert.

func IsPreDefTypeChanged

func IsPreDefTypeChanged(update *pb.TypeUpdate) bool

IsPreDefTypeChanged returns true if the initial update for the pre-defined type is different than the passed update. If the passed update is not a pre-defined type than it just returns false.

func Load

func Load(predicate string) error

Load reads the latest schema for the given predicate from the DB.

func LoadFromDb

func LoadFromDb(ctx context.Context) error

LoadFromDb reads schema information from db and stores it in memory

func ParseBytes

func ParseBytes(s []byte, gid uint32) (rerr error)

ParseBytes parses the byte array which holds the schema. We will reset all the globals. Overwrites schema blindly - called only during initilization in testing

func State

func State() *state

State returns the struct holding the current schema.

Types

type ParsedSchema

type ParsedSchema struct {
	Preds []*pb.SchemaUpdate
	Types []*pb.TypeUpdate
}

ParsedSchema represents the parsed schema and type updates.

func Parse

func Parse(s string) (*ParsedSchema, error)

Parse parses the schema with namespace preserved. For the types/predicates for which the namespace is not specified, it uses default.

func ParseWithNamespace

func ParseWithNamespace(s string, namespace uint64) (*ParsedSchema, error)

ParseWithNamespace parses the schema and forces the given namespace on each of the type/predicate.

Jump to

Keyboard shortcuts

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