-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use detached attribution key (#13991)
## Description Uses detached attribution keys in `MergeTree`'s insert-only attribution policy. This avoids serializing keys with seq: 0. Note that we still optimize for size for seq-based attribution keys (by eliding the object type and serializing it as only the `seq`). Though it's possible people will create large chunks of content in a detached state, the optimization to combine adjacent and equivalent attribution keys will still avoid creating large summaries in this case. The change mostly adds coverage to various testing layers for this.
- Loading branch information
Showing
5 changed files
with
218 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/dds/merge-tree/src/test/createInsertOnlyAttributionPolicy.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*! | ||
* Copyright (c) Microsoft Corporation and contributors. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { strict as assert } from "assert"; | ||
import { createInsertOnlyAttributionPolicy } from "../attributionCollection"; | ||
import { TestClient } from "./testClient"; | ||
|
||
const localUserLongId = "localUser"; | ||
describe("createInsertOnlyAttributionPolicy", () => { | ||
let client: TestClient; | ||
let seq = 0; | ||
beforeEach(() => { | ||
client = new TestClient({ | ||
attribution: { | ||
track: true, | ||
policyFactory: createInsertOnlyAttributionPolicy, | ||
}, | ||
}); | ||
seq = 0; | ||
}); | ||
|
||
it("Attributes content on insert", () => { | ||
client.startOrUpdateCollaboration(localUserLongId); | ||
client.applyMsg(client.makeOpMessage(client.insertTextLocal(0, "ABC"), ++seq, seq - 1)); | ||
assert.deepEqual(client.getAllAttributionSeqs(), [1, 1, 1]); | ||
}); | ||
|
||
it("Attributes content inserted before starting collaboration with a detached key", () => { | ||
client.insertTextLocal(0, "C"); | ||
client.startOrUpdateCollaboration(localUserLongId); | ||
client.applyMsg(client.makeOpMessage(client.insertTextLocal(0, "AB"), ++seq, seq - 1)); | ||
assert.deepEqual(client.getAllAttributionSeqs(), [1, 1, { type: "detached", id: 0 }]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.