Crates.io | type-erased-table |
lib.rs | type-erased-table |
version | 0.1.0 |
source | src |
created_at | 2024-06-14 12:27:47.556459 |
updated_at | 2024-06-14 12:27:47.556459 |
description | A column-oriented based raw data storage |
homepage | |
repository | |
max_upload_size | |
id | 1271940 |
size | 14,336 |
Allow to create Table like structure represented by a structure of Arrays maintaining multiple arrays of different types while maintaining the same size for all the arrays and a shared index for each attribute created throughout its lifetime.
Provide a Table struct that allows to store rows of data composed of different types. This structure can be represented as a Structure of arrays and is built has an HashMap where keys are column identifiers and values are Column. Each Column is a contiguous array and every row component can be accessed with the same index on each Column.
This is an example of how you use this crate to to create a table struct with a simple columns.
Add dependency to you cargo.toml
[dependencies]
type-erased-table = "0.1.0"
After creating a table just add a column and start filling it with un-typed data.
let mut table = Table::new(1);
let value: u32 = 2;
// Get Layout from concrete type
let layout = Layout::for_value(&value);
// Create column with u32 identifier
let column_info = ColumnInfo::new(1, layout);
table.add_column(column_info);
let column = table.get_column_mut(1).unwrap();
// Push data into row of column by passing pointer as *const u8
unsafe { column.push(ptr::addr_of!(value) as *const u8) }
// Read value of row 0
let row_ptr = unsafe { column.get(0) };
let row_value: u32 = unsafe { (*row_ptr).into() };
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License.
Project Link: https://github.com/ValentinRio/type-erased-table