blob: ca908fc75fcfba086c06788752a827924ca969da (
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
42
43
44
45
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "tensor_update.h"
#include "valueupdate.h"
namespace vespalib::eval { struct Value; }
namespace document {
class TensorDataType;
class TensorFieldValue;
/**
* An update used to remove cells from a sparse or mixed tensor.
*
* The cells to remove are contained in a sparse tensor (with all mapped dimensions) where cell values are set to 1.0.
* When used on a mixed tensor the entire dense sub-space (pointed to by a cell in the sparse tensor) is removed.
*/
class TensorRemoveUpdate final : public ValueUpdate, public TensorUpdate {
private:
std::unique_ptr<const TensorDataType> _tensorType;
std::unique_ptr<TensorFieldValue> _tensor;
friend ValueUpdate;
TensorRemoveUpdate();
ACCEPT_UPDATE_VISITOR;
public:
explicit TensorRemoveUpdate(std::unique_ptr<TensorFieldValue> tensor);
TensorRemoveUpdate(const TensorRemoveUpdate &rhs) = delete;
TensorRemoveUpdate &operator=(const TensorRemoveUpdate &rhs) = delete;
~TensorRemoveUpdate() override;
const TensorFieldValue &getTensor() const { return *_tensor; }
std::unique_ptr<vespalib::eval::Value> applyTo(const vespalib::eval::Value &tensor) const;
std::unique_ptr<Value> apply_to(const Value &tensor,
const ValueBuilderFactory &factory) const override;
bool operator==(const ValueUpdate &other) const override;
void checkCompatibility(const Field &field) const override;
bool applyTo(FieldValue &value) const override;
void printXml(XmlOutputStream &xos) const override;
void print(std::ostream &out, bool verbose, const std::string &indent) const override;
void deserialize(const DocumentTypeRepo &repo, const DataType &type, nbostream &stream) override;
};
}
|