[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: lmdb as a Lua database



On Tue, Oct 3, 2017 at 11:19 PM, Russell Haley <russ.haley@gmail.com> wrote:
> Hi,
>
> So I'm using LMDB to create a simple 'database' system for lua that
> will allow me to directly serialize and store lua table data. So far I
> have used the wonderful lmdb wrapper lightningmdb and created a simple
> API to hide some of the mechanisms.
>
> Honestly, your API is so well thought out, I'm doing a disservice by
> removing a lot of the powerful features. However, I press ahead and
> beg forgiveness. :)
>
> I have two questions:
>
> 1) There is a simplified vs cursor API. I am starting to suspect that
> the simplified functions are just basic wrappers around the cursor
> API? I ask because if this is the case, I could just remove my support
> for the simplified API and only have to support one set of functions.
>
> 2) The key lookup is blazing fast (so awesome, this thing is going to
> smoke!). I wanted to create a way of indexing the data elements within
> the database by allowing users to create lua functions that parse the
> lua table values.
> --a basic table that would be serialized into a lmdb database called t1
> t1 = {
> 1={col_a="test",col_b="item1"},
> 2={col_a="not-a-test",col_b="item2"},
> 3={col_a="test",col_b="item3"}
> }
>
> --The function that would be called per-row to create an index.
> local function(k,v)
>
>    return v.col_a, k
> end
>
> The idea would be to use the dupsort feature to create an 'index'
> database with data structured as:
>
> not-a-test, 2
> test, 1
> test, 3

Sorry, hit send in gmail by accident. Anyway, the idea is to use the
dupsort feature to create indexes. Is this feasible? Any input or
direction would be fantastic.

Thanks!
Russ