Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aios/catalog/tools/TableSchemaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ std::vector<std::string> IndexConfig::intParams = {"term_payload_flag",
"position_payload_flag",
"term_frequency_flag",
"term_frequency_bitmap",
"multi_level_skip_list",
"format_version_id"};
std::vector<std::string> IndexConfig::boolParams = {"has_primary_key_attribute"};

Expand Down
7 changes: 3 additions & 4 deletions aios/storage/indexlib/index/inverted_index/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ strict_cc_library(
'//aios/storage/indexlib/index/inverted_index/format:InMemPostingDecoder',
'//aios/storage/indexlib/index/inverted_index/format:ShortListSegmentDecoder',
'//aios/storage/indexlib/index/inverted_index/format:SkipListSegmentDecoder',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:TriValueSkipListReader'
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib'
]
)
strict_cc_library(
name='InDocStateKeeper',
deps=[
'//aios/storage/indexlib/index/inverted_index/format:InMemPositionListDecoder',
'//aios/storage/indexlib/index/inverted_index/format:TermMeta',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:PairValueSkipListReader'
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib'
]
)
strict_cc_library(
Expand All @@ -462,8 +462,7 @@ strict_cc_library(
'//aios/storage/indexlib/index/inverted_index/format:ShortListSegmentDecoder',
'//aios/storage/indexlib/index/inverted_index/format:SkipListSegmentDecoder',
'//aios/storage/indexlib/index/inverted_index/format:TermMetaLoader',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:PairValueSkipListReader',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:TriValueSkipListReader',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib',
'//aios/storage/indexlib/util:simple_heap'
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "indexlib/index/inverted_index/format/TermMetaLoader.h"
#include "indexlib/index/inverted_index/format/skiplist/PairValueSkipListReader.h"
#include "indexlib/index/inverted_index/format/skiplist/TriValueSkipListReader.h"
#include "indexlib/index/inverted_index/format/skiplist/MultiLevelSkipListReader.h"

namespace indexlib::index {
AUTIL_LOG_SETUP(indexlib.index, BufferedIndexDecoder);
Expand Down Expand Up @@ -257,12 +258,26 @@ BufferedSegmentIndexDecoder* BufferedIndexDecoder::CreateNormalSegmentDecoder(ui
compressMode, enableShortListVbyteCompress);
}

if (mCurSegPostingFormatOption.HasTfList()) {
return IE_POOL_COMPATIBLE_NEW_CLASS(_sessionPool, SkipListSegmentDecoder<TriValueSkipListReader>, _sessionPool,
&_docListReader, docListBeginPos, compressMode);
if (mCurSegPostingFormatOption.HasMultiLevelSkipList()) {
if (mCurSegPostingFormatOption.HasTfList()) {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<MultiLevelTriValueSkipListReader>,
_sessionPool, &_docListReader, docListBeginPos, compressMode);
} else {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<MultiLevelPairValueSkipListReader>,
_sessionPool, &_docListReader, docListBeginPos, compressMode);
}
} else {
return IE_POOL_COMPATIBLE_NEW_CLASS(_sessionPool, SkipListSegmentDecoder<PairValueSkipListReader>, _sessionPool,
&_docListReader, docListBeginPos, compressMode);
if (mCurSegPostingFormatOption.HasTfList()) {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<TriValueSkipListReader>, _sessionPool,
&_docListReader, docListBeginPos, compressMode);
} else {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<PairValueSkipListReader>, _sessionPool,
&_docListReader, docListBeginPos, compressMode);
}
}
}
} // namespace indexlib::index
2 changes: 2 additions & 0 deletions aios/storage/indexlib/index/inverted_index/Constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ constexpr uint8_t MAX_DICT_INLINE_AVAILABLE_SIZE = 7;
constexpr uint8_t COMPRESS_MODE_SIZE = 4;
constexpr uint32_t MAX_UNCOMPRESSED_SKIP_LIST_SIZE = 10;
constexpr uint8_t SKIP_LIST_BUFFER_SIZE = 32;
constexpr uint8_t SKIP_MULTIPLIER = 8;
constexpr uint8_t MAX_SKIP_LEVEL = 10;

static constexpr const char* TRUNCATE_ATTRIBUTE_READER_CREATOR = "truncate_attribute_reader_creator";
static constexpr const char* TRUNCATE_META_FILE_READER_CREATOR = "truncate_meta_file_reader_creator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "indexlib/index/inverted_index/format/NormalInDocState.h"
#include "indexlib/index/inverted_index/format/PositionListSegmentDecoder.h"
#include "indexlib/index/inverted_index/format/TermMeta.h"
#include "indexlib/index/inverted_index/format/skiplist/PairValueSkipListReader.h"

namespace indexlib::index {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "indexlib/index/inverted_index/format/TermMetaLoader.h"
#include "indexlib/index/inverted_index/format/skiplist/PairValueSkipListReader.h"
#include "indexlib/index/inverted_index/format/skiplist/TriValueSkipListReader.h"
#include "indexlib/index/inverted_index/format/skiplist/MultiLevelSkipListReader.h"

namespace indexlib::index {
AUTIL_LOG_SETUP(indexlib.index, RangeSegmentPostingsIterator);
Expand Down Expand Up @@ -182,12 +183,26 @@ RangeSegmentPostingsIterator::CreateNormalSegmentDecoder(file_system::ByteSliceR
compressMode, curSegPostingFormatOption.IsShortListVbyteCompress());
}

if (curSegPostingFormatOption.HasTfList()) {
return IE_POOL_COMPATIBLE_NEW_CLASS(_sessionPool, SkipListSegmentDecoder<TriValueSkipListReader>, _sessionPool,
docListReader, docListBeginPos, compressMode);
if (curSegPostingFormatOption.HasMultiLevelSkipList()) {
if (curSegPostingFormatOption.HasTfList()) {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<MultiLevelTriValueSkipListReader>,
_sessionPool, docListReader, docListBeginPos, compressMode);
} else {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<MultiLevelPairValueSkipListReader>,
_sessionPool, docListReader, docListBeginPos, compressMode);
}
} else {
return IE_POOL_COMPATIBLE_NEW_CLASS(_sessionPool, SkipListSegmentDecoder<PairValueSkipListReader>, _sessionPool,
docListReader, docListBeginPos, compressMode);
if (curSegPostingFormatOption.HasTfList()) {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<TriValueSkipListReader>, _sessionPool,
docListReader, docListBeginPos, compressMode);
} else {
return IE_POOL_COMPATIBLE_NEW_CLASS(
_sessionPool, SkipListSegmentDecoder<PairValueSkipListReader>, _sessionPool,
docListReader, docListBeginPos, compressMode);
}
}
}
} // namespace indexlib::index
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct InvertedIndexConfig::Impl {
bool isPatchCompressed = false;
bool isVirtual = false;
bool isShortListVbyteCompress = false;
bool isMultiLevelSkipList = false;
bool hasTruncate = false;
indexlib::config::PayloadConfig payloadConfig;

Expand Down Expand Up @@ -115,6 +116,7 @@ struct InvertedIndexConfig::Impl {
, isPatchCompressed(other.isPatchCompressed)
, isVirtual(other.isVirtual)
, isShortListVbyteCompress(other.isShortListVbyteCompress)
, isMultiLevelSkipList(other.isMultiLevelSkipList)
, hasTruncate(other.hasTruncate)
{
}
Expand Down Expand Up @@ -185,7 +187,9 @@ Status InvertedIndexConfig::CheckEqual(const InvertedIndexConfig& other) const
CHECK_CONFIG_EQUAL(_impl->formatVersionId, other._impl->formatVersionId, "_impl->formatVersionId not equal");
CHECK_CONFIG_EQUAL(_impl->isShortListVbyteCompress, other._impl->isShortListVbyteCompress,
"_impl->isShortListVbyteCompress not equal");

CHECK_CONFIG_EQUAL(_impl->isMultiLevelSkipList,
other._impl->isMultiLevelSkipList,
"_impl->isMultiLevelSkipList not equal");
for (size_t i = 0; i < _impl->shardingIndexConfigs.size(); i++) {
auto status = _impl->shardingIndexConfigs[i]->CheckEqual(*other._impl->shardingIndexConfigs[i]);
RETURN_IF_STATUS_ERROR(status, "sharding index config [%s] not equal",
Expand Down Expand Up @@ -340,6 +344,16 @@ void InvertedIndexConfig::SetShortListVbyteCompress(bool isShortListVbyteCompres
_impl->isShortListVbyteCompress = isShortListVbyteCompress;
}

bool InvertedIndexConfig::IsMultiLevelSkipList() const
{
return _impl->isMultiLevelSkipList;
}

void InvertedIndexConfig::SetMultiLevelSkipList(bool isMultiLevelSkipList)
{
_impl->isMultiLevelSkipList = isMultiLevelSkipList;
}

void InvertedIndexConfig::SetIsReferenceCompress(bool isReferenceCompress)
{
_impl->isReferenceCompress = isReferenceCompress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ class InvertedIndexConfig : public indexlibv2::config::IIndexConfig
bool IsShortListVbyteCompress() const;
void SetShortListVbyteCompress(bool isShortListVbyteCompress);

bool IsMultiLevelSkipList() const;
void SetMultiLevelSkipList(bool isMultiLevelSkipList);

void SetIsReferenceCompress(bool isReferenceCompress);
bool IsReferenceCompress() const;

Expand Down Expand Up @@ -272,6 +275,7 @@ class InvertedIndexConfig : public indexlibv2::config::IIndexConfig
inline static const std::string DOC_PAYLOAD_FLAG = "doc_payload_flag";
inline static const std::string POSITION_PAYLOAD_FLAG = "position_payload_flag";
inline static const std::string POSITION_LIST_FLAG = "position_list_flag";
inline static const std::string MULTI_LEVEL_SKIP_LIST = "multi_level_skip_list";
inline static const std::string TERM_FREQUENCY_FLAG = "term_frequency_flag";
inline static const std::string TERM_FREQUENCY_BITMAP = "term_frequency_bitmap";
inline static const std::string HIGH_FEQUENCY_DICTIONARY = "high_frequency_dictionary";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ void InvertedIndexConfigSerializer::Serialize(const indexlibv2::config::Inverted
std::string indexCompressMode = indexlibv2::config::InvertedIndexConfig::INDEX_COMPRESS_MODE_REFERENCE;
json->Jsonize(indexlibv2::config::InvertedIndexConfig::INDEX_COMPRESS_MODE, indexCompressMode);
}

if (indexConfig.IsMultiLevelSkipList()) {
json->Jsonize(indexlibv2::config::InvertedIndexConfig::MULTI_LEVEL_SKIP_LIST, enableValue);
}
if (indexConfig.IsHashTypedDictionary()) {
json->Jsonize(indexlibv2::config::InvertedIndexConfig::USE_HASH_DICTIONARY,
indexConfig.IsHashTypedDictionary());
Expand Down Expand Up @@ -209,6 +211,9 @@ void InvertedIndexConfigSerializer::DeserializeCommonFields(const autil::legacy:
indexlibv2::config::InvertedIndexConfig::INDEX_COMPRESS_MODE_PFOR_DELTA);
indexConfig->SetIsReferenceCompress(
(compressMode == indexlibv2::config::InvertedIndexConfig::INDEX_COMPRESS_MODE_REFERENCE) ? true : false);
int useMultiLevelSkipList = 0;
json.Jsonize(indexlibv2::config::InvertedIndexConfig::MULTI_LEVEL_SKIP_LIST, useMultiLevelSkipList, useMultiLevelSkipList);
indexConfig->SetMultiLevelSkipList(useMultiLevelSkipList == 1);
bool isHashTypedDictionary = false;
json.Jsonize(indexlibv2::config::InvertedIndexConfig::USE_HASH_DICTIONARY, isHashTypedDictionary,
isHashTypedDictionary);
Expand Down
13 changes: 4 additions & 9 deletions aios/storage/indexlib/index/inverted_index/format/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ strict_cc_library(
'//aios/storage/indexlib/index/common/field_format/section_attribute:MultiSectionMeta',
'//aios/storage/indexlib/index/common/numeric_compress:EncoderProvider',
'//aios/storage/indexlib/index/inverted_index:InDocPositionState',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:PairValueSkipListReader',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib',
'//aios/storage/indexlib/index/inverted_index/section_attribute:SectionAttributeReaderImpl',
'//aios/storage/indexlib/util:object_pool'
]
Expand Down Expand Up @@ -155,8 +155,7 @@ strict_cc_library(
':BufferedByteSlice', ':InMemPositionListDecoder',
':PositionListFormat', '//aios/autil:mem_pool_base',
'//aios/storage/indexlib/file_system:byte_slice_rw',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:BufferedSkipListWriter',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:InMemPairValueSkipListReader'
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib'
]
)
strict_cc_library(
Expand Down Expand Up @@ -224,19 +223,15 @@ strict_cc_library(
deps=[
':BufferedByteSlice', ':DocListFormat', ':InMemDocListDecoder',
':PositionBitmapWriter', '//aios/autil:mem_pool_base',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:BufferedSkipListWriter',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:InMemPairValueSkipListReader',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:InMemTriValueSkipListReader'
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib',
]
)
strict_cc_library(
name='DocListEncoderImproved',
deps=[
':BufferedByteSlice', ':DocListFormat', ':InMemDocListDecoder',
':PositionBitmapWriter', '//aios/autil:mem_pool_base',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:BufferedSkipListWriter',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:InMemPairValueSkipListReader',
'//aios/storage/indexlib/index/inverted_index/format/skiplist:InMemTriValueSkipListReader'
'//aios/storage/indexlib/index/inverted_index/format/skiplist:lib'
]
)
strict_cc_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DocListEncoder::DocListEncoder(const DocListFormatOption& docListFormatOption, u
DocListEncoder::~DocListEncoder()
{
if (_docSkipListWriter) {
_docSkipListWriter->~BufferedSkipListWriter();
_docSkipListWriter->~SkipListWriter();
_docSkipListWriter = nullptr;
}
if (_ownDocListFormat) {
Expand Down Expand Up @@ -199,16 +199,21 @@ void DocListEncoder::FlushDocListBuffer(uint8_t compressMode)

void DocListEncoder::CreateDocSkipListWriter()
{
void* buffer = _byteSlicePool->allocate(sizeof(BufferedSkipListWriter));
autil::mem_pool::RecyclePool* bufferPool =
dynamic_cast<autil::mem_pool::RecyclePool*>(_docListBuffer.GetBufferPool());
assert(bufferPool);

BufferedSkipListWriter* docSkipListWriter =
new (buffer) BufferedSkipListWriter(_byteSlicePool, bufferPool, _compressMode);
docSkipListWriter->Init(_docListFormat->GetDocListSkipListFormat());
// skip list writer should be atomic created;
_docSkipListWriter = docSkipListWriter;
if (_docListFormatOption.HasMultiLevelSkipList()) {
void *buffer = _byteSlicePool->allocate(sizeof(MultiLevelSkipListWriter));
MultiLevelSkipListWriter *docSkipListWriter =
new (buffer) MultiLevelSkipListWriter(_byteSlicePool);
_docSkipListWriter = docSkipListWriter;
} else {
void *buffer = _byteSlicePool->allocate(sizeof(BufferedSkipListWriter));
autil::mem_pool::RecyclePool *bufferPool = dynamic_cast<autil::mem_pool::RecyclePool *>(_docListBuffer.GetBufferPool());
assert(bufferPool);
BufferedSkipListWriter *docSkipListWriter =
new (buffer) BufferedSkipListWriter(_byteSlicePool, bufferPool, _compressMode);
docSkipListWriter->Init(_docListFormat->GetDocListSkipListFormat());
_docSkipListWriter = docSkipListWriter;
}
}

void DocListEncoder::AddSkipListItem(uint32_t itemSize)
Expand All @@ -234,17 +239,37 @@ InMemDocListDecoder* DocListEncoder::GetInMemDocListDecoder(autil::mem_pool::Poo
if (_docSkipListWriter) {
const DocListSkipListFormat* skipListFormat = _docListFormat->GetDocListSkipListFormat();
assert(skipListFormat);

if (skipListFormat->HasTfList()) {
InMemTriValueSkipListReader* inMemSkipListReader =
IE_POOL_COMPATIBLE_NEW_CLASS(sessionPool, InMemTriValueSkipListReader, sessionPool);
inMemSkipListReader->Load(_docSkipListWriter);
skipListReader = inMemSkipListReader;
if (_docListFormatOption.HasMultiLevelSkipList()) {
MultiLevelSkipListWriter *skipwriter =
dynamic_cast<MultiLevelSkipListWriter *>(_docSkipListWriter);
assert(skipwriter != nullptr);
if (skipListFormat->HasTfList()) {
MultiLevelTriValueSkipListReader *inMemSkipListReader =
IE_POOL_COMPATIBLE_NEW_CLASS(sessionPool, MultiLevelTriValueSkipListReader);
skipwriter->SnapShot(inMemSkipListReader, sessionPool);
skipListReader = inMemSkipListReader;
} else {
MultiLevelPairValueSkipListReader *inMemSkipListReader =
IE_POOL_COMPATIBLE_NEW_CLASS(sessionPool, MultiLevelPairValueSkipListReader);
skipwriter->SnapShot(inMemSkipListReader, sessionPool);
skipListReader = inMemSkipListReader;
}
} else {
InMemPairValueSkipListReader* inMemSkipListReader = IE_POOL_COMPATIBLE_NEW_CLASS(
sessionPool, InMemPairValueSkipListReader, sessionPool, _compressMode == REFERENCE_COMPRESS_MODE);
inMemSkipListReader->Load(_docSkipListWriter);
skipListReader = inMemSkipListReader;
BufferedSkipListWriter *bufferedWriter =
dynamic_cast<BufferedSkipListWriter *>(_docSkipListWriter);
assert(bufferedWriter != nullptr);
if (skipListFormat->HasTfList()) {
InMemTriValueSkipListReader *inMemSkipListReader = IE_POOL_COMPATIBLE_NEW_CLASS(
sessionPool, InMemTriValueSkipListReader, sessionPool);
inMemSkipListReader->Load(bufferedWriter);
skipListReader = inMemSkipListReader;
} else {
InMemPairValueSkipListReader *inMemSkipListReader = IE_POOL_COMPATIBLE_NEW_CLASS(
sessionPool, InMemPairValueSkipListReader, sessionPool,
_compressMode == REFERENCE_COMPRESS_MODE);
inMemSkipListReader->Load(bufferedWriter);
skipListReader = inMemSkipListReader;
}
}
}
BufferedByteSlice* docListBuffer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "indexlib/index/inverted_index/format/InMemDocListDecoder.h"
#include "indexlib/index/inverted_index/format/PositionBitmapWriter.h"
#include "indexlib/index/inverted_index/format/skiplist/BufferedSkipListWriter.h"
#include "indexlib/index/inverted_index/format/skiplist/SkipListWriter.h"
#include "indexlib/index/inverted_index/format/skiplist/MultiLevelSkipListWriter.h"
#include "indexlib/util/PoolUtil.h"
#include "indexlib/util/SimplePool.h"

Expand Down Expand Up @@ -80,7 +82,7 @@ class DocListEncoder
private:
const DocListFormat* TEST_GetDocListFormat() const { return _docListFormat; }
BufferedByteSlice* TEST_GetDocListBuffer() { return &_docListBuffer; }
void TEST_SetDocSkipListWriter(BufferedSkipListWriter* skipListBuffer) { _docSkipListWriter = skipListBuffer; }
void TEST_SetDocSkipListWriter(SkipListWriter* skipListBuffer) { _docSkipListWriter = skipListBuffer; }

void TEST_SetPositionBitmapWriter(PositionBitmapWriter* tfBitmapWriter)
{
Expand All @@ -104,7 +106,7 @@ class DocListEncoder
index::CompressMode _compressMode; // 1byte
// volatile for realtime
PositionBitmapWriter* _tfBitmapWriter; // 8byte
BufferedSkipListWriter* volatile _docSkipListWriter;
SkipListWriter* volatile _docSkipListWriter;
DocListFormat* _docListFormat;
autil::mem_pool::Pool* _byteSlicePool;

Expand Down
Loading