Skip to content

Commit 695f7ed

Browse files
committed
Initial version of native coverage database format
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
1 parent 2cc0926 commit 695f7ed

67 files changed

Lines changed: 7360 additions & 174 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ dmypy.json
127127
.pyre/
128128

129129
packages/
130+
src/ucis/ncdb/_accel/_ncdb_accel.c

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ PyUCIS supports bi-directional conversion between formats using the UCIS data mo
191191
| UCIS XML | `xml` ||||| - | near |
192192
| UCIS YAML | `yaml` |||| - | - | - |
193193
| SQLite | `sqlite` |||||| **** |
194+
| **NCDB** | `ncdb` | **** | **** | **** | **** | **** | **** |
194195
| LCOV | `lcov` | - || - || - | - |
195196
| cocotb YAML | `cocotb-yaml` |||| - | - | - |
196197
| cocotb XML | `cocotb-xml` |||| - | - | - |
@@ -210,6 +211,54 @@ pyucis convert --input-format xml --output-format lcov --strict input.xml -o out
210211
pyucis convert --input-format xml --output-format cocotb-yaml --warn-summary input.xml -o out.yml
211212
```
212213

214+
## NCDB — Native Coverage Database Format
215+
216+
NCDB (`.cdb`) is a compact binary format for UCIS coverage data, implemented as a ZIP archive. It achieves **~60–73× size reduction** over SQLite by using schema-aware V2 encoding: LEB128 varints, toggle-pair compression, presence bitfields, and type-level defaults.
217+
218+
### NCDB CLI Examples
219+
220+
```bash
221+
# Convert SQLite → NCDB
222+
pyucis convert --input-format sqlite --output-format ncdb input.cdb -o compact.cdb
223+
224+
# Convert NCDB → SQLite (for tool interop)
225+
pyucis convert --input-format ncdb --output-format sqlite compact.cdb -o output.cdb
226+
227+
# Merge NCDB files (fast same-schema path avoids re-decoding the scope tree)
228+
pyucis merge --input-format ncdb --output-format ncdb run1.cdb run2.cdb -o merged.cdb
229+
230+
# Auto-detect format (.cdb files are identified by header bytes)
231+
pyucis show summary coverage.cdb
232+
```
233+
234+
### NCDB Python API
235+
236+
```python
237+
from ucis.ncdb.ncdb_writer import NcdbWriter
238+
from ucis.ncdb.ncdb_reader import NcdbReader
239+
240+
# Write any UCIS database as NCDB
241+
NcdbWriter().write(db, "coverage.cdb")
242+
243+
# Read back as an in-memory UCIS database
244+
db = NcdbReader().read("coverage.cdb")
245+
246+
# Merge NCDB files
247+
from ucis.ncdb.ncdb_merger import NcdbMerger
248+
NcdbMerger().merge(["run1.cdb", "run2.cdb"], "merged.cdb")
249+
```
250+
251+
### NCDB ZIP Archive Members
252+
253+
| Member | Contents |
254+
|--------|----------|
255+
| `manifest.json` | Format version, schema hash (for fast-path merge) |
256+
| `scope_tree.bin` | V2-encoded scope hierarchy |
257+
| `counts.bin` | Coverage hit counts (LEB128 varint or uint32 array) |
258+
| `strings.bin` | Deduplicated string table |
259+
| `history.json` | Test/merge history nodes |
260+
| `sources.json` | Source file references |
261+
213262
## Documentation
214263

215264
- [MCP Server Documentation](MCP_SERVER.md)

doc/source/reference/formats/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Technical specifications for the file formats read and written by PyUCIS.
77
.. toctree::
88
:maxdepth: 1
99

10+
ncdb-format
1011
xml-interchange
1112
yaml-format
1213
sqlite-schema

0 commit comments

Comments
 (0)