From: Sage Weil Date: Thu, 1 Dec 2016 19:28:51 +0000 (-0500) Subject: writer X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fheads%2Fwip-log-reader-writer;p=rocksdb.git writer --- diff --git a/db/db_impl.cc b/db/db_impl.cc index 2830ee05..372f1ace 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -5168,7 +5168,8 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) { new WritableFileWriter(std::move(lfile), opt_env_opt)); new_log = new log::Writer(std::move(file_writer), new_log_number, - immutable_db_options_.recycle_log_file_num > 0); + immutable_db_options_.recycle_log_file_num > 0, + &db_options_); } } @@ -5958,7 +5959,8 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname, new_log_number, new log::Writer( std::move(file_writer), new_log_number, - impl->immutable_db_options_.recycle_log_file_num > 0)); + impl->immutable_db_options_.recycle_log_file_num > 0, + _impl->db_options_)); // set column family handles for (auto cf : column_families) { diff --git a/db/log_writer.cc b/db/log_writer.cc index 3277088b..da979487 100644 --- a/db/log_writer.cc +++ b/db/log_writer.cc @@ -11,6 +11,7 @@ #include #include "rocksdb/env.h" +#include "rocksdb/options.h" #include "util/coding.h" #include "util/crc32c.h" #include "util/file_reader_writer.h" @@ -19,8 +20,10 @@ namespace rocksdb { namespace log { Writer::Writer(unique_ptr&& dest, - uint64_t log_number, bool recycle_log_files) - : dest_(std::move(dest)), + uint64_t log_number, bool recycle_log_files, + const DBOptions *opt) + : db_options_(opt), + dest_(std::move(dest)), block_offset_(0), log_number_(log_number), recycle_log_files_(recycle_log_files) { @@ -122,6 +125,14 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) { crc = crc32c::Mask(crc); // Adjust for storage EncodeFixed32(buf, crc); + if (db_options_) + Log(InfoLogLevel::DEBUG_LEVEL, db_options_->info_log, + "EmitPhysicalRecord: log %lld offset %lld len %d crc %d", + (unsigned long long)log_number_, + (unsigned long long)dest_->GetFileSize(), + (int)header_size + (int)n, + crc); + // Write the header and the payload Status s = dest_->Append(Slice(buf, header_size)); if (s.ok()) { diff --git a/db/log_writer.h b/db/log_writer.h index 11267b33..dadd02cd 100644 --- a/db/log_writer.h +++ b/db/log_writer.h @@ -19,6 +19,7 @@ namespace rocksdb { class WritableFileWriter; +class DBOptions; using std::unique_ptr; @@ -73,7 +74,8 @@ class Writer { // "*dest" must be initially empty. // "*dest" must remain live while this Writer is in use. explicit Writer(unique_ptr&& dest, - uint64_t log_number, bool recycle_log_files); + uint64_t log_number, bool recycle_log_files, + const DBOptions *opt = NULL); ~Writer(); Status AddRecord(const Slice& slice); @@ -84,6 +86,7 @@ class Writer { uint64_t get_log_number() const { return log_number_; } private: + const DBOptions *db_options_; unique_ptr dest_; size_t block_offset_; // Current offset in block uint64_t log_number_;