cscalalibrariesg-waninterfacing

How to hold data structures in memory G-wan with Java / Scala


I am looking at Gwan as a higher performance way to run our Scala application. Our use-case involves keeping a good amount of data in memory using Scala data structures. This is a bit more complex than a simple hashmap so I would want to avoid trying to wedge it into the K/V store that comes with Gwan.

Also there are a number of C-libraries that would be great to interface with. Curious what the process of using a third party C-library with a Scala app on Gwan would be.

Thanks!


Solution

  • keeping a good amount of data in memory using Scala data structures

    The easiest way to attach Scala data structures to G-WAN servlets is to use the G-WAN persistence pointers, see the persistence.c example.

    For the sake of the discussion, G-WAN KV store is not using hash tables (nor any hashing by the way, to avoid large unused memory and entry collisions).

    what the process of using a third party C-library with a Scala app on Gwan would be

    If you want to call a C function (either from a servlet or from a pre-compiled C library) from a Scala G-WAN script then you can just pick the function pointer (from a handler for example), register it by attaching it to a G-WAN persistent pointer, and then invoke it later (from your Scala scripts).

    Or you can dynamically load a pre-compiled C library from your Scala scripts, resolve the function name (only once at startup), and then call it many times.