diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-10-09 20:12:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-09 20:12:34 +0200 |
commit | 240a62de8a9b3c93fb9f7031f5e204264d414817 (patch) | |
tree | 1f5e0bb204f8a98d7bf8fdf0da48472de27a3ab8 /searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp | |
parent | 14e1b2febd40c3fa89d09b64569b4634f5594acc (diff) | |
parent | a45d929b88b17c9de0d53d4c6fc3b25815bbe233 (diff) |
Merge pull request #24367 from vespa-engine/toregge/share-code-for-loading-and-saving-tensor-attributev8.65.41
Share code for loading and saving tensor attribute between
Diffstat (limited to 'searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp')
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp index 94bf3f1a37b..a24059b3f7c 100644 --- a/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp @@ -1,17 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "serialized_fast_value_attribute.h" -#include "streamed_value_saver.h" #include <vespa/eval/eval/value.h> -#include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.tensor.serialized_fast_value_attribute"); -#include "blob_sequence_reader.h" - using namespace vespalib; using namespace vespalib::eval; @@ -50,50 +46,4 @@ SerializedFastValueAttribute::getTensor(DocId docId) const return _tensorBufferStore.get_tensor(ref); } -bool -SerializedFastValueAttribute::onLoad(vespalib::Executor *) -{ - BlobSequenceReader tensorReader(*this); - if (!tensorReader.hasData()) { - return false; - } - setCreateSerialNum(tensorReader.getCreateSerialNum()); - assert(tensorReader.getVersion() == getVersion()); - uint32_t numDocs(tensorReader.getDocIdLimit()); - _refVector.reset(); - _refVector.unsafe_reserve(numDocs); - vespalib::Array<char> buffer(1024); - for (uint32_t lid = 0; lid < numDocs; ++lid) { - uint32_t tensorSize = tensorReader.getNextSize(); - if (tensorSize != 0) { - if (tensorSize > buffer.size()) { - buffer.resize(tensorSize + 1024); - } - tensorReader.readBlob(&buffer[0], tensorSize); - vespalib::nbostream source(&buffer[0], tensorSize); - EntryRef ref = _tensorBufferStore.store_encoded_tensor(source); - _refVector.push_back(AtomicEntryRef(ref)); - } else { - EntryRef invalid; - _refVector.push_back(AtomicEntryRef(invalid)); - } - } - setNumDocs(numDocs); - setCommittedDocIdLimit(numDocs); - return true; -} - - -std::unique_ptr<AttributeSaver> -SerializedFastValueAttribute::onInitSave(vespalib::stringref fileName) -{ - vespalib::GenerationHandler::Guard guard(getGenerationHandler(). - takeGuard()); - return std::make_unique<StreamedValueSaver> - (std::move(guard), - this->createAttributeHeader(fileName), - getRefCopy(), - _tensorBufferStore); -} - } |