Documentation ¶
Index ¶
- func CounterValueFromBytes(counterType CounterType, value []byte) interface{}
- func EscapeString(s string) string
- func ValueFromBytes(valueType ValueType, value []byte) interface{}
- type Array
- func (a *Array) Add(elem Element) *Array
- func (a *Array) AnnotatedString() string
- func (a *Array) CreatedAt() *time.Ticket
- func (a *Array) DeepCopy() Element
- func (a *Array) Delete(idx int, deletedAt *time.Ticket) Element
- func (a *Array) DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) Element
- func (a *Array) Descendants(callback func(elem Element, parent Container) bool)
- func (a *Array) Elements() []Element
- func (a *Array) FindPrevCreatedAt(createdAt *time.Ticket) *time.Ticket
- func (a *Array) Get(idx int) Element
- func (a *Array) InsertAfter(prevCreatedAt *time.Ticket, element Element)
- func (a *Array) LastCreatedAt() *time.Ticket
- func (a *Array) Len() int
- func (a *Array) Marshal() string
- func (a *Array) MoveAfter(prevCreatedAt, createdAt, executedAt *time.Ticket)
- func (a *Array) MovedAt() *time.Ticket
- func (a *Array) Purge(elem Element)
- func (a *Array) RGANodes() []*RGATreeListNode
- func (a *Array) Remove(removedAt *time.Ticket) bool
- func (a *Array) RemovedAt() *time.Ticket
- func (a *Array) SetMovedAt(movedAt *time.Ticket)
- func (a *Array) SetRemovedAt(removedAt *time.Ticket)
- type Container
- type Counter
- func (p *Counter) Bytes() []byte
- func (p *Counter) CreatedAt() *time.Ticket
- func (p *Counter) DeepCopy() Element
- func (p *Counter) Increase(v *Primitive) *Counter
- func (p *Counter) IsNumericType() bool
- func (p *Counter) Marshal() string
- func (p *Counter) MovedAt() *time.Ticket
- func (p *Counter) Remove(removedAt *time.Ticket) bool
- func (p *Counter) RemovedAt() *time.Ticket
- func (p *Counter) SetMovedAt(movedAt *time.Ticket)
- func (p *Counter) SetRemovedAt(removedAt *time.Ticket)
- func (p *Counter) ValueType() CounterType
- type CounterType
- type Element
- type ElementPair
- type Object
- func (o *Object) CreatedAt() *time.Ticket
- func (o *Object) DeepCopy() Element
- func (o *Object) Delete(k string, deletedAt *time.Ticket) Element
- func (o *Object) DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) Element
- func (o *Object) Descendants(callback func(elem Element, parent Container) bool)
- func (o *Object) Get(k string) Element
- func (o *Object) Has(k string) bool
- func (o *Object) Marshal() string
- func (o *Object) Members() map[string]Element
- func (o *Object) MovedAt() *time.Ticket
- func (o *Object) Purge(elem Element)
- func (o *Object) RHTNodes() []*RHTPQMapNode
- func (o *Object) Remove(removedAt *time.Ticket) bool
- func (o *Object) RemovedAt() *time.Ticket
- func (o *Object) Set(k string, v Element) Element
- func (o *Object) SetMovedAt(movedAt *time.Ticket)
- func (o *Object) SetRemovedAt(removedAt *time.Ticket)
- type Primitive
- func (p *Primitive) Bytes() []byte
- func (p *Primitive) CreatedAt() *time.Ticket
- func (p *Primitive) DeepCopy() Element
- func (p *Primitive) IsNumericType() bool
- func (p *Primitive) Marshal() string
- func (p *Primitive) MovedAt() *time.Ticket
- func (p *Primitive) Remove(removedAt *time.Ticket) bool
- func (p *Primitive) RemovedAt() *time.Ticket
- func (p *Primitive) SetMovedAt(movedAt *time.Ticket)
- func (p *Primitive) SetRemovedAt(removedAt *time.Ticket)
- func (p *Primitive) Value() interface{}
- func (p *Primitive) ValueType() ValueType
- type RGATreeList
- func (a *RGATreeList) Add(elem Element)
- func (a *RGATreeList) AnnotatedString() string
- func (a *RGATreeList) Delete(idx int, deletedAt *time.Ticket) *RGATreeListNode
- func (a *RGATreeList) DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) *RGATreeListNode
- func (a *RGATreeList) FindPrevCreatedAt(createdAt *time.Ticket) *time.Ticket
- func (a *RGATreeList) Get(idx int) *RGATreeListNode
- func (a *RGATreeList) InsertAfter(prevCreatedAt *time.Ticket, elem Element)
- func (a *RGATreeList) LastCreatedAt() *time.Ticket
- func (a *RGATreeList) Len() int
- func (a *RGATreeList) Marshal() string
- func (a *RGATreeList) MoveAfter(prevCreatedAt, createdAt, executedAt *time.Ticket)
- func (a *RGATreeList) Nodes() []*RGATreeListNode
- type RGATreeListNode
- type RGATreeSplit
- func (s *RGATreeSplit[V]) AnnotatedString() string
- func (s *RGATreeSplit[V]) CheckWeight() bool
- func (s *RGATreeSplit[V]) FindNode(id *RGATreeSplitNodeID) *RGATreeSplitNode[V]
- func (s *RGATreeSplit[V]) InitialHead() *RGATreeSplitNode[V]
- func (s *RGATreeSplit[V]) InsertAfter(prev, node *RGATreeSplitNode[V]) *RGATreeSplitNode[V]
- type RGATreeSplitNode
- func (s *RGATreeSplitNode[V]) DeepCopy() *RGATreeSplitNode[V]
- func (s *RGATreeSplitNode[V]) ID() *RGATreeSplitNodeID
- func (s *RGATreeSplitNode[V]) InsPrevID() *RGATreeSplitNodeID
- func (s *RGATreeSplitNode[V]) Len() int
- func (s *RGATreeSplitNode[V]) Marshal() string
- func (s *RGATreeSplitNode[V]) Remove(removedAt *time.Ticket, latestCreatedAt *time.Ticket) bool
- func (s *RGATreeSplitNode[V]) RemovedAt() *time.Ticket
- func (s *RGATreeSplitNode[V]) SetInsPrev(node *RGATreeSplitNode[V])
- func (s *RGATreeSplitNode[V]) String() string
- func (s *RGATreeSplitNode[V]) Value() V
- type RGATreeSplitNodeID
- func (id *RGATreeSplitNodeID) AnnotatedString() string
- func (id *RGATreeSplitNodeID) Compare(other llrb.Key) int
- func (id *RGATreeSplitNodeID) CreatedAt() *time.Ticket
- func (id *RGATreeSplitNodeID) Equal(other llrb.Key) bool
- func (id *RGATreeSplitNodeID) Offset() int
- func (id *RGATreeSplitNodeID) Split(offset int) *RGATreeSplitNodeID
- type RGATreeSplitNodePos
- type RGATreeSplitValue
- type RHT
- func (rht *RHT) DeepCopy() *RHT
- func (rht *RHT) Elements() map[string]string
- func (rht *RHT) Get(key string) string
- func (rht *RHT) Has(key string) bool
- func (rht *RHT) Marshal() string
- func (rht *RHT) Nodes() []*RHTNode
- func (rht *RHT) Remove(k string, executedAt *time.Ticket) string
- func (rht *RHT) Set(k, v string, executedAt *time.Ticket)
- type RHTNode
- type RHTPQMapNode
- type RHTPriorityQueueMap
- func (rht *RHTPriorityQueueMap) Delete(k string, deletedAt *time.Ticket) Element
- func (rht *RHTPriorityQueueMap) DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) Element
- func (rht *RHTPriorityQueueMap) Elements() map[string]Element
- func (rht *RHTPriorityQueueMap) Get(key string) Element
- func (rht *RHTPriorityQueueMap) Has(key string) bool
- func (rht *RHTPriorityQueueMap) Marshal() string
- func (rht *RHTPriorityQueueMap) Nodes() []*RHTPQMapNode
- func (rht *RHTPriorityQueueMap) Set(k string, v Element) Element
- func (rht *RHTPriorityQueueMap) SetInternal(k string, v Element)
- type RichText
- func (t *RichText) AnnotatedString() string
- func (t *RichText) CreateRange(from, to int) (*RGATreeSplitNodePos, *RGATreeSplitNodePos)
- func (t *RichText) CreatedAt() *time.Ticket
- func (t *RichText) DeepCopy() Element
- func (t *RichText) Edit(from, to *RGATreeSplitNodePos, ...) (*RGATreeSplitNodePos, map[string]*time.Ticket)
- func (t *RichText) Marshal() string
- func (t *RichText) MovedAt() *time.Ticket
- func (t *RichText) Nodes() []*RGATreeSplitNode[*RichTextValue]
- func (t *RichText) Remove(removedAt *time.Ticket) bool
- func (t *RichText) RemovedAt() *time.Ticket
- func (t *RichText) Select(from *RGATreeSplitNodePos, to *RGATreeSplitNodePos, executedAt *time.Ticket)
- func (t *RichText) SetMovedAt(movedAt *time.Ticket)
- func (t *RichText) SetRemovedAt(removedAt *time.Ticket)
- func (t *RichText) SetStyle(from, to *RGATreeSplitNodePos, attributes map[string]string, ...)
- type RichTextValue
- func (t *RichTextValue) AnnotatedString() string
- func (t *RichTextValue) Attrs() *RHT
- func (t *RichTextValue) DeepCopy() RGATreeSplitValue
- func (t *RichTextValue) Len() int
- func (t *RichTextValue) Marshal() string
- func (t *RichTextValue) Split(offset int) RGATreeSplitValue
- func (t *RichTextValue) String() string
- func (t *RichTextValue) Value() string
- type Root
- func (r *Root) DeepCopy() *Root
- func (r *Root) DeregisterElement(elem Element)
- func (r *Root) ElementMapLen() int
- func (r *Root) FindByCreatedAt(createdAt *time.Ticket) Element
- func (r *Root) GarbageCollect(ticket *time.Ticket) int
- func (r *Root) GarbageLen() int
- func (r *Root) Object() *Object
- func (r *Root) RegisterElement(elem Element)
- func (r *Root) RegisterRemovedElementPair(parent Container, elem Element)
- func (r *Root) RegisterTextElementWithGarbage(textType TextElement)
- func (r *Root) RemovedElementLen() int
- type Selection
- type Text
- func (t *Text) AnnotatedString() string
- func (t *Text) CheckWeight() bool
- func (t *Text) CreateRange(from, to int) (*RGATreeSplitNodePos, *RGATreeSplitNodePos)
- func (t *Text) CreatedAt() *time.Ticket
- func (t *Text) DeepCopy() Element
- func (t *Text) Edit(from, to *RGATreeSplitNodePos, ...) (*RGATreeSplitNodePos, map[string]*time.Ticket)
- func (t *Text) Marshal() string
- func (t *Text) MovedAt() *time.Ticket
- func (t *Text) Nodes() []*RGATreeSplitNode[*TextValue]
- func (t *Text) Remove(removedAt *time.Ticket) bool
- func (t *Text) RemovedAt() *time.Ticket
- func (t *Text) Select(from *RGATreeSplitNodePos, to *RGATreeSplitNodePos, executedAt *time.Ticket)
- func (t *Text) SetMovedAt(movedAt *time.Ticket)
- func (t *Text) SetRemovedAt(removedAt *time.Ticket)
- func (t *Text) String() string
- type TextElement
- type TextValue
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CounterValueFromBytes ¶
func CounterValueFromBytes(counterType CounterType, value []byte) interface{}
CounterValueFromBytes parses the given bytes into value.
func EscapeString ¶ added in v0.2.6
EscapeString returns a string that is safe to embed in a JSON document.
func ValueFromBytes ¶
ValueFromBytes parses the given bytes into value.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array represents JSON array data structure including logical clock. Array implements Element interface.
func NewArray ¶
func NewArray(elements *RGATreeList, createdAt *time.Ticket) *Array
NewArray creates a new instance of Array.
func (*Array) AnnotatedString ¶
AnnotatedString returns a String containing the metadata of the elements for debugging purpose.
func (*Array) DeleteByCreatedAt ¶
DeleteByCreatedAt deletes the given element.
func (*Array) Descendants ¶
Descendants traverse the descendants of this array.
func (*Array) FindPrevCreatedAt ¶
FindPrevCreatedAt returns the creation time of the previous element of the given element.
func (*Array) InsertAfter ¶
InsertAfter inserts the given element after the given previous element.
func (*Array) LastCreatedAt ¶
LastCreatedAt returns the creation time of the last element.
func (*Array) MoveAfter ¶
MoveAfter moves the given `createdAt` element after the `prevCreatedAt` element.
func (*Array) RGANodes ¶
func (a *Array) RGANodes() []*RGATreeListNode
RGANodes returns the slices of RGATreeListNode.
func (*Array) SetMovedAt ¶
SetMovedAt sets the move time of this array.
func (*Array) SetRemovedAt ¶ added in v0.1.6
SetRemovedAt sets the removal time of this array.
type Container ¶
type Container interface { Element // Purge physically purges the given chile element. Purge(child Element) // Descendants returns all descendants of this container. Descendants(callback func(elem Element, parent Container) bool) // DeleteByCreatedAt removes the given element from this container. DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) Element }
Container represents Array or Object.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter represents changeable number data type.
func NewCounter ¶
NewCounter creates a new instance of Counter.
func (*Counter) Increase ¶
Increase increases integer, long or double. If the result of the operation is greater than MaxInt32 or less than MinInt32, Counter's value type can be changed Integer to Long. Because in golang, int can be either int32 or int64. So we need to assert int to int32.
func (*Counter) IsNumericType ¶
IsNumericType checks for numeric types.
func (*Counter) SetMovedAt ¶
SetMovedAt sets the move time of this element.
func (*Counter) SetRemovedAt ¶ added in v0.1.6
SetRemovedAt sets the removal time of this array.
func (*Counter) ValueType ¶
func (p *Counter) ValueType() CounterType
ValueType returns the type of the value.
type CounterType ¶
type CounterType int
CounterType represents any type that can be used as a counter.
const ( IntegerCnt CounterType = iota LongCnt DoubleCnt )
The values below are the types that can be used as counters.
type Element ¶
type Element interface { // Marshal returns the JSON encoding of this element. Marshal() string // DeepCopy copies itself deeply. DeepCopy() Element // CreatedAt returns the creation time of this element. CreatedAt() *time.Ticket // MovedAt returns the move time of this element. MovedAt() *time.Ticket // SetMovedAt sets the move time of this element. SetMovedAt(*time.Ticket) // RemovedAt returns the removal time of this element. RemovedAt() *time.Ticket // Remove removes this element. Remove(*time.Ticket) bool }
Element represents JSON element.
type ElementPair ¶
type ElementPair struct {
// contains filtered or unexported fields
}
ElementPair represents pair that has a parent element and child element.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents a JSON object, but unlike regular JSON, it has time tickets which is created by logical clock.
func NewObject ¶
func NewObject(memberNodes *RHTPriorityQueueMap, createdAt *time.Ticket) *Object
NewObject creates a new instance of Object.
func (*Object) DeleteByCreatedAt ¶
DeleteByCreatedAt deletes the element of the given creation time.
func (*Object) Descendants ¶
Descendants traverse the descendants of this object.
func (*Object) RHTNodes ¶
func (o *Object) RHTNodes() []*RHTPQMapNode
RHTNodes returns the RHTPriorityQueueMap nodes.
func (*Object) SetMovedAt ¶
SetMovedAt sets the move time of this object.
func (*Object) SetRemovedAt ¶ added in v0.1.6
SetRemovedAt sets the removal time of this array.
type Primitive ¶
type Primitive struct {
// contains filtered or unexported fields
}
Primitive represents JSON primitive data type including logical lock.
func NewPrimitive ¶
NewPrimitive creates a new instance of Primitive.
func (*Primitive) IsNumericType ¶
IsNumericType checks for numeric types.
func (*Primitive) SetMovedAt ¶
SetMovedAt sets the move time of this element.
func (*Primitive) SetRemovedAt ¶ added in v0.1.6
SetRemovedAt sets the removal time of this element.
type RGATreeList ¶
type RGATreeList struct {
// contains filtered or unexported fields
}
RGATreeList is a list with improved index-based lookup in RGA. RGA is a linked list that has a logical clock and tombstone. Since RGA is composed as a linked list, index-based element search is slow, O(n). To optimise for fast insertions and removals at any index in the list, RGATreeList has a tree.
func NewRGATreeList ¶
func NewRGATreeList() *RGATreeList
NewRGATreeList creates a new instance of RGATreeList.
func (*RGATreeList) Add ¶
func (a *RGATreeList) Add(elem Element)
Add adds the given element at the last.
func (*RGATreeList) AnnotatedString ¶
func (a *RGATreeList) AnnotatedString() string
AnnotatedString returns a String containing the metadata of the node id for debugging purpose.
func (*RGATreeList) Delete ¶
func (a *RGATreeList) Delete(idx int, deletedAt *time.Ticket) *RGATreeListNode
Delete deletes the node of the given index.
func (*RGATreeList) DeleteByCreatedAt ¶
func (a *RGATreeList) DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) *RGATreeListNode
DeleteByCreatedAt deletes the given element.
func (*RGATreeList) FindPrevCreatedAt ¶
func (a *RGATreeList) FindPrevCreatedAt(createdAt *time.Ticket) *time.Ticket
FindPrevCreatedAt returns the creation time of the previous element of the given element.
func (*RGATreeList) Get ¶
func (a *RGATreeList) Get(idx int) *RGATreeListNode
Get returns the element of the given index.
func (*RGATreeList) InsertAfter ¶
func (a *RGATreeList) InsertAfter(prevCreatedAt *time.Ticket, elem Element)
InsertAfter inserts the given element after the given previous element.
func (*RGATreeList) LastCreatedAt ¶
func (a *RGATreeList) LastCreatedAt() *time.Ticket
LastCreatedAt returns the creation time of last elements.
func (*RGATreeList) Marshal ¶
func (a *RGATreeList) Marshal() string
Marshal returns the JSON encoding of this RGATreeList.
func (*RGATreeList) MoveAfter ¶
func (a *RGATreeList) MoveAfter(prevCreatedAt, createdAt, executedAt *time.Ticket)
MoveAfter moves the given `createdAt` element after the `prevCreatedAt` element.
func (*RGATreeList) Nodes ¶
func (a *RGATreeList) Nodes() []*RGATreeListNode
Nodes returns an array of elements contained in this RGATreeList. TODO: If we encounter performance issues, we need to replace this with other solution.
type RGATreeListNode ¶
type RGATreeListNode struct {
// contains filtered or unexported fields
}
RGATreeListNode is a node of RGATreeList.
func (*RGATreeListNode) CreatedAt ¶ added in v0.1.5
func (n *RGATreeListNode) CreatedAt() *time.Ticket
CreatedAt returns the creation time of this element.
func (*RGATreeListNode) Element ¶
func (n *RGATreeListNode) Element() Element
Element returns the element of this node.
func (*RGATreeListNode) Len ¶
func (n *RGATreeListNode) Len() int
Len returns the length of this node.
func (*RGATreeListNode) PositionedAt ¶ added in v0.1.5
func (n *RGATreeListNode) PositionedAt() *time.Ticket
PositionedAt returns the time this element was positioned.
func (*RGATreeListNode) String ¶
func (n *RGATreeListNode) String() string
String returns the string representation of this node.
type RGATreeSplit ¶
type RGATreeSplit[V RGATreeSplitValue] struct { // contains filtered or unexported fields }
RGATreeSplit is a block-based list with improved index-based lookup in RGA. The difference from RGATreeList is that it has data on a block basis to reduce the size of CRDT metadata. When an edit occurs on a block, the block is split.
func NewRGATreeSplit ¶
func NewRGATreeSplit[V RGATreeSplitValue](initialHead *RGATreeSplitNode[V]) *RGATreeSplit[V]
NewRGATreeSplit creates a new instance of RGATreeSplit.
func (*RGATreeSplit[V]) AnnotatedString ¶
func (s *RGATreeSplit[V]) AnnotatedString() string
AnnotatedString returns a String containing the metadata of the nodes for debugging purpose.
func (*RGATreeSplit[V]) CheckWeight ¶ added in v0.2.12
func (s *RGATreeSplit[V]) CheckWeight() bool
CheckWeight returns false when there is an incorrect weight node. for debugging purpose.
func (*RGATreeSplit[V]) FindNode ¶
func (s *RGATreeSplit[V]) FindNode(id *RGATreeSplitNodeID) *RGATreeSplitNode[V]
FindNode returns the node of the given ID.
func (*RGATreeSplit[V]) InitialHead ¶
func (s *RGATreeSplit[V]) InitialHead() *RGATreeSplitNode[V]
InitialHead returns the head node of this RGATreeSplit.
func (*RGATreeSplit[V]) InsertAfter ¶
func (s *RGATreeSplit[V]) InsertAfter(prev, node *RGATreeSplitNode[V]) *RGATreeSplitNode[V]
InsertAfter inserts the given node after the given previous node.
type RGATreeSplitNode ¶
type RGATreeSplitNode[V RGATreeSplitValue] struct { // contains filtered or unexported fields }
RGATreeSplitNode is a node of RGATreeSplit.
func InitialRichTextNode ¶
func InitialRichTextNode() *RGATreeSplitNode[*RichTextValue]
InitialRichTextNode creates an initial node of RichText. The text is edited as this node is split into multiple nodes.
func InitialTextNode ¶
func InitialTextNode() *RGATreeSplitNode[*TextValue]
InitialTextNode creates an initial node of Text. The text is edited as this node is split into multiple nodes.
func NewRGATreeSplitNode ¶
func NewRGATreeSplitNode[V RGATreeSplitValue](id *RGATreeSplitNodeID, value V) *RGATreeSplitNode[V]
NewRGATreeSplitNode creates a new instance of RGATreeSplit.
func (*RGATreeSplitNode[V]) DeepCopy ¶
func (s *RGATreeSplitNode[V]) DeepCopy() *RGATreeSplitNode[V]
DeepCopy returns a new instance of this RGATreeSplitNode without structural info.
func (*RGATreeSplitNode[V]) ID ¶
func (s *RGATreeSplitNode[V]) ID() *RGATreeSplitNodeID
ID returns the ID of this RGATreeSplitNode.
func (*RGATreeSplitNode[V]) InsPrevID ¶
func (s *RGATreeSplitNode[V]) InsPrevID() *RGATreeSplitNodeID
InsPrevID returns previous node ID at the time of this node insertion.
func (*RGATreeSplitNode[V]) Len ¶
func (s *RGATreeSplitNode[V]) Len() int
Len returns the length of this node.
func (*RGATreeSplitNode[V]) Marshal ¶ added in v0.2.6
func (s *RGATreeSplitNode[V]) Marshal() string
Marshal returns the JSON encoding of this node.
func (*RGATreeSplitNode[V]) Remove ¶
Remove removes this node if it created before the time of deletion are deleted. It only marks the deleted time (tombstone).
func (*RGATreeSplitNode[V]) RemovedAt ¶
func (s *RGATreeSplitNode[V]) RemovedAt() *time.Ticket
RemovedAt return the remove time of this node.
func (*RGATreeSplitNode[V]) SetInsPrev ¶
func (s *RGATreeSplitNode[V]) SetInsPrev(node *RGATreeSplitNode[V])
SetInsPrev sets previous node of this node insertion.
func (*RGATreeSplitNode[V]) String ¶
func (s *RGATreeSplitNode[V]) String() string
String returns the string representation of this node.
func (*RGATreeSplitNode[V]) Value ¶
func (s *RGATreeSplitNode[V]) Value() V
Value returns the value of this node.
type RGATreeSplitNodeID ¶
type RGATreeSplitNodeID struct {
// contains filtered or unexported fields
}
RGATreeSplitNodeID is an ID of RGATreeSplitNode.
func NewRGATreeSplitNodeID ¶
func NewRGATreeSplitNodeID(createdAt *time.Ticket, offset int) *RGATreeSplitNodeID
NewRGATreeSplitNodeID creates a new instance of RGATreeSplitNodeID.
func (*RGATreeSplitNodeID) AnnotatedString ¶
func (id *RGATreeSplitNodeID) AnnotatedString() string
AnnotatedString returns a String containing the metadata of the node id for debugging purpose.
func (*RGATreeSplitNodeID) Compare ¶
func (id *RGATreeSplitNodeID) Compare(other llrb.Key) int
Compare returns an integer comparing two ID. The result will be 0 if id==other, -1 if id < other, and +1 if id > other. If the receiver or argument is nil, it would panic at runtime.
func (*RGATreeSplitNodeID) CreatedAt ¶
func (id *RGATreeSplitNodeID) CreatedAt() *time.Ticket
CreatedAt returns the creation time of this ID.
func (*RGATreeSplitNodeID) Equal ¶
func (id *RGATreeSplitNodeID) Equal(other llrb.Key) bool
Equal returns whether given ID equals to this ID or not.
func (*RGATreeSplitNodeID) Offset ¶
func (id *RGATreeSplitNodeID) Offset() int
Offset returns the offset of this ID.
func (*RGATreeSplitNodeID) Split ¶
func (id *RGATreeSplitNodeID) Split(offset int) *RGATreeSplitNodeID
Split creates a new ID with an offset from this ID.
type RGATreeSplitNodePos ¶
type RGATreeSplitNodePos struct {
// contains filtered or unexported fields
}
RGATreeSplitNodePos is the position of the text inside the node.
func NewRGATreeSplitNodePos ¶
func NewRGATreeSplitNodePos(id *RGATreeSplitNodeID, offset int) *RGATreeSplitNodePos
NewRGATreeSplitNodePos creates a new instance of RGATreeSplitNodePos.
func (*RGATreeSplitNodePos) AnnotatedString ¶
func (pos *RGATreeSplitNodePos) AnnotatedString() string
AnnotatedString returns a String containing the metadata of the position for debugging purpose.
func (*RGATreeSplitNodePos) Equal ¶ added in v0.1.11
func (pos *RGATreeSplitNodePos) Equal(other *RGATreeSplitNodePos) bool
Equal returns the whether the given pos equals or not.
func (*RGATreeSplitNodePos) ID ¶
func (pos *RGATreeSplitNodePos) ID() *RGATreeSplitNodeID
ID returns the ID of this RGATreeSplitNodePos.
func (*RGATreeSplitNodePos) RelativeOffset ¶
func (pos *RGATreeSplitNodePos) RelativeOffset() int
RelativeOffset returns the relative offset of this RGATreeSplitNodePos.
type RGATreeSplitValue ¶
type RGATreeSplitValue interface { Split(offset int) RGATreeSplitValue Len() int DeepCopy() RGATreeSplitValue String() string Marshal() string AnnotatedString() string }
RGATreeSplitValue is a value of RGATreeSplitNode.
type RHT ¶
type RHT struct {
// contains filtered or unexported fields
}
RHT is a hashtable with logical clock(Replicated hashtable). For more details about RHT: http://csl.skku.edu/papers/jpdc11.pdf
func (*RHT) Elements ¶
Elements returns a map of elements because the map easy to use for loop. TODO: If we encounter performance issues, we need to replace this with other solution.
func (*RHT) Nodes ¶
Nodes returns a map of elements because the map easy to use for loop. TODO: If we encounter performance issues, we need to replace this with other solution.
type RHTNode ¶
type RHTNode struct {
// contains filtered or unexported fields
}
RHTNode is a node of RHT(Replicated Hashtable).
type RHTPQMapNode ¶
type RHTPQMapNode struct {
// contains filtered or unexported fields
}
RHTPQMapNode is a node of RHTPQMap.
func (*RHTPQMapNode) Element ¶
func (n *RHTPQMapNode) Element() Element
Element returns the element of this node.
type RHTPriorityQueueMap ¶
type RHTPriorityQueueMap struct {
// contains filtered or unexported fields
}
RHTPriorityQueueMap is a hashtable with logical clock(Replicated hashtable). The difference from RHT is that it keeps multiple values in one key. Using Max Heap, the recently inserted value from the logical clock is returned to the outside.
func NewRHTPriorityQueueMap ¶
func NewRHTPriorityQueueMap() *RHTPriorityQueueMap
NewRHTPriorityQueueMap creates a new instance of RHTPriorityQueueMap.
func (*RHTPriorityQueueMap) Delete ¶
func (rht *RHTPriorityQueueMap) Delete(k string, deletedAt *time.Ticket) Element
Delete deletes the Element of the given key.
func (*RHTPriorityQueueMap) DeleteByCreatedAt ¶
func (rht *RHTPriorityQueueMap) DeleteByCreatedAt(createdAt *time.Ticket, deletedAt *time.Ticket) Element
DeleteByCreatedAt deletes the Element of the given creation time.
func (*RHTPriorityQueueMap) Elements ¶
func (rht *RHTPriorityQueueMap) Elements() map[string]Element
Elements returns a map of elements because the map easy to use for loop. TODO: If we encounter performance issues, we need to replace this with other solution.
func (*RHTPriorityQueueMap) Get ¶
func (rht *RHTPriorityQueueMap) Get(key string) Element
Get returns the value of the given key.
func (*RHTPriorityQueueMap) Has ¶
func (rht *RHTPriorityQueueMap) Has(key string) bool
Has returns whether the element exists of the given key or not.
func (*RHTPriorityQueueMap) Marshal ¶
func (rht *RHTPriorityQueueMap) Marshal() string
Marshal returns the JSON encoding of this map.
func (*RHTPriorityQueueMap) Nodes ¶
func (rht *RHTPriorityQueueMap) Nodes() []*RHTPQMapNode
Nodes returns a map of elements because the map easy to use for loop. TODO: If we encounter performance issues, we need to replace this with other solution.
func (*RHTPriorityQueueMap) Set ¶
func (rht *RHTPriorityQueueMap) Set(k string, v Element) Element
Set sets the value of the given key. If there is an existing value, it is removed.
func (*RHTPriorityQueueMap) SetInternal ¶ added in v0.1.6
func (rht *RHTPriorityQueueMap) SetInternal(k string, v Element)
SetInternal sets the value of the given key.
type RichText ¶
type RichText struct {
// contains filtered or unexported fields
}
RichText is an extended data type for the contents of a text editor.
func NewInitialRichText ¶
func NewInitialRichText(elements *RGATreeSplit[*RichTextValue], createdAt *time.Ticket) *RichText
NewInitialRichText creates a new instance of RichText.
func NewRichText ¶
func NewRichText(elements *RGATreeSplit[*RichTextValue], createdAt *time.Ticket) *RichText
NewRichText creates a new instance of RichText.
func (*RichText) AnnotatedString ¶
AnnotatedString returns a String containing the metadata of the text for debugging purpose.
func (*RichText) CreateRange ¶
func (t *RichText) CreateRange(from, to int) (*RGATreeSplitNodePos, *RGATreeSplitNodePos)
CreateRange returns a pair of RGATreeSplitNodePos of the given integer offsets.
func (*RichText) Edit ¶
func (t *RichText) Edit( from, to *RGATreeSplitNodePos, latestCreatedAtMapByActor map[string]*time.Ticket, content string, attributes map[string]string, executedAt *time.Ticket, ) (*RGATreeSplitNodePos, map[string]*time.Ticket)
Edit edits the given range with the given content and attributes.
func (*RichText) Nodes ¶
func (t *RichText) Nodes() []*RGATreeSplitNode[*RichTextValue]
Nodes returns the internal nodes of this rich text.
func (*RichText) Select ¶
func (t *RichText) Select( from *RGATreeSplitNodePos, to *RGATreeSplitNodePos, executedAt *time.Ticket, )
Select stores that the given range has been selected.
func (*RichText) SetMovedAt ¶
SetMovedAt sets the move time of this Text.
func (*RichText) SetRemovedAt ¶ added in v0.1.6
SetRemovedAt sets the removal time of this array.
type RichTextValue ¶
type RichTextValue struct {
// contains filtered or unexported fields
}
RichTextValue is a value of RichText which has an attributes that represent the text style.
func NewRichTextValue ¶
func NewRichTextValue(attrs *RHT, value string) *RichTextValue
NewRichTextValue creates a value of RichText.
func (*RichTextValue) AnnotatedString ¶
func (t *RichTextValue) AnnotatedString() string
AnnotatedString returns a String containing the metadata of this value for debugging purpose.
func (*RichTextValue) Attrs ¶
func (t *RichTextValue) Attrs() *RHT
Attrs returns the attributes of this value.
func (*RichTextValue) DeepCopy ¶
func (t *RichTextValue) DeepCopy() RGATreeSplitValue
DeepCopy copies itself deeply.
func (*RichTextValue) Len ¶
func (t *RichTextValue) Len() int
Len returns the length of this value. It is calculated in UTF-16 code units.
func (*RichTextValue) Marshal ¶ added in v0.2.6
func (t *RichTextValue) Marshal() string
Marshal returns the JSON encoding of this text.
func (*RichTextValue) Split ¶
func (t *RichTextValue) Split(offset int) RGATreeSplitValue
Split splits this value by the given offset.
func (*RichTextValue) String ¶
func (t *RichTextValue) String() string
String returns the string representation of this value.
func (*RichTextValue) Value ¶
func (t *RichTextValue) Value() string
Value returns the value of this rich text value.
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root is a structure represents the root of JSON. It has a hash table of all JSON elements to find a specific element when applying remote changes received from server.
Every element has a unique time ticket at creation, which allows us to find a particular element.
func (*Root) DeregisterElement ¶
DeregisterElement deregister the given element from hash tables.
func (*Root) ElementMapLen ¶ added in v0.1.10
ElementMapLen returns the size of element map.
func (*Root) FindByCreatedAt ¶
FindByCreatedAt returns the element of given creation time.
func (*Root) GarbageCollect ¶
GarbageCollect purge elements that were removed before the given time.
func (*Root) GarbageLen ¶
GarbageLen returns the count of removed elements.
func (*Root) RegisterElement ¶
RegisterElement registers the given element to hash table.
func (*Root) RegisterRemovedElementPair ¶
RegisterRemovedElementPair register the given element pair to hash table.
func (*Root) RegisterTextElementWithGarbage ¶ added in v0.1.11
func (r *Root) RegisterTextElementWithGarbage(textType TextElement)
RegisterTextElementWithGarbage register the given text element with garbage to hash table.
func (*Root) RemovedElementLen ¶ added in v0.1.10
RemovedElementLen returns the size of removed element map.
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection represents the selection of text range in the editor.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text is an extended data type for the contents of a text editor.
func NewText ¶
func NewText(elements *RGATreeSplit[*TextValue], createdAt *time.Ticket) *Text
NewText creates a new instance of Text.
func (*Text) AnnotatedString ¶
AnnotatedString returns a String containing the metadata of the text for debugging purpose.
func (*Text) CheckWeight ¶ added in v0.2.12
CheckWeight returns false when there is an incorrect weight node. for debugging purpose.
func (*Text) CreateRange ¶
func (t *Text) CreateRange(from, to int) (*RGATreeSplitNodePos, *RGATreeSplitNodePos)
CreateRange returns a pair of RGATreeSplitNodePos of the given integer offsets.
func (*Text) Edit ¶
func (t *Text) Edit( from, to *RGATreeSplitNodePos, latestCreatedAtMapByActor map[string]*time.Ticket, content string, executedAt *time.Ticket, ) (*RGATreeSplitNodePos, map[string]*time.Ticket)
Edit edits the given range with the given content.
func (*Text) Nodes ¶
func (t *Text) Nodes() []*RGATreeSplitNode[*TextValue]
Nodes returns the internal nodes of this text.
func (*Text) Select ¶
func (t *Text) Select( from *RGATreeSplitNodePos, to *RGATreeSplitNodePos, executedAt *time.Ticket, )
Select stores that the given range has been selected.
func (*Text) SetMovedAt ¶
SetMovedAt sets the move time of this Text.
func (*Text) SetRemovedAt ¶ added in v0.1.6
SetRemovedAt sets the removal time of this array.
type TextElement ¶ added in v0.1.1
type TextElement interface { Element // contains filtered or unexported methods }
TextElement represents Text or RichText.
type TextValue ¶
type TextValue struct {
// contains filtered or unexported fields
}
TextValue is a value of Text.
func NewTextValue ¶
NewTextValue creates a value of Text.
func (*TextValue) AnnotatedString ¶
AnnotatedString returns a String containing the metadata of this value for debugging purpose.
func (*TextValue) DeepCopy ¶
func (t *TextValue) DeepCopy() RGATreeSplitValue
DeepCopy copies itself deeply.
func (*TextValue) Len ¶
Len returns the length of this value. It is calculated in UTF-16 code units.
func (*TextValue) Split ¶
func (t *TextValue) Split(offset int) RGATreeSplitValue
Split splits this value by the given offset.