提交 879f9f75 编写于 作者: C Cary Xu

code optimization

上级 0d9cf348
...@@ -475,37 +475,37 @@ static void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols ...@@ -475,37 +475,37 @@ static void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols
pCols->numOfRows++; pCols->numOfRows++;
} }
static void tdGetKVRowColInfo(const STSchema *pSchema, SColIdx *pColIdx, int nRowCols, STColumn *pSTColumn, // static void tdGetKVRowColInfo(const STSchema *pSchema, SColIdx *pColIdx, int nRowCols, STColumn *pSTColumn,
int *nColMatched) { // int *nColMatched) {
int nSchema = schemaNCols(pSchema); // int nSchema = schemaNCols(pSchema);
int iCol = 0; // int iCol = 0;
int iSchema = 0; // int iSchema = 0;
int nColMatch = 0; // int nColMatch = 0;
SColIdx * pIdx = pColIdx; // SColIdx * pIdx = pColIdx;
const STColumn *pColumn = NULL; // const STColumn *pColumn = NULL;
while (iCol < nRowCols && iSchema < nSchema) { // while (iCol < nRowCols && iSchema < nSchema) {
pColumn = &pSchema->columns[iSchema]; // pColumn = &pSchema->columns[iSchema];
if (pIdx->colId == pColumn->colId) { // if (pIdx->colId == pColumn->colId) {
pSTColumn[nColMatch].colId = pIdx->colId; // pSTColumn[nColMatch].colId = pIdx->colId;
pSTColumn[nColMatch].type = pColumn->type; // pSTColumn[nColMatch].type = pColumn->type;
pSTColumn[nColMatch].bytes = pColumn->bytes; // pSTColumn[nColMatch].bytes = pColumn->bytes;
pSTColumn[nColMatch].offset = pIdx->offset; // pSTColumn[nColMatch].offset = pIdx->offset;
pIdx += sizeof(SColIdx); // pIdx += sizeof(SColIdx);
++iCol; // ++iCol;
++iSchema; // ++iSchema;
++nColMatch; // ++nColMatch;
} else if (pIdx->colId > pColumn->colId) { // } else if (pIdx->colId > pColumn->colId) {
++iSchema; // ++iSchema;
} else { // } else {
pIdx += sizeof(SColIdx); // pIdx += sizeof(SColIdx);
++iCol; // ++iCol;
} // }
} // }
*nColMatched = nColMatch; // *nColMatched = nColMatch;
} // }
static void tdAppendKvRowToDataCol(SKVRow row, STSchema *pSchema, SDataCols *pCols) { static void tdAppendKvRowToDataCol(SKVRow row, STSchema *pSchema, SDataCols *pCols) {
ASSERT(pCols->numOfRows == 0 || dataColsKeyLast(pCols) < kvRowKey(row)); ASSERT(pCols->numOfRows == 0 || dataColsKeyLast(pCols) < kvRowKey(row));
...@@ -524,15 +524,15 @@ static void tdAppendKvRowToDataCol(SKVRow row, STSchema *pSchema, SDataCols *pCo ...@@ -524,15 +524,15 @@ static void tdAppendKvRowToDataCol(SKVRow row, STSchema *pSchema, SDataCols *pCo
} }
} else { } else {
int nRowCols = kvRowNCols(row); int nRowCols = kvRowNCols(row);
int nRowColsMatched = 0; // int nRowColsMatched = 0;
STColumn stColumn[nRowCols]; // STColumn stColumn[nRowCols];
tdGetKVRowColInfo(pSchema, kvRowColIdx(row), nRowCols, stColumn, &nRowColsMatched); // tdGetKVRowColInfo(pSchema, kvRowColIdx(row), nRowCols, stColumn, &nRowColsMatched);
uDebug("prop:kvRow: nRowCols=%d, nRowColsMatched=%d, nSchemaCols=%d", nRowCols, nRowColsMatched, // uInfo("prop:kvRow: nRowCols=%d, nRowColsMatched=%d, nSchemaCols=%d", nRowCols, nRowColsMatched,
schemaNCols(pSchema)); // schemaNCols(pSchema));
while (dcol < pCols->numOfCols) { while (dcol < pCols->numOfCols) {
SDataCol *pDataCol = &(pCols->cols[dcol]); SDataCol *pDataCol = &(pCols->cols[dcol]);
if (rcol >= nRowColsMatched || rcol >= schemaNCols(pSchema)) { if (rcol >= nRowCols || rcol >= schemaNCols(pSchema)) {
dataColAppendVal(pDataCol, tdGetNullVal(pDataCol->type), pCols->numOfRows, pCols->maxPoints); dataColAppendVal(pDataCol, tdGetNullVal(pDataCol->type), pCols->numOfRows, pCols->maxPoints);
dcol++; dcol++;
continue; continue;
...@@ -541,9 +541,7 @@ static void tdAppendKvRowToDataCol(SKVRow row, STSchema *pSchema, SDataCols *pCo ...@@ -541,9 +541,7 @@ static void tdAppendKvRowToDataCol(SKVRow row, STSchema *pSchema, SDataCols *pCo
SColIdx *colIdx = kvRowColIdxAt(row, rcol); SColIdx *colIdx = kvRowColIdxAt(row, rcol);
if (colIdx->colId == pDataCol->colId) { if (colIdx->colId == pDataCol->colId) {
ASSERT(pDataCol->type == stColumn[rcol].type); void *value = tdGetKvRowDataOfCol(row, pDataCol->type, colIdx->offset);
void *value = tdGetKvRowDataOfCol(row, pDataCol->type, stColumn[rcol].offset + TD_KV_ROW_HEAD_SIZE);
dataColAppendVal(pDataCol, value, pCols->numOfRows, pCols->maxPoints); dataColAppendVal(pDataCol, value, pCols->numOfRows, pCols->maxPoints);
dcol++; dcol++;
rcol++; rcol++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册