Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
2fe0304b
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看板
提交
2fe0304b
编写于
7月 21, 2020
作者:
R
root
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/query' of
https://github.com/taosdata/TDengine
into feature/query
上级
d633a966
b4fce76b
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
124 addition
and
106 deletion
+124
-106
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+1
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-1
src/query/inc/qResultbuf.h
src/query/inc/qResultbuf.h
+14
-5
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+0
-0
src/query/src/qAst.c
src/query/src/qAst.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+8
-6
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+1
-1
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+16
-12
src/query/src/sql.c
src/query/src/sql.c
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+79
-77
src/util/src/tcache.c
src/util/src/tcache.c
+1
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
2fe0304b
...
...
@@ -31,8 +31,8 @@ extern "C" {
#include "tutil.h"
#include "qExecutor.h"
#include "qSqlparser.h"
#include "qTsbuf.h"
#include "qsqlparser.h"
#include "tcmdtype.h"
// forward declaration
...
...
src/client/src/tscSystem.c
浏览文件 @
2fe0304b
...
...
@@ -148,7 +148,7 @@ void taos_init_imp() {
refreshTime
=
refreshTime
<
10
?
10
:
refreshTime
;
if
(
tscCacheHandle
==
NULL
)
{
tscCacheHandle
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
refreshTime
,
false
,
NULL
,
"
client
"
);
tscCacheHandle
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
refreshTime
,
false
,
NULL
,
"
tableMeta
"
);
}
tscDebug
(
"client is initialized successfully"
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
2fe0304b
...
...
@@ -20,8 +20,8 @@
#include "hash.h"
#include "qFill.h"
#include "qResultbuf.h"
#include "qSqlparser.h"
#include "qTsbuf.h"
#include "qsqlparser.h"
#include "query.h"
#include "taosdef.h"
#include "tarray.h"
...
...
src/query/inc/qResultbuf.h
浏览文件 @
2fe0304b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
VNODEQUERYUTIL
_H
#define TDENGINE_
VNODEQUERYUTIL
_H
#ifndef TDENGINE_
QRESULTBUF
_H
#define TDENGINE_
QRESULTBUF
_H
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -26,11 +26,18 @@ extern "C" {
typedef
struct
SArray
*
SIDList
;
typedef
struct
SPageInfo
{
int32_t
pageId
;
int32_t
offset
;
int32_t
lengthOnDisk
;
}
SPageInfo
;
typedef
struct
SDiskbasedResultBuf
{
int32_t
numOfRowsPerPage
;
int32_t
numOfPages
;
int64_t
totalBufSize
;
int32_t
fd
;
// data file fd
FILE
*
file
;
// int32_t fd; // data file fd
int32_t
allocateId
;
// allocated page id
int32_t
incStep
;
// minimum allocated pages
void
*
pBuf
;
// mmap buffer pointer
...
...
@@ -43,6 +50,8 @@ typedef struct SDiskbasedResultBuf {
void
*
iBuf
;
// inmemory buf
void
*
handle
;
// for debug purpose
void
*
emptyDummyIdList
;
// dummy id list
bool
comp
;
}
SDiskbasedResultBuf
;
#define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L)
...
...
@@ -56,7 +65,7 @@ typedef struct SDiskbasedResultBuf {
* @return
*/
int32_t
createDiskbasedResultBuffer
(
SDiskbasedResultBuf
**
pResultBuf
,
int32_t
numOfPages
,
int32_t
rowSize
,
int32_t
pagesize
,
int32_t
inMemPages
,
void
*
handle
);
int32_t
inMemPages
,
const
void
*
handle
);
/**
*
...
...
@@ -126,4 +135,4 @@ int32_t getLastPageId(SIDList pList);
}
#endif
#endif // TDENGINE_
VNODEQUERYUTIL
_H
#endif // TDENGINE_
QRESULTBUF
_H
src/query/inc/q
s
qlparser.h
→
src/query/inc/q
S
qlparser.h
浏览文件 @
2fe0304b
文件已移动
src/query/src/qAst.c
浏览文件 @
2fe0304b
...
...
@@ -18,8 +18,8 @@
#include "exception.h"
#include "qAst.h"
#include "qSqlparser.h"
#include "qSyntaxtreefunction.h"
#include "qsqlparser.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
...
...
src/query/src/qExecutor.c
浏览文件 @
2fe0304b
...
...
@@ -6617,14 +6617,16 @@ void* qOpenQueryMgmt(int32_t vgId) {
char
cacheName
[
128
]
=
{
0
};
sprintf
(
cacheName
,
"qhandle_%d"
,
vgId
);
SQueryMgmt
*
pQuery
Handle
=
calloc
(
1
,
sizeof
(
SQueryMgmt
));
SQueryMgmt
*
pQuery
Mgmt
=
calloc
(
1
,
sizeof
(
SQueryMgmt
));
pQueryHandle
->
qinfoPool
=
taosCacheInit
(
TSDB_DATA_TYPE_BIGINT
,
REFRESH_HANDLE_INTERVAL
,
true
,
freeqinfoFn
,
cacheName
);
pQueryHandle
->
closed
=
false
;
pthread_mutex_init
(
&
pQueryHandle
->
lock
,
NULL
);
pQueryMgmt
->
qinfoPool
=
taosCacheInit
(
TSDB_DATA_TYPE_BIGINT
,
REFRESH_HANDLE_INTERVAL
,
true
,
freeqinfoFn
,
cacheName
);
pQueryMgmt
->
closed
=
false
;
pQueryMgmt
->
vgId
=
vgId
;
pthread_mutex_init
(
&
pQueryMgmt
->
lock
,
NULL
);
qDebug
(
"vgId:%d, open querymgmt success"
,
vgId
);
return
pQuery
Handle
;
return
pQuery
Mgmt
;
}
static
void
queryMgmtKillQueryFn
(
void
*
handle
)
{
...
...
@@ -6664,7 +6666,7 @@ void qCleanupQueryMgmt(void* pQMgmt) {
pthread_mutex_destroy
(
&
pQueryMgmt
->
lock
);
tfree
(
pQueryMgmt
);
qDebug
(
"vgId:%d query
m
gmt cleanup completed"
,
vgId
);
qDebug
(
"vgId:%d query
M
gmt cleanup completed"
,
vgId
);
}
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qInfo
)
{
...
...
src/query/src/qParserImpl.c
浏览文件 @
2fe0304b
...
...
@@ -14,7 +14,7 @@
*/
#include "os.h"
#include "q
s
qlparser.h"
#include "q
S
qlparser.h"
#include "queryLog.h"
#include "taosdef.h"
#include "taosmsg.h"
...
...
src/query/src/qResultbuf.c
浏览文件 @
2fe0304b
...
...
@@ -5,7 +5,7 @@
#include "taoserror.h"
int32_t
createDiskbasedResultBuffer
(
SDiskbasedResultBuf
**
pResultBuf
,
int32_t
numOfPages
,
int32_t
rowSize
,
int32_t
pagesize
,
int32_t
inMemPages
,
void
*
handle
)
{
int32_t
pagesize
,
int32_t
inMemPages
,
const
void
*
handle
)
{
*
pResultBuf
=
calloc
(
1
,
sizeof
(
SDiskbasedResultBuf
));
SDiskbasedResultBuf
*
pResBuf
=
*
pResultBuf
;
...
...
@@ -24,6 +24,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t nu
pResBuf
->
incStep
=
4
;
pResBuf
->
allocateId
=
-
1
;
// todo opt perf by on demand create in memory buffer
pResBuf
->
iBuf
=
calloc
(
pResBuf
->
inMemPages
,
pResBuf
->
pageSize
);
// init id hash table
...
...
@@ -31,10 +32,10 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t nu
pResBuf
->
list
=
taosArrayInit
(
numOfPages
,
POINTER_BYTES
);
char
path
[
PATH_MAX
]
=
{
0
};
getTmpfilePath
(
"
tsdb_
qbuf"
,
path
);
getTmpfilePath
(
"qbuf"
,
path
);
pResBuf
->
path
=
strdup
(
path
);
pResBuf
->
f
d
=
FD_INITIALIZER
;
pResBuf
->
f
ile
=
NULL
;
pResBuf
->
pBuf
=
NULL
;
pResBuf
->
emptyDummyIdList
=
taosArrayInit
(
1
,
sizeof
(
int32_t
));
...
...
@@ -52,8 +53,9 @@ int32_t getResBufSize(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->tota
#define FILE_SIZE_ON_DISK(_r) (NUM_OF_PAGES_ON_DISK(_r) * (_r)->pageSize)
static
int32_t
createDiskResidesBuf
(
SDiskbasedResultBuf
*
pResultBuf
)
{
pResultBuf
->
fd
=
open
(
pResultBuf
->
path
,
O_CREAT
|
O_RDWR
,
0666
);
if
(
!
FD_VALID
(
pResultBuf
->
fd
))
{
// pResultBuf->fd = open(pResultBuf->path, O_CREAT | O_RDWR, 0666);
pResultBuf
->
file
=
fopen
(
pResultBuf
->
path
,
"r+"
);
if
(
pResultBuf
->
file
==
NULL
)
{
qError
(
"failed to create tmp file: %s on disk. %s"
,
pResultBuf
->
path
,
strerror
(
errno
));
return
TAOS_SYSTEM_ERROR
(
errno
);
}
...
...
@@ -61,13 +63,15 @@ static int32_t createDiskResidesBuf(SDiskbasedResultBuf* pResultBuf) {
assert
(
pResultBuf
->
numOfPages
==
pResultBuf
->
inMemPages
);
pResultBuf
->
numOfPages
+=
pResultBuf
->
incStep
;
int32_t
ret
=
ftruncate
(
pResultBuf
->
fd
,
NUM_OF_PAGES_ON_DISK
(
pResultBuf
)
*
pResultBuf
->
pageSize
);
int32_t
ret
=
ftruncate
(
fileno
(
pResultBuf
->
file
)
,
NUM_OF_PAGES_ON_DISK
(
pResultBuf
)
*
pResultBuf
->
pageSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to create tmp file: %s on disk. %s"
,
pResultBuf
->
path
,
strerror
(
errno
));
return
TAOS_SYSTEM_ERROR
(
errno
);
}
pResultBuf
->
pBuf
=
mmap
(
NULL
,
FILE_SIZE_ON_DISK
(
pResultBuf
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
pResultBuf
->
fd
,
0
);
pResultBuf
->
pBuf
=
mmap
(
NULL
,
FILE_SIZE_ON_DISK
(
pResultBuf
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fileno
(
pResultBuf
->
file
),
0
);
if
(
pResultBuf
->
pBuf
==
MAP_FAILED
)
{
qError
(
"QInfo:%p failed to map temp file: %s. %s"
,
pResultBuf
->
handle
,
pResultBuf
->
path
,
strerror
(
errno
));
return
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -82,7 +86,7 @@ static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t incNu
int32_t
ret
=
TSDB_CODE_SUCCESS
;
if
(
pResultBuf
->
pBuf
==
NULL
)
{
assert
(
pResultBuf
->
f
d
==
FD_INITIALIZER
);
assert
(
pResultBuf
->
f
ile
==
NULL
);
if
((
ret
=
createDiskResidesBuf
(
pResultBuf
))
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
...
...
@@ -95,7 +99,7 @@ static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t incNu
* disk-based output buffer is exhausted, try to extend the disk-based buffer, the available disk space may
* be insufficient
*/
ret
=
ftruncate
(
pResultBuf
->
fd
,
NUM_OF_PAGES_ON_DISK
(
pResultBuf
)
*
pResultBuf
->
pageSize
);
ret
=
ftruncate
(
fileno
(
pResultBuf
->
file
)
,
NUM_OF_PAGES_ON_DISK
(
pResultBuf
)
*
pResultBuf
->
pageSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// dError("QInfo:%p failed to create intermediate result output file:%s. %s", pQInfo, pSupporter->extBufFile,
// strerror(errno));
...
...
@@ -103,7 +107,7 @@ static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t incNu
}
pResultBuf
->
totalBufSize
=
pResultBuf
->
numOfPages
*
pResultBuf
->
pageSize
;
pResultBuf
->
pBuf
=
mmap
(
NULL
,
FILE_SIZE_ON_DISK
(
pResultBuf
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
pResultBuf
->
fd
,
0
);
pResultBuf
->
pBuf
=
mmap
(
NULL
,
FILE_SIZE_ON_DISK
(
pResultBuf
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fileno
(
pResultBuf
->
file
)
,
0
);
if
(
pResultBuf
->
pBuf
==
MAP_FAILED
)
{
// dError("QInfo:%p failed to map temp file: %s. %s", pQInfo, pSupporter->extBufFile, strerror(errno));
...
...
@@ -185,11 +189,11 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) {
return
;
}
if
(
FD_VALID
(
pResultBuf
->
fd
)
)
{
if
(
pResultBuf
->
file
!=
NULL
)
{
qDebug
(
"QInfo:%p disk-based output buffer closed, total:%"
PRId64
" bytes, file created:%s, file size:%d"
,
handle
,
pResultBuf
->
totalBufSize
,
pResultBuf
->
path
,
FILE_SIZE_ON_DISK
(
pResultBuf
));
close
(
pResultBuf
->
fd
);
fclose
(
pResultBuf
->
file
);
munmap
(
pResultBuf
->
pBuf
,
FILE_SIZE_ON_DISK
(
pResultBuf
));
pResultBuf
->
pBuf
=
NULL
;
}
else
{
...
...
src/query/src/sql.c
浏览文件 @
2fe0304b
...
...
@@ -30,7 +30,7 @@
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "q
s
qlparser.h"
#include "q
S
qlparser.h"
#include "tcmdtype.h"
#include "tstoken.h"
#include "ttokendef.h"
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
2fe0304b
...
...
@@ -654,8 +654,9 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
int64_t
elapsedTime
=
(
taosGetTimestampUs
()
-
st
);
pQueryHandle
->
cost
.
blockLoadTime
+=
elapsedTime
;
tsdbDebug
(
"%p load file block into buffer, elapsed time:%"
PRId64
" us"
,
pQueryHandle
,
elapsedTime
);
tsdbDebug
(
"%p load file block into buffer, brange:%"
PRId64
"-%"
PRId64
" , rows:%d, elapsed time:%"
PRId64
" us"
,
pQueryHandle
,
pBlock
->
keyFirst
,
pBlock
->
keyLast
,
pBlock
->
numOfRows
,
elapsedTime
);
return
blockLoaded
;
}
...
...
@@ -971,6 +972,52 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
}
}
static
void
moveDataToFront
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
numOfRows
,
int32_t
numOfCols
)
{
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
return
;
}
// if the buffer is not full in case of descending order query, move the data in the front of the buffer
if
(
numOfRows
<
pQueryHandle
->
outputCapacity
)
{
int32_t
emptySize
=
pQueryHandle
->
outputCapacity
-
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
memmove
(
pColInfo
->
pData
,
pColInfo
->
pData
+
emptySize
*
pColInfo
->
info
.
bytes
,
numOfRows
*
pColInfo
->
info
.
bytes
);
}
}
}
static
void
getQualifiedRowsPos
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
startPos
,
int32_t
endPos
,
int32_t
numOfExisted
,
int32_t
*
start
,
int32_t
*
end
)
{
*
start
=
-
1
;
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
int32_t
remain
=
endPos
-
startPos
+
1
;
if
(
remain
+
numOfExisted
>
pQueryHandle
->
outputCapacity
)
{
*
end
=
(
pQueryHandle
->
outputCapacity
-
numOfExisted
)
+
startPos
-
1
;
}
*
start
=
startPos
;
}
else
{
int32_t
remain
=
(
startPos
-
endPos
)
+
1
;
if
(
remain
+
numOfExisted
>
pQueryHandle
->
outputCapacity
)
{
*
end
=
startPos
+
1
-
(
pQueryHandle
->
outputCapacity
-
numOfExisted
);
}
*
start
=
*
end
;
*
end
=
startPos
;
}
}
static
void
updateInfoAfterMerge
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
int32_t
numOfRows
,
int32_t
endPos
)
{
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
pCheckInfo
->
lastKey
=
cur
->
lastKey
;
pQueryHandle
->
realNumOfRows
=
numOfRows
;
cur
->
rows
=
numOfRows
;
cur
->
pos
=
endPos
;
}
// only return the qualified data to client in terms of query time window, data rows in the same block but do not
// be included in the query time window will be discarded
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
)
{
...
...
@@ -978,7 +1025,10 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
SDataBlockInfo
blockInfo
=
GET_FILE_DATA_BLOCK_INFO
(
pCheckInfo
,
pBlock
);
initTableMemIterator
(
pQueryHandle
,
pCheckInfo
);
SDataCols
*
pCols
=
pQueryHandle
->
rhelper
.
pDataCols
[
0
];
assert
(
pCols
->
cols
[
0
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
&&
pCols
->
cols
[
0
].
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
TSKEY
*
tsArray
=
pCols
->
cols
[
0
].
pData
;
// for search the endPos, so the order needs to reverse
int32_t
order
=
(
pQueryHandle
->
order
==
TSDB_ORDER_ASC
)
?
TSDB_ORDER_DESC
:
TSDB_ORDER_ASC
;
...
...
@@ -1004,9 +1054,6 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
// compared with the data from in-memory buffer, to generate the correct timestamp array list
int32_t
pos
=
cur
->
pos
;
assert
(
pCols
->
cols
[
0
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
&&
pCols
->
cols
[
0
].
colId
==
0
);
TSKEY
*
tsArray
=
pCols
->
cols
[
0
].
pData
;
int32_t
numOfRows
=
0
;
pQueryHandle
->
cur
.
win
=
TSWINDOW_INITIALIZER
;
...
...
@@ -1014,34 +1061,22 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
if
(
pCheckInfo
->
iiter
==
NULL
&&
pCheckInfo
->
iter
==
NULL
)
{
int32_t
start
=
cur
->
pos
;
int32_t
end
=
endPos
;
if
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
end
=
cur
->
pos
;
start
=
endPos
;
SWAP
(
start
,
end
,
int32_t
);
}
cur
->
win
.
skey
=
tsArray
[
start
];
cur
->
win
.
ekey
=
tsArray
[
end
];
// todo opt in case of no data in buffer
numOfRows
=
copyDataFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
start
,
end
);
// if the buffer is not full in case of descending order query, move the data in the front of the buffer
if
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
&&
numOfRows
<
pQueryHandle
->
outputCapacity
)
{
int32_t
emptySize
=
pQueryHandle
->
outputCapacity
-
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
memmove
(
pColInfo
->
pData
,
pColInfo
->
pData
+
emptySize
*
pColInfo
->
info
.
bytes
,
numOfRows
*
pColInfo
->
info
.
bytes
);
}
}
cur
->
win
=
(
STimeWindow
)
{.
skey
=
tsArray
[
start
],
.
ekey
=
tsArray
[
end
]};
pos
+=
(
end
-
start
+
1
)
*
step
;
cur
->
blockCompleted
=
(((
pos
>=
endPos
||
cur
->
lastKey
>
pQueryHandle
->
window
.
ekey
)
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
((
pos
<=
endPos
||
cur
->
lastKey
<
pQueryHandle
->
window
.
ekey
)
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)));
pCheckInfo
->
lastKey
=
cur
->
lastKey
;
pQueryHandle
->
realNumOfRows
=
numOfRows
;
cur
->
rows
=
numOfRows
;
// if the buffer is not full in case of descending order query, move the data in the front of the buffer
moveDataToFront
(
pQueryHandle
,
numOfRows
,
numOfCols
);
updateInfoAfterMerge
(
pQueryHandle
,
pCheckInfo
,
numOfRows
,
pos
);
return
;
}
else
if
(
pCheckInfo
->
iter
!=
NULL
||
pCheckInfo
->
iiter
!=
NULL
)
{
SSkipListNode
*
node
=
NULL
;
...
...
@@ -1088,26 +1123,14 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
moveToNextRowInMem
(
pCheckInfo
);
}
int32_t
start
=
-
1
;
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
int32_t
remain
=
end
-
pos
+
1
;
if
(
remain
+
numOfRows
>
pQueryHandle
->
outputCapacity
)
{
end
=
(
pQueryHandle
->
outputCapacity
-
numOfRows
)
+
pos
-
1
;
}
start
=
pos
;
}
else
{
int32_t
remain
=
(
pos
-
end
)
+
1
;
if
(
remain
+
numOfRows
>
pQueryHandle
->
outputCapacity
)
{
end
=
pos
+
1
-
(
pQueryHandle
->
outputCapacity
-
numOfRows
);
}
int32_t
qstart
=
0
,
qend
=
0
;
getQualifiedRowsPos
(
pQueryHandle
,
pos
,
end
,
numOfRows
,
&
qstart
,
&
qend
);
start
=
end
;
end
=
pos
;
}
numOfRows
=
copyDataFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
qstart
,
qend
);
pos
+=
(
qend
-
qstart
+
1
)
*
step
;
numOfRows
=
copyDataFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
start
,
end
)
;
pos
+=
(
end
-
start
+
1
)
*
step
;
cur
->
win
.
ekey
=
tsArray
[
end
]
;
cur
->
lastKey
=
cur
->
win
.
ekey
+
step
;
}
}
while
(
numOfRows
<
pQueryHandle
->
outputCapacity
);
...
...
@@ -1124,30 +1147,14 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
cur
->
win
.
skey
=
tsArray
[
pos
];
}
int32_t
start
=
-
1
;
int32_t
end
=
-
1
;
// all remain data are qualified, but check the remain capacity in the first place.
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
int32_t
remain
=
endPos
-
pos
+
1
;
if
(
remain
+
numOfRows
>
pQueryHandle
->
outputCapacity
)
{
endPos
=
(
pQueryHandle
->
outputCapacity
-
numOfRows
)
+
pos
-
1
;
}
start
=
pos
;
end
=
endPos
;
}
else
{
int32_t
remain
=
pos
+
1
;
if
(
remain
+
numOfRows
>
pQueryHandle
->
outputCapacity
)
{
endPos
=
pos
+
1
-
(
pQueryHandle
->
outputCapacity
-
numOfRows
);
}
start
=
endPos
;
end
=
pos
;
}
int32_t
start
=
-
1
,
end
=
-
1
;
getQualifiedRowsPos
(
pQueryHandle
,
pos
,
endPos
,
numOfRows
,
&
start
,
&
end
);
numOfRows
=
copyDataFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
start
,
end
);
pos
+=
(
end
-
start
+
1
)
*
step
;
cur
->
win
.
ekey
=
tsArray
[
end
];
cur
->
lastKey
=
cur
->
win
.
ekey
+
step
;
}
}
}
...
...
@@ -1157,21 +1164,16 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
if
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
SWAP
(
cur
->
win
.
skey
,
cur
->
win
.
ekey
,
TSKEY
);
// if the buffer is not full in case of descending order query, move the data in the front of the buffer
if
(
numOfRows
<
pQueryHandle
->
outputCapacity
)
{
int32_t
emptySize
=
pQueryHandle
->
outputCapacity
-
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
memmove
(
pColInfo
->
pData
,
pColInfo
->
pData
+
emptySize
*
pColInfo
->
info
.
bytes
,
numOfRows
*
pColInfo
->
info
.
bytes
);
}
}
}
pCheckInfo
->
lastKey
=
cur
->
lastKey
;
pQueryHandle
->
realNumOfRows
=
numOfRows
;
cur
->
rows
=
numOfRows
;
cur
->
pos
=
pos
;
moveDataToFront
(
pQueryHandle
,
numOfRows
,
numOfCols
);
updateInfoAfterMerge
(
pQueryHandle
,
pCheckInfo
,
numOfRows
,
pos
);
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
assert
(
cur
->
win
.
skey
>=
pQueryHandle
->
window
.
skey
&&
cur
->
win
.
ekey
<=
pQueryHandle
->
window
.
ekey
);
}
else
{
assert
(
cur
->
win
.
skey
>=
pQueryHandle
->
window
.
ekey
&&
cur
->
win
.
ekey
<=
pQueryHandle
->
window
.
skey
);
}
tsdbDebug
(
"%p uid:%"
PRIu64
",tid:%d data block created, brange:%"
PRIu64
"-%"
PRIu64
" rows:%d, %p"
,
pQueryHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
cur
->
win
.
skey
,
cur
->
win
.
ekey
,
cur
->
rows
,
pQueryHandle
->
qinfo
);
...
...
src/util/src/tcache.c
浏览文件 @
2fe0304b
...
...
@@ -674,6 +674,7 @@ void* taosCacheTimedRefresh(void *handle) {
// check if current cache object will be deleted every 500ms.
if
(
pCacheObj
->
deleting
)
{
uDebug
(
"%s refresh threads quit"
,
pCacheObj
->
name
);
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录