MapSchema
A schema for maps with independently typed keys and values.
Keys can be any type that has a schema, so Map<Int, Pose> and Map<MyEnum, Double> both work.
Binary format
The schema:
[4 bytes: tag] [key schema blob] [value schema blob]An encoded map:
[4 bytes: entry count N] [key1][value1] [key2][value2] ... [keyN][valueN]Entries are written in the map's own iteration order, and the format does not depend on it. Every key is written, so a HashMap and a LinkedHashMap with the same entries both decode correctly, but their bytes differ.
Mutation
gay.zharel.fateweaver.log.FateLogWriter.write calls objSize and encodeObject separately, so don't mutate the map in between. If you do, the write fails with a java.nio.BufferOverflowException or the writer's "encoded object does not match reported size" check. It does not write corrupt bytes. Pass a copy if another thread might touch the map.
Nulls
A null key or value needs an OptionalSchema on that side. Map<String, Double?> infers as MapSchema(StringSchema, OptionalSchema(DoubleSchema)), and each absent value costs one byte. A null passed to a schema that is not optional throws.
Size limits
objSize returns an Int. A map that encodes to more than 2 GiB overflows it, and the writer's buffer allocation then throws without saying why.
Example
val powers = writer.createChannel("Motors/Powers", MapSchema(StringSchema, DoubleSchema))
powers.put(mapOf("fl" to 0.5, "fr" to -0.5))Parameters
the key type
the value type
schema used to encode each key
schema used to encode each value
Properties
Functions
Writes the given object into the buffer.
Writes the whole schema definition, starting with the tag, into the buffer.