Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
869171d2
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看板
提交
869171d2
编写于
11月 07, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor the allocation buffer for load data block into memory
上级
c2e91fcb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
29 deletion
+29
-29
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+2
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+4
-4
src/system/detail/inc/vnodeRead.h
src/system/detail/inc/vnodeRead.h
+0
-1
src/system/detail/src/vnodeFile.c
src/system/detail/src/vnodeFile.c
+7
-8
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+16
-15
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
869171d2
...
...
@@ -266,7 +266,8 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
}
else
if
(
functionId
==
TSDB_FUNC_PERCT
)
{
*
type
=
(
int16_t
)
TSDB_DATA_TYPE_DOUBLE
;
*
bytes
=
(
int16_t
)
sizeof
(
double
);
*
intermediateResBytes
=
POINTER_BYTES
;
//*intermediateResBytes = POINTER_BYTES;
*
intermediateResBytes
=
(
int16_t
)
sizeof
(
double
);
}
else
if
(
functionId
==
TSDB_FUNC_LEASTSQR
)
{
*
type
=
TSDB_DATA_TYPE_BINARY
;
*
bytes
=
TSDB_AVG_FUNCTION_INTER_BUFFER_SIZE
;
// string
...
...
src/client/src/tscSql.c
浏览文件 @
869171d2
...
...
@@ -262,15 +262,15 @@ int taos_query_imp(STscObj* pObj, SSqlObj* pSql) {
int
taos_query
(
TAOS
*
taos
,
const
char
*
sqlstr
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
SSqlObj
*
pSql
=
pObj
->
pSql
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
return
TSDB_CODE_DISCONNECTED
;
}
int32_t
sqlLen
=
strlen
(
sqlstr
);
SSqlObj
*
pSql
=
pObj
->
pSql
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
size_t
sqlLen
=
strlen
(
sqlstr
);
if
(
sqlLen
>
TSDB_MAX_SQL_LEN
)
{
tscError
(
"%p sql too long"
,
pSql
);
pRes
->
code
=
TSDB_CODE_INVALID_SQL
;
...
...
src/system/detail/inc/vnodeRead.h
浏览文件 @
869171d2
...
...
@@ -122,7 +122,6 @@ typedef struct RuntimeEnvironment {
SQuery
*
pQuery
;
SMeterObj
*
pMeterObj
;
SQLFunctionCtx
*
pCtx
;
char
*
buffer
;
/* column data load buffer, colDataBuffer is point to this value */
SQueryLoadBlockInfo
loadBlockInfo
;
/* record current block load information */
SQueryLoadCompBlockInfo
loadCompBlockInfo
;
/* record current compblock information in SQuery */
...
...
src/system/detail/src/vnodeFile.c
浏览文件 @
869171d2
...
...
@@ -1522,7 +1522,6 @@ int vnodeQueryFromFile(SMeterObj *pObj, SQuery *pQuery) {
int
lastPos
=
-
1
,
startPos
;
int
col
,
step
,
code
=
0
;
char
*
pRead
,
*
pData
;
char
*
buffer
;
SData
*
sdata
[
TSDB_MAX_COLUMNS
];
SCompBlock
*
pBlock
=
NULL
;
SVnodeObj
*
pVnode
=
&
vnodeList
[
pObj
->
vnode
];
...
...
@@ -1556,12 +1555,10 @@ int vnodeQueryFromFile(SMeterObj *pObj, SQuery *pQuery) {
if
(
pQuery
->
over
)
return
0
;
// allocate memory more efficiently
buffer
=
calloc
(
1
,
pQuery
->
dataRowSize
*
pBlock
->
numOfPoints
+
sizeof
(
SData
)
*
pQuery
->
numOfCols
);
sdata
[
0
]
=
(
SData
*
)
buffer
;
for
(
col
=
1
;
col
<
pQuery
->
numOfCols
;
++
col
)
sdata
[
col
]
=
(
SData
*
)(((
char
*
)
sdata
[
col
-
1
])
+
sizeof
(
SData
)
+
pBlock
->
numOfPoints
*
pQuery
->
colList
[
col
-
1
].
data
.
bytes
);
// To make sure the start position of each buffer is aligned to 4bytes in 32-bit ARM system.
for
(
col
=
0
;
col
<
pQuery
->
numOfCols
;
++
col
)
{
sdata
[
col
]
=
calloc
(
1
,
sizeof
(
SData
)
+
pBlock
->
numOfPoints
*
pQuery
->
colList
[
col
].
data
.
bytes
+
EXTRA_BYTES
);
}
/*
* timestamp column is fetched in any cases. Therefore, if the query does not fetch primary column,
...
...
@@ -1768,7 +1765,9 @@ _next:
pQuery
->
slot
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
0
:
pQuery
->
numOfBlocks
-
1
;
}
tfree
(
buffer
);
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfCols
;
++
i
)
{
tfree
(
sdata
[
i
]);
}
return
code
;
}
...
...
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
869171d2
...
...
@@ -1931,19 +1931,13 @@ static int32_t setupQueryRuntimeEnv(SMeterObj *pMeterObj, SQuery *pQuery, SQuery
// for loading block data in memory
assert
(
vnodeList
[
pMeterObj
->
vnode
].
cfg
.
rowsInFileBlock
==
pMeterObj
->
pointsPerFileBlock
);
size_t
loadDataBlockBufferSize
=
pQuery
->
dataRowSize
*
(
pMeterObj
->
pointsPerFileBlock
)
+
(
sizeof
(
SData
)
+
EXTRA_BYTES
)
*
pQuery
->
numOfCols
;
pRuntimeEnv
->
buffer
=
(
char
*
)
malloc
(
loadDataBlockBufferSize
);
if
(
pRuntimeEnv
->
buffer
==
NULL
)
{
goto
_error_clean
;
}
pRuntimeEnv
->
colDataBuffer
[
0
]
=
(
SData
*
)
pRuntimeEnv
->
buffer
;
for
(
int32_t
i
=
1
;
i
<
pQuery
->
numOfCols
;
++
i
)
{
int32_t
bytes
=
pQuery
->
colList
[
i
-
1
].
data
.
bytes
;
pRuntimeEnv
->
colDataBuffer
[
i
]
=
(
SData
*
)(((
void
*
)
pRuntimeEnv
->
colDataBuffer
[
i
-
1
])
+
sizeof
(
SData
)
+
EXTRA_BYTES
+
pMeterObj
->
pointsPerFileBlock
*
bytes
);
// To make sure the start position of each buffer is aligned to 4bytes in 32-bit ARM system.
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfCols
;
++
i
)
{
int32_t
bytes
=
pQuery
->
colList
[
i
].
data
.
bytes
;
pRuntimeEnv
->
colDataBuffer
[
i
]
=
calloc
(
1
,
sizeof
(
SData
)
+
EXTRA_BYTES
+
pMeterObj
->
pointsPerFileBlock
*
bytes
);
if
(
pRuntimeEnv
->
colDataBuffer
[
i
]
==
NULL
)
{
goto
_error_clean
;
}
}
// record the maximum column width among columns of this meter/metric
...
...
@@ -1978,7 +1972,11 @@ static int32_t setupQueryRuntimeEnv(SMeterObj *pMeterObj, SQuery *pQuery, SQuery
_error_clean:
tfree
(
pRuntimeEnv
->
resultInfo
);
tfree
(
pRuntimeEnv
->
pCtx
);
tfree
(
pRuntimeEnv
->
buffer
);
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfCols
;
++
i
)
{
tfree
(
pRuntimeEnv
->
colDataBuffer
[
i
]);
}
tfree
(
pRuntimeEnv
->
unzipBuffer
);
tfree
(
pRuntimeEnv
->
secondaryUnzipBuffer
);
...
...
@@ -1995,7 +1993,10 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
}
dTrace
(
"QInfo:%p teardown runtime env"
,
GET_QINFO_ADDR
(
pRuntimeEnv
->
pQuery
));
tfree
(
pRuntimeEnv
->
buffer
);
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfCols
;
++
i
)
{
tfree
(
pRuntimeEnv
->
colDataBuffer
[
i
]);
}
tfree
(
pRuntimeEnv
->
secondaryUnzipBuffer
);
taosCleanUpIntHash
(
pRuntimeEnv
->
hashList
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录