GithubHelp home page GithubHelp logo

Comments (3)

dahlbaek avatar dahlbaek commented on July 20, 2024

While working on #3 I ran into

static SERIALIZED_FNS: Lazy<Mutex<HashMap<String, Box<dyn Any + Sync + Send>>>> =
Lazy::new(|| Mutex::new(HashMap::new()));
pub fn serialize_fn<T: Any + Sync + Send>(obj: Box<T>) -> String {
let mut serialized_fns = SERIALIZED_FNS.lock().unwrap();
let name = format!("object{}", serialized_fns.len());
serialized_fns.insert(name.to_string(), obj);
name
}
pub fn deserialize_fn<T: Any + Sync + Send>(name: &String) -> Option<&'static T> {
let binding = SERIALIZED_FNS.lock().unwrap();
let untyped = binding.get(name);
let typed = match untyped {
Some(x) => x.downcast_ref::<T>(),
None => None,
};

which made debugging somewhat tedious. As far as I can tell it's an unnecessary indirection 🤔 it seems to me a more idiomatic solution in Rust would be to make Transformations/Operators generic as needed so they can carry the closures directly, which should make it possible to remove a lot of the current usage of Box/Any. Do you agree @laysakura, or is there something I've misunderstood?

from beam.

laysakura avatar laysakura commented on July 20, 2024

@dahlbaek I definitely agree with you!

from beam.

laysakura avatar laysakura commented on July 20, 2024

Found out that statically-typed pipelines (including user-defined types) are unrealistic via:

from beam.

Related Issues (16)

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.