From fdf5361a7f005d3688b2f60190a628487a45bb66 Mon Sep 17 00:00:00 2001 From: mahach666 <79989386+mahach666@users.noreply.github.com> Date: Sat, 28 Nov 2026 05:51:26 +0300 Subject: [PATCH] Name raw values of unknown meaning by byte offset The raw DBV@ fields had bare letters (B, C, L1, L2, T) while the raw fields of the .db1 id map are named by byte offset (IdMapField65, IdMapField73). One value, two naming schemes. - Remove B, C, L1, L2, T and EventLevel from DbvDocument. The byte offsets of the domain events stay as BaseOffset, CurrentOffset and LastEventOffset; the reader checks every other raw value against the values always seen and reports deviations in Warnings, and Payload holds the raw bytes. - The vector tests now read the removed words back from the payload at their computed offsets, so the vectors still verify them. - List the removals in CompatibilitySuppressions.xml for the package validation against 0.1.0 and move the CHANGELOG entry under Breaking. Fixes #11. --- CHANGELOG.md | 8 ++- docs/public-api.md | 2 +- src/TdbIO/CompatibilitySuppressions.xml | 76 +++++++++++++++++++++++++ src/TdbIO/DbvDocument.cs | 49 ++++++---------- src/TdbIO/Internal/DbvReader.cs | 3 +- src/TdbIO/TdbIO.csproj | 4 +- tests/TdbIO.Tests/DbvTests.cs | 10 +--- tests/TdbIO.Tests/SampleTests.Tables.cs | 1 - tests/TdbIO.Tests/VectorTests.Tables.cs | 25 +++++--- 9 files changed, 123 insertions(+), 55 deletions(-) create mode 100644 src/TdbIO/CompatibilitySuppressions.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index df23bf9..12b1268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,13 @@ API between minor releases. HTML exports of `tdbio` warn on standard error how many parts are rectangular proxy boxes, and the last two also list the findings. The warnings are not part of the exported data. +### Breaking + +- `DbvDocument`: the raw fields `B`, `C`, `L1`, `L2`, `T` and `EventLevel` are removed. The offsets of the domain + events stay as `BaseOffset`, `CurrentOffset` and `LastEventOffset`; the reader checks every other raw value + against the ones always seen and reports deviations in `Warnings`, and `Payload` holds the raw bytes. Raw values + of unknown meaning are named by byte offset everywhere (`Db1Document.IdMapField65` and `IdMapField73`). + ### Changed - The IFC output of the object model is kept apart from the native engine in `src/TdbIO/Ifc`. With @@ -45,7 +52,6 @@ API between minor releases. - The DSTV NC reader and the template lexer stream their lines and tokens instead of holding them as lists. - The gzip reader takes the unpacked size in the trailer as the initial size of its buffer. - Text rows with marker `0x0C` are rejected; only `0x04` was seen in text sections. - ### Fixed - The text values of table rows are no longer required to be UTF-8. They are single-byte in the code page of the system diff --git a/docs/public-api.md b/docs/public-api.md index 552da97..ff11849 100644 --- a/docs/public-api.md +++ b/docs/public-api.md @@ -82,7 +82,7 @@ offset or line number. A warning never contains text from the file. Warnings are | --- | --- | | `TableSection` | A section of fixed-size rows, from `Db1Document.ReadTables()` or `DbvDocument.Sections`. `Ordinal`, `Offset`, `End`, `Key` (schema table number in `.db1`, else null), `RowSize`, `Descriptors` (primary and secondary index specifications), `RowsOffset` and `Rows`. `Rows` is a view over the data: a row is built when it is read. Typed bulk decoders (`AsObjects()`, `AsParts()`, `AsPoints()`, etc.) decode all rows into typed record structs. | | `TableRow` | `Offset` (of the marker byte), `Marker` (0x04 active, 0x0C deleted/superseded in `.db1`), `Body` (`RowSize` raw bytes), `A` / `CreationTimeId` (creation transaction TimeId) and `B` / `DeletionTimeId` (deletion or superseding transaction TimeId). `IsActive` and `IsDeleted` inspect the marker. `TextEncoding`: the encoding the typed decoders read the text values with, the `TdbReadOptions.TextEncoding` the file was opened with or null. Typed decoders (`AsObject()`, `AsPart()`, `AsPoint()`, etc.) decode the row body into typed record structs. | -| `DbvDocument` | A DBV@ file: `Name`, `DomainId` (`Prologue[1]`), `Generation` (`ListHeader[3]`), `BaseOffset` (`B`), `EventLevel` (`C`), `CurrentOffset` (`T[1]`), `LastEventOffset` (`T[4]`), `Prologue`, `ListHeader`, `GuidRecords`, `B`, `C`, `L1`, `L2`, `T`, `C9Records`, `Sections` and `Payload`. The raw numbers are preserved; named aliases identify the domain, generation and event offsets. | +| `DbvDocument` | A DBV@ file: `Name`, `DomainId` (`Prologue[1]`), `Generation` (`ListHeader[3]`), `BaseOffset`, `CurrentOffset` and `LastEventOffset` (the byte offsets of the domain events, checked against the relations the files always keep), `Prologue`, `ListHeader`, `GuidRecords`, `C9Records`, `Sections` and `Payload`. Raw values whose meaning is not known are not separate properties: the reader checks them against the values always seen, reports deviations in `Warnings`, and `Payload` holds the raw bytes. | | `DbvGuidRecord` | `Value` (raw), `Index` (1-based, checked against the position) and `Id`. | | `DbvC9Record` | A record that starts with `C9 C0 CE DB`: four raw numbers `R0` to `R3`. | diff --git a/src/TdbIO/CompatibilitySuppressions.xml b/src/TdbIO/CompatibilitySuppressions.xml new file mode 100644 index 0000000..c611aad --- /dev/null +++ b/src/TdbIO/CompatibilitySuppressions.xml @@ -0,0 +1,76 @@ + + + + + + CP0002 + M:TdbIO.DbvDocument.get_B + lib/net10.0/TdbIO.dll + lib/net10.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_C + lib/net10.0/TdbIO.dll + lib/net10.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_L1 + lib/net10.0/TdbIO.dll + lib/net10.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_L2 + lib/net10.0/TdbIO.dll + lib/net10.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_T + lib/net10.0/TdbIO.dll + lib/net10.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_B + lib/net8.0/TdbIO.dll + lib/net8.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_C + lib/net8.0/TdbIO.dll + lib/net8.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_L1 + lib/net8.0/TdbIO.dll + lib/net8.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_L2 + lib/net8.0/TdbIO.dll + lib/net8.0/TdbIO.dll + true + + + CP0002 + M:TdbIO.DbvDocument.get_T + lib/net8.0/TdbIO.dll + lib/net8.0/TdbIO.dll + true + + \ No newline at end of file diff --git a/src/TdbIO/DbvDocument.cs b/src/TdbIO/DbvDocument.cs index b3b7f80..7e8742d 100644 --- a/src/TdbIO/DbvDocument.cs +++ b/src/TdbIO/DbvDocument.cs @@ -4,12 +4,13 @@ namespace TdbIO; /// A gzip file whose content starts with DBV@: a name, a GUID list, a few lists of numbers and table -/// sections. Most numbers have no known meaning and are given raw; values that differ from the ones always seen are kept -/// and reported in . +/// sections. Raw values whose meaning is not known are not separate properties: the reader checks each of them against +/// the values always seen, reports deviations in , and holds +/// the raw bytes. public sealed class DbvDocument : TdbDocument { internal DbvDocument(IReadOnlyList warnings, string name, IReadOnlyList prologue, IReadOnlyList listHeader, - IReadOnlyList guidRecords, uint b, uint c, IReadOnlyList l1, IReadOnlyList l2, IReadOnlyList t, + IReadOnlyList guidRecords, uint baseOffset, uint currentOffset, uint lastEventOffset, IReadOnlyList c9Records, IReadOnlyList sections, ReadOnlyMemory payload) : base(TdbFileKind.Dbv, warnings) { @@ -17,11 +18,9 @@ internal DbvDocument(IReadOnlyList warnings, string name, IReadOnlyList< Prologue = prologue; ListHeader = listHeader; GuidRecords = guidRecords; - B = b; - C = c; - L1 = l1; - L2 = l2; - T = t; + BaseOffset = baseOffset; + CurrentOffset = currentOffset; + LastEventOffset = lastEventOffset; C9Records = c9Records; Sections = sections; Payload = payload; @@ -36,17 +35,17 @@ internal DbvDocument(IReadOnlyList warnings, string name, IReadOnlyList< /// The generation/version number of the domain file (from word 3), equals GuidRecords.Count + 1. public uint Generation => ListHeader[3]; - /// The base byte offset of domain events (alias for ). - public uint BaseOffset => B; + /// The base byte offset of the domain events: the row enders of the sections lie inside the interval that + /// starts here and ends at . The raw word is checked to be a multiple of 32. + public uint BaseOffset { get; } - /// The domain event level (alias for ; expected to be 5). - public uint EventLevel => C; + /// The byte offset after the domain events, which the reader checks to equal + /// BaseOffset + 32 · K for the length K stored before the lists. + public uint CurrentOffset { get; } - /// The current byte offset after domain events (from word 1; equals BaseOffset + 32 * L1.Count). - public uint CurrentOffset => T[1]; - - /// The byte offset of the last domain event (from word 4; equals CurrentOffset - 32). - public uint LastEventOffset => T[4]; + /// The byte offset of the last domain event, which the reader checks to equal + /// CurrentOffset − 32. + public uint LastEventOffset { get; } /// The six raw numbers after the name. public IReadOnlyList Prologue { get; } @@ -57,22 +56,6 @@ internal DbvDocument(IReadOnlyList warnings, string name, IReadOnlyList< /// The GUID records in file order. public IReadOnlyList GuidRecords { get; } - /// The raw number after the GUID records. - public uint B { get; } - - /// The raw number after . - public uint C { get; } - - /// The first list of raw numbers; its length is stored before it. - public IReadOnlyList L1 { get; } - - /// The second list of raw numbers, signed, as long as . - public IReadOnlyList L2 { get; } - - /// The six raw numbers after the lists. The first one equals the last number of ; - /// the last one is the number of . - public IReadOnlyList T { get; } - /// The records that start with C9 C0 CE DB. public IReadOnlyList C9Records { get; } diff --git a/src/TdbIO/Internal/DbvReader.cs b/src/TdbIO/Internal/DbvReader.cs index f9f9514..3e42bbb 100644 --- a/src/TdbIO/Internal/DbvReader.cs +++ b/src/TdbIO/Internal/DbvReader.cs @@ -95,8 +95,7 @@ public static DbvDocument Read(byte[] payload, List warnings, Encoding? var sections = SectionWalker.Walk(payload, (int)p, 0, SectionMode.Dbv, warnings, textEncoding); return new DbvDocument(warnings.AsReadOnly(), name, Array.AsReadOnly(prologue), Array.AsReadOnly(listHeader), - Array.AsReadOnly(records), b, c, Array.AsReadOnly(l1), Array.AsReadOnly(l2), Array.AsReadOnly(t), Array.AsReadOnly(c9), - sections, payload); + Array.AsReadOnly(records), b, t[1], t[4], Array.AsReadOnly(c9), sections, payload); } private static uint[] ReadU32s(ReadOnlySpan d, long at, int count) diff --git a/src/TdbIO/TdbIO.csproj b/src/TdbIO/TdbIO.csproj index b0e4cff..f1732f1 100644 --- a/src/TdbIO/TdbIO.csproj +++ b/src/TdbIO/TdbIO.csproj @@ -7,9 +7,11 @@ TdbIO TdbIO true - + true 0.1.0 + $(MSBuildProjectDirectory)\CompatibilitySuppressions.xml