Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Cherenkov effect
TDengine
提交
93c666bb
T
TDengine
项目概览
Cherenkov effect
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
93c666bb
编写于
10月 30, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] refactor codes.
上级
d597ad5c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
22 addition
and
159 deletion
+22
-159
src/client/inc/tschemautil.h
src/client/inc/tschemautil.h
+0
-3
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+0
-8
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+5
-84
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+0
-22
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+15
-33
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-1
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+0
-7
未找到文件。
src/client/inc/tschemautil.h
浏览文件 @
93c666bb
...
...
@@ -107,9 +107,6 @@ SSchema tscGetTbnameColumnSchema();
*/
STableMeta
*
tscCreateTableMetaFromMsg
(
STableMetaMsg
*
pTableMetaMsg
,
size_t
*
size
);
//todo tags value as well as the table id structure needs refactor
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
);
#ifdef __cplusplus
}
#endif
...
...
src/client/inc/tsclient.h
浏览文件 @
93c666bb
...
...
@@ -431,14 +431,6 @@ void tscResetSqlCmdObj(SSqlCmd *pCmd, bool removeFromCache);
*/
void
tscFreeSqlResult
(
SSqlObj
*
pSql
);
/**
* only free part of resources allocated during query.
* TODO remove it later
* Note: this function is multi-thread safe.
* @param pObj
*/
void
tscPartiallyFreeSqlObj
(
SSqlObj
*
pSql
);
/**
* free sql object, release allocated resource
* @param pObj
...
...
src/client/src/tscLocal.c
浏览文件 @
93c666bb
...
...
@@ -49,82 +49,6 @@ typedef struct SCreateBuilder {
}
SCreateBuilder
;
static
void
tscSetLocalQueryResult
(
SSqlObj
*
pSql
,
const
char
*
val
,
const
char
*
columnName
,
int16_t
type
,
size_t
valueLength
);
static
int32_t
getToStringLength
(
const
char
*
pData
,
int32_t
length
,
int32_t
type
)
{
char
buf
[
512
]
=
{
0
};
int32_t
len
=
0
;
int32_t
MAX_BOOL_TYPE_LENGTH
=
5
;
// max(strlen("true"), strlen("false"));
switch
(
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
return
length
;
case
TSDB_DATA_TYPE_NCHAR
:
return
length
;
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
dv
=
0
;
dv
=
GET_DOUBLE_VAL
(
pData
);
len
=
sprintf
(
buf
,
"%lf"
,
dv
);
if
(
strncasecmp
(
"nan"
,
buf
,
3
)
==
0
)
{
len
=
4
;
}
}
break
;
case
TSDB_DATA_TYPE_FLOAT
:
{
float
fv
=
0
;
fv
=
GET_FLOAT_VAL
(
pData
);
len
=
sprintf
(
buf
,
"%f"
,
fv
);
if
(
strncasecmp
(
"nan"
,
buf
,
3
)
==
0
)
{
len
=
4
;
}
}
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
len
=
sprintf
(
buf
,
"%"
PRId64
,
*
(
int64_t
*
)
pData
);
break
;
case
TSDB_DATA_TYPE_BOOL
:
len
=
MAX_BOOL_TYPE_LENGTH
;
break
;
default:
len
=
sprintf
(
buf
,
"%d"
,
*
(
int32_t
*
)
pData
);
break
;
};
return
len
;
}
/*
* we need to convert all data into string, so we need to sprintf all kinds of
* non-string data into string, and record its length to get the right
* maximum length. The length may be less or greater than its original binary length:
* For example:
* length((short) 1) == 1, less than sizeof(short)
* length((uint64_t) 123456789011) > 12, greater than sizsof(uint64_t)
*/
static
int32_t
tscMaxLengthOfTagsFields
(
SSqlObj
*
pSql
)
{
STableMeta
*
pMeta
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
)
->
pTableMeta
;
if
(
pMeta
->
tableType
==
TSDB_SUPER_TABLE
||
pMeta
->
tableType
==
TSDB_NORMAL_TABLE
||
pMeta
->
tableType
==
TSDB_STREAM_TABLE
)
{
return
0
;
}
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
SSchema
*
pTagsSchema
=
tscGetTableTagSchema
(
pMeta
);
int32_t
len
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
0
].
bytes
,
pTagsSchema
[
0
].
type
);
pTagValue
+=
pTagsSchema
[
0
].
bytes
;
int32_t
numOfTags
=
tscGetNumOfTags
(
pMeta
);
for
(
int32_t
i
=
1
;
i
<
numOfTags
;
++
i
)
{
int32_t
tLen
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
i
].
bytes
,
pTagsSchema
[
i
].
type
);
if
(
len
<
tLen
)
{
len
=
tLen
;
}
pTagValue
+=
pTagsSchema
[
i
].
bytes
;
}
return
len
;
}
static
int32_t
tscSetValueToResObj
(
SSqlObj
*
pSql
,
int32_t
rowLen
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -186,8 +110,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
return
0
;
}
// the following is handle display tags value for meters created according to metric
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
// the following is handle display tags for table created according to super table
for
(
int32_t
i
=
numOfRows
;
i
<
totalNumOfRows
;
++
i
)
{
// field name
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
0
);
...
...
@@ -219,8 +142,6 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
char
*
target
=
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
;
const
char
*
src
=
"TAG"
;
STR_WITH_MAXSIZE_TO_VARSTR
(
target
,
src
,
pField
->
bytes
);
pTagValue
+=
pSchema
[
i
].
bytes
;
}
return
0
;
...
...
@@ -286,10 +207,10 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
const
int32_t
TYPE_COLUMN_LENGTH
=
16
;
const
int32_t
NOTE_COLUMN_MIN_LENGTH
=
8
;
int32_t
noteFieldLen
=
tscMaxLengthOfTagsFields
(
pSql
);
if
(
noteFieldLen
==
0
)
{
noteFieldLen
=
NOTE_COLUMN_MIN_LENGTH
;
}
int32_t
noteFieldLen
=
NOTE_COLUMN_MIN_LENGTH
;
//
tscMaxLengthOfTagsFields(pSql);
//
if (noteFieldLen == 0) {
//
noteFieldLen = NOTE_COLUMN_MIN_LENGTH;
//
}
int32_t
rowLen
=
tscBuildTableSchemaResultFields
(
pSql
,
NUM_OF_DESC_TABLE_COLUMNS
,
TYPE_COLUMN_LENGTH
,
noteFieldLen
);
tscFieldInfoUpdateOffset
(
pQueryInfo
);
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
93c666bb
...
...
@@ -197,28 +197,6 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
return
pTableMeta
;
}
/**
* the TableMeta data format in memory is as follows:
*
* +--------------------+
* |STableMeta Body data| sizeof(STableMeta)
* +--------------------+
* |Schema data | numOfTotalColumns * sizeof(SSchema)
* +--------------------+
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* +--------------------+
*
* @param pTableMeta
* @return
*/
char
*
tsGetTagsValue
(
STableMeta
*
pTableMeta
)
{
int32_t
offset
=
0
;
// int32_t numOfTotalCols = pTableMeta->numOfColumns + pTableMeta->numOfTags;
// uint32_t offset = sizeof(STableMeta) + numOfTotalCols * sizeof(SSchema);
return
((
char
*
)
pTableMeta
+
offset
);
}
// todo refactor
UNUSED_FUNC
static
FORCE_INLINE
char
*
skipSegments
(
char
*
input
,
char
delim
,
int32_t
num
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
93c666bb
...
...
@@ -886,7 +886,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STSVnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pQueryInfo
->
tsBuf
,
vnodeId
);
assert
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
pBlockInfo
!=
NULL
);
// this query should not be sent
// todo refactor
// todo refactor
, extract method and put into tsBuf.c
if
(
fseek
(
pQueryInfo
->
tsBuf
->
f
,
pBlockInfo
->
offset
,
SEEK_SET
)
!=
0
)
{
int
code
=
TAOS_SYSTEM_ERROR
(
ferror
(
pQueryInfo
->
tsBuf
->
f
));
tscError
(
"%p: fseek failed: %s"
,
pSql
,
tstrerror
(
code
));
...
...
src/client/src/tscUtil.c
浏览文件 @
93c666bb
...
...
@@ -338,34 +338,6 @@ void tscFreeSqlResult(SSqlObj* pSql) {
memset
(
&
pSql
->
res
,
0
,
sizeof
(
SSqlRes
));
}
void
tscPartiallyFreeSqlObj
(
SSqlObj
*
pSql
)
{
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
;
}
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
cmd
=
pCmd
->
command
;
if
(
cmd
<
TSDB_SQL_INSERT
||
cmd
==
TSDB_SQL_RETRIEVE_LOCALMERGE
||
cmd
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
cmd
==
TSDB_SQL_TABLE_JOIN_RETRIEVE
)
{
tscRemoveFromSqlList
(
pSql
);
}
// pSql->sqlstr will be used by tscBuildQueryStreamDesc
// if (pObj->signature == pObj) {
//pthread_mutex_lock(&pObj->mutex);
taosTFree
(
pSql
->
sqlstr
);
//pthread_mutex_unlock(&pObj->mutex);
// }
tscFreeSqlResult
(
pSql
);
taosTFree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
self
=
0
;
tscResetSqlCmdObj
(
pCmd
,
false
);
}
static
void
tscFreeSubobj
(
SSqlObj
*
pSql
)
{
if
(
pSql
->
subState
.
numOfSub
==
0
)
{
return
;
...
...
@@ -434,22 +406,32 @@ void tscFreeSqlObj(SSqlObj* pSql) {
tscDebug
(
"%p start to free sqlObj"
,
pSql
);
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
tscFreeSubobj
(
pSql
);
tscPartiallyFreeSqlObj
(
pSql
);
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
cmd
=
pCmd
->
command
;
if
(
cmd
<
TSDB_SQL_INSERT
||
cmd
==
TSDB_SQL_RETRIEVE_LOCALMERGE
||
cmd
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
cmd
==
TSDB_SQL_TABLE_JOIN_RETRIEVE
)
{
tscRemoveFromSqlList
(
pSql
);
}
pSql
->
signature
=
NULL
;
pSql
->
fp
=
NULL
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
taosTFree
(
pSql
->
sqlstr
);
taosTFree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
self
=
0
;
tscFreeSqlResult
(
pSql
);
tscResetSqlCmdObj
(
pCmd
,
false
);
memset
(
pCmd
->
payload
,
0
,
(
size_t
)
pCmd
->
allocSize
);
taosTFree
(
pCmd
->
payload
);
pCmd
->
allocSize
=
0
;
taosTFree
(
pSql
->
sqlstr
);
tsem_destroy
(
&
pSql
->
rspSem
);
free
(
pSql
);
}
...
...
src/query/inc/qExecutor.h
浏览文件 @
93c666bb
...
...
@@ -94,7 +94,7 @@ typedef struct SSingleColumnFilterInfo {
SColumnFilterElem
*
pFilters
;
}
SSingleColumnFilterInfo
;
typedef
struct
STableQueryInfo
{
// todo merge with the STableQueryInfo struct
typedef
struct
STableQueryInfo
{
TSKEY
lastKey
;
int32_t
groupIndex
;
// group id in table list
int16_t
queryRangeSet
;
// denote if the query range is set, only available for interval query
...
...
src/query/inc/qSqlparser.h
浏览文件 @
93c666bb
...
...
@@ -223,13 +223,6 @@ typedef struct tSQLExprList {
tSQLExprItem
*
a
;
/* One entry for each expression */
}
tSQLExprList
;
typedef
struct
tSQLExprListList
{
int32_t
nList
;
/* Number of expressions on the list */
int32_t
nAlloc
;
/* Number of entries allocated below */
tSQLExprList
**
a
;
/* one entry for each row */
}
tSQLExprListList
;
/**
*
* @param yyp The parser
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录