chiark / gitweb /
notes for compressed archive format
[ypp-sc-tools.main.git] / yarrg / notes
1 m.{153,155} Admiral, 3580s
2
3 using only cols 2,3 (buy)
4
5 changes in price,qty by island, commod, stall
6         295 rows out of 4281
7 changes in total qty by island, commod, price
8         540 rows out of 2106
9
10 stall "Couchablanca" adds lots of offers (100ish), lots else
11
12 ----------------------------------------
13
14 m.{151,153} Admiral, 38s
15
16 using only cols 2,3 (buy)
17
18 changes in price,qty by island, commod, stall
19         2 rows out of 4179
20
21 two stocks changed at one stall
22
23
24 m.{149,151} Admiral, 84s
25
26 no changes
27
28 ----------------------------------------
29
30 m.{020,145} Turtle, 271944s
31
32 by stall
33         391 / 1056      53 stall changes, 128 commod changes, if sorted
34 by price
35         334 / 797
36
37 ----------------------------------------
38
39 m.{117,145} Turtle, 47797s
40
41 by stall
42         130 / 1023
43 by price
44         135 / 757
45
46
47 ========================================
48
49 very few price changes, mostly qty changes
50
51
52 ====================
53
54 files
55         ARCHIVE.%{ocean}.lock.par               never removed
56         ARCHIVE.%{ocean}.ocean.par              updated by rename
57         ARCHIVE.%{ocean}s.%{isle}s.main.par     updated by rename
58         ARCHIVE.%{ocean}s.%{isle}s.log.par      appended, length in main
59         ARCHIVE.%{ocean}s.%{isle}s.z%d.par      create/write, length in main
60  ocean file is always updated first so lockfree readers should open
61  main, then ocean
62
63 integers are in LE byte order
64 vuint is one or more bytes with 7 bits each, BE first; top bit is "more bytes"
65
66 format for an ocean file
67         magic                                   Frame   uint8*4 59a72671
68
69         for each commodity:
70          starting with commodity 0x0001 as zero is reserved for sentinels
71                 commodity name                  uint16 name length
72                                                 uint8*length name bytes
73
74 format for a main file
75         magic                                   Frame   uint8*4 59a72672
76         number of z files                       Frame   uint32
77         length of log file in bytes             Frame   uint32
78
79         single uncompressed diff
80          representing the change from nothing to
81          the most recent uploaded data
82
83 format for a log or z file
84
85         magic                                   Frame   uint8*4 59a72673
86
87         series of diffs most recent last
88
89         for a log file, there may be some trailing garbage
90          not referred to in main file (see "length of log file")
91
92         for a z file, the file length is definitive and the last
93          entry is always valid if the file is referred to in the main
94          file, but any z file not mentioned in the main file is
95          garbage
96
97 format for a diff
98  Each diff records a change "going backwards", ie you apply the
99  diff to a more recent state to get an earlier state; the metadata
100  corresponds to the earlier state; diffs at the physical end, ie
101  logical start, of the file, contain information without previous
102  context (ie start from empty, no offers)
103
104         diff format version                     Plain   uint8 constant 0x01
105
106         timestamp delta
107          (amount by which this timestamp
108          is later than the previous upload in this file,
109          or later than 0 if there is no previous pload in this file)
110                                                 Plain   vuint time_t
111
112         for each payload stream, ie:
113         for Meta, Stall, Commod, Price, Qty:
114             in an uncompressed diff:
115                 uncompressed data               Plain   some number of bytes
116                  the uncompressed data is in the order shown below
117             in a compressed diff:
118                 compressed length               Plain   vuint
119                 compressed data                 Plain   that number of bytes
120                  the compressed data for each stream forms a continuous
121                  compression stream within each file, starting with
122                  the last diff in the file and then running backwards
123
124         diff length (reverse pointer)           Frame   uint32
125          includes length of exactly the
126          data sections marked "Plain"
127
128 format inside the payload streams
129  uncompressed streams, literally in this order
130  compressed streams: read each substream in order, but ordering
131   between substreams with a diff is semantic but not physical
132
133         metadata excluding
134          ocean, island, timestamp               Meta    uint16 metadata length
135                                                 Meta    uint8*length metadata
136
137         for each stall
138
139                 stall name                      Stall   uint16 name length
140                                                 Stall   uint8*length name
141
142                 for each commod which has changed price
143                  including ones which have been added
144
145                         commodid                Commod  uint16 commodity id
146
147                         buy price delta         Price   uint16
148                         sell price delta        Price   uint16
149                           in case of added offers, previous price
150                           is taken to be best price from previous upload
151                           at this island, or 0 if previously no offers
152
153                 sentinel commodid               Commod  uint16 constant 0x0000
154
155                 for each commod which has changed qty
156                  including ones which have been added or removed
157
158                         commodid                Commod  uint16 commodity id
159                         buy qty delta           Qty     uint16
160                         sell qty delta          Qty     uint16
161
162                 sentinel commodid               Commod  uint16 constant 0x0000
163
164         sentinel stall name                     Stall   uint16 constant 0x0000