DeleteRange unsupported in non-block-based tables

Summary:
Return an error from DeleteRange() (or Write() if the user is using the
low-level WriteBatch API) if an unsupported table type is configured.
Closes https://github.com/facebook/rocksdb/pull/1519

Differential Revision: D4185933

Pulled By: ajkr

fbshipit-source-id: abcdf84
main
Andrew Kryczka 8 years ago committed by Facebook Github Bot
parent 489d142808
commit 661e4c9267
  1. 3
      db/column_family.cc
  2. 4
      db/column_family.h
  3. 14
      db/write_batch.cc

@ -27,6 +27,7 @@
#include "db/version_set.h"
#include "db/write_controller.h"
#include "memtable/hash_skiplist_rep.h"
#include "table/block_based_table_factory.h"
#include "util/autovector.h"
#include "util/compression.h"
#include "util/options_helper.h"
@ -359,6 +360,8 @@ ColumnFamilyData::ColumnFamilyData(
initial_cf_options_(SanitizeOptions(db_options, cf_options)),
ioptions_(db_options, initial_cf_options_),
mutable_cf_options_(initial_cf_options_),
is_delete_range_supported_(strcmp(cf_options.table_factory->Name(),
BlockBasedTableFactory().Name()) == 0),
write_buffer_manager_(write_buffer_manager),
mem_(nullptr),
imm_(ioptions_.min_write_buffer_number_to_merge,

@ -220,6 +220,8 @@ class ColumnFamilyData {
// options.
ColumnFamilyOptions GetLatestCFOptions() const;
bool is_delete_range_supported() { return is_delete_range_supported_; }
#ifndef ROCKSDB_LITE
// REQUIRES: DB mutex held
Status SetOptions(
@ -354,6 +356,8 @@ class ColumnFamilyData {
const ImmutableCFOptions ioptions_;
MutableCFOptions mutable_cf_options_;
const bool is_delete_range_supported_;
std::unique_ptr<TableCache> table_cache_;
std::unique_ptr<InternalStats> internal_stats_;

@ -48,6 +48,7 @@
#include "util/coding.h"
#include "util/perf_context_imp.h"
#include "util/statistics.h"
#include "util/string_util.h"
namespace rocksdb {
@ -973,6 +974,19 @@ class MemTableInserter : public WriteBatch::Handler {
++sequence_;
return seek_status;
}
if (db_ != nullptr) {
auto cf_handle = cf_mems_->GetColumnFamilyHandle();
if (cf_handle == nullptr) {
cf_handle = db_->DefaultColumnFamily();
}
auto* cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(cf_handle)->cfd();
if (!cfd->is_delete_range_supported()) {
return Status::NotSupported(
std::string("DeleteRange not supported for table type ") +
cfd->ioptions()->table_factory->Name() + " in CF " +
cfd->GetName());
}
}
return DeleteImpl(column_family_id, begin_key, end_key, kTypeRangeDeletion);
}

Loading…
Cancel
Save