@ -7,6 +7,7 @@
# include "utilities/blob_db/blob_db_impl.h"
# include "utilities/blob_db/blob_db_impl.h"
# include "util/filename.h"
# include "util/logging.h"
# include "util/logging.h"
# include "util/mutexlock.h"
# include "util/mutexlock.h"
@ -63,6 +64,10 @@ Status BlobDBImpl::EnableFileDeletions(bool force) {
Status BlobDBImpl : : GetLiveFiles ( std : : vector < std : : string > & ret ,
Status BlobDBImpl : : GetLiveFiles ( std : : vector < std : : string > & ret ,
uint64_t * manifest_file_size ,
uint64_t * manifest_file_size ,
bool flush_memtable ) {
bool flush_memtable ) {
if ( ! bdb_options_ . path_relative ) {
return Status : : NotSupported (
" Not able to get relative blob file path from absolute blob_dir. " ) ;
}
// Hold a lock in the beginning to avoid updates to base DB during the call
// Hold a lock in the beginning to avoid updates to base DB during the call
ReadLock rl ( & mutex_ ) ;
ReadLock rl ( & mutex_ ) ;
Status s = db_ - > GetLiveFiles ( ret , manifest_file_size , flush_memtable ) ;
Status s = db_ - > GetLiveFiles ( ret , manifest_file_size , flush_memtable ) ;
@ -72,12 +77,16 @@ Status BlobDBImpl::GetLiveFiles(std::vector<std::string>& ret,
ret . reserve ( ret . size ( ) + blob_files_ . size ( ) ) ;
ret . reserve ( ret . size ( ) + blob_files_ . size ( ) ) ;
for ( auto bfile_pair : blob_files_ ) {
for ( auto bfile_pair : blob_files_ ) {
auto blob_file = bfile_pair . second ;
auto blob_file = bfile_pair . second ;
ret . emplace_back ( blob_file - > PathName ( ) ) ;
// Path should be relative to db_name, but begin with slash.
ret . emplace_back (
BlobFileName ( " " , bdb_options_ . blob_dir , blob_file - > BlobFileNumber ( ) ) ) ;
}
}
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
void BlobDBImpl : : GetLiveFilesMetaData ( std : : vector < LiveFileMetaData > * metadata ) {
void BlobDBImpl : : GetLiveFilesMetaData ( std : : vector < LiveFileMetaData > * metadata ) {
// Path should be relative to db_name.
assert ( bdb_options_ . path_relative ) ;
// Hold a lock in the beginning to avoid updates to base DB during the call
// Hold a lock in the beginning to avoid updates to base DB during the call
ReadLock rl ( & mutex_ ) ;
ReadLock rl ( & mutex_ ) ;
db_ - > GetLiveFilesMetaData ( metadata ) ;
db_ - > GetLiveFilesMetaData ( metadata ) ;
@ -85,7 +94,9 @@ void BlobDBImpl::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {
auto blob_file = bfile_pair . second ;
auto blob_file = bfile_pair . second ;
LiveFileMetaData filemetadata ;
LiveFileMetaData filemetadata ;
filemetadata . size = blob_file - > GetFileSize ( ) ;
filemetadata . size = blob_file - > GetFileSize ( ) ;
filemetadata . name = blob_file - > PathName ( ) ;
// Path should be relative to db_name, but begin with slash.
filemetadata . name =
BlobFileName ( " " , bdb_options_ . blob_dir , blob_file - > BlobFileNumber ( ) ) ;
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( DefaultColumnFamily ( ) ) ;
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( DefaultColumnFamily ( ) ) ;
filemetadata . column_family_name = cfh - > GetName ( ) ;
filemetadata . column_family_name = cfh - > GetName ( ) ;
metadata - > emplace_back ( filemetadata ) ;
metadata - > emplace_back ( filemetadata ) ;