Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
Compressor
cajeta.wire.Compressor is the compress stage of a byte-to-byte codec, the
inverse of Decompressor. It carries no T, so it stays
separate from Encoder<T>. Block containers (Parquet, ORC, Avro)
call compress(src). HTTP content coding picks a level with
compress(src, len, level) and streams a body through stream(level).
import cajeta.wire.Compressor;
import cajeta.wire.CompressStream;
// The stream a pass-through codec hands out: it returns what was written.
final class PassStream implements CompressStream {
int8[] held;
int64 n;
PassStream() {
this.held = heap int8[4096];
this.n = 0;
}
public void write(int8[] src, int64 len) {
int64 i = 0;
while (i < len) {
this.held[this.n + i] = src[i];
i = i + 1;
}
this.n = this.n + len;
}
public #int8[] flush() {
int8[] out #= CopyCompressor.take(this.held, this.n);
this.n = 0;
return #out;
}
public #int8[] finish() {
return this.flush();
}
}
// A pass-through codec showing the contract's shape.
public final class CopyCompressor implements Compressor {
public CopyCompressor() { }
static #int8[] take(int8[] src, int64 len) {
int8[] out = heap int8[len];
int64 i = 0;
while (i < len) {
out[i] = src[i];
i = i + 1;
}
return #out;
}
public #int8[] compress(int8[] src) {
return CopyCompressor.take(src, src.count());
}
public #int8[] compress(int8[] src, int64 len, int32 level) {
return CopyCompressor.take(src, len);
}
public #CompressStream stream(int32 level) {
return heap PassStream();
}
}
Methods
| Signature | |
|---|---|
#int8[] compress(int8[] src) ⚑ | Compress all of src into a fresh, caller-owned block |
#int8[] compress(int8[] src, int64 len, int32 level) ⚑ | Compress src[0 .. len) at level (1 fastest to 9 smallest for DEFLATE codecs). A codec without levels ignores it |
#CompressStream stream(int32 level) ⚑ | A CompressStream that compresses what is written to it |
⚑ = @EntryPoint
See also
- Decompressor, the inverse stage
- CompressStream, the streaming form
- Encoder, the typed (
T-carrying) wire codec - Source:
runtime/src/cajeta/wire/Compressor.cajeta