ravi
ravi

Reputation: 6328

Fast serialize / deserialize table (no recursion) in Lua

I am using Lua 5.2. I am receiving large tables (1-dimensional array) of size 800,000. I want to dump these tables quickly. I found an article on wiki titled Save Table To File and used it but found not up to the mark. A sample table saved using this method, i.e., table.save(table, filename) is shared in my DropBox here. (File is too large to put here. 8MB approx)

Since my primary concern is speed, I am ready to adopt binary serialization if such exists.

Upvotes: 0

Views: 759

Answers (1)

brianolive
brianolive

Reputation: 1671

Are you bound to Lua 5.2? 5.3 introduced bitwise operators and built-in binary pack/unpack operations (see chapter 13, “Bits and Bytes”, of Programming in Lua, 4th edition). There are also specific algorithms and recommendations for serializing tables in chapter 15, “Data Files and Serialization”. These chapters will be your best source of information for a proper implementation.

Upvotes: 1

Related Questions