Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Ip2region
提交
25572716
I
Ip2region
项目概览
int
/
Ip2region
上一次同步 大约 1 年
通知
20
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Ip2region
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
25572716
编写于
7月 06, 2022
作者:
L
Lion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
return err for buffer functions
上级
7c588b9c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
37 addition
and
21 deletion
+37
-21
binding/lua_c/bench_test.lua
binding/lua_c/bench_test.lua
+11
-7
binding/lua_c/search_test.lua
binding/lua_c/search_test.lua
+5
-5
binding/lua_c/xdb_searcher.c
binding/lua_c/xdb_searcher.c
+21
-9
未找到文件。
binding/lua_c/bench_test.lua
浏览文件 @
25572716
...
...
@@ -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
...
...
binding/lua_c/search_test.lua
浏览文件 @
25572716
...
...
@@ -68,9 +68,9 @@ if cachePolicy == "file" then
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
...
...
@@ -80,8 +80,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
...
...
binding/lua_c/xdb_searcher.c
浏览文件 @
25572716
...
...
@@ -152,13 +152,16 @@ static int lua_xdb_load_header_from_file(lua_State *L) {
header
=
xdb_load_header_from_file
(
db_path
);
if
(
header
==
NULL
)
{
lua_pushnil
(
L
);
return
1
;
lua_pushfstring
(
L
,
"load header from `%s`"
,
db_path
);
return
2
;
}
// alloc the buffer.
buffer
=
(
xdb_buffer_t
*
)
lua_newuserdata
(
L
,
sizeof
(
xdb_buffer_t
));
if
(
buffer
==
NULL
)
{
return
luaL_error
(
L
,
"failed to alloc xdb buffer entry"
);
lua_pushnil
(
L
);
lua_pushfstring
(
L
,
"failed to alloc xdb buffer entry"
);
return
2
;
}
// init the buffer
...
...
@@ -170,8 +173,9 @@ static int lua_xdb_load_header_from_file(lua_State *L) {
// set the metatable of the header buffer object and push onto the stack
luaL_getmetatable
(
L
,
XDB_BUFFER_METATABLE_NAME
);
lua_setmetatable
(
L
,
-
2
);
lua_pushnil
(
L
);
return
1
;
return
2
;
}
static
int
lua_xdb_load_vector_index_from_file
(
lua_State
*
L
)
{
...
...
@@ -184,13 +188,16 @@ static int lua_xdb_load_vector_index_from_file(lua_State *L) {
v_index
=
xdb_load_vector_index_from_file
(
db_path
);
if
(
v_index
==
NULL
)
{
lua_pushnil
(
L
);
return
1
;
lua_pushfstring
(
L
,
"load vector index from `%s`"
,
db_path
);
return
2
;
}
// alloc the buffer.
buffer
=
(
xdb_buffer_t
*
)
lua_newuserdata
(
L
,
sizeof
(
xdb_buffer_t
));
if
(
buffer
==
NULL
)
{
return
luaL_error
(
L
,
"failed to alloc xdb buffer entry"
);
lua_pushnil
(
L
);
lua_pushstring
(
L
,
"failed to alloc xdb buffer entry"
);
return
2
;
}
// init the buffer
...
...
@@ -202,8 +209,9 @@ static int lua_xdb_load_vector_index_from_file(lua_State *L) {
// set the metatable of the header buffer object and push onto the stack
luaL_getmetatable
(
L
,
XDB_BUFFER_METATABLE_NAME
);
lua_setmetatable
(
L
,
-
2
);
lua_pushnil
(
L
);
return
1
;
return
2
;
}
static
int
lua_xdb_load_content_from_file
(
lua_State
*
L
)
{
...
...
@@ -216,13 +224,16 @@ static int lua_xdb_load_content_from_file(lua_State *L) {
content
=
xdb_load_content_from_file
(
db_path
);
if
(
content
==
NULL
)
{
lua_pushnil
(
L
);
return
1
;
lua_pushfstring
(
L
,
"load xdb content from `%s`"
,
db_path
);
return
2
;
}
// alloc the buffer.
buffer
=
(
xdb_buffer_t
*
)
lua_newuserdata
(
L
,
sizeof
(
xdb_buffer_t
));
if
(
buffer
==
NULL
)
{
return
luaL_error
(
L
,
"failed to alloc xdb buffer entry"
);
lua_pushnil
(
L
);
lua_pushstring
(
L
,
"failed to alloc xdb buffer entry"
);
return
2
;
}
// init the buffer
...
...
@@ -234,8 +245,9 @@ static int lua_xdb_load_content_from_file(lua_State *L) {
// set the metatable of the header buffer object and push onto the stack
luaL_getmetatable
(
L
,
XDB_BUFFER_METATABLE_NAME
);
lua_setmetatable
(
L
,
-
2
);
lua_pushnil
(
L
);
return
1
;
return
2
;
}
// --- End of buffer api
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录