private static BinaryFormat getFormatDecoder(GrowableByteBuffer buffer) {
        int formatType = decodeFormatType(buffer);
        switch (formatType) {
            case SPARSE_BINARY_FORMAT_TYPE: return new SparseBinaryFormat();
            case DENSE_BINARY_FORMAT_TYPE: return new DenseBinaryFormat();
            case MIXED_BINARY_FORMAT_TYPE: return new MixedBinaryFormat();
            case SPARSE_BINARY_FORMAT_WITH_CELLTYPE: return new SparseBinaryFormat(decodeValueType(buffer));
            case DENSE_BINARY_FORMAT_WITH_CELLTYPE: return new DenseBinaryFormat(decodeValueType(buffer));
            case MIXED_BINARY_FORMAT_WITH_CELLTYPE: return new MixedBinaryFormat(decodeValueType(buffer));
        }
        throw new IllegalArgumentException("Binary format type " + formatType + " is unknown");
    }
Decode some data to a tensor

@param type the type to decode and validate to, or empty to use the type given in the data
@param buffer the buffer containing the data, use GrowableByteByffer.wrap(byte[]) if you have a byte array
@return the resulting tensor
@throws IllegalArgumentException if the tensor data was invalid
vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java