summaryrefslogtreecommitdiffstats
path: root/memfilepersistence
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@yahoo-inc.com>2016-10-10 14:24:38 +0200
committerArnstein Ressem <aressem@yahoo-inc.com>2016-10-10 14:24:38 +0200
commitc355f4c97a5455f46ff9c779b6320060f67211d0 (patch)
treefc8005b46c3661d02a6c2cc2c810af21a5ae85eb /memfilepersistence
parent2eacefe6b4c7b7981c0fcec0a1fa5fdaa933ec36 (diff)
parent6abdd3d8960ce01422e0cc902cba7e2fa9facc67 (diff)
Merge branch 'master' into aressem/dont-allow-unresolved-symbols-in-shared-libs-or-executables
Diffstat (limited to 'memfilepersistence')
-rw-r--r--memfilepersistence/src/tests/spi/buffer_test.cpp5
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h3
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/common/options.h4
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/common/types.h10
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.cpp11
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h8
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp3
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h4
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h6
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h6
10 files changed, 32 insertions, 28 deletions
diff --git a/memfilepersistence/src/tests/spi/buffer_test.cpp b/memfilepersistence/src/tests/spi/buffer_test.cpp
index a2d917301fc..0addb1032f5 100644
--- a/memfilepersistence/src/tests/spi/buffer_test.cpp
+++ b/memfilepersistence/src/tests/spi/buffer_test.cpp
@@ -36,9 +36,8 @@ BufferTest::getSizeReturnsInitiallyAllocatedSize()
void
BufferTest::getSizeReturnsUnAlignedSizeForMMappedAllocs()
{
- Buffer buf(vespalib::MMapAlloc::HUGEPAGE_SIZE + 1);
- CPPUNIT_ASSERT_EQUAL(size_t(vespalib::MMapAlloc::HUGEPAGE_SIZE + 1),
- buf.getSize());
+ Buffer buf(vespalib::alloc::MemoryAllocator::HUGEPAGE_SIZE + 1);
+ CPPUNIT_ASSERT_EQUAL(size_t(vespalib::alloc::MemoryAllocator::HUGEPAGE_SIZE + 1), buf.getSize());
}
void
diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h b/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h
index 4d9cda2c47c..63dd0d3172e 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h
@@ -20,8 +20,7 @@ namespace memfile {
class MemFileEnvironment;
class FileSpecification : private Types,
- public vespalib::Printable,
- public boost::operators<FileSpecification>
+ public vespalib::Printable
{
BucketId _bucketId;
Directory* _dir;
diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/options.h b/memfilepersistence/src/vespa/memfilepersistence/common/options.h
index 831f43ab603..a83657a9189 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/common/options.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/common/options.h
@@ -16,7 +16,6 @@
#pragma once
-#include <boost/operators.hpp>
#include <vespa/vespalib/util/printable.h>
#include <vespa/fastos/types.h> // For uint32_t on linux
#include <string>
@@ -29,8 +28,7 @@ namespace storage {
namespace memfile {
-struct Options : public vespalib::Printable,
- public boost::operators<Options>
+struct Options : public vespalib::Printable
{
// Parameters from def file. See config file for comments.
diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/types.h b/memfilepersistence/src/vespa/memfilepersistence/common/types.h
index bf4bdc98222..71a9b411e6c 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/common/types.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/common/types.h
@@ -39,7 +39,7 @@ namespace memfile {
* of zero with a non-zero position is invalid, and used to indicate that this
* value is not set yet. (Typically when data isn't persisted to disk yet)
*/
-struct DataLocation : public boost::operators<DataLocation> {
+struct DataLocation {
uint32_t _pos;
uint32_t _size;
@@ -52,8 +52,12 @@ struct DataLocation : public boost::operators<DataLocation> {
bool valid() const { return (_size > 0 || _pos == 0); }
- bool operator==(const DataLocation& other) const
- { return (_pos == other._pos && _size == other._size); }
+ bool operator==(const DataLocation& other) const {
+ return (_pos == other._pos && _size == other._size);
+ }
+ bool operator!=(const DataLocation& other) const {
+ return ! (*this == other);
+ }
bool operator<(const DataLocation& other) const {
if (_pos == other._pos) {
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.cpp
index 5ecb439b3f0..a998bb7d90e 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.cpp
@@ -5,11 +5,18 @@
#include <algorithm>
#include <stdlib.h>
+using vespalib::DefaultAlloc;
+using vespalib::alloc::MemoryAllocator;
+using vespalib::alloc::Alloc;
+
namespace storage {
namespace memfile {
+// Use AutoAlloc to transparently use mmap for large buffers.
+// It is crucial that any backing buffer type returns an address that is
+// 512-byte aligned, or direct IO will scream at us and fail everything.
Buffer::Buffer(size_t size)
- : _buffer(size),
+ : _buffer(DefaultAlloc::create(size, MemoryAllocator::HUGEPAGE_SIZE, 512)),
_size(size)
{
}
@@ -17,7 +24,7 @@ Buffer::Buffer(size_t size)
void
Buffer::resize(size_t size)
{
- BackingType buffer(size);
+ Alloc buffer = _buffer.create(size);
size_t commonSize(std::min(size, _size));
memcpy(buffer.get(), _buffer.get(), commonSize);
_buffer.swap(buffer);
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h
index d097a078af9..26f4a644d0c 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h
@@ -19,13 +19,7 @@ namespace memfile {
class Buffer
{
- // Use AutoAlloc to transparently use mmap for large buffers.
- // It is crucial that any backing buffer type returns an address that is
- // 512-byte aligned, or direct IO will scream at us and fail everything.
- static constexpr size_t MMapLimit = vespalib::MMapAlloc::HUGEPAGE_SIZE;
- using BackingType = vespalib::AutoAlloc<MMapLimit, 512>;
-
- BackingType _buffer;
+ vespalib::alloc::Alloc _buffer;
// Actual, non-aligned size (as opposed to _buffer.size()).
size_t _size;
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp
index 369df0c1143..1cc765ada5a 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp
@@ -2,7 +2,6 @@
#include <vespa/fastos/fastos.h>
#include <vespa/memfilepersistence/mapper/bufferedfilewriter.h>
-#include <boost/scoped_array.hpp>
#include <vespa/vespalib/util/guard.h>
#include <vespa/log/log.h>
#include <vespa/vespalib/io/fileutil.h>
@@ -162,7 +161,7 @@ void BufferedFileWriter::writeGarbage(uint32_t size) {
ValueGuard<uint32_t> filePositionGuard(_filePosition);
uint32_t maxBufferSize = 0xFFFF;
uint32_t bufSize = (size > maxBufferSize ? maxBufferSize : size);
- boost::scoped_array<char> buf(new char[bufSize]);
+ std::unique_ptr<char[]> buf(new char[bufSize]);
while (size > 0) {
uint32_t part = (size > bufSize ? bufSize : size);
write(&buf[0], part, _filePosition);
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h
index 8dbffcaf795..c564893a154 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h
@@ -77,7 +77,7 @@ public:
typedef vespalib::LinkedPtr<SharedBuffer> LP;
explicit SharedBuffer(size_t totalSize)
- : _buf(totalSize),
+ : _buf(vespalib::alloc::MMapAllocFactory::create(totalSize)),
_usedSize(0)
{
}
@@ -115,7 +115,7 @@ public:
return static_cast<const char*>(_buf.get());
}
private:
- vespalib::MMapAlloc _buf;
+ vespalib::alloc::Alloc _buf;
size_t _usedSize;
};
diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h
index 53a20a86f8a..4ea44a45996 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h
@@ -28,8 +28,7 @@ namespace memfile {
class MemFile;
-class MemSlot : private Types,
- private boost::operators<MemSlot>
+class MemSlot : private Types
{
// Metadata for slot we need to keep.
Timestamp _timestamp; // 64 bit - 8 bytes timestamp
@@ -166,6 +165,9 @@ public:
* Used in unit testing only.
*/
bool operator==(const MemSlot& other) const;
+ bool operator!=(const MemSlot& other) const {
+ return ! (*this == other);
+ }
// Implement print functions so we can be used similar to as we were
// a document::Printable (Don't want inheritance in this class)
diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h
index c10075ef143..d62bdf10025 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h
@@ -20,7 +20,6 @@
#pragma once
-#include <boost/operators.hpp>
#include <vespa/memfilepersistence/common/types.h>
#include <vespa/vespalib/stllike/hash_set.h>
@@ -97,7 +96,7 @@ public:
* implementation in order to be able to return iterators by value, as one is
* acustomed to in the standard library.
*/
-class IteratorWrapper : public boost::operators<IteratorWrapper> {
+class IteratorWrapper {
SlotIterator::CUP _it;
public:
@@ -116,6 +115,9 @@ public:
const MemSlot* slot2(o._it.get() == 0 ? 0 : o._it->getCurrent());
return (slot == slot2);
}
+ bool operator!=(const IteratorWrapper& o) const {
+ return ! (*this == o);
+ }
const MemSlot& operator*() const { return *_it->getCurrent(); }
const MemSlot* operator->() const { return _it->getCurrent(); }