aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/eval/value_codec.h
blob: 085237179b6506ca340db7fbe2d490444fe409eb (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
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "value.h"
#include "tensor_spec.h"
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/exception.h>

namespace vespalib { class nbostream; }

namespace vespalib::eval {

VESPA_DEFINE_EXCEPTION(DecodeValueException, Exception);

struct ValueBuilderFactory;

/**
 * encode a value (which must support the new APIs) to binary format
 **/
void encode_value(const Value &value, nbostream &output);

/**
 * decode a value from binary format
 *
 * will throw DecodeValueException if input contains malformed data
 **/
std::unique_ptr<Value> decode_value(nbostream &input, const ValueBuilderFactory &factory);

/**
 * Make a value from a tensor spec using a value builder factory
 * interface, making it work with any value implementation.
 **/
std::unique_ptr<Value> value_from_spec(const TensorSpec &spec, const ValueBuilderFactory &factory);

/**
 * Convert a generic value to a tensor spec.
 **/
TensorSpec spec_from_value(const Value &value);

}