1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
8 #include "utilities/blob_db/blob_db.h"
11 #include "utilities/blob_db/blob_db_impl.h"
13 namespace ROCKSDB_NAMESPACE
{
16 Status
BlobDB::Open(const Options
& options
, const BlobDBOptions
& bdb_options
,
17 const std::string
& dbname
, BlobDB
** blob_db
) {
19 DBOptions
db_options(options
);
20 ColumnFamilyOptions
cf_options(options
);
21 std::vector
<ColumnFamilyDescriptor
> column_families
;
22 column_families
.push_back(
23 ColumnFamilyDescriptor(kDefaultColumnFamilyName
, cf_options
));
24 std::vector
<ColumnFamilyHandle
*> handles
;
25 Status s
= BlobDB::Open(db_options
, bdb_options
, dbname
, column_families
,
28 assert(handles
.size() == 1);
29 // i can delete the handle since DBImpl is always holding a reference to
30 // default column family
36 Status
BlobDB::Open(const DBOptions
& db_options
,
37 const BlobDBOptions
& bdb_options
, const std::string
& dbname
,
38 const std::vector
<ColumnFamilyDescriptor
>& column_families
,
39 std::vector
<ColumnFamilyHandle
*>* handles
,
43 if (column_families
.size() != 1 ||
44 column_families
[0].name
!= kDefaultColumnFamilyName
) {
45 return Status::NotSupported(
46 "Blob DB doesn't support non-default column family.");
49 BlobDBImpl
* blob_db_impl
= new BlobDBImpl(dbname
, bdb_options
, db_options
,
50 column_families
[0].options
);
51 Status s
= blob_db_impl
->Open(handles
);
53 *blob_db
= static_cast<BlobDB
*>(blob_db_impl
);
55 if (!handles
->empty()) {
56 for (ColumnFamilyHandle
* cfh
: *handles
) {
57 blob_db_impl
->DestroyColumnFamilyHandle(cfh
);
69 BlobDB::BlobDB() : StackableDB(nullptr) {}
71 void BlobDBOptions::Dump(Logger
* log
) const {
73 log
, " BlobDBOptions.blob_dir: %s",
76 log
, " BlobDBOptions.path_relative: %d",
79 log
, " BlobDBOptions.is_fifo: %d",
82 log
, " BlobDBOptions.max_db_size: %" PRIu64
,
85 log
, " BlobDBOptions.ttl_range_secs: %" PRIu64
,
88 log
, " BlobDBOptions.min_blob_size: %" PRIu64
,
91 log
, " BlobDBOptions.bytes_per_sync: %" PRIu64
,
94 log
, " BlobDBOptions.blob_file_size: %" PRIu64
,
97 log
, " BlobDBOptions.compression: %d",
98 static_cast<int>(compression
));
100 log
, " BlobDBOptions.enable_garbage_collection: %d",
101 enable_garbage_collection
);
103 log
, " BlobDBOptions.garbage_collection_cutoff: %f",
104 garbage_collection_cutoff
);
106 log
, " BlobDBOptions.disable_background_tasks: %d",
107 disable_background_tasks
);
110 } // namespace blob_db
111 } // namespace ROCKSDB_NAMESPACE