blob: 791662caed76d7a9925fce59006b5899c1852364 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "tensor_deserialize.h"
#include <vespa/document/util/serializableexceptions.h>
#include <vespa/eval/eval/fast_value.h>
#include <vespa/eval/eval/value_codec.h>
#include <vespa/eval/eval/value.h>
#include <vespa/vespalib/objects/nbostream.h>
using document::DeserializeException;
using vespalib::eval::FastValueBuilderFactory;
using vespalib::eval::Value;
namespace search::tensor {
std::unique_ptr<Value> deserialize_tensor(vespalib::nbostream &buffer)
{
try {
auto tensor = vespalib::eval::decode_value(buffer, FastValueBuilderFactory::get());
if (buffer.size() != 0) {
throw DeserializeException("Leftover bytes deserializing tensor attribute value.", VESPA_STRLOC);
}
return tensor;
} catch (const vespalib::eval::DecodeValueException &e) {
throw DeserializeException("tensor value decode failed", e, VESPA_STRLOC);
}
}
} // namespace
|