-
Notifications
You must be signed in to change notification settings - Fork 2
/
.todo
186 lines (137 loc) · 4.51 KB
/
.todo
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
[h] - multiple aggregates
- last-block cache smart evicting
- fsync policies
- multiple codecs
- text query parser
- index based selects
- group by
- support tuples as value
- support named tuples as values
Timestamp(u64) - Type representing an UNIX timestamp
Point<T> - Type representing one data-point
+ timestamp: Timestamp
+ value: T
Schema<T> - Trait representing any schema (method of encoding the data)
+ type EncState: Default
+ type DecState: Default
+ encode(state: &mut EncState, entry: Point<T>) -> SmallVec
+ decode(state: &mut DecState, buff: &[u8]) -> (Point<T>, usize)
F32 : Schema - One realization of Schema
BlockHeader - Type representing metadata about the Block.
+ free_bytes
Block - Type owning data of block
+ header: BlockHeader
+ data: [u8]
BlockSpec - Type that represents a "handle" to potentially unloaded Block
+ block_id
+ series_id
BlockCache - Type that owns loaded Blocks
+ blocks_cache: Map<BlockSpec, Block>
+ lru: Vec<Option<BlockSpec>>
+ lru_idx
+ contains_block(spec: BlockSpec) -> bool
+ get_mut(spec: BlockSpec) -> &mut Block
+ insert(spec: BlockSpec, block: Block)
FsyncPolicy - Policy of sync-ing data to disk
- Immediate
- Never
- Every10s
BlockIO - load & saving block files to disk
+ open_files: Map<Path, File>
+ fsync_policy: FsyncPolicy
+ create_load_block(spec: BlockSpec) -> Block
+ write_block(spec: BlockSpec, block: &mut Block)
BlocksInfo - Information about block storage structure.
+ block_count: usize
+ block_size: usize
+ last_block_unused_bytes
TimestampIndex
+ file: File
+ fsync_policy: FsyncPolicy
+ data: Vec<Timestamp>
+ dirty_from_idx
+ create_or_load() -> TimestampIndex
+ write_index()
Series - Type that contains metadata about series
+ name: String
+ schema: F32
+ blocks_info: BlocksInfo
+ enc_state:
+ timestamp_index: TimestampIndex
Clock - Source of time that provides timestamps that do not go backwards in time
+ now() -> Timestamp
Server
+ clock: Clock
+ series: Map<String, Series>
+ cache: BlockCache
+ block_io: BlockIO
+ simple_commands: SimpleCommands
+ query_engine: QueryEngine
SimpleCommands - Type that provides simple commands of DB for storing and retrieving data
+ create_series(series_name: String)
+ insert_point<T>(series_name: String, point: Point<T>)
+ retrieve_points<T>(series_name: String, from: Timestamp, to: Timestamp) -> Iter<Point<T>>
QueryEngine - Type that provides advanced querying capabilities (filtering, grouping, aggregate functions, sub-queries)
+ handle_query(query: Query) -> Result
Selectable
- Timestamp
- Value
- AggFn
From
- Series(String)
- Temporary(Result)
GroupBy
- Minute
- Hour
- Day
- Week
- Month
- Year
Between
+ min_timestamp: Option<Timestamp>
+ max_timestamp: Option<Timestamp>
Cond<T>
- Lt(T)
- Gt(T)
- Le(T)
- Ge(T)
- Eq(T)
- Ne(T)
Query
+ from: From
+ select: Vec<Selectable>
+ between: Option<Between>
+ where: Vec<Cond>
+ group_by: GroupBy
Result<T>
+ points: Vec<Point<T>> ?????
SELECT timestamp, value FROM outdoor_sunlight AFTER '01-01-2019 20:00:05'
SELECT timestamp, value FROM outdoor_sunlight BETWEEN 01-01-2019 AND 02-01-2019
Select([S::Timestamp, S::Value], Retrieve(Timestamp(), Timestamp(), "outdoor_sunlight"))
SELECT AVG(value), MIN(value), MAX(value) FROM outdoor_sunlight BETWEEN 01-01-2019 AND 02-01-2019 GROUP BY HOUR
Aggregate([Value(), Min(), Max()], A:HOUR, Retrieve(Timestamp(), Timestamp(), "outdoor_sunlight"))
SELECT SUM(value), COUNT(value) FROM outdoor_sunlight AFTER NOW() - 1 HOUR
SELECT timestamp, value FROM outdoor_sunlight WHERE value > 500
SELECT AVG(a.value + b.value) FROM bikesharing_station01 a, bikesharing_station01 b GROUP BY DAY
0.dat (series file)
0.tsidx (main timestamp index file)
Point<V>
+ value: V
+ timestamp: Timestamp
+ tags: Vec<String>
Series<V>
+ id: usize
+ timestamp_index: Index<Timestamp>
+ indices: Vec<Index<_>>
+ encoder_state: V::EncState
+ schema: V::Schema
ArrayVec - stack-allocated Vec
Storage - provides fd pooling, loading/saving parts of files, fsync (periodic)
Block - provides format of storing the data
Index - provides indices (btree, bitmap) based on Storage & Block
Cache - provides LRU cache with unevictable entries
Engine - glues components together to allow storing and retrieval of data
QueryEngine - provides support for advanced queries
Protocol - defines how to talk to Server, parser
Auth - defines authentication methods of Server
Server - uses tokio to provides Engine over network, service