-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rle-pack): update data format, custom repeat sizes, rename fns
- add support for custom run-length group thresholds - rename => encode() / decode() - decode() returns Uint8/16/32Array based on given word size - add encode() error handling (arg checks) - update tests & readme - add diagram BREAKING CHANGE: new API and encoding format, see readme for details
- Loading branch information
1 parent
89b4ad5
commit 694a253
Showing
6 changed files
with
114 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
digraph g { | ||
fontname=Inconsolata; | ||
rankdir=LR; | ||
node[shape=square,width=1.5,fontname=Inconsolata]; | ||
|
||
subgraph cluster0 { | ||
label="header"; | ||
style="filled"; | ||
bgcolor="#eeeeee"; | ||
num[label="num values\n(32 bits)"]; | ||
wordsize[label="word size\n(5 bits)"]; | ||
rlesizes[label="RLE sizes\n(4x4 bits)"]; | ||
} | ||
|
||
subgraph cluster1 { | ||
label="each value"; | ||
bgcolor="#cccccc"; | ||
flag[label="RLE flag\n(1 bit)"]; | ||
val[label="value\n(word size)"]; | ||
|
||
subgraph cluster1b { | ||
bgcolor="#aaaaaa"; | ||
label="repeats only"; | ||
repeatid[label="repeat ID\n(2 bits)"]; | ||
repeat[label="repeats\n(varying)"]; | ||
} | ||
} | ||
|
||
num -> wordsize -> rlesizes -> flag -> val -> repeatid -> repeat; | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import * as assert from "assert"; | ||
import { encodeBytes, decodeBytes } from "../src/index"; | ||
import { encode, decode } from "../src/index"; | ||
|
||
const src = new Uint8Array(1024); | ||
src.set([1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1], 512); | ||
|
||
describe("rle-pack", () => { | ||
it("3bit", () => { | ||
const src = new Uint8Array(1024); | ||
src.set([1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1], 512); | ||
const packed = encodeBytes(src, src.length, 3); | ||
assert.deepEqual(packed, [0, 0, 4, 0, 140, 7, 254, 73, 67, 177, 96, 87, 3, 98, 161, 201, 35, 1, 226]); | ||
const dest = decodeBytes(packed, 3); | ||
let packed = encode(src, src.length, 3); | ||
assert.deepEqual(packed, [0, 0, 4, 0, 25, 27, 252, 96, 63, 242, 74, 29, 139, 2, 184, 27, 21, 14, 73, 24, 15, 16]); | ||
let dest = decode(packed); | ||
assert.deepEqual(dest, src); | ||
packed = encode(src, src.length, 3, [1, 2, 4, 9]); | ||
assert.deepEqual(packed, [0, 0, 4, 0, 24, 9, 196, 127, 249, 146, 158, 219, 10, 225, 182, 167, 153, 35, 241, 0]); | ||
dest = decode(packed); | ||
assert.deepEqual(dest, src); | ||
}); | ||
}); |