@cloudbitmaps/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2184,6 +2184,7 @@ function writeCrbmGeneration(driver, key, chunks, options = {}) {
2184
2184
  const writer = new CrbmWriter(sink, { generation: key.generation, crypto: options.crypto });
2185
2185
  for (const { chunkKey, bitmap } of sorted) {
2186
2186
  if (bitmap.isEmpty) continue;
2187
+ bitmap.optimize?.();
2187
2188
  await writer.addChunk(chunkKey, bitmap.serialize(), bitmap.size);
2188
2189
  const pause = tick();
2189
2190
  if (pause !== null) await pause;
@@ -2199,6 +2200,7 @@ async function writeCrbmGenerationStream(driver, key, chunks, options = {}) {
2199
2200
  const writer = new CrbmWriter(sink, { generation: key.generation, crypto: options.crypto });
2200
2201
  for await (const { chunkKey, bitmap } of chunks) {
2201
2202
  if (bitmap.isEmpty) continue;
2203
+ bitmap.optimize?.();
2202
2204
  await writer.addChunk(chunkKey, bitmap.serialize(), bitmap.size);
2203
2205
  chunkKeys.push(chunkKey);
2204
2206
  cardinality += bitmap.size;
@@ -3987,7 +3989,22 @@ async function eraseNamespace(namespace, deps, options) {
3987
3989
  const destroyed = [];
3988
3990
  let segmentsShredded = 0;
3989
3991
  for (const ref of refs) {
3990
- const result = await shredSegment(ref, deps, options.allowCleartext ?? false);
3992
+ let result;
3993
+ try {
3994
+ result = await shredSegment(ref, deps, options.allowCleartext ?? false);
3995
+ } catch (err) {
3996
+ result = {
3997
+ segment: ref.segment,
3998
+ namespace: ref.namespace,
3999
+ destroyed: false,
4000
+ cryptoShredded: false,
4001
+ reason: isWriteConflictError(err) ? "contended" : `failed: ${err instanceof Error ? err.message : String(err)}`,
4002
+ // Deliberately 0, and not a partial count. `eraseWarm` may have deleted rows before it threw, but the
4003
+ // erase did not complete as a unit, so a partial figure on a failed entry would invite reading it as
4004
+ // progress toward a destruction that did not happen. The attestation that matters is `destroyed`.
4005
+ warmRowsDeleted: 0
4006
+ };
4007
+ }
3991
4008
  destroyed.push(result);
3992
4009
  if (result.cryptoShredded) {
3993
4010
  segmentsShredded += 1;