[][src]Function cql_db::create_db_unchecked

pub fn create_db_unchecked<TStore: CqlType>(
    db_location: &str,
    array_size: &[u64]
) -> Result<()>

Creates an CQL database in the provided directory, overwriting existing files. Does not validate given parameters.

Errors

Will return any I/O errors encountered during the execution of the function. Function may partially succeed resulting in changes to the file system, including the overwrite of any existing database files were they already present.

Panics

Function does not actively defend against panics, and will likely do so if given invalid parameters. Function may partially succeed resulting in changes to the file system, including the overwrite of any existing database files were they already present.

Examples

The below code creates a 2 dimensional array of [2, 3] storing unsigned 64bit integers:

use cql_u64::U64;

cql_db::create_db_unchecked::<U64>(
    DATABASE_LOCATION,
    &[2, 3]
)?;

// created database will be matrix of zeros (default u64 value):
// [ 0, 0, 0, ]
// [ 0, 0, 0, ]

More complex databases can be created by increaing the length of the input array:

// 4 dimensional array:
cql_db::create_db_unchecked::<U64>(
    DATABASE_LOCATION,
    &[2, 3, 4, 5]
)?;

// 10 dimensional array:
cql_db::create_db_unchecked::<U64>(
    DATABASE_LOCATION,
    &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
)?;

There are no restrictions on the shape of your databases, but it is usually better to have smaller dimensions at the start:

// This is valid:
cql_db::create_db_unchecked::<U64>(
    DATABASE_LOCATION,
    &[20, 50, 3]
)?;

// However this will likely be both faster to read from, and save file space:
cql_db::create_db_unchecked::<U64>(
    DATABASE_LOCATION,
    &[3, 20, 50]
)?;

But see the type(s) that you are interested in for performance benchmarks, and the index page to see how to calcuate file size requirements.