summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-08-31 12:27:59 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-08-31 12:30:34 +0000
commit2932130635e132c591f13aeb5dce8f9c6aac2a7c (patch)
treec4966a6b163ecc8418f5aa86c35a59eb6e07be21 /vespalib
parentfb84d303e6e1f4c434bafe44538dbf3689d3bddd (diff)
Use an allocator that automagically allocates large buffer by using mmap.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/slime/json_slime_benchmark.cpp2
-rw-r--r--vespalib/src/tests/slime/slime_binary_format_test.cpp1
-rw-r--r--vespalib/src/tests/slime/slime_json_format_test.cpp1
-rw-r--r--vespalib/src/tests/slime/slime_test.cpp7
-rw-r--r--vespalib/src/tests/trace/trace_serialization.cpp1
-rw-r--r--vespalib/src/vespa/vespalib/data/memory.h12
-rw-r--r--vespalib/src/vespa/vespalib/data/simple_buffer.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/data/simple_buffer.h3
-rw-r--r--vespalib/src/vespa/vespalib/data/slime/slime.h1
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h4
-rw-r--r--vespalib/src/vespa/vespalib/util/arrayref.h18
11 files changed, 30 insertions, 22 deletions
diff --git a/vespalib/src/tests/slime/json_slime_benchmark.cpp b/vespalib/src/tests/slime/json_slime_benchmark.cpp
index 3c006bb89f7..36987843492 100644
--- a/vespalib/src/tests/slime/json_slime_benchmark.cpp
+++ b/vespalib/src/tests/slime/json_slime_benchmark.cpp
@@ -1,9 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/data/slime/slime.h>
+#include <vespa/vespalib/data/simple_buffer.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <iostream>
#include <fstream>
-#include <sstream>
using namespace vespalib::slime::convenience;
diff --git a/vespalib/src/tests/slime/slime_binary_format_test.cpp b/vespalib/src/tests/slime/slime_binary_format_test.cpp
index e6661cbf554..37ce6d5dfdf 100644
--- a/vespalib/src/tests/slime/slime_binary_format_test.cpp
+++ b/vespalib/src/tests/slime/slime_binary_format_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/data/slime/slime.h>
+#include <vespa/vespalib/data/simple_buffer.h>
#include "type_traits.h"
#include <vespa/vespalib/util/stringfmt.h>
diff --git a/vespalib/src/tests/slime/slime_json_format_test.cpp b/vespalib/src/tests/slime/slime_json_format_test.cpp
index d1f77f09af1..df2f8b2e30b 100644
--- a/vespalib/src/tests/slime/slime_json_format_test.cpp
+++ b/vespalib/src/tests/slime/slime_json_format_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/data/input.h>
#include <vespa/vespalib/data/memory_input.h>
+#include <vespa/vespalib/data/simple_buffer.h>
#include <iostream>
#include <fstream>
diff --git a/vespalib/src/tests/slime/slime_test.cpp b/vespalib/src/tests/slime/slime_test.cpp
index 7e70dc3538e..e58b1599b8f 100644
--- a/vespalib/src/tests/slime/slime_test.cpp
+++ b/vespalib/src/tests/slime/slime_test.cpp
@@ -1,11 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("slime_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/data/slime/strfmt.h>
+#include <vespa/vespalib/data/simple_buffer.h>
#include <type_traits>
+#include <vespa/log/log.h>
+LOG_SETUP("slime_test");
+
using namespace vespalib::slime::convenience;
TEST("print sizes") {
diff --git a/vespalib/src/tests/trace/trace_serialization.cpp b/vespalib/src/tests/trace/trace_serialization.cpp
index 7658fe7f163..3182e46061a 100644
--- a/vespalib/src/tests/trace/trace_serialization.cpp
+++ b/vespalib/src/tests/trace/trace_serialization.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/trace/tracenode.h>
#include <vespa/vespalib/trace/slime_trace_serializer.h>
#include <vespa/vespalib/trace/slime_trace_deserializer.h>
+#include <vespa/vespalib/data/simple_buffer.h>
#include <vespa/log/log.h>
LOG_SETUP("trace_test");
diff --git a/vespalib/src/vespa/vespalib/data/memory.h b/vespalib/src/vespa/vespalib/data/memory.h
index 07767180b57..eee0a1a3e4f 100644
--- a/vespalib/src/vespa/vespalib/data/memory.h
+++ b/vespalib/src/vespa/vespalib/data/memory.h
@@ -15,14 +15,14 @@ struct Memory
const char *data;
size_t size;
- Memory() : data(nullptr), size(0) {}
- Memory(const char *d, size_t s) : data(d), size(s) {}
- Memory(const char *str) : data(str), size(strlen(str)) {}
- Memory(const std::string &str)
+ Memory() noexcept : data(nullptr), size(0) {}
+ Memory(const char *d, size_t s) noexcept : data(d), size(s) {}
+ Memory(const char *str) noexcept : data(str), size(strlen(str)) {}
+ Memory(const std::string &str) noexcept
: data(str.data()), size(str.size()) {}
- Memory(const vespalib::string &str)
+ Memory(const vespalib::string &str) noexcept
: data(str.data()), size(str.size()) {}
- Memory(vespalib::stringref str_ref)
+ Memory(vespalib::stringref str_ref) noexcept
: data(str_ref.data()), size(str_ref.size()) {}
vespalib::string make_string() const;
vespalib::stringref make_stringref() const { return stringref(data, size); }
diff --git a/vespalib/src/vespa/vespalib/data/simple_buffer.cpp b/vespalib/src/vespa/vespalib/data/simple_buffer.cpp
index 09ac4a4b830..7e3c5022fc5 100644
--- a/vespalib/src/vespa/vespalib/data/simple_buffer.cpp
+++ b/vespalib/src/vespa/vespalib/data/simple_buffer.cpp
@@ -11,7 +11,7 @@ SimpleBuffer::SimpleBuffer()
{
}
-SimpleBuffer::~SimpleBuffer() { }
+SimpleBuffer::~SimpleBuffer() = default;
Memory
SimpleBuffer::obtain()
diff --git a/vespalib/src/vespa/vespalib/data/simple_buffer.h b/vespalib/src/vespa/vespalib/data/simple_buffer.h
index f7d9543440f..3bcb43a3856 100644
--- a/vespalib/src/vespa/vespalib/data/simple_buffer.h
+++ b/vespalib/src/vespa/vespalib/data/simple_buffer.h
@@ -4,6 +4,7 @@
#include "input.h"
#include "output.h"
+#include <vespa/vespalib/stllike/allocator.h>
#include <iosfwd>
#include <vector>
@@ -20,7 +21,7 @@ class SimpleBuffer : public Input,
public Output
{
private:
- std::vector<char> _data;
+ std::vector<char, allocator_large<char>> _data;
size_t _used;
public:
diff --git a/vespalib/src/vespa/vespalib/data/slime/slime.h b/vespalib/src/vespa/vespalib/data/slime/slime.h
index aa44b38b353..6523cd1dac0 100644
--- a/vespalib/src/vespa/vespalib/data/slime/slime.h
+++ b/vespalib/src/vespa/vespalib/data/slime/slime.h
@@ -31,7 +31,6 @@
#include "external_data_value_factory.h"
#include <vespa/vespalib/data/input_reader.h>
#include <vespa/vespalib/data/output_writer.h>
-#include <vespa/vespalib/data/simple_buffer.h>
#include <vespa/vespalib/data/output.h>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h
index db545451a30..78597a53dc8 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h
@@ -3,6 +3,7 @@
#pragma once
#include "i_unique_store_dictionary.h"
+#include <vespa/vespalib/stllike/allocator.h>
namespace vespalib::datastore {
@@ -18,9 +19,10 @@ template <typename RefT>
class UniqueStoreEnumerator {
public:
using RefType = RefT;
- using EnumValues = std::vector<std::vector<uint32_t>>;
private:
+ using UInt32Vector = std::vector<uint32_t, vespalib::allocator_large<uint32_t>>;
+ using EnumValues = std::vector<UInt32Vector>;
IUniqueStoreDictionary::ReadSnapshot::UP _dict_snapshot;
const DataStoreBase &_store;
EnumValues _enumValues;
diff --git a/vespalib/src/vespa/vespalib/util/arrayref.h b/vespalib/src/vespa/vespalib/util/arrayref.h
index 749395ff574..03634a7a094 100644
--- a/vespalib/src/vespa/vespalib/util/arrayref.h
+++ b/vespalib/src/vespa/vespalib/util/arrayref.h
@@ -13,11 +13,11 @@ namespace vespalib {
template <typename T>
class ArrayRef {
public:
- ArrayRef() : _v(nullptr), _sz(0) { }
- ArrayRef(T * v, size_t sz) : _v(v), _sz(sz) { }
+ ArrayRef() noexcept : _v(nullptr), _sz(0) { }
+ ArrayRef(T * v, size_t sz) noexcept : _v(v), _sz(sz) { }
template<typename A=std::allocator<T>>
- ArrayRef(std::vector<T, A> & v) : _v(&v[0]), _sz(v.size()) { }
- ArrayRef(Array<T> &v) : _v(&v[0]), _sz(v.size()) { }
+ ArrayRef(std::vector<T, A> & v) noexcept : _v(&v[0]), _sz(v.size()) { }
+ ArrayRef(Array<T> &v) noexcept : _v(&v[0]), _sz(v.size()) { }
T & operator [] (size_t i) { return _v[i]; }
const T & operator [] (size_t i) const { return _v[i]; }
size_t size() const { return _sz; }
@@ -32,12 +32,12 @@ private:
template <typename T>
class ConstArrayRef {
public:
- ConstArrayRef(const T *v, size_t sz) : _v(v), _sz(sz) { }
+ ConstArrayRef(const T *v, size_t sz) noexcept : _v(v), _sz(sz) { }
template<typename A=std::allocator<T>>
- ConstArrayRef(const std::vector<T, A> & v) : _v(&v[0]), _sz(v.size()) { }
- ConstArrayRef(const ArrayRef<T> & v) : _v(&v[0]), _sz(v.size()) { }
- ConstArrayRef(const Array<T> &v) : _v(&v[0]), _sz(v.size()) { }
- ConstArrayRef() : _v(nullptr), _sz(0) {}
+ ConstArrayRef(const std::vector<T, A> & v) noexcept : _v(&v[0]), _sz(v.size()) { }
+ ConstArrayRef(const ArrayRef<T> & v) noexcept : _v(&v[0]), _sz(v.size()) { }
+ ConstArrayRef(const Array<T> &v) noexcept : _v(&v[0]), _sz(v.size()) { }
+ ConstArrayRef() noexcept : _v(nullptr), _sz(0) {}
const T & operator [] (size_t i) const { return _v[i]; }
size_t size() const { return _sz; }
bool empty() const { return _sz == 0; }