Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a9ec970d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
a9ec970d
编写于
7月 07, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor code.
上级
88fc56d1
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
74 addition
and
75 deletion
+74
-75
src/client/inc/tschemautil.h
src/client/inc/tschemautil.h
+0
-2
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+6
-6
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+0
-22
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+3
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+5
-5
src/common/inc/tname.h
src/common/inc/tname.h
+3
-0
src/common/inc/tvariant.h
src/common/inc/tvariant.h
+0
-0
src/common/src/tname.c
src/common/src/tname.c
+23
-0
src/common/src/tvariant.c
src/common/src/tvariant.c
+0
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+3
-3
src/query/src/qast.c
src/query/src/qast.c
+12
-12
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+0
-5
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+18
-16
未找到文件。
src/client/inc/tschemautil.h
浏览文件 @
a9ec970d
...
...
@@ -110,8 +110,6 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
//todo tags value as well as the table id structure needs refactor
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
);
void
extractTableNameFromToken
(
SSQLToken
*
pToken
,
SSQLToken
*
pTable
);
#ifdef __cplusplus
}
#endif
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
a9ec970d
...
...
@@ -14,7 +14,6 @@
*/
#include "os.h"
#include "qast.h"
#include "qextbuffer.h"
#include "qfill.h"
#include "qhistogram.h"
...
...
@@ -23,6 +22,7 @@
#include "qtsbuf.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "qast.h"
#include "tscLog.h"
#include "tscSubquery.h"
#include "tscompression.h"
...
...
src/client/src/tscSQLParser.c
浏览文件 @
a9ec970d
...
...
@@ -18,19 +18,19 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "qast.h"
#include "taos.h"
#include "taosmsg.h"
#include "
tstoken
.h"
#include "t
strbuild
.h"
#include "t
ti
me.h"
#include "
qast
.h"
#include "t
compare
.h"
#include "t
na
me.h"
#include "tscLog.h"
#include "tscUtil.h"
#include "tschemautil.h"
#include "tsclient.h"
#include "tstoken.h"
#include "tstrbuild.h"
#include "ttime.h"
#include "ttokendef.h"
#include "tname.h"
#include "tcompare.h"
#define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0"
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
a9ec970d
...
...
@@ -215,25 +215,3 @@ __attribute__ ((unused)) static FORCE_INLINE size_t copy(char* dst, const char*
return
len
;
}
/*
* tablePrefix.columnName
* extract table name and save it in pTable, with only column name in pToken
*/
void
extractTableNameFromToken
(
SSQLToken
*
pToken
,
SSQLToken
*
pTable
)
{
const
char
sep
=
TS_PATH_DELIMITER
[
0
];
if
(
pToken
==
pTable
||
pToken
==
NULL
||
pTable
==
NULL
)
{
return
;
}
char
*
r
=
strnchr
(
pToken
->
z
,
sep
,
pToken
->
n
,
false
);
if
(
r
!=
NULL
)
{
// record the table name token
pTable
->
n
=
r
-
pToken
->
z
;
pTable
->
z
=
pToken
->
z
;
r
+=
1
;
pToken
->
n
-=
(
r
-
pToken
->
z
);
pToken
->
z
=
r
;
}
}
src/client/src/tscSubquery.c
浏览文件 @
a9ec970d
...
...
@@ -14,12 +14,12 @@
*/
#include "os.h"
#include "
tscSubquery
.h"
#include "
qtsbuf
.h"
#include "qast.h"
#include "tcompare.h"
#include "tschemautil.h"
#include "qtsbuf.h"
#include "tscLog.h"
#include "tscSubquery.h"
#include "tschemautil.h"
#include "tsclient.h"
typedef
struct
SInsertSupporter
{
...
...
src/client/src/tscUtil.c
浏览文件 @
a9ec970d
...
...
@@ -14,21 +14,21 @@
*/
#include "os.h"
#include "qast.h"
#include "hash.h"
#include "tscUtil.h"
#include "taosmsg.h"
#include "qast.h"
#include "tcache.h"
#include "tkey.h"
#include "tmd5.h"
#include "tscProfile.h"
#include "tscLocalMerge.h"
#include "tscLog.h"
#include "tscProfile.h"
#include "tscSubquery.h"
#include "tschemautil.h"
#include "tsclient.h"
#include "ttimer.h"
#include "ttokendef.h"
#include "tscLog.h"
#include "tscUtil.h"
#include "hash.h"
static
void
freeQueryInfoImpl
(
SQueryInfo
*
pQueryInfo
);
static
void
clearAllTableMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
...
...
src/common/inc/tname.h
浏览文件 @
a9ec970d
...
...
@@ -3,6 +3,7 @@
#include "os.h"
#include "taosmsg.h"
#include "tstoken.h"
typedef
struct
SDataStatis
{
int16_t
colId
;
...
...
@@ -23,6 +24,8 @@ void extractTableName(const char *tableId, char *name);
char
*
extractDBName
(
const
char
*
tableId
,
char
*
name
);
void
extractTableNameFromToken
(
SSQLToken
*
pToken
,
SSQLToken
*
pTable
);
SSchema
tGetTableNameColumnSchema
();
bool
tscValidateTableNameLength
(
size_t
len
);
...
...
src/
query
/inc/tvariant.h
→
src/
common
/inc/tvariant.h
浏览文件 @
a9ec970d
文件已移动
src/common/src/tname.c
浏览文件 @
a9ec970d
...
...
@@ -105,3 +105,26 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
}
return
start
;
}
/*
* tablePrefix.columnName
* extract table name and save it in pTable, with only column name in pToken
*/
void
extractTableNameFromToken
(
SSQLToken
*
pToken
,
SSQLToken
*
pTable
)
{
const
char
sep
=
TS_PATH_DELIMITER
[
0
];
if
(
pToken
==
pTable
||
pToken
==
NULL
||
pTable
==
NULL
)
{
return
;
}
char
*
r
=
strnchr
(
pToken
->
z
,
sep
,
pToken
->
n
,
false
);
if
(
r
!=
NULL
)
{
// record the table name token
pTable
->
n
=
r
-
pToken
->
z
;
pTable
->
z
=
pToken
->
z
;
r
+=
1
;
pToken
->
n
-=
(
r
-
pToken
->
z
);
pToken
->
z
=
r
;
}
}
src/
query
/src/tvariant.c
→
src/
common
/src/tvariant.c
浏览文件 @
a9ec970d
文件已移动
src/query/src/qExecutor.c
浏览文件 @
a9ec970d
...
...
@@ -18,18 +18,18 @@
#include "qfill.h"
#include "taosmsg.h"
#include "exception.h"
#include "hash.h"
#include "qExecutor.h"
#include "qUtil.h"
#include "qast.h"
#include "qresultBuf.h"
#include "query.h"
#include "queryLog.h"
#include "qast.h"
#include "tfile.h"
#include "tlosertree.h"
#include "exception.h"
#include "tscompression.h"
#include "ttime.h"
#include "tfile.h"
/**
* check if the primary column is load by default, otherwise, the program will
...
...
src/query/src/qast.c
浏览文件 @
a9ec970d
...
...
@@ -13,25 +13,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tulog.h"
#include "tutil.h"
#include "tbuffer.h"
#include "tname.h"
#include "qast.h"
#include "tcompare.h"
#include "tsdb.h"
#include "exception.h"
#include "qsqlparser.h"
#include "qsyntaxtreefunction.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tbuffer.h"
#include "tcompare.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "tstoken.h"
#include "ttokendef.h"
#include "tschemautil.h"
#include "tarray.h"
#include "tskiplist.h"
#include "queryLog.h"
#include "tsdbMain.h"
#include "exception.h"
#include "tulog.h"
#include "tutil.h"
/*
*
...
...
@@ -675,8 +676,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
// todo refactor:
tstr
*
name
=
(
*
(
STable
**
)
pData
)
->
name
;
tstr
*
name
=
(
tstr
*
)
tsdbGetTableName
(
*
(
void
**
)
pData
);
// todo speed up by using hash
if
(
pQueryInfo
->
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_IN
)
{
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
a9ec970d
...
...
@@ -192,11 +192,6 @@ char *tsdbGetTableName(void* pTable) {
}
}
STableId
tsdbGetTableId
(
void
*
pTable
)
{
assert
(
pTable
);
return
((
STable
*
)
pTable
)
->
tableId
;
}
STableCfg
*
tsdbCreateTableCfgFromMsg
(
SMDCreateTableMsg
*
pMsg
)
{
if
(
pMsg
==
NULL
)
return
NULL
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
a9ec970d
...
...
@@ -122,7 +122,7 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
,
SArray
*
sa
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
TSKEY
*
skey
,
TSKEY
*
ekey
,
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbQueryHandle
*
pQueryHandle
);
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
...
...
@@ -412,8 +412,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
int32_t
step
=
ASCENDING_TRAVERSE
(
pHandle
->
order
)
?
1
:-
1
;
STimeWindow
*
win
=
&
pHandle
->
cur
.
win
;
pHandle
->
cur
.
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
,
pHandle
->
window
.
ekey
,
pHandle
->
outputCapacity
,
&
win
->
skey
,
&
win
->
ekey
,
pHandle
);
// todo refactor API
pHandle
->
cur
.
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
,
pHandle
->
window
.
ekey
,
pHandle
->
outputCapacity
,
win
,
pHandle
);
// update the last key value
pCheckInfo
->
lastKey
=
win
->
ekey
+
step
;
...
...
@@ -643,7 +642,7 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
int32_t
step
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
1
:
-
1
;
cur
->
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
,
binfo
.
window
.
skey
-
step
,
pQueryHandle
->
outputCapacity
,
&
cur
->
win
.
skey
,
&
cur
->
win
.
ekey
,
pQueryHandle
);
pQueryHandle
->
outputCapacity
,
&
cur
->
win
,
pQueryHandle
);
pQueryHandle
->
realNumOfRows
=
cur
->
rows
;
// update the last key value
...
...
@@ -1244,7 +1243,6 @@ static int32_t dataBlockOrderCompar(const void* pLeft, const void* pRight, void*
// assert(pLeftBlockInfoEx->compBlock->offset != pRightBlockInfoEx->compBlock->offset);
if
(
pLeftBlockInfoEx
->
compBlock
->
offset
==
pRightBlockInfoEx
->
compBlock
->
offset
&&
pLeftBlockInfoEx
->
compBlock
->
last
==
pRightBlockInfoEx
->
compBlock
->
last
)
{
// todo add more information
tsdbError
(
"error in header file, two block with same offset:%"
PRId64
,
(
int64_t
)
pLeftBlockInfoEx
->
compBlock
->
offset
);
}
...
...
@@ -1701,11 +1699,11 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
pQueryHandle
->
window
=
(
STimeWindow
)
{
info
.
lastKey
,
TSKEY_INITIAL_VAL
};
}
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
TSKEY
*
skey
,
TSKEY
*
ekey
,
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbQueryHandle
*
pQueryHandle
)
{
int
numOfRows
=
0
;
int32_t
numOfCols
=
taosArrayGetSize
(
pQueryHandle
->
pColumns
);
*
skey
=
TSKEY_INITIAL_VAL
;
win
->
skey
=
TSKEY_INITIAL_VAL
;
int64_t
st
=
taosGetTimestampUs
();
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
pQueryHandle
->
pTsdb
);
...
...
@@ -1725,11 +1723,11 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
break
;
}
if
(
*
skey
==
INT64_MIN
)
{
*
skey
=
key
;
if
(
win
->
skey
==
INT64_MIN
)
{
win
->
skey
=
key
;
}
*
ekey
=
key
;
win
->
ekey
=
key
;
copyOneRowFromMem
(
pQueryHandle
,
maxRowsToRead
,
numOfRows
,
row
,
pMeta
,
numOfCols
,
pTable
);
if
(
++
numOfRows
>=
maxRowsToRead
)
{
...
...
@@ -1978,9 +1976,9 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
int32_t
type
=
0
;
int32_t
bytes
=
0
;
if
(
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// todo refactor extract method , to queryExecutor to generate tags values
f1
=
(
char
*
)
pTable1
->
name
;
f2
=
(
char
*
)
pTable2
->
name
;
if
(
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
f1
=
(
char
*
)
TABLE_NAME
(
pTable1
)
;
f2
=
(
char
*
)
TABLE_NAME
(
pTable2
)
;
type
=
TSDB_DATA_TYPE_BINARY
;
bytes
=
tGetTableNameColumnSchema
().
bytes
;
}
else
{
...
...
@@ -2089,13 +2087,17 @@ bool indexedNodeFilterFp(const void* pNode, void* param) {
char
*
val
=
NULL
;
if
(
pInfo
->
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
val
=
(
char
*
)
pTable
->
name
;
val
=
(
char
*
)
TABLE_NAME
(
pTable
)
;
}
else
{
val
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
pInfo
->
sch
.
colId
);
}
//todo :the val is possible to be null, so check it out carefully
int32_t
ret
=
pInfo
->
compare
(
val
,
pInfo
->
q
);
int32_t
ret
=
0
;
if
(
val
==
NULL
)
{
//the val is possible to be null, so check it out carefully
ret
=
-
1
;
// val is missing in table tags value pairs
}
else
{
ret
=
pInfo
->
compare
(
val
,
pInfo
->
q
);
}
switch
(
pInfo
->
optr
)
{
case
TSDB_RELATION_EQUAL
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录