Skip to content

Commit

Permalink
Merge pull request #692 from gheinrich/dev/default-to-lua-table-for-keys
Browse files Browse the repository at this point in the history
Default to Lua table if tds not installed
  • Loading branch information
lukeyeager committed Apr 25, 2016
2 parents c5f47fe + c96d52d commit 55b9656
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/torch/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package.path = debug.getinfo(1, "S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua
require 'logmessage'
local ffi = require 'ffi'

local tds = check_require 'tds'
local tdsIsInstalled, tds = pcall(function() return check_require 'tds' end)

-- enable shared serialization to speed up Tensor passing between threads
threads.Threads.serialization('threads.sharedserialize')
Expand Down Expand Up @@ -322,7 +322,14 @@ end

-- Derived class method lmdb_getKeys
function DBSource:lmdb_getKeys ()
local Keys = tds.Vec()
local Keys
if tdsIsInstalled then
-- use tds.Vec() to allocate memory outside of Lua heap
Keys = tds.Vec()
else
-- if tds is not installed, use regular table (and Lua memory allocator)
Keys = {}
end
local i=0
local key=nil
for k,v in all_keys(self.lmdb_data.c,nil,self.lightningmdb.MDB_NEXT) do
Expand Down

0 comments on commit 55b9656

Please sign in to comment.