Skip to content

Commit 826b78a

Browse files
aw-query: Fix unnecessary lifetime parameter and references
1 parent edc9b3f commit 826b78a

File tree

3 files changed

+83
-80
lines changed

3 files changed

+83
-80
lines changed

aw-query/src/functions.rs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,95 +5,98 @@ use std::collections::HashMap;
55

66
pub type QueryFn = fn(
77
args: Vec<DataType>,
8-
env: &HashMap<&str, DataType>,
8+
env: &HashMap<String, DataType>,
99
ds: &Datastore,
1010
) -> Result<DataType, QueryError>;
1111

12-
pub fn fill_env<'a>(env: &mut HashMap<&'a str, DataType>) {
12+
pub fn fill_env(env: &mut HashMap<String, DataType>) {
1313
env.insert(
14-
"print",
14+
"print".to_string(),
1515
DataType::Function("print".to_string(), qfunctions::print),
1616
);
1717
env.insert(
18-
"query_bucket",
18+
"query_bucket".to_string(),
1919
DataType::Function("query_bucket".to_string(), qfunctions::query_bucket),
2020
);
2121
env.insert(
22-
"query_bucket_names",
22+
"query_bucket_names".to_string(),
2323
DataType::Function(
2424
"query_bucket_names".to_string(),
2525
qfunctions::query_bucket_names,
2626
),
2727
);
2828
env.insert(
29-
"sort_by_duration",
29+
"sort_by_duration".to_string(),
3030
DataType::Function("sort_by_duration".to_string(), qfunctions::sort_by_duration),
3131
);
3232
env.insert(
33-
"sort_by_timestamp",
33+
"sort_by_timestamp".to_string(),
3434
DataType::Function(
3535
"sort_by_timestamp".to_string(),
3636
qfunctions::sort_by_timestamp,
3737
),
3838
);
3939
env.insert(
40-
"sum_durations",
40+
"sum_durations".to_string(),
4141
DataType::Function("sum_durations".to_string(), qfunctions::sum_durations),
4242
);
4343
env.insert(
44-
"limit_events",
44+
"limit_events".to_string(),
4545
DataType::Function("limit_events".to_string(), qfunctions::limit_events),
4646
);
4747
env.insert(
48-
"contains",
48+
"contains".to_string(),
4949
DataType::Function("contains".to_string(), qfunctions::contains),
5050
);
5151
env.insert(
52-
"flood",
52+
"flood".to_string(),
5353
DataType::Function("flood".to_string(), qfunctions::flood),
5454
);
5555
env.insert(
56-
"find_bucket",
56+
"find_bucket".to_string(),
5757
DataType::Function("find_bucket".to_string(), qfunctions::find_bucket),
5858
);
5959
env.insert(
60-
"merge_events_by_keys",
60+
"merge_events_by_keys".to_string(),
6161
DataType::Function(
6262
"merge_events_by_keys".to_string(),
6363
qfunctions::merge_events_by_keys,
6464
),
6565
);
6666
env.insert(
67-
"chunk_events_by_key",
67+
"chunk_events_by_key".to_string(),
6868
DataType::Function(
6969
"chunk_events_by_key".to_string(),
7070
qfunctions::chunk_events_by_key,
7171
),
7272
);
7373
env.insert(
74-
"filter_keyvals",
74+
"filter_keyvals".to_string(),
7575
DataType::Function("filter_keyvals".to_string(), qfunctions::filter_keyvals),
7676
);
7777
env.insert(
78-
"filter_period_intersect",
78+
"filter_period_intersect".to_string(),
7979
DataType::Function(
8080
"filter_period_intersect".to_string(),
8181
qfunctions::filter_period_intersect,
8282
),
8383
);
8484
env.insert(
85-
"split_url_events",
85+
"split_url_events".to_string(),
8686
DataType::Function("split_url_events".to_string(), qfunctions::split_url_events),
8787
);
8888
env.insert(
89-
"concat",
89+
"concat".to_string(),
9090
DataType::Function("concat".to_string(), qfunctions::concat),
9191
);
9292
env.insert(
93-
"categorize",
93+
"categorize".to_string(),
9494
DataType::Function("categorize".into(), qfunctions::categorize),
9595
);
96-
env.insert("tag", DataType::Function("tag".into(), qfunctions::tag));
96+
env.insert(
97+
"tag".to_string(),
98+
DataType::Function("tag".into(), qfunctions::tag),
99+
);
97100
}
98101

99102
mod qfunctions {
@@ -111,7 +114,7 @@ mod qfunctions {
111114

112115
pub fn print(
113116
args: Vec<DataType>,
114-
_env: &HashMap<&str, DataType>,
117+
_env: &HashMap<String, DataType>,
115118
_ds: &Datastore,
116119
) -> Result<DataType, QueryError> {
117120
for arg in args {
@@ -122,7 +125,7 @@ mod qfunctions {
122125

123126
pub fn query_bucket(
124127
args: Vec<DataType>,
125-
env: &HashMap<&str, DataType>,
128+
env: &HashMap<String, DataType>,
126129
ds: &Datastore,
127130
) -> Result<DataType, QueryError> {
128131
// Typecheck
@@ -153,7 +156,7 @@ mod qfunctions {
153156

154157
pub fn query_bucket_names(
155158
args: Vec<DataType>,
156-
_env: &HashMap<&str, DataType>,
159+
_env: &HashMap<String, DataType>,
157160
ds: &Datastore,
158161
) -> Result<DataType, QueryError> {
159162
validate::args_length(&args, 0)?;
@@ -175,7 +178,7 @@ mod qfunctions {
175178

176179
pub fn find_bucket(
177180
args: Vec<DataType>,
178-
_env: &HashMap<&str, DataType>,
181+
_env: &HashMap<String, DataType>,
179182
ds: &Datastore,
180183
) -> Result<DataType, QueryError> {
181184
validate::args_length(&args, 1)?;
@@ -203,7 +206,7 @@ mod qfunctions {
203206

204207
pub fn contains(
205208
args: Vec<DataType>,
206-
_env: &HashMap<&str, DataType>,
209+
_env: &HashMap<String, DataType>,
207210
_ds: &Datastore,
208211
) -> Result<DataType, QueryError> {
209212
// typecheck
@@ -231,7 +234,7 @@ mod qfunctions {
231234

232235
pub fn flood(
233236
args: Vec<DataType>,
234-
_env: &HashMap<&str, DataType>,
237+
_env: &HashMap<String, DataType>,
235238
_ds: &Datastore,
236239
) -> Result<DataType, QueryError> {
237240
// typecheck
@@ -249,7 +252,7 @@ mod qfunctions {
249252

250253
pub fn categorize(
251254
args: Vec<DataType>,
252-
_env: &HashMap<&str, DataType>,
255+
_env: &HashMap<String, DataType>,
253256
_ds: &Datastore,
254257
) -> Result<DataType, QueryError> {
255258
// typecheck
@@ -268,7 +271,7 @@ mod qfunctions {
268271

269272
pub fn tag(
270273
args: Vec<DataType>,
271-
_env: &HashMap<&str, DataType>,
274+
_env: &HashMap<String, DataType>,
272275
_ds: &Datastore,
273276
) -> Result<DataType, QueryError> {
274277
// typecheck
@@ -287,7 +290,7 @@ mod qfunctions {
287290

288291
pub fn sort_by_duration(
289292
args: Vec<DataType>,
290-
_env: &HashMap<&str, DataType>,
293+
_env: &HashMap<String, DataType>,
291294
_ds: &Datastore,
292295
) -> Result<DataType, QueryError> {
293296
// typecheck
@@ -306,7 +309,7 @@ mod qfunctions {
306309

307310
pub fn limit_events(
308311
args: Vec<DataType>,
309-
_env: &HashMap<&str, DataType>,
312+
_env: &HashMap<String, DataType>,
310313
_ds: &Datastore,
311314
) -> Result<DataType, QueryError> {
312315
// typecheck
@@ -326,7 +329,7 @@ mod qfunctions {
326329

327330
pub fn sort_by_timestamp(
328331
args: Vec<DataType>,
329-
_env: &HashMap<&str, DataType>,
332+
_env: &HashMap<String, DataType>,
330333
_ds: &Datastore,
331334
) -> Result<DataType, QueryError> {
332335
// typecheck
@@ -345,7 +348,7 @@ mod qfunctions {
345348

346349
pub fn sum_durations(
347350
args: Vec<DataType>,
348-
_env: &HashMap<&str, DataType>,
351+
_env: &HashMap<String, DataType>,
349352
_ds: &Datastore,
350353
) -> Result<DataType, QueryError> {
351354
// typecheck
@@ -364,7 +367,7 @@ mod qfunctions {
364367

365368
pub fn merge_events_by_keys(
366369
args: Vec<DataType>,
367-
_env: &HashMap<&str, DataType>,
370+
_env: &HashMap<String, DataType>,
368371
_ds: &Datastore,
369372
) -> Result<DataType, QueryError> {
370373
// typecheck
@@ -382,7 +385,7 @@ mod qfunctions {
382385

383386
pub fn chunk_events_by_key(
384387
args: Vec<DataType>,
385-
_env: &HashMap<&str, DataType>,
388+
_env: &HashMap<String, DataType>,
386389
_ds: &Datastore,
387390
) -> Result<DataType, QueryError> {
388391
// typecheck
@@ -400,7 +403,7 @@ mod qfunctions {
400403

401404
pub fn filter_keyvals(
402405
args: Vec<DataType>,
403-
_env: &HashMap<&str, DataType>,
406+
_env: &HashMap<String, DataType>,
404407
_ds: &Datastore,
405408
) -> Result<DataType, QueryError> {
406409
// typecheck
@@ -419,7 +422,7 @@ mod qfunctions {
419422

420423
pub fn filter_period_intersect(
421424
args: Vec<DataType>,
422-
_env: &HashMap<&str, DataType>,
425+
_env: &HashMap<String, DataType>,
423426
_ds: &Datastore,
424427
) -> Result<DataType, QueryError> {
425428
// typecheck
@@ -437,7 +440,7 @@ mod qfunctions {
437440

438441
pub fn split_url_events(
439442
args: Vec<DataType>,
440-
_env: &HashMap<&str, DataType>,
443+
_env: &HashMap<String, DataType>,
441444
_ds: &Datastore,
442445
) -> Result<DataType, QueryError> {
443446
// typecheck
@@ -454,7 +457,7 @@ mod qfunctions {
454457

455458
pub fn concat(
456459
args: Vec<DataType>,
457-
_env: &HashMap<&str, DataType>,
460+
_env: &HashMap<String, DataType>,
458461
_ds: &Datastore,
459462
) -> Result<DataType, QueryError> {
460463
let mut event_list = Vec::new();
@@ -484,7 +487,7 @@ mod validate {
484487
Ok(())
485488
}
486489

487-
pub fn get_timeinterval(env: &HashMap<&str, DataType>) -> Result<TimeInterval, QueryError> {
490+
pub fn get_timeinterval(env: &HashMap<String, DataType>) -> Result<TimeInterval, QueryError> {
488491
let interval_str = match env.get("TIMEINTERVAL") {
489492
Some(data_ti) => match data_ti {
490493
DataType::String(ti_str) => ti_str,

0 commit comments

Comments
 (0)