diff options
Diffstat (limited to 'searchlib/src/vespa')
5 files changed, 7 insertions, 60 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h b/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h index b32c8fc1663..58aba882e8d 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h +++ b/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h @@ -5,7 +5,6 @@ #include "attributememoryfilewriter.h" #include "iattributesavetarget.h" #include <vespa/searchlib/common/tunefileinfo.h> -#include <vespa/searchlib/util/rawbuf.h> #include <vespa/vespalib/stllike/hash_fun.h> #include <memory> #include <unordered_map> @@ -37,7 +36,7 @@ private: public: AttributeMemorySaveTarget(); - ~AttributeMemorySaveTarget(); + ~AttributeMemorySaveTarget() override; /** * Write the underlying buffer(s) to file(s). diff --git a/searchlib/src/vespa/searchlib/parsequery/parse.h b/searchlib/src/vespa/searchlib/parsequery/parse.h index c3b5fcc81fa..1285125d34b 100644 --- a/searchlib/src/vespa/searchlib/parsequery/parse.h +++ b/searchlib/src/vespa/searchlib/parsequery/parse.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/searchlib/query/weight.h> -#include <vespa/searchlib/util/rawbuf.h> #include <vespa/vespalib/stllike/string.h> namespace search { diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp index 5ed33ec18a1..9bb62e76c49 100644 --- a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp +++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp @@ -8,6 +8,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/searchlib/parsequery/parse.h> +#include <vespa/searchlib/util/rawbuf.h> using vespalib::string; using std::vector; diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.cpp b/searchlib/src/vespa/searchlib/util/rawbuf.cpp index d3cc9996c34..d64d85f2f1d 100644 --- a/searchlib/src/vespa/searchlib/util/rawbuf.cpp +++ b/searchlib/src/vespa/searchlib/util/rawbuf.cpp @@ -2,14 +2,12 @@ #include "rawbuf.h" #include <vespa/vespalib/util/compress.h> -#include <vespa/fastos/file.h> #include <cassert> #include <cstring> +#include <cstdio> namespace search { -static inline size_t smin(size_t a, size_t b) { return (a < b) ? a : b; } - RawBuf::RawBuf(size_t size) : _bufStart(nullptr), _bufEnd(nullptr), @@ -25,21 +23,6 @@ RawBuf::RawBuf(size_t size) _bufDrainPos = _bufFillPos = _bufStart; } - -RawBuf::RawBuf(char *start, size_t size) - : _bufStart(nullptr), - _bufEnd(nullptr), - _bufFillPos(nullptr), - _bufDrainPos(nullptr), - _initialBufStart(start), - _initialSize(size) -{ - _bufStart = start; - _bufEnd = _bufStart + size; - _bufDrainPos = _bufFillPos = _bufStart; -} - - RawBuf::~RawBuf() { if (_bufStart != _initialBufStart) @@ -109,17 +92,6 @@ RawBuf::appendCompressedNumber(int64_t n) _bufFillPos += vespalib::compress::Integer::compress(n, _bufFillPos); } - -/** - * Has the entire contents of the buffer been used up, i.e. freed? - */ -bool -RawBuf::IsEmpty() -{ - return _bufFillPos == _bufDrainPos; -} - - /** * Free 'len' bytes from the start of the contents. (These * have presumably been written or read.) @@ -345,19 +317,6 @@ RawBuf::addSignedHitRank(SignedHitRank num) append(buf1, strlen(buf1)); } -/** - * Read from the indicated file into the buffer, no more that the - * given number of bytes and no more than will fit in the buffer. - */ -size_t -RawBuf::readFile(FastOS_FileInterface &file, size_t maxlen) -{ - size_t got = file.Read(_bufFillPos, smin((_bufEnd - _bufFillPos), maxlen)); - if (got > 0) - _bufFillPos += got; - return got; -} - void RawBuf::ensureSizeInternal(size_t size) { expandBuf(size); diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.h b/searchlib/src/vespa/searchlib/util/rawbuf.h index e69c13e13b3..258e3da88ed 100644 --- a/searchlib/src/vespa/searchlib/util/rawbuf.h +++ b/searchlib/src/vespa/searchlib/util/rawbuf.h @@ -19,9 +19,6 @@ namespace search { class RawBuf { private: - RawBuf(const RawBuf &); - RawBuf& operator=(const RawBuf &); - char* _bufStart; // ref. to start of buffer (don't move this!) char* _bufEnd; // ref. to byte after last in buffer (don't mo) char* _bufFillPos; // ref. to byte where next should be put in @@ -31,9 +28,9 @@ private: void ensureSizeInternal(size_t size); public: - - RawBuf(char *start, size_t size);// Initially use provided buffer - RawBuf(size_t size); // malloc-s given size, assigns to _bufStart + RawBuf(const RawBuf &) = delete; + RawBuf& operator=(const RawBuf &) = delete; + explicit RawBuf(size_t size); // malloc-s given size, assigns to _bufStart ~RawBuf(); // Frees _bufStart, i.e. the char[]. void operator+=(const char *src); @@ -48,10 +45,8 @@ public: void append(const void *data, size_t len); void append(uint8_t byte); - void appendLong(uint64_t n); void appendCompressedPositiveNumber(uint64_t n); void appendCompressedNumber(int64_t n); - bool IsEmpty(); // Return whether all written. void expandBuf(size_t needlen); size_t GetFreeLen() const { return _bufEnd - _bufFillPos; } size_t GetDrainLen() const { return _bufDrainPos - _bufStart; } @@ -59,7 +54,6 @@ public: const char *GetFillPos() const { return _bufFillPos; } char * GetWritableFillPos() const { return _bufFillPos; } char * GetWritableFillPos(size_t len) { preAlloc(len); return _bufFillPos; } - char * GetWritableDrainPos(size_t offset) { return _bufDrainPos + offset; } void truncate(size_t offset) { _bufFillPos = _bufDrainPos + offset; } void preAlloc(size_t len); // Ensure room for 'len' more bytes. size_t readFile(FastOS_FileInterface &file, size_t maxlen); @@ -83,16 +77,11 @@ public: static uint16_t InetTo16(const unsigned char *src) { return (static_cast<uint16_t>(*src) << 8) + *(src + 1); }; - static uint16_t InetTo16(const char* src) { - return InetTo16(reinterpret_cast<const unsigned char *>(src)); - }; + static uint32_t InetTo32(const unsigned char* src) { return (((((static_cast<uint32_t>(*src) << 8) + *(src + 1)) << 8) + *(src + 2)) << 8) + *(src + 3); }; - static uint32_t InetTo32(const char* src) { - return InetTo32(reinterpret_cast<const unsigned char *>(src)); - }; /** * Convert unsigned int.s 'src', to interNet highendian order, at 'dst' |