code refactor
This commit is contained in:
parent
21a8b09174
commit
889aa8a11b
|
@ -104,15 +104,11 @@ typedef struct SParsedDataColInfo {
|
|||
} SParsedDataColInfo;
|
||||
|
||||
typedef struct {
|
||||
// for SDataRow
|
||||
SSchema *pSchema;
|
||||
int16_t sversion;
|
||||
int32_t flen;
|
||||
// for SKVRow
|
||||
uint16_t nCols;
|
||||
uint16_t size;
|
||||
void * buf;
|
||||
|
||||
SSchema * pSchema;
|
||||
int16_t sversion;
|
||||
int32_t flen;
|
||||
uint16_t nCols;
|
||||
void * buf;
|
||||
void * pDataBlock;
|
||||
SSubmitBlk *pSubmitBlk;
|
||||
} SMemRowBuilder;
|
||||
|
|
|
@ -48,7 +48,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
|
|||
static FORCE_INLINE int32_t getExtendedRowSize(STableComInfo *tinfo) {
|
||||
return tinfo->rowSize + PAYLOAD_HEADER_LEN + PAYLOAD_COL_HEAD_LEN * tinfo->numOfColumns;
|
||||
}
|
||||
int initSMemRowHelper(SMemRowHelper *pHelper, SSchema *pSSchema, uint16_t nCols, uint16_t allNullColsLen) {
|
||||
static int initSMemRowHelper(SMemRowHelper *pHelper, SSchema *pSSchema, uint16_t nCols, uint16_t allNullColsLen) {
|
||||
pHelper->allNullLen = allNullColsLen; // TODO: get allNullColsLen when creating or altering table meta
|
||||
if (pHelper->allNullLen == 0) {
|
||||
for (uint16_t i = 0; i < nCols; ++i) {
|
||||
|
@ -406,7 +406,7 @@ static FORCE_INLINE TDRowLenT tsSetPayloadColValue(char *payloadStart, char *pay
|
|||
payloadColSetId(payload, columnId);
|
||||
payloadColSetType(payload, columnType);
|
||||
memcpy(POINTER_SHIFT(payloadStart,tOffset), value, valueLen);
|
||||
payloadSetTLen(payloadStart, payloadTLen(payloadStart) + valueLen);
|
||||
// payloadSetTLen(payloadStart, payloadTLen(payloadStart) + valueLen);
|
||||
return valueLen;
|
||||
}
|
||||
|
||||
|
@ -793,7 +793,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
|
|||
|
||||
payloadSetNCols(payload, spd->numOfBound);
|
||||
payloadValOffset = payloadValuesOffset(payload); // rely on payloadNCols
|
||||
payloadSetTLen(payload, payloadValOffset);
|
||||
// payloadSetTLen(payload, payloadValOffset);
|
||||
|
||||
char *kvPrimaryKeyStart = payload + PAYLOAD_HEADER_LEN; // primaryKey in 1st column tuple
|
||||
char *kvStart = kvPrimaryKeyStart + PAYLOAD_COL_HEAD_LEN; // the column tuple behind the primaryKey
|
||||
|
@ -1138,7 +1138,7 @@ int tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlk
|
|||
size_t nAlloc = nRows * sizeof(SBlockKeyTuple);
|
||||
if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) {
|
||||
size_t nRealAlloc = nAlloc + 10 * sizeof(SBlockKeyTuple);
|
||||
char * tmp = realloc(pBlkKeyInfo->pKeyTuple, nRealAlloc);
|
||||
char * tmp = trealloc(pBlkKeyInfo->pKeyTuple, nRealAlloc);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1609,7 +1609,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
|
|||
pColInfo->isOrdered = isOrdered;
|
||||
|
||||
if (!isOrdered) {
|
||||
pColInfo->colIdxInfo = calloc(pColInfo->numOfBound, sizeof(SBoundIdxInfo));
|
||||
pColInfo->colIdxInfo = tcalloc(pColInfo->numOfBound, sizeof(SBoundIdxInfo));
|
||||
if (pColInfo->colIdxInfo == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto _clean;
|
||||
|
|
|
@ -1829,7 +1829,6 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bo
|
|||
rowBuilder.pDataBlock = pDataBlock;
|
||||
rowBuilder.pSubmitBlk = pBlock;
|
||||
rowBuilder.buf = p;
|
||||
rowBuilder.size = 0;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
rowBuilder.buf = (blkKeyTuple + i)->payloadAddr;
|
||||
|
|
|
@ -190,7 +190,7 @@ static FORCE_INLINE int tkeyComparFn(const void *tkey1, const void *tkey2) {
|
|||
// ----------------- Data row structure
|
||||
|
||||
/* A data row, the format is like below:
|
||||
* |<--------------------+--------------------------- len ---------------------------------->|
|
||||
* |<------------------------------------------------ len ---------------------------------->|
|
||||
* |<-- Head -->|<--------- flen -------------->| |
|
||||
* +---------------------+---------------------------------+---------------------------------+
|
||||
* | uint16_t | int16_t | | |
|
||||
|
@ -224,11 +224,10 @@ SDataRow tdDataRowDup(SDataRow row);
|
|||
static FORCE_INLINE int tdAppendColVal(SDataRow row, const void *value, int8_t type, int32_t offset) {
|
||||
ASSERT(value != NULL);
|
||||
int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE;
|
||||
char * ptr = (char *)POINTER_SHIFT(row, dataRowLen(row));
|
||||
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
*(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row);
|
||||
memcpy(ptr, value, varDataTLen(value));
|
||||
memcpy(POINTER_SHIFT(row, dataRowLen(row)), value, varDataTLen(value));
|
||||
dataRowLen(row) += varDataTLen(value);
|
||||
} else {
|
||||
if (offset == 0) {
|
||||
|
|
|
@ -196,9 +196,10 @@ do { \
|
|||
#define TSDB_APPNAME_LEN TSDB_UNI_LEN
|
||||
|
||||
/**
|
||||
* Don't change to 65536. As in some scenarios uint16_t (0~65535) is used to store the row len.
|
||||
* So, we use 65531(65535 - 4), as the SDataRow and SKVRow including 4 bits header.
|
||||
* If all cols are VarType except primary key, we need 4 bits to store the offset. 65531-8-4095*4=49143
|
||||
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
||||
* - Firstly, we use 65531(65535 - 4), as the SDataRow and SKVRow including 4 bits header.
|
||||
* - Secondly, if all cols are VarType except primary key, we need 4 bits to store the offset, thus
|
||||
* the final value is 65531-8-4095*4 = 49143.
|
||||
*/
|
||||
#define TSDB_MAX_BYTES_PER_ROW 49143
|
||||
#define TSDB_MAX_TAGS_LEN 16384
|
||||
|
|
Loading…
Reference in New Issue