Documentation
¶
Index ¶
- Constants
- Variables
- func DiffFromRow(ctx *sql.Context, conflict doltdb.ConflictRootObject, row sql.Row) (_ doltdb.RootObjectDiff, err error)
- type Collection
- type Conflict
- type RootObject
- type RootObjectDiff
- type RootObjectDiffChange
- type RootObjectID
- type RootObjectSerializer
- func (serializer RootObjectSerializer) CreateProllyMap(ctx context.Context, root RootValue) (prolly.AddressMap, error)
- func (serializer RootObjectSerializer) GetProllyMap(ctx context.Context, root RootValue) (prolly.AddressMap, bool, error)
- func (serializer RootObjectSerializer) WriteProllyMap(ctx context.Context, root RootValue, val prolly.AddressMap) (RootValue, error)
- type RootValue
Constants ¶
const ( FIELD_NAME_ROOT_OBJECT = "root_object" FIELD_NAME_ANCESTOR = "ancestor" FIELD_NAME_OURS = "ours" FIELD_NAME_THEIRS = "theirs" )
Variables ¶
var RootObjectDiffSchema = sql.Schema{ {Name: "from_root_ish", Type: pgtypes.Text, Default: nil, Nullable: false}, {Name: "base_value", Type: pgtypes.Text, Default: nil, Nullable: true}, {Name: "our_value", Type: pgtypes.Text, Default: nil, Nullable: true}, {Name: "our_diff_type", Type: pgtypes.Text, Default: nil, Nullable: false}, {Name: "their_value", Type: pgtypes.Text, Default: nil, Nullable: true}, {Name: "their_diff_type", Type: pgtypes.Text, Default: nil, Nullable: false}, {Name: "dolt_conflict_id", Type: pgtypes.Text, Default: nil, Nullable: false}, }
RootObjectDiffSchema is the baseline schema that is returned for root object diffs.
Functions ¶
func DiffFromRow ¶ added in v0.51.1
func DiffFromRow(ctx *sql.Context, conflict doltdb.ConflictRootObject, row sql.Row) (_ doltdb.RootObjectDiff, err error)
DiffFromRow converts a row to a conflict diff.
Types ¶
type Collection ¶
type Collection interface {
// DeserializeRootObject deserializes a root object's data.
DeserializeRootObject(ctx context.Context, data []byte) (RootObject, error)
// DiffRootObjects returns a RootObjectDiff for each change made from the ancestor that is not reflected on both
// "ours" and "theirs".
DiffRootObjects(ctx context.Context, fromHash string, ours RootObject, theirs RootObject, ancestor RootObject) ([]RootObjectDiff, RootObject, error)
// DropRootObject removes the given root object from the collection.
DropRootObject(ctx context.Context, identifier id.Id) error
// GetFieldType returns the type associated with the given diff field name. Returns nil if the name is invalid.
GetFieldType(ctx context.Context, fieldName string) *pgtypes.DoltgresType
// GetID returns the identifying ID for the Collection.
GetID() RootObjectID
// GetRootObject returns the root object matching the given ID. Returns false if it cannot be found.
GetRootObject(ctx context.Context, identifier id.Id) (RootObject, bool, error)
// HasRootObject returns whether a root object exactly matching the given ID was found.
HasRootObject(ctx context.Context, identifier id.Id) (bool, error)
// IDToTableName converts the given ID to a table name. The table name will be empty for invalid IDs.
IDToTableName(identifier id.Id) doltdb.TableName
// IterAll iterates over all root objects in the Collection.
IterAll(ctx context.Context, callback func(rootObj RootObject) (stop bool, err error)) error
// IterIDs iterates over all IDs in the Collection.
IterIDs(ctx context.Context, callback func(identifier id.Id) (stop bool, err error)) error
// PutRootObject updates the Collection with the given root object. This may error if the root object already exists.
PutRootObject(ctx context.Context, rootObj RootObject) error
// RenameRootObject changes the ID for a root object matching the old ID.
RenameRootObject(ctx context.Context, oldID id.Id, newID id.Id) error
// ResolveName finds the closest matching (or exact) ID for the given name. If an exact match is not found, then
// this may error if the name is ambiguous.
ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error)
// TableNameToID converts the given name to an ID. The ID will be invalid for empty/malformed names.
TableNameToID(name doltdb.TableName) id.Id
// UpdateField updates the field on the given root object with the new value. Returns a new root object with the
// updated field.
UpdateField(ctx context.Context, rootObject RootObject, fieldName string, newValue any) (RootObject, error)
// HandleMerge handles merging of two objects. It is guaranteed that "ours" and "theirs" will not be nil, however
// "ancestor" may or may not be nil.
HandleMerge(ctx context.Context, mro merge.MergeRootObject) (doltdb.RootObject, *merge.MergeStats, error)
// LoadCollection loads the Collection from the given root.
LoadCollection(ctx context.Context, root RootValue) (Collection, error)
// LoadCollectionHash loads the Collection hash from the given root. This does not load the entire collection from
// the root, and is therefore a bit more performant if only the hash is needed.
LoadCollectionHash(ctx context.Context, root RootValue) (hash.Hash, error)
// ResolveNameFromObjects finds the closest matching (or exact) ID for the given name. If an exact match is not
// found, then this may error if the name is ambiguous. This searches through the given root objects rather than the
// ones stored in the collection itself.
ResolveNameFromObjects(ctx context.Context, name doltdb.TableName, rootObjects []RootObject) (doltdb.TableName, id.Id, error)
// Serializer returns the serializer associated with this Collection.
Serializer() RootObjectSerializer
// UpdateRoot updates the Collection in the given root, returning the updated root.
UpdateRoot(ctx context.Context, root RootValue) (RootValue, error)
}
Collection is a collection of root objects.
type Conflict ¶ added in v0.51.1
type Conflict interface {
RootObject
doltdb.ConflictRootObject
// GetContainedRootObjectID returns the root object ID of the contained items.
GetContainedRootObjectID() RootObjectID
// Diffs returns the diffs for the conflict, along with the merged root object if there are no diffs.
Diffs(ctx context.Context) ([]RootObjectDiff, RootObject, error)
// FieldType returns the type associated with the given field name. Returns nil if the name does not match a field.
FieldType(ctx context.Context, name string) *pgtypes.DoltgresType
}
Conflict is an expanded interface on Dolt's conflict root object.
type RootObject ¶
type RootObject interface {
doltdb.RootObject
// GetID returns the root object ID.
GetID() id.Id
// GetRootObjectID returns the root object ID.
GetRootObjectID() RootObjectID
// Serialize returns the byte representation of the root object.
Serialize(ctx context.Context) ([]byte, error)
}
RootObject is an expanded interface on Dolt's root objects.
type RootObjectDiff ¶ added in v0.51.1
type RootObjectDiff struct {
Type *pgtypes.DoltgresType
FromHash string
FieldName string
AncestorValue any
OurValue any
TheirValue any
OurChange RootObjectDiffChange
TheirChange RootObjectDiffChange
}
RootObjectDiff represents a diff between the ancestor value and our/their values. The field name uniquely identifies which part of a root object that this diff covers.
func (RootObjectDiff) CompareIds ¶ added in v0.51.1
func (diff RootObjectDiff) CompareIds(ctx context.Context, o doltdb.RootObjectDiff) (int, error)
CompareIds implements the interface doltdb.RootObjectDiff.
type RootObjectDiffChange ¶ added in v0.51.1
type RootObjectDiffChange uint8
RootObjectDiffChange specifies the type of change that occurred from the ancestor value.
const ( RootObjectDiffChange_Added RootObjectDiffChange = iota RootObjectDiffChange_Deleted RootObjectDiffChange_Modified RootObjectDiffChange_NoChange )
type RootObjectID ¶
type RootObjectID int64
RootObjectID is an ID that distinguishes names and root objects from one another.
const ( RootObjectID_None RootObjectID = iota RootObjectID_Sequences RootObjectID_Types RootObjectID_Functions RootObjectID_Triggers RootObjectID_Extensions RootObjectID_Conflicts RootObjectID_Procedures )
type RootObjectSerializer ¶
type RootObjectSerializer struct {
Bytes func(*serial.RootValue) []byte
RootValueAdd func(builder *flatbuffers.Builder, sequences flatbuffers.UOffsetT)
}
RootObjectSerializer holds function pointers for the serialization of root objects.
func (RootObjectSerializer) CreateProllyMap ¶
func (serializer RootObjectSerializer) CreateProllyMap(ctx context.Context, root RootValue) (prolly.AddressMap, error)
CreateProllyMap creates and returns a new, empty Prolly map.
func (RootObjectSerializer) GetProllyMap ¶
func (serializer RootObjectSerializer) GetProllyMap(ctx context.Context, root RootValue) (prolly.AddressMap, bool, error)
GetProllyMap loads the Prolly map from the given root, using the internal serialization functions.
func (RootObjectSerializer) WriteProllyMap ¶
func (serializer RootObjectSerializer) WriteProllyMap(ctx context.Context, root RootValue, val prolly.AddressMap) (RootValue, error)
WriteProllyMap writes the given Prolly map to the root, returning the updated root.
type RootValue ¶
type RootValue interface {
doltdb.RootValue
// GetStorage returns the storage contained in the root.
GetStorage(context.Context) storage.RootStorage
// WithStorage returns an updated RootValue with the given storage.
WithStorage(context.Context, storage.RootStorage) RootValue
}
RootValue is an interface to get around import cycles, since the core package references this package (and is where RootValue is defined).