diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-12-30 09:26:10 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-09 15:58:44 +0100 |
commit | 3aaa5053d289fec6fc5bfec6fa352a55100bfa72 (patch) | |
tree | b056577770635fea3dd3db12472c550b25e656a4 /searchlib | |
parent | e8b197ceb9652cb85f3473675725e3c3d894c98f (diff) |
Use nested namespace
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp | 27 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h | 21 |
2 files changed, 17 insertions, 31 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp index cb24bb4edf7..ba48dc7781a 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp @@ -14,9 +14,9 @@ using vespalib::tensor::DenseTensor; using vespalib::tensor::DenseTensorView; using vespalib::tensor::MutableDenseTensorView; using vespalib::eval::ValueType; +using std::make_unique; -namespace search { -namespace tensor { +namespace search::tensor { constexpr size_t MIN_BUFFER_CLUSTERS = 1024; @@ -25,12 +25,9 @@ DenseTensorStore::BufferType::BufferType() MIN_BUFFER_CLUSTERS, RefType::offsetSize() / RefType::align(1)), _unboundDimSizesSize(0u) -{ -} +{} -DenseTensorStore::BufferType::~BufferType() -{ -} +DenseTensorStore::BufferType::~BufferType() = default; void DenseTensorStore::BufferType::cleanHold(void *buffer, uint64_t offset, @@ -171,20 +168,16 @@ void makeConcreteType(MutableDenseTensorView &tensor, std::unique_ptr<Tensor> DenseTensorStore::getTensor(EntryRef ref) const { + using CellsRef = DenseTensorView::CellsRef; if (!ref.valid()) { return std::unique_ptr<Tensor>(); } auto raw = getRawBuffer(ref); size_t numCells = getNumCells(raw); if (_numUnboundDims == 0) { - return std::make_unique<DenseTensorView> - (_type, - DenseTensorView::CellsRef(static_cast<const double *>(raw), numCells)); + return make_unique<DenseTensorView>(_type, CellsRef(static_cast<const double *>(raw), numCells)); } else { - std::unique_ptr <MutableDenseTensorView> result = - std::make_unique<MutableDenseTensorView>(_type, - DenseTensorView::CellsRef(static_cast<const double *>(raw), - numCells)); + auto result = make_unique<MutableDenseTensorView>(_type, CellsRef(static_cast<const double *>(raw), numCells)); makeConcreteType(*result, raw, _numUnboundDims); return result; } @@ -208,8 +201,7 @@ DenseTensorStore::getTensor(EntryRef ref, MutableDenseTensorView &tensor) const } } -namespace -{ +namespace { void checkMatchingType(const ValueType &lhs, const ValueType &rhs, size_t numCells) @@ -277,5 +269,4 @@ DenseTensorStore::setTensor(const Tensor &tensor) abort(); } -} // namespace search::tensor -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h index cd183162443..67a2dc7b8c0 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h @@ -7,9 +7,7 @@ namespace vespalib { namespace tensor { class MutableDenseTensorView; }} -namespace search { - -namespace tensor { +namespace search::tensor { /** * Class for storing dense tensors with known bounds in memory, used @@ -39,13 +37,13 @@ public: uint32_t _unboundDimSizesSize; public: BufferType(); - virtual ~BufferType(); - virtual void cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext cleanCtx) override; + ~BufferType() override; + void cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext cleanCtx) override; uint32_t unboundDimSizesSize() const { return _unboundDimSizesSize; } void setUnboundDimSizesSize(uint32_t unboundDimSizesSize_in) { _unboundDimSizesSize = unboundDimSizesSize_in; } - virtual size_t getReservedElements(uint32_t bufferId) const override; + size_t getReservedElements(uint32_t bufferId) const override; }; private: DataStoreType _concreteStore; @@ -68,7 +66,7 @@ private: public: DenseTensorStore(const ValueType &type); - virtual ~DenseTensorStore(); + ~DenseTensorStore() override; const ValueType &type() const { return _type; } uint32_t unboundDimSizesSize() const { return _bufferType.unboundDimSizesSize(); } @@ -76,14 +74,11 @@ public: uint32_t getCellSize() const { return _cellSize; } const void *getRawBuffer(RefType ref) const; datastore::Handle<char> allocRawBuffer(size_t numCells, const std::vector<uint32_t> &unboundDimSizes); - virtual void holdTensor(EntryRef ref) override; - virtual EntryRef move(EntryRef ref) override; + void holdTensor(EntryRef ref) override; + EntryRef move(EntryRef ref) override; std::unique_ptr<Tensor> getTensor(EntryRef ref) const; void getTensor(EntryRef ref, vespalib::tensor::MutableDenseTensorView &tensor) const; EntryRef setTensor(const Tensor &tensor); }; - -} // namespace search::tensor - -} // namespace search +} |