@@ -59,16 +59,27 @@ Result<DorisFSDirectory*> InvertedIndexFileWriter::open(const TabletIndex* index
59
59
}
60
60
if (exists) {
61
61
LOG (ERROR) << " try to init a directory:" << lfs_index_path << " already exists" ;
62
- return ResultError (Status::InternalError (" init_fulltext_index directory already exists" ));
62
+ return ResultError (
63
+ Status::InternalError (" InvertedIndexFileWriter::open directory already exists" ));
63
64
}
64
65
65
66
bool can_use_ram_dir = true ;
66
67
bool use_compound_file_writer = false ;
67
68
auto * dir = DorisFSDirectoryFactory::getDirectory (_lfs, lfs_index_path.c_str (),
68
69
use_compound_file_writer, can_use_ram_dir,
69
70
nullptr , _fs, index_path.c_str ());
70
- _indices_dirs.emplace (std::make_pair (index_id, index_suffix),
71
- std::unique_ptr<DorisFSDirectory>(dir));
71
+ auto key = std::make_pair (index_id, index_suffix);
72
+ auto [it, inserted] = _indices_dirs.emplace (key, std::unique_ptr<DorisFSDirectory>(dir));
73
+ if (!inserted) {
74
+ LOG (ERROR) << " InvertedIndexFileWriter::open attempted to insert a duplicate key: ("
75
+ << key.first << " , " << key.second << " )" ;
76
+ LOG (ERROR) << " Directories already in map: " ;
77
+ for (const auto & entry : _indices_dirs) {
78
+ LOG (ERROR) << " Key: (" << entry.first .first << " , " << entry.first .second << " )" ;
79
+ }
80
+ return ResultError (Status::InternalError (
81
+ " InvertedIndexFileWriter::open attempted to insert a duplicate dir" ));
82
+ }
72
83
return dir;
73
84
}
74
85
0 commit comments