Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
8f58cb6c
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看板
提交
8f58cb6c
编写于
6月 30, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code optimization
上级
33c6b5ce
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
113 addition
and
223 deletion
+113
-223
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+33
-33
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+33
-33
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+28
-38
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+18
-17
src/inc/ttype.h
src/inc/ttype.h
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+0
-101
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
8f58cb6c
...
@@ -359,39 +359,39 @@ typedef struct {
...
@@ -359,39 +359,39 @@ typedef struct {
SSubmitBlk
*
pSubmitBlk
;
SSubmitBlk
*
pSubmitBlk
;
}
SMemRowBuilder
;
}
SMemRowBuilder
;
int
tdInitMemRowBuilder
(
SMemRowBuilder
*
pBuilder
);
//
int tdInitMemRowBuilder(SMemRowBuilder* pBuilder);
void
tdDestroyMemRowBuilder
(
SMemRowBuilder
*
pBuilder
);
//
void tdDestroyMemRowBuilder(SMemRowBuilder* pBuilder);
void
tdResetMemRowBuilder
(
SMemRowBuilder
*
pBuilder
);
//
void tdResetMemRowBuilder(SMemRowBuilder* pBuilder);
SMemRow
tdGe
t
MemRowFromBuilder
(
SMemRowBuilder
*
pBuilder
);
SMemRow
tdGe
n
MemRowFromBuilder
(
SMemRowBuilder
*
pBuilder
);
static
FORCE_INLINE
int
tdAddColToMemRow
(
SMemRowBuilder
*
pBuilder
,
int16_t
colId
,
int8_t
type
,
void
*
value
)
{
//
static FORCE_INLINE int tdAddColToMemRow(SMemRowBuilder* pBuilder, int16_t colId, int8_t type, void* value) {
// TODO
//
// TODO
if
(
pBuilder
->
nCols
>=
pBuilder
->
tCols
)
{
//
if (pBuilder->nCols >= pBuilder->tCols) {
pBuilder
->
tCols
*=
2
;
//
pBuilder->tCols *= 2;
pBuilder
->
pColIdx
=
(
SColIdx
*
)
realloc
((
void
*
)(
pBuilder
->
pColIdx
),
sizeof
(
SColIdx
)
*
pBuilder
->
tCols
);
//
pBuilder->pColIdx = (SColIdx*)realloc((void*)(pBuilder->pColIdx), sizeof(SColIdx) * pBuilder->tCols);
if
(
pBuilder
->
pColIdx
==
NULL
)
return
-
1
;
//
if (pBuilder->pColIdx == NULL) return -1;
}
//
}
pBuilder
->
pColIdx
[
pBuilder
->
nCols
].
colId
=
colId
;
//
pBuilder->pColIdx[pBuilder->nCols].colId = colId;
pBuilder
->
pColIdx
[
pBuilder
->
nCols
].
offset
=
pBuilder
->
size
;
//
pBuilder->pColIdx[pBuilder->nCols].offset = pBuilder->size;
pBuilder
->
nCols
++
;
//
pBuilder->nCols++;
int
tlen
=
IS_VAR_DATA_TYPE
(
type
)
?
varDataTLen
(
value
)
:
TYPE_BYTES
[
type
];
//
int tlen = IS_VAR_DATA_TYPE(type) ? varDataTLen(value) : TYPE_BYTES[type];
if
(
tlen
>
pBuilder
->
alloc
-
pBuilder
->
size
)
{
//
if (tlen > pBuilder->alloc - pBuilder->size) {
while
(
tlen
>
pBuilder
->
alloc
-
pBuilder
->
size
)
{
//
while (tlen > pBuilder->alloc - pBuilder->size) {
pBuilder
->
alloc
*=
2
;
//
pBuilder->alloc *= 2;
}
//
}
pBuilder
->
buf
=
realloc
(
pBuilder
->
buf
,
pBuilder
->
alloc
);
//
pBuilder->buf = realloc(pBuilder->buf, pBuilder->alloc);
if
(
pBuilder
->
buf
==
NULL
)
return
-
1
;
//
if (pBuilder->buf == NULL) return -1;
}
//
}
memcpy
(
POINTER_SHIFT
(
pBuilder
->
buf
,
pBuilder
->
size
),
value
,
tlen
);
//
memcpy(POINTER_SHIFT(pBuilder->buf, pBuilder->size), value, tlen);
pBuilder
->
size
+=
tlen
;
//
pBuilder->size += tlen;
return
0
;
//
return 0;
}
//
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
8f58cb6c
...
@@ -1640,35 +1640,34 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
...
@@ -1640,35 +1640,34 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int
tdInitMemRowBuilder
(
SMemRowBuilder
*
pBuilder
)
{
// int tdInitMemRowBuilder(SMemRowBuilder* pBuilder) {
pBuilder
->
pSchema
=
NULL
;
// pBuilder->pSchema = NULL;
pBuilder
->
sversion
=
0
;
// pBuilder->sversion = 0;
pBuilder
->
tCols
=
128
;
// pBuilder->tCols = 128;
pBuilder
->
nCols
=
0
;
// pBuilder->nCols = 0;
pBuilder
->
pColIdx
=
(
SColIdx
*
)
malloc
(
sizeof
(
SColIdx
)
*
pBuilder
->
tCols
);
// pBuilder->pColIdx = (SColIdx*)malloc(sizeof(SColIdx) * pBuilder->tCols);
if
(
pBuilder
->
pColIdx
==
NULL
)
return
-
1
;
// if (pBuilder->pColIdx == NULL) return -1;
pBuilder
->
alloc
=
1024
;
// pBuilder->alloc = 1024;
pBuilder
->
size
=
0
;
// pBuilder->size = 0;
pBuilder
->
buf
=
malloc
(
pBuilder
->
alloc
);
// pBuilder->buf = malloc(pBuilder->alloc);
if
(
pBuilder
->
buf
==
NULL
)
{
// if (pBuilder->buf == NULL) {
free
(
pBuilder
->
pColIdx
);
// free(pBuilder->pColIdx);
return
-
1
;
// return -1;
}
// }
return
0
;
// return 0;
}
// }
void
tdDestroyMemRowBuilder
(
SMemRowBuilder
*
pBuilder
)
{
// void tdDestroyMemRowBuilder(SMemRowBuilder* pBuilder) {
tfree
(
pBuilder
->
pColIdx
);
// tfree(pBuilder->pColIdx);
tfree
(
pBuilder
->
buf
);
// tfree(pBuilder->buf);
}
// }
void
tdResetMemRowBuilder
(
SMemRowBuilder
*
pBuilder
)
{
// void tdResetMemRowBuilder(SMemRowBuilder* pBuilder) {
pBuilder
->
nCols
=
0
;
// pBuilder->nCols = 0;
pBuilder
->
size
=
0
;
// pBuilder->size = 0;
}
// }
#define KvRowNullColRatio 0.75 // If nullable column ratio larger than 0.75, utilize SKVRow, otherwise SDataRow.
#define KvRowNColsThresh 1 // default value: 32 TODO: for test, restore to 32 after test finished
#define KvRowNColsThresh 1 // default value: 32
static
FORCE_INLINE
uint8_t
tdRowTypeJudger
(
SSchema
*
pSchema
,
void
*
pData
,
int32_t
nCols
,
int32_t
flen
,
static
FORCE_INLINE
uint8_t
tdRowTypeJudger
(
SSchema
*
pSchema
,
void
*
pData
,
int32_t
nCols
,
int32_t
flen
,
uint16_t
*
nColsNotNull
)
{
uint16_t
*
nColsNotNull
)
{
...
@@ -1701,7 +1700,8 @@ static FORCE_INLINE uint8_t tdRowTypeJudger(SSchema* pSchema, void* pData, int32
...
@@ -1701,7 +1700,8 @@ static FORCE_INLINE uint8_t tdRowTypeJudger(SSchema* pSchema, void* pData, int32
p
+=
pSchema
[
i
].
bytes
;
p
+=
pSchema
[
i
].
bytes
;
}
}
tscInfo
(
"prop:nColsNull %d, nCols: %d, kvRowLen: %d, dataRowLen: %d"
,
nColsNull
,
nCols
,
kvRowLength
,
dataRowLength
);
tscDebug
(
"prop:nColsNull %d, nCols: %d, kvRowLen: %d, dataRowLen: %d"
,
(
int32_t
)
nColsNull
,
nCols
,
kvRowLength
,
dataRowLength
);
if
(
kvRowLength
<
dataRowLength
)
{
if
(
kvRowLength
<
dataRowLength
)
{
if
(
nColsNotNull
)
{
if
(
nColsNotNull
)
{
...
@@ -1713,7 +1713,7 @@ static FORCE_INLINE uint8_t tdRowTypeJudger(SSchema* pSchema, void* pData, int32
...
@@ -1713,7 +1713,7 @@ static FORCE_INLINE uint8_t tdRowTypeJudger(SSchema* pSchema, void* pData, int32
return
SMEM_ROW_DATA
;
return
SMEM_ROW_DATA
;
}
}
SMemRow
tdGe
t
MemRowFromBuilder
(
SMemRowBuilder
*
pBuilder
)
{
SMemRow
tdGe
n
MemRowFromBuilder
(
SMemRowBuilder
*
pBuilder
)
{
SSchema
*
pSchema
=
pBuilder
->
pSchema
;
SSchema
*
pSchema
=
pBuilder
->
pSchema
;
char
*
p
=
(
char
*
)
pBuilder
->
buf
;
char
*
p
=
(
char
*
)
pBuilder
->
buf
;
...
@@ -1840,7 +1840,7 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bo
...
@@ -1840,7 +1840,7 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bo
pDataBlock = (char*)pDataBlock + dataRowLen(trow); // next SDataRow
pDataBlock = (char*)pDataBlock + dataRowLen(trow); // next SDataRow
pBlock->dataLen += dataRowLen(trow); // SSubmitBlk data length
pBlock->dataLen += dataRowLen(trow); // SSubmitBlk data length
#endif
#endif
tdGe
t
MemRowFromBuilder
(
&
mRowBuilder
);
tdGe
n
MemRowFromBuilder
(
&
mRowBuilder
);
}
}
int32_t
len
=
pBlock
->
dataLen
+
pBlock
->
schemaLen
;
int32_t
len
=
pBlock
->
dataLen
+
pBlock
->
schemaLen
;
...
...
src/common/inc/tdataformat.h
浏览文件 @
8f58cb6c
...
@@ -224,10 +224,10 @@ typedef void *SMemRow;
...
@@ -224,10 +224,10 @@ typedef void *SMemRow;
#define dataRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_DATA_ROW_HEAD_SIZE)
#define dataRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_DATA_ROW_HEAD_SIZE)
#define dataRowDeleted(r) TKEY_IS_DELETED(dataRowTKey(r))
#define dataRowDeleted(r) TKEY_IS_DELETED(dataRowTKey(r))
//
SDataRow tdNewDataRowFromSchema(STSchema *pSchema);
SDataRow
tdNewDataRowFromSchema
(
STSchema
*
pSchema
);
//
void tdFreeDataRow(SDataRow row);
void
tdFreeDataRow
(
SDataRow
row
);
void
tdInitDataRow
(
SDataRow
row
,
STSchema
*
pSchema
);
void
tdInitDataRow
(
SDataRow
row
,
STSchema
*
pSchema
);
//
SDataRow tdDataRowDup(SDataRow row);
SDataRow
tdDataRowDup
(
SDataRow
row
);
SMemRow
tdMemRowDup
(
SMemRow
row
);
SMemRow
tdMemRowDup
(
SMemRow
row
);
// offset here not include dataRow header length
// offset here not include dataRow header length
...
@@ -253,6 +253,16 @@ static FORCE_INLINE int tdAppendColVal(SDataRow row, const void *value, int8_t t
...
@@ -253,6 +253,16 @@ static FORCE_INLINE int tdAppendColVal(SDataRow row, const void *value, int8_t t
return
0
;
return
0
;
}
}
// NOTE: offset here including the header size
static
FORCE_INLINE
void
*
tdGetRowDataOfCol
(
void
*
row
,
int8_t
type
,
int32_t
offset
)
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
return
POINTER_SHIFT
(
row
,
*
(
VarDataOffsetT
*
)
POINTER_SHIFT
(
row
,
offset
));
}
else
{
return
POINTER_SHIFT
(
row
,
offset
);
}
return
NULL
;
}
// ----------------- Data column structure
// ----------------- Data column structure
typedef
struct
SDataCol
{
typedef
struct
SDataCol
{
int8_t
type
;
// column type
int8_t
type
;
// column type
...
@@ -519,27 +529,26 @@ static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId,
...
@@ -519,27 +529,26 @@ static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId,
return
0
;
return
0
;
}
}
// ----------------- Data row structure
// ----------------- Sequential Data row structure
// ----------------- Sequential Data row structure
/*
A sequential data row, the format is like below:
/*
* |
<
--------------------+--------------------------- len ---------------------------------->|
* |
-----------
--------------------+--------------------------- len ---------------------------------->|
* |<--
Head
-->|<--------- flen -------------->| |
* |<--
------ Head ----
-->|<--------- flen -------------->| |
* +---------------------+---------------------------------+---------------------------------+
*
|---------
+---------------------+---------------------------------+---------------------------------+
* | uint16_t | int16_t | | |
* | uint
8_t | uint
16_t | int16_t | | |
* +----------+----------+---------------------------------+---------------------------------+
*
|---------
+----------+----------+---------------------------------+---------------------------------+
* | len | sversion | First part | Second part |
* |
flag |
len | sversion | First part | Second part |
* +----------+----------+---------------------------------+---------------------------------+
* +---------
+---------
-+----------+---------------------------------+---------------------------------+
*
*
* NOTE: timestamp in this row structure is TKEY instead of TSKEY
* NOTE: timestamp in this row structure is TKEY instead of TSKEY
*/
*/
// ----------------- K-V data row structure
// ----------------- K-V data row structure
/*
/*
*
+
----------+----------+---------------------------------+---------------------------------+
*
|----------
----------+----------+---------------------------------+---------------------------------+
* |
int16_t | int16_t | | |
* |
uint8_t | u
int16_t | int16_t | | |
* +----------+----------+---------------------------------+---------------------------------+
*
|---------
+----------+----------+---------------------------------+---------------------------------+
* | len | ncols | cols index | data part |
* |
flag |
len | ncols | cols index | data part |
* +----------+----------+---------------------------------+---------------------------------+
*
|---------
+----------+----------+---------------------------------+---------------------------------+
*/
*/
#define TD_MEM_ROW_TYPE_SIZE sizeof(uint8_t)
#define TD_MEM_ROW_TYPE_SIZE sizeof(uint8_t)
...
@@ -572,24 +581,11 @@ static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId,
...
@@ -572,24 +581,11 @@ static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId,
#define memRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_MEM_ROW_HEAD_SIZE)
#define memRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_MEM_ROW_HEAD_SIZE)
#define memRowDeleted(r) TKEY_IS_DELETED(memRowTKey(r))
#define memRowDeleted(r) TKEY_IS_DELETED(memRowTKey(r))
// #define memRowNCols(r) (*(int16_t *)POINTER_SHIFT(r, TD_MEM_ROW_TYPE_SIZE + sizeof(int16_t))) // for SKVRow
// #define memRowSetNCols(r, n) memRowNCols(r) = (n) // for SKVRow
// #define memRowColIdx(r) (SColIdx *)POINTER_SHIFT(r, TD_MEM_ROW_HEAD_SIZE) // for SKVRow
// #define memRowValues(r) POINTER_SHIFT(r, TD_MEM_ROW_HEAD_SIZE + sizeof(SColIdx) * memRowNCols(r)) // for SKVRow
// NOTE: offset here including the header size
// NOTE: offset here including the header size
static
FORCE_INLINE
void
*
tdGetRowDataOfCol
(
void
*
row
,
int8_t
type
,
int32_t
offset
)
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
return
POINTER_SHIFT
(
row
,
*
(
VarDataOffsetT
*
)
POINTER_SHIFT
(
row
,
offset
));
}
else
{
return
POINTER_SHIFT
(
row
,
offset
);
}
return
NULL
;
}
static
FORCE_INLINE
void
*
tdGetKvRowDataOfCol
(
void
*
row
,
int8_t
type
,
int32_t
offset
)
{
static
FORCE_INLINE
void
*
tdGetKvRowDataOfCol
(
void
*
row
,
int8_t
type
,
int32_t
offset
)
{
return
POINTER_SHIFT
(
row
,
offset
);
return
POINTER_SHIFT
(
row
,
offset
);
}
}
// NOTE: offset here including the header size
static
FORCE_INLINE
void
*
tdGetMemRowDataOfCol
(
void
*
row
,
int8_t
type
,
int32_t
offset
)
{
static
FORCE_INLINE
void
*
tdGetMemRowDataOfCol
(
void
*
row
,
int8_t
type
,
int32_t
offset
)
{
if
(
isDataRow
(
row
))
{
if
(
isDataRow
(
row
))
{
return
tdGetRowDataOfCol
(
row
,
type
,
offset
);
return
tdGetRowDataOfCol
(
row
,
type
,
offset
);
...
@@ -601,12 +597,6 @@ static FORCE_INLINE void *tdGetMemRowDataOfCol(void *row, int8_t type, int32_t o
...
@@ -601,12 +597,6 @@ static FORCE_INLINE void *tdGetMemRowDataOfCol(void *row, int8_t type, int32_t o
return
NULL
;
return
NULL
;
}
}
// #define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
// #define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
// #define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
// #define kvRowFree(r) tfree(r)
// #define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/common/src/tdataformat.c
浏览文件 @
8f58cb6c
...
@@ -188,30 +188,30 @@ void tdInitDataRow(SDataRow row, STSchema *pSchema) {
...
@@ -188,30 +188,30 @@ void tdInitDataRow(SDataRow row, STSchema *pSchema) {
dataRowSetVersion
(
row
,
schemaVersion
(
pSchema
));
dataRowSetVersion
(
row
,
schemaVersion
(
pSchema
));
}
}
//
SDataRow tdNewDataRowFromSchema(STSchema *pSchema) {
SDataRow
tdNewDataRowFromSchema
(
STSchema
*
pSchema
)
{
//
int32_t size = dataRowMaxBytesFromSchema(pSchema);
int32_t
size
=
dataRowMaxBytesFromSchema
(
pSchema
);
//
SDataRow row = malloc(size);
SDataRow
row
=
malloc
(
size
);
//
if (row == NULL) return NULL;
if
(
row
==
NULL
)
return
NULL
;
//
tdInitDataRow(row, pSchema);
tdInitDataRow
(
row
,
pSchema
);
//
return row;
return
row
;
//
}
}
/**
/**
* Free the SDataRow object
* Free the SDataRow object
*/
*/
//
void tdFreeDataRow(SDataRow row) {
void
tdFreeDataRow
(
SDataRow
row
)
{
//
if (row) free(row);
if
(
row
)
free
(
row
);
//
}
}
//
SDataRow tdDataRowDup(SDataRow row) {
SDataRow
tdDataRowDup
(
SDataRow
row
)
{
//
SDataRow trow = malloc(dataRowLen(row));
SDataRow
trow
=
malloc
(
dataRowLen
(
row
));
//
if (trow == NULL) return NULL;
if
(
trow
==
NULL
)
return
NULL
;
//
dataRowCpy(trow, row);
dataRowCpy
(
trow
,
row
);
//
return trow;
return
trow
;
//
}
}
SMemRow
tdMemRowDup
(
SMemRow
row
)
{
SMemRow
tdMemRowDup
(
SMemRow
row
)
{
SMemRow
trow
=
malloc
(
memRowTLen
(
row
));
SMemRow
trow
=
malloc
(
memRowTLen
(
row
));
...
@@ -220,6 +220,7 @@ SMemRow tdMemRowDup(SMemRow row) {
...
@@ -220,6 +220,7 @@ SMemRow tdMemRowDup(SMemRow row) {
memRowCpy
(
trow
,
row
);
memRowCpy
(
trow
,
row
);
return
trow
;
return
trow
;
}
}
void
dataColInit
(
SDataCol
*
pDataCol
,
STColumn
*
pCol
,
void
**
pBuf
,
int
maxPoints
)
{
void
dataColInit
(
SDataCol
*
pDataCol
,
STColumn
*
pCol
,
void
**
pBuf
,
int
maxPoints
)
{
pDataCol
->
type
=
colType
(
pCol
);
pDataCol
->
type
=
colType
(
pCol
);
pDataCol
->
colId
=
colColId
(
pCol
);
pDataCol
->
colId
=
colColId
(
pCol
);
...
@@ -436,7 +437,7 @@ void tdResetDataCols(SDataCols *pCols) {
...
@@ -436,7 +437,7 @@ void tdResetDataCols(SDataCols *pCols) {
static
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
STSchema
*
pSchema
,
SDataCols
*
pCols
)
{
static
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
STSchema
*
pSchema
,
SDataCols
*
pCols
)
{
ASSERT
(
pCols
->
numOfRows
==
0
||
dataColsKeyLast
(
pCols
)
<
dataRowKey
(
row
));
ASSERT
(
pCols
->
numOfRows
==
0
||
dataColsKeyLast
(
pCols
)
<
dataRowKey
(
row
));
int
rcol
=
0
;
// rowCol
int
rcol
=
0
;
int
dcol
=
0
;
int
dcol
=
0
;
if
(
dataRowDeleted
(
row
))
{
if
(
dataRowDeleted
(
row
))
{
...
...
src/inc/ttype.h
浏览文件 @
8f58cb6c
...
@@ -11,7 +11,7 @@ extern "C" {
...
@@ -11,7 +11,7 @@ extern "C" {
// ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR
// ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR
typedef
int32_t
VarDataOffsetT
;
typedef
int32_t
VarDataOffsetT
;
typedef
int16_t
VarDataLenT
;
// maxDataLen: 32767
typedef
int16_t
VarDataLenT
;
// max
Var
DataLen: 32767
typedef
struct
tstr
{
typedef
struct
tstr
{
VarDataLenT
len
;
VarDataLenT
len
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
8f58cb6c
...
@@ -1442,107 +1442,6 @@ int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity
...
@@ -1442,107 +1442,6 @@ int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity
return
numOfRows
+
num
;
return
numOfRows
+
num
;
}
}
#if 0
static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity, int32_t numOfRows, SMemRow row,
int32_t numOfCols, STable* pTable, STSchema* pSchema) {
char* pData = NULL;
// the schema version info is embedded in SDataRow, and use latest schema version for SKVRow
int32_t numOfRowCols = 0;
if (pSchema == NULL) {
pSchema = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row));
numOfRowCols = schemaNCols(pSchema);
} else {
numOfRowCols = schemaNCols(pSchema);
}
int32_t i = 0, j = 0;
while(i < numOfCols && j < numOfRowCols) {
SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i);
if (pSchema->columns[j].colId < pColInfo->info.colId) {
j++;
continue;
}
if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
pData = (char*)pColInfo->pData + numOfRows * pColInfo->info.bytes;
} else {
pData = (char*)pColInfo->pData + (capacity - numOfRows - 1) * pColInfo->info.bytes;
}
if (pSchema->columns[j].colId == pColInfo->info.colId) {
void* value =
tdGetMemRowDataOfCol(row, (int8_t)pColInfo->info.type, TD_MEM_ROW_HEAD_SIZE + pSchema->columns[j].offset);
switch (pColInfo->info.type) {
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR:
memcpy(pData, value, varDataTLen(value));
break;
case TSDB_DATA_TYPE_NULL:
case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
*(uint8_t *)pData = *(uint8_t *)value;
break;
case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
*(uint16_t *)pData = *(uint16_t *)value;
break;
case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
*(uint32_t *)pData = *(uint32_t *)value;
break;
case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
*(uint64_t *)pData = *(uint64_t *)value;
break;
case TSDB_DATA_TYPE_FLOAT:
SET_FLOAT_PTR(pData, value);
break;
case TSDB_DATA_TYPE_DOUBLE:
SET_DOUBLE_PTR(pData, value);
break;
case TSDB_DATA_TYPE_TIMESTAMP:
if (pColInfo->info.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
*(TSKEY *)pData = tdGetKey(*(TKEY *)value);
} else {
*(TSKEY *)pData = *(TSKEY *)value;
}
break;
default:
memcpy(pData, value, pColInfo->info.bytes);
}
j++;
i++;
} else { // pColInfo->info.colId < pSchema->columns[j].colId, it is a NULL data
if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pData, pColInfo->info.type);
} else {
setNull(pData, pColInfo->info.type, pColInfo->info.bytes);
}
i++;
}
}
while (i < numOfCols) { // the remain columns are all null data
SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i);
if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
pData = (char*)pColInfo->pData + numOfRows * pColInfo->info.bytes;
} else {
pData = (char*)pColInfo->pData + (capacity - numOfRows - 1) * pColInfo->info.bytes;
}
if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pData, pColInfo->info.type);
} else {
setNull(pData, pColInfo->info.type, pColInfo->info.bytes);
}
i++;
}
}
#endif
static
void
copyOneRowFromMem
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
SMemRow
row
,
static
void
copyOneRowFromMem
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
SMemRow
row
,
int32_t
numOfCols
,
STable
*
pTable
,
STSchema
*
pSchema
)
{
int32_t
numOfCols
,
STable
*
pTable
,
STSchema
*
pSchema
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录