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

refactor(tree): Enable compressed encoding in pending tests #21069

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexvy86
Copy link
Contributor

@alexvy86 alexvy86 commented May 14, 2024

Description

Enables compressed encoding for some tests that were missing a schema.

Reviewer Guidance

The review process is outlined on this wiki page.

The task calls for

Essentially we want a way to use our validator for our tests (like how our customers would)

But I think that's not really what the tests AB#7111 was about needed, since they're operating at a level where the schema validator doesn't apply (they're creating a SharedTree object and directly using its editor (non-exposed API) to create changes, not schematizing it and using public APIs of ITree.

@alexvy86 alexvy86 requested a review from a team as a code owner May 14, 2024 00:22
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree base: main PRs targeted against main branch labels May 14, 2024
// Can't use assertSchema() because it sets an event listener that fails when we're rebasing
// the changes that move from one schema to another, because we try to go from an optional rootField
// to a forbidden one.
// assertSchema(peer, schemaGeneralized);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make it so the schema change is outside of the range of changes/commits that get rebased, so we can call assertSchema() like the other tests?

scope: "test",
libraries: [leaf.library],
});
const schemaGeneralized = builder.intoSchema(Any);
Copy link
Contributor

Choose a reason for hiding this comment

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

So before this change, was there no schema available for sharedtree( including a generalized one)? Was this generalized schema (as opposed to flexfield/rootField) recently introduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest I'm not entirely clear how it works :) just followed an existing pattern in other tests that used compressed encoding. I'm hoping the SharedTree team will point out if there's anything weird with the usage pattern.

tree: SharedTree,
schema: FlexTreeSchema<TRoot>,
onDispose: () => void = () => assert.fail(),
): FlexTreeView<TRoot> {
const viewSchema = new ViewSchema(defaultSchemaPolicy, {}, schema);
return requireSchema(tree.checkout, viewSchema, onDispose, createMockNodeKeyManager());
}

export function updateSchema(tree: SharedTree, schema: FlexTreeSchema): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Docs please :)

@alexvy86 alexvy86 requested a review from a team May 21, 2024 23:21
@@ -66,7 +70,7 @@ const nodesCountDeep = [
// TODO: ADO#7111 Schema should be fixed to enable schema based encoding.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this comment be removed now?

@@ -66,7 +70,7 @@ const nodesCountDeep = [
// TODO: ADO#7111 Schema should be fixed to enable schema based encoding.
const factory = new SharedTreeFactory({
jsonValidator: typeboxValidator,
treeEncodeType: TreeCompressionStrategy.Uncompressed,
treeEncodeType: TreeCompressionStrategy.Compressed,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a need to keep benchmarks for a tree without compressed encoding? Wondering if we should maintain tests for both.

Comment on lines +369 to +370
updateSchema(tree, schemaGeneralized);
assertSchema(tree, schemaGeneralized);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not familiar with how these tests work exactly but I'm wondering if schema updates and assertions should occur after the inserts on line 373?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: tree 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.

None yet

4 participants