TDengine/include/libs/executor/dataSinkMgt.h

164 lines
4 KiB
C
Raw Normal View History

2022-01-06 23:34:51 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DATA_SINK_MGT_H
#define _DATA_SINK_MGT_H
2025-05-08 02:45:00 +00:00
#include <stdint.h>
2022-01-06 23:34:51 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2022-01-11 10:15:37 +00:00
#include "executor.h"
2022-10-13 03:09:43 +00:00
#include "os.h"
2022-02-28 09:02:43 +00:00
#include "plannodes.h"
2022-10-13 03:09:43 +00:00
#include "thash.h"
2022-01-06 23:34:51 +00:00
2022-01-11 07:56:24 +00:00
#define DS_BUF_LOW 1
#define DS_BUF_FULL 2
#define DS_BUF_EMPTY 3
2022-01-06 23:34:51 +00:00
2024-07-01 09:22:43 +00:00
#define DS_FLAG_USE_MEMPOOL (1 << 0)
#define DS_FLAG_PROCESS_ONE_BLOCK (1 << 1)
2024-07-01 09:22:43 +00:00
2022-01-06 23:34:51 +00:00
struct SSDataBlock;
2022-06-06 12:59:36 +00:00
typedef struct SDeleterRes {
2022-06-23 06:25:30 +00:00
uint64_t suid;
2022-06-06 12:59:36 +00:00
SArray* uidList;
int64_t skey;
int64_t ekey;
int64_t affectedRows;
char tableName[TSDB_TABLE_NAME_LEN];
char tsColName[TSDB_COL_NAME_LEN];
2022-06-06 12:59:36 +00:00
} SDeleterRes;
typedef struct SDeleterParam {
2022-06-23 06:25:30 +00:00
uint64_t suid;
SArray* pUidList;
2022-06-06 12:59:36 +00:00
} SDeleterParam;
2025-05-08 01:48:53 +00:00
typedef enum {
AUTO_CREATE_TABLE_UNKNOWN = 0,
AUTO_CREATE_TABLE_STABLE,
AUTO_CREATE_TABLE_STREAM_STABLE,
AUTO_CREATE_TABLE_STREAM_NORMAL,
} AUTO_CREATE_TABLE_MODE;
2022-07-06 08:29:51 +00:00
typedef struct SInserterParam {
2025-05-08 01:48:53 +00:00
SReadHandle* readHandle;
SStreamInserterParam* streamInserterParam;
2022-07-06 08:29:51 +00:00
} SInserterParam;
2022-05-31 06:03:47 +00:00
typedef struct SDataSinkStat {
uint64_t cachedSize;
} SDataSinkStat;
2022-01-06 23:34:51 +00:00
typedef struct SDataSinkMgtCfg {
int8_t compress;
2022-10-13 03:09:43 +00:00
uint32_t maxDataBlockNum; // todo: this should be numOfRows?
2022-01-06 23:34:51 +00:00
uint32_t maxDataBlockNumPerQuery;
} SDataSinkMgtCfg;
2023-08-22 10:40:42 +00:00
int32_t dsDataSinkMgtInit(SDataSinkMgtCfg* cfg, SStorageAPI* pAPI, void** ppSinkManager);
2022-01-06 23:34:51 +00:00
2025-05-08 07:07:04 +00:00
typedef struct SStreamDataInserterInfo {
2025-07-23 06:49:19 +00:00
bool isAutoCreateTable;
int64_t streamId;
int64_t groupId;
char* tbName;
SArray* pTagVals; // SArray<SStreamTagInfo>
2025-05-08 07:07:04 +00:00
} SStreamDataInserterInfo;
2025-05-08 02:45:00 +00:00
typedef struct SInputData {
2022-01-11 08:20:06 +00:00
const struct SSDataBlock* pData;
2025-05-08 07:07:04 +00:00
SStreamDataInserterInfo* pStreamDataInserterInfo;
} SInputData;
2022-01-11 07:56:24 +00:00
typedef struct SOutputData {
int32_t numOfBlocks;
int64_t numOfRows; // int32_t changed to int64_t
int32_t numOfCols;
int8_t compressed;
char* pData;
2022-01-11 07:56:24 +00:00
bool queryEnd;
int32_t bufStatus;
int64_t useconds;
int8_t precision;
} SOutputData;
2022-01-06 23:34:51 +00:00
/**
2022-10-13 03:09:43 +00:00
* Create a subplan's datasinker handle for all later operations.
2022-01-06 23:34:51 +00:00
* @param pDataSink
* @param pHandle output
* @return error code
*/
int32_t dsCreateDataSinker(void* pSinkManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle, void* pParam, const char* id, bool processOneBlock);
2022-01-06 23:34:51 +00:00
2022-10-13 03:09:43 +00:00
int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat);
2022-05-31 06:03:47 +00:00
2022-01-06 23:34:51 +00:00
/**
* Put the result set returned by the executor into datasinker.
* @param handle
* @param pRes
* @return error code
*/
2022-01-11 07:56:24 +00:00
int32_t dsPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* pContinue);
2022-01-18 06:12:25 +00:00
void dsEndPut(DataSinkHandle handle, uint64_t useconds);
2022-01-06 23:34:51 +00:00
2023-07-26 05:54:58 +00:00
void dsReset(DataSinkHandle handle);
2022-01-06 23:34:51 +00:00
/**
* Get the length of the data returned by the next call to dsGetDataBlock.
* @param handle
2022-01-11 02:44:58 +00:00
* @param pLen data length
2022-01-06 23:34:51 +00:00
*/
void dsGetDataLength(DataSinkHandle handle, int64_t* pLen, int64_t* pRawLen, bool* pQueryEnd);
2022-01-06 23:34:51 +00:00
/**
* Get data, the caller needs to allocate data memory.
* @param handle
* @param pOutput output
* @param pStatus output
2022-01-06 23:34:51 +00:00
* @return error code
*/
2022-01-11 07:56:24 +00:00
int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput);
2022-01-06 23:34:51 +00:00
2022-10-13 03:09:43 +00:00
int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t* pSize);
2022-05-31 06:03:47 +00:00
2022-01-06 23:34:51 +00:00
/**
* After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue.
* @param ahandle
* @param pItem
*/
void dsScheduleProcess(void* ahandle, void* pItem);
/**
* Destroy the datasinker handle.
* @param handle
*/
void dsDestroyDataSinker(DataSinkHandle handle);
2024-07-01 09:22:43 +00:00
int32_t dsGetSinkFlags(DataSinkHandle handle, uint64_t* pFlags);
2022-01-06 23:34:51 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_DATA_SINK_MGT_H*/