Giter Site home page Giter Site logo

Comments (6)

petar-dambovaliev avatar petar-dambovaliev commented on June 12, 2024 1

It would be nice if the UDFs were not just strings but went through a macro that enforced the aerospike rules for Lua.
It would bring runtime errors into compile time.

from aerospike-client-rust.

petar-dambovaliev avatar petar-dambovaliev commented on June 12, 2024

Macros for collections like as_list and as_map do not create the collections with the known length.
This results in multiple unnecessary allocations.

from aerospike-client-rust.

khaf avatar khaf commented on June 12, 2024

Thanks Petar for your feedback, please keep them coming.

from aerospike-client-rust.

petar-dambovaliev avatar petar-dambovaliev commented on June 12, 2024

Some functions' arguments have improper names, where bin: &str should actually be bin_name: &str or udf_name: &str where it should be module: &str or something like that. Naming is not super important but it can be confusing in the beginning, when you are trying to figure out how this client works.

For example

pub async fn execute_udf(
        &self,
        policy: &WritePolicy,
        key: &Key,
        udf_name: &str,
        function_name: &str,
        args: Option<&[Value]>,
    )

Inside the body of this function, udf_name is actually passed onto as package_name.

from aerospike-client-rust.

petar-dambovaliev avatar petar-dambovaliev commented on June 12, 2024

It would be nice if the UDFs were not just strings but went through a macro that enforced the aerospike rules for Lua. It would bring runtime errors into compile time.

To expand on this, the macro can also generate a rust function with the same name as the Lua function.
So instead of calling it like

client
        .execute_udf(
            &WritePolicy::default(),
            &key,
            "map_merge",
            "map_merge",
            Some(&[as_val!(2)]),
        )
        .await;

you will call it like

map_merge(client, &WritePolicy::default(), as_val!(2)]).await

Which will push more errors into compile time, like incorrect arguments.

from aerospike-client-rust.

petar-dambovaliev avatar petar-dambovaliev commented on June 12, 2024

This enum was defined with the idea that there would be more than 1 language and possible additions in the future.
However, with this definition, adding another variant is a breaking change.
It is not clear how big of a problem that is, but still.
Adding #[non_exhaustive] would be good.

/// User-defined function (UDF) language
#[derive(Debug)]
pub enum UDFLang {
    /// Lua embedded programming language.
    Lua,
}

from aerospike-client-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.