Skip to main content
Version: v1

SharedSegmentSequence Class

Signature​

export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>

Extends: SharedObject<ISharedSegmentSequenceEvents

Implements: ISharedIntervalCollection<SequenceInterval

Type Parameters​

ParameterConstraintDescription
TISegment

Constructors​

ConstructorDescription
(constructor)(dataStoreRuntime, id, attributes, segmentFromSpec)Constructs a new instance of the SharedSegmentSequence class

Properties​

PropertyTypeDescription
clientClient
idstring
loadedPromise<void>
loadedDeferredDeferred<void>
segmentFromSpec(spec: IJSONSegment) => ISegment

Methods​

MethodAlertsReturn TypeDescription
addLocalReference(lref)Deprecatedvoid
annotateRange(start, end, props, combiningOp)voidAnnotates the range with the provided properties
applyStashedOp(content)unknownApply changes from an op. Used when rehydrating an attached container with pending changes. This prepares the SharedObject for seeing an ACK for the op or resubmitting the op upon reconnection.
createLocalReferencePosition(segment, offset, refType, properties)LocalReferencePosition
createPositionReference(segment, offset, refType)DeprecatedLocalReference
didAttach()void
getContainingSegment(pos){ segment: T; offset: number; }
getCurrentSeq()number
getIntervalCollection(label)IntervalCollection<SequenceInterval>
getIntervalCollectionLabels()IterableIterator<string>
getLength()numberReturns the length of the current sequence for the client
getPosition(segment)numberReturns the current position of a segment, and -1 if the segment does not exist in this sequence
getPropertiesAtPosition(pos)PropertySet
getRangeExtentsOfPosition(pos){ posStart: number; posAfterEnd: number; }
getStackContext(startPos, rangeLabels)RangeStackMap
groupOperation(groupOp)void
initializeLocalCore()void
insertAtReferencePosition(pos, segment)void
loadCore(storage)Promise<void>
localReferencePositionToPosition(lref)number
localRefToPos(localRef)Deprecatednumber
onConnect()void
onDisconnect()void
posFromRelativePos(relativePos)numberGiven a position specified relative to a marker id, lookup the marker and convert the position to a character position.
processCore(message, local, localOpMetadata)void
processGCDataCore(serializer)voidRuns serializer over the GC data for this SharedMatrix. All the IFluidHandle's represent routes to other objects.
removeLocalReference(lref)DeprecatedLocalReferencePosition
removeLocalReferencePosition(lref)LocalReferencePosition
removeRange(start, end)IMergeTreeRemoveMsg
replaceRange(start, end, segment)voidReplace the range specified from start to end with the provided segment This is done by inserting the segment at the end of the range, followed by removing the contents of the range For a zero or reverse range (start >= end), insert at end do not remove anything
resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId)numberResolves a remote client's position against the local sequence and returns the remote client's position relative to the local sequence. The client ref seq must be above the minimum sequence number or the return value will be undefined. Generally this method is used in conjunction with signals which provide point in time values for the below parameters, and is useful for things like displaying user position. It should not be used with persisted values as persisted values will quickly become invalid as the remoteClientRefSeq moves below the minimum sequence number
reSubmitCore(content, localOpMetadata)void
submitSequenceMessage(message)void
summarizeCore(serializer, telemetryContext)ISummaryTreeWithStats
waitIntervalCollection(label)DeprecatedPromise<IntervalCollection<SequenceInterval>>
walkSegments(handler, start, end, accum, splitRange)voidWalk the underlying segments of the sequence. The walked segments may extend beyond the range if the segments cross the ranges start or end boundaries. Set split range to true to ensure only segments within the range are walked.

Constructor Details​

(constructor)​

Constructs a new instance of the SharedSegmentSequence class

Signature​

constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: IJSONSegment) => ISegment);

Parameters​

ParameterTypeDescription
dataStoreRuntimeIFluidDataStoreRuntime
idstring
attributesIChannelAttributes
segmentFromSpec(spec: IJSONSegment) => ISegment

Property Details​

client​

Signature​

protected client: Client;

Type: Client

id​

Signature​

id: string;

Type: string

loaded​

Signature​

get loaded(): Promise<void>;

Type: Promise<void>

loadedDeferred​

Signature​

protected loadedDeferred: Deferred<void>;

Type: Deferred<void>

segmentFromSpec​

Signature​

readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;

Type: (spec: IJSONSegment) => ISegment

Method Details​

addLocalReference​

This API is deprecated and will be removed in a future release.
  • use createLocalReferencePosition

Signature​

addLocalReference(lref: LocalReference): void;

Parameters​

ParameterTypeDescription
lrefLocalReference

annotateRange​

Annotates the range with the provided properties

Signature​

annotateRange(start: number, end: number, props: PropertySet, combiningOp?: ICombiningOp): void;

Parameters​

ParameterModifiersTypeDescription
startnumberThe inclusive start position of the range to annotate
endnumberThe exclusive end position of the range to annotate
propsPropertySetThe properties to annotate the range with
combiningOpoptionalICombiningOpOptional. Specifies how to combine values for the property, such as "incr" for increment.

applyStashedOp​

Apply changes from an op. Used when rehydrating an attached container with pending changes. This prepares the SharedObject for seeing an ACK for the op or resubmitting the op upon reconnection.

Signature​

protected applyStashedOp(content: any): unknown;

Parameters​

ParameterTypeDescription
contentanyContents of a stashed op.

Returns​

localMetadata of the op, to be passed to process() or resubmit() when the op is ACKed or resubmitted, respectively

Return type: unknown

createLocalReferencePosition​

Signature​

createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined): LocalReferencePosition;

Parameters​

ParameterTypeDescription
segmentT
offsetnumber
refTypeReferenceType
propertiesPropertySet | undefined

Returns​

Return type: LocalReferencePosition

createPositionReference​

This API is deprecated and will be removed in a future release.
  • use createLocalReferencePosition

Signature​

createPositionReference(segment: T, offset: number, refType: ReferenceType): LocalReference;

Parameters​

ParameterTypeDescription
segmentT
offsetnumber
refTypeReferenceType

Returns​

Return type: LocalReference

didAttach​

Signature​

protected didAttach(): void;

getContainingSegment​

Signature​

getContainingSegment(pos: number): {
segment: T;
offset: number;
};

Parameters​

ParameterTypeDescription
posnumber

Returns​

Return type: { segment: T; offset: number; }

getCurrentSeq​

Signature​

getCurrentSeq(): number;

Returns​

Return type: number

getIntervalCollection​

Signature​

getIntervalCollection(label: string): IntervalCollection<SequenceInterval>;

Parameters​

ParameterTypeDescription
labelstring

Returns​

Return type: IntervalCollection<SequenceInterval>

getIntervalCollectionLabels​

Signature​

getIntervalCollectionLabels(): IterableIterator<string>;

Returns​

an iterable object that enumerates the IntervalCollection labels Usage: const iter = this.getIntervalCollectionKeys(); for (key of iter) const collection = this.getIntervalCollection(key); ...

Return type: IterableIterator<string>

getLength​

Returns the length of the current sequence for the client

Signature​

getLength(): number;

Returns​

Return type: number

getPosition​

Returns the current position of a segment, and -1 if the segment does not exist in this sequence

Signature​

getPosition(segment: ISegment): number;

Parameters​

ParameterTypeDescription
segmentISegmentThe segment to get the position of

Returns​

Return type: number

getPropertiesAtPosition​

Signature​

getPropertiesAtPosition(pos: number): PropertySet;

Parameters​

ParameterTypeDescription
posnumber

Returns​

Return type: PropertySet

getRangeExtentsOfPosition​

Signature​

getRangeExtentsOfPosition(pos: number): {
posStart: number;
posAfterEnd: number;
};

Parameters​

ParameterTypeDescription
posnumber

Returns​

Return type: { posStart: number; posAfterEnd: number; }

getStackContext​

Signature​

getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;

Parameters​

ParameterTypeDescription
startPosnumber
rangeLabelsstring[]

Returns​

Return type: RangeStackMap

groupOperation​

Signature​

groupOperation(groupOp: IMergeTreeGroupMsg): void;

Parameters​

ParameterTypeDescription
groupOpIMergeTreeGroupMsg

initializeLocalCore​

Signature​

protected initializeLocalCore(): void;

insertAtReferencePosition​

Signature​

insertAtReferencePosition(pos: ReferencePosition, segment: T): void;

Parameters​

ParameterTypeDescription
posReferencePosition
segmentT

loadCore​

Signature​

protected loadCore(storage: IChannelStorageService): Promise<void>;

Parameters​

ParameterTypeDescription
storageIChannelStorageService

Returns​

Return type: Promise<void>

localReferencePositionToPosition​

Signature​

localReferencePositionToPosition(lref: ReferencePosition): number;

Parameters​

ParameterTypeDescription
lrefReferencePosition

Returns​

Return type: number

localRefToPos​

This API is deprecated and will be removed in a future release.
  • use localReferencePositionToPosition

Signature​

localRefToPos(localRef: LocalReference): number;

Parameters​

ParameterTypeDescription
localRefLocalReference

Returns​

Return type: number

onConnect​

Signature​

protected onConnect(): void;

onDisconnect​

Signature​

protected onDisconnect(): void;

posFromRelativePos​

Given a position specified relative to a marker id, lookup the marker and convert the position to a character position.

Signature​

posFromRelativePos(relativePos: IRelativePosition): number;

Parameters​

ParameterTypeDescription
relativePosIRelativePositionId of marker (may be indirect) and whether position is before or after marker.

Returns​

Return type: number

processCore​

Signature​

protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;

Parameters​

ParameterTypeDescription
messageISequencedDocumentMessage
localboolean
localOpMetadataunknown

processGCDataCore​

Runs serializer over the GC data for this SharedMatrix. All the IFluidHandle's represent routes to other objects.

Signature​

protected processGCDataCore(serializer: SummarySerializer): void;

Parameters​

ParameterTypeDescription
serializerSummarySerializer

removeLocalReference​

This API is deprecated and will be removed in a future release.
  • use removeLocalReferencePosition

Signature​

removeLocalReference(lref: LocalReference): LocalReferencePosition;

Parameters​

ParameterTypeDescription
lrefLocalReference

Returns​

Return type: LocalReferencePosition

removeLocalReferencePosition​

Signature​

removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition;

Parameters​

ParameterTypeDescription
lrefLocalReferencePosition

Returns​

Return type: LocalReferencePosition

removeRange​

Signature​

removeRange(start: number, end: number): IMergeTreeRemoveMsg;

Parameters​

ParameterTypeDescription
startnumberThe inclusive start of the range to remove
endnumberThe exclusive end of the range to remove

Returns​

Return type: IMergeTreeRemoveMsg

replaceRange​

Replace the range specified from start to end with the provided segment This is done by inserting the segment at the end of the range, followed by removing the contents of the range For a zero or reverse range (start >= end), insert at end do not remove anything

Signature​

protected replaceRange(start: number, end: number, segment: ISegment): void;

Parameters​

ParameterTypeDescription
startnumberThe start of the range to replace
endnumberThe end of the range to replace
segmentISegmentThe segment that will replace the range

resolveRemoteClientPosition​

Resolves a remote client's position against the local sequence and returns the remote client's position relative to the local sequence. The client ref seq must be above the minimum sequence number or the return value will be undefined. Generally this method is used in conjunction with signals which provide point in time values for the below parameters, and is useful for things like displaying user position. It should not be used with persisted values as persisted values will quickly become invalid as the remoteClientRefSeq moves below the minimum sequence number

Signature​

resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number;

Parameters​

ParameterTypeDescription
remoteClientPositionnumberThe remote client's position to resolve
remoteClientRefSeqnumberThe reference sequence number of the remote client
remoteClientIdstringThe client id of the remote client

Returns​

Return type: number

reSubmitCore​

Signature​

protected reSubmitCore(content: any, localOpMetadata: unknown): void;

Parameters​

ParameterTypeDescription
contentany
localOpMetadataunknown

submitSequenceMessage​

Signature​

submitSequenceMessage(message: IMergeTreeOp): void;

Parameters​

ParameterTypeDescription
messageIMergeTreeOp

summarizeCore​

Signature​

protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;

Parameters​

ParameterModifiersTypeDescription
serializerIFluidSerializer
telemetryContextoptionalITelemetryContext

Returns​

Return type: ISummaryTreeWithStats

waitIntervalCollection​

This API is deprecated and will be removed in a future release.
  • IntervalCollections are created on a first-write wins basis, and concurrent creates are supported. Use getIntervalCollection instead.

Signature​

waitIntervalCollection(label: string): Promise<IntervalCollection<SequenceInterval>>;

Parameters​

ParameterTypeDescription
labelstring

Returns​

Return type: Promise<IntervalCollection<SequenceInterval>>

walkSegments​

Walk the underlying segments of the sequence. The walked segments may extend beyond the range if the segments cross the ranges start or end boundaries. Set split range to true to ensure only segments within the range are walked.

Signature​

walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
Type Parameters​
ParameterDescription
TClientData

Parameters​

ParameterModifiersTypeDescription
handlerISegmentAction<TClientData>The function to handle each segment
startoptionalnumberOptional. The start of range walk.
endoptionalnumberOptional. The end of range walk
accumoptionalTClientDataOptional. An object that will be passed to the handler for accumulation
splitRangeoptionalbooleanOptional. Splits boundary segments on the range boundaries