Skip to main content

ISegment Interface

A segment representing a portion of the merge tree. Segments are leaf nodes of the merge tree and contain data.

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/merge-tree/legacy.

For more information about our API support guarantees, see here.

Signature

export interface ISegment

Properties

Property Alerts Modifiers Type Description
attribution Alpha optional IAttributionCollection<AttributionKey>

Stores attribution keys associated with offsets of this segment. This data is only persisted if MergeTree's attributions.track flag is set to true. Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have attribution === undefined until ack.

Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.

cachedLength Alpha number The length of the contents of the node.
properties Alpha optional PropertySet Properties that have been added to this segment via annotation.
trackingCollection Alpha readonly TrackingGroupCollection
type Alpha readonly string

Methods

Method Alerts Return Type Description
append(segment) Alpha void
canAppend(segment) Alpha boolean
clone() Alpha ISegment
isLeaf() Alpha this is ISegment
splitAt(pos) Alpha ISegment | undefined
toJSONObject() Alpha any

Property Details

attribution

Stores attribution keys associated with offsets of this segment. This data is only persisted if MergeTree's attributions.track flag is set to true. Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have attribution === undefined until ack.

Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

attribution?: IAttributionCollection<AttributionKey>;

Type: IAttributionCollection<AttributionKey>

Remarks

There are plans to make the shape of the data stored extensible in a couple ways:

  1. Injection of custom attribution information associated with the segment (ex: copy-paste of content but keeping the old attribution information).

  2. Storage of multiple "channels" of information (ex: track property changes separately from insertion, or only attribute certain property modifications, etc.)

cachedLength

The length of the contents of the node.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

cachedLength: number;

Type: number

properties

Properties that have been added to this segment via annotation.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

properties?: PropertySet;

Type: PropertySet

trackingCollection

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

readonly trackingCollection: TrackingGroupCollection;

Type: TrackingGroupCollection

type

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

readonly type: string;

Type: string

Method Details

append

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

append(segment: ISegment): void;

Parameters

Parameter Type Description
segment ISegment

canAppend

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

canAppend(segment: ISegment): boolean;

Parameters

Parameter Type Description
segment ISegment

Returns

Return type: boolean

clone

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

clone(): ISegment;

Returns

Return type: ISegment

isLeaf

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

isLeaf(): this is ISegment;

Returns

Return type: this is ISegment

splitAt

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

splitAt(pos: number): ISegment | undefined;

Parameters

Parameter Type Description
pos number

Returns

Return type: ISegment | undefined

toJSONObject

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

toJSONObject(): any;

Returns

Return type: any