提交 1eddf234 编写于 作者: H hzcheng

Fix some bug

上级 4900f23a
......@@ -48,6 +48,7 @@ void tdFreeDataRow(SDataRow row);
int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset);
void tdDataRowCpy(void *dst, SDataRow row);
void tdDataRowReset(SDataRow row);
SDataRow tdDataRowDup(SDataRow row);
/* Data rows definition, the format of it is like below:
* +---------+-----------------------+--------+-----------------------+
......@@ -94,30 +95,6 @@ typedef char *SDataCol;
*/
typedef char *SDataCols;
// ----------------- Data column structure
// ---- operation on SDataRow;
#define TD_DATA_ROW_HEADER_SIZE sizeof(int32_t)
#define TD_DATAROW_LEN(pDataRow) (*(int32_t *)(pDataRow))
#define TD_DATAROW_DATA(pDataRow) ((pDataRow) + sizeof(int32_t))
SDataRow tdSDataRowDup(SDataRow rdata);
void tdSDataRowCpy(SDataRow src, void *dst);
void tdFreeSDataRow(SDataRow rdata);
// ---- operation on SDataRows
#define TD_DATAROWS_LEN(pDataRows) (*(int32_t *)(pDataRows))
#define TD_DATAROWS_ROWS(pDataRows) (*(int32_t *)((pDataRows) + sizeof(int32_t)))
#define TD_DATAROWS_DATA(pDataRows) (SDataRow)((pDataRows) + 2 * sizeof(int32_t))
// ---- operation on SDataCol
#define TD_DATACOL_LEN(pDataCol) (*(int32_t *)(pDataCol))
#define TD_DATACOL_NPOINTS(pDataCol) (*(int32_t *)(pDataCol + sizeof(int32_t)))
// ---- operation on SDataCols
#define TD_DATACOLS_LEN(pDataCols) (*(int32_t *)(pDataCols))
#define TD_DATACOLS_NPOINTS(pDataCols) (*(int32_t *)(pDataCols + sizeof(int32_t)))
#ifdef __cplusplus
}
#endif
......
......@@ -80,6 +80,13 @@ int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixO
*/
void tdDataRowCpy(void *dst, SDataRow row) { memcpy(dst, row, dataRowLen(row)); }
void tdDataRowReset(SDataRow row) { dataRowSetLen(row, sizeof(int32_t)); }
SDataRow tdDataRowDup(SDataRow row) {
SDataRow trow = tdNewDataRow(dataRowLen(row));
if (trow == NULL) return NULL;
dataRowCpy(trow, row);
return row;
}
void tdDataRowsAppendRow(SDataRows rows, SDataRow row) {
tdDataRowCpy((void *)((char *)rows + dataRowsLen(rows)), row);
......@@ -113,19 +120,4 @@ SDataRow tdDataRowsNext(SDataRowsIter *pIter) {
}
return row;
}
// ------ Codes below should be refactored
SDataRow tdSDataRowDup(SDataRow rdata) { return NULL; }
void tdFreeSDataRow(SDataRow rdata) {
if (rdata == NULL) return;
free(rdata);
}
/**
* Copy it
*/
void tdSDataRowCpy(SDataRow src, void *dst) {
// TODO
}
\ No newline at end of file
......@@ -111,7 +111,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
if (IS_CREATE_STABLE(pCfg)) { // TSDB_STABLE
pTable->type = TSDB_STABLE;
pTable->stableUid = pCfg->stableUid;
pTable->pTagVal = tdSDataRowDup(pCfg->tagValues);
pTable->pTagVal = tdDataRowDup(pCfg->tagValues);
} else { // TSDB_NTABLE
pTable->type = TSDB_NTABLE;
pTable->stableUid = -1;
......@@ -183,7 +183,7 @@ int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) {
static int tsdbFreeTable(STable *pTable) {
// TODO: finish this function
if (pTable->type == TSDB_STABLE) {
tdFreeSDataRow(pTable->pTagVal);
tdFreeDataRow(pTable->pTagVal);
} else {
tdFreeSchema(pTable->pSchema);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册