Bridge — Java vespajlib Tensor to C++ vespa/eval Tensor Binary Wire Contract
Tensors constructed or embedded in the Java stateless container (container-jdisc / utility-libs) must cross the process boundary into C++ content nodes (content-nodes) for both document feeding (Document tensor fields) and query ranking (input.query(q_vec) properties) without losing dimension type or cell precision (double, float, bfloat16, int8).
Side A — Java Container Producer (vespa/vespajlib)
- Anchor package:
vespa/vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java Tensor.from(TensorType, ...)or container embedders (vespa/container-onnxruntime) produceIndexedTensor,MappedTensor, orMixedTensorinstances.TypedBinaryFormat.encode(tensor)serializes the format tag (1= sparse,2= dense,3= mixed,6= typed cell-type header) followed by dimension sizes, string label tables, and raw cell values.
Wire Protocol — Typed Binary Tensor Format
- Format Tag & Cell-Type Encoding: Encodes whether dimensions are trivial, sparse (
mapped), dense (indexed), or mixed (mappedouter +indexedinner), plus cell value encoding (0 = double,1 = float,2 = bfloat16,3 = int8). - Travels inside
vespa/documentfield payloads during feeding and insidefef::Properties(vespa/searchlib/src/vespa/searchlib/fef/) during query dispatch.
Side B — C++ Content Node Consumer (vespa/eval)
- Anchor package:
vespa/eval/src/vespa/eval/eval/serialization/typed_binary_format.cppandvespa/eval/src/vespa/eval/eval/fast_value.cpp vespalib::eval::TypedBinaryFormat::deserializereconstructs a C++FastValueIndex/Value::UPdirectly backed by contiguous cell arrays (std::span<const float>,BFloat16,Int8Float) ready forTensorFunctionexecution or HNSW distance calculation (see vespa-tensor-type-system-and-algebra).