diff options
Diffstat (limited to 'searchlib')
13 files changed, 47 insertions, 58 deletions
diff --git a/searchlib/abi-spec.json b/searchlib/abi-spec.json index 1896337b419..7caf5a06032 100644 --- a/searchlib/abi-spec.json +++ b/searchlib/abi-spec.json @@ -1615,12 +1615,8 @@ ], "methods": [ "public void <init>()", - "public void <init>(java.util.Collection)", "public void <init>(java.util.Collection, java.util.Optional)", - "public void <init>(java.util.Map)", - "public void <init>(java.util.Collection, java.util.Map)", "public void <init>(java.util.Collection, java.util.Map, com.yahoo.tensor.evaluation.TypeContext)", - "public void <init>(java.util.Map, java.util.Map, java.util.Map)", "public void <init>(java.util.Map, java.util.Map, java.util.Optional, java.util.Map)", "public java.util.Optional typeContext()", "public void addFunctionSerialization(java.lang.String, java.lang.String)", diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java index 5e5f7be7001..7d0c0b98910 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java @@ -28,33 +28,29 @@ public class SerializationContext extends FunctionReferenceContext { /** Create a context for a single serialization task */ public SerializationContext() { - this(Collections.emptyList()); + this(Collections.emptyList(), Collections.emptyMap(), Optional.empty(), new LinkedHashMap<>()); } - /** @deprecated Use {@link #SerializationContext(Collection, Optional) instead}*/ - @Deprecated(forRemoval = true, since = "7") - public SerializationContext(Collection<ExpressionFunction> functions) { - this(functions, Collections.emptyMap(), Optional.empty(), new LinkedHashMap<>()); - } - - public SerializationContext(Collection<ExpressionFunction> functions, Optional<TypeContext<Reference>> typeContext) { + /** + * Create a context for a single serialization task + * + * @param functions the functions of this + * @param typeContext the type context of this: Serialization may depend on type resolution + */ + public SerializationContext(Collection<ExpressionFunction> functions, + Optional<TypeContext<Reference>> typeContext) { this(functions, Collections.emptyMap(), typeContext, new LinkedHashMap<>()); } - /** @deprecated Use {@link #SerializationContext(Map, Map, Optional, Map) instead}*/ - @Deprecated(forRemoval = true, since = "7") - public SerializationContext(Map<String, ExpressionFunction> functions) { - this(functions.values()); - } - - /** @deprecated Use {@link #SerializationContext(Collection, Map, TypeContext) instead}*/ - @Deprecated(forRemoval = true, since = "7") - public SerializationContext(Collection<ExpressionFunction> functions, Map<String, String> bindings) { - this(functions, bindings, Optional.empty(), new LinkedHashMap<>()); - } - - /** Create a context for a single serialization task */ - public SerializationContext(Collection<ExpressionFunction> functions, Map<String, String> bindings, + /** + * Create a context for a single serialization task + * + * @param functions the functions of this + * @param bindings the arguments of this + * @param typeContext the type context of this: Serialization may depend on type resolution + */ + public SerializationContext(Collection<ExpressionFunction> functions, + Map<String, String> bindings, TypeContext<Reference> typeContext) { this(functions, bindings, Optional.of(typeContext), new LinkedHashMap<>()); } @@ -68,20 +64,15 @@ public class SerializationContext extends FunctionReferenceContext { * @param serializedFunctions a cache of serializedFunctions - the ownership of this map * is <b>transferred</b> to this and will be modified in it */ - private SerializationContext(Collection<ExpressionFunction> functions, Map<String, String> bindings, + private SerializationContext(Collection<ExpressionFunction> functions, + Map<String, String> bindings, Optional<TypeContext<Reference>> typeContext, Map<String, String> serializedFunctions) { this(toMap(functions), bindings, typeContext, serializedFunctions); } - /** @deprecated Use {@link #SerializationContext(Map, Map, Optional, Map) instead}*/ - @Deprecated(forRemoval = true, since = "7") - public SerializationContext(Map<String, ExpressionFunction> functions, Map<String, String> bindings, - Map<String, String> serializedFunctions) { - this(functions, bindings, Optional.empty(), serializedFunctions); - } - - public SerializationContext(Map<String, ExpressionFunction> functions, Map<String, String> bindings, + public SerializationContext(Map<String, ExpressionFunction> functions, + Map<String, String> bindings, Optional<TypeContext<Reference>> typeContext, Map<String, String> serializedFunctions) { super(functions, bindings); diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 5ddbb6d0a11..72b2f1e320a 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -100,7 +100,7 @@ private: public: MockIndexLoader(int& index_value, FastOS_FileInterface& file) : _index_value(index_value), - _reader(file) + _reader(&file) {} bool load_next() override { _index_value = _reader.readHostOrder(); diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 005fe6bd9d5..82bdf99ab2c 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -56,7 +56,7 @@ private: T getRandomValue() { T min = std::numeric_limits<T>::min(); T max = std::numeric_limits<T>::max(); - return min + static_cast<T>(double(max - min) * (((float)rand() / (float)RAND_MAX))); + return static_cast<T>(double(min) + (double(max) - double(min)) * (double(rand()) / double(RAND_MAX))); } template<typename T> void fill(IntegerAttribute *attr, uint32_t size, uint32_t unique = 0); diff --git a/searchlib/src/vespa/searchlib/attribute/primitivereader.h b/searchlib/src/vespa/searchlib/attribute/primitivereader.h index 12eac275f8a..613065260ad 100644 --- a/searchlib/src/vespa/searchlib/attribute/primitivereader.h +++ b/searchlib/src/vespa/searchlib/attribute/primitivereader.h @@ -13,7 +13,7 @@ namespace search { public: PrimitiveReader(AttributeVector &attr) : ReaderBase(attr), - _datReader(_datFile.file()) + _datReader(&_datFile.file()) { } virtual ~PrimitiveReader() { } diff --git a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp index d023d9b56b1..8dd1a466fb5 100644 --- a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp @@ -32,9 +32,9 @@ ReaderBase::ReaderBase(AttributeVector &attr) attribute::LoadUtils::openWeight(attr) : std::unique_ptr<Fast_BufferedFile>()), _idxFile(attr.hasMultiValue() ? attribute::LoadUtils::openIDX(attr) : std::unique_ptr<Fast_BufferedFile>()), - _weightReader(_weightFile.file()), - _idxReader(_idxFile.file()), - _enumReader(_datFile.file()), + _weightReader(_weightFile.valid() ? &_weightFile.file() : nullptr), + _idxReader(_idxFile.valid() ? &_idxFile.file() : nullptr), + _enumReader(&_datFile.file()), _currIdx(0), _createSerialNum(0u), _fixedWidth(attr.getFixedWidth()), diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp index 9e3e6c9e46c..79a6742f9da 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp +++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp @@ -38,8 +38,8 @@ ChunkFormat::pack(uint64_t lastSerial, vespalib::DataBuffer & compressed, const compressed.getData()[oldPos] = type; } if (includeSerializedSize()) { - const uint32_t serializedSize = compressed.getDataLen()+4; - *reinterpret_cast<uint32_t *>(compressed.getData() + serializedSizePos) = htonl(serializedSize); + const uint32_t serializedSize = htonl(compressed.getDataLen()+4); + memcpy(compressed.getData() + serializedSizePos, &serializedSize, sizeof(serializedSize)); } uint32_t crc = computeCrc(compressed.getData(), compressed.getDataLen()); compressed.writeInt32(crc); diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index f625a2b7fd2..ae1d2c16960 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -48,17 +48,19 @@ SimpleQueryStackDumpIterator::read_stringref(const char *&p) uint64_t SimpleQueryStackDumpIterator::readUint64(const char *&p) { - uint64_t l = vespalib::nbo::n2h(*(const uint64_t *)(const void *)p); - p += sizeof(uint64_t); - return l; + uint64_t value; + memcpy(&value, p, sizeof(value)); + p += sizeof(value); + return vespalib::nbo::n2h(value); } double SimpleQueryStackDumpIterator::read_double(const char *&p) { - double result = vespalib::nbo::n2h(*reinterpret_cast<const double *>(p)); - p += sizeof(double); - return result; + double value; + memcpy(&value, p, sizeof(value)); + p += sizeof(value); + return vespalib::nbo::n2h(value); } uint64_t diff --git a/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h b/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h index 45fcf5524d2..adad87d8cfe 100644 --- a/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h +++ b/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h @@ -17,7 +17,7 @@ private: public: BlobSequenceReader(AttributeVector &attr) : ReaderBase(attr), - _sizeReader(_datFile.file()) + _sizeReader(&_datFile.file()) { } uint32_t getNextSize() { return _sizeReader.readHostOrder(); } void readBlob(void *buf, size_t len); diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index 994c5aa142d..2ee1b268449 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -685,7 +685,7 @@ HnswIndex::make_loader(FastOS_FileInterface& file) assert(get_entry_docid() == 0); // cannot load after index has data using ReaderType = FileReader<uint32_t>; using LoaderType = HnswIndexLoader<ReaderType>; - return std::make_unique<LoaderType>(_graph, std::make_unique<ReaderType>(file)); + return std::make_unique<LoaderType>(_graph, std::make_unique<ReaderType>(&file)); } struct NeighborsByDocId { diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h index 7f17adc99f7..f7ea80c9248 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h @@ -18,7 +18,7 @@ namespace search::transactionlog { class TransLogServerExplorer; class Domain; -class TransLogServer : public document::Runnable, private FRT_Invokable, public WriterFactory +class TransLogServer : private FRT_Invokable, public document::Runnable, public WriterFactory { public: friend class TransLogServerExplorer; diff --git a/searchlib/src/vespa/searchlib/util/fileutil.cpp b/searchlib/src/vespa/searchlib/util/fileutil.cpp index e85e792f492..7d65e298767 100644 --- a/searchlib/src/vespa/searchlib/util/fileutil.cpp +++ b/searchlib/src/vespa/searchlib/util/fileutil.cpp @@ -109,9 +109,9 @@ FileUtil::loadFile(const vespalib::string &fileName) void FileReaderBase::handleError(ssize_t numRead, size_t wanted) { if (numRead == 0) { - throw std::runtime_error(vespalib::make_string("Trying to read past EOF of file %s", _file.GetFileName())); + throw std::runtime_error(vespalib::make_string("Trying to read past EOF of file %s", _file->GetFileName())); } else { - throw std::runtime_error(vespalib::make_string("Partial read(%zd of %zu) of file %s", numRead, wanted, _file.GetFileName())); + throw std::runtime_error(vespalib::make_string("Partial read(%zd of %zu) of file %s", numRead, wanted, _file->GetFileName())); } } @@ -126,7 +126,7 @@ void FileWriterBase::handleError(ssize_t numRead, size_t wanted) ssize_t FileReaderBase::read(void *buf, size_t sz) { - ssize_t numRead = _file.Read(buf, sz); + ssize_t numRead = _file->Read(buf, sz); if (numRead != ssize_t(sz)) { handleError(numRead, sz); } diff --git a/searchlib/src/vespa/searchlib/util/fileutil.h b/searchlib/src/vespa/searchlib/util/fileutil.h index 8271265aa33..bb74aa47484 100644 --- a/searchlib/src/vespa/searchlib/util/fileutil.h +++ b/searchlib/src/vespa/searchlib/util/fileutil.h @@ -73,11 +73,11 @@ public: class FileReaderBase { public: - FileReaderBase(FastOS_FileInterface & file) : _file(file) { } + FileReaderBase(FastOS_FileInterface * file) : _file(file) { } ssize_t read(void *buf, size_t sz); private: void handleError(ssize_t numRead, size_t wanted); - FastOS_FileInterface & _file; + FastOS_FileInterface * _file; }; class FileWriterBase @@ -95,7 +95,7 @@ template <typename T> class FileReader : public FileReaderBase { public: - FileReader(FastOS_FileInterface & file) : FileReaderBase(file) { } + FileReader(FastOS_FileInterface * file) : FileReaderBase(file) { } T readHostOrder() { T result; read(&result, sizeof(result)); |