[column families] Implement DB::OpenWithColumnFamilies()

Summary:
In addition to implementing OpenWithColumnFamilies, this diff also includes some minor changes:
* Changed all column family names from Slice() to std::string. The performance of column family name handling is not critical, and it's more convenient and cleaner to have names as std::strings
* Implemented ColumnFamilyOptions(const Options&) and DBOptions(const Options&)
* Added ColumnFamilyOptions to VersionSet::ColumnFamilyData. ColumnFamilyOptions are specified on OpenWithColumnFamilies() and CreateColumnFamily()

I will keep the diff in the Phabricator for a day or two and will push to the branch then. Feel free to comment even after the diff has been pushed.

Test Plan: Added a simple unit test

Reviewers: dhruba, haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D15033
This commit is contained in:
Igor Canadi
2014-01-06 13:31:06 -08:00
parent d3a2ba9c64
commit 72918efffe
10 changed files with 232 additions and 37 deletions

View File

@@ -26,6 +26,6 @@ struct ColumnFamilyHandle {
};
const ColumnFamilyHandle default_column_family = ColumnFamilyHandle();
extern const Slice& default_column_family_name;
extern const std::string default_column_family_name;
}

View File

@@ -13,6 +13,7 @@
#include <stdio.h>
#include <memory>
#include <vector>
#include <string>
#include "rocksdb/iterator.h"
#include "rocksdb/options.h"
#include "rocksdb/types.h"
@@ -26,8 +27,11 @@ struct ColumnFamilyHandle;
extern const ColumnFamilyHandle default_column_family;
struct ColumnFamilyDescriptor {
Slice name;
std::string name;
ColumnFamilyOptions options;
ColumnFamilyDescriptor(const std::string& name,
const ColumnFamilyOptions& options)
: name(name), options(options) {}
};
// Update Makefile if you change these
@@ -117,7 +121,7 @@ class DB {
// Create a column_family and return the handle of column family
// through the argument handle.
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
const Slice& column_family,
const std::string& column_family_name,
ColumnFamilyHandle* handle);
// Drop a column family specified by column_family handle.

View File

@@ -68,6 +68,8 @@ struct CompressionOptions {
strategy(strategy){}
};
struct Options;
struct ColumnFamilyOptions {
// -------------------
// Parameters that affect behavior
@@ -426,6 +428,8 @@ struct ColumnFamilyOptions {
// Create ColumnFamilyOptions with default values for all fields
ColumnFamilyOptions();
// Create ColumnFamilyOptions from Options
explicit ColumnFamilyOptions(const Options& options);
};
struct DBOptions {
@@ -627,6 +631,8 @@ struct DBOptions {
// Create DBOptions with default values for all fields
DBOptions();
// Create DBOptions from Options
explicit DBOptions(const Options& options);
};
// Options to control the behavior of a database (passed to DB::Open)