Public
Edited
Apr 13, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
someFloats = {
// Generate some random floats.
const someFloats = new arrow.Table({
floats: arrow.vectorFromArray(
points.slice(0, datapoints),
new arrow.Float32()
)
});
const { mask_1, mask_2 } = masks;
// Take a view of the underlying bytes
const floatValues = someFloats.getChild("floats").data[0].values;
const int8 = new Uint8Array(floatValues.buffer);
for (let i = 0; i < int8.length; i += 4) {
int8[i] = (int8[i] & mask_1[0]) | mask_2[0];
int8[i + 1] = (int8[i + 1] & mask_1[1]) | mask_2[1];
// int8[i + 2] = 0;
// int8[i + 3] = 0;
}
return someFloats;
}
Insert cell
Insert cell
errors
Insert cell
masks = {
let mask_1 = 0;
let mask_2 = 0;
for (let i = 0; i < zeroedOut; i++) {
mask_1 += 2 ** i;
if (use1sToo[0] && i < zeroedOut - 1) {
mask_2 += 2 ** i;
}
}
return {
mask_1: [mask_1 % 256 ^ 255, (mask_1 / 256) ^ 255],
mask_2: [mask_2 % 256, mask_2 / 256]
};
}
Insert cell
Insert cell
async function createCompressedStreamFromArrowTable(tb) {
const bytes = new arrow.tableToIPC(tb);
// Create a readable stream from the string
const readableStream = new ReadableStream({
start(controller) {
// Convert the string to a Uint8Array and enqueue it to the stream
controller.enqueue(bytes);
// Close the stream
controller.close();
}
});
if (compression === "none") {
return readableStream;
}
// Pipe the readable stream through a CompressionStream for gzip compression
const compressedReadableStream = readableStream.pipeThrough(
new CompressionStream(compression)
);

return compressedReadableStream;
}
Insert cell
sampled = {
return d3.range(10).map((d) => Math.floor(Math.random() * datapoints));
}
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.
Learn more