C# stores: every flush, commit and CultMesh single-file write applies a write set to the durable store
SingleFileBackingStore.ApplyWriteSet replaces WholeView and ReplaceDurable: under the lock, from the durable snapshot read there, it removes staged removals, writes staged upserts and copies every other record and the catalog entries they reference unchanged. PushAll, CommitBatchCore (conditional and unconditional, one apply) and CultMesh's write call only it. Catalog entries read from a store keep their exact bytes and are written verbatim while their decoded fields are unchanged. Derive no longer lets a registered entry publish an id nothing staged sits under. HeaderForWrite is the one header rule for the single-file and directory stores. A write is judged against variants another writer left in the file. Tests of the deleted rules are rewritten in the next commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60735753dd
commit
aa186513a5
4 changed files with 242 additions and 121 deletions
|
|
@ -293,20 +293,23 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
|
|||
pagePayload);
|
||||
}
|
||||
|
||||
// The catalog and the header follow the shared write rules: the registered entry publishes only the ids this write put a record
|
||||
// under, every other record and entry stays as the manifest holds it.
|
||||
var written = keysToWrite.Where(key => Entries.ContainsKey(key)).ToHashSet(StringComparer.Ordinal);
|
||||
var targetCatalog = CultSchemaCatalogEntry.Derive(
|
||||
currentIndex.Values,
|
||||
Entries.Values.Select(entry => entry.Descriptor.ToCatalogEntry()).ToArray(),
|
||||
written.Select(key => Entries[key].Descriptor).Distinct().Select(descriptor => descriptor.ToCatalogEntry()).ToArray(),
|
||||
currentManifest.SchemaCatalog)
|
||||
.OrderBy(entry => entry.SchemaName, StringComparer.Ordinal)
|
||||
.ThenBy(entry => entry.SchemaId, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
|
||||
// The directory store writes only its dirty pages, so it keeps a manifest already marked.
|
||||
var header = HeaderFor(
|
||||
keysToWrite.Any(key => Entries.TryGetValue(key, out var written) && written.HoldsIds),
|
||||
var header = HeaderForWrite(
|
||||
currentManifest.FormatVersion,
|
||||
wholeStore: false,
|
||||
directoryStore: true);
|
||||
written.Select(key => (bool?)Entries[key].HoldsIds),
|
||||
currentIndex.Values.Where(record => !written.Contains(record.Key)),
|
||||
directoryStore: true,
|
||||
holdsVariants: false);
|
||||
WriteManifest(targetCatalog, currentIndex.Values
|
||||
.OrderBy(record => record.Key, StringComparer.Ordinal)
|
||||
.ToArray(), header);
|
||||
|
|
|
|||
Loading…
Reference in a new issue