Skip to content

Commit

Permalink
refactor(tree): use SharedTree format version 3 by default (#21157)
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-achard-MS authored Jun 13, 2024
1 parent 9ce3819 commit 8f8728f
Show file tree
Hide file tree
Showing 35 changed files with 24,317 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/dds/tree/src/shared-tree/sharedTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ interface ExplicitCodecVersions extends ExplicitCoreCodecVersions {
const formatVersionToTopLevelCodecVersions = new Map<number, ExplicitCodecVersions>([
[1, { forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 1, message: 1, fieldBatch: 1 }],
[2, { forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 2, message: 2, fieldBatch: 1 }],
[3, { forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 3, message: 3, fieldBatch: 1 }],
]);

function getCodecVersions(formatVersion: number): ExplicitCodecVersions {
Expand Down Expand Up @@ -361,6 +362,11 @@ export const SharedTreeFormatVersion = {
* Requires \@fluidframework/tree \>= 2.0.0.
*/
v2: 2,

/**
* Requires \@fluidframework/tree \>= 2.0.0.
*/
v3: 3,
} as const;

/**
Expand Down Expand Up @@ -427,7 +433,7 @@ export const defaultSharedTreeOptions: Required<SharedTreeOptions> = {
jsonValidator: noopValidator,
forest: ForestType.Reference,
treeEncodeType: TreeCompressionStrategy.Compressed,
formatVersion: SharedTreeFormatVersion.v2,
formatVersion: SharedTreeFormatVersion.v3,
};

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[
{
"revision": -5,
"originatorId": "00000000-0000-4000-b000-000000000000",
"changeset": [
{
"data": {
"maxId": 2,
"changes": [
{
"fieldKey": "rootFieldKey",
"fieldKind": "ModularEditBuilder.Generic",
"change": [
[
0,
{
"fieldChanges": [
{
"fieldKey": "x",
"fieldKind": "Value",
"change": {
"r": {
"e": false,
"d": 1,
"s": 0
}
}
}
]
}
]
]
}
],
"builds": {
"builds": [
[
[
[
0,
0
]
]
]
],
"trees": {
"version": 1,
"identifiers": [],
"shapes": [
{
"c": {
"type": "com.fluidframework.leaf.number",
"value": true
}
}
],
"data": [
[
0,
1
]
]
}
}
}
}
],
"version": 3
}
]
180 changes: 180 additions & 0 deletions packages/dds/tree/src/test/snapshots/op-format/v3/schema change.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
[
{
"revision": -4,
"originatorId": "00000000-0000-4000-b000-000000000000",
"changeset": [
{
"schema": {
"new": {
"version": 1,
"nodes": {
"com.fluidframework.leaf.number": {
"leaf": 0
},
"snapshots.Point": {
"object": {
"x": {
"kind": "Value",
"types": [
"com.fluidframework.leaf.number"
]
},
"y": {
"kind": "Value",
"types": [
"com.fluidframework.leaf.number"
]
}
}
}
},
"root": {
"kind": "Optional",
"types": [
"snapshots.Point"
]
}
},
"old": {
"version": 1,
"nodes": {},
"root": {
"kind": "Forbidden",
"types": []
}
}
}
},
{
"data": {
"maxId": 1,
"changes": [
{
"fieldKey": "rootFieldKey",
"fieldKind": "Optional",
"change": {
"r": {
"e": true,
"d": 0,
"s": 1
}
}
}
],
"builds": {
"builds": [
[
[
[
1,
0
]
]
]
],
"trees": {
"version": 1,
"identifiers": [],
"shapes": [
{
"c": {
"type": "com.fluidframework.leaf.number",
"value": true
}
},
{
"c": {
"type": "snapshots.Point",
"value": false,
"fields": [
[
"x",
0
],
[
"y",
0
]
]
}
}
],
"data": [
[
1,
0,
0
]
]
}
}
}
},
{
"schema": {
"new": {
"version": 1,
"nodes": {
"com.fluidframework.leaf.number": {
"leaf": 0
},
"snapshots.Point": {
"object": {
"x": {
"kind": "Value",
"types": [
"com.fluidframework.leaf.number"
]
},
"y": {
"kind": "Value",
"types": [
"com.fluidframework.leaf.number"
]
}
}
}
},
"root": {
"kind": "Value",
"types": [
"snapshots.Point"
]
}
},
"old": {
"version": 1,
"nodes": {
"com.fluidframework.leaf.number": {
"leaf": 0
},
"snapshots.Point": {
"object": {
"x": {
"kind": "Value",
"types": [
"com.fluidframework.leaf.number"
]
},
"y": {
"kind": "Value",
"types": [
"com.fluidframework.leaf.number"
]
}
}
}
},
"root": {
"kind": "Optional",
"types": [
"snapshots.Point"
]
}
}
}
}
],
"version": 3
}
]
Loading

0 comments on commit 8f8728f

Please sign in to comment.