dataSinkMgt.c 2.1 KB
Newer Older
X
Xiaoyu Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

H
Haojun Liao 已提交
16
#include "tarray.h"
X
Xiaoyu Wang 已提交
17 18 19 20
#include "dataSinkMgt.h"
#include "dataSinkInt.h"
#include "planner.h"

21 22
static SDataSinkManager gDataSinkManager = {0};

X
Xiaoyu Wang 已提交
23
int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg) {
24 25
  gDataSinkManager.cfg = *cfg;
  pthread_mutex_init(&gDataSinkManager.mutex, NULL);
X
Xiaoyu Wang 已提交
26 27
}

X
Xiaoyu Wang 已提交
28 29
int32_t dsCreateDataSinker(const SDataSinkNode *pDataSink, DataSinkHandle* pHandle) {
  if (QUERY_NODE_DSINK_DISPATCH == nodeType(pDataSink)) {
30
    return createDataDispatcher(&gDataSinkManager, pDataSink, pHandle);
X
Xiaoyu Wang 已提交
31 32 33 34
  }
  return TSDB_CODE_FAILED;
}

X
Xiaoyu Wang 已提交
35
int32_t dsPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* pContinue) {
X
Xiaoyu Wang 已提交
36
  SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
X
Xiaoyu Wang 已提交
37
  return pHandleImpl->fPut(pHandleImpl, pInput, pContinue);
X
Xiaoyu Wang 已提交
38 39
}

D
dapan1121 已提交
40
void dsEndPut(DataSinkHandle handle, uint64_t useconds) {
41
  SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
X
Xiaoyu Wang 已提交
42
  return pHandleImpl->fEndPut(pHandleImpl, useconds);
X
Xiaoyu Wang 已提交
43 44
}

X
Xiaoyu Wang 已提交
45
void dsGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) {
X
Xiaoyu Wang 已提交
46
  SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
X
Xiaoyu Wang 已提交
47
  pHandleImpl->fGetLen(pHandleImpl, pLen, pQueryEnd);
X
Xiaoyu Wang 已提交
48 49
}

X
Xiaoyu Wang 已提交
50
int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
51
  SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
X
Xiaoyu Wang 已提交
52
  return pHandleImpl->fGetData(pHandleImpl, pOutput);
X
Xiaoyu Wang 已提交
53 54 55 56 57 58 59 60 61 62
}

void dsScheduleProcess(void* ahandle, void* pItem) {
  // todo
}

void dsDestroyDataSinker(DataSinkHandle handle) {
  SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
  pHandleImpl->fDestroy(pHandleImpl);
}