diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-04-07 20:23:42 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-04-23 13:49:07 +0200 |
commit | d781938ec3beb5f8158333c0e46b6b1bb88156c5 (patch) | |
tree | d4ac50445af72530ef0d809a49c423cfd2b083d1 | |
parent | 40bddbaac34ece542a057aa97eb63db6f1c5775e (diff) |
Add override to memfilepersistence.
16 files changed, 112 insertions, 215 deletions
diff --git a/memfilepersistence/src/tests/device/devicemanagertest.cpp b/memfilepersistence/src/tests/device/devicemanagertest.cpp index 15882663383..f5e16032361 100644 --- a/memfilepersistence/src/tests/device/devicemanagertest.cpp +++ b/memfilepersistence/src/tests/device/devicemanagertest.cpp @@ -1,10 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/memfilepersistence/device/devicemanager.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/exception.h> -#include <sys/errno.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> namespace storage { @@ -70,19 +68,17 @@ namespace { std::ostringstream ost; Listener() : ost() { ost << "\n"; } - virtual ~Listener() {} + ~Listener() {} - virtual void handleDirectoryEvent(Directory& dir, const IOEvent& e) override { + void handleDirectoryEvent(Directory& dir, const IOEvent& e) override { ost << "Dir " << dir.getPath() << ": " << e.toString(true) << "\n"; } - virtual void handlePartitionEvent(Partition& part, const IOEvent& e) override { - ost << "Partition " << part.getMountPoint() << ": " - << e.toString(true) << "\n"; + void handlePartitionEvent(Partition& part, const IOEvent& e) override { + ost << "Partition " << part.getMountPoint() << ": " << e.toString(true) << "\n"; } - virtual void handleDiskEvent(Disk& disk, const IOEvent& e) override { + void handleDiskEvent(Disk& disk, const IOEvent& e) override { ost << "Disk " << disk.getId() << ": " << e.toString(true) << "\n"; } - }; } diff --git a/memfilepersistence/src/tests/device/partitionmonitortest.cpp b/memfilepersistence/src/tests/device/partitionmonitortest.cpp index 44f3752d840..d1f40e07320 100644 --- a/memfilepersistence/src/tests/device/partitionmonitortest.cpp +++ b/memfilepersistence/src/tests/device/partitionmonitortest.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/memfilepersistence/device/partitionmonitor.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vdstestlib/cppunit/macros.h> @@ -56,7 +55,7 @@ struct FakeStatter : public PartitionMonitor::Statter { _info.f_bfree -= (size / _info.f_bsize); } - virtual void statFileSystem(const std::string&, struct statvfs& info) override { + void statFileSystem(const std::string&, struct statvfs& info) override { info = _info; } }; diff --git a/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp b/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp index ad20a28ed0c..a7960057d2a 100644 --- a/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp +++ b/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/memfilepersistence/mapper/memfilemapper.h> #include <vespa/memfilepersistence/mapper/memfile_v1_serializer.h> #include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> @@ -229,23 +228,16 @@ struct DummyMemFileIOInterface : MemFileIOInterface { void clear(DocumentPart) override {} bool verifyConsistent() const override { return true; } void move(const FileSpecification&) override {} - DataLocation copyCache(const MemFileIOInterface&, - DocumentPart, - DataLocation) override - { + DataLocation copyCache(const MemFileIOInterface&, DocumentPart, DataLocation) override { return DataLocation(); } - void close() override {} + void close() override {}; bool isCached(DataLocation, DocumentPart) const override { return false; } bool isPersisted(DataLocation, DocumentPart) const override { return false; } - uint32_t getSerializedSize(DocumentPart, - DataLocation) const override { return 0; } + uint32_t getSerializedSize(DocumentPart, DataLocation) const override { return 0; } - void ensureCached(Environment&, - DocumentPart, - const std::vector<DataLocation>&) override - {} + void ensureCached(Environment&, DocumentPart, const std::vector<DataLocation>&) override {} size_t getCachedSize(DocumentPart) const override { return 0; } }; diff --git a/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp b/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp index ffe7972552f..6d51188234b 100644 --- a/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp +++ b/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp @@ -51,19 +51,15 @@ class SimpleMemFileIOBufferTest : public SingleDiskMemFileTestUtils public: class DummyFileReader : public VersionSerializer { public: - virtual FileVersion getFileVersion() override { return FileVersion(); } - virtual void loadFile(MemFile&, Environment&, Buffer&, uint64_t ) override {} - virtual FlushResult flushUpdatesToFile(MemFile&, Environment&) override { + FileVersion getFileVersion() override { return FileVersion(); } + void loadFile(MemFile&, Environment&, Buffer&, uint64_t ) override {} + FlushResult flushUpdatesToFile(MemFile&, Environment&) override { return FlushResult::TooSmall; } - virtual void rewriteFile(MemFile&, Environment&) override {} - virtual bool verify(MemFile&, Environment&, - std::ostream&, bool, uint16_t) override { return false; }; - virtual void cacheLocations(MemFileIOInterface&, - Environment&, - const Options&, - DocumentPart, - const std::vector<DataLocation>&) override {} + void rewriteFile(MemFile&, Environment&) override {} + bool verify(MemFile&, Environment&, std::ostream&, bool, uint16_t) override { return false; }; + void cacheLocations(MemFileIOInterface&, Environment&, const Options&, + DocumentPart, const std::vector<DataLocation>&) override {} }; DummyFileReader dfr; diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp index 742a37fcf36..d9cc0c35cc4 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp @@ -3,16 +3,13 @@ #include "memfile_v1_serializer.h" #include "memfile_v1_verifier.h" -#include "memfilemapper.h" #include "locationreadplanner.h" #include "uniqueslotgenerator.h" -#include "simplememfileiobuffer.h" #include <vespa/memfilepersistence/common/exceptions.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h> -#include <vespa/vespalib/util/crc.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <vespa/log/log.h> +#include <vespa/log/log.h> LOG_SETUP(".persistence.memfilev1"); namespace storage { @@ -742,19 +739,16 @@ namespace { _buffer.resize(firstAligned - _headerBlockIndex); } - virtual uint32_t getCachedAmount() const override - { return _buffer.size() + _headerBlockIndex; } - - virtual char* getCache(uint32_t pos) override { + uint32_t getCachedAmount() const override { return _buffer.size() + _headerBlockIndex; } + char* getCache(uint32_t pos) override { // We should never get requests to write prior to header block // index. assert(pos >= _headerBlockIndex); return (&_buffer[0] + (pos - _headerBlockIndex)); } - virtual bool duplicateCacheWrite() const override { return true; } - - virtual void setData(const char* data, size_t len, uint64_t pos) override { + bool duplicateCacheWrite() const override { return true; } + void setData(const char* data, size_t len, uint64_t pos) override { if (pos < _headerBlockIndex) { if (len <= _headerBlockIndex - pos) return; uint32_t diff = (_headerBlockIndex - pos); diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h index 283ab174895..500c47e94e4 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h @@ -1,10 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/memfilepersistence/mapper/bufferedfilewriter.h> -#include <vespa/memfilepersistence/mapper/versionserializer.h> -#include <vespa/memfilepersistence/mapper/fileinfo.h> -#include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> +#include "bufferedfilewriter.h" +#include "versionserializer.h" +#include "fileinfo.h" +#include "simplememfileiobuffer.h" #include <vespa/memfilepersistence/common/environment.h> #include <vespa/memfilepersistence/spi/threadmetricprovider.h> @@ -22,40 +22,25 @@ public: MemFileV1Serializer(ThreadMetricProvider&); - virtual FileVersion getFileVersion() override { return TRADITIONAL_SLOTFILE; } + FileVersion getFileVersion() override { return TRADITIONAL_SLOTFILE; } + void loadFile(MemFile& file, Environment&, Buffer& buffer, uint64_t bytesRead) override; - virtual void loadFile(MemFile& file, Environment&, - Buffer& buffer, uint64_t bytesRead) override; - - void cacheLocationsForPart(SimpleMemFileIOBuffer& cache, - DocumentPart part, - uint32_t blockIndex, + void cacheLocationsForPart(SimpleMemFileIOBuffer& cache, DocumentPart part, uint32_t blockIndex, const std::vector<DataLocation>& locationsToCache, const std::vector<DataLocation>& locationsRead, SimpleMemFileIOBuffer::BufferAllocation& buf); - virtual void cacheLocations(MemFileIOInterface& cache, - Environment& env, - const Options& options, - DocumentPart part, - const std::vector<DataLocation>& locations) override; - - virtual FlushResult flushUpdatesToFile(MemFile&, Environment&) override; - - virtual void rewriteFile(MemFile&, Environment&) override; + void cacheLocations(MemFileIOInterface& cache, Environment& env, const Options& options, + DocumentPart part, const std::vector<DataLocation>& locations) override; - virtual bool verify(MemFile&, Environment&, - std::ostream& errorReport, bool repairErrors, - uint16_t fileVerifyFlags) override; - - uint64_t read(vespalib::LazyFile& file, - char* buf, - const std::vector<DataLocation>& readOps); + FlushResult flushUpdatesToFile(MemFile&, Environment&) override; + void rewriteFile(MemFile&, Environment&) override; + bool verify(MemFile&, Environment&, std::ostream& errorReport, + bool repairErrors, uint16_t fileVerifyFlags) override; + uint64_t read(vespalib::LazyFile& file, char* buf, const std::vector<DataLocation>& readOps); void ensureFormatSpecificDataSet(const MemFile& file); - - uint32_t writeMetaData(BufferedFileWriter& writer, - const MemFile& file); + uint32_t writeMetaData(BufferedFileWriter& writer, const MemFile& file); uint32_t writeAndUpdateLocations( MemFile& file, @@ -68,4 +53,3 @@ public: } // memfile } // storage - diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h index 6ed529e6c80..74875d3ee79 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h @@ -199,8 +199,7 @@ public: class PartNotCachedException : public vespalib::Exception { public: - PartNotCachedException(const std::string& msg, - const std::string& location) + PartNotCachedException(const std::string& msg, const std::string& location) : vespalib::Exception(msg, location) {}; }; @@ -211,64 +210,39 @@ public: const FileSpecification& fileSpec, const Environment& env); - virtual Document::UP getDocumentHeader( - const document::DocumentTypeRepo& repo, - DataLocation loc) const override; - - virtual document::DocumentId getDocumentId(DataLocation loc) const override; - - virtual void readBody( - const document::DocumentTypeRepo& repo, - DataLocation loc, - Document& doc) const override; - - virtual DataLocation addDocumentIdOnlyHeader( - const DocumentId& id, - const document::DocumentTypeRepo& repo) override; - - virtual DataLocation addHeader(const Document& doc) override; - - virtual DataLocation addBody(const Document& doc) override; - - virtual void clear(DocumentPart type) override; - - virtual bool verifyConsistent() const override; + Document::UP getDocumentHeader(const document::DocumentTypeRepo& repo, DataLocation loc) const override; + document::DocumentId getDocumentId(DataLocation loc) const override; + void readBody(const document::DocumentTypeRepo& repo, DataLocation loc, Document& doc) const override; + DataLocation addDocumentIdOnlyHeader(const DocumentId& id, const document::DocumentTypeRepo& repo) override; + DataLocation addHeader(const Document& doc) override; + DataLocation addBody(const Document& doc) override; + void clear(DocumentPart type) override; + bool verifyConsistent() const override; /** * Moves the underlying file to another location. */ - virtual void move(const FileSpecification& target) override; - - virtual void close() override; - - virtual DataLocation copyCache(const MemFileIOInterface& source, - DocumentPart part, - DataLocation loc) override; + void move(const FileSpecification& target) override; + void close() override; + DataLocation copyCache(const MemFileIOInterface& source, DocumentPart part, DataLocation loc) override; /** * Add a location -> buffer mapping */ - void cacheLocation(DocumentPart part, - DataLocation loc, - BufferType::SP buf, - uint32_t bufferPos); + void cacheLocation(DocumentPart part, DataLocation loc, BufferType::SP buf, uint32_t bufferPos); /** * @return Returns true if the given location is cached. */ - virtual bool isCached(DataLocation loc, DocumentPart type) const override; + bool isCached(DataLocation loc, DocumentPart type) const override; /** * @return Returns true if the given location has been persisted to disk. */ - virtual bool isPersisted(DataLocation loc, DocumentPart type) const override; - virtual uint32_t getSerializedSize(DocumentPart part, - DataLocation loc) const override; - - virtual void ensureCached(Environment& env, - DocumentPart part, - const std::vector<DataLocation>& locations) override; + bool isPersisted(DataLocation loc, DocumentPart type) const override; + uint32_t getSerializedSize(DocumentPart part, DataLocation loc) const override; + void ensureCached(Environment& env, DocumentPart part, const std::vector<DataLocation>& locations) override; /** * Moves the given location into the persisted data area. @@ -342,14 +316,9 @@ private: // the reasoning about a given bucket in the face of such actions. std::shared_ptr<const Options> _options; - DataLocation addLocation(DocumentPart part, - BufferAllocation newData); - + DataLocation addLocation(DocumentPart part, BufferAllocation newData); const Data& getData(DocumentPart part, DataLocation loc) const; - - BufferAllocation serializeDocumentIdOnlyHeader( - const DocumentId& id, - const document::DocumentTypeRepo&); + BufferAllocation serializeDocumentIdOnlyHeader(const DocumentId& id, const document::DocumentTypeRepo&); BufferAllocation serializeHeader(const Document& doc); BufferAllocation serializeBody(const Document& doc); @@ -358,5 +327,3 @@ private: } } - - diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h index b3ac15ed376..f22035faf04 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h @@ -27,12 +27,12 @@ #pragma once +#include "memslot.h" +#include "slotiterator.h" +#include "memfileiointerface.h" #include <vespa/memfilepersistence/common/filespecification.h> #include <vespa/memfilepersistence/common/types.h> -#include <vespa/memfilepersistence/memfile/memslot.h> -#include <vespa/memfilepersistence/memfile/slotiterator.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/memfilepersistence/memfile/memfileiointerface.h> namespace storage { namespace memfile { diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp index 8ea60d57f80..e8fff0facd0 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp @@ -1,19 +1,16 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> +#include "memfilecache.h" #include <vespa/memfilepersistence/common/environment.h> #include <vespa/memfilepersistence/mapper/memfilemapper.h> -#include <vespa/memfilepersistence/memfile/memfilecache.h> -#include <vespa/log/log.h> -#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h> +#include <vespa/log/log.h> LOG_SETUP(".persistence.memfile.cache"); namespace storage { namespace memfile { - void MemFileCache::Entry::setInUse(bool inUse) { LOG(debug, "Setting in use to %d for file %s", inUse, _file.toString().c_str()); @@ -111,7 +108,7 @@ struct MemFileCache::CacheEntryGuard : public MemFilePtr::EntryGuard { _entry(&entry) { } - virtual ~CacheEntryGuard() { + ~CacheEntryGuard() { if (_entry) { _cache.done(*_entry); } @@ -121,20 +118,20 @@ struct MemFileCache::CacheEntryGuard : public MemFilePtr::EntryGuard { return _entry->_file; } - virtual void deleteFile() override { + void deleteFile() override { LOG(debug, "Cache entry guard deleting %s", _file->toString().c_str()); _env._memFileMapper.deleteFile(*_file, _env); erase(); } - virtual void erase() override { + void erase() override { LOG(debug, "Cache entry guard erasing %s from cache", _file->toString().c_str()); _cache.erase(document::BucketId(_entry->_file.getFile().getBucketId())); _entry = 0; } - virtual void move(EntryGuard& target) override { + void move(EntryGuard& target) override { LOG(debug, "Cache entry guard moving %s", _file->toString().c_str()); _cache.move(*this, static_cast<CacheEntryGuard&>(target)); } @@ -175,10 +172,7 @@ MemFileCache::setCacheSize(MemoryUsage cacheSize) vespalib::LockGuard lock(_cacheLock); _cacheLimit = cacheSize; - - _memoryToken->resize(std::min(_memoryToken->getSize(), _cacheLimit.sum()), - _cacheLimit.sum()); - + _memoryToken->resize(std::min(_memoryToken->getSize(), _cacheLimit.sum()), _cacheLimit.sum()); evictWhileFull(); } diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h index b1d68591b92..91106cd765b 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h @@ -65,8 +65,8 @@ public: Timestamp fromTimestamp, Timestamp toTimestamp); - virtual void iterate() const override; - virtual SlotIterator* clone() const override; + void iterate() const override; + SlotIterator* clone() const override; }; class AllSlotsIterator : public SlotIterator { @@ -82,8 +82,8 @@ public: Timestamp fromTimestamp, Timestamp toTimestamp); - virtual void iterate() const override; - virtual SlotIterator* clone() const override; + void iterate() const override; + SlotIterator* clone() const override; }; /** @@ -127,4 +127,3 @@ public: } // memfile } // storage - diff --git a/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp b/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp index 247722588f5..9e75e4fa182 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/memfilepersistence/spi/splitoperationhandler.h> -#include <vespa/memfilepersistence/spi/cacheevictionguard.h> -#include <vespa/log/log.h> +#include "splitoperationhandler.h" +#include "cacheevictionguard.h" + +#include <vespa/log/log.h> LOG_SETUP(".persistence.memfile.handler.split"); namespace storage { @@ -25,7 +25,7 @@ struct BucketMatcher : public SlotMatcher { _factory(factory), _bid(bid) {} - virtual bool match(const Slot& slot) override { + bool match(const Slot& slot) override { document::DocumentId id(slot.getDocumentId()); document::BucketId bucket = _factory.getBucketId(id); bucket.setUsedBits(_bid.getUsedBits()); @@ -69,7 +69,7 @@ SplitOperationHandler::splitIntoFile(MemFile& source, MemFileCacheEvictionGuard targetFile(getMemFile(target, false)); LOG(debug, - "Found %" PRIu64 " slots to move from file %s to file %s", + "Found %zu slots to move from file %s to file %s", ts.size(), source.getFile().toString().c_str(), targetFile->getFile().toString().c_str()); diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp index c794d611767..072b3e9fae0 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include "dumpslotfile.h" #include <vespa/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> @@ -9,7 +9,6 @@ #include <vespa/memfilepersistence/mapper/memfilemapper.h> #include <vespa/memfilepersistence/memfile/memfilecache.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h> -#include <vespa/memfilepersistence/tools/dumpslotfile.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> #include <vespa/storageframework/defaultimplementation/memory/nomemorymanager.h> diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp index f8d13714ae9..544be9c5eac 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> +#include "dumpslotfile.h" #include <vespa/config/subscription/configuri.h> -#include <vespa/memfilepersistence/tools/dumpslotfile.h> +#include <vespa/fastos/app.h> #include <iostream> namespace { diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp index 7127c75cb1b..34855aeabc1 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp @@ -1,13 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> +#include "vdsdisktool.h" #include <vespa/defaults.h> -#include <vespa/log/log.h> -#include <vespa/memfilepersistence/tools/vdsdisktool.h> +#include <vespa/fastos/app.h> #include <iostream> -LOG_SETUP(".vdsdisktool"); - namespace { struct DiskApp : public FastOS_Application { int Main() override { diff --git a/staging_vespalib/src/vespa/vespalib/util/programoptions.h b/staging_vespalib/src/vespa/vespalib/util/programoptions.h index 58d1d133d04..9e25f960af7 100644 --- a/staging_vespalib/src/vespa/vespalib/util/programoptions.h +++ b/staging_vespalib/src/vespa/vespalib/util/programoptions.h @@ -23,12 +23,10 @@ #pragma once +#include <vespa/vespalib/util/exception.h> #include <map> #include <set> -#include <string> #include <vector> -#include <stdint.h> -#include <vespa/vespalib/util/exception.h> namespace vespalib { @@ -237,9 +235,9 @@ struct ProgramOptions::OptionParser { struct ProgramOptions::OptionHeader : public OptionParser { OptionHeader(const std::string& desc) : OptionParser("", 0, desc) {} - virtual void set(const std::vector<std::string>&) override {} - virtual void setDefault() override {} - virtual bool isHeader() const override { return true; } + void set(const std::vector<std::string>&) override {} + void setDefault() override {} + bool isHeader() const override { return true; } }; template<typename Number> @@ -262,61 +260,45 @@ struct ProgramOptions::NumberOptionParser : public OptionParser { : OptionParser(nameList, 1, getStringValue(defValue), desc), _number(number), _defaultValue(defValue) - { - } - - virtual void set(const std::vector<std::string>& arguments) override; - - virtual void setDefault() override { _number = _defaultValue; } - - virtual std::string getArgType(uint32_t /* index */) const override - { return getTypeName<Number>(); } + {} + void set(const std::vector<std::string>& arguments) override; + void setDefault() override { _number = _defaultValue; } + std::string getArgType(uint32_t /* index */) const override { + return getTypeName<Number>(); + } }; struct ProgramOptions::BoolOptionParser : public OptionParser { bool& _value; bool _defaultValue; - BoolOptionParser(const std::string& nameList, bool& value, - const std::string& description); - - virtual void set(const std::vector<std::string>&) override { _value = true; } - - virtual void setDefault() override { _value = false; } + BoolOptionParser(const std::string& nameList, bool& value, const std::string& description); + void set(const std::vector<std::string>&) override { _value = true; } + void setDefault() override { _value = false; } }; struct ProgramOptions::FlagOptionParser : public OptionParser { bool& _value; bool _unsetValue; - FlagOptionParser(const std::string& nameList, bool& value, - const std::string& description); - FlagOptionParser(const std::string& nameList, bool& value, - const bool& unsetValue, const std::string& description); - - virtual void set(const std::vector<std::string>&) override { _value = !_unsetValue; } - - virtual void setDefault() override { _value = _unsetValue; } + FlagOptionParser(const std::string& nameList, bool& value, const std::string& description); + FlagOptionParser(const std::string& nameList, bool& value, const bool& unsetValue, const std::string& description); + void set(const std::vector<std::string>&) override { _value = !_unsetValue; } + void setDefault() override { _value = _unsetValue; } }; struct ProgramOptions::StringOptionParser : public OptionParser { std::string& _value; std::string _defaultValue; - StringOptionParser(const std::string& nameList, std::string& value, - const std::string& description); - + StringOptionParser(const std::string& nameList, std::string& value, const std::string& description); StringOptionParser(const std::string& nameList, std::string& value, const std::string& defVal, const std::string& desc); - virtual void set(const std::vector<std::string>& arguments) override - { _value = arguments[0]; } - - virtual void setDefault() override { _value = _defaultValue; } - - virtual std::string getArgType(uint32_t /* index */) const override - { return "string"; } + void set(const std::vector<std::string>& arguments) override { _value = arguments[0]; } + void setDefault() override { _value = _defaultValue; } + std::string getArgType(uint32_t /* index */) const override { return "string"; } }; struct ProgramOptions::MapOptionParser : public OptionParser { @@ -327,14 +309,14 @@ struct ProgramOptions::MapOptionParser : public OptionParser { std::map<std::string, std::string>& value, const std::string& description); - virtual void set(const std::vector<std::string>& arguments) override - { _value[arguments[0]] = arguments[1]; } + void set(const std::vector<std::string>& arguments) override { + _value[arguments[0]] = arguments[1]; + } - virtual std::string getArgType(uint32_t /* index */) const override - { return "string"; } + std::string getArgType(uint32_t /* index */) const override { return "string"; } - // Default of map is just an empty map. - virtual void setDefault() override { _value.clear(); } + // Default of map is just an empty map. + void setDefault() override { _value.clear(); } }; template<typename T> @@ -356,9 +338,8 @@ struct ProgramOptions::ListOptionParser : public OptionParser { void setEntryParser(OptionParser::UP entryParser) { _entryParser = std::move(entryParser); } - - virtual bool isRequired() const override { return false; } - virtual void set(const std::vector<std::string>& arguments) override { + bool isRequired() const override { return false; } + void set(const std::vector<std::string>& arguments) override { for (uint32_t i=0; i<arguments.size(); ++i) { std::vector<std::string> v; v.push_back(arguments[i]); @@ -366,10 +347,10 @@ struct ProgramOptions::ListOptionParser : public OptionParser { _value.push_back(_singleValue); } } - virtual void setDefault() override { + void setDefault() override { _value.clear(); } - virtual std::string getArgType(uint32_t index) const override { + std::string getArgType(uint32_t index) const override { return _entryParser->getArgType(index) + "[]"; } }; diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h index af2f1bc225a..1ea1a9e5e61 100644 --- a/vespalib/src/vespa/vespalib/util/exception.h +++ b/vespalib/src/vespa/vespalib/util/exception.h @@ -6,7 +6,6 @@ #include <vespa/vespalib/util/macro.h> #include <vespa/vespalib/util/error.h> #include <vespa/vespalib/util/stringfmt.h> -#include <string> #include <exception> #define VESPALIB_EXCEPTION_USEBACKTRACES |