Platform
Resources
Pricing
Sign in
Get started
Trevor Manz
phd student, middle child
Workspace
Fork
Published
By
Trevor Manz
Edited
Dec 28, 2020
4
Insert cell
Insert cell
Insert cell
Insert cell
Zstd
=
import
(
codecUrl
+
'/zstd'
)
.
then
(
r
=>
r
.
default
)
Insert cell
LZ4
=
import
(
codecUrl
+
'/lz4'
)
.
then
(
r
=>
r
.
default
)
Insert cell
Insert cell
zstd
=
{
const
meta
=
await
files
.
get
(
'data-zstd.zarr/.zarray'
)
.
json
(
)
;
return
Zstd
.
fromConfig
(
meta
.
compressor
)
;
}
Insert cell
lz4
=
{
const
meta
=
await
files
.
get
(
'data-lz4.zarr/.zarray'
)
.
json
(
)
;
return
LZ4
.
fromConfig
(
meta
.
compressor
)
;
}
Insert cell
Insert cell
decodedZstd
=
{
// load chunk as an ArrayBuffer
const
buffer
=
await
files
.
get
(
'data-zstd.zarr/0.0'
)
.
arrayBuffer
(
)
;
// take view of compressed bytes
const
cbytes
=
new
Uint8Array
(
buffer
)
;
// decompress bytes into new buffer
const
dbytes
=
await
zstd
.
decode
(
cbytes
)
;
// take `i4` view of decompressed bytes
return
new
Int32Array
(
dbytes
.
buffer
)
;
}
Insert cell
decodedLZ4
=
{
const
buffer
=
await
files
.
get
(
'data-lz4.zarr/0.0'
)
.
arrayBuffer
(
)
;
const
cbytes
=
new
Uint8Array
(
buffer
)
;
const
dbytes
=
await
lz4
.
decode
(
cbytes
)
;
return
new
Int32Array
(
dbytes
.
buffer
)
;
}
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
codecUrl
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Zstd
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
LZ4
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
zstd
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
lz4
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
decodedZstd
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
decodedLZ4
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
files
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML