summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2020-04-27 09:00:30 +0200
committerGitHub <noreply@github.com>2020-04-27 09:00:30 +0200
commit3cf7d545bb9cf9532747f835fbf49ab859d9e281 (patch)
treecf7b1eec45eff08f5ceda2b5790b6cf9f650049a /vespalib
parent6eec72125244ca7b0738af4c616f378ced98dd13 (diff)
parent2c0e3e3c68772d06b2a842c1c5403b382763deec (diff)
Merge pull request #13066 from vespa-engine/toregge/move-bufferwriter-back-to-searchlib
Move BufferWriter back to searchlib.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store.hpp1
-rw-r--r--vespalib/src/vespa/vespalib/util/CMakeLists.txt1
-rw-r--r--vespalib/src/vespa/vespalib/util/bufferwriter.cpp36
-rw-r--r--vespalib/src/vespa/vespalib/util/bufferwriter.h56
4 files changed, 0 insertions, 94 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
index 33830bbe4ab..956d4c16d40 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
@@ -10,7 +10,6 @@
#include "unique_store_builder.hpp"
#include "unique_store_dictionary.hpp"
#include "unique_store_enumerator.hpp"
-#include <vespa/vespalib/util/bufferwriter.h>
#include <atomic>
#include <algorithm>
diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
index e3397b54740..4029c4881c4 100644
--- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt
+++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
@@ -12,7 +12,6 @@ vespa_add_library(vespalib_vespalib_util OBJECT
benchmark_timer.cpp
blockingthreadstackexecutor.cpp
box.cpp
- bufferwriter.cpp
classname.cpp
closuretask.cpp
compress.cpp
diff --git a/vespalib/src/vespa/vespalib/util/bufferwriter.cpp b/vespalib/src/vespa/vespalib/util/bufferwriter.cpp
deleted file mode 100644
index 6e57d6f58d4..00000000000
--- a/vespalib/src/vespa/vespalib/util/bufferwriter.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "bufferwriter.h"
-
-namespace search {
-
-BufferWriter::BufferWriter()
- : _cur(nullptr),
- _end(nullptr),
- _start(nullptr)
-{
-}
-
-BufferWriter::~BufferWriter() = default;
-
-void
-BufferWriter::writeSlow(const void *src, size_t len)
-{
- size_t residue = len;
- const char *csrc = static_cast<const char *>(src);
- for (;;) {
- size_t maxLen = freeLen();
- if (residue <= maxLen) {
- writeFast(csrc, residue);
- break;
- }
- if (maxLen != 0) {
- writeFast(csrc, maxLen);
- csrc += maxLen;
- residue -= maxLen;
- }
- flush();
- }
-}
-
-} // namespace search
diff --git a/vespalib/src/vespa/vespalib/util/bufferwriter.h b/vespalib/src/vespa/vespalib/util/bufferwriter.h
deleted file mode 100644
index 3da6e3f8030..00000000000
--- a/vespalib/src/vespa/vespalib/util/bufferwriter.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include <cstddef>
-
-namespace search {
-
-/**
- * Abstract class to write to a buffer with an abstract backing store
- * and abstract backing buffer. Each time backing buffer is full,
- * flush() is called to resize it or drain it to the backing store.
- */
-class BufferWriter
-{
- char *_cur;
- char *_end;
- char *_start;
-protected:
- void rewind() { _cur = _start; }
-
- void setup(void *start, size_t len) {
- _start = static_cast<char *>(start);
- _end = _start + len;
- rewind();
- }
-
- size_t freeLen() const { return _end - _cur; }
- size_t usedLen() const { return _cur - _start; }
-
- void writeFast(const void *src, size_t len)
- {
- __builtin_memcpy(_cur, src, len);
- _cur += len;
- }
-
- void writeSlow(const void *src, size_t len);
-
-public:
- BufferWriter();
-
- virtual ~BufferWriter();
-
- virtual void flush() = 0;
-
- void write(const void *src, size_t len)
- {
- if (__builtin_expect(len <= freeLen(), true)) {
- writeFast(src, len);
- return;
- }
- writeSlow(src, len);
- }
-};
-
-} // namespace search