-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move NodeId Generation to a separate crate (#484)
Moves the `NodeId` and its Id generation to a new crate, `partiql-common` so that it can get consumed by multiple crates. --------- Co-authored-by: Josh Pschorr <[email protected]>
- Loading branch information
Showing
29 changed files
with
164 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#![deny(rust_2018_idioms)] | ||
#![deny(clippy::all)] | ||
pub mod node; | ||
pub mod syntax; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use indexmap::IndexMap; | ||
use std::hash::Hash; | ||
|
||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub type NodeMap<T> = IndexMap<NodeId, T>; | ||
|
||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct NodeId(pub u32); | ||
|
||
/// Auto-incrementing [`NodeIdGenerator`] | ||
pub struct AutoNodeIdGenerator { | ||
next_id: NodeId, | ||
} | ||
|
||
impl Default for AutoNodeIdGenerator { | ||
fn default() -> Self { | ||
AutoNodeIdGenerator { next_id: NodeId(1) } | ||
} | ||
} | ||
|
||
/// A provider of 'fresh' [`NodeId`]s. | ||
pub trait NodeIdGenerator { | ||
/// Provides a 'fresh' [`NodeId`]. | ||
fn id(&mut self) -> NodeId; | ||
} | ||
|
||
impl NodeIdGenerator for AutoNodeIdGenerator { | ||
#[inline] | ||
fn id(&mut self) -> NodeId { | ||
let mut next = NodeId(&self.next_id.0 + 1); | ||
std::mem::swap(&mut self.next_id, &mut next); | ||
next | ||
} | ||
} | ||
|
||
/// A provider of [`NodeId`]s that are always `0`; Useful for testing | ||
#[derive(Default)] | ||
pub struct NullIdGenerator {} | ||
|
||
impl NodeIdGenerator for NullIdGenerator { | ||
fn id(&mut self) -> NodeId { | ||
NodeId(0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e5b8ce7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PartiQL (rust) Benchmark
arith_agg-avg
775198
ns/iter (± 34461
)769347
ns/iter (± 8086
)1.01
arith_agg-avg_distinct
856544
ns/iter (± 5154
)864631
ns/iter (± 3111
)0.99
arith_agg-count
820861
ns/iter (± 18988
)817735
ns/iter (± 44170
)1.00
arith_agg-count_distinct
852867
ns/iter (± 4970
)859871
ns/iter (± 16448
)0.99
arith_agg-min
827041
ns/iter (± 2639
)823541
ns/iter (± 16473
)1.00
arith_agg-min_distinct
860210
ns/iter (± 10560
)860789
ns/iter (± 3429
)1.00
arith_agg-max
835593
ns/iter (± 3961
)828686
ns/iter (± 1915
)1.01
arith_agg-max_distinct
864949
ns/iter (± 4270
)867876
ns/iter (± 32406
)1.00
arith_agg-sum
824926
ns/iter (± 1621
)824516
ns/iter (± 3833
)1.00
arith_agg-sum_distinct
857067
ns/iter (± 1983
)868788
ns/iter (± 2851
)0.99
arith_agg-avg-count-min-max-sum
968375
ns/iter (± 8380
)965437
ns/iter (± 13827
)1.00
arith_agg-avg-count-min-max-sum-group_by
1204293
ns/iter (± 13453
)1203160
ns/iter (± 24930
)1.00
arith_agg-avg-count-min-max-sum-group_by-group_as
1801364
ns/iter (± 31255
)1805354
ns/iter (± 41273
)1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct
1229000
ns/iter (± 13263
)1264656
ns/iter (± 12802
)0.97
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by
1508448
ns/iter (± 9427
)1550278
ns/iter (± 24933
)0.97
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as
2098733
ns/iter (± 10245
)2145855
ns/iter (± 41224
)0.98
parse-1
5619
ns/iter (± 23
)5378
ns/iter (± 84
)1.04
parse-15
48240
ns/iter (± 118
)46773
ns/iter (± 120
)1.03
parse-30
93707
ns/iter (± 250
)91519
ns/iter (± 268
)1.02
compile-1
4326
ns/iter (± 10
)4321
ns/iter (± 23
)1.00
compile-15
33011
ns/iter (± 270
)33227
ns/iter (± 112
)0.99
compile-30
68472
ns/iter (± 296
)69079
ns/iter (± 1950
)0.99
plan-1
66983
ns/iter (± 261
)67288
ns/iter (± 1696
)1.00
plan-15
1047620
ns/iter (± 5242
)1050445
ns/iter (± 41700
)1.00
plan-30
2101187
ns/iter (± 26131
)2102844
ns/iter (± 19876
)1.00
eval-1
13463456
ns/iter (± 113930
)13304642
ns/iter (± 223004
)1.01
eval-15
91368497
ns/iter (± 276047
)86429143
ns/iter (± 2425132
)1.06
eval-30
174268173
ns/iter (± 529438
)166575250
ns/iter (± 2418779
)1.05
join
9998
ns/iter (± 152
)9850
ns/iter (± 102
)1.02
simple
2479
ns/iter (± 11
)2502
ns/iter (± 9
)0.99
simple-no
428
ns/iter (± 5
)423
ns/iter (± 2
)1.01
numbers
57
ns/iter (± 0
)57
ns/iter (± 0
)1
parse-simple
717
ns/iter (± 5
)775
ns/iter (± 9
)0.93
parse-ion
2263
ns/iter (± 5
)2398
ns/iter (± 5
)0.94
parse-group
7145
ns/iter (± 31
)6958
ns/iter (± 23
)1.03
parse-complex
18704
ns/iter (± 58
)18549
ns/iter (± 418
)1.01
parse-complex-fexpr
25839
ns/iter (± 81
)25695
ns/iter (± 131
)1.01
This comment was automatically generated by workflow using github-action-benchmark.