About The Project
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.
Built With
- Nohash to create hashmap without hashing algorithm (keys are u32) - https://github.com/tetcoin/nohash
- Based on bevy BlobVec implementation - https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs
Getting Started
This is an example of how you use this crate to to create a table struct with a simple columns.
Installation
Add dependency to you cargo.toml
[]
= "0.1.0"
Usage
After creating a table just add a column and start filling it with un-typed data.
let mut table = new;
let value: u32 = 2;
// Get Layout from concrete type
let layout = for_value;
// Create column with u32 identifier
let column_info = new;
table.add_column;
let column = table.get_column_mut.unwrap;
// Push data into row of column by passing pointer as *const u8
unsafe
// Read value of row 0
let row_ptr = unsafe ;
let row_value: u32 = unsafe ;
Contributing
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License.
Contact
Project Link: https://github.com/ValentinRio/type-erased-table