require 'lmdb'require 'xlua'
cmd = torch.CmdLine()cmd:option('-rows',3333,'Number of samples')cmd:option('-cols',2,'Number of dimensions')opt = cmd:parse(arg or {})
db= lmdb.env{ Path = './testDB', Name = 'testDB' }
db:open()txn = db:txn() --Write transactionx=torch.Tensor(opt.rows,opt.cols):byte():fill(10)-------Write-------for i=1,opt.rows,1 do xlua.progress(i,opt.rows) txn:put(i,x[i])endtxn:commit()
print("Writing done")print('db : '..db:stat().entries)print("Reading now")
reader = db:txn(true) --Read-only transactiony = {}-------Read-------for i=1,opt.rows,1 do xlua.progress(i,opt.rows) value = reader:get(i) table.insert(y,value)end
print('x : '..x:size(1))print('y : '..#y)
reader:abort()db:close()Error in LMDB function mdb_get : .......MDB_NOTFOUND: No matching key/data pair found
--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at http://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.
Hey Riddhiman,I dont get the errrors that you see. This is my output when I run the script:th lmt.lua[================================================================================================== 3333/3333 ==============================================================================================>] ETA: 0ms | Step: 0msWriting donedb : 3333Reading now[================================================================================================== 3333/3333 ==============================================================================================>] ETA: 0ms | Step: 0msx : 3333y : 3333I am using lmdb-0.9.14 and latest lmdb.torch
$ rm -rf testDB/; th lmdb.lua -rows 4000 -cols 5
Error in LMDB function mdb_cursor_get : MDB_NOTFOUND: No matching key/data pair found
[============================================================== 4000/4000 =========================================================>] ETA: 0ms | Step: 0ms Writing done db : 3998 Reading now Error in LMDB function mdb_cursor_get : ........MDB_NOTFOUND: No matching key/data pair found........................................] ETA: 692ms | Step: 0ms Error in LMDB function mdb_get : MDB_NOTFOUND: No matching key/data pair found /torch/install/bin/luajit: inconsistent tensor size at /torch/pkg/torch/lib/TH/generic/THTensorCopy.c:16stack traceback: [C]: at 0x7f2b3384e3c0 [C]: in function '__newindex' lmdb.lua:48: in main chunk [C]: in function 'dofile' ...iman/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:133: in main chunk [C]: at 0x00406670Segmentation fault (core dumped)Hey Riddhiman,I dont get the errrors that you see. This is my output when I run the script:th lmt.lua[================================================================================================== 3333/3333 ==============================================================================================>] ETA: 0ms | Step: 0msWriting donedb : 3333Reading now[================================================================================================== 3333/3333 ==============================================================================================>] ETA: 0ms | Step: 0msx : 3333y : 3333I am using lmdb-0.9.14 and latest lmdb.torch
On Monday, October 19, 2015 at 10:29:54 AM UTC+5:30, smth chntla wrote:It seems that lmdb doesn't like the keys to be doubles. I converted the keys to be strings and it was happy:
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