@@ -29,7 +29,8 @@ const size_t kFadviseTrigger = 1024 * 1024; // 1MB
2929struct SstFileWriter ::Rep {
3030 Rep (const EnvOptions& _env_options, const Options& options,
3131 Env::IOPriority _io_priority, const Comparator* _user_comparator,
32- ColumnFamilyHandle* _cfh, bool _invalidate_page_cache, bool _skip_filters)
32+ ColumnFamilyHandle* _cfh, bool _invalidate_page_cache, bool _skip_filters,
33+ bool _unsafe_add)
3334 : env_options(_env_options),
3435 ioptions (options),
3536 mutable_cf_options(options),
@@ -38,7 +39,8 @@ struct SstFileWriter::Rep {
3839 cfh(_cfh),
3940 invalidate_page_cache(_invalidate_page_cache),
4041 last_fadvise_size(0 ),
41- skip_filters(_skip_filters) {}
42+ skip_filters(_skip_filters),
43+ unsafe_add(_unsafe_add) {}
4244
4345 std::unique_ptr<WritableFileWriter> file_writer;
4446 std::unique_ptr<TableBuilder> builder;
@@ -58,6 +60,7 @@ struct SstFileWriter::Rep {
5860 // cached pages from page cache.
5961 uint64_t last_fadvise_size;
6062 bool skip_filters;
63+ bool unsafe_add;
6164 Status Add (const Slice& user_key, const Slice& value,
6265 const ValueType value_type) {
6366 if (!builder) {
@@ -66,7 +69,7 @@ struct SstFileWriter::Rep {
6669
6770 if (file_info.num_entries == 0 ) {
6871 file_info.smallest_key .assign (user_key.data (), user_key.size ());
69- } else {
72+ } else if (!unsafe_add) {
7073 if (internal_comparator.user_comparator ()->Compare (
7174 user_key, file_info.largest_key ) <= 0 ) {
7275 // Make sure that keys are added in order
@@ -165,9 +168,11 @@ SstFileWriter::SstFileWriter(const EnvOptions& env_options,
165168 const Comparator* user_comparator,
166169 ColumnFamilyHandle* column_family,
167170 bool invalidate_page_cache,
168- Env::IOPriority io_priority, bool skip_filters)
171+ Env::IOPriority io_priority, bool skip_filters,
172+ bool unsafe_add)
169173 : rep_(new Rep(env_options, options, io_priority, user_comparator,
170- column_family, invalidate_page_cache, skip_filters)) {
174+ column_family, invalidate_page_cache, skip_filters,
175+ unsafe_add)) {
171176 rep_->file_info .file_size = 0 ;
172177}
173178
0 commit comments