summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirstorli@yahoo.no>2018-09-20 10:30:19 +0200
committerGitHub <noreply@github.com>2018-09-20 10:30:19 +0200
commitd94350c19c8e75c79405c967c427df9e832e0b6f (patch)
tree1ef466d8942fb20cc5f4927033b199fec9073289
parent5ecf27f2099432ed15eeb4c5dbc0d2f3708bf0e1 (diff)
parenta54f79a4dff7581a5e0671d8e89dc4da9d23f95b (diff)
Merge pull request #7021 from vespa-engine/balder/random-code-maintainance-while-reading-code
Nested namespaces and style changes.
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp15
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/featurestore.h98
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/iordereddocumentinserter.h7
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h21
5 files changed, 33 insertions, 109 deletions
diff --git a/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp b/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
index 583fadae7a6..be8c71de7a9 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
@@ -11,8 +11,7 @@ constexpr size_t MIN_CLUSTERS = 1024u;
using index::SchemaUtil;
uint64_t
-FeatureStore::writeFeatures(uint32_t packedIndex,
- const DocIdAndFeatures &features)
+FeatureStore::writeFeatures(uint32_t packedIndex, const DocIdAndFeatures &features)
{
_f._fieldsParams = &_fieldsParams[packedIndex];
uint64_t oldOffset = _f.getWriteOffset();
@@ -90,8 +89,7 @@ FeatureStore::FeatureStore(const Schema &schema)
_fieldsParams.resize(_schema.getNumIndexFields());
SchemaUtil::IndexIterator it(_schema);
for(; it.isValid(); ++it) {
- _fieldsParams[it.getIndex()].
- setSchemaParams(_schema, it.getIndex());
+ _fieldsParams[it.getIndex()].setSchemaParams(_schema, it.getIndex());
}
_store.addType(&_type);
_store.initActiveBuffers();
@@ -105,8 +103,7 @@ FeatureStore::~FeatureStore()
std::pair<datastore::EntryRef, uint64_t>
-FeatureStore::addFeatures(uint32_t packedIndex,
- const DocIdAndFeatures &features)
+FeatureStore::addFeatures(uint32_t packedIndex, const DocIdAndFeatures &features)
{
uint64_t oldOffset = writeFeatures(packedIndex, features);
uint64_t newOffset = _f.getWriteOffset();
@@ -117,8 +114,7 @@ FeatureStore::addFeatures(uint32_t packedIndex,
void
-FeatureStore::getFeatures(uint32_t packedIndex, datastore::EntryRef ref,
- DocIdAndFeatures &features)
+FeatureStore::getFeatures(uint32_t packedIndex, datastore::EntryRef ref, DocIdAndFeatures &features)
{
setupForField(packedIndex, _d);
setupForReadFeatures(ref, _d);
@@ -141,8 +137,7 @@ FeatureStore::bitSize(uint32_t packedIndex, datastore::EntryRef ref)
datastore::EntryRef
-FeatureStore::moveFeatures(uint32_t packedIndex,
- datastore::EntryRef ref)
+FeatureStore::moveFeatures(uint32_t packedIndex, datastore::EntryRef ref)
{
uint64_t bitLen = bitSize(packedIndex, ref);
return moveFeatures(ref, bitLen);
diff --git a/searchlib/src/vespa/searchlib/memoryindex/featurestore.h b/searchlib/src/vespa/searchlib/memoryindex/featurestore.h
index ecf21892f78..4ffdf2bc4e7 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/featurestore.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/featurestore.h
@@ -7,9 +7,7 @@
#include <vespa/searchlib/bitcompression/compression.h>
#include <vespa/searchlib/bitcompression/posocccompression.h>
-namespace search {
-
-namespace memoryindex {
+namespace search::memoryindex {
class FeatureStore
{
@@ -54,8 +52,7 @@ private:
* @param features the features to be encoded
* @return the encode offset before writing
*/
- uint64_t
- writeFeatures(uint32_t packedIndex, const DocIdAndFeatures &features);
+ uint64_t writeFeatures(uint32_t packedIndex, const DocIdAndFeatures &features);
/**
* Adds the features from the given buffer to the data store.
@@ -64,8 +61,7 @@ private:
* @param byteLen the byte length of the buffer
* @return the entry ref for the added features
*/
- datastore::EntryRef
- addFeatures(const uint8_t * src, uint64_t byteLen);
+ datastore::EntryRef addFeatures(const uint8_t * src, uint64_t byteLen);
/**
* Adds the features currently in the underlying encode context to the data store.
@@ -74,8 +70,7 @@ private:
* @param endOffset the end offset into the encode context
* @return the entry ref and bit length of the features
*/
- std::pair<datastore::EntryRef, uint64_t>
- addFeatures(uint64_t beginOffset, uint64_t endOffset);
+ std::pair<datastore::EntryRef, uint64_t> addFeatures(uint64_t beginOffset, uint64_t endOffset);
/**
* Moves features to new location, as part of compaction.
@@ -107,9 +102,7 @@ public:
* @return pair with reference to stored features and
* size of encoded features in bits
*/
- std::pair<datastore::EntryRef, uint64_t>
- addFeatures(uint32_t packedIndex,
- const DocIdAndFeatures &features);
+ std::pair<datastore::EntryRef, uint64_t> addFeatures(uint32_t packedIndex, const DocIdAndFeatures &features);
/**
@@ -120,10 +113,7 @@ public:
* @param ref Reference to stored features
* @param features The features to be decoded
*/
- void
- getFeatures(uint32_t packedIndex,
- datastore::EntryRef ref,
- DocIdAndFeatures &features);
+ void getFeatures(uint32_t packedIndex, datastore::EntryRef ref, DocIdAndFeatures &features);
/**
@@ -189,9 +179,7 @@ public:
* @param ref Referennce to stored features
* @return byte address of stored features
*/
- const uint8_t *
- getBits(datastore::EntryRef ref) const
- {
+ const uint8_t *getBits(datastore::EntryRef ref) const {
RefType iRef(ref);
return _store.getBufferEntry<uint8_t>(iRef.bufferId(), iRef.offset());
}
@@ -203,72 +191,22 @@ public:
* @param ref Old reference to stored features
* @return New reference to stored features
*/
- datastore::EntryRef
- moveFeatures(uint32_t packedIndex,
- datastore::EntryRef ref);
+ datastore::EntryRef moveFeatures(uint32_t packedIndex, datastore::EntryRef ref);
/**
* Return a const view of the fields params used by this feature store.
*
* @return const view of fields params.
*/
- const std::vector<PosOccFieldsParams> &
- getFieldsParams() const
- {
- return _fieldsParams;
- }
-
- // Inherit doc from DataStoreBase
- void
- trimHoldLists(generation_t usedGen)
- {
- _store.trimHoldLists(usedGen);
- }
-
- // Inherit doc from DataStoreBase
- void
- transferHoldLists(generation_t generation)
- {
- _store.transferHoldLists(generation);
- }
-
- void
- clearHoldLists()
- {
- _store.clearHoldLists();
- }
-
- // Inherit doc from DataStoreBase
- std::vector<uint32_t>
- startCompact()
- {
- return _store.startCompact(_typeId);
- }
-
- // Inherit doc from DataStoreBase
- void
- finishCompact(const std::vector<uint32_t> & toHold)
- {
- _store.finishCompact(toHold);
- }
-
- // Inherit doc from DataStoreBase
- MemoryUsage
- getMemoryUsage() const
- {
- return _store.getMemoryUsage();
- }
-
- // Inherit doc from DataStoreBase
- datastore::DataStoreBase::MemStats
- getMemStats() const
- {
- return _store.getMemStats();
- }
+ const std::vector<PosOccFieldsParams> &getFieldsParams() const { return _fieldsParams; }
+
+ void trimHoldLists(generation_t usedGen) { _store.trimHoldLists(usedGen); }
+ void transferHoldLists(generation_t generation) { _store.transferHoldLists(generation); }
+ void clearHoldLists() { _store.clearHoldLists();}
+ std::vector<uint32_t> startCompact() { return _store.startCompact(_typeId); }
+ void finishCompact(const std::vector<uint32_t> & toHold) { _store.finishCompact(toHold); }
+ MemoryUsage getMemoryUsage() const { return _store.getMemoryUsage(); }
+ datastore::DataStoreBase::MemStats getMemStats() const { return _store.getMemStats(); }
};
-
-} // namespace search::memoryindex
-} // namespace search
-
-
+}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/iordereddocumentinserter.h b/searchlib/src/vespa/searchlib/memoryindex/iordereddocumentinserter.h
index f36086bd49f..9edd1eb4d3b 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/iordereddocumentinserter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/iordereddocumentinserter.h
@@ -5,11 +5,9 @@
#include <vespa/vespalib/stllike/string.h>
#include <cstdint>
-namespace search {
+namespace search::index { class DocIdAndFeatures; }
-namespace index { class DocIdAndFeatures; }
-
-namespace memoryindex {
+namespace search::memoryindex {
/**
* Interface class for ordered document inserter.
@@ -49,4 +47,3 @@ public:
};
}
-}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp
index b1e365c7fd7..1f15bcf1c75 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp
@@ -94,6 +94,7 @@ OrderedDocumentInserter::setNextWord(const vespalib::stringref word)
}
if (!_dItr.valid() || cmp(key, _dItr.getKey())) {
datastore::EntryRef wordRef = _fieldIndex.addWord(_word);
+
WordKey insertKey(wordRef);
DictionaryTree &dTree(_fieldIndex.getDictionaryTree());
dTree.insert(_dItr, insertKey, datastore::EntryRef().ref());
diff --git a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h
index 941695b2707..9645c3890e2 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h
@@ -6,11 +6,7 @@
#include "memoryfieldindex.h"
#include <limits>
-namespace search
-{
-
-namespace memoryindex
-{
+namespace search::memoryindex {
class IDocumentInsertListener;
@@ -52,11 +48,10 @@ class OrderedDocumentInserter : public IOrderedDocumentInserter
public:
OrderedDocumentInserter(MemoryFieldIndex &fieldIndex);
- virtual ~OrderedDocumentInserter();
- virtual void setNextWord(const vespalib::stringref word) override;
- virtual void add(uint32_t docId,
- const index::DocIdAndFeatures &features) override;
- virtual void remove(uint32_t docId) override;
+ ~OrderedDocumentInserter() override;
+ void setNextWord(const vespalib::stringref word) override;
+ void add(uint32_t docId, const index::DocIdAndFeatures &features) override;
+ void remove(uint32_t docId) override;
/*
* Flush pending changes to postinglist for (_word). Also flush
@@ -64,17 +59,15 @@ public:
*
* _dItr is located at correct position.
*/
- virtual void flush() override;
+ void flush() override;
/*
* Rewind iterator, to start new pass.
*/
- virtual void rewind() override;
+ void rewind() override;
// Used by unit test
datastore::EntryRef getWordRef() const;
};
}
-
-}