← back to roto on ba3a.dev

CacheKeyBuilder

Feeds the inputs and parameters of one stage output into its CacheKey.

Every value goes in under a name, unique within the key, and is encoded unambiguously: a type tag, then fixed-width numbers or length-prefixed bytes. So "ab", "c" and "a", "bc" hash differently, as do an Int and a Long of the same value, or a 2×3 and a 3×2 raster of the same pixels. The names stage and version are taken by CacheKey.of itself.

Functions

Link copied to clipboard
fun put(name: String, value: CacheKey)

An upstream stage's output, by its key: the key already covers everything that output came from.

fun put(name: String, value: Raster)

A raster: its size and every pixel.

fun put(name: String, value: Boolean)

A flag.

fun put(name: String, value: ByteArray)

Raw bytes.

fun put(name: String, value: Double)

By bit pattern, so every NaN is one value and 0.0 and -0.0 are two.

fun put(name: String, value: Int)

A 32-bit integer.

fun put(name: String, value: Long)

A 64-bit integer.

fun put(name: String, value: String)

A string, as UTF-8 bytes.

fun <T> put(name: String, value: T, serializer: SerializationStrategy<T>)

A parameter model, by its canonical JSON. Every field reaches the key, defaults included, so a field added to the model later can never be left out of it. The model must not hold a collection whose iteration order is unspecified, such as a HashMap.

Link copied to clipboard
fun putFile(name: String, file: Path)

A file, by its content: moving or renaming it keeps the key, editing it changes the key.