summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-10-31 13:43:43 +0100
committerGitHub <noreply@github.com>2018-10-31 13:43:43 +0100
commit641a2581f5772462adc0b27c4689f5a60d95b64e (patch)
tree53efd5747e006feb01426eb09492c948da473edb
parentcfb45c39bb5c59f648c657bffdb87a3c32ecd276 (diff)
parentb382d9631315820c4786b7951f0087c68c804ad5 (diff)
Merge pull request #7504 from vespa-engine/balder/avoid-reallocation
Balder/avoid reallocation
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/compression.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/compression.h19
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/countcompression.cpp47
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/countcompression.h10
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/zcposting.h16
-rw-r--r--searchlib/src/vespa/searchlib/index/postinglistcounts.h9
6 files changed, 17 insertions, 85 deletions
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp
index 1031aab71f5..2aa21f9871d 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp
+++ b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp
@@ -449,5 +449,4 @@ template class FeatureDecodeContext<false>;
template class FeatureEncodeContext<true>;
template class FeatureEncodeContext<false>;
-
}
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.h b/searchlib/src/vespa/searchlib/bitcompression/compression.h
index 931e4165b21..482a9d8b6bb 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/compression.h
+++ b/searchlib/src/vespa/searchlib/bitcompression/compression.h
@@ -7,19 +7,13 @@
#include <vespa/vespalib/stllike/string.h>
#include <cassert>
-namespace vespalib {
+namespace vespalib { class GenericHeader; }
-class GenericHeader;
+namespace search::index { class DocIdAndFeatures; }
-}
-
-namespace search {
-
- namespace index { class DocIdAndFeatures; }
-
-namespace fef { class TermFieldMatchDataArray; }
+namespace search::fef { class TermFieldMatchDataArray; }
-namespace bitcompression {
+namespace search::bitcompression {
class Position {
public:
@@ -1733,7 +1727,4 @@ extern template class FeatureDecodeContext<false>;
extern template class FeatureEncodeContext<true>;
extern template class FeatureEncodeContext<false>;
-} // namespace bitcompression
-
-} // namespace search
-
+}
diff --git a/searchlib/src/vespa/searchlib/bitcompression/countcompression.cpp b/searchlib/src/vespa/searchlib/bitcompression/countcompression.cpp
index 49d5ae92ec8..b0da806286e 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/countcompression.cpp
+++ b/searchlib/src/vespa/searchlib/bitcompression/countcompression.cpp
@@ -4,14 +4,11 @@
#include "countcompression.h"
#include <vespa/searchlib/index/postinglistcounts.h>
-namespace search {
-
-namespace bitcompression {
+namespace search::bitcompression {
#define K_VALUE_COUNTFILE_LASTDOCID 22
#define K_VALUE_COUNTFILE_NUMCHUNKS 1
#define K_VALUE_COUNTFILE_CHUNKNUMDOCS 18
-#define K_VALUE_COUNTFILE_WORDNUMDELTA 0
#define K_VALUE_COUNTFILE_SPNUMDOCS 0
@@ -61,6 +58,7 @@ readCounts(PostingListCounts &counts)
}
if (numChunks != 0) {
uint32_t prevLastDoc = 0u;
+ counts._segments.reserve(numChunks);
for (uint32_t chunk = 0; chunk < numChunks; ++chunk) {
if (__builtin_expect(oCompr >= valE, false)) {
UC64_DECODECONTEXT_STORE(o, _);
@@ -91,27 +89,6 @@ readCounts(PostingListCounts &counts)
_readContext->readComprBuffer();
}
-
-void
-PostingListCountFileDecodeContext::
-readWordNum(uint64_t &wordNum)
-{
- UC64_DECODECONTEXT_CONSTRUCTOR(o, _);
- uint32_t length;
- uint64_t val64;
- const uint64_t *valE = _valE;
-
- UC64BE_DECODEEXPGOLOMB_NS(o,
- K_VALUE_COUNTFILE_WORDNUMDELTA,
- EC);
- wordNum = _minWordNum + val64;
- UC64_DECODECONTEXT_STORE(o, _);
- if (__builtin_expect(oCompr >= valE, false))
- _readContext->readComprBuffer();
- _minWordNum = wordNum + 1;
-}
-
-
void
PostingListCountFileDecodeContext::
copyParams(const PostingListCountFileDecodeContext &rhs)
@@ -166,21 +143,6 @@ writeCounts(const PostingListCounts &counts)
_writeContext->writeComprBuffer(false);
}
-
-void
-PostingListCountFileEncodeContext::
-writeWordNum(uint64_t wordNum)
-{
- assert(wordNum >= _minWordNum);
- assert(wordNum <= _numWordIds);
- encodeExpGolomb(wordNum - _minWordNum,
- K_VALUE_COUNTFILE_WORDNUMDELTA);
- if (__builtin_expect(_valI >= _valE, false))
- _writeContext->writeComprBuffer(false);
- _minWordNum = wordNum + 1;
-}
-
-
void
PostingListCountFileEncodeContext::
copyParams(const PostingListCountFileEncodeContext &rhs)
@@ -191,7 +153,4 @@ copyParams(const PostingListCountFileEncodeContext &rhs)
_numWordIds = rhs._numWordIds;
}
-
-} // namespace bitcompression
-
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/bitcompression/countcompression.h b/searchlib/src/vespa/searchlib/bitcompression/countcompression.h
index fc448ba1c30..06e01c4c6f4 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/countcompression.h
+++ b/searchlib/src/vespa/searchlib/bitcompression/countcompression.h
@@ -8,9 +8,7 @@
#define K_VALUE_COUNTFILE_POSOCCBITS 6
-namespace search {
-
-namespace bitcompression {
+namespace search::bitcompression {
class PostingListCountFileDecodeContext : public FeatureDecodeContext<true>
{
@@ -34,7 +32,6 @@ public:
}
void readCounts(PostingListCounts &counts);
- void readWordNum(uint64_t &wordNum);
static uint64_t noWordNum() {
return std::numeric_limits<uint64_t>::max();
@@ -66,7 +63,6 @@ public:
}
void writeCounts(const PostingListCounts &counts);
- void writeWordNum(uint64_t wordNum);
static uint64_t noWordNum() {
return std::numeric_limits<uint64_t>::max();
@@ -75,6 +71,4 @@ public:
void copyParams(const PostingListCountFileEncodeContext &rhs);
};
-} // namespace bitcompression
-
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposting.h b/searchlib/src/vespa/searchlib/diskindex/zcposting.h
index 9a650abdd40..8c69a051e83 100644
--- a/searchlib/src/vespa/searchlib/diskindex/zcposting.h
+++ b/searchlib/src/vespa/searchlib/diskindex/zcposting.h
@@ -7,16 +7,12 @@
#include <vespa/searchlib/bitcompression/compression.h>
#include <vespa/fastos/file.h>
-namespace search {
-
-namespace index {
-
-class PostingListCountFileSeqRead;
-class PostingListCountFileSeqWrite;
-
+namespace search::index {
+ class PostingListCountFileSeqRead;
+ class PostingListCountFileSeqWrite;
}
-namespace diskindex {
+namespace search::diskindex {
class Zc4PostingSeqRead : public index::PostingListFileSeqRead
{
@@ -230,6 +226,4 @@ public:
void flushWordNoSkip() override;
};
-} // namespace diskindex
-
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/index/postinglistcounts.h b/searchlib/src/vespa/searchlib/index/postinglistcounts.h
index d11f7286fa1..c6e51dc7d87 100644
--- a/searchlib/src/vespa/searchlib/index/postinglistcounts.h
+++ b/searchlib/src/vespa/searchlib/index/postinglistcounts.h
@@ -4,9 +4,7 @@
#include <vector>
#include <cstdint>
-namespace search {
-
-namespace index {
+namespace search::index {
/**
* Basic class for holding the result of a dictionary lookup result
@@ -103,7 +101,4 @@ public:
{ }
};
-} // namespace index
-
-} // namespace search
-
+}