Skip to content

Check whether marker is removed in searchForMarker #24771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025

Conversation

scarlettjlee
Copy link
Contributor

Update implementation of searchForMarker to not return removed markers. This matches what getMarkerFromId does. The unit test was passing because the removed marker is at the beginning of the string, so starting the search at index 0 is after it.

@scarlettjlee scarlettjlee requested a review from jzaffiro June 6, 2025 00:08
@scarlettjlee scarlettjlee self-assigned this Jun 6, 2025
@Copilot Copilot AI review requested due to automatic review settings June 6, 2025 00:08
@scarlettjlee scarlettjlee requested a review from a team as a code owner June 6, 2025 00:08
@github-actions github-actions bot added area: dds Issues related to distributed data structures base: main PRs targeted against main branch labels Jun 6, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the marker lookup logic in searchForMarker to ensure that removed markers are not returned, aligning its behavior with getMarkerFromId.

  • Updated the test case to reflect corrected insertion and removal indices for markers
  • Modified mergeTree.ts to exclude removed markers during search

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/dds/merge-tree/src/test/client.searchForMarker.spec.ts Adjusted marker insertion and removal indices for accurate test validation
packages/dds/merge-tree/src/mergeTree.ts Added a check to ignore removed markers in searchForMarker
Comments suppressed due to low confidence (1)

packages/dds/merge-tree/src/test/client.searchForMarker.spec.ts:599

  • Changing the insertion index and corresponding removal range ensures that the test correctly verifies that removed markers are excluded. Please double-check that these indices consistently reflect marker positions across the system.
client.insertMarkerLocal(1, ReferenceType.Tile, {

@@ -1270,7 +1270,7 @@ export class MergeTree {
segment,
(node) => {
if (node.isLeaf()) {
Copy link
Preview

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introducing the !isRemoved(node) condition prevents removed markers from being returned. Consider adding a short inline comment describing why this check is necessary for future maintainability.

Suggested change
if (node.isLeaf()) {
if (node.isLeaf()) {
// Exclude removed markers to ensure only valid markers are returned.

Copilot uses AI. Check for mistakes.

@@ -1270,7 +1270,7 @@ export class MergeTree {
segment,
(node) => {
if (node.isLeaf()) {
if (Marker.is(node) && refHasTileLabel(node, markerLabel)) {
if (!isRemoved(node) && Marker.is(node) && refHasTileLabel(node, markerLabel)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need the same check where we update leftmostTiles and rightmostTiles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftmostTiles and rightmostTiles already exclude removed tiles due to the check for (this.leafLength(segment) ?? 0) > 0

@scarlettjlee scarlettjlee merged commit e9075de into microsoft:main Jun 7, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds Issues related to distributed data structures base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants