}
file->SetPreallocationBlockSize(db_options_.manifest_preallocation_size);
{
- log::Writer log(std::move(file));
+ log::Writer log(&db_options_, std::move(file), 0);
std::string record;
new_db.EncodeTo(&record);
s = log.AddRecord(record);
// (compression, etc) but err on the side of caution.
lfile->SetPreallocationBlockSize(
1.1 * mutable_cf_options.write_buffer_size);
- new_log = new log::Writer(std::move(lfile));
- log_dir_synced_ = false;
+ new_log = new log::Writer(&db_options_, std::move(lfile),
+ new_log_number);
+ log_dir_synced_ = false;
}
}
if (s.ok()) {
lfile->SetPreallocationBlockSize(1.1 * max_write_buffer_size);
impl->logfile_number_ = new_log_number;
- impl->log_.reset(new log::Writer(std::move(lfile)));
+ impl->log_.reset(new log::Writer(&impl->db_options_, std::move(lfile),
+ new_log_number));
// set column family handles
for (auto cf : column_families) {
#include <stdint.h>
#include "rocksdb/env.h"
+#include "rocksdb/options.h"
#include "util/coding.h"
#include "util/crc32c.h"
namespace rocksdb {
namespace log {
-Writer::Writer(unique_ptr<WritableFile>&& dest)
- : dest_(std::move(dest)),
- block_offset_(0) {
+Writer::Writer(const DBOptions *opt, unique_ptr<WritableFile>&& dest,
+ int log_number)
+ : db_options_(opt),
+ dest_(std::move(dest)),
+ block_offset_(0),
+ log_number_(log_number) {
for (int i = 0; i <= kMaxRecordType; i++) {
char t = static_cast<char>(i);
type_crc_[i] = crc32c::Value(&t, 1);
namespace rocksdb {
class WritableFile;
+class DBOptions;
using std::unique_ptr;
// Create a writer that will append data to "*dest".
// "*dest" must be initially empty.
// "*dest" must remain live while this Writer is in use.
- explicit Writer(unique_ptr<WritableFile>&& dest);
+ explicit Writer(const DBOptions *opt,
+ unique_ptr<WritableFile>&& dest,
+ int log_number);
~Writer();
Status AddRecord(const Slice& slice);
const WritableFile* file() const { return dest_.get(); }
private:
+ const DBOptions *db_options_;
unique_ptr<WritableFile> dest_;
int block_offset_; // Current offset in block
+ int log_number_;
// crc32c values for all supported record types. These are
// pre-computed to reduce the overhead of computing the crc of the
//fprintf(stderr, "NewDescriptor:\n%s\n", edit_.DebugString().c_str());
{
- log::Writer log(std::move(file));
+ log::Writer log(&options_, std::move(file), 0);
std::string record;
edit_->EncodeTo(&record);
status = log.AddRecord(record);
if (s.ok()) {
descriptor_file->SetPreallocationBlockSize(
db_options_->manifest_preallocation_size);
- descriptor_log_.reset(new log::Writer(std::move(descriptor_file)));
+ descriptor_log_.reset(new log::Writer(db_options_,
+ std::move(descriptor_file), 0));
s = WriteSnapshot(descriptor_log_.get());
}
}
std::string fname = ArchivedLogFileName(dbname_, current_log_number_);
unique_ptr<WritableFile> file;
ASSERT_OK(env_->NewWritableFile(fname, &file, env_options_));
- current_log_writer_.reset(new log::Writer(std::move(file)));
+ current_log_writer_.reset(new log::Writer(&db_options_, std::move(file)));
}
void CreateArchiveLogs(int num_logs, int entries_per_log) {