mirror of
https://github.com/matrix-construct/construct
synced 2024-11-18 07:50:57 +01:00
ircd::db: Use reference to descriptor in database::column object.
This commit is contained in:
parent
5544da61b8
commit
183be76a3a
2 changed files with 31 additions and 28 deletions
|
@ -32,9 +32,9 @@ struct ircd::db::database::column final
|
||||||
,rocksdb::ColumnFamilyDescriptor
|
,rocksdb::ColumnFamilyDescriptor
|
||||||
{
|
{
|
||||||
database *d;
|
database *d;
|
||||||
|
db::descriptor *descriptor;
|
||||||
std::type_index key_type;
|
std::type_index key_type;
|
||||||
std::type_index mapped_type;
|
std::type_index mapped_type;
|
||||||
db::descriptor descriptor;
|
|
||||||
comparator cmp;
|
comparator cmp;
|
||||||
prefix_transform prefix;
|
prefix_transform prefix;
|
||||||
compaction_filter cfilter;
|
compaction_filter cfilter;
|
||||||
|
@ -51,7 +51,7 @@ struct ircd::db::database::column final
|
||||||
operator rocksdb::ColumnFamilyHandle *();
|
operator rocksdb::ColumnFamilyHandle *();
|
||||||
operator database &();
|
operator database &();
|
||||||
|
|
||||||
explicit column(database *const &d, const db::descriptor &);
|
explicit column(database &d, db::descriptor &);
|
||||||
column() = delete;
|
column() = delete;
|
||||||
column(column &&) = delete;
|
column(column &&) = delete;
|
||||||
column(const column &) = delete;
|
column(const column &) = delete;
|
||||||
|
|
55
ircd/db.cc
55
ircd/db.cc
|
@ -1377,38 +1377,40 @@ ircd::db::name(const database::column &c)
|
||||||
const ircd::db::descriptor &
|
const ircd::db::descriptor &
|
||||||
ircd::db::describe(const database::column &c)
|
ircd::db::describe(const database::column &c)
|
||||||
{
|
{
|
||||||
return c.descriptor;
|
assert(c.descriptor);
|
||||||
|
return *c.descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// database::column
|
// database::column
|
||||||
//
|
//
|
||||||
|
|
||||||
ircd::db::database::column::column(database *const &d,
|
ircd::db::database::column::column(database &d,
|
||||||
const db::descriptor &descriptor)
|
db::descriptor &descriptor)
|
||||||
:rocksdb::ColumnFamilyDescriptor
|
:rocksdb::ColumnFamilyDescriptor
|
||||||
(
|
(
|
||||||
descriptor.name, database::options{descriptor.options}
|
descriptor.name, database::options{descriptor.options}
|
||||||
)
|
)
|
||||||
,d{d}
|
,d{&d}
|
||||||
,key_type{descriptor.type.first}
|
,descriptor{&descriptor}
|
||||||
,mapped_type{descriptor.type.second}
|
,key_type{this->descriptor->type.first}
|
||||||
,descriptor{descriptor}
|
,mapped_type{this->descriptor->type.second}
|
||||||
,cmp{d, this->descriptor.cmp}
|
,cmp{this->d, this->descriptor->cmp}
|
||||||
,prefix{d, this->descriptor.prefix}
|
,prefix{this->d, this->descriptor->prefix}
|
||||||
,cfilter{this, this->descriptor.compactor}
|
,cfilter{this, this->descriptor->compactor}
|
||||||
,stats{std::make_shared<struct database::stats>(d)}
|
,stats{std::make_shared<struct database::stats>(this->d)}
|
||||||
,handle
|
,handle
|
||||||
{
|
{
|
||||||
nullptr, [this](rocksdb::ColumnFamilyHandle *const handle)
|
nullptr, [&d](rocksdb::ColumnFamilyHandle *const handle)
|
||||||
{
|
{
|
||||||
if(handle)
|
assert(d.d);
|
||||||
this->d->d->DestroyColumnFamilyHandle(handle);
|
if(handle && d.d)
|
||||||
|
d.d->DestroyColumnFamilyHandle(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// If possible, deduce comparator based on type given in descriptor
|
// If possible, deduce comparator based on type given in descriptor
|
||||||
if(!this->descriptor.cmp.less)
|
if(!this->descriptor->cmp.less)
|
||||||
{
|
{
|
||||||
if(key_type == typeid(string_view))
|
if(key_type == typeid(string_view))
|
||||||
this->cmp.user = cmp_string_view{};
|
this->cmp.user = cmp_string_view{};
|
||||||
|
@ -1466,22 +1468,22 @@ ircd::db::database::column::column(database *const &d,
|
||||||
table_opts.pin_l0_filter_and_index_blocks_in_cache = false;
|
table_opts.pin_l0_filter_and_index_blocks_in_cache = false;
|
||||||
|
|
||||||
// Setup the block size
|
// Setup the block size
|
||||||
table_opts.block_size = this->descriptor.block_size;
|
table_opts.block_size = this->descriptor->block_size;
|
||||||
table_opts.metadata_block_size = this->descriptor.meta_block_size;
|
table_opts.metadata_block_size = this->descriptor->meta_block_size;
|
||||||
table_opts.block_size_deviation = 5;
|
table_opts.block_size_deviation = 5;
|
||||||
|
|
||||||
// Setup the cache for assets.
|
// Setup the cache for assets.
|
||||||
const auto &cache_size(this->descriptor.cache_size);
|
const auto &cache_size(this->descriptor->cache_size);
|
||||||
if(cache_size != 0)
|
if(cache_size != 0)
|
||||||
table_opts.block_cache = std::make_shared<database::cache>(d, this->stats, cache_size);
|
table_opts.block_cache = std::make_shared<database::cache>(this->d, this->stats, cache_size);
|
||||||
|
|
||||||
// Setup the cache for compressed assets.
|
// Setup the cache for compressed assets.
|
||||||
const auto &cache_size_comp(this->descriptor.cache_size_comp);
|
const auto &cache_size_comp(this->descriptor->cache_size_comp);
|
||||||
if(cache_size_comp != 0)
|
if(cache_size_comp != 0)
|
||||||
table_opts.block_cache_compressed = std::make_shared<database::cache>(d, this->stats, cache_size_comp);
|
table_opts.block_cache_compressed = std::make_shared<database::cache>(this->d, this->stats, cache_size_comp);
|
||||||
|
|
||||||
// Setup the bloom filter.
|
// Setup the bloom filter.
|
||||||
const auto &bloom_bits(this->descriptor.bloom_bits);
|
const auto &bloom_bits(this->descriptor->bloom_bits);
|
||||||
if(bloom_bits)
|
if(bloom_bits)
|
||||||
table_opts.filter_policy.reset(rocksdb::NewBloomFilterPolicy(bloom_bits, false));
|
table_opts.filter_policy.reset(rocksdb::NewBloomFilterPolicy(bloom_bits, false));
|
||||||
|
|
||||||
|
@ -1509,7 +1511,7 @@ ircd::db::database::column::column(database *const &d,
|
||||||
this->options.compaction_pri = rocksdb::CompactionPri::kOldestLargestSeqFirst;
|
this->options.compaction_pri = rocksdb::CompactionPri::kOldestLargestSeqFirst;
|
||||||
|
|
||||||
// Set filter reductions for this column. This means we expect a key to exist.
|
// Set filter reductions for this column. This means we expect a key to exist.
|
||||||
this->options.optimize_filters_for_hits = this->descriptor.expect_queries_hit;
|
this->options.optimize_filters_for_hits = this->descriptor->expect_queries_hit;
|
||||||
|
|
||||||
// Compression
|
// Compression
|
||||||
//TODO: descriptor / conf / detect etc...
|
//TODO: descriptor / conf / detect etc...
|
||||||
|
@ -1530,7 +1532,7 @@ ircd::db::database::column::column(database *const &d,
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "schema '%s' column [%s => %s] cmp[%s] pfx[%s] lru:%s:%s bloom:%zu %s",
|
log, "schema '%s' column [%s => %s] cmp[%s] pfx[%s] lru:%s:%s bloom:%zu %s",
|
||||||
db::name(*d),
|
db::name(d),
|
||||||
demangle(key_type.name()),
|
demangle(key_type.name()),
|
||||||
demangle(mapped_type.name()),
|
demangle(mapped_type.name()),
|
||||||
this->cmp.Name(),
|
this->cmp.Name(),
|
||||||
|
@ -1538,7 +1540,7 @@ ircd::db::database::column::column(database *const &d,
|
||||||
cache_size? "YES": "NO",
|
cache_size? "YES": "NO",
|
||||||
cache_size_comp? "YES": "NO",
|
cache_size_comp? "YES": "NO",
|
||||||
bloom_bits,
|
bloom_bits,
|
||||||
this->descriptor.name
|
this->descriptor->name
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8216,7 +8218,8 @@ ircd::db::column::operator
|
||||||
const descriptor &()
|
const descriptor &()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
return c->descriptor;
|
assert(c->descriptor);
|
||||||
|
return *c->descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue