Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
afa86981
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
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看板
提交
afa86981
编写于
8月 06, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1057
上级
8434058a
变更
15
展开全部
显示空白变更内容
内联
并排
Showing
15 changed file
with
148 addition
and
120 deletion
+148
-120
deps/pthread/config.h
deps/pthread/config.h
+1
-0
src/client/CMakeLists.txt
src/client/CMakeLists.txt
+2
-2
src/client/src/taos.def
src/client/src/taos.def
+13
-1
src/query/CMakeLists.txt
src/query/CMakeLists.txt
+7
-6
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+1
-1
src/query/src/qAst.c
src/query/src/qAst.c
+2
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+78
-64
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+5
-5
src/query/src/qFill.c
src/query/src/qFill.c
+11
-11
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+3
-3
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+3
-3
src/query/src/qPercentile.c
src/query/src/qPercentile.c
+7
-7
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+6
-6
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+2
-2
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+7
-7
未找到文件。
deps/pthread/config.h
浏览文件 @
afa86981
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
*********************************************************************/
*********************************************************************/
/* We're building the pthreads-win32 library */
/* We're building the pthreads-win32 library */
#undef PTW32_BUILD
#define PTW32_BUILD
#define PTW32_BUILD
/* Do we know about the C type sigset_t? */
/* Do we know about the C type sigset_t? */
...
...
src/client/CMakeLists.txt
浏览文件 @
afa86981
...
@@ -37,14 +37,14 @@ ELSEIF (TD_WINDOWS)
...
@@ -37,14 +37,14 @@ ELSEIF (TD_WINDOWS)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/windows/win32
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/windows/win32
)
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taos_static trpc tutil
)
TARGET_LINK_LIBRARIES
(
taos_static trpc tutil
query
)
# generate dynamic library (*.dll)
# generate dynamic library (*.dll)
ADD_LIBRARY
(
taos SHARED
${
SRC
}
)
ADD_LIBRARY
(
taos SHARED
${
SRC
}
)
IF
(
NOT TD_GODLL
)
IF
(
NOT TD_GODLL
)
SET_TARGET_PROPERTIES
(
taos PROPERTIES LINK_FLAGS /DEF:
${
TD_COMMUNITY_DIR
}
/src/client/src/taos.def
)
SET_TARGET_PROPERTIES
(
taos PROPERTIES LINK_FLAGS /DEF:
${
TD_COMMUNITY_DIR
}
/src/client/src/taos.def
)
ENDIF
()
ENDIF
()
TARGET_LINK_LIBRARIES
(
taos trpc tutil
)
TARGET_LINK_LIBRARIES
(
taos trpc tutil
query
)
ELSEIF
(
TD_DARWIN
)
ELSEIF
(
TD_DARWIN
)
SET
(
CMAKE_MACOSX_RPATH 1
)
SET
(
CMAKE_MACOSX_RPATH 1
)
...
...
src/client/src/taos.def
浏览文件 @
afa86981
EXPORTS
EXPORTS
taos_init
taos_init
taos_cleanup
taos_options
taos_options
taos_connect
taos_connect
taos_close
taos_close
taos_stmt_init
taos_stmt_prepare
taos_stmt_bind_param
taos_stmt_add_batch
taos_stmt_execute
taos_stmt_use_result
taos_stmt_close
taos_query
taos_query
taos_fetch_row
taos_fetch_row
taos_result_precision
taos_free_result
taos_free_result
taos_field_count
taos_field_count
taos_num_fields
taos_num_fields
...
@@ -13,6 +22,9 @@ taos_fetch_fields
...
@@ -13,6 +22,9 @@ taos_fetch_fields
taos_select_db
taos_select_db
taos_print_row
taos_print_row
taos_stop_query
taos_stop_query
taos_fetch_block
taos_validate_sql
taos_fetch_lengths
taos_get_server_info
taos_get_server_info
taos_get_client_info
taos_get_client_info
taos_errstr
taos_errstr
...
@@ -26,5 +38,5 @@ taos_unsubscribe
...
@@ -26,5 +38,5 @@ taos_unsubscribe
taos_open_stream
taos_open_stream
taos_close_stream
taos_close_stream
taos_fetch_block
taos_fetch_block
taos_
result_precision
taos_
load_table_info
src/query/CMakeLists.txt
浏览文件 @
afa86981
...
@@ -5,12 +5,13 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc)
...
@@ -5,12 +5,13 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
query
${
SRC
}
)
SET_SOURCE_FILES_PROPERTIES
(
src/sql.c PROPERTIES COMPILE_FLAGS -w
)
IF
(
TD_LINUX
)
IF
(
TD_LINUX
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
TARGET_LINK_LIBRARIES
(
query tutil m rt
)
ADD_LIBRARY
(
query
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
query tsdb tutil m rt
)
ADD_SUBDIRECTORY
(
tests
)
ADD_SUBDIRECTORY
(
tests
)
SET_SOURCE_FILES_PROPERTIES
(
src/sql.c PROPERTIES COMPILE_FLAGS -w
)
ELSEIF
(
TD_WINDOWS
)
TARGET_LINK_LIBRARIES
(
query tutil
)
ENDIF
()
ENDIF
()
src/query/inc/qUtil.h
浏览文件 @
afa86981
...
@@ -52,7 +52,7 @@ static FORCE_INLINE char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int3
...
@@ -52,7 +52,7 @@ static FORCE_INLINE char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int3
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
// tFilePage *page = getResBufPage(pRuntimeEnv->pResultBuf, pResult->pos.pageId);
// tFilePage *page = getResBufPage(pRuntimeEnv->pResultBuf, pResult->pos.pageId);
int32_t
realRowId
=
pResult
->
pos
.
rowId
*
GET_ROW_PARAM_FOR_MULTIOUTPUT
(
pQuery
,
pRuntimeEnv
->
topBotQuery
,
pRuntimeEnv
->
stableQuery
);
int32_t
realRowId
=
(
int32_t
)(
pResult
->
pos
.
rowId
*
GET_ROW_PARAM_FOR_MULTIOUTPUT
(
pQuery
,
pRuntimeEnv
->
topBotQuery
,
pRuntimeEnv
->
stableQuery
)
);
return
((
char
*
)
page
->
data
)
+
pRuntimeEnv
->
offset
[
columnIndex
]
*
pRuntimeEnv
->
numOfRowsPerPage
+
return
((
char
*
)
page
->
data
)
+
pRuntimeEnv
->
offset
[
columnIndex
]
*
pRuntimeEnv
->
numOfRowsPerPage
+
pQuery
->
pSelectExpr
[
columnIndex
].
bytes
*
realRowId
;
pQuery
->
pSelectExpr
[
columnIndex
].
bytes
*
realRowId
;
}
}
...
...
src/query/src/qAst.c
浏览文件 @
afa86981
...
@@ -1044,7 +1044,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
...
@@ -1044,7 +1044,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
}
else
if
(
*
e
==
','
)
{
}
else
if
(
*
e
==
','
)
{
size_t
len
=
e
-
cond
;
size_t
len
=
e
-
cond
;
char
*
p
=
exception_malloc
(
len
+
VARSTR_HEADER_SIZE
);
char
*
p
=
exception_malloc
(
len
+
VARSTR_HEADER_SIZE
);
STR_WITH_SIZE_TO_VARSTR
(
p
,
cond
,
len
);
STR_WITH_SIZE_TO_VARSTR
(
p
,
cond
,
(
VarDataLenT
)
len
);
cond
+=
len
;
cond
+=
len
;
taosArrayPush
(
pVal
->
arr
,
&
p
);
taosArrayPush
(
pVal
->
arr
,
&
p
);
}
}
...
@@ -1054,7 +1054,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
...
@@ -1054,7 +1054,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
size_t
len
=
strlen
(
cond
)
+
VARSTR_HEADER_SIZE
;
size_t
len
=
strlen
(
cond
)
+
VARSTR_HEADER_SIZE
;
char
*
p
=
exception_malloc
(
len
);
char
*
p
=
exception_malloc
(
len
);
STR_WITH_SIZE_TO_VARSTR
(
p
,
cond
,
len
-
VARSTR_HEADER_SIZE
);
STR_WITH_SIZE_TO_VARSTR
(
p
,
cond
,
(
VarDataLenT
)(
len
-
VARSTR_HEADER_SIZE
)
);
taosArrayPush
(
pVal
->
arr
,
&
p
);
taosArrayPush
(
pVal
->
arr
,
&
p
);
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
afa86981
此差异已折叠。
点击以展开。
src/query/src/qExtbuffer.c
浏览文件 @
afa86981
...
@@ -172,7 +172,7 @@ int16_t tExtMemBufferPut(tExtMemBuffer *pMemBuffer, void *data, int32_t numOfRow
...
@@ -172,7 +172,7 @@ int16_t tExtMemBufferPut(tExtMemBuffer *pMemBuffer, void *data, int32_t numOfRow
pMemBuffer
->
numOfElemsInBuffer
+=
numOfRows
;
pMemBuffer
->
numOfElemsInBuffer
+=
numOfRows
;
pMemBuffer
->
numOfTotalElems
+=
numOfRows
;
pMemBuffer
->
numOfTotalElems
+=
numOfRows
;
}
else
{
}
else
{
int32_t
numOfRemainEntries
=
pMemBuffer
->
numOfElemsPerPage
-
pLast
->
item
.
num
;
int32_t
numOfRemainEntries
=
pMemBuffer
->
numOfElemsPerPage
-
(
int32_t
)
pLast
->
item
.
num
;
tColModelAppend
(
pMemBuffer
->
pColumnModel
,
&
pLast
->
item
,
data
,
0
,
numOfRemainEntries
,
numOfRows
);
tColModelAppend
(
pMemBuffer
->
pColumnModel
,
&
pLast
->
item
,
data
,
0
,
numOfRemainEntries
,
numOfRows
);
pMemBuffer
->
numOfElemsInBuffer
+=
numOfRemainEntries
;
pMemBuffer
->
numOfElemsInBuffer
+=
numOfRemainEntries
;
...
@@ -270,7 +270,7 @@ int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) {
...
@@ -270,7 +270,7 @@ int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) {
return
ret
;
return
ret
;
}
}
pMemBuffer
->
fileMeta
.
numOfElemsInFile
+=
first
->
item
.
num
;
pMemBuffer
->
fileMeta
.
numOfElemsInFile
+=
(
uint32_t
)
first
->
item
.
num
;
pMemBuffer
->
fileMeta
.
nFileSize
+=
1
;
pMemBuffer
->
fileMeta
.
nFileSize
+=
1
;
tFilePagesItem
*
ptmp
=
first
;
tFilePagesItem
*
ptmp
=
first
;
...
@@ -322,7 +322,7 @@ void tExtMemBufferClear(tExtMemBuffer *pMemBuffer) {
...
@@ -322,7 +322,7 @@ void tExtMemBufferClear(tExtMemBuffer *pMemBuffer) {
}
}
bool
tExtMemBufferLoadData
(
tExtMemBuffer
*
pMemBuffer
,
tFilePage
*
pFilePage
,
int32_t
flushoutId
,
int32_t
pageIdx
)
{
bool
tExtMemBufferLoadData
(
tExtMemBuffer
*
pMemBuffer
,
tFilePage
*
pFilePage
,
int32_t
flushoutId
,
int32_t
pageIdx
)
{
if
(
flushoutId
<
0
||
flushoutId
>
pMemBuffer
->
fileMeta
.
flushoutData
.
nLength
)
{
if
(
flushoutId
<
0
||
flushoutId
>
(
int32_t
)
pMemBuffer
->
fileMeta
.
flushoutData
.
nLength
)
{
return
false
;
return
false
;
}
}
...
@@ -1011,8 +1011,8 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC
...
@@ -1011,8 +1011,8 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC
}
}
int32_t
removed
=
e
-
s
+
1
;
int32_t
removed
=
e
-
s
+
1
;
int32_t
remain
=
inputBuffer
->
num
-
removed
;
int32_t
remain
=
(
int32_t
)
inputBuffer
->
num
-
removed
;
int32_t
secPart
=
inputBuffer
->
num
-
e
-
1
;
int32_t
secPart
=
(
int32_t
)
inputBuffer
->
num
-
e
-
1
;
/* start from the second column */
/* start from the second column */
for
(
int32_t
i
=
0
;
i
<
pModel
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pModel
->
numOfCols
;
++
i
)
{
...
...
src/query/src/qFill.c
浏览文件 @
afa86981
...
@@ -185,34 +185,34 @@ static double linearInterpolationImpl(double v1, double v2, double k1, double k2
...
@@ -185,34 +185,34 @@ static double linearInterpolationImpl(double v1, double v2, double k1, double k2
int
taosDoLinearInterpolation
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
)
{
int
taosDoLinearInterpolation
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
)
{
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
case
TSDB_DATA_TYPE_INT
:
{
*
(
int32_t
*
)
point
->
val
=
(
int32_t
)
linearInterpolationImpl
(
*
(
int32_t
*
)
point1
->
val
,
*
(
int32_t
*
)
point2
->
val
,
point1
->
key
,
*
(
int32_t
*
)
point
->
val
=
(
int32_t
)
linearInterpolationImpl
(
*
(
int32_t
*
)
point1
->
val
,
*
(
int32_t
*
)
point2
->
val
,
(
double
)
point1
->
key
,
point2
->
key
,
point
->
key
);
(
double
)
point2
->
key
,
(
double
)
point
->
key
);
break
;
break
;
}
}
case
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDB_DATA_TYPE_FLOAT
:
{
*
(
float
*
)
point
->
val
=
*
(
float
*
)
point
->
val
=
(
float
)
linearInterpolationImpl
(
*
(
float
*
)
point1
->
val
,
*
(
float
*
)
point2
->
val
,
point1
->
key
,
point2
->
key
,
point
->
key
);
linearInterpolationImpl
(
*
(
float
*
)
point1
->
val
,
*
(
float
*
)
point2
->
val
,
(
double
)
point1
->
key
,
(
double
)
point2
->
key
,
(
double
)
point
->
key
);
break
;
break
;
};
};
case
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDB_DATA_TYPE_DOUBLE
:
{
*
(
double
*
)
point
->
val
=
*
(
double
*
)
point
->
val
=
linearInterpolationImpl
(
*
(
double
*
)
point1
->
val
,
*
(
double
*
)
point2
->
val
,
point1
->
key
,
point2
->
key
,
point
->
key
);
linearInterpolationImpl
(
*
(
double
*
)
point1
->
val
,
*
(
double
*
)
point2
->
val
,
(
double
)
point1
->
key
,
(
double
)
point2
->
key
,
(
double
)
point
->
key
);
break
;
break
;
};
};
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
{
case
TSDB_DATA_TYPE_BIGINT
:
{
*
(
int64_t
*
)
point
->
val
=
(
int64_t
)
linearInterpolationImpl
(
*
(
int64_t
*
)
point1
->
val
,
*
(
int64_t
*
)
point2
->
val
,
point1
->
key
,
*
(
int64_t
*
)
point
->
val
=
(
int64_t
)
linearInterpolationImpl
((
double
)(
*
(
int64_t
*
)
point1
->
val
),
(
double
)(
*
(
int64_t
*
)
point2
->
val
),
(
double
)
point1
->
key
,
point2
->
key
,
point
->
key
);
(
double
)
point2
->
key
,
(
double
)
point
->
key
);
break
;
break
;
};
};
case
TSDB_DATA_TYPE_SMALLINT
:
{
case
TSDB_DATA_TYPE_SMALLINT
:
{
*
(
int16_t
*
)
point
->
val
=
(
int16_t
)
linearInterpolationImpl
(
*
(
int16_t
*
)
point1
->
val
,
*
(
int16_t
*
)
point2
->
val
,
point1
->
key
,
*
(
int16_t
*
)
point
->
val
=
(
int16_t
)
linearInterpolationImpl
(
*
(
int16_t
*
)
point1
->
val
,
*
(
int16_t
*
)
point2
->
val
,
(
double
)
point1
->
key
,
point2
->
key
,
point
->
key
);
(
double
)
point2
->
key
,
(
double
)
point
->
key
);
break
;
break
;
};
};
case
TSDB_DATA_TYPE_TINYINT
:
{
case
TSDB_DATA_TYPE_TINYINT
:
{
*
(
int8_t
*
)
point
->
val
=
(
int8_t
)
*
(
int8_t
*
)
point
->
val
=
(
int8_t
)
linearInterpolationImpl
(
*
(
int8_t
*
)
point1
->
val
,
*
(
int8_t
*
)
point2
->
val
,
point1
->
key
,
point2
->
key
,
point
->
key
);
linearInterpolationImpl
(
*
(
int8_t
*
)
point1
->
val
,
*
(
int8_t
*
)
point2
->
val
,
(
double
)
point1
->
key
,
(
double
)
point2
->
key
,
(
double
)
point
->
key
);
break
;
break
;
};
};
default:
{
default:
{
...
@@ -467,7 +467,7 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu
...
@@ -467,7 +467,7 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu
int64_t
taosGenerateDataBlock
(
SFillInfo
*
pFillInfo
,
tFilePage
**
output
,
int32_t
capacity
)
{
int64_t
taosGenerateDataBlock
(
SFillInfo
*
pFillInfo
,
tFilePage
**
output
,
int32_t
capacity
)
{
int32_t
remain
=
taosNumOfRemainRows
(
pFillInfo
);
// todo use iterator?
int32_t
remain
=
taosNumOfRemainRows
(
pFillInfo
);
// todo use iterator?
int32_t
rows
=
getFilledNumOfRes
(
pFillInfo
,
pFillInfo
->
endKey
,
capacity
);
int32_t
rows
=
(
int32_t
)
getFilledNumOfRes
(
pFillInfo
,
pFillInfo
->
endKey
,
capacity
);
int32_t
numOfRes
=
generateDataBlockImpl
(
pFillInfo
,
output
,
remain
,
rows
,
pFillInfo
->
pData
);
int32_t
numOfRes
=
generateDataBlockImpl
(
pFillInfo
,
output
,
remain
,
rows
,
pFillInfo
->
pData
);
assert
(
numOfRes
==
rows
);
assert
(
numOfRes
==
rows
);
...
...
src/query/src/qHistogram.c
浏览文件 @
afa86981
...
@@ -482,10 +482,10 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) {
...
@@ -482,10 +482,10 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) {
}
}
}
}
double
m1
=
pHisto
->
elems
[
slotIdx
].
num
;
double
m1
=
(
double
)
pHisto
->
elems
[
slotIdx
].
num
;
double
v1
=
pHisto
->
elems
[
slotIdx
].
val
;
double
v1
=
pHisto
->
elems
[
slotIdx
].
val
;
double
m2
=
pHisto
->
elems
[
slotIdx
+
1
].
num
;
double
m2
=
(
double
)
pHisto
->
elems
[
slotIdx
+
1
].
num
;
double
v2
=
pHisto
->
elems
[
slotIdx
+
1
].
val
;
double
v2
=
pHisto
->
elems
[
slotIdx
+
1
].
val
;
double
estNum
=
m1
+
(
m2
-
m1
)
*
(
v
-
v1
)
/
(
v2
-
v1
);
double
estNum
=
m1
+
(
m2
-
m1
)
*
(
v
-
v1
)
/
(
v2
-
v1
);
...
@@ -538,7 +538,7 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
...
@@ -538,7 +538,7 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
pVal
[
i
]
=
pHisto
->
elems
[
j
].
val
;
pVal
[
i
]
=
pHisto
->
elems
[
j
].
val
;
}
}
double
start
=
pHisto
->
elems
[
j
].
num
;
double
start
=
(
double
)
pHisto
->
elems
[
j
].
num
;
double
range
=
pHisto
->
elems
[
j
+
1
].
num
-
start
;
double
range
=
pHisto
->
elems
[
j
+
1
].
num
-
start
;
if
(
range
==
0
)
{
if
(
range
==
0
)
{
...
...
src/query/src/qParserImpl.c
浏览文件 @
afa86981
...
@@ -158,7 +158,7 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
...
@@ -158,7 +158,7 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
pExpr
->
nSQLOptr
=
optType
;
pExpr
->
nSQLOptr
=
optType
;
pExpr
->
pParam
=
pList
;
pExpr
->
pParam
=
pList
;
int32_t
len
=
(
endToken
->
z
+
endToken
->
n
)
-
pFuncToken
->
z
;
int32_t
len
=
(
int32_t
)((
endToken
->
z
+
endToken
->
n
)
-
pFuncToken
->
z
)
;
pExpr
->
operand
.
z
=
pFuncToken
->
z
;
pExpr
->
operand
.
z
=
pFuncToken
->
z
;
pExpr
->
operand
.
n
=
len
;
// raw field name
pExpr
->
operand
.
n
=
len
;
// raw field name
...
@@ -468,7 +468,7 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType)
...
@@ -468,7 +468,7 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType)
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
// truncate the column name
// truncate the column name
if
(
pName
->
n
>=
maxLen
)
{
if
(
(
int32_t
)
pName
->
n
>=
maxLen
)
{
pName
->
n
=
maxLen
-
1
;
pName
->
n
=
maxLen
-
1
;
}
}
...
@@ -524,7 +524,7 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
...
@@ -524,7 +524,7 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
SQuerySQL
*
pQuery
=
calloc
(
1
,
sizeof
(
SQuerySQL
));
SQuerySQL
*
pQuery
=
calloc
(
1
,
sizeof
(
SQuerySQL
));
pQuery
->
selectToken
=
*
pSelectToken
;
pQuery
->
selectToken
=
*
pSelectToken
;
pQuery
->
selectToken
.
n
=
strlen
(
pQuery
->
selectToken
.
z
);
// all later sql string are belonged to the stream sql
pQuery
->
selectToken
.
n
=
(
uint32_t
)
strlen
(
pQuery
->
selectToken
.
z
);
// all later sql string are belonged to the stream sql
pQuery
->
pSelection
=
pSelection
;
pQuery
->
pSelection
=
pSelection
;
pQuery
->
from
=
pFrom
;
pQuery
->
from
=
pFrom
;
...
...
src/query/src/qPercentile.c
浏览文件 @
afa86981
...
@@ -55,18 +55,18 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx,
...
@@ -55,18 +55,18 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx,
// load data in disk to memory
// load data in disk to memory
tFilePage
*
pPage
=
(
tFilePage
*
)
calloc
(
1
,
pMemBuffer
->
pageSize
);
tFilePage
*
pPage
=
(
tFilePage
*
)
calloc
(
1
,
pMemBuffer
->
pageSize
);
for
(
int32_t
i
=
0
;
i
<
pMemBuffer
->
fileMeta
.
flushoutData
.
nLength
;
++
i
)
{
for
(
u
int32_t
i
=
0
;
i
<
pMemBuffer
->
fileMeta
.
flushoutData
.
nLength
;
++
i
)
{
tFlushoutInfo
*
pFlushInfo
=
&
pMemBuffer
->
fileMeta
.
flushoutData
.
pFlushoutInfo
[
i
];
tFlushoutInfo
*
pFlushInfo
=
&
pMemBuffer
->
fileMeta
.
flushoutData
.
pFlushoutInfo
[
i
];
int32_t
ret
=
fseek
(
pMemBuffer
->
file
,
pFlushInfo
->
startPageId
*
pMemBuffer
->
pageSize
,
SEEK_SET
);
int32_t
ret
=
fseek
(
pMemBuffer
->
file
,
pFlushInfo
->
startPageId
*
pMemBuffer
->
pageSize
,
SEEK_SET
);
UNUSED
(
ret
);
UNUSED
(
ret
);
for
(
uint32_t
j
=
0
;
j
<
pFlushInfo
->
numOfPages
;
++
j
)
{
for
(
uint32_t
j
=
0
;
j
<
pFlushInfo
->
numOfPages
;
++
j
)
{
ret
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
ret
=
(
int32_t
)
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
ret
);
UNUSED
(
ret
);
assert
(
pPage
->
num
>
0
);
assert
(
pPage
->
num
>
0
);
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pPage
->
data
,
0
,
pPage
->
num
,
pPage
->
num
);
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pPage
->
data
,
0
,
(
int32_t
)
pPage
->
num
,
(
int32_t
)
pPage
->
num
);
printf
(
"id: %d count: %"
PRIu64
"
\n
"
,
j
,
buffer
->
num
);
printf
(
"id: %d count: %"
PRIu64
"
\n
"
,
j
,
buffer
->
num
);
}
}
}
}
...
@@ -78,12 +78,12 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx,
...
@@ -78,12 +78,12 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx,
// load data in pMemBuffer to buffer
// load data in pMemBuffer to buffer
tFilePagesItem
*
pListItem
=
pMemBuffer
->
pHead
;
tFilePagesItem
*
pListItem
=
pMemBuffer
->
pHead
;
while
(
pListItem
!=
NULL
)
{
while
(
pListItem
!=
NULL
)
{
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pListItem
->
item
.
data
,
0
,
pListItem
->
item
.
num
,
tColModelAppend
(
pDesc
->
pColumnModel
,
buffer
,
pListItem
->
item
.
data
,
0
,
(
int32_t
)
pListItem
->
item
.
num
,
pListItem
->
item
.
num
);
(
int32_t
)
pListItem
->
item
.
num
);
pListItem
=
pListItem
->
pNext
;
pListItem
=
pListItem
->
pNext
;
}
}
tColDataQSort
(
pDesc
,
buffer
->
num
,
0
,
buffer
->
num
-
1
,
buffer
->
data
,
TSDB_ORDER_ASC
);
tColDataQSort
(
pDesc
,
(
int32_t
)
buffer
->
num
,
0
,
(
int32_t
)
buffer
->
num
-
1
,
buffer
->
data
,
TSDB_ORDER_ASC
);
pDesc
->
pColumnModel
->
capacity
=
oldCapacity
;
// restore value
pDesc
->
pColumnModel
->
capacity
=
oldCapacity
;
// restore value
return
buffer
;
return
buffer
;
...
@@ -883,7 +883,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
...
@@ -883,7 +883,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
if
(
sz
!=
pMemBuffer
->
pageSize
)
{
if
(
sz
!=
pMemBuffer
->
pageSize
)
{
uError
(
"MemBucket:%p, read tmp file %s failed"
,
pMemBucket
,
pMemBuffer
->
path
);
uError
(
"MemBucket:%p, read tmp file %s failed"
,
pMemBucket
,
pMemBuffer
->
path
);
}
else
{
}
else
{
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
);
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
(
int32_t
)
pPage
->
num
);
}
}
}
}
...
...
src/query/src/qResultbuf.c
浏览文件 @
afa86981
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#include "queryLog.h"
#include "queryLog.h"
#include "taoserror.h"
#include "taoserror.h"
#define GET_DATA_PAYLOAD(_p) ((
_p)->pData + POINTER_BYTES
)
#define GET_DATA_PAYLOAD(_p) ((
tFilePage*)(((char*)(_p)->pData) + POINTER_BYTES)
)
int32_t
createDiskbasedResultBuffer
(
SDiskbasedResultBuf
**
pResultBuf
,
int32_t
rowSize
,
int32_t
pagesize
,
int32_t
createDiskbasedResultBuffer
(
SDiskbasedResultBuf
**
pResultBuf
,
int32_t
rowSize
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
const
void
*
handle
)
{
int32_t
inMemBufSize
,
const
void
*
handle
)
{
...
@@ -95,8 +95,8 @@ static int32_t allocatePositionInFile(SDiskbasedResultBuf* pResultBuf, size_t si
...
@@ -95,8 +95,8 @@ static int32_t allocatePositionInFile(SDiskbasedResultBuf* pResultBuf, size_t si
SFreeListItem
*
pi
=
taosArrayGet
(
pResultBuf
->
pFree
,
i
);
SFreeListItem
*
pi
=
taosArrayGet
(
pResultBuf
->
pFree
,
i
);
if
(
pi
->
len
>=
size
)
{
if
(
pi
->
len
>=
size
)
{
offset
=
pi
->
offset
;
offset
=
pi
->
offset
;
pi
->
offset
+=
size
;
pi
->
offset
+=
(
int32_t
)
size
;
pi
->
len
-=
size
;
pi
->
len
-=
(
int32_t
)
size
;
return
offset
;
return
offset
;
}
}
...
@@ -172,7 +172,7 @@ static char* flushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
...
@@ -172,7 +172,7 @@ static char* flushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
// load file block data in disk
// load file block data in disk
static
char
*
loadPageFromDisk
(
SDiskbasedResultBuf
*
pResultBuf
,
SPageInfo
*
pg
)
{
static
char
*
loadPageFromDisk
(
SDiskbasedResultBuf
*
pResultBuf
,
SPageInfo
*
pg
)
{
int32_t
ret
=
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
int32_t
ret
=
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
ret
=
fread
(
GET_DATA_PAYLOAD
(
pg
),
1
,
pg
->
info
.
length
,
pResultBuf
->
file
);
ret
=
(
int32_t
)
fread
(
GET_DATA_PAYLOAD
(
pg
),
1
,
pg
->
info
.
length
,
pResultBuf
->
file
);
if
(
ret
!=
pg
->
info
.
length
)
{
if
(
ret
!=
pg
->
info
.
length
)
{
terrno
=
errno
;
terrno
=
errno
;
return
NULL
;
return
NULL
;
...
@@ -183,7 +183,7 @@ static char* loadPageFromDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
...
@@ -183,7 +183,7 @@ static char* loadPageFromDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
int32_t
fullSize
=
0
;
int32_t
fullSize
=
0
;
doDecompressData
(
GET_DATA_PAYLOAD
(
pg
),
pg
->
info
.
length
,
&
fullSize
,
pResultBuf
);
doDecompressData
(
GET_DATA_PAYLOAD
(
pg
),
pg
->
info
.
length
,
&
fullSize
,
pResultBuf
);
return
GET_DATA_PAYLOAD
(
pg
);
return
(
char
*
)
GET_DATA_PAYLOAD
(
pg
);
}
}
#define NO_AVAILABLE_PAGES(_b) ((_b)->numOfPages >= (_b)->inMemPages)
#define NO_AVAILABLE_PAGES(_b) ((_b)->numOfPages >= (_b)->inMemPages)
...
@@ -246,7 +246,7 @@ static char* evicOneDataPage(SDiskbasedResultBuf* pResultBuf) {
...
@@ -246,7 +246,7 @@ static char* evicOneDataPage(SDiskbasedResultBuf* pResultBuf) {
// all pages are referenced by user, try to allocate new space
// all pages are referenced by user, try to allocate new space
if
(
pn
==
NULL
)
{
if
(
pn
==
NULL
)
{
int32_t
prev
=
pResultBuf
->
inMemPages
;
int32_t
prev
=
pResultBuf
->
inMemPages
;
pResultBuf
->
inMemPages
=
pResultBuf
->
inMemPages
*
1
.
5
;
pResultBuf
->
inMemPages
=
(
int32_t
)(
pResultBuf
->
inMemPages
*
1
.
5
f
)
;
qWarn
(
"%p in memory buf page not sufficient, expand from %d to %d, page size:%d"
,
pResultBuf
,
prev
,
qWarn
(
"%p in memory buf page not sufficient, expand from %d to %d, page size:%d"
,
pResultBuf
,
prev
,
pResultBuf
->
inMemPages
,
pResultBuf
->
pageSize
);
pResultBuf
->
inMemPages
,
pResultBuf
->
pageSize
);
...
...
src/query/src/qTokenizer.c
浏览文件 @
afa86981
...
@@ -254,12 +254,12 @@ static const char isIdChar[] = {
...
@@ -254,12 +254,12 @@ static const char isIdChar[] = {
static
void
*
KeywordHashTable
=
NULL
;
static
void
*
KeywordHashTable
=
NULL
;
static
void
doInitKeywordsTable
()
{
static
void
doInitKeywordsTable
(
void
)
{
int
numOfEntries
=
tListLen
(
keywordTable
);
int
numOfEntries
=
tListLen
(
keywordTable
);
KeywordHashTable
=
taosHashInit
(
numOfEntries
,
MurmurHash3_32
,
false
);
KeywordHashTable
=
taosHashInit
(
numOfEntries
,
MurmurHash3_32
,
false
);
for
(
int32_t
i
=
0
;
i
<
numOfEntries
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfEntries
;
i
++
)
{
keywordTable
[
i
].
len
=
strlen
(
keywordTable
[
i
].
name
);
keywordTable
[
i
].
len
=
(
uint8_t
)
strlen
(
keywordTable
[
i
].
name
);
void
*
ptr
=
&
keywordTable
[
i
];
void
*
ptr
=
&
keywordTable
[
i
];
taosHashPut
(
KeywordHashTable
,
keywordTable
[
i
].
name
,
keywordTable
[
i
].
len
,
(
void
*
)
&
ptr
,
POINTER_BYTES
);
taosHashPut
(
KeywordHashTable
,
keywordTable
[
i
].
name
,
keywordTable
[
i
].
len
,
(
void
*
)
&
ptr
,
POINTER_BYTES
);
}
}
...
...
src/query/src/qTsbuf.c
浏览文件 @
afa86981
...
@@ -75,7 +75,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -75,7 +75,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
return
NULL
;
}
}
if
(
header
.
numOfVnode
>
pTSBuf
->
numOfAlloc
)
{
if
(
(
int32_t
)
header
.
numOfVnode
>
pTSBuf
->
numOfAlloc
)
{
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
...
@@ -171,7 +171,7 @@ static STSVnodeBlockInfoEx* tsBufGetLastVnodeInfo(STSBuf* pTSBuf) {
...
@@ -171,7 +171,7 @@ static STSVnodeBlockInfoEx* tsBufGetLastVnodeInfo(STSBuf* pTSBuf) {
static
STSVnodeBlockInfoEx
*
addOneVnodeInfo
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
)
{
static
STSVnodeBlockInfoEx
*
addOneVnodeInfo
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
)
{
if
(
pTSBuf
->
numOfAlloc
<=
pTSBuf
->
numOfVnodes
)
{
if
(
pTSBuf
->
numOfAlloc
<=
pTSBuf
->
numOfVnodes
)
{
uint32_t
newSize
=
(
uint32_t
)(
pTSBuf
->
numOfAlloc
*
1
.
5
);
uint32_t
newSize
=
(
uint32_t
)(
pTSBuf
->
numOfAlloc
*
1
.
5
);
assert
(
newSize
>
pTSBuf
->
numOfAlloc
);
assert
(
(
int32_t
)
newSize
>
pTSBuf
->
numOfAlloc
);
STSVnodeBlockInfoEx
*
tmp
=
(
STSVnodeBlockInfoEx
*
)
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
newSize
);
STSVnodeBlockInfoEx
*
tmp
=
(
STSVnodeBlockInfoEx
*
)
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
newSize
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
...
@@ -288,7 +288,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
...
@@ -288,7 +288,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
* set the right position for the reversed traverse, the reversed traverse is started from
* set the right position for the reversed traverse, the reversed traverse is started from
* the end of each comp data block
* the end of each comp data block
*/
*/
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
-
sizeof
(
pBlock
->
padding
),
SEEK_CUR
);
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
-
(
int32_t
)(
sizeof
(
pBlock
->
padding
)
),
SEEK_CUR
);
size_t
sz
=
fread
(
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
),
1
,
pTSBuf
->
f
);
size_t
sz
=
fread
(
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
UNUSED
(
sz
);
...
@@ -474,7 +474,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo
...
@@ -474,7 +474,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo
offset
=
pBlockInfo
->
offset
+
pBlockInfo
->
compLen
;
offset
=
pBlockInfo
->
offset
+
pBlockInfo
->
compLen
;
}
}
if
(
fseek
(
pTSBuf
->
f
,
offset
,
SEEK_SET
)
!=
0
)
{
if
(
fseek
(
pTSBuf
->
f
,
(
int32_t
)
offset
,
SEEK_SET
)
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -524,7 +524,7 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t vnodeIndex, int32_t blockIndex
...
@@ -524,7 +524,7 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t vnodeIndex, int32_t blockIndex
* may exceed the maximum allowed size during *tsBufAppend* function by invoking expandBuffer function
* may exceed the maximum allowed size during *tsBufAppend* function by invoking expandBuffer function
*/
*/
if
(
s
>
pTSBuf
->
tsData
.
allocSize
)
{
if
(
s
>
pTSBuf
->
tsData
.
allocSize
)
{
expandBuffer
(
&
pTSBuf
->
tsData
,
s
);
expandBuffer
(
&
pTSBuf
->
tsData
,
(
int32_t
)
s
);
}
}
pTSBuf
->
tsData
.
len
=
pTSBuf
->
tsData
.
len
=
...
@@ -737,7 +737,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) {
...
@@ -737,7 +737,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) {
assert
(
r
==
0
);
assert
(
r
==
0
);
int64_t
offset
=
getDataStartOffset
();
int64_t
offset
=
getDataStartOffset
();
int32_t
size
=
pSrcBuf
->
fileSize
-
offset
;
int32_t
size
=
(
int32_t
)
pSrcBuf
->
fileSize
-
(
int32_t
)
offset
;
ssize_t
rc
=
taosFSendFile
(
pDestBuf
->
f
,
pSrcBuf
->
f
,
&
offset
,
size
);
ssize_t
rc
=
taosFSendFile
(
pDestBuf
->
f
,
pSrcBuf
->
f
,
&
offset
,
size
);
...
@@ -896,7 +896,7 @@ static int32_t doUpdateVnodeInfo(STSBuf* pTSBuf, int64_t offset, STSVnodeBlockIn
...
@@ -896,7 +896,7 @@ static int32_t doUpdateVnodeInfo(STSBuf* pTSBuf, int64_t offset, STSVnodeBlockIn
return
-
1
;
return
-
1
;
}
}
if
(
fseek
(
pTSBuf
->
f
,
offset
,
SEEK_SET
)
!=
0
)
{
if
(
fseek
(
pTSBuf
->
f
,
(
int32_t
)
offset
,
SEEK_SET
)
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录