This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from AndrewSisley/i16
Add support for i16
- Loading branch information
Showing
9 changed files
with
952 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "cql_i16" | ||
description = "i16 storage support for CQL Database - a lightweight array-based database" | ||
readme = "./README.md" | ||
keywords = ["cql", "database", "array", "storage", "nosql"] | ||
categories = ["database", "database-implementations", "filesystem", "caching"] | ||
version = "0.2.0" | ||
repository = "https://github.com/AndrewSisley/CQLDb/tree/master/cql_storage_types/cql_i16" | ||
authors = ["Andrew Sisley"] | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[lib] | ||
name = "cql_i16" | ||
path = "src/i16.rs" | ||
|
||
[dev-dependencies] | ||
cql_db = "^0.2.4" | ||
serial_test = "0.3.2" | ||
|
||
[dependencies] | ||
cql_model = "^0.2" | ||
byteorder = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub const DATABASE_LOCATION: &str = "./.test_db"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
#![feature(test)] | ||
mod constants; | ||
extern crate test; | ||
|
||
use constants::DATABASE_LOCATION; | ||
use test::Bencher; | ||
use cql_i16::I16; | ||
|
||
#[bench] | ||
fn _1d_i16_single_point_read_location_1(b: &mut Bencher) { | ||
let axis = [ | ||
2, | ||
]; | ||
|
||
let point1 = [1]; | ||
let value1 = 42; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&axis | ||
).unwrap(); | ||
|
||
cql_db::write_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1, | ||
value1 | ||
).unwrap(); | ||
|
||
b.iter(|| { | ||
cql_db::read_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1 | ||
).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _1d_i16_single_point_read_location_100000(b: &mut Bencher) { | ||
let axis = [ | ||
100000, | ||
]; | ||
|
||
let point1 = [100000]; | ||
let value1 = 42; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&axis | ||
).unwrap(); | ||
|
||
cql_db::write_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1, | ||
value1 | ||
).unwrap(); | ||
|
||
b.iter(|| { | ||
cql_db::read_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1 | ||
).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _4d_i16_single_point_read_location_1_1_1_1(b: &mut Bencher) { | ||
let axis = [ | ||
2, | ||
2, | ||
2, | ||
2, | ||
]; | ||
|
||
let point1 = [1, 1, 1, 1]; | ||
let value1 = 5; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&axis | ||
).unwrap(); | ||
|
||
cql_db::link_dimensions_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1[0..3], | ||
).unwrap(); | ||
|
||
cql_db::write_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1, | ||
value1 | ||
).unwrap(); | ||
|
||
b.iter(|| { | ||
cql_db::read_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1 | ||
).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _4d_i16_single_point_read_location_1_1_1_100000(b: &mut Bencher) { | ||
let axis = [ | ||
2, | ||
2, | ||
2, | ||
100000, | ||
]; | ||
|
||
let point1 = [1, 1, 1, 100000]; | ||
let value1 = 5; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&axis | ||
).unwrap(); | ||
|
||
cql_db::link_dimensions_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1[0..3], | ||
).unwrap(); | ||
|
||
cql_db::write_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1, | ||
value1 | ||
).unwrap(); | ||
|
||
b.iter(|| { | ||
cql_db::read_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1 | ||
).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _4d_i16_single_point_read_location_1_100000_1_1(b: &mut Bencher) { | ||
let axis = [ | ||
2, | ||
100000, | ||
2, | ||
2, | ||
]; | ||
|
||
let point1 = [1, 100000, 1, 1]; | ||
let value1 = 5; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&axis | ||
).unwrap(); | ||
|
||
cql_db::link_dimensions_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1[0..3], | ||
).unwrap(); | ||
|
||
cql_db::write_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1, | ||
value1 | ||
).unwrap(); | ||
|
||
b.iter(|| { | ||
cql_db::read_value_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&point1 | ||
).unwrap(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#![feature(test)] | ||
mod constants; | ||
extern crate test; | ||
|
||
use std::io::{ Cursor, SeekFrom, Seek }; | ||
use constants::DATABASE_LOCATION; | ||
use test::{ Bencher }; | ||
use cql_i16::{ unpack_stream, I16 }; | ||
|
||
#[bench] | ||
fn _1d_i16_stream_read_location_1_to_1(b: &mut Bencher) { | ||
let n_values_to_read = 1usize; | ||
let point1 = [1]; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&[1] | ||
).unwrap(); | ||
|
||
let mut result = [0]; | ||
let mut stream = Cursor::new(Vec::new()); | ||
|
||
b.iter(|| { | ||
cql_db::read_to_stream_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&mut stream, | ||
&point1, | ||
n_values_to_read as u64 | ||
).unwrap(); | ||
|
||
stream.seek(SeekFrom::Start(0)).unwrap(); | ||
|
||
unpack_stream(&mut stream, n_values_to_read, |idx, value| { | ||
result[idx] = value | ||
}).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _1d_i16_stream_read_location_50000_to_100000(b: &mut Bencher) { | ||
let n_values_to_read = 50000usize; | ||
let base_point = [50000u64]; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&[100000] | ||
).unwrap(); | ||
|
||
let mut result = [0; 50000]; | ||
let mut stream = Cursor::new(Vec::new()); | ||
|
||
b.iter(|| { | ||
cql_db::read_to_stream_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&mut stream, | ||
&base_point, | ||
n_values_to_read as u64 | ||
).unwrap(); | ||
|
||
stream.seek(SeekFrom::Start(0)).unwrap(); | ||
|
||
unpack_stream(&mut stream, n_values_to_read, |idx, value| { | ||
result[idx] = value | ||
}).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _4d_i16_stream_read_location_1_1_1_1_to_1_1_1_1(b: &mut Bencher) { | ||
let n_values_to_read = 1usize; | ||
let base_point = [1, 1, 1, 1]; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&[1, 1, 1, 1] | ||
).unwrap(); | ||
|
||
cql_db::link_dimensions_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&base_point[0..3], | ||
).unwrap(); | ||
|
||
let mut result = [0]; | ||
let mut stream = Cursor::new(Vec::new()); | ||
|
||
b.iter(|| { | ||
cql_db::read_to_stream_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&mut stream, | ||
&base_point, | ||
n_values_to_read as u64 | ||
).unwrap(); | ||
|
||
stream.seek(SeekFrom::Start(0)).unwrap(); | ||
|
||
unpack_stream(&mut stream, n_values_to_read, |idx, value| { | ||
result[idx] = value | ||
}).unwrap(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn _4d_i16_stream_read_location_1_1_1_50000_to_1_1_1_100000(b: &mut Bencher) { | ||
let n_values_to_read = 50000usize; | ||
let base_point = [1, 1, 1, 50000]; | ||
|
||
cql_db::create_db_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&[1, 1, 1, 100000] | ||
).unwrap(); | ||
|
||
cql_db::link_dimensions_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&base_point[0..3], | ||
).unwrap(); | ||
|
||
let mut result = [0; 50000]; | ||
let mut stream = Cursor::new(Vec::new()); | ||
|
||
b.iter(|| { | ||
cql_db::read_to_stream_unchecked::<I16>( | ||
DATABASE_LOCATION, | ||
&mut stream, | ||
&base_point, | ||
n_values_to_read as u64 | ||
).unwrap(); | ||
|
||
stream.seek(SeekFrom::Start(0)).unwrap(); | ||
|
||
unpack_stream(&mut stream, n_values_to_read, |idx, value| { | ||
result[idx] = value | ||
}).unwrap(); | ||
}); | ||
} |
Oops, something went wrong.