mirror of
https://github.com/netfun2000/ip2region.git
synced 2026-02-27 09:44:31 +08:00
return err for buffer functions
This commit is contained in:
@@ -65,11 +65,15 @@ end
|
||||
-- create the searcher based on the cache-policy
|
||||
local searcher, v_index, content
|
||||
if cachePolicy == "file" then
|
||||
searcher = xdb.new_with_file_only(dbFile)
|
||||
searcher, err = xdb.new_with_file_only(dbFile)
|
||||
if err ~= nil then
|
||||
print(string.format("failed to create searcher: %s", err))
|
||||
return
|
||||
end
|
||||
elseif cachePolicy == "vectorIndex" then
|
||||
v_index = xdb.load_vector_index(dbFile)
|
||||
if v_index == nil then
|
||||
print(string.format("failed to load vector index from '%s'", dbFile))
|
||||
v_index, err = xdb.load_vector_index(dbFile)
|
||||
if err ~= nil then
|
||||
print(string.format("failed to load vector index: %s", err))
|
||||
return
|
||||
end
|
||||
|
||||
@@ -79,8 +83,8 @@ elseif cachePolicy == "vectorIndex" then
|
||||
return
|
||||
end
|
||||
elseif cachePolicy == "content" then
|
||||
content = xdb.load_content(dbFile)
|
||||
if content == nil then
|
||||
content, err = xdb.load_content(dbFile)
|
||||
if err ~= nil then
|
||||
print(string.format("failed to load xdb content from '%s'", dbFile))
|
||||
return
|
||||
end
|
||||
@@ -174,4 +178,4 @@ if count > 0 then
|
||||
avg_costs = c_time / count
|
||||
end
|
||||
print(string.format("Bench finished, {cachePolicy: %s, total: %d, took: %.3f s, cost: %.3f μs/op}",
|
||||
cachePolicy, count, (xdb.now() - s_time)/1e6, c_time / count))
|
||||
cachePolicy, count, (xdb.now() - s_time)/1e6, c_time / count))
|
||||
Reference in New Issue
Block a user