Export DEFAILT_COLUMN_FAMILY_NAME constant (#435)

master
Stanislav Tkach 4 years ago committed by GitHub
parent 6eeee5e60a
commit 22fc1faca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 6
      src/column_family.rs
  3. 6
      src/db.rs
  4. 2
      src/lib.rs
  5. 4
      tests/test_column_family.rs

@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
* Export the `DEFAULT_COLUMN_FAMILY_NAME` constant.
## 0.14.0 (2020-04-22)
* Updated lz4 to v1.9.2 (ordian)

@ -14,6 +14,12 @@
use crate::{ffi, Options};
/// The name of the default column family.
///
/// The column family with this name is created implicitly whenever column
/// families are used.
pub const DEFAULT_COLUMN_FAMILY_NAME: &str = "default";
/// A descriptor for a RocksDB column family.
///
/// A description of the column family, containing the name and `Options`.

@ -18,7 +18,7 @@ use crate::{
ffi_util::{opt_bytes_to_ptr, to_cpath},
ColumnFamily, ColumnFamilyDescriptor, DBIterator, DBPinnableSlice, DBRawIterator,
DBWALIterator, Direction, Error, FlushOptions, IngestExternalFileOptions, IteratorMode,
Options, ReadOptions, Snapshot, WriteBatch, WriteOptions,
Options, ReadOptions, Snapshot, WriteBatch, WriteOptions, DEFAULT_COLUMN_FAMILY_NAME,
};
use libc::{self, c_char, c_int, c_uchar, c_void, size_t};
@ -216,9 +216,9 @@ impl DB {
} else {
let mut cfs_v = cfs;
// Always open the default column family.
if !cfs_v.iter().any(|cf| cf.name == "default") {
if !cfs_v.iter().any(|cf| cf.name == DEFAULT_COLUMN_FAMILY_NAME) {
cfs_v.push(ColumnFamilyDescriptor {
name: String::from("default"),
name: String::from(DEFAULT_COLUMN_FAMILY_NAME),
options: Options::default(),
});
}

@ -90,7 +90,7 @@ mod sst_file_writer;
mod write_batch;
pub use crate::{
column_family::{ColumnFamily, ColumnFamilyDescriptor},
column_family::{ColumnFamily, ColumnFamilyDescriptor, DEFAULT_COLUMN_FAMILY_NAME},
compaction_filter::Decision as CompactionDecision,
db::DB,
db_iterator::{DBIterator, DBRawIterator, DBWALIterator, Direction, IteratorMode},

@ -14,7 +14,7 @@
mod util;
use rocksdb::{ColumnFamilyDescriptor, MergeOperands, Options, DB};
use rocksdb::{ColumnFamilyDescriptor, MergeOperands, Options, DB, DEFAULT_COLUMN_FAMILY_NAME};
use util::DBPath;
#[test]
@ -68,7 +68,7 @@ fn test_column_family() {
let opts = Options::default();
let vec = DB::list_cf(&opts, &n);
match vec {
Ok(vec) => assert_eq!(vec, vec!["default", "cf1"]),
Ok(vec) => assert_eq!(vec, vec![DEFAULT_COLUMN_FAMILY_NAME, "cf1"]),
Err(e) => panic!("failed to drop column family: {}", e),
}
}

Loading…
Cancel
Save