+
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
#ifndef ROCKSDB_LITE
#include "utilities/blob_db/blob_file.h"
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS
-#endif
-
-#include <inttypes.h>
#include <stdio.h>
+#include <cinttypes>
#include <algorithm>
-#include <limits>
#include <memory>
#include "db/column_family.h"
-#include "db/db_impl.h"
+#include "db/db_impl/db_impl.h"
#include "db/dbformat.h"
-#include "util/filename.h"
-#include "util/logging.h"
+#include "env/composite_env_wrapper.h"
+#include "file/filename.h"
+#include "file/readahead_raf.h"
+#include "logging/logging.h"
#include "utilities/blob_db/blob_db_impl.h"
-namespace rocksdb {
+namespace ROCKSDB_NAMESPACE {
namespace blob_db {
-BlobFile::BlobFile()
- : parent_(nullptr),
- file_number_(0),
- info_log_(nullptr),
- column_family_id_(std::numeric_limits<uint32_t>::max()),
- compression_(kNoCompression),
- has_ttl_(false),
- blob_count_(0),
- file_size_(0),
- closed_(false),
- obsolete_(false),
- expiration_range_({0, 0}),
- last_access_(-1),
- last_fsync_(0),
- header_valid_(false),
- footer_valid_(false) {}
-
BlobFile::BlobFile(const BlobDBImpl* p, const std::string& bdir, uint64_t fn,
Logger* info_log)
+ : parent_(p), path_to_dir_(bdir), file_number_(fn), info_log_(info_log) {}
+
+BlobFile::BlobFile(const BlobDBImpl* p, const std::string& bdir, uint64_t fn,
+ Logger* info_log, uint32_t column_family_id,
+ CompressionType compression, bool has_ttl,
+ const ExpirationRange& expiration_range)
: parent_(p),
path_to_dir_(bdir),
file_number_(fn),
info_log_(info_log),
- column_family_id_(std::numeric_limits<uint32_t>::max()),
- compression_(kNoCompression),
- has_ttl_(false),
- blob_count_(0),
- file_size_(0),
- closed_(false),
- obsolete_(false),
- expiration_range_({0, 0}),
- last_access_(-1),
- last_fsync_(0),
- header_valid_(false),
- footer_valid_(false) {}
+ column_family_id_(column_family_id),
+ compression_(compression),
+ has_ttl_(has_ttl),
+ expiration_range_(expiration_range),
+ header_(column_family_id, compression, has_ttl, expiration_range),
+ header_valid_(true) {}
BlobFile::~BlobFile() {
if (obsolete_) {
}
}
-uint32_t BlobFile::column_family_id() const { return column_family_id_; }
+uint32_t BlobFile::GetColumnFamilyId() const { return column_family_id_; }
std::string BlobFile::PathName() const {
return BlobFileName(path_to_dir_, file_number_);
sfile = NewReadaheadRandomAccessFile(std::move(sfile), kReadaheadSize);
std::unique_ptr<RandomAccessFileReader> sfile_reader;
- sfile_reader.reset(new RandomAccessFileReader(std::move(sfile), path_name));
+ sfile_reader.reset(new RandomAccessFileReader(
+ NewLegacyRandomAccessFileWrapper(sfile), path_name));
std::shared_ptr<Reader> log_reader = std::make_shared<Reader>(
std::move(sfile_reader), db_options.env, db_options.statistics.get());
: (file_size_ - last_fsync_) >= bytes_per_sync;
}
-Status BlobFile::WriteFooterAndCloseLocked() {
+Status BlobFile::WriteFooterAndCloseLocked(SequenceNumber sequence) {
BlobLogFooter footer;
footer.blob_count = blob_count_;
if (HasTTL()) {
Status s = log_writer_->AppendFooter(footer);
if (s.ok()) {
closed_ = true;
+ immutable_sequence_ = sequence;
file_size_ += BlobLogFooter::kSize;
}
// delete the sequential writer
return s;
}
- ra_file_reader_ = std::make_shared<RandomAccessFileReader>(std::move(rfile),
- PathName());
+ ra_file_reader_ = std::make_shared<RandomAccessFileReader>(
+ NewLegacyRandomAccessFileWrapper(rfile), PathName());
*reader = ra_file_reader_;
*fresh_open = true;
return s;
return s;
}
std::unique_ptr<RandomAccessFileReader> file_reader(
- new RandomAccessFileReader(std::move(file), PathName()));
+ new RandomAccessFileReader(NewLegacyRandomAccessFileWrapper(file),
+ PathName()));
// Read file header.
char header_buf[BlobLogHeader::kSize];
}
} // namespace blob_db
-} // namespace rocksdb
+} // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE