diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2017-01-10 02:51:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 02:51:24 +0000 |
commit | 8e67ba0904d753efdfa58d28ba60af895b04d4fa (patch) | |
tree | d89f028368a9baf9c122ee93c77dbeff10975599 | |
parent | b2ccc946f2f693919d59d05613030a8a9279d8cb (diff) | |
parent | 6d335de8f20dd2eae6d060fbf59c56c552b7e58b (diff) |
Merge pull request #1461 from yahoo/havardpe/support-serialized-dense-tensors-from-clients
support serialized dense tensors from clients
4 files changed, 5 insertions, 15 deletions
diff --git a/searchlib/src/vespa/searchlib/features/queryfeature.cpp b/searchlib/src/vespa/searchlib/features/queryfeature.cpp index b449849f6df..6ec8ed70a44 100644 --- a/searchlib/src/vespa/searchlib/features/queryfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/queryfeature.cpp @@ -118,11 +118,9 @@ createTensorExecutor(const search::fef::IQueryEnvironment &env, { search::fef::Property prop = env.getProperties().lookup(queryKey); if (prop.found() && !prop.get().empty()) { - DefaultTensor::builder tensorBuilder; const vespalib::string &value = prop.get(); vespalib::nbostream stream(value.data(), value.size()); - vespalib::tensor::TypedBinaryFormat::deserialize(stream, tensorBuilder); - vespalib::tensor::Tensor::UP tensor = tensorBuilder.build(); + vespalib::tensor::Tensor::UP tensor = vespalib::tensor::TypedBinaryFormat::deserialize(stream); if (tensor->getType() != valueType) { vespalib::tensor::TensorMapper mapper(valueType); vespalib::tensor::Tensor::UP mappedTensor = mapper.map(*tensor); diff --git a/vespalib/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp b/vespalib/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp index 81caf706304..95d6a45f196 100644 --- a/vespalib/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp +++ b/vespalib/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/tensor/default_tensor.h> #include <vespa/vespalib/tensor/tensor_factory.h> #include <vespa/vespalib/tensor/serialization/typed_binary_format.h> +#include <vespa/vespalib/tensor/serialization/sparse_binary_format.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/objects/hexdump.h> #include <ostream> @@ -80,7 +81,9 @@ struct Fixture Tensor::UP deserialize(nbostream &stream) { BuilderType builder; nbostream wrapStream(stream.peek(), stream.size()); - TypedBinaryFormat::deserialize(wrapStream, builder); + auto formatId = wrapStream.getInt1_4Bytes(); + ASSERT_EQUAL(formatId, 1); // sparse format + SparseBinaryFormat::deserialize(wrapStream, builder); EXPECT_TRUE(wrapStream.size() == 0); auto ret = builder.build(); checkDeserialize<BuilderType>(stream, *ret); diff --git a/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.cpp b/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.cpp index b7f225c2ba2..80d0252dfe1 100644 --- a/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.cpp +++ b/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.cpp @@ -29,16 +29,6 @@ TypedBinaryFormat::serialize(nbostream &stream, const Tensor &tensor) } -void -TypedBinaryFormat::deserialize(nbostream &stream, TensorBuilder &builder) -{ - auto formatId = stream.getInt1_4Bytes(); - (void) formatId; - assert(formatId == SPARSE_BINARY_FORMAT_TYPE); - SparseBinaryFormat::deserialize(stream, builder); -} - - std::unique_ptr<Tensor> TypedBinaryFormat::deserialize(nbostream &stream) { diff --git a/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.h b/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.h index 45cba6018d4..772f820ffc5 100644 --- a/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.h +++ b/vespalib/src/vespa/vespalib/tensor/serialization/typed_binary_format.h @@ -20,7 +20,6 @@ class TypedBinaryFormat static constexpr uint32_t DENSE_BINARY_FORMAT_TYPE = 2u; public: static void serialize(nbostream &stream, const Tensor &tensor); - static void deserialize(nbostream &stream, TensorBuilder &builder); static std::unique_ptr<Tensor> deserialize(nbostream &stream); }; |