Error in LMDB torch package when reading an already existing LMDB database

113 views
Skip to first unread message

Mansi Rankawat

unread,
Nov 23, 2015, 3:13:54 PM11/23/15
to torch7
Hi,

I am trying to use this package (https://github.com/eladhoffer/lmdb.torch) to read an already existing LMDB database. However when I do so I get the following error:

Error in LMDB function mdb_get : MDB_NOTFOUND: No matching key/data pair found


Here is my code for reading the database:

local db=lmdb.env{

Path = './data/CamVid-train-lmdb',

Name = 'CamVid-train-lmdb'

}

rows=367


db:open()

local reader = db:txn(true)

inputs=torch.Tensor(rows,1,240,320)

for i=1,rows do

        inputs[i]=reader:get(tostring(i))

end

reader:abort()

db:close()



Thanks

Mansi

Greg Heinrich

unread,
Nov 29, 2015, 11:16:47 AM11/29/15
to torch7
Hi, are you certain the keys in your database are named "1", "2", etc. as your code implies?
If you don't know the keys and wish to read all rows, you can create a cursor and iterate using the MDB_NEXT operator:

cursor = reader:cursor()
repeat
   k,v = cursor:get(k,lmdb.MDB_NEXT)
   -- do something with your key/value pair
until (not k)
Reply all
Reply to author
Forward
0 new messages