Skip to content
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

tree: Fix bug with loading detached field index #22680

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix bug with detached field index
  • Loading branch information
alex-pardes committed Sep 24, 2024
commit 3f73239396a7239f856eeacc0aaf8ef2339b37bc
10 changes: 9 additions & 1 deletion packages/dds/tree/src/core/tree/detachedFieldIndex.ts
Original file line number Diff line number Diff line change
@@ -150,7 +150,15 @@ export class DetachedFieldIndex {
});
}
this.latestRelevantRevisionToFields.delete(current);
this.latestRelevantRevisionToFields.set(updated, inner);

const updatedInner = this.latestRelevantRevisionToFields.get(updated);
if (updatedInner !== undefined) {
for (const [root, nodeId] of inner) {
updatedInner.set(root, nodeId);
}
} else {
this.latestRelevantRevisionToFields.set(updated, inner);
}
}
}

2 changes: 1 addition & 1 deletion packages/dds/tree/src/core/tree/detachedFieldIndexTypes.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export type ForestRootId = Brand<number, "tree.ForestRootId">;
export interface DetachedField {
/**
* The atomic ID that the `DetachedFieldIndex` uses to uniquely identify the first (and only) root in the field.
* This ID is scoped to the specific `DetachedFieldIndex` from witch this object was retrieved.
* This ID is scoped to the specific `DetachedFieldIndex` from which this object was retrieved.
*
* The current implementation only supports a single root per field.
* This will be changed in the future for performance reasons.