This repository was archived by the owner on May 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +1354
-37
lines changed Expand file tree Collapse file tree 7 files changed +1354
-37
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,45 @@ log.since((offset) => {
178
178
})
179
179
```
180
180
181
+ ### Compact the log (remove deleted records)
182
+
183
+ ``` js
184
+ log .compact ((err ) => {
185
+ // This callback will be called once, when the compaction is done.
186
+ })
187
+ ```
188
+
189
+ ### Track progress of compactions
190
+
191
+ As an [ obz] observable:
192
+
193
+ ``` js
194
+ log .compactionProgress ((progress ) => {
195
+ console .log (progress)
196
+ // {
197
+ // startOffset,
198
+ // compactedOffset,
199
+ // unshiftedOffset,
200
+ // percent,
201
+ // done,
202
+ // sizeDiff,
203
+ // }
204
+ })
205
+ ```
206
+
207
+ Where
208
+
209
+ - ` startOffset ` : the starting point for compaction. All offsets smaller than
210
+ this have been left untouched by the compaction algorithm.
211
+ - ` compactedOffset ` : all records up until this point have been compacted so far.
212
+ - ` unshiftedOffset ` : offset for the first record that hasn't yet been "moved"
213
+ to previous slots. Tracking this allows you to see the algorithm proceeding.
214
+ - ` percent ` : a number between 0 and 1 to indicate the progress of compaction.
215
+ - ` done ` : a boolean indicating whether compaction is ongoing (` false ` ) or done
216
+ (` true ` ).
217
+ - ` sizeDiff ` : number of bytes freed after compaction is finished. Only available
218
+ if ` done ` is ` true ` .
219
+
181
220
### Close the log
182
221
183
222
``` js
You can’t perform that action at this time.
0 commit comments