defs

package
v0.0.0-...-b6e1e37 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Children

type Children map[NodeId]Node

todo: integrate with lamport counters

type ListNode

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

func NewListNode

func NewListNode(id NodeId) *ListNode

NewListNode returns a Node of type ListNode.

func (*ListNode) Assign

func (l *ListNode) Assign(child Node, _ bool) error

func (ListNode) Child

func (b ListNode) Child(id NodeId) (Node, error)

func (ListNode) Children

func (b ListNode) Children() Children

func (*ListNode) Clone

func (l *ListNode) Clone() (Node, error)

func (*ListNode) DeepClone

func (l *ListNode) DeepClone() (Node, error)

func (*ListNode) Delete

func (l *ListNode) Delete(id NodeId) error

func (*ListNode) Deserialize

func (l *ListNode) Deserialize(bytes []byte) error

func (ListNode) FetchChild

func (b ListNode) FetchChild(idList []NodeId) (Node, error)

func (ListNode) Id

func (b ListNode) Id() NodeId

func (*ListNode) InsertAfter

func (l *ListNode) InsertAfter(id NodeId, child Node) error

func (*ListNode) InsertAtHead

func (l *ListNode) InsertAtHead(child Node) error

func (ListNode) IsTombStone

func (b ListNode) IsTombStone() bool

func (ListNode) ListIndex

func (b ListNode) ListIndex() int

func (ListNode) MarkTombstone

func (b ListNode) MarkTombstone() error

func (*ListNode) Serialize

func (l *ListNode) Serialize() ([]byte, error)

func (ListNode) SetId

func (b ListNode) SetId(id NodeId) error

func (ListNode) SetListIndex

func (b ListNode) SetListIndex(idx int) error

type MapNode

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

func NewMapNode

func NewMapNode(id NodeId) *MapNode

NewMapNode is an exported function used to create a Node of type MapNode.

func (MapNode) Assign

func (b MapNode) Assign(node Node, override bool) error

func (MapNode) Child

func (b MapNode) Child(id NodeId) (Node, error)

func (MapNode) Children

func (b MapNode) Children() Children

func (*MapNode) Clone

func (m *MapNode) Clone() (Node, error)

func (*MapNode) DeepClone

func (m *MapNode) DeepClone() (Node, error)

func (*MapNode) Delete

func (m *MapNode) Delete(id NodeId) error

func (*MapNode) Deserialize

func (m *MapNode) Deserialize(bytes []byte) error

func (MapNode) FetchChild

func (b MapNode) FetchChild(idList []NodeId) (Node, error)

func (MapNode) Id

func (b MapNode) Id() NodeId

func (MapNode) IsTombStone

func (b MapNode) IsTombStone() bool

func (MapNode) ListIndex

func (b MapNode) ListIndex() int

func (MapNode) MarkTombstone

func (b MapNode) MarkTombstone() error

func (*MapNode) Serialize

func (m *MapNode) Serialize() ([]byte, error)

func (MapNode) SetId

func (b MapNode) SetId(id NodeId) error

func (MapNode) SetListIndex

func (b MapNode) SetListIndex(idx int) error

type Node

type Node interface {
	// Id returns current Node id.
	Id() NodeId
	// SetId sets the node with the given id.
	SetId(NodeId) error

	// IsTombStone returns if the given node has already been marked as a tombstone.
	IsTombStone() bool
	// MarkTombstone marks the current node as a tombstone.
	MarkTombstone() error

	// Serialize and Deserialize aids to perform serialization and deserialization
	// of the subtree pointed by current node.
	Serialize() ([]byte, error)
	Deserialize([]byte) error

	// DeepClone performs a deepcopy and returns a copied subtree.
	DeepClone() (Node, error)
	// Clone copies just the node and not the subtree.
	Clone() (Node, error)

	// FetchChild returns the children node reachable through the given set of ids as path.
	// travserse the json tree in using []NodeId as a path
	FetchChild([]NodeId) (Node, error)

	// Child returns the children map of current node.
	Children() Children

	// Get returns child with Id if present and not marked as tombstone
	Child(NodeId) (Node, error)

	// Assign assigns argument node as a child of the current node.
	Assign(Node, bool) error

	// ListIndex is only valid if node is a child of a ListNode
	// Get listIndex for node
	ListIndex() int
	// SetListIndex sets the index value for the node
	SetListIndex(int) error

	// Delete marks the given id a tombstone.
	Delete(NodeId) error
}

Node interface represents the overall primary operations of an JSON node.

type NodeId

type NodeId string

NodeId is of type string.

type RegisterNode

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

func NewRegisterNode

func NewRegisterNode(id NodeId, value interface{}) *RegisterNode

NewRegisterNode returns a Node of type RegisterNode with given id and value.

func (RegisterNode) Assign

func (b RegisterNode) Assign(node Node, override bool) error

func (RegisterNode) Child

func (b RegisterNode) Child(id NodeId) (Node, error)

func (*RegisterNode) Children

func (r *RegisterNode) Children() Children

Child returns a nil object, as RegisterNode itself is a leaf node.

func (*RegisterNode) Clone

func (r *RegisterNode) Clone() (Node, error)

DeepClone and Clone does the same thing here

func (*RegisterNode) DeepClone

func (r *RegisterNode) DeepClone() (Node, error)

func (*RegisterNode) Delete

func (r *RegisterNode) Delete(NodeId) error

func (*RegisterNode) Deserialize

func (r *RegisterNode) Deserialize(bytes []byte) error

func (*RegisterNode) FetchChild

func (r *RegisterNode) FetchChild([]NodeId) (Node, error)

FetchChild override. RegisterNode is always a leaf node.

func (RegisterNode) Id

func (b RegisterNode) Id() NodeId

func (RegisterNode) IsTombStone

func (b RegisterNode) IsTombStone() bool

func (RegisterNode) ListIndex

func (b RegisterNode) ListIndex() int

func (RegisterNode) MarkTombstone

func (b RegisterNode) MarkTombstone() error

func (*RegisterNode) Serialize

func (r *RegisterNode) Serialize() ([]byte, error)

func (RegisterNode) SetId

func (b RegisterNode) SetId(id NodeId) error

func (RegisterNode) SetListIndex

func (b RegisterNode) SetListIndex(idx int) error

func (*RegisterNode) SetValue

func (r *RegisterNode) SetValue(val interface{})

SetValue assigns the current node with the given value.

func (*RegisterNode) Value

func (r *RegisterNode) Value() interface{}

Value returns the current RegisterNode value.

Jump to

Keyboard shortcuts

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