diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-06-05 14:23:40 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2019-06-05 14:23:40 +0200 |
commit | 2f3df2f53050c4b087dd896669b13ff53fb5f01d (patch) | |
tree | 0e244402868e7efdd99fa642575e519bf1e30711 | |
parent | a8d38e225ea6fe6028afc2270d374bb827eece95 (diff) |
Factor out PosOccFieldParams and PosOccFieldsParams from posocccompression
compilation unit.
15 files changed, 432 insertions, 358 deletions
diff --git a/searchlib/src/vespa/searchlib/bitcompression/CMakeLists.txt b/searchlib/src/vespa/searchlib/bitcompression/CMakeLists.txt index 9573573652b..bebfccc6433 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/bitcompression/CMakeLists.txt @@ -5,5 +5,7 @@ vespa_add_library(searchlib_bitcompression OBJECT countcompression.cpp pagedict4.cpp posocccompression.cpp + posocc_fields_params.cpp + posocc_field_params.cpp DEPENDS ) diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocc_field_params.cpp b/searchlib/src/vespa/searchlib/bitcompression/posocc_field_params.cpp new file mode 100644 index 00000000000..006c0b29ffb --- /dev/null +++ b/searchlib/src/vespa/searchlib/bitcompression/posocc_field_params.cpp @@ -0,0 +1,190 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "posocc_field_params.h" +#include <vespa/searchcommon/common/schema.h> +#include <vespa/searchlib/index/postinglistparams.h> +#include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/stllike/asciistream.h> + +#include <vespa/log/log.h> +LOG_SETUP(".posocc_field_params"); + +using vespalib::GenericHeader; + +namespace search::bitcompression { + +namespace schema = search::index::schema; + +PosOccFieldParams::PosOccFieldParams() + : _elemLenK(0), + _hasElements(false), + _hasElementWeights(false), + _avgElemLen(512), + _collectionType(SINGLE), + _name() +{ } + + +bool +PosOccFieldParams::operator==(const PosOccFieldParams &rhs) const +{ + return _collectionType == rhs._collectionType && + _avgElemLen == rhs._avgElemLen && + _name == rhs._name; +} + + +vespalib::string +PosOccFieldParams::getParamsPrefix(uint32_t idx) +{ + vespalib::asciistream paramsPrefix; + paramsPrefix << "fieldParams."; + paramsPrefix << idx; + return paramsPrefix.str(); +} + + +void +PosOccFieldParams::getParams(PostingListParams ¶ms, uint32_t idx) const +{ + vespalib::string paramsPrefix = getParamsPrefix(idx); + vespalib::string collStr = paramsPrefix + ".collectionType"; + vespalib::string avgElemLenStr = paramsPrefix + ".avgElemLen"; + vespalib::string nameStr = paramsPrefix + ".name"; + + switch (_collectionType) { + case SINGLE: + params.setStr(collStr, "single"); + break; + case ARRAY: + params.setStr(collStr, "array"); + break; + case WEIGHTEDSET: + params.setStr(collStr, "weightedSet"); + break; + } + params.set(avgElemLenStr, _avgElemLen); + params.setStr(nameStr, _name); +} + + +void +PosOccFieldParams::setParams(const PostingListParams ¶ms, uint32_t idx) +{ + vespalib::string paramsPrefix = getParamsPrefix(idx); + vespalib::string collStr = paramsPrefix + ".collectionType"; + vespalib::string avgElemLenStr = paramsPrefix + ".avgElemLen"; + vespalib::string nameStr = paramsPrefix + ".name"; + + if (params.isSet(collStr)) { + vespalib::string collVal = params.getStr(collStr); + if (collVal == "single") { + _collectionType = SINGLE; + _hasElements = false; + _hasElementWeights = false; + } else if (collVal == "array") { + _collectionType = ARRAY; + _hasElements = true; + _hasElementWeights = false; + } else if (collVal == "weightedSet") { + _collectionType = WEIGHTEDSET; + _hasElements = true; + _hasElementWeights = true; + } + } + params.get(avgElemLenStr, _avgElemLen); + if (params.isSet(nameStr)) { + _name = params.getStr(nameStr); + } +} + + +void +PosOccFieldParams::setSchemaParams(const Schema &schema, uint32_t fieldId) +{ + assert(fieldId < schema.getNumIndexFields()); + const Schema::IndexField &field = schema.getIndexField(fieldId); + switch (field.getCollectionType()) { + case schema::CollectionType::SINGLE: + _collectionType = SINGLE; + _hasElements = false; + _hasElementWeights = false; + break; + case schema::CollectionType::ARRAY: + _collectionType = ARRAY; + _hasElements = true; + _hasElementWeights = false; + break; + case schema::CollectionType::WEIGHTEDSET: + _collectionType = WEIGHTEDSET; + _hasElements = true; + _hasElementWeights = true; + break; + default: + LOG(error, "Bad collection type"); + LOG_ABORT("should not be reached"); + } + _avgElemLen = field.getAvgElemLen(); + _name = field.getName(); +} + + +void +PosOccFieldParams::readHeader(const vespalib::GenericHeader &header, + const vespalib::string &prefix) +{ + vespalib::string nameKey(prefix + "fieldName"); + vespalib::string collKey(prefix + "collectionType"); + vespalib::string avgElemLenKey(prefix + "avgElemLen"); + _name = header.getTag(nameKey).asString(); + Schema::CollectionType ct = schema::collectionTypeFromName(header.getTag(collKey).asString()); + switch (ct) { + case schema::CollectionType::SINGLE: + _collectionType = SINGLE; + _hasElements = false; + _hasElementWeights = false; + break; + case schema::CollectionType::ARRAY: + _collectionType = ARRAY; + _hasElements = true; + _hasElementWeights = false; + break; + case schema::CollectionType::WEIGHTEDSET: + _collectionType = WEIGHTEDSET; + _hasElements = true; + _hasElementWeights = true; + break; + default: + LOG_ABORT("Bad collection type when reading field param in header"); + } + _avgElemLen = header.getTag(avgElemLenKey).asInteger(); +} + + +void +PosOccFieldParams::writeHeader(vespalib::GenericHeader &header, + const vespalib::string &prefix) const +{ + vespalib::string nameKey(prefix + "fieldName"); + vespalib::string collKey(prefix + "collectionType"); + vespalib::string avgElemLenKey(prefix + "avgElemLen"); + header.putTag(GenericHeader::Tag(nameKey, _name)); + Schema::CollectionType ct(schema::CollectionType::SINGLE); + switch (_collectionType) { + case SINGLE: + ct = schema::CollectionType::SINGLE; + break; + case ARRAY: + ct = schema::CollectionType::ARRAY; + break; + case WEIGHTEDSET: + ct = schema::CollectionType::WEIGHTEDSET; + break; + default: + LOG_ABORT("Bad collection type when writing field param in header"); + } + header.putTag(GenericHeader::Tag(collKey, schema::getTypeName(ct))); + header.putTag(GenericHeader::Tag(avgElemLenKey, _avgElemLen)); +} + +} diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocc_field_params.h b/searchlib/src/vespa/searchlib/bitcompression/posocc_field_params.h new file mode 100644 index 00000000000..c781cec4db5 --- /dev/null +++ b/searchlib/src/vespa/searchlib/bitcompression/posocc_field_params.h @@ -0,0 +1,49 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <cstdint> +#include <vespa/vespalib/stllike/string.h> + +namespace search::index { +class PostingListParams; +class Schema; +} + +namespace vespalib { class GenericHeader; } + +namespace search::bitcompression { + +class PosOccFieldParams +{ +public: + typedef index::PostingListParams PostingListParams; + typedef index::Schema Schema; + + enum CollectionType + { + SINGLE, + ARRAY, + WEIGHTEDSET + }; + + uint8_t _elemLenK; + bool _hasElements; + bool _hasElementWeights; + uint32_t _avgElemLen; + CollectionType _collectionType; + vespalib::string _name; + + PosOccFieldParams(); + + bool operator==(const PosOccFieldParams &rhs) const; + static vespalib::string getParamsPrefix(uint32_t idx); + void getParams(PostingListParams ¶ms, uint32_t idx) const; + void setParams(const PostingListParams ¶ms, uint32_t idx); + void setSchemaParams(const Schema &schema, uint32_t fieldId); + void readHeader(const vespalib::GenericHeader &header, const vespalib::string &prefix); + void writeHeader(vespalib::GenericHeader &header, const vespalib::string &prefix) const; +}; + +} + diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocc_fields_params.cpp b/searchlib/src/vespa/searchlib/bitcompression/posocc_fields_params.cpp new file mode 100644 index 00000000000..2e2674f98c6 --- /dev/null +++ b/searchlib/src/vespa/searchlib/bitcompression/posocc_fields_params.cpp @@ -0,0 +1,132 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "posocc_fields_params.h" +#include <vespa/searchlib/index/postinglistparams.h> +#include <vespa/searchlib/index/schemautil.h> +#include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/stllike/asciistream.h> + +#include <vespa/log/log.h> +LOG_SETUP(".posocc_fields_params"); + +using search::index::SchemaUtil; +using vespalib::GenericHeader; + +namespace search::bitcompression { + +PosOccFieldsParams::PosOccFieldsParams() + : _numFields(0u), + _fieldParams(nullptr), + _params() +{ +} + +PosOccFieldsParams::PosOccFieldsParams(const PosOccFieldsParams &rhs) + : _numFields(0u), + _fieldParams(nullptr), + _params(rhs._params) +{ + cacheParamsRef(); +} + +PosOccFieldsParams & +PosOccFieldsParams::operator=(const PosOccFieldsParams &rhs) +{ + assertCachedParamsRef(); + _params = rhs._params; + cacheParamsRef(); + return *this; +} + + +bool +PosOccFieldsParams::operator==(const PosOccFieldsParams &rhs) const +{ + return _params == rhs._params; +} + + +void +PosOccFieldsParams::getParams(PostingListParams ¶ms) const +{ + assertCachedParamsRef(); + assert(_numFields == 1u); // Only single field for now + params.set("numFields", _numFields); + // Single posting file index format will have multiple fields in file + for (uint32_t field = 0; field < _numFields; ++field) { + _fieldParams[field].getParams(params, field); + } +} + + +void +PosOccFieldsParams::setParams(const PostingListParams ¶ms) +{ + assertCachedParamsRef(); + uint32_t numFields = _numFields; + params.get("numFields", numFields); + assert(numFields == 1u); + _params.resize(numFields); + cacheParamsRef(); + // Single posting file index format will have multiple fields in file + for (uint32_t field = 0; field < numFields; ++field) { + _params[field].setParams(params, field); + } +} + + +void +PosOccFieldsParams::setSchemaParams(const Schema &schema, + const uint32_t indexId) +{ + assertCachedParamsRef(); + SchemaUtil::IndexIterator i(schema, indexId); + assert(i.isValid()); + _params.resize(1u); + cacheParamsRef(); + const Schema::IndexField &field = schema.getIndexField(indexId); + if (!SchemaUtil::validateIndexField(field)) { + LOG_ABORT("should not be reached"); + } + _params[0].setSchemaParams(schema, indexId); +} + + +void +PosOccFieldsParams::readHeader(const vespalib::GenericHeader &header, + const vespalib::string &prefix) +{ + vespalib::string numFieldsKey(prefix + "numFields"); + assertCachedParamsRef(); + uint32_t numFields = header.getTag(numFieldsKey).asInteger(); + assert(numFields == 1u); + _params.resize(numFields); + cacheParamsRef(); + // Single posting file index format will have multiple fields in file + for (uint32_t field = 0; field < numFields; ++field) { + vespalib::asciistream as; + as << prefix << "field[" << field << "]."; + vespalib::string subPrefix(as.str()); + _params[field].readHeader(header, subPrefix); + } +} + + +void +PosOccFieldsParams::writeHeader(vespalib::GenericHeader &header, + const vespalib::string &prefix) const +{ + vespalib::string numFieldsKey(prefix + "numFields"); + assertCachedParamsRef(); + assert(_numFields == 1u); + header.putTag(GenericHeader::Tag(numFieldsKey, _numFields)); + // Single posting file index format will have multiple fields in file + for (uint32_t field = 0; field < _numFields; ++field) { + vespalib::asciistream as; + as << prefix << "field[" << field << "]."; + vespalib::string subPrefix(as.str()); + _params[field].writeHeader(header, subPrefix); + } +} + +} diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocc_fields_params.h b/searchlib/src/vespa/searchlib/bitcompression/posocc_fields_params.h new file mode 100644 index 00000000000..f6ae886b3f0 --- /dev/null +++ b/searchlib/src/vespa/searchlib/bitcompression/posocc_fields_params.h @@ -0,0 +1,49 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "posocc_field_params.h" +#include <vector> +#include <cassert> + +namespace search::bitcompression { + +class PosOccFieldsParams +{ + // Cache pointers. + uint32_t _numFields; + const PosOccFieldParams *_fieldParams; + + // Storage + std::vector<PosOccFieldParams> _params; + +public: + typedef index::PostingListParams PostingListParams; + typedef index::Schema Schema; + + PosOccFieldsParams(); + PosOccFieldsParams(const PosOccFieldsParams &rhs); + + PosOccFieldsParams &operator=(const PosOccFieldsParams &rhs); + bool operator==(const PosOccFieldsParams &rhs) const; + + void cacheParamsRef() { + _numFields = _params.size(); + _fieldParams = _params.empty() ? nullptr : &_params[0]; + } + + void assertCachedParamsRef() const { + assert(_numFields == _params.size()); + assert(_fieldParams == (_params.empty() ? nullptr : &_params[0])); + } + + uint32_t getNumFields() const { return _numFields; } + const PosOccFieldParams *getFieldParams() const { return _fieldParams; } + void getParams(PostingListParams ¶ms) const; + void setParams(const PostingListParams ¶ms); + void setSchemaParams(const Schema &schema, const uint32_t indexId); + void readHeader(const vespalib::GenericHeader &header, const vespalib::string &prefix); + void writeHeader(vespalib::GenericHeader &header, const vespalib::string &prefix) const; +}; + +} diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp index 9f5d3cf751f..30c3ac4a7d2 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp @@ -2,6 +2,7 @@ #include "compression.h" #include "posocccompression.h" +#include "posocc_fields_params.h" #include <vespa/searchlib/index/schemautil.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> @@ -31,295 +32,6 @@ vespalib::string EG64PosOccId2 = "EG64PosOcc.2"; // Fixed k values namespace search::bitcompression { -PosOccFieldParams::PosOccFieldParams() - : _elemLenK(0), - _hasElements(false), - _hasElementWeights(false), - _avgElemLen(512), - _collectionType(SINGLE), - _name() -{ } - - -bool -PosOccFieldParams::operator==(const PosOccFieldParams &rhs) const -{ - return _collectionType == rhs._collectionType && - _avgElemLen == rhs._avgElemLen && - _name == rhs._name; -} - - -vespalib::string -PosOccFieldParams::getParamsPrefix(uint32_t idx) -{ - vespalib::asciistream paramsPrefix; - paramsPrefix << "fieldParams."; - paramsPrefix << idx; - return paramsPrefix.str(); -} - - -void -PosOccFieldParams::getParams(PostingListParams ¶ms, uint32_t idx) const -{ - vespalib::string paramsPrefix = getParamsPrefix(idx); - vespalib::string collStr = paramsPrefix + ".collectionType"; - vespalib::string avgElemLenStr = paramsPrefix + ".avgElemLen"; - vespalib::string nameStr = paramsPrefix + ".name"; - - switch (_collectionType) { - case SINGLE: - params.setStr(collStr, "single"); - break; - case ARRAY: - params.setStr(collStr, "array"); - break; - case WEIGHTEDSET: - params.setStr(collStr, "weightedSet"); - break; - } - params.set(avgElemLenStr, _avgElemLen); - params.setStr(nameStr, _name); -} - - -void -PosOccFieldParams::setParams(const PostingListParams ¶ms, uint32_t idx) -{ - vespalib::string paramsPrefix = getParamsPrefix(idx); - vespalib::string collStr = paramsPrefix + ".collectionType"; - vespalib::string avgElemLenStr = paramsPrefix + ".avgElemLen"; - vespalib::string nameStr = paramsPrefix + ".name"; - - if (params.isSet(collStr)) { - vespalib::string collVal = params.getStr(collStr); - if (collVal == "single") { - _collectionType = SINGLE; - _hasElements = false; - _hasElementWeights = false; - } else if (collVal == "array") { - _collectionType = ARRAY; - _hasElements = true; - _hasElementWeights = false; - } else if (collVal == "weightedSet") { - _collectionType = WEIGHTEDSET; - _hasElements = true; - _hasElementWeights = true; - } - } - params.get(avgElemLenStr, _avgElemLen); - if (params.isSet(nameStr)) { - _name = params.getStr(nameStr); - } -} - - -void -PosOccFieldParams::setSchemaParams(const Schema &schema, uint32_t fieldId) -{ - assert(fieldId < schema.getNumIndexFields()); - const Schema::IndexField &field = schema.getIndexField(fieldId); - switch (field.getCollectionType()) { - case schema::CollectionType::SINGLE: - _collectionType = SINGLE; - _hasElements = false; - _hasElementWeights = false; - break; - case schema::CollectionType::ARRAY: - _collectionType = ARRAY; - _hasElements = true; - _hasElementWeights = false; - break; - case schema::CollectionType::WEIGHTEDSET: - _collectionType = WEIGHTEDSET; - _hasElements = true; - _hasElementWeights = true; - break; - default: - LOG(error, "Bad collection type"); - LOG_ABORT("should not be reached"); - } - _avgElemLen = field.getAvgElemLen(); - _name = field.getName(); -} - - -void -PosOccFieldParams::readHeader(const vespalib::GenericHeader &header, - const vespalib::string &prefix) -{ - vespalib::string nameKey(prefix + "fieldName"); - vespalib::string collKey(prefix + "collectionType"); - vespalib::string avgElemLenKey(prefix + "avgElemLen"); - _name = header.getTag(nameKey).asString(); - Schema::CollectionType ct = schema::collectionTypeFromName(header.getTag(collKey).asString()); - switch (ct) { - case schema::CollectionType::SINGLE: - _collectionType = SINGLE; - _hasElements = false; - _hasElementWeights = false; - break; - case schema::CollectionType::ARRAY: - _collectionType = ARRAY; - _hasElements = true; - _hasElementWeights = false; - break; - case schema::CollectionType::WEIGHTEDSET: - _collectionType = WEIGHTEDSET; - _hasElements = true; - _hasElementWeights = true; - break; - default: - LOG_ABORT("Bad collection type when reading field param in header"); - } - _avgElemLen = header.getTag(avgElemLenKey).asInteger(); -} - - -void -PosOccFieldParams::writeHeader(vespalib::GenericHeader &header, - const vespalib::string &prefix) const -{ - vespalib::string nameKey(prefix + "fieldName"); - vespalib::string collKey(prefix + "collectionType"); - vespalib::string avgElemLenKey(prefix + "avgElemLen"); - header.putTag(GenericHeader::Tag(nameKey, _name)); - Schema::CollectionType ct(schema::CollectionType::SINGLE); - switch (_collectionType) { - case SINGLE: - ct = schema::CollectionType::SINGLE; - break; - case ARRAY: - ct = schema::CollectionType::ARRAY; - break; - case WEIGHTEDSET: - ct = schema::CollectionType::WEIGHTEDSET; - break; - default: - LOG_ABORT("Bad collection type when writing field param in header"); - } - header.putTag(GenericHeader::Tag(collKey, schema::getTypeName(ct))); - header.putTag(GenericHeader::Tag(avgElemLenKey, _avgElemLen)); -} - - -PosOccFieldsParams::PosOccFieldsParams() - : _numFields(0u), - _fieldParams(nullptr), - _params() -{ -} - -PosOccFieldsParams::PosOccFieldsParams(const PosOccFieldsParams &rhs) - : _numFields(0u), - _fieldParams(nullptr), - _params(rhs._params) -{ - cacheParamsRef(); -} - -PosOccFieldsParams & -PosOccFieldsParams::operator=(const PosOccFieldsParams &rhs) -{ - assertCachedParamsRef(); - _params = rhs._params; - cacheParamsRef(); - return *this; -} - - -bool -PosOccFieldsParams::operator==(const PosOccFieldsParams &rhs) const -{ - return _params == rhs._params; -} - - -void -PosOccFieldsParams::getParams(PostingListParams ¶ms) const -{ - assertCachedParamsRef(); - assert(_numFields == 1u); // Only single field for now - params.set("numFields", _numFields); - // Single posting file index format will have multiple fields in file - for (uint32_t field = 0; field < _numFields; ++field) { - _fieldParams[field].getParams(params, field); - } -} - - -void -PosOccFieldsParams::setParams(const PostingListParams ¶ms) -{ - assertCachedParamsRef(); - uint32_t numFields = _numFields; - params.get("numFields", numFields); - assert(numFields == 1u); - _params.resize(numFields); - cacheParamsRef(); - // Single posting file index format will have multiple fields in file - for (uint32_t field = 0; field < numFields; ++field) { - _params[field].setParams(params, field); - } -} - - -void -PosOccFieldsParams::setSchemaParams(const Schema &schema, - const uint32_t indexId) -{ - assertCachedParamsRef(); - SchemaUtil::IndexIterator i(schema, indexId); - assert(i.isValid()); - _params.resize(1u); - cacheParamsRef(); - const Schema::IndexField &field = schema.getIndexField(indexId); - if (!SchemaUtil::validateIndexField(field)) { - LOG_ABORT("should not be reached"); - } - _params[0].setSchemaParams(schema, indexId); -} - - -void -PosOccFieldsParams::readHeader(const vespalib::GenericHeader &header, - const vespalib::string &prefix) -{ - vespalib::string numFieldsKey(prefix + "numFields"); - assertCachedParamsRef(); - uint32_t numFields = header.getTag(numFieldsKey).asInteger(); - assert(numFields == 1u); - _params.resize(numFields); - cacheParamsRef(); - // Single posting file index format will have multiple fields in file - for (uint32_t field = 0; field < numFields; ++field) { - vespalib::asciistream as; - as << prefix << "field[" << field << "]."; - vespalib::string subPrefix(as.str()); - _params[field].readHeader(header, subPrefix); - } -} - - -void -PosOccFieldsParams::writeHeader(vespalib::GenericHeader &header, - const vespalib::string &prefix) const -{ - vespalib::string numFieldsKey(prefix + "numFields"); - assertCachedParamsRef(); - assert(_numFields == 1u); - header.putTag(GenericHeader::Tag(numFieldsKey, _numFields)); - // Single posting file index format will have multiple fields in file - for (uint32_t field = 0; field < _numFields; ++field) { - vespalib::asciistream as; - as << prefix << "field[" << field << "]."; - vespalib::string subPrefix(as.str()); - _params[field].writeHeader(header, subPrefix); - } -} - - template <bool bigEndian> void EG2PosOccDecodeContext<bigEndian>:: diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h index d500dacd7d4..46f5e2864c0 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h +++ b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h @@ -58,75 +58,7 @@ public: namespace search::bitcompression { -class PosOccFieldParams -{ -public: - typedef index::PostingListParams PostingListParams; - typedef index::Schema Schema; - - enum CollectionType - { - SINGLE, - ARRAY, - WEIGHTEDSET - }; - - uint8_t _elemLenK; - bool _hasElements; - bool _hasElementWeights; - uint32_t _avgElemLen; - CollectionType _collectionType; - vespalib::string _name; - - PosOccFieldParams(); - - bool operator==(const PosOccFieldParams &rhs) const; - static vespalib::string getParamsPrefix(uint32_t idx); - void getParams(PostingListParams ¶ms, uint32_t idx) const; - void setParams(const PostingListParams ¶ms, uint32_t idx); - void setSchemaParams(const Schema &schema, uint32_t fieldId); - void readHeader(const vespalib::GenericHeader &header, const vespalib::string &prefix); - void writeHeader(vespalib::GenericHeader &header, const vespalib::string &prefix) const; -}; - - -class PosOccFieldsParams -{ - // Cache pointers. - uint32_t _numFields; - const PosOccFieldParams *_fieldParams; - - // Storage - std::vector<PosOccFieldParams> _params; - -public: - typedef index::PostingListParams PostingListParams; - typedef index::Schema Schema; - - PosOccFieldsParams(); - PosOccFieldsParams(const PosOccFieldsParams &rhs); - - PosOccFieldsParams &operator=(const PosOccFieldsParams &rhs); - bool operator==(const PosOccFieldsParams &rhs) const; - - void cacheParamsRef() { - _numFields = _params.size(); - _fieldParams = _params.empty() ? nullptr : &_params[0]; - } - - void assertCachedParamsRef() const { - assert(_numFields == _params.size()); - assert(_fieldParams == (_params.empty() ? nullptr : &_params[0])); - } - - uint32_t getNumFields() const { return _numFields; } - const PosOccFieldParams *getFieldParams() const { return _fieldParams; } - void getParams(PostingListParams ¶ms) const; - void setParams(const PostingListParams ¶ms); - void setSchemaParams(const Schema &schema, const uint32_t indexId); - void readHeader(const vespalib::GenericHeader &header, const vespalib::string &prefix); - void writeHeader(vespalib::GenericHeader &header, const vespalib::string &prefix) const; -}; +class PosOccFieldsParams; template <bool bigEndian> class EG2PosOccDecodeContext : public FeatureDecodeContext<bigEndian> diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposocc.h b/searchlib/src/vespa/searchlib/diskindex/zcposocc.h index 1e0555116ce..27700399bfb 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposocc.h +++ b/searchlib/src/vespa/searchlib/diskindex/zcposocc.h @@ -4,6 +4,7 @@ #include "zcposting.h" #include <vespa/searchlib/bitcompression/posocccompression.h> +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> namespace search::diskindex { diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposocciterators.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposocciterators.cpp index 6a3ea9254d2..b71a1505eac 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposocciterators.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcposocciterators.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "zcposocciterators.h" +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> #include "zc4_posting_params.h" diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h index dcaca5d1f81..26b23161cb1 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h +++ b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h @@ -5,6 +5,7 @@ #include <vespa/searchlib/index/postinglistfile.h> #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include "zc4_posting_params.h" diff --git a/searchlib/src/vespa/searchlib/memoryindex/feature_store.h b/searchlib/src/vespa/searchlib/memoryindex/feature_store.h index 6afc3c02301..59683d30c1f 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/feature_store.h +++ b/searchlib/src/vespa/searchlib/memoryindex/feature_store.h @@ -5,6 +5,7 @@ #include <vespa/searchlib/index/docidandfeatures.h> #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> #include <vespa/vespalib/datastore/datastore.h> namespace search::memoryindex { diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp index 641398f8ae1..e40cfd1748c 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/index/docidandfeatures.h> #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataPosition; diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp index 09c8e86d979..1be2ea65796 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp @@ -3,6 +3,7 @@ #include "fakewordset.h" #include "fakeword.h" #include <vespa/fastos/time.h> +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> #include <sstream> #include <vespa/log/log.h> diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h index d404c664a34..3dcf47cf8c8 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h @@ -4,6 +4,7 @@ #include <vector> #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> namespace search { class Rand48; } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp index ac2c0203ac8..f4189d0ce66 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp @@ -2,6 +2,7 @@ #include "fakezcfilterocc.h" #include "fpfactory.h" +#include <vespa/searchlib/bitcompression/posocc_fields_params.h> #include <vespa/searchlib/diskindex/zcposocciterators.h> #include <vespa/searchlib/diskindex/zc4_posting_header.h> #include <vespa/searchlib/diskindex/zc4_posting_params.h> |