Ensure function arguments are processed concurrently
This commit is contained in:
parent
1e93c0f304
commit
94cdef565f
1 changed files with 12 additions and 11 deletions
|
@ -9,6 +9,7 @@ use crate::sql::error::IResult;
|
||||||
use crate::sql::fmt::Fmt;
|
use crate::sql::fmt::Fmt;
|
||||||
use crate::sql::script::{script as func, Script};
|
use crate::sql::script::{script as func, Script};
|
||||||
use crate::sql::value::{single, value, Value};
|
use crate::sql::value::{single, value, Value};
|
||||||
|
use futures::future::try_join_all;
|
||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::char;
|
use nom::character::complete::char;
|
||||||
|
@ -117,25 +118,25 @@ impl Function {
|
||||||
// Process the function type
|
// Process the function type
|
||||||
match self {
|
match self {
|
||||||
Self::Cast(s, x) => {
|
Self::Cast(s, x) => {
|
||||||
let v = x.compute(ctx, opt, txn, doc).await?;
|
// Compute the value to be cast
|
||||||
fnc::cast::run(ctx, s, v)
|
let a = x.compute(ctx, opt, txn, doc).await?;
|
||||||
|
// Run the cast function
|
||||||
|
fnc::cast::run(ctx, s, a)
|
||||||
}
|
}
|
||||||
Self::Normal(s, x) => {
|
Self::Normal(s, x) => {
|
||||||
let mut a: Vec<Value> = Vec::with_capacity(x.len());
|
// Compute the function arguments
|
||||||
for v in x {
|
let a = try_join_all(x.iter().map(|v| v.compute(ctx, opt, txn, doc))).await?;
|
||||||
a.push(v.compute(ctx, opt, txn, doc).await?);
|
// Run the normal function
|
||||||
}
|
|
||||||
fnc::run(ctx, s, a).await
|
fnc::run(ctx, s, a).await
|
||||||
}
|
}
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
Self::Script(s, x) => {
|
Self::Script(s, x) => {
|
||||||
#[cfg(feature = "scripting")]
|
#[cfg(feature = "scripting")]
|
||||||
{
|
{
|
||||||
let mut a: Vec<Value> = Vec::with_capacity(x.len());
|
// Compute the function arguments
|
||||||
for v in x {
|
let a = try_join_all(x.iter().map(|v| v.compute(ctx, opt, txn, doc))).await?;
|
||||||
a.push(v.compute(ctx, opt, txn, doc).await?);
|
// Run the script function
|
||||||
}
|
fnc::script::run(ctx, opt, txn, doc, s, a).await
|
||||||
fnc::script::run(ctx, doc, s, a).await
|
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "scripting"))]
|
#[cfg(not(feature = "scripting"))]
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue