aboutsummaryrefslogtreecommitdiffstats
path: root/memfilepersistence
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-04 15:55:10 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-01-04 15:55:10 +0100
commitafa8fd925b8b24399b2acf5671c720926db90153 (patch)
tree0736b8ba2c585e0d5469f74666dd845f86943f31 /memfilepersistence
parent2d2b53b10fd9a73e7db19577e4c6a730c0c4c3d1 (diff)
Track the requested size yourself as the underlying allocation will take the liberty of rounding up to a suitable pagesize.
Diffstat (limited to 'memfilepersistence')
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h
index f5c8914d40d..fa5436bdeaa 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h
@@ -77,11 +77,11 @@ public:
typedef vespalib::LinkedPtr<SharedBuffer> LP;
explicit SharedBuffer(size_t totalSize)
: _buf(vespalib::alloc::Alloc::allocMMap(totalSize)),
+ _totalSize(totalSize),
_usedSize(0)
- {
- }
+ { }
- size_t getSize() const { return _buf.size(); }
+ size_t getSize() const { return _totalSize; }
size_t getUsedSize() const { return _usedSize; }
size_t getFreeSize() const { return getSize() - getUsedSize(); }
bool hasRoomFor(size_t sz, Alignment align = NO_ALIGN) const {
@@ -115,6 +115,7 @@ public:
}
private:
vespalib::alloc::Alloc _buf;
+ size_t _totalSize;
size_t _usedSize;
};
@@ -123,7 +124,7 @@ public:
BufferAllocation() : pos(0), size(0) {}
BufferAllocation(const SharedBuffer::LP& b, uint32_t p, uint32_t sz)
- : buf(b), pos(p), size(sz) {}
+ : buf(b), pos(p), size(sz) { }
/**
* Get buffer area available to this specific allocation
@@ -157,10 +158,9 @@ public:
static const size_t DEFAULT_STREAM_ALLOC_SIZE = 5 * 2014;
HeaderChunkEncoder(const document::DocumentId& docId)
- : _serializedDoc(DEFAULT_STREAM_ALLOC_SIZE),
- _docId(docId.toString())
- {
- }
+ : _serializedDoc(DEFAULT_STREAM_ALLOC_SIZE),
+ _docId(docId.toString())
+ { }
/**
* Serializes header chunk to buf, which must have at least a size