|
25 | 25 |
|
26 | 26 | ;; transactions contain tree roots for the 3 tree indices,
|
27 | 27 | ;; the tree root for the data pool,
|
| 28 | +;; the 3 block counts for the tuples index tree, the tuples blocks, and the data pool index tree |
28 | 29 | ;; the internal node counter
|
29 |
| -(def tx-record-size (* 5 common/long-size)) |
| 30 | +(def tx-record-size (* 8 common/long-size)) |
30 | 31 |
|
31 | 32 | (def TxRecord {(s/required-key :r-spot) (s/maybe s/Int)
|
32 | 33 | (s/required-key :r-post) (s/maybe s/Int)
|
33 | 34 | (s/required-key :r-ospt) (s/maybe s/Int)
|
34 | 35 | (s/required-key :r-pool) (s/maybe s/Int)
|
| 36 | + (s/required-key :nr-index-node) (s/maybe s/Int) |
| 37 | + (s/required-key :nr-index-block) (s/maybe s/Int) |
| 38 | + (s/required-key :nr-pool-node) (s/maybe s/Int) |
35 | 39 | (s/required-key :nodes) s/Int
|
36 | 40 | (s/required-key :timestamp) s/Int})
|
37 | 41 |
|
|
40 | 44 | (s/one s/Int "post root id")
|
41 | 45 | (s/one s/Int "ospt root id")
|
42 | 46 | (s/one s/Int "pool root id")
|
| 47 | + (s/one s/Int "number of index nodes allocated") |
| 48 | + (s/one s/Int "number of index blocks allocated") |
| 49 | + (s/one s/Int "number of pool index nodes allocated") |
43 | 50 | (s/one s/Int "node id counter")]})
|
44 | 51 |
|
45 | 52 | (s/defn pack-tx :- TxRecordPacked
|
46 | 53 | "Packs a transaction into a vector for serialization"
|
47 |
| - [{:keys [r-spot r-post r-ospt r-pool nodes timestamp]} :- TxRecord] |
48 |
| - {:timestamp timestamp :tx-data [(or r-spot 0) (or r-post 0) (or r-ospt 0) (or r-pool 0) nodes]}) |
| 54 | + [{:keys [r-spot r-post r-ospt r-pool nr-index-node nr-index-block nr-pool-node nodes timestamp]} :- TxRecord] |
| 55 | + {:timestamp timestamp :tx-data [(or r-spot 0) (or r-post 0) (or r-ospt 0) (or r-pool 0) |
| 56 | + (or nr-index-node 0) (or nr-index-block 0) (or nr-pool-node 0) |
| 57 | + nodes]}) |
49 | 58 |
|
50 | 59 | (s/defn unpack-tx :- TxRecord
|
51 | 60 | "Unpacks a transaction vector into a structure when deserializing"
|
52 |
| - [{[r-spot r-post r-ospt r-pool nodes] :tx-data timestamp :timestamp} :- TxRecordPacked] |
| 61 | + [{[r-spot r-post r-ospt r-pool |
| 62 | + nr-index-node nr-index-block nr-pool-node nodes] :tx-data |
| 63 | + timestamp :timestamp} :- TxRecordPacked] |
53 | 64 | (letfn [(non-zero [v] (and v (when-not (zero? v) v)))]
|
54 | 65 | {:r-spot (non-zero r-spot)
|
55 | 66 | :r-post (non-zero r-post)
|
56 | 67 | :r-ospt (non-zero r-ospt)
|
57 | 68 | :r-pool (non-zero r-pool)
|
| 69 | + :nr-index-node (non-zero nr-index-node) |
| 70 | + :nr-index-block (non-zero nr-index-block) |
| 71 | + :nr-pool-node (non-zero nr-pool-node) |
58 | 72 | :nodes nodes
|
59 | 73 | :timestamp timestamp}))
|
60 | 74 |
|
61 | 75 | (s/defn new-db :- TxRecordPacked
|
62 | 76 | []
|
63 |
| - {:timestamp (long-time (now)) :tx-data [0 0 0 0 0]}) |
| 77 | + {:timestamp (long-time (now)) :tx-data [0 0 0 0 0 0 0 0]}) |
64 | 78 |
|
65 | 79 | (declare ->DurableDatabase)
|
66 | 80 |
|
|
0 commit comments