sstables: get rid of write_static_column_name

After the last round of cleanups, this function turned out to be exactly the
same as write_column_name, except that the composite differs. Because the
composite is passed as a parameter, we can just use the same function for all
and pre-create the composite.

This will make the implementation of collections a lot easier, since for
collections we will prepend each element with the column name.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This commit is contained in:
Glauber Costa
2015-05-27 17:46:48 -04:00
parent 9ee588bc49
commit 7073639201
2 changed files with 4 additions and 15 deletions

View File

@@ -955,18 +955,6 @@ future<> sstable::write_column_name(file_writer& out, const composite& clusterin
});
}
future<> sstable::write_static_column_name(file_writer& out, const schema& schema, const std::vector<bytes_view>& column_names) {
column_name_helper::min_components(_c_stats.min_column_names, column_names);
column_name_helper::max_components(_c_stats.max_column_names, column_names);
return do_with(composite::from_exploded(column_names), [&out, &schema] (composite& c) {
return do_with(composite::static_prefix(schema), [&out, &c] (composite& sp) {
uint16_t sz = sp.size() + c.size();
return write(out, sz, sp, c);
});
});
}
static inline void update_cell_stats(column_stats& c_stats, uint64_t timestamp) {
c_stats.update_min_timestamp(timestamp);
c_stats.update_max_timestamp(timestamp);
@@ -1073,8 +1061,10 @@ future<> sstable::write_static_row(file_writer& out, schema_ptr schema, const ro
}
assert(column_definition.is_static());
atomic_cell_view cell = value.second.as_atomic_cell();
return this->write_static_column_name(out, *schema, { bytes_view(column_definition.name()) }).then([&out, cell, this] {
return this->write_cell(out, cell);
return do_with(composite::static_prefix(*schema), [this, &out, &column_definition, cell = std::move(cell)] (composite& sp) {
return this->write_column_name(out, sp, { bytes_view(column_definition.name()) }).then([this, &out, cell] {
return this->write_cell(out, cell);
});
});
});
}

View File

@@ -292,7 +292,6 @@ private:
future<> write_static_row(file_writer& out, schema_ptr schema, const row& static_row);
future<> write_cell(file_writer& out, atomic_cell_view cell);
future<> write_column_name(file_writer& out, const composite& clustering_key, const std::vector<bytes_view>& column_names);
future<> write_static_column_name(file_writer& out, const schema& schema, const std::vector<bytes_view>& column_names);
public:
// Allow the test cases from sstable_test.cc to test private methods. We use
// a placeholder to avoid cluttering this class too much. The sstable_test class