[Mod](Lib) Lua Table Serialization Library [serialize_lib]

Post Reply
User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

[Mod](Lib) Lua Table Serialization Library [serialize_lib]

by orwell » Post

Note: this mod is not intended for end users. It is merely providing functionality to other mods. It does not add things on its own.

serialize_lib provides a way to store Lua table structures in on-disk files, similar to minetest.serialize(). It has been an integral part of advtrains for some time now, being required as an alternative to built-in functions due to its excessively large save file structure.

The main motivation behind creating serialize_lib was that minetest.deserialize() is unable to handle tables that have more than 65536 constant values when Minetest is compiled with LuaJIT. Also, since minetest.serialize() employs many string-concatenation operations creating a potentially very large string in-memory, its performance degrades significantly when serializing large tables.

Serialize_lib, in turn, can handle arbitrarily large structures, the only limit being the RAM available to the Lua environment to hold the final deserialized table. This comes at the tradeoff of using a special non-standard serialization format. Further, serialization and deserialization is only supported to and from files, not into a string.

serialize.lua included in this mod is a standard Lua module without Minetest dependencies, and thus can be loaded by any non-Minetest Lua script.

In addition to the serialization function, serialize_lib also includes helper functions to manage atomic saving even of multiple files, that is, it ensures that no data is lost even when the program crashes during saving.

License: GNU Affero GPL version 3
Zip Download: http://git.bananach.space/serialize_lib ... master.zip
Git repository: http://git.bananach.space/serialize_lib.git/
Dependencies: none

Please note that serialize_lib is included in advtrains by means of a git subtree. If you or your users run into problems because of this, please notify me.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests