Skip to content

Conversation

@jtoffoloDI
Copy link

Description

Create module containing utils for recovering data from corrupt log files
Potential start point:

TorQ TP Log Utils Documentation

TorQ TP Log Utils Code

KDB-X Modules

Acceptance Criteria

Please create a separate directory for each package and place code, documentation and unit tests within. All packages must have documentation and unit tests to be accepted.Package: TP Log File Recovery · DataIntellectTech kdbx-modules · Discussion #20

Project Owner

Jonathon McMurray

@jtoffoloDI
Copy link
Author

Screenshot 2026-01-02 125820

Copy link
Member

@jonathonmcmurray jonathonmcmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please align all code to style guide at https://github.com/DataIntellectTech/kdbx-modules/blob/main/style.md

(e.g. comment style, naming conventions etc.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these tests still pass? (I'm pretty sure they won't)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumping this, have you re-run the tests? I'm fairly certain they will fail

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumping this, have you re-run the tests? I'm fairly certain they will fail

result:tplogsutils.repair[testfile];

/ assert
nameCorrect:result~goodfile;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still some camelCase in here

|----------|-------------|
| `check[logfile;lastmsgtoreplay]` | Returns `logfile` if it should be used as-is per `check` logic, otherwise triggers `repair` and returns `<logfile>.good`. |
| `repair[logfile]` | Creates `<logfile>.good` and writes any recoverable messages into it. Returns the new filename. |
| `repairover[logfile;goodlogh;d]` | Internal chunk worker called repeatedly by `repair` (exported for testing/advanced use). |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is no longer exported

Comment on lines 127 to 143
### `repairover`

```q
tplogutils.repairover[logfile; goodlogh; d]
```

**Parameters**

| Parameter | Type | Description |
|----------:|------|-------------|
| `logfile` | symbol | Source logfile |
| `goodlogh` | int | Handle to the output `.good` logfile (opened via `hopen`) |
| `d` | dict | State dictionary with keys `start` and `size` (byte offset and chunk length) |

**Notes**
- `repair` calls `repairover` repeatedly using `over` and a `(start;size)` state dictionary.
- This is exported for transparency/testing; most users should call `check` or `repair`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer exported

The module exports:

```q
export:([check;repair;repairover])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated

Comment on lines 1 to 8
/ header to build deserialisable msg
header: 8 # -8!(`upd;`trade;());
/ first part of tp update msg
updmsg: `char$10 # 8 _ -8!(`upd;`trade;());
/ size of default chunk to read (10MB)
chunk: 10 * 1024 * 1024;
/ don't let single read exceed this
maxchunk: 8 * chunk;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/ header to build deserialisable msg
header: 8 # -8!(`upd;`trade;());
/ first part of tp update msg
updmsg: `char$10 # 8 _ -8!(`upd;`trade;());
/ size of default chunk to read (10MB)
chunk: 10 * 1024 * 1024;
/ don't let single read exceed this
maxchunk: 8 * chunk;
/ header to build deserialisable msg
header:8#-8!(`upd;`trade;());
/ first part of tp update msg
updmsg:`char$10#8_-8!(`upd;`trade;());
/ size of default chunk to read (10MB)
chunk:10*1024*1024;
/ don't let single read exceed this
maxchunk:8*chunk;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants