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

落花浮王杯 提交于 2020-01-04 06:24:08

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/17281117/how-to-hold-data-structures-in-memory-g-wan-with-java-scala

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!