Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #38 from AndrewSisley/i16
Browse files Browse the repository at this point in the history
Add support for i16
  • Loading branch information
AndrewSisley authored Mar 22, 2020
2 parents 4f673b2 + c7c8376 commit 551309a
Show file tree
Hide file tree
Showing 9 changed files with 952 additions and 0 deletions.
Empty file.
23 changes: 23 additions & 0 deletions cql_storage_types/cql_i16/Cargo.toml
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"
1 change: 1 addition & 0 deletions cql_storage_types/cql_i16/benches/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub const DATABASE_LOCATION: &str = "./.test_db";
171 changes: 171 additions & 0 deletions cql_storage_types/cql_i16/benches/read_single.rs
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();
});
}
134 changes: 134 additions & 0 deletions cql_storage_types/cql_i16/benches/read_stream.rs
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();
});
}
Loading

0 comments on commit 551309a

Please sign in to comment.