@maplibre/mlt 1.1.1 → 1.1.4
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/decoding/decodingTestUtils.d.ts +75 -0
- package/dist/decoding/decodingTestUtils.js +285 -0
- package/dist/decoding/decodingTestUtils.js.map +1 -0
- package/dist/decoding/decodingUtils.d.ts +5 -8
- package/dist/decoding/decodingUtils.js +24 -51
- package/dist/decoding/decodingUtils.js.map +1 -1
- package/dist/decoding/decodingUtils.spec.js +85 -69
- package/dist/decoding/decodingUtils.spec.js.map +1 -1
- package/dist/decoding/fsstDecoder.spec.js +52 -35
- package/dist/decoding/fsstDecoder.spec.js.map +1 -1
- package/dist/decoding/geometryDecoder.js +49 -38
- package/dist/decoding/geometryDecoder.js.map +1 -1
- package/dist/decoding/integerDecodingUtils.d.ts +18 -31
- package/dist/decoding/integerDecodingUtils.js +134 -299
- package/dist/decoding/integerDecodingUtils.js.map +1 -1
- package/dist/decoding/integerDecodingUtils.spec.js +254 -148
- package/dist/decoding/integerDecodingUtils.spec.js.map +1 -1
- package/dist/decoding/integerStreamDecoder.d.ts +5 -7
- package/dist/decoding/integerStreamDecoder.js +104 -122
- package/dist/decoding/integerStreamDecoder.js.map +1 -1
- package/dist/decoding/integerStreamDecoder.spec.js +370 -113
- package/dist/decoding/integerStreamDecoder.spec.js.map +1 -1
- package/dist/decoding/propertyDecoder.js +23 -33
- package/dist/decoding/propertyDecoder.js.map +1 -1
- package/dist/decoding/propertyDecoder.spec.js +397 -605
- package/dist/decoding/propertyDecoder.spec.js.map +1 -1
- package/dist/decoding/stringDecoder.d.ts +2 -10
- package/dist/decoding/stringDecoder.js +146 -158
- package/dist/decoding/stringDecoder.js.map +1 -1
- package/dist/decoding/stringDecoder.spec.js +322 -321
- package/dist/decoding/stringDecoder.spec.js.map +1 -1
- package/dist/decoding/unpackNullableUtils.d.ts +25 -0
- package/dist/decoding/unpackNullableUtils.js +51 -0
- package/dist/decoding/unpackNullableUtils.js.map +1 -0
- package/dist/decoding/unpackNullableUtils.spec.js +71 -0
- package/dist/decoding/unpackNullableUtils.spec.js.map +1 -0
- package/dist/encoding/embeddedTilesetMetadataEncoder.d.ts +16 -0
- package/dist/encoding/embeddedTilesetMetadataEncoder.js +40 -0
- package/dist/encoding/embeddedTilesetMetadataEncoder.js.map +1 -0
- package/dist/encoding/encodingUtils.d.ts +7 -0
- package/dist/encoding/encodingUtils.js +107 -0
- package/dist/encoding/encodingUtils.js.map +1 -0
- package/dist/encoding/fsstEncoder.d.ts +21 -0
- package/dist/encoding/fsstEncoder.js +78 -0
- package/dist/encoding/fsstEncoder.js.map +1 -0
- package/dist/encoding/integerEncodingUtils.d.ts +68 -0
- package/dist/encoding/integerEncodingUtils.js +655 -0
- package/dist/encoding/integerEncodingUtils.js.map +1 -0
- package/dist/encoding/integerStreamEncoder.d.ts +27 -0
- package/dist/encoding/integerStreamEncoder.js +139 -0
- package/dist/encoding/integerStreamEncoder.js.map +1 -0
- package/dist/encoding/packNullableUtils.d.ts +4 -0
- package/dist/encoding/packNullableUtils.js +55 -0
- package/dist/encoding/packNullableUtils.js.map +1 -0
- package/dist/encoding/propertyEncoder.d.ts +78 -0
- package/dist/encoding/propertyEncoder.js +335 -0
- package/dist/encoding/propertyEncoder.js.map +1 -0
- package/dist/encoding/stringEncoder.d.ts +12 -0
- package/dist/encoding/stringEncoder.js +182 -0
- package/dist/encoding/stringEncoder.js.map +1 -0
- package/dist/encoding/zOrderCurveEncoder.d.ts +1 -0
- package/dist/encoding/zOrderCurveEncoder.js +10 -0
- package/dist/encoding/zOrderCurveEncoder.js.map +1 -0
- package/dist/metadata/tile/streamMetadataDecoder.d.ts +28 -4
- package/dist/metadata/tile/streamMetadataDecoder.js +81 -15
- package/dist/metadata/tile/streamMetadataDecoder.js.map +1 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.d.ts +5 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.js +33 -45
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.js.map +1 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.spec.d.ts +1 -0
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.spec.js +142 -0
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.spec.js.map +1 -0
- package/dist/metadata/tileset/typeMap.d.ts +21 -29
- package/dist/metadata/tileset/typeMap.js +167 -169
- package/dist/metadata/tileset/typeMap.js.map +1 -1
- package/dist/mltDecoder.js +12 -11
- package/dist/mltDecoder.js.map +1 -1
- package/dist/vector/dictionary/stringDictionaryVector.d.ts +1 -1
- package/dist/vector/dictionary/stringDictionaryVector.js.map +1 -1
- package/dist/vector/flat/stringFlatVector.d.ts +1 -1
- package/dist/vector/flat/stringFlatVector.js.map +1 -1
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.d.ts +1 -1
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.js.map +1 -1
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.spec.js +2 -2
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.spec.js.map +1 -1
- package/dist/vector/geometry/constGpuVector.d.ts +2 -2
- package/dist/vector/geometry/constGpuVector.js.map +1 -1
- package/dist/vector/geometry/flatGpuVector.d.ts +2 -2
- package/dist/vector/geometry/flatGpuVector.js.map +1 -1
- package/dist/vector/geometry/geometryVector.js +2 -2
- package/dist/vector/geometry/geometryVector.js.map +1 -1
- package/dist/vector/geometry/geometryVectorConverter.js +4 -4
- package/dist/vector/geometry/geometryVectorConverter.js.map +1 -1
- package/dist/vector/geometry/gpuVector.d.ts +2 -2
- package/dist/vector/geometry/gpuVector.js.map +1 -1
- package/dist/vector/geometry/topologyVector.d.ts +4 -4
- package/dist/vector/geometry/topologyVector.js +0 -1
- package/dist/vector/geometry/topologyVector.js.map +1 -1
- package/dist/vector/geometry/zOrderCurve.d.ts +4 -17
- package/dist/vector/geometry/zOrderCurve.js +10 -35
- package/dist/vector/geometry/zOrderCurve.js.map +1 -1
- package/dist/vector/geometry/zOrderCurve.spec.js +21 -10
- package/dist/vector/geometry/zOrderCurve.spec.js.map +1 -1
- package/dist/vector/variableSizeVector.d.ts +2 -2
- package/dist/vector/variableSizeVector.js +0 -1
- package/dist/vector/variableSizeVector.js.map +1 -1
- package/package.json +6 -8
- package/dist/decoding/geometryDecoder.spec.js +0 -5
- package/dist/decoding/geometryDecoder.spec.js.map +0 -1
- package/dist/metadata/tile/mortonEncodedStreamMetadata.d.ts +0 -15
- package/dist/metadata/tile/mortonEncodedStreamMetadata.js +0 -27
- package/dist/metadata/tile/mortonEncodedStreamMetadata.js.map +0 -1
- package/dist/metadata/tile/rleEncodedStreamMetadata.d.ts +0 -24
- package/dist/metadata/tile/rleEncodedStreamMetadata.js +0 -38
- package/dist/metadata/tile/rleEncodedStreamMetadata.js.map +0 -1
- package/dist/metadata/tile/streamMetadata.d.ts +0 -29
- package/dist/metadata/tile/streamMetadata.js +0 -82
- package/dist/metadata/tile/streamMetadata.js.map +0 -1
- package/dist/vector/geometry/spaceFillingCurve.d.ts +0 -22
- package/dist/vector/geometry/spaceFillingCurve.js +0 -31
- package/dist/vector/geometry/spaceFillingCurve.js.map +0 -1
- /package/dist/decoding/{geometryDecoder.spec.d.ts → unpackNullableUtils.spec.d.ts} +0 -0
|
@@ -1,145 +1,402 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import {
|
|
3
|
-
import { RleEncodedStreamMetadata } from "../metadata/tile/rleEncodedStreamMetadata";
|
|
4
|
-
import { PhysicalStreamType } from "../metadata/tile/physicalStreamType";
|
|
5
|
-
import { LogicalStreamType } from "../metadata/tile/logicalStreamType";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { decodeFloat64, decodeIntStream, decodeLongStream, getVectorType } from "./integerStreamDecoder";
|
|
6
3
|
import { LogicalLevelTechnique } from "../metadata/tile/logicalLevelTechnique";
|
|
7
4
|
import { PhysicalLevelTechnique } from "../metadata/tile/physicalLevelTechnique";
|
|
8
5
|
import { VectorType } from "../vector/vectorType";
|
|
9
|
-
import { DictionaryType } from "../metadata/tile/dictionaryType";
|
|
10
6
|
import IntWrapper from "./intWrapper";
|
|
11
7
|
import BitVector from "../vector/flat/bitVector";
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
* Helper function to create StreamMetadata
|
|
15
|
-
*/
|
|
16
|
-
function createStreamMetadata(logicalTechnique1, logicalTechnique2 = LogicalLevelTechnique.NONE, numValues = 3) {
|
|
17
|
-
return new StreamMetadata(PhysicalStreamType.DATA, new LogicalStreamType(DictionaryType.NONE), logicalTechnique1, logicalTechnique2, PhysicalLevelTechnique.VARINT, numValues, 10);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Helper function to create RleEncodedStreamMetadata
|
|
21
|
-
*/
|
|
22
|
-
function createRleMetadata(logicalTechnique1, logicalTechnique2, runs, numRleValues) {
|
|
23
|
-
return new RleEncodedStreamMetadata(PhysicalStreamType.DATA, new LogicalStreamType(DictionaryType.NONE), logicalTechnique1, logicalTechnique2, PhysicalLevelTechnique.VARINT, runs * 2, 10, runs, numRleValues);
|
|
24
|
-
}
|
|
8
|
+
import { createRleMetadata, createStreamMetadata } from "./decodingTestUtils";
|
|
9
|
+
import { encodeFloat64, encodeInt64SignedDelta, encodeInt64SignedDeltaRle, encodeInt64SignedNone, encodeInt64SignedRle, encodeInt64UnsignedNone, encodeIntStream, } from "../encoding/integerStreamEncoder";
|
|
25
10
|
describe("getVectorType", () => {
|
|
26
|
-
it("
|
|
27
|
-
const metadata = createRleMetadata(LogicalLevelTechnique.
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
it("should return FLAT for RLE with 0 runs", () => {
|
|
12
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.RLE, 0, 0);
|
|
13
|
+
const result = getVectorType(metadata, 0, new Uint8Array(), new IntWrapper(0));
|
|
14
|
+
expect(result).toBe(VectorType.FLAT);
|
|
15
|
+
});
|
|
16
|
+
it("should return CONST for single run RLE", () => {
|
|
17
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.RLE, 1, 0);
|
|
18
|
+
const result = getVectorType(metadata, 0, new Uint8Array(), new IntWrapper(0));
|
|
19
|
+
expect(result).toBe(VectorType.CONST);
|
|
20
|
+
});
|
|
21
|
+
it("should return FLAT for NONE with 0 runs", () => {
|
|
22
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE, LogicalLevelTechnique.NONE, 0);
|
|
23
|
+
const result = getVectorType(metadata, 0, new Uint8Array(), new IntWrapper(0));
|
|
24
|
+
expect(result).toBe(VectorType.FLAT);
|
|
25
|
+
});
|
|
26
|
+
it("should return CONST for NONE with single run", () => {
|
|
27
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE, LogicalLevelTechnique.NONE, 1);
|
|
28
|
+
const result = getVectorType(metadata, 0, new Uint8Array(), new IntWrapper(0));
|
|
29
|
+
expect(result).toBe(VectorType.CONST);
|
|
30
|
+
});
|
|
31
|
+
it("should return FLAT for features and values mismatch", () => {
|
|
32
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, 1);
|
|
33
|
+
const result = getVectorType(metadata, 2, new Uint8Array(), new IntWrapper(0));
|
|
34
|
+
expect(result).toBe(VectorType.FLAT);
|
|
35
|
+
});
|
|
36
|
+
it("should return SEQUENCE for single RLE run", () => {
|
|
37
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, 1, 1);
|
|
38
|
+
const result = getVectorType(metadata, 1, new Uint8Array(), new IntWrapper(0));
|
|
31
39
|
expect(result).toBe(VectorType.SEQUENCE);
|
|
32
40
|
});
|
|
33
|
-
it("
|
|
41
|
+
it("should return SEQUENCE for RLE run with 2 runs", () => {
|
|
34
42
|
const metadata = createRleMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, 2, 5);
|
|
35
|
-
const data = new Uint8Array([1, 4, 2, 2]);
|
|
36
|
-
const
|
|
37
|
-
const result = getVectorType(metadata, 5, data, offset);
|
|
43
|
+
const data = new Uint8Array([1, 4, 2, 2]); // Can't achieve this array using the encoding method...
|
|
44
|
+
const result = getVectorType(metadata, 5, data, new IntWrapper(0));
|
|
38
45
|
expect(result).toBe(VectorType.SEQUENCE);
|
|
39
46
|
});
|
|
40
47
|
});
|
|
41
|
-
describe("
|
|
42
|
-
it("should decode
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const data =
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
expect(result).toBeInstanceOf(BigInt64Array);
|
|
48
|
+
describe("decodeIntStream", () => {
|
|
49
|
+
it("should decode with PhysicalLevelTechnique.NONE", () => {
|
|
50
|
+
const expectedValues = new Int32Array([10, 20, 30]);
|
|
51
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
52
|
+
const data = encodeIntStream(expectedValues, metadata, false);
|
|
53
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, false);
|
|
54
|
+
expect(result).toEqual(expectedValues);
|
|
49
55
|
});
|
|
50
|
-
it
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
it("should throw for unsupported PhysicalLevelTechnique", () => {
|
|
57
|
+
const data = new Uint8Array([10, 20, 30]);
|
|
58
|
+
const metadata = {
|
|
59
|
+
...createStreamMetadata(LogicalLevelTechnique.NONE),
|
|
60
|
+
physicalLevelTechnique: PhysicalLevelTechnique.ALP,
|
|
61
|
+
numValues: 3,
|
|
62
|
+
byteLength: 3,
|
|
63
|
+
};
|
|
64
|
+
expect(() => decodeIntStream(data, new IntWrapper(0), metadata, false)).toThrow("Specified physicalLevelTechnique is not supported (yet).");
|
|
57
65
|
});
|
|
58
|
-
it("should decode
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const data =
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
expect(result).toBeInstanceOf(BigInt64Array);
|
|
66
|
+
it("should decode MORTON", () => {
|
|
67
|
+
const expectedValues = new Int32Array([10, 15, 18, 20]);
|
|
68
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.MORTON, LogicalLevelTechnique.NONE, 4);
|
|
69
|
+
const data = encodeIntStream(expectedValues, metadata, false);
|
|
70
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, false);
|
|
71
|
+
expect(result).toEqual(expectedValues);
|
|
65
72
|
});
|
|
66
|
-
it
|
|
67
|
-
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
68
|
-
const
|
|
69
|
-
const
|
|
73
|
+
it("should decode nullable MORTON fully populated", () => {
|
|
74
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.MORTON, LogicalLevelTechnique.NONE, 4);
|
|
75
|
+
const expectedValues = new Int32Array([10, 15, 18, 20]);
|
|
76
|
+
const bitVector = new BitVector(new Uint8Array([0b1111]), 4);
|
|
77
|
+
const data = encodeIntStream(expectedValues, metadata, false, bitVector);
|
|
70
78
|
const offset = new IntWrapper(0);
|
|
71
|
-
const result =
|
|
72
|
-
expect(result).
|
|
79
|
+
const result = decodeIntStream(data, offset, metadata, false, undefined, bitVector);
|
|
80
|
+
expect(result).toEqual(expectedValues);
|
|
73
81
|
});
|
|
74
|
-
it
|
|
75
|
-
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const result =
|
|
80
|
-
expect(result).
|
|
82
|
+
it("should decode nullable MORTON null values", () => {
|
|
83
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.MORTON, LogicalLevelTechnique.NONE, 3);
|
|
84
|
+
const expectedValues = new Int32Array([10, 0, 15, 0, 18]);
|
|
85
|
+
const bitVector = new BitVector(new Uint8Array([0b10101]), 5);
|
|
86
|
+
const data = encodeIntStream(expectedValues, metadata, false, bitVector);
|
|
87
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, false, undefined, bitVector);
|
|
88
|
+
expect(result).toEqual(expectedValues);
|
|
81
89
|
});
|
|
82
|
-
it("should
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const data =
|
|
86
|
-
const
|
|
87
|
-
expect(
|
|
90
|
+
it("should decode NONE signed with Int32", () => {
|
|
91
|
+
const expectedValues = new Int32Array([2, -4, 6, -8]);
|
|
92
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE, LogicalLevelTechnique.NONE, expectedValues.length);
|
|
93
|
+
const data = encodeIntStream(expectedValues, metadata, true);
|
|
94
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true);
|
|
95
|
+
expect(result).toEqual(expectedValues);
|
|
88
96
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const bitVector = new BitVector(new Uint8Array([0b00000111]), 5);
|
|
97
|
-
const result = decodeNullableLongStream(data, offset, metadata, true, bitVector);
|
|
98
|
-
expect(result).toBeInstanceOf(BigInt64Array);
|
|
97
|
+
it("should decode nullable NONE signed Int32 partially populated", () => {
|
|
98
|
+
const expectedValues = new Int32Array([0, 15, 0, 20]);
|
|
99
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE, LogicalLevelTechnique.NONE, 2);
|
|
100
|
+
const bitVector = new BitVector(new Uint8Array([0b1010]), 4);
|
|
101
|
+
const data = encodeIntStream(expectedValues, metadata, true, bitVector);
|
|
102
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true, undefined, bitVector);
|
|
103
|
+
expect(result).toEqual(new Int32Array([0, 15, 0, 20]));
|
|
99
104
|
});
|
|
100
|
-
it("should decode DELTA
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const data =
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const result = decodeNullableLongStream(data, offset, metadata, true, bitVector);
|
|
107
|
-
expect(result).toBeInstanceOf(BigInt64Array);
|
|
105
|
+
it("should decode DELTA signed with Int32", () => {
|
|
106
|
+
const expectedValues = new Int32Array([10, 12, 14, 16]);
|
|
107
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.NONE, expectedValues.length);
|
|
108
|
+
const data = encodeIntStream(expectedValues, metadata, true);
|
|
109
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true);
|
|
110
|
+
expect(result).toEqual(expectedValues);
|
|
108
111
|
});
|
|
109
|
-
it("should decode
|
|
110
|
-
const metadata =
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
expect(result).toBeInstanceOf(BigInt64Array);
|
|
112
|
+
it("should decode nullable DELTA signed Int32 with null values", () => {
|
|
113
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.NONE, 5);
|
|
114
|
+
const expectedValues = new Int32Array([0, 2, 0, 4, 6]);
|
|
115
|
+
const bitVector = new BitVector(new Uint8Array([0b00011010]), 5);
|
|
116
|
+
const data = encodeIntStream(expectedValues, metadata, true, bitVector);
|
|
117
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true, undefined, bitVector);
|
|
118
|
+
expect(result).toEqual(expectedValues);
|
|
117
119
|
});
|
|
118
|
-
it("should decode
|
|
119
|
-
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
120
|
-
const
|
|
121
|
-
const data =
|
|
120
|
+
it("should decode Componentwise Delta with Int32", () => {
|
|
121
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.COMPONENTWISE_DELTA, LogicalLevelTechnique.NONE, 4);
|
|
122
|
+
const expectedValues = new Int32Array([10, 20, 11, 21]);
|
|
123
|
+
const data = encodeIntStream(expectedValues, metadata, true);
|
|
124
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true);
|
|
125
|
+
expect(result).toEqual(expectedValues);
|
|
126
|
+
});
|
|
127
|
+
it("should decode Componentwise Delta Scaled with Int32", () => {
|
|
128
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.COMPONENTWISE_DELTA, LogicalLevelTechnique.NONE, 4);
|
|
129
|
+
const expectedValues = new Int32Array([100, 200, 110, 220]);
|
|
130
|
+
const scalingData = { extent: 4096, min: 0, max: 4096, scale: 2.0 };
|
|
131
|
+
const data = encodeIntStream(expectedValues, metadata, true, undefined, scalingData);
|
|
132
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true, scalingData);
|
|
133
|
+
expect(result).toEqual(expectedValues);
|
|
134
|
+
});
|
|
135
|
+
it("should decode RLE signed with Int32", () => {
|
|
136
|
+
const expectedValues = new Int32Array([100, 100, 100, -50, -50]);
|
|
137
|
+
const runs = 2;
|
|
138
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, runs, expectedValues.length);
|
|
139
|
+
const data = encodeIntStream(expectedValues, metadata, true);
|
|
140
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, true);
|
|
141
|
+
expect(result).toEqual(expectedValues);
|
|
142
|
+
});
|
|
143
|
+
it("should decode nullable RLE Int32 partially populated", () => {
|
|
144
|
+
let metadata = createStreamMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, 2);
|
|
145
|
+
const expectedValues = new Int32Array([0, 15, 0, 20]);
|
|
146
|
+
const bitVector = new BitVector(new Uint8Array([0b1010]), 4);
|
|
147
|
+
const data = encodeIntStream(expectedValues, metadata, false, bitVector);
|
|
148
|
+
metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, 2, 2);
|
|
149
|
+
const result = decodeIntStream(data, new IntWrapper(0), metadata, false, undefined, bitVector);
|
|
150
|
+
expect(result).toEqual(new Int32Array([0, 15, 0, 20]));
|
|
151
|
+
});
|
|
152
|
+
it("should throw for unsupported technique", () => {
|
|
153
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.PDE, LogicalLevelTechnique.NONE, 3);
|
|
122
154
|
const offset = new IntWrapper(0);
|
|
123
155
|
const bitVector = new BitVector(new Uint8Array([0b00000111]), 3);
|
|
124
|
-
|
|
125
|
-
expect(result).toBeInstanceOf(BigInt64Array);
|
|
156
|
+
expect(() => decodeIntStream(new Uint8Array([]), offset, metadata, false, undefined, bitVector)).toThrow("The specified Logical level technique is not supported");
|
|
126
157
|
});
|
|
158
|
+
});
|
|
159
|
+
describe("decodeFloat64Buffer", () => {
|
|
127
160
|
it("should decode NONE unsigned", () => {
|
|
128
161
|
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
129
|
-
const
|
|
130
|
-
const data =
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
162
|
+
const expectedValues = new Float64Array([1.5, 2.5, 3.5]);
|
|
163
|
+
const data = encodeFloat64(expectedValues, metadata, false);
|
|
164
|
+
const result = decodeFloat64(data, metadata, false);
|
|
165
|
+
expect(result).toEqual(expectedValues);
|
|
166
|
+
});
|
|
167
|
+
it("should decode NONE signed", () => {
|
|
168
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
169
|
+
const expectedValues = new Float64Array([2, 5, 3]);
|
|
170
|
+
const data = encodeFloat64(expectedValues, metadata, true);
|
|
171
|
+
const result = decodeFloat64(data, metadata, true);
|
|
172
|
+
expect(result).toEqual(expectedValues);
|
|
173
|
+
});
|
|
174
|
+
it("should decode RLE unsigned", () => {
|
|
175
|
+
const expectedValues = new Float64Array([10.5, 10.5, 10.5, 20.5, 20.5]);
|
|
176
|
+
const runs = 2;
|
|
177
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, runs, expectedValues.length);
|
|
178
|
+
const data = encodeFloat64(expectedValues, metadata, false);
|
|
179
|
+
const result = decodeFloat64(data, metadata, false);
|
|
180
|
+
expect(result).toEqual(expectedValues);
|
|
181
|
+
});
|
|
182
|
+
it("should decode RLE signed", () => {
|
|
183
|
+
const expectedValues = new Float64Array([10, 10, 10, 20, 20]);
|
|
184
|
+
const runs = 2;
|
|
185
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, runs, expectedValues.length);
|
|
186
|
+
const data = encodeFloat64(expectedValues, metadata, true);
|
|
187
|
+
const result = decodeFloat64(data, metadata, true);
|
|
188
|
+
expect(result).toEqual(expectedValues);
|
|
189
|
+
});
|
|
190
|
+
it("should decode DELTA without RLE", () => {
|
|
191
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA);
|
|
192
|
+
const expectedValues = new Float64Array([2, 4, 6]);
|
|
193
|
+
const data = encodeFloat64(expectedValues, metadata, true);
|
|
194
|
+
const result = decodeFloat64(data, metadata, true);
|
|
195
|
+
expect(result).toEqual(expectedValues);
|
|
196
|
+
});
|
|
197
|
+
it("should decode DELTA with RLE", () => {
|
|
198
|
+
const expectedValues = new Float64Array([10, 12, 14, 16, 18]);
|
|
199
|
+
const runs = 2;
|
|
200
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, runs, expectedValues.length);
|
|
201
|
+
const data = encodeFloat64(expectedValues, metadata, true);
|
|
202
|
+
const result = decodeFloat64(data, metadata, true);
|
|
203
|
+
expect(result).toEqual(new Float64Array([10, 12, 14, 16, 18]));
|
|
135
204
|
});
|
|
136
205
|
it("should throw for unsupported technique", () => {
|
|
137
|
-
const metadata = createStreamMetadata(LogicalLevelTechnique.
|
|
138
|
-
const values = new
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
206
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.MORTON);
|
|
207
|
+
const values = new Float64Array([1, 2, 3]);
|
|
208
|
+
expect(() => decodeFloat64(values, metadata, true)).toThrow("The specified Logical level technique is not supported: MORTON");
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
describe("decodeLongStream", () => {
|
|
212
|
+
describe("DELTA with RLE", () => {
|
|
213
|
+
it("should decode DELTA with RLE", () => {
|
|
214
|
+
const numRleValues = 5;
|
|
215
|
+
const runs = 3;
|
|
216
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, runs, numRleValues);
|
|
217
|
+
const expectedValues = new BigInt64Array([10n, 12n, 14n, 15n, 16n]);
|
|
218
|
+
const data = encodeInt64SignedDeltaRle([
|
|
219
|
+
[1, 10n],
|
|
220
|
+
[2, 2n],
|
|
221
|
+
[2, 1n],
|
|
222
|
+
]);
|
|
223
|
+
const offset = new IntWrapper(0);
|
|
224
|
+
const result = decodeLongStream(data, offset, metadata, true);
|
|
225
|
+
expect(result).toEqual(expectedValues);
|
|
226
|
+
});
|
|
227
|
+
it("should decode DELTA with RLE with all non-null values", () => {
|
|
228
|
+
const numRleValues = 5;
|
|
229
|
+
const runs = 3;
|
|
230
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, runs, numRleValues);
|
|
231
|
+
const expectedValues = new BigInt64Array([10n, 12n, 14n, 15n, 16n]);
|
|
232
|
+
const data = encodeInt64SignedDeltaRle([
|
|
233
|
+
[1, 10n],
|
|
234
|
+
[2, 2n],
|
|
235
|
+
[2, 1n],
|
|
236
|
+
]);
|
|
237
|
+
const offset = new IntWrapper(0);
|
|
238
|
+
const bitVector = new BitVector(new Uint8Array([0b00011111]), 5);
|
|
239
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
240
|
+
expect(result).toEqual(expectedValues);
|
|
241
|
+
});
|
|
242
|
+
it("should decode DELTA with RLE with null values", () => {
|
|
243
|
+
const numRleValues = 3;
|
|
244
|
+
const runs = 2;
|
|
245
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.RLE, runs, numRleValues);
|
|
246
|
+
const expectedValues = new BigInt64Array([10n, 0n, 12n, 0n, 14n]);
|
|
247
|
+
const data = encodeInt64SignedDeltaRle([
|
|
248
|
+
[1, 10n],
|
|
249
|
+
[2, 2n],
|
|
250
|
+
]);
|
|
251
|
+
const offset = new IntWrapper(0);
|
|
252
|
+
const bitVector = new BitVector(new Uint8Array([0b00010101]), 5);
|
|
253
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
254
|
+
expect(result).toEqual(expectedValues);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
describe("DELTA without RLE", () => {
|
|
258
|
+
it("should decode DELTA without RLE", () => {
|
|
259
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA);
|
|
260
|
+
const expectedValues = new BigInt64Array([2n, 4n, 6n]);
|
|
261
|
+
const data = encodeInt64SignedDelta(expectedValues);
|
|
262
|
+
const offset = new IntWrapper(0);
|
|
263
|
+
const result = decodeLongStream(data, offset, metadata, true);
|
|
264
|
+
expect(result).toEqual(expectedValues);
|
|
265
|
+
});
|
|
266
|
+
it("should decode DELTA without RLE with all non-null values", () => {
|
|
267
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA);
|
|
268
|
+
const expectedValues = new BigInt64Array([2n, 4n, 6n]);
|
|
269
|
+
const data = encodeInt64SignedDelta(expectedValues);
|
|
270
|
+
const offset = new IntWrapper(0);
|
|
271
|
+
const bitVector = new BitVector(new Uint8Array([0b00000111]), 3);
|
|
272
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
273
|
+
expect(result).toEqual(expectedValues);
|
|
274
|
+
});
|
|
275
|
+
it("should decode DELTA without RLE with null values", () => {
|
|
276
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.DELTA, LogicalLevelTechnique.NONE, 5);
|
|
277
|
+
const expectedValues = new BigInt64Array([0n, 2n, 0n, 4n, 6n]);
|
|
278
|
+
const nonNullValues = new BigInt64Array([2n, 4n, 6n]);
|
|
279
|
+
const data = encodeInt64SignedDelta(nonNullValues);
|
|
280
|
+
const offset = new IntWrapper(0);
|
|
281
|
+
const bitVector = new BitVector(new Uint8Array([0b00011010]), 5);
|
|
282
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
283
|
+
expect(result).toEqual(expectedValues);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
describe("RLE", () => {
|
|
287
|
+
it("should decode RLE", () => {
|
|
288
|
+
const numRleValues = 5;
|
|
289
|
+
const runs = 2;
|
|
290
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, runs, numRleValues);
|
|
291
|
+
const expectedValues = new BigInt64Array([100n, 100n, 100n, -50n, -50n]);
|
|
292
|
+
const data = encodeInt64SignedRle([
|
|
293
|
+
[3, 100n],
|
|
294
|
+
[2, -50n],
|
|
295
|
+
]);
|
|
296
|
+
const offset = new IntWrapper(0);
|
|
297
|
+
const result = decodeLongStream(data, offset, metadata, true);
|
|
298
|
+
expect(result).toEqual(expectedValues);
|
|
299
|
+
});
|
|
300
|
+
it("should decode RLE with all non-null values", () => {
|
|
301
|
+
const numRleValues = 5;
|
|
302
|
+
const runs = 2;
|
|
303
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, runs, numRleValues);
|
|
304
|
+
const expectedValues = new BigInt64Array([100n, 100n, 100n, -50n, -50n]);
|
|
305
|
+
const data = encodeInt64SignedRle([
|
|
306
|
+
[3, 100n],
|
|
307
|
+
[2, -50n],
|
|
308
|
+
]);
|
|
309
|
+
const offset = new IntWrapper(0);
|
|
310
|
+
const bitVector = new BitVector(new Uint8Array([0b00011111]), 5);
|
|
311
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
312
|
+
expect(result).toEqual(expectedValues);
|
|
313
|
+
});
|
|
314
|
+
it("should decode RLE with null values", () => {
|
|
315
|
+
const numRleValues = 3;
|
|
316
|
+
const runs = 2;
|
|
317
|
+
const metadata = createRleMetadata(LogicalLevelTechnique.RLE, LogicalLevelTechnique.NONE, runs, numRleValues);
|
|
318
|
+
const expectedValues = new BigInt64Array([100n, 0n, 100n, 0n, -50n]);
|
|
319
|
+
const data = encodeInt64SignedRle([
|
|
320
|
+
[2, 100n],
|
|
321
|
+
[1, -50n],
|
|
322
|
+
]);
|
|
323
|
+
const offset = new IntWrapper(0);
|
|
324
|
+
const bitVector = new BitVector(new Uint8Array([0b00010101]), 5);
|
|
325
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
326
|
+
expect(result).toEqual(expectedValues);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
describe("NONE", () => {
|
|
330
|
+
it("should decode NONE signed", () => {
|
|
331
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
332
|
+
const expectedValues = new BigInt64Array([2n, -4n, 6n]);
|
|
333
|
+
const data = encodeInt64SignedNone(expectedValues);
|
|
334
|
+
const offset = new IntWrapper(0);
|
|
335
|
+
const result = decodeLongStream(data, offset, metadata, true);
|
|
336
|
+
expect(result).toEqual(expectedValues);
|
|
337
|
+
});
|
|
338
|
+
it("should decode NONE unsigned", () => {
|
|
339
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
340
|
+
const expectedValues = new BigInt64Array([1n, 2n, 3n]);
|
|
341
|
+
const data = encodeInt64UnsignedNone(expectedValues);
|
|
342
|
+
const offset = new IntWrapper(0);
|
|
343
|
+
const result = decodeLongStream(data, offset, metadata, false);
|
|
344
|
+
expect(result).toEqual(expectedValues);
|
|
345
|
+
});
|
|
346
|
+
it("should decode NONE signed with all non-null values", () => {
|
|
347
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
348
|
+
const expectedValues = new BigInt64Array([2n, -4n, 6n]);
|
|
349
|
+
const data = encodeInt64SignedNone(expectedValues);
|
|
350
|
+
const offset = new IntWrapper(0);
|
|
351
|
+
const bitVector = new BitVector(new Uint8Array([0b00000111]), 3);
|
|
352
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
353
|
+
expect(result).toEqual(expectedValues);
|
|
354
|
+
});
|
|
355
|
+
it("should decode NONE signed with null values", () => {
|
|
356
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE, LogicalLevelTechnique.NONE, 5);
|
|
357
|
+
const expectedValues = new BigInt64Array([2n, 0n, -4n, 0n, 6n]);
|
|
358
|
+
const nonNullValues = new BigInt64Array([2n, -4n, 6n]);
|
|
359
|
+
const data = encodeInt64SignedNone(nonNullValues);
|
|
360
|
+
const offset = new IntWrapper(0);
|
|
361
|
+
const bitVector = new BitVector(new Uint8Array([0b00010101]), 5);
|
|
362
|
+
const result = decodeLongStream(data, offset, metadata, true, bitVector);
|
|
363
|
+
expect(result).toEqual(expectedValues);
|
|
364
|
+
});
|
|
365
|
+
it("should decode NONE unsigned with all non-null values", () => {
|
|
366
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE);
|
|
367
|
+
const expectedValues = new BigInt64Array([1n, 2n, 3n]);
|
|
368
|
+
const data = encodeInt64UnsignedNone(expectedValues);
|
|
369
|
+
const offset = new IntWrapper(0);
|
|
370
|
+
const bitVector = new BitVector(new Uint8Array([0b00000111]), 3);
|
|
371
|
+
const result = decodeLongStream(data, offset, metadata, false, bitVector);
|
|
372
|
+
expect(result).toEqual(expectedValues);
|
|
373
|
+
});
|
|
374
|
+
it("should decode NONE unsigned with null values", () => {
|
|
375
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.NONE, LogicalLevelTechnique.NONE, 5);
|
|
376
|
+
const expectedValues = new BigInt64Array([0n, 1n, 2n, 0n, 3n]);
|
|
377
|
+
const nonNullValues = new BigInt64Array([1n, 2n, 3n]);
|
|
378
|
+
const data = encodeInt64UnsignedNone(nonNullValues);
|
|
379
|
+
const offset = new IntWrapper(0);
|
|
380
|
+
const bitVector = new BitVector(new Uint8Array([0b00010110]), 5);
|
|
381
|
+
const result = decodeLongStream(data, offset, metadata, false, bitVector);
|
|
382
|
+
expect(result).toEqual(expectedValues);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
describe("error handling", () => {
|
|
386
|
+
it("should throw for unsupported technique", () => {
|
|
387
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.MORTON);
|
|
388
|
+
const data = encodeInt64UnsignedNone(new BigInt64Array([1n, 2n, 3n]));
|
|
389
|
+
const offset = new IntWrapper(0);
|
|
390
|
+
expect(() => decodeLongStream(data, offset, metadata, true)).toThrow("The specified Logical level technique is not supported: MORTON");
|
|
391
|
+
});
|
|
392
|
+
it("should throw for unsupported technique with nullable", () => {
|
|
393
|
+
const metadata = createStreamMetadata(LogicalLevelTechnique.COMPONENTWISE_DELTA);
|
|
394
|
+
const values = new BigInt64Array([1n, 2n, 3n]);
|
|
395
|
+
const data = encodeInt64UnsignedNone(values);
|
|
396
|
+
const offset = new IntWrapper(0);
|
|
397
|
+
const bitVector = new BitVector(new Uint8Array([0b00000111]), 3);
|
|
398
|
+
expect(() => decodeLongStream(data, offset, metadata, true, bitVector)).toThrow();
|
|
399
|
+
});
|
|
143
400
|
});
|
|
144
401
|
});
|
|
145
402
|
//# sourceMappingURL=integerStreamDecoder.spec.js.map
|