Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightningmdb serpent #4

Open
vstath opened this issue May 8, 2018 · 3 comments
Open

lightningmdb serpent #4

vstath opened this issue May 8, 2018 · 3 comments

Comments

@vstath
Copy link

vstath commented May 8, 2018

Hello,

I'm trying to familiarize with your software (found it via an openldap email of yours) but I hit a wall. Any pointers?

I've done:

export LUA_PATH=/root/lbdm/lua-persist/?.lua";;"

Cloned, compiled and installed LMDB libraries https://github.com/LMDB/lmdb.git
Installed luarocks as mentioned in the README (lfs = luafilesystem, I assume?)

luarocks install luafilesystem lightningmdb serpent

and run your tests:

root@blog:~/lbdm/lua-persist/test# lua db-test.lua 
lua: /root/lbdm/lua-persist/persist.lua:177: attempt to index upvalue 'lightningmdb' (a boolean value)
stack traceback:
	/root/lbdm/lua-persist/persist.lua:177: in function </root/lbdm/lua-persist/persist.lua:167>
	(tail call): ?
	db-test.lua:16: in main chunk
	[C]: ?
root@blog:~/lbdm/lua-persist/test# lua insert-random-data.lua 
lua: /root/lbdm/lua-persist/persist.lua:177: attempt to index upvalue 'lightningmdb' (a boolean value)
stack traceback:
	/root/lbdm/lua-persist/persist.lua:177: in function </root/lbdm/lua-persist/persist.lua:167>
	(tail call): ?
	insert-random-data.lua:7: in main chunk
	[C]: ?
root@blog:~/lbdm/lua-persist/test# 

My version of Lua is

Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio

Any help is appreciated.

@RussellHaley
Copy link
Owner

Hi! Far out. I assumed all this stuff was going to /dev/null. (tee hee.)

First, this is only tested against 5.3 so no guarantees, but happy to take a look. Second, I've been away from this for a couple of months now so I'll need a little bit to pick it up again. And third, It's all still very alpha level.

I'll get my head into it tonight and hopefully have something soon. 👍

@RussellHaley
Copy link
Owner

RussellHaley commented May 9, 2018

So I had marked the lightningmdb library to only run on 5.2 or greater. I have no idea why, as the readme on https://github.com/shmul/lightningmdb indicates it runs on 5.1 as well. I pushed that fix (2351b89), but you're not out of the woods yet.

I rely heavily on meta-tables for the change tracking and I fear I'm not very good at them. If you run db-test.lua in 5.3 it returns the correct results. If you run it in 5.1, the code seems to commit everything to the database, but the output seem to be meta-table functions:

russellh@g1 ~/G/lua-persist> lua53 test/db-test.lua 
Words db init table count 3
readonly disabled
boys names: 7.0
readonly disabled
Christopher	1
William	1
Richard	1
Joeseph	1
Stephen	1
Adam	1
Russell	1
readonly disabled
Christopher	1
William	1
Richard	1
Joeseph	1
Stephen	1
Adam	1
Russell	1
count two 3
Numbers Database Count 2
{
  __databases = true,
  ["insurance-policies"] = true
} --[[table: 0x80169e140]]

russellh@g1 ~/G/lua-persist> lua51 test/db-test.lua 
Words db init table count 3
readonly disabled
boys names: 7
readonly disabled
commit	function: 0x8018df970
status	function: 0x8018df9d0
readonly disabled
commit	function: 0x8018dfdc0
status	function: 0x8018dfe20
count two 3
Numbers Database Count 2
{
  __databases = true,
  ["insurance-policies"] = true
} --[[table: 0x8018bfe80]]

To create a 'changetracker' table, I set the actual table to read only and return a proxy table. See database.lua starting at line 407. Note the proxy table has functions named commit and status (lines 517 and 519). I'm not sure what to do about that as I don't play in 5.1.

Thoughts?

@vstath
Copy link
Author

vstath commented May 18, 2018

I just saw this update. I will look into this tomorrow. I appreciate your responses.

I'm not much of a Lua person but I will try to play and see the differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants