Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d2ef1dad
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看板
提交
d2ef1dad
编写于
12月 10, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[tbase-1287]
上级
2ab2e283
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
42 deletion
+72
-42
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-4
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+15
-10
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+3
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+52
-25
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
d2ef1dad
...
@@ -67,7 +67,7 @@ typedef struct SJoinSubquerySupporter {
...
@@ -67,7 +67,7 @@ typedef struct SJoinSubquerySupporter {
}
SJoinSubquerySupporter
;
}
SJoinSubquerySupporter
;
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
STableDataBlocks
*
tscCreateDataBlock
(
int32_t
siz
e
);
STableDataBlocks
*
tscCreateDataBlock
(
size_t
initialBufSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
nam
e
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
);
uint32_t
offset
);
...
@@ -78,9 +78,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDa
...
@@ -78,9 +78,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDa
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
STableDataBlocks
*
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
STableDataBlocks
*
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
char
*
tableId
);
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
);
STableDataBlocks
*
tscCreateDataBlockEx
(
size_t
size
,
int32_t
rowSize
,
int32_t
startOffset
,
char
*
name
);
SVnodeSidList
*
tscGetVnodeSidList
(
SMetricMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
SVnodeSidList
*
tscGetVnodeSidList
(
SMetricMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
SMeterSidExtInfo
*
tscGetMeterSidInfo
(
SVnodeSidList
*
pSidList
,
int32_t
idx
);
SMeterSidExtInfo
*
tscGetMeterSidInfo
(
SVnodeSidList
*
pSidList
,
int32_t
idx
);
...
...
src/client/inc/tsclient.h
浏览文件 @
d2ef1dad
...
@@ -231,17 +231,22 @@ typedef struct SParamInfo {
...
@@ -231,17 +231,22 @@ typedef struct SParamInfo {
typedef
struct
STableDataBlocks
{
typedef
struct
STableDataBlocks
{
char
meterId
[
TSDB_METER_ID_LEN
];
char
meterId
[
TSDB_METER_ID_LEN
];
int8_t
tsSource
;
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
bool
ordered
;
bool
ordered
;
// if current rows are ordered or not
int64_t
vgid
;
// virtual group id
int64_t
prevTS
;
// previous timestamp, recorded to decide if the records array is ts ascending
int32_t
numOfMeters
;
// number of tables in current submit block
int64_t
vgid
;
int32_t
rowSize
;
// row size for current table
int64_t
prevTS
;
int32_t
numOfMeters
;
int32_t
rowSize
;
uint32_t
nAllocSize
;
uint32_t
nAllocSize
;
uint32_t
size
;
uint32_t
size
;
/*
* the metermeta for current table, the metermeta will be used during submit stage, keep a ref
* to avoid it to be removed from cache
*/
SMeterMeta
*
pMeterMeta
;
union
{
union
{
char
*
filename
;
char
*
filename
;
char
*
pData
;
char
*
pData
;
...
@@ -255,8 +260,8 @@ typedef struct STableDataBlocks {
...
@@ -255,8 +260,8 @@ typedef struct STableDataBlocks {
typedef
struct
SDataBlockList
{
typedef
struct
SDataBlockList
{
int32_t
idx
;
int32_t
idx
;
int32_t
nSize
;
uint32_t
nSize
;
int32_t
nAlloc
;
uint32_t
nAlloc
;
char
*
userParam
;
/* user assigned parameters for async query */
char
*
userParam
;
/* user assigned parameters for async query */
void
*
udfp
;
/* user defined function pointer, used in async model */
void
*
udfp
;
/* user defined function pointer, used in async model */
STableDataBlocks
**
pData
;
STableDataBlocks
**
pData
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
d2ef1dad
...
@@ -985,7 +985,7 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
...
@@ -985,7 +985,7 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
strcpy
(
fname
,
full_path
.
we_wordv
[
0
]);
strcpy
(
fname
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
STableDataBlocks
*
pDataBlock
=
tscCreateDataBlock
Ex
(
PATH_MAX
,
pMeterMetaInfo
->
pMeterMeta
->
rowSize
,
STableDataBlocks
*
pDataBlock
=
tscCreateDataBlock
(
PATH_MAX
,
pMeterMetaInfo
->
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
);
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
);
tscAppendDataBlock
(
pCmd
->
pDataBlocks
,
pDataBlock
);
tscAppendDataBlock
(
pCmd
->
pDataBlocks
,
pDataBlock
);
...
@@ -1222,8 +1222,8 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
...
@@ -1222,8 +1222,8 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
int32_t
rowSize
=
pMeterMeta
->
rowSize
;
int32_t
rowSize
=
pMeterMeta
->
rowSize
;
pCmd
->
pDataBlocks
=
tscCreateBlockArrayList
();
pCmd
->
pDataBlocks
=
tscCreateBlockArrayList
();
STableDataBlocks
*
pTableDataBlock
=
STableDataBlocks
*
pTableDataBlock
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
pMeterMeta
->
rowSize
,
tscCreateDataBlockEx
(
TSDB_PAYLOAD_SIZE
,
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
);
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
);
tscAppendDataBlock
(
pCmd
->
pDataBlocks
,
pTableDataBlock
);
tscAppendDataBlock
(
pCmd
->
pDataBlocks
,
pTableDataBlock
);
...
...
src/client/src/tscUtil.c
浏览文件 @
d2ef1dad
...
@@ -451,15 +451,6 @@ void tscFreeSqlObj(SSqlObj* pSql) {
...
@@ -451,15 +451,6 @@ void tscFreeSqlObj(SSqlObj* pSql) {
free
(
pSql
);
free
(
pSql
);
}
}
STableDataBlocks
*
tscCreateDataBlock
(
int32_t
size
)
{
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
dataBuf
->
nAllocSize
=
(
uint32_t
)
size
;
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
return
dataBuf
;
}
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
)
{
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
)
{
if
(
pDataBlock
==
NULL
)
{
if
(
pDataBlock
==
NULL
)
{
return
;
return
;
...
@@ -467,6 +458,9 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
...
@@ -467,6 +458,9 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
tfree
(
pDataBlock
->
pData
);
tfree
(
pDataBlock
->
pData
);
tfree
(
pDataBlock
->
params
);
tfree
(
pDataBlock
->
params
);
// free the refcount for metermeta
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pDataBlock
->
pMeterMeta
),
false
);
tfree
(
pDataBlock
);
tfree
(
pDataBlock
);
}
}
...
@@ -513,11 +507,11 @@ SDataBlockList* tscCreateBlockArrayList() {
...
@@ -513,11 +507,11 @@ SDataBlockList* tscCreateBlockArrayList() {
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
)
{
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
)
{
if
(
pList
->
nSize
>=
pList
->
nAlloc
)
{
if
(
pList
->
nSize
>=
pList
->
nAlloc
)
{
pList
->
nAlloc
=
pList
->
nAlloc
<<
1
;
pList
->
nAlloc
=
(
pList
->
nAlloc
)
<<
1U
;
pList
->
pData
=
realloc
(
pList
->
pData
,
sizeof
(
void
*
)
*
(
size_t
)
pList
->
nAlloc
);
pList
->
pData
=
realloc
(
pList
->
pData
,
POINTER_BYTES
*
(
size_t
)
pList
->
nAlloc
);
// reset allocated memory
// reset allocated memory
memset
(
pList
->
pData
+
pList
->
nSize
,
0
,
sizeof
(
void
*
)
*
(
pList
->
nAlloc
-
pList
->
nSize
));
memset
(
pList
->
pData
+
pList
->
nSize
,
0
,
POINTER_BYTES
*
(
pList
->
nAlloc
-
pList
->
nSize
));
}
}
pList
->
pData
[
pList
->
nSize
++
]
=
pBlocks
;
pList
->
pData
[
pList
->
nSize
++
]
=
pBlocks
;
...
@@ -539,29 +533,43 @@ void* tscDestroyBlockArrayList(SDataBlockList* pList) {
...
@@ -539,29 +533,43 @@ void* tscDestroyBlockArrayList(SDataBlockList* pList) {
}
}
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
)
{
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
assert
(
pDataBlock
->
pMeterMeta
!=
NULL
);
pCmd
->
count
=
pDataBlock
->
numOfMeters
;
pCmd
->
count
=
pDataBlock
->
numOfMeters
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
strcpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meterId
);
//set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
if
(
pMeterMetaInfo
->
pMeterMeta
!=
pDataBlock
->
pMeterMeta
)
{
strcpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meterId
);
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pMeterMetaInfo
->
pMeterMeta
),
false
);
pMeterMetaInfo
->
pMeterMeta
=
pDataBlock
->
pMeterMeta
;
pDataBlock
->
pMeterMeta
=
NULL
;
// delegate the ownership of metermeta to pMeterMetaInfo
}
else
{
assert
(
strncmp
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meterId
,
tListLen
(
pDataBlock
->
meterId
))
==
0
);
}
/*
/*
* the submit message consists of : [RPC header|message body|digest]
* the submit message consists of : [RPC header|message body|digest]
* the dataBlock only includes the RPC Header buffer and actual submit messsage body, space for digest needs
* the dataBlock only includes the RPC Header buffer and actual submit messsage body, space for digest needs
* additional space.
* additional space.
*/
*/
int
ret
=
tscAllocPayload
(
pCmd
,
pDataBlock
->
nAllocSize
+
sizeof
(
STaosDigest
));
int
ret
=
tscAllocPayload
(
pCmd
,
pDataBlock
->
nAllocSize
+
sizeof
(
STaosDigest
));
if
(
TSDB_CODE_SUCCESS
!=
ret
)
return
ret
;
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
return
ret
;
}
memcpy
(
pCmd
->
payload
,
pDataBlock
->
pData
,
pDataBlock
->
nAllocSize
);
memcpy
(
pCmd
->
payload
,
pDataBlock
->
pData
,
pDataBlock
->
nAllocSize
);
/*
/*
* the payloadLen should be actual message body size
* the payloadLen should be actual message body size
* the old value of payloadLen is the allocated payload size
* the old value of payloadLen is the allocated payload size
*/
*/
pCmd
->
payloadLen
=
pDataBlock
->
nAllocSize
-
tsRpcHeadSize
;
pCmd
->
payloadLen
=
pDataBlock
->
nAllocSize
-
tsRpcHeadSize
;
assert
(
pCmd
->
allocSize
>=
pCmd
->
payloadLen
+
tsRpcHeadSize
+
sizeof
(
STaosDigest
));
assert
(
pCmd
->
allocSize
>=
pCmd
->
payloadLen
+
tsRpcHeadSize
+
sizeof
(
STaosDigest
));
return
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
->
name
,
0
)
;
return
TSDB_CODE_SUCCESS
;
}
}
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
)
{
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
)
{
...
@@ -573,19 +581,38 @@ void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
...
@@ -573,19 +581,38 @@ void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
}
}
}
}
STableDataBlocks
*
tscCreateDataBlockEx
(
size_t
size
,
int32_t
rowSize
,
int32_t
startOffset
,
char
*
name
)
{
/**
STableDataBlocks
*
dataBuf
=
tscCreateDataBlock
(
size
);
* create the in-memory buffer for each table to keep the submitted data block
* @param initialSize
* @param rowSize
* @param startOffset
* @param name
* @param pMeterMeta the ownership of pMeterMeta should be transfer to STableDataBlocks
* @return
*/
STableDataBlocks
*
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
)
{
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
dataBuf
->
nAllocSize
=
(
uint32_t
)
initialSize
;
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
tsSource
=
-
1
;
dataBuf
->
tsSource
=
-
1
;
strncpy
(
dataBuf
->
meterId
,
name
,
TSDB_METER_ID_LEN
);
strncpy
(
dataBuf
->
meterId
,
name
,
TSDB_METER_ID_LEN
);
// sure that the metermeta must be in the local client cache
dataBuf
->
pMeterMeta
=
taosGetDataFromCache
(
tscCacheHandle
,
dataBuf
->
meterId
);
assert
(
dataBuf
->
pMeterMeta
!=
NULL
&&
initialSize
>
0
);
return
dataBuf
;
return
dataBuf
;
}
}
STableDataBlocks
*
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
STableDataBlocks
*
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
char
*
tableId
)
{
int32_t
startOffset
,
int32_t
rowSize
,
c
onst
c
har
*
tableId
)
{
STableDataBlocks
*
dataBuf
=
NULL
;
STableDataBlocks
*
dataBuf
=
NULL
;
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosGetIntHashData
(
pHashList
,
id
);
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosGetIntHashData
(
pHashList
,
id
);
...
@@ -594,7 +621,7 @@ STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pData
...
@@ -594,7 +621,7 @@ STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pData
}
}
if
(
dataBuf
==
NULL
)
{
if
(
dataBuf
==
NULL
)
{
dataBuf
=
tscCreateDataBlock
Ex
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
);
dataBuf
=
tscCreateDataBlock
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
);
dataBuf
=
*
(
STableDataBlocks
**
)
taosAddIntHash
(
pHashList
,
id
,
(
char
*
)
&
dataBuf
);
dataBuf
=
*
(
STableDataBlocks
**
)
taosAddIntHash
(
pHashList
,
id
,
(
char
*
)
&
dataBuf
);
tscAppendDataBlock
(
pDataBlockList
,
dataBuf
);
tscAppendDataBlock
(
pDataBlockList
,
dataBuf
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录