private void encodeCells(GrowableByteBuffer buffer, Tensor tensor) {
        buffer.putInt1_4Bytes(tensor.sizeAsInt()); // XXX: Size truncation
        switch (serializationValueType) {
            case DOUBLE: encodeCells(buffer, tensor, buffer::putDouble); break;
            case FLOAT: encodeCells(buffer, tensor, (val) -> buffer.putFloat(val.floatValue())); break;
            case BFLOAT16: encodeCells(buffer, tensor, (val) ->
                    buffer.putShort(TypedBinaryFormat.bFloat16BitsFromFloat(val.floatValue()))); break;
            case INT8: encodeCells(buffer, tensor, (val) -> buffer.put((byte)(val.floatValue()))); break;
        }
    }
Implementation of a sparse binary format for a tensor on the form:

Sorted dimensions = num_dimensions [dimension_str_len dimension_str_bytes]*
Cells = num_cells [label_1_str_len label_1_str_bytes ... label_N_str_len label_N_str_bytes cell_value]*

Note that the dimensions are sorted and the tensor address labels are given in the same sorted order.
Unspecified labels are encoded as the empty string "".

@author geirst
vespajlib/src/main/java/com/yahoo/tensor/serialization/SparseBinaryFormat.java