Skip to content

DotKernelSingle[A: Any val]

[Source]

This class is a reusable abstraction meant for use inside other CRDTs.

It is a variant of the DotKernel class which changes the indexing of the map of active values, such that at most one value per replica is retained. This simplifies the logic for data structures like CCounter which operate with this assumption.

See the docs for the DotKernel class for more information.

class ref DotKernelSingle[A: Any val] is
  Replicated ref

Implements


Constructors

create

[Source]

Instantiate under the given unique replica id.

It will only be possible to add dotted values under this replica id, aside from converging it as external data with the converge function.

new ref create(
  id': ID)
: DotKernelSingle[A] ref^

Parameters

Returns


create_in

[Source]

Instantiate under the given DotContext.

new ref create_in(
  ctx': DotContext ref)
: DotKernelSingle[A] ref^

Parameters

Returns


Public Functions

context

[Source]

Get the underlying DotContext.

fun box context()
: this->DotContext ref

Returns


is_empty

[Source]

Return true if there are no values ever recorded from any replica. This is true at creation, after calling the clear method, or after a converge that results in all values being cleared.

fun box is_empty()
: Bool val

Returns


values

[Source]

Return an iterator over the active values in this kernel.

fun box values()
: Iterator[A] ref^

Returns


update[optional D: DotKernelSingle[A] ref]

[Source]

Update the value for this replica in the map of active values. The next-sequence-numbered dot for this replica will be used, so that the new value has a happens-after causal relationship with the previous value.

fun ref update[optional D: DotKernelSingle[A] ref](
  value': A,
  delta': D = recover DotKernelSingle[A](0) end)
: D^

Parameters

  • value': A
  • delta': D = recover DotKernelSingleA end

Returns

  • D^

upsert[optional D: DotKernelSingle[A] ref]

[Source]

Update the value for this replica in the map of active values, using a function to define the strategy for updating an existing value. The next-sequence-numbered dot for this replica will be used, so that the new value has a happens-after causal relationship with the previous value.

fun ref upsert[optional D: DotKernelSingle[A] ref](
  value': A,
  fn': {(A, A): A^}[A, D] box,
  delta': D = recover DotKernelSingle[A](0) end)
: D^

Parameters

  • value': A
  • fn': {(A, A): A^}[A, D] box
  • delta': D = recover DotKernelSingleA end

Returns

  • D^

remove_value[E: EqFn[A] val, optional D: DotKernelSingle[A] ref]

[Source]

Remove all dots with this value from the map of active values, using the given eq_fn for testing equality between pairs of values of type A. They will be retained in the causal context (if they were already present).

This removes the dots and associated value while keeping reminders that we have seen them before, so that we can ignore them if we see them again.

If the value was not present, this function silently does nothing.

Accepts and returns a convergent delta-state.

fun ref remove_value[E: EqFn[A] val, optional D: DotKernelSingle[A] ref](
  value': A,
  delta': D = recover DotKernelSingle[A](0) end)
: D^

Parameters

  • value': A
  • delta': D = recover DotKernelSingleA end

Returns

  • D^

remove_all[optional D: DotKernelSingle[A] ref]

[Source]

Remove all dots currently present in the map of active values. They will be retained in the causal context.

This removes the dots and associated values while keeping reminders that we have seen them before, so that we can ignore them if we see them again.

Accepts and returns a convergent delta-state.

fun ref remove_all[optional D: DotKernelSingle[A] ref](
  delta': D = recover DotKernelSingle[A](0) end)
: D^

Parameters

  • delta': D = recover DotKernelSingleA end

Returns

  • D^

converge

[Source]

Catch up on active values and dot history from that kernel into this one, using the dot history as a context for understanding for which disagreements we are out of date, and for which disagreements the other is out of date.

fun ref converge(
  that: DotKernelSingle[A] box)
: Bool val

Parameters

Returns


converge_empty_in

[Source]

Optimize for the special case of converging from a peer with an empty map, taking only their DotContext as an argument for resolving disagreements.

fun ref converge_empty_in(
  ctx': DotContext box)
: Bool val

Parameters

Returns


string

[Source]

Return a best effort at printing the data structure. This is intended for debugging purposes only.

fun box string()
: String iso^

Returns


from_tokens

[Source]

Deserialize an instance of this data structure from a stream of tokens.

fun ref from_tokens(
  that: TokensIterator ref)
: None val ?

Parameters

Returns


each_token

[Source]

Serialize the data structure, capturing each token into the given Tokens.

fun ref each_token(
  tokens: Tokens ref)
: None val

Parameters

Returns