Skip to content

Commit

Permalink
Obliterate expansion utilities and feature flag (microsoft#22574)
Browse files Browse the repository at this point in the history
Adds some utilities and properties needed for obliterate endpoint
expansion. Split out from microsoft#22552
  • Loading branch information
jzaffiro authored Sep 19, 2024
1 parent 78cc3c9 commit c98abac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ export interface IMergeTreeOptions {
catchUpBlobName?: string;
mergeTreeEnableObliterate?: boolean;
mergeTreeEnableObliterateReconnect?: boolean;
mergeTreeEnableSidedObliterate?: boolean;
mergeTreeReferencesCanSlideToEndpoint?: boolean;
// (undocumented)
mergeTreeSnapshotChunkSize?: number;
Expand Down Expand Up @@ -418,6 +419,7 @@ export interface IMoveInfo {
movedSeq: number;
movedSeqs: number[];
moveDst?: ReferencePosition;
prevObliterateByInserter?: ObliterateInfo;
wasMovedOnInsert: boolean;
}

Expand Down
11 changes: 11 additions & 0 deletions packages/dds/merge-tree/src/mergeTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ export interface IMergeTreeOptions {
* @defaultValue `false`
*/
mergeTreeEnableObliterateReconnect?: boolean;

/**
* Enables support for obliterate endpoint expansion.
* When enabled, obliterate operations can have sidedness specified for their endpoints.
* If an endpoint is externally anchored
* (aka the start is after a given position, or the end is before a given position),
* then concurrent inserts adjacent to the exclusive endpoint of an obliterated range will be included in the obliteration
*
* @defaultValue `false`
*/
mergeTreeEnableSidedObliterate?: boolean;
}
export function errorIfOptionNotTrue(
options: IMergeTreeOptions | undefined,
Expand Down
7 changes: 7 additions & 0 deletions packages/dds/merge-tree/src/mergeTreeNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ export interface IMoveInfo {
* calculations
*/
wasMovedOnInsert: boolean;

/**
* If a segment is inserted into an obliterated range,
* but the newest obliteration of that range was by the inserting client,
* then the segment is not obliterated because it is aware of the latest obliteration.
*/
prevObliterateByInserter?: ObliterateInfo;
}

export function toMoveInfo(maybe: Partial<IMoveInfo> | undefined): IMoveInfo | undefined {
Expand Down
16 changes: 16 additions & 0 deletions packages/dds/merge-tree/src/sequencePlace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,19 @@ export function endpointPosAndSide(
endPos,
};
}

/**
* Returns the given place in InteriorSequencePlace form.
*/
export function normalizePlace(place: SequencePlace): InteriorSequencePlace {
if (typeof place === "number") {
return { pos: place, side: Side.Before };
}
if (place === "start") {
return { pos: -1, side: Side.After };
}
if (place === "end") {
return { pos: -1, side: Side.Before };
}
return place;
}

0 comments on commit c98abac

Please sign in to comment.