Unalian commented on code in PR #32418: URL: https://github.com/apache/doris/pull/32418#discussion_r1767957959
########## be/src/olap/rowset/segment_v2/inverted_index_writer.cpp: ########## @@ -546,72 +511,85 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter { faststring buf; buf.resize(size); _null_bitmap.write(reinterpret_cast<char*>(buf.data()), false); - null_bitmap_out->writeBytes(reinterpret_cast<uint8_t*>(buf.data()), size); + null_bitmap_out->writeBytes(buf.data(), size); null_bitmap_out->close(); } } Status finish() override { - std::unique_ptr<lucene::store::IndexOutput> null_bitmap_out = nullptr; - std::unique_ptr<lucene::store::IndexOutput> data_out = nullptr; - std::unique_ptr<lucene::store::IndexOutput> index_out = nullptr; - std::unique_ptr<lucene::store::IndexOutput> meta_out = nullptr; - try { - // write bkd file - if constexpr (field_is_numeric_type(field_type)) { - _bkd_writer->max_doc_ = _rid; - _bkd_writer->docs_seen_ = _row_ids_seen_for_bkd; - null_bitmap_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( - InvertedIndexDescriptor::get_temporary_null_bitmap_file_name().c_str())); - data_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( - InvertedIndexDescriptor::get_temporary_bkd_index_data_file_name().c_str())); - meta_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( - InvertedIndexDescriptor::get_temporary_bkd_index_meta_file_name().c_str())); - index_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( - InvertedIndexDescriptor::get_temporary_bkd_index_file_name().c_str())); - write_null_bitmap(null_bitmap_out.get()); - - DBUG_EXECUTE_IF("InvertedIndexWriter._set_bkd_data_out_nullptr", - { data_out = nullptr; }); - if (data_out != nullptr && meta_out != nullptr && index_out != nullptr) { - _bkd_writer->meta_finish(meta_out.get(), - _bkd_writer->finish(data_out.get(), index_out.get()), - int(field_type)); - } else { - LOG(WARNING) << "Inverted index writer create output error occurred: nullptr"; - _CLTHROWA(CL_ERR_IO, "Create output error with nullptr"); + if (_dir != nullptr) { + std::unique_ptr<lucene::store::IndexOutput> null_bitmap_out = nullptr; + std::unique_ptr<lucene::store::IndexOutput> data_out = nullptr; + std::unique_ptr<lucene::store::IndexOutput> index_out = nullptr; + std::unique_ptr<lucene::store::IndexOutput> meta_out = nullptr; + try { + // write bkd file + if constexpr (field_is_numeric_type(field_type)) { + _bkd_writer->max_doc_ = _rid; + _bkd_writer->docs_seen_ = _row_ids_seen_for_bkd; + null_bitmap_out = + std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( + InvertedIndexDescriptor::get_temporary_null_bitmap_file_name() + .c_str())); + data_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( + InvertedIndexDescriptor::get_temporary_bkd_index_data_file_name() + .c_str())); + meta_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( + InvertedIndexDescriptor::get_temporary_bkd_index_meta_file_name() + .c_str())); + index_out = std::unique_ptr<lucene::store::IndexOutput>(_dir->createOutput( + InvertedIndexDescriptor::get_temporary_bkd_index_file_name().c_str())); + write_null_bitmap(null_bitmap_out.get()); + + DBUG_EXECUTE_IF("InvertedIndexWriter._set_bkd_data_out_nullptr", + { data_out = nullptr; }); + if (data_out != nullptr && meta_out != nullptr && index_out != nullptr) { + _bkd_writer->meta_finish( + meta_out.get(), + _bkd_writer->finish(data_out.get(), index_out.get()), + int(field_type)); + } else { + LOG(WARNING) + << "Inverted index writer create output error occurred: nullptr"; + _CLTHROWA(CL_ERR_IO, "Create output error with nullptr"); + } + meta_out->close(); + data_out->close(); + index_out->close(); + _dir->close(); + } else if constexpr (field_is_slice_type(field_type)) { Review Comment: Why does it seem that no index is output when field_is_slice_type(field_type) is used? I read the code from segcompaction to this point. If no inverted index is created here during segcompaction, where is the inverted index created? Thank you for your time :0 -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org