Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/cortex/blob/main/tests/import/realcheck.py # cortex aien-dev/cortex Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `cortex / tests / import / realcheck.py` 29 lines ยท 1042 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # realcheck.py DB - verification-only: independent minimal parser of a one-page table b-tree leaf 3 # (root page 2) that prints the serial type of column 0 of every row. Used to prove SQLite stores 4 # integral REAL values as integer serial types on disk (so the importer's int->f64 path is live). 5 import struct, sys 6 b = open(sys.argv[1], 'rb').read() 7 ps = struct.unpack('>H', b[16:18])[0] 8 ps = 65536 if ps == 1 else ps 9 pg = b[ps:2 * ps] 10 assert pg[0] == 13, 'root page 2 is not a table leaf' 11 def var(o): 12 v = 0 13 for i in range(9): 14 c = pg[o + i] 15 if i == 8: 16 return (v << 8) | c, o + 9 17 v = (v << 7) | (c & 127) 18 if c < 128: 19 return v, o + i + 1 20 n = struct.unpack('>H', pg[3:5])[0] 21 out = [] 22 for i in range(n): 23 c = struct.unpack('>H', pg[8 + 2 * i:10 + 2 * i])[0] 24 _, o = var(c) 25 rowid, o = var(o) 26 _, o = var(o) # record header size 27 st, o = var(o) # serial type of column 0 28 out.append('%d:%d' % (rowid, st)) 29 print(' '.join(out))