airborne12 commented on code in PR #70883:
URL: https://github.com/apache/doris/pull/70883#discussion_r4680730892
##########
be/src/storage/index/inverted/snii/reader/logical_index_reader.cpp:
##########
@@ -605,6 +635,37 @@ Status
LogicalIndexReader::open_norms(format::NormsPodReader* out) const {
return status;
}
+Status LogicalIndexReader::read_dense_norms(std::vector<uint8_t>* bytes,
+ format::NormsPodReader* out) const
{
+ const RegionRef& norms = section_refs().norms;
+ const auto read_len = static_cast<size_t>(norms.length);
+ RETURN_IF_ERROR(reader_->read_at(norms.offset, read_len, bytes));
+ if (bytes->size() != read_len) {
+ return Status::Error<ErrorCode::INVERTED_INDEX_FILE_CORRUPTED, false>(
+ "logical_index: short norms read");
+ }
+ return format::NormsPodReader::open(Slice(*bytes), out);
+}
+
+Status LogicalIndexReader::read_sparse_norms(std::vector<uint8_t>* dense,
+ format::NormsPodReader* out)
const {
+ const RegionRef& norms = section_refs().sparse_norms;
+ const auto read_len = static_cast<size_t>(norms.length);
+ std::vector<uint8_t> section;
+ RETURN_IF_ERROR(reader_->read_at(norms.offset, read_len, §ion));
Review Comment:
Thanks, confirmed. `read_sparse_norms` keeps the whole section in a plain
`std::vector` and decodes the null bitmap without a reservation. The SNII
`FileReader::read_at` only fills plain vectors, which are not charged to the
query's memory tracker, and the searcher cache charge covers only the expanded
`doc_count` bytes. So during the first load, the section and the null bitmap
decode are outside the query memory limit.
In this PR, writers keep writing dense norms. The sparse form is written
only behind the debug point `LogicalIndexWriter::finalize_build.sparse_norms`,
so no index written by a normal load reaches this code.
The follow-up PR that turns the sparse form on by default will charge the
section and the null bitmap decode to the current thread's memory tracker for
the duration of the load, with a unit test. It will also handle your rollout
note about a rewriter that predates field 6, before any sparse section can be
written by default.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]