Skip to content

Commit 422bb09

Browse files
committed
Fix table properties
Summary: Adapt table properties to column family world Test Plan: make check Reviewers: kailiu CC: leveldb Differential Revision: https://reviews.facebook.net/D16161
1 parent 76c0481 commit 422bb09

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

db/db_impl.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,9 @@ Iterator* DBImpl::TEST_NewInternalIterator(ColumnFamilyHandle* column_family) {
27502750
mutex_.Lock();
27512751
SuperVersion* super_version = cfd->GetSuperVersion()->Ref();
27522752
mutex_.Unlock();
2753-
return NewInternalIterator(ReadOptions(), cfd, super_version);
2753+
ReadOptions roptions;
2754+
roptions.prefix_seek = true;
2755+
return NewInternalIterator(roptions, cfd, super_version);
27542756
}
27552757

27562758
std::pair<Iterator*, Iterator*> DBImpl::GetTailingIteratorPair(
@@ -3604,10 +3606,14 @@ Status DBImpl::MakeRoomForWrite(ColumnFamilyData* cfd, bool force) {
36043606
return s;
36053607
}
36063608

3607-
Status DBImpl::GetPropertiesOfAllTables(TablePropertiesCollection* props) {
3609+
Status DBImpl::GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
3610+
TablePropertiesCollection* props) {
3611+
auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
3612+
auto cfd = cfh->cfd();
3613+
36083614
// Increment the ref count
36093615
mutex_.Lock();
3610-
auto version = versions_->current();
3616+
auto version = cfd->current();
36113617
version->Ref();
36123618
mutex_.Unlock();
36133619

db/db_impl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ class DBImpl : public DB {
494494
void InstallSuperVersion(ColumnFamilyData* cfd,
495495
DeletionState& deletion_state);
496496

497-
virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props)
497+
using DB::GetPropertiesOfAllTables;
498+
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
499+
TablePropertiesCollection* props)
498500
override;
499501

500502
// Function that Get and KeyMayExist call with no_io true or false

db/db_test.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -5133,7 +5133,9 @@ class ModelDB: public DB {
51335133
return s;
51345134
}
51355135

5136-
virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) {
5136+
using DB::GetPropertiesOfAllTables;
5137+
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
5138+
TablePropertiesCollection* props) {
51375139
return Status();
51385140
}
51395141

db/version_set.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,17 @@ bool Version::PrefixMayMatch(const ReadOptions& options,
244244
}
245245

246246
Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props) {
247-
auto table_cache = vset_->table_cache_;
248-
auto options = vset_->options_;
247+
auto table_cache = cfd_->table_cache();
248+
auto options = cfd_->full_options();
249249
for (int level = 0; level < num_levels_; level++) {
250250
for (const auto& file_meta : files_[level]) {
251251
auto fname = TableFileName(vset_->dbname_, file_meta->number);
252252
// 1. If the table is already present in table cache, load table
253253
// properties from there.
254254
std::shared_ptr<const TableProperties> table_properties;
255255
Status s = table_cache->GetTableProperties(
256-
vset_->storage_options_, vset_->icmp_, *file_meta, &table_properties,
257-
true /* no io */);
256+
vset_->storage_options_, cfd_->internal_comparator(), *file_meta,
257+
&table_properties, true /* no io */);
258258
if (s.ok()) {
259259
props->insert({fname, table_properties});
260260
continue;
@@ -269,8 +269,8 @@ Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props) {
269269
// 2. Table is not present in table cache, we'll read the table properties
270270
// directly from the properties block in the file.
271271
std::unique_ptr<RandomAccessFile> file;
272-
s = vset_->env_->NewRandomAccessFile(fname, &file,
273-
vset_->storage_options_);
272+
s = options->env->NewRandomAccessFile(fname, &file,
273+
vset_->storage_options_);
274274
if (!s.ok()) {
275275
return s;
276276
}

include/rocksdb/db.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,11 @@ class DB {
435435
// Returns default column family handle
436436
virtual ColumnFamilyHandle* DefaultColumnFamily() const = 0;
437437

438-
virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) = 0;
438+
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
439+
TablePropertiesCollection* props) = 0;
440+
virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) {
441+
return GetPropertiesOfAllTables(DefaultColumnFamily(), props);
442+
}
439443

440444
private:
441445
// No copying allowed

include/utilities/stackable_db.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ class StackableDB : public DB {
182182
return db_->GetDbIdentity(identity);
183183
}
184184

185-
virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) {
186-
return db_->GetPropertiesOfAllTables(props);
185+
using DB::GetPropertiesOfAllTables;
186+
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
187+
TablePropertiesCollection* props) {
188+
return db_->GetPropertiesOfAllTables(column_family, props);
187189
}
188190

189191
virtual Status GetUpdatesSince(SequenceNumber seq_number,

0 commit comments

Comments
 (0)