-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: replace OnceLock
with LazyLock
(round 2)
#13674
Conversation
@@ -332,13 +330,13 @@ async fn evaluate_agg_test(expr: Expr, expected_lines: Vec<&str>) { | |||
/// Converts the `Expr` to a `PhysicalExpr`, evaluates it against the provided | |||
/// `RecordBatch` and compares the result to the expected result. | |||
fn evaluate_expr_test(expr: Expr, expected_lines: Vec<&str>) { | |||
let batch = test_batch(); | |||
let batch = &TEST_BATCH; |
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.
This change also avoids a clone.
[< STATIC_ $UDAF >] | ||
.get_or_init(|| { | ||
/// Singleton instance of [$UDAF], ensures the UDAF is only created once | ||
static INSTANCE: std::sync::LazyLock<std::sync::Arc<crate::AggregateUDF>> = |
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.
Narrow the scope to inside the function, so we can use a simpler name.
}) | ||
.clone() | ||
/// Singleton instance of the function | ||
static $GNAME: std::sync::LazyLock< |
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.
$GNAME
can be removed, maybe in a follow-up PR.
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.
thank you
Which issue does this PR close?
Part of #11687
Replaced the remaining
OnceLock
s except for function Documentation instances.Rationale for this change
LazyLock provides a simpler way to define static variables.
What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No