/// test whether we can successfully initialize; may have side effects (e.g., create)
static int test_init(const std::string& type, const std::string& dir);
virtual int init(string option_str="") = 0;
- virtual int open(std::ostream &out) = 0;
- virtual int open(std::ostream &out, const vector<ColumnFamily>& cfs) {
- assert(0 == "Not implemented");
- }
- virtual int create_and_open(std::ostream &out) = 0;
- virtual void close() { }
+ virtual int open(std::ostream &out, const vector<ColumnFamily>& cfs = {}) = 0;
// vector cfs contains column families to be created when db is created.
virtual int create_and_open(std::ostream &out,
- const vector<ColumnFamily>& cfs) {
- assert(0 == "Not implemented");
- }
+ const vector<ColumnFamily>& cfs = {}) = 0;
+ virtual void close() { }
virtual Transaction get_transaction() = 0;
virtual int submit_transaction(Transaction) = 0;
return status.ok() ? 0 : -EIO;
}
+int KineticStore::open(ostream &out, const vector<ColumnFamily>& cfs)
+{
+ if (!cfs.empty()) {
+ assert(0 == "Not implemented");
+ }
+ return do_open(out, false);
+}
+
+int KineticStore::create_and_open(ostream &out, const vector<ColumnFamily>& cfs)
+{
+ if (!cfs.empty()) {
+ assert(0 == "Not implemented");
+ }
+ return do_open(out, true);
+}
+
int KineticStore::do_open(ostream &out, bool create_if_missing)
{
kinetic::KineticConnectionFactory conn_factory =
int init();
/// Opens underlying db
- int open(ostream &out) {
- return do_open(out, false);
- }
+ int open(ostream &out, const std::vector<ColumnFamily>& = {}) override;
/// Creates underlying db if missing and opens it
- int create_and_open(ostream &out) override {
- return do_open(out, true);
- }
+ int create_and_open(ostream &out, const std::vector<ColumnFamily>& = {}) override;
void close();
return 0;
}
+int LevelDBStore::open(ostream &out, const vector<ColumnFamily>& cfs) {
+ if (!cfs.empty()) {
+ assert(0 == "Not implemented");
+ }
+ return do_open(out, false);
+}
+
+int LevelDBStore::create_and_open(ostream &out, const vector<ColumnFamily>& cfs) {
+ if (!cfs.empty()) {
+ assert(0 == "Not implemented");
+ }
+ return do_open(out, true);
+}
+
int LevelDBStore::do_open(ostream &out, bool create_if_missing)
{
leveldb::Options ldoptions;
int init(string option_str="") override;
/// Opens underlying db
- int open(ostream &out) override {
- return do_open(out, false);
- }
+ int open(ostream &out, const std::vector<ColumnFamily>& = {}) override;
/// Creates underlying db if missing and opens it
- int create_and_open(ostream &out) override {
- return do_open(out, true);
- }
+ int create_and_open(ostream &out, const std::vector<ColumnFamily>& = {}) override;
void close() override;
return _init(create);
}
+int MemDB::open(ostream &out, const vector<ColumnFamily>& cfs) {
+ if (!cfs.empty()) {
+ assert(0 == "Not implemented");
+ }
+ return do_open(out, false);
+}
+
+int MemDB::create_and_open(ostream &out, const vector<ColumnFamily>& cfs) {
+ if (!cfs.empty()) {
+ assert(0 == "Not implemented");
+ }
+ return do_open(out, true);
+}
+
MemDB::~MemDB()
{
close();
int _init(bool format);
int do_open(ostream &out, bool create);
- int open(ostream &out) override { return do_open(out, false); }
- int create_and_open(ostream &out) override { return do_open(out, true); }
+ int open(ostream &out, const std::vector<ColumnFamily>&) override;
+ int create_and_open(ostream &out, const std::vector<ColumnFamily>&) override;
+ using KeyValueDB::create_and_open;
KeyValueDB::Transaction get_transaction() override {
return std::shared_ptr<MDBTransactionImpl>(new MDBTransactionImpl(this));
return 0;
}
-int RocksDBStore::create_and_open(ostream &out)
-{
- int r = create_db_dir();
- if (r < 0)
- return r;
- return do_open(out, true);
-}
-
int RocksDBStore::create_and_open(ostream &out,
const vector<ColumnFamily>& cfs)
{
int r = create_db_dir();
if (r < 0)
return r;
- return do_open(out, true, &cfs);
+ if (cfs.empty()) {
+ return do_open(out, true, nullptr);
+ } else {
+ return do_open(out, true, &cfs);
+ }
}
int RocksDBStore::do_open(ostream &out, bool create_if_missing,
static bool check_omap_dir(string &omap_dir);
/// Opens underlying db
- int open(ostream &out) override {
- return do_open(out, false);
- }
- int open(ostream &out, const vector<ColumnFamily>& cfs) override {
+ int open(ostream &out, const vector<ColumnFamily>& cfs = {}) override {
return do_open(out, false, &cfs);
}
/// Creates underlying db if missing and opens it
- int create_and_open(ostream &out) override;
int create_and_open(ostream &out,
- const vector<ColumnFamily>& cfs) override;
+ const vector<ColumnFamily>& cfs = {}) override;
void close() override;
int init(string _opt) override {
return 0;
}
- int open(ostream &out) override {
+ int open(std::ostream &out, const vector<ColumnFamily>& cfs = {}) override {
return 0;
}
- int create_and_open(ostream &out) override {
+ int create_and_open(ostream &out, const vector<ColumnFamily>& cfs = {}) override {
return 0;
}