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
Chunked encoding in tree summary #17602
Chunked encoding in tree summary #17602
Conversation
⯅ @fluid-example/bundle-size-tests: +11.45 KB
Baseline commit: ed4ffda |
experimental/dds/tree2/src/feature-libraries/forestSummarizer.ts
Outdated
Show resolved
Hide resolved
| const delta: [FieldKey, Delta.Insert[]][] = fields.map(([fieldKey, content]) => { | ||
| const jsonableTree = mapCursorField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this conversion is unneeded. Since you just need a cursor, decode(content).cursor() can be used as the Delta's content below, and you don't need to generate a jsonable tree then make a cursor from that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to prevent generating a jsonable tree to convert back to a cursor by changing to the following (shown below), but for some reason this does not convert the field cursor into an array of node cursors and the resulting cursors are still in fields mode (which leads to an error).
const cursors = mapCursorField( decode(content).cursor(), (cursor) => cursor as ITreeCursorSynchronous )
However, if I convert to a jsonable tree first (shown below), the cursors seem to be properly converted and it works.
const cursors = mapCursorField( decode(content).cursor(), jsonableTreeFromCursor, ).map(singleTextCursor);
Would there be a better way to convert the field cursor into an array of node cursors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to const cursors = mapCursorField(decode(content).cursor(), (cursor) => cursor.fork());
experimental/dds/tree2/src/test/snapshots/files/concurrent-inserts-tree3.json
Show resolved
Hide resolved
| const factory = new SharedTreeFactory({ jsonValidator: typeboxValidator }); | ||
| const factory = new SharedTreeFactory({ | ||
| jsonValidator: typeboxValidator, | ||
| summaryEncodeType: TreeCompressionStratagy.Compressed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we store textual diffs for these, if they are going to explicitly an option, I think uncompressed would make more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to TreeCompressionStrategy.Uncompressed
experimental/dds/tree2/src/feature-libraries/chunked-forest/codec/schemaBasedEncoding.ts
Outdated
Show resolved
Hide resolved
experimental/dds/tree2/src/feature-libraries/chunked-forest/codec/fence.json
Outdated
Show resolved
Hide resolved
| case TreeCompressionStrategy.Uncompressed: | ||
| return uncompressedEncode(cursor); | ||
| default: | ||
| return schemaCompressedEncode(schema, policy, cursor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using unreachableCase here would make this code less likley to get out of date if we added more options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated default case to unreachableCase
Description
This PR changes the sharedTree summary to use the chunked forest codec.