public interface IDurableEncoding
IDurableEncoding.Unityped
).
For collections, we need only describe the encoding of the individual values. For primitives, we must define several things:
IDurableEncoding.Primitive.blockSize()
, which is the number of values which can be typically encoded in ~2kbIDurableEncoding.Primitive.encode(IList, DurableOutput)
, which takes a list of values and writes them as a single block
to the outputIDurableEncoding.Primitive.decode(DurableInput, IDurableCollection.Root)
which takes an input corresponding to an
encoded block, and returns a special iterator that can skip over ignored valuesOptionally, encodings may provide custom hash, equality, and comparison semantics.
One should not expect a 1:1 correspondence between encodings and in-memory types. Where an in-memory type only relates to the qualities of an individual value, an encoding must also consider the relationships between neighboring values. Integers which represent incrementing ids, for instance, are much more compressible than arbitrary integers.
In general, one should always use the constructors in DurableEncodings
to define a new encoding.
Modifier and Type | Interface and Description |
---|---|
static interface |
IDurableEncoding.List
A list comprised of a single
IDurableEncoding.List.elementEncoding() . |
static interface |
IDurableEncoding.Map
A map, comprised of a
IDurableEncoding.Map.keyEncoding() and IDurableEncoding.Map.valueEncoding() . |
static interface |
IDurableEncoding.Primitive
A primitive, which can encode and decode blocks of values.
|
static interface |
IDurableEncoding.Set
A set, comprised of a single
IDurableEncoding.Set.elementEncoding() . |
static interface |
IDurableEncoding.SkippableIterator
An extension of
Iterator , which provides for skipping elements without ever providing a value. |
static interface |
IDurableEncoding.Unityped
An encoding which is all things to all people.
|
Modifier and Type | Method and Description |
---|---|
default Comparator<Object> |
comparator()
The comparator used for decoded values.
|
static int |
defaultComparator(Object a,
Object b) |
String |
description()
A description of the encoding.
|
default BiPredicate<Object,Object> |
equalityFn()
The equality function used for decoded values.
|
default ToLongFunction<Object> |
hashFn()
The hash function used for decoded values.
|
boolean |
isSingleton(Object o)
A predicate that allows us to call out values we want to be stored individually.
|
String description()
default Comparator<Object> comparator()
default ToLongFunction<Object> hashFn()
default BiPredicate<Object,Object> equalityFn()
boolean isSingleton(Object o)