@cloudbitmaps/roaring 0.22.0 → 0.23.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/PRIVACY.md +23 -17
- package/README.md +13 -4
- package/dist/bin/export-segments.js +471 -173
- package/dist/bin/export-segments.js.map +3 -3
- package/dist/index.d.ts +261 -60
- package/dist/index.js +462 -169
- package/dist/index.js.map +3 -3
- package/dist/roaring-codec.d.ts +23 -22
- package/package.json +4 -3
package/dist/roaring-codec.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* SafeBitmap — the thin wrapper around the `roaring` (CRoaring) engine that owns the
|
|
3
|
-
* untrusted-bytes boundary.
|
|
4
|
-
*
|
|
5
|
-
* All (de)serialization uses the **portable** format — the stable, bounds-checked one. The
|
|
6
|
-
* `unsafe_frozen_*` formats are never used (they are explicitly documented as crash/attack
|
|
7
|
-
* vectors). Every deserialize is preceded by a hard size cap and a structural check, because the native
|
|
8
|
-
* portable deserializer bounds its reads and checks nothing else (see `portable/layout.ts`).
|
|
9
|
-
*/
|
|
10
|
-
import roaring from 'roaring';
|
|
11
|
-
import type { CodecBitmap, CodecInterface, EncodedChunk, LoadInput } from '@cloudbitmaps/core';
|
|
12
|
-
declare const RoaringBitmap32: typeof roaring.RoaringBitmap32;
|
|
13
|
-
type RoaringBitmap32 = InstanceType<typeof RoaringBitmap32>;
|
|
1
|
+
import type { CodecBitmap, CodecInterface, EncodedChunk, LoadInput, PortableBitmap } from '@cloudbitmaps/core';
|
|
14
2
|
export declare class SafeBitmap implements CodecBitmap {
|
|
15
3
|
private readonly bitmap;
|
|
16
4
|
private constructor();
|
|
@@ -31,8 +19,6 @@ export declare class SafeBitmap implements CodecBitmap {
|
|
|
31
19
|
static safeDeserialize(bytes: Uint8Array, maxBytes: number, options?: {
|
|
32
20
|
readonly whole?: boolean;
|
|
33
21
|
}): SafeBitmap;
|
|
34
|
-
/** The `roaring` bitmap this wraps, for a caller that was handed it once and keeps no wrapper. */
|
|
35
|
-
unwrap(): RoaringBitmap32;
|
|
36
22
|
serialize(): Uint8Array;
|
|
37
23
|
/**
|
|
38
24
|
* Convert containers to run-encoding where that is smaller. Representation only — membership is untouched, and
|
|
@@ -96,9 +82,10 @@ export declare class SafeBitmap implements CodecBitmap {
|
|
|
96
82
|
toUint32Array(): Uint32Array;
|
|
97
83
|
}
|
|
98
84
|
/**
|
|
99
|
-
* A bare `RoaringBitmap32` of this package's own `roaring`,
|
|
100
|
-
* containers, through the same check as any bytes, never id by id. Any
|
|
101
|
-
* bitmap from another copy of `roaring` is loaded as the ids it
|
|
85
|
+
* A bare `RoaringBitmap32` of this package's own `roaring`, or a bitmap {@link deserializePortable} returned, passed
|
|
86
|
+
* where ids go, loads as `{ bitmap }`: from its containers, through the same check as any bytes, never id by id. Any
|
|
87
|
+
* other input passes through unchanged, and a bitmap from another copy of `roaring` is loaded as the ids it
|
|
88
|
+
* iterates, which is correct and slower.
|
|
102
89
|
*/
|
|
103
90
|
export declare function bitmapAsLoadInput(input: LoadInput): LoadInput;
|
|
104
91
|
/**
|
|
@@ -108,11 +95,25 @@ export declare function bitmapAsLoadInput(input: LoadInput): LoadInput;
|
|
|
108
95
|
*/
|
|
109
96
|
export declare const roaringCodec: CodecInterface;
|
|
110
97
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
98
|
+
* A decoded bitmap that can only be read: what {@link deserializePortable} returns. Its ids come out ascending when
|
|
99
|
+
* it is iterated, which is a promise. It is a `PortableBitmap`, so a load takes it as `{ bitmap }`, and the library
|
|
100
|
+
* keeps no reference to it. What {@link deserializePortable} returns has these members only: a call to any other
|
|
101
|
+
* throws `TypeError`, it has no `getSerializationSizeInBytes`, and `serialize` takes exactly `'portable'`. Its class
|
|
102
|
+
* is not part of the contract: do not cast it and do not test it with `instanceof`. Passed to a method of the `roaring`
|
|
103
|
+
* package from npm in place of a `RoaringBitmap32`, it answers wrongly: decode its bytes first. `JSON.stringify` of one gives `"{}"`; write
|
|
104
|
+
* `JSON.stringify([...bitmap])`. For the rest of a Roaring library's API, decode its portable bytes with that library.
|
|
105
|
+
*/
|
|
106
|
+
export interface ReadonlyBitmap extends PortableBitmap, Iterable<number> {
|
|
107
|
+
/** How many ids it holds. */
|
|
108
|
+
readonly size: number;
|
|
109
|
+
/** Whether it holds `id`. */
|
|
110
|
+
has(id: number): boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Decode portable Roaring bytes you hold into a {@link ReadonlyBitmap}, through the check a `{ serialized }` load
|
|
114
|
+
* makes first: a size cap, a structural check, one whole bitmap, and only then the native decoder.
|
|
113
115
|
*
|
|
114
116
|
* @param bytes a `Uint8Array`, which a Node `Buffer` is.
|
|
115
117
|
* @throws {ValidationError} for bytes that are not exactly one well-formed portable bitmap, as a load refuses them.
|
|
116
118
|
*/
|
|
117
|
-
export declare function deserializePortable(bytes: Uint8Array):
|
|
118
|
-
export {};
|
|
119
|
+
export declare function deserializePortable(bytes: Uint8Array): ReadonlyBitmap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbitmaps/roaring",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Distributed, cloud-native Roaring Bitmaps — query and intersect billion-scale integer sets straight out of object storage, from a bounded RAM cache over immutable objects in your own bucket, at a fraction of an always-on cache.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"roaring",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
".": {
|
|
49
49
|
"types": "./dist/index.d.ts",
|
|
50
50
|
"default": "./dist/index.js"
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"./package.json": "./package.json"
|
|
52
53
|
},
|
|
53
54
|
"files": [
|
|
54
55
|
"dist",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"roaring": "2.7.0",
|
|
68
|
-
"@cloudbitmaps/core": "
|
|
69
|
+
"@cloudbitmaps/core": "0.23.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@types/node": "^22.0.0",
|