1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use RandomState;
use Cache;
use Lazy;
pub const SERVER_PORT: u16 = 8080;
pub const HEADER_SIZE: u16 = 30;
pub const CHUNK_SIZE: u32 = 4194304; //4MB
pub const EMPTY_BUFFER: = ;
pub static POSITIONS_CACHE: =
new;
/// # Rasterized DB (Alpha)
/// ## A new schemaless high-performance database written in Rust from scratch.
///
/// #### Features:
/// `enable_index_caching` to enable query caching
///
/// #### Create a static TABLE
/// ```rust
/// //Local File Storage Database
/// let io_sync = LocalStorageProvider::new(
/// "Some\\Folder",
/// "database.db"
/// );
/// //In-Memory Database
/// let io_sync = MemoryStorageProvider::new();
///
/// let mut table = Table::init(io_sync, false, false).unwrap();
/// ```
///
/// #### Create columns, rows and insert them
/// ```rust
/// let c1 = Column::new(10).unwrap();
/// let c2 = Column::new(-10).unwrap();
/// let str = 'A'.to_string().repeat(100);
/// let c3 = Column::new(str).unwrap();
///
/// let mut columns_buffer: Vec<u8> = Vec::with_capacity(
/// c1.len() +
/// c2.len() +
/// c3.len()
/// );
///
/// columns_buffer.append(&mut c1.content.to_vec());
/// columns_buffer.append(&mut c2.content.to_vec());
/// columns_buffer.append(&mut c3.content.to_vec());
///
/// let insert_row = InsertOrUpdateRow {
/// columns_data: columns_buffer.clone()
/// };
///
/// table.insert_row(insert_row).await;
/// //OR unsafe
/// table.insert_row_unsync(insert_row).await;
/// ```
/// #### Build in-memory file indexes
/// ```rust
/// table.rebuild_in_memory_indexes();
/// ```
///
/// #### Retrieve a row
/// ```rust
/// //Rasterized Query Language (Alpha)
/// let query_evaluation = parse_rql(&format!(r#"
/// BEGIN
/// SELECT FROM NAME_DOESNT_MATTER_FOR_NOW
/// WHERE COL(1) = -10
/// LIMIT 2
/// END
/// "#)).unwrap();
///
/// let rows = table.execute_query(query_evaluation.parser_result).await?;
/// ```
/// #### Update a row
/// ```rust
/// let update_row = InsertOrUpdateRow {
/// columns_data: columns_buffer_update // Same as insert_row
/// };
///
/// table.update_row_by_id(3, update_row).await;
/// ```
///
/// #### Delete a row
/// ```rust
/// // Invalidates cache automatically
/// table.delete_row_by_id(10).unwrap();
/// ```
///
/// #### Table Maintanance
/// ```rust
/// // Vacuum the table
/// table.vacuum_table().await;
///
/// // Must rebuild in-memory file indexes after vacuum
/// table.rebuild_in_memory_indexes();
/// ```
pub