Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
76f70feb
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
76f70feb
编写于
12月 20, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add index TFile
上级
21d6ba86
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
128 addition
and
9 deletion
+128
-9
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+2
-0
source/libs/index/inc/index_cache.h
source/libs/index/inc/index_cache.h
+1
-1
source/libs/index/inc/index_tfile.h
source/libs/index/inc/index_tfile.h
+46
-0
source/libs/index/src/index.c
source/libs/index/src/index.c
+45
-5
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+3
-3
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+31
-0
未找到文件。
source/libs/index/inc/indexInt.h
浏览文件 @
76f70feb
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
enum
{
kTypeValue
,
kTypeDeletion
}
STermValueType
;
typedef
struct
SIndexStat
{
typedef
struct
SIndexStat
{
int32_t
totalAdded
;
//
int32_t
totalAdded
;
//
int32_t
totalDeled
;
//
int32_t
totalDeled
;
//
...
...
source/libs/index/inc/index_cache.h
浏览文件 @
76f70feb
...
@@ -44,7 +44,7 @@ void indexCacheDestroy(void *cache);
...
@@ -44,7 +44,7 @@ void indexCacheDestroy(void *cache);
int
indexCachePut
(
void
*
cache
,
SIndexTerm
*
term
,
int16_t
colId
,
int32_t
version
,
uint64_t
uid
);
int
indexCachePut
(
void
*
cache
,
SIndexTerm
*
term
,
int16_t
colId
,
int32_t
version
,
uint64_t
uid
);
//int indexCacheGet(void *cache, uint64_t *rst);
//int indexCacheGet(void *cache, uint64_t *rst);
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
int16_t
colId
,
int32_t
version
,
SArray
*
result
);
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
int16_t
colId
,
int32_t
version
,
SArray
*
result
,
STermValueType
*
s
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/index/inc/index_tfile.h
0 → 100644
浏览文件 @
76f70feb
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __INDEX_TFILE_H__
#define __INDEX_TFILE_H__
#include "index.h"
#include "indexInt.h"
#include "tlockfree.h"
#include "tskiplist.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
IndexTFile
{
T_REF_DECLARE
()
}
IndexTFile
;
IndexTFile
*
indexTFileCreate
();
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SArray
*
result
);
#ifdef __cplusplus
}
#endif
#endif
source/libs/index/src/index.c
浏览文件 @
76f70feb
...
@@ -16,13 +16,19 @@
...
@@ -16,13 +16,19 @@
#include "index.h"
#include "index.h"
#include "indexInt.h"
#include "indexInt.h"
#include "index_cache.h"
#include "index_cache.h"
#include "index_tfile.h"
#include "tdef.h"
#include "tdef.h"
#ifdef USE_LUCENE
#ifdef USE_LUCENE
#include "lucene++/Lucene_c.h"
#include "lucene++/Lucene_c.h"
#endif
#endif
static
int
uidCompare
(
const
void
*
a
,
const
void
*
b
)
{
uint64_t
u1
=
*
(
uint64_t
*
)
a
;
uint64_t
u2
=
*
(
uint64_t
*
)
b
;
if
(
u1
==
u2
)
{
return
0
;
}
else
{
return
u1
<
u2
?
-
1
:
1
;
}
}
typedef
struct
SIdxColInfo
{
typedef
struct
SIdxColInfo
{
int
colId
;
// generated by index internal
int
colId
;
// generated by index internal
int
cVersion
;
int
cVersion
;
...
@@ -273,9 +279,44 @@ void indexMultiTermDestroy(SIndexMultiTerm *terms) {
...
@@ -273,9 +279,44 @@ void indexMultiTermDestroy(SIndexMultiTerm *terms) {
void
indexInit
()
{
void
indexInit
()
{
//do nothing
//do nothing
}
}
static
int
indexTermSearch
(
SIndex
*
sIdx
,
SIndexTermQuery
*
term
,
SArray
**
result
)
{
static
int
indexTermSearch
(
SIndex
*
sIdx
,
SIndexTermQuery
*
query
,
SArray
**
result
)
{
int32_t
version
=
-
1
;
int16_t
colId
=
-
1
;
SIdxColInfo
*
colInfo
=
NULL
;
SIndexTerm
*
term
=
query
->
term
;
const
char
*
colName
=
term
->
colName
;
int32_t
nColName
=
term
->
nColName
;
pthread_mutex_lock
(
&
sIdx
->
mtx
);
colInfo
=
taosHashGet
(
sIdx
->
colObj
,
colName
,
nColName
);
if
(
colInfo
==
NULL
)
{
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
return
-
1
;
}
colId
=
colInfo
->
colId
;
version
=
colInfo
->
cVersion
;
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
return
0
;
*
result
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
//TODO: iterator mem and tidex
STermValueType
s
;
if
(
0
==
indexCacheSearch
(
sIdx
->
cache
,
query
,
colId
,
version
,
*
result
,
&
s
))
{
if
(
s
==
kTypeDeletion
)
{
indexInfo
(
"col: %s already drop by other opera"
,
term
->
colName
);
// coloum already drop by other oper, no need to query tindex
return
0
;
}
else
{
if
(
0
!=
indexTFileSearch
(
sIdx
->
tindex
,
query
,
*
result
))
{
indexError
(
"corrupt at index(TFile) col:%s val: %s"
,
term
->
colName
,
term
->
colVal
);
return
-
1
;
}
}
}
else
{
indexError
(
"corrupt at index(cache) col:%s val: %s"
,
term
->
colName
,
term
->
colVal
);
return
-
1
;
}
return
0
;
}
}
static
void
indexInterResultsDestroy
(
SArray
*
results
)
{
static
void
indexInterResultsDestroy
(
SArray
*
results
)
{
if
(
results
==
NULL
)
{
return
;
}
if
(
results
==
NULL
)
{
return
;
}
...
@@ -291,8 +332,7 @@ static void indexInterResultsDestroy(SArray *results) {
...
@@ -291,8 +332,7 @@ static void indexInterResultsDestroy(SArray *results) {
static
int
indexMergeFinalResults
(
SArray
*
interResults
,
EIndexOperatorType
oType
,
SArray
*
fResults
)
{
static
int
indexMergeFinalResults
(
SArray
*
interResults
,
EIndexOperatorType
oType
,
SArray
*
fResults
)
{
//refactor, merge interResults into fResults by oType
//refactor, merge interResults into fResults by oType
SArray
*
first
=
taosArrayGetP
(
interResults
,
0
);
SArray
*
first
=
taosArrayGetP
(
interResults
,
0
);
taosArraySort
(
first
,
uidCompare
);
//taosArraySort(first, getCom)
if
(
oType
==
MUST
)
{
if
(
oType
==
MUST
)
{
}
else
if
(
oType
==
SHOULD
)
{
}
else
if
(
oType
==
SHOULD
)
{
...
...
source/libs/index/src/index_cache.c
浏览文件 @
76f70feb
...
@@ -46,7 +46,7 @@ static int32_t compareKey(const void *l, const void *r) {
...
@@ -46,7 +46,7 @@ static int32_t compareKey(const void *l, const void *r) {
rp
+=
sizeof
(
rf
);
rp
+=
sizeof
(
rf
);
// compare field type
// compare field type
int
16
_t
lft
,
rft
;
int
8
_t
lft
,
rft
;
memcpy
(
&
lft
,
lp
,
sizeof
(
lft
));
memcpy
(
&
lft
,
lp
,
sizeof
(
lft
));
memcpy
(
&
rft
,
rp
,
sizeof
(
rft
));
memcpy
(
&
rft
,
rp
,
sizeof
(
rft
));
lp
+=
sizeof
(
lft
);
lp
+=
sizeof
(
lft
);
...
@@ -149,7 +149,7 @@ int indexCacheDel(void *cache, int32_t fieldId, const char *fieldValue, int32_t
...
@@ -149,7 +149,7 @@ int indexCacheDel(void *cache, int32_t fieldId, const char *fieldValue, int32_t
IndexCache
*
pCache
=
cache
;
IndexCache
*
pCache
=
cache
;
return
0
;
return
0
;
}
}
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
int16_t
colId
,
int32_t
version
,
SArray
*
result
)
{
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
int16_t
colId
,
int32_t
version
,
SArray
*
result
,
STermValueType
*
s
)
{
if
(
cache
==
NULL
)
{
return
-
1
;
}
if
(
cache
==
NULL
)
{
return
-
1
;
}
IndexCache
*
pCache
=
cache
;
IndexCache
*
pCache
=
cache
;
SIndexTerm
*
term
=
query
->
term
;
SIndexTerm
*
term
=
query
->
term
;
...
@@ -159,7 +159,7 @@ int indexCacheSearch(void *cache, SIndexTermQuery *query, int16_t colId, int32_t
...
@@ -159,7 +159,7 @@ int indexCacheSearch(void *cache, SIndexTermQuery *query, int16_t colId, int32_t
char
*
buf
=
calloc
(
1
,
keyLen
);
char
*
buf
=
calloc
(
1
,
keyLen
);
if
(
qtype
==
QUERY_TERM
)
{
if
(
qtype
==
QUERY_TERM
)
{
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
}
else
if
(
qtype
==
QUERY_SUFFIX
)
{
}
else
if
(
qtype
==
QUERY_SUFFIX
)
{
...
...
source/libs/index/src/index_tfile.c
0 → 100644
浏览文件 @
76f70feb
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "index_tfile.h"
IndexTFile
*
indexTFileCreate
()
{
IndexTFile
*
tfile
=
calloc
(
1
,
sizeof
(
IndexTFile
));
return
tfile
;
}
void
IndexTFileDestroy
(
IndexTFile
*
tfile
)
{
free
(
tfile
);
}
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
IndexTFile
*
ptfile
=
(
IndexTFile
*
)
tfile
;
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录