tstreamFileState.h 2.1 KB
Newer Older
5
54liuyao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * 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 _STREAM_FILE_STATE_H_
#define _STREAM_FILE_STATE_H_

#include "os.h"

dengyihao's avatar
dengyihao 已提交
21
#include "tarray.h"
5
54liuyao 已提交
22 23 24 25 26 27 28 29 30
#include "tdef.h"
#include "tlist.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct SStreamFileState SStreamFileState;
typedef struct SRowBuffPos {
dengyihao's avatar
dengyihao 已提交
31 32 33 34
  void* pRowBuff;
  void* pKey;
  bool  beFlushed;
  bool  beUsed;
5
54liuyao 已提交
35 36 37 38
} SRowBuffPos;

typedef SList SStreamSnapshot;

5
54liuyao 已提交
39
typedef TSKEY (*GetTsFun)(void*);
5
54liuyao 已提交
40

dengyihao's avatar
dengyihao 已提交
41 42
SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, GetTsFun fp, void* pFile,
                                      TSKEY delMark);
5
54liuyao 已提交
43 44
void              streamFileStateDestroy(SStreamFileState* pFileState);
void              streamFileStateClear(SStreamFileState* pFileState);
5
54liuyao 已提交
45 46

int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen);
5
54liuyao 已提交
47 48
int32_t deleteRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t keyLen);
int32_t getRowBuffByPos(SStreamFileState* pFileState, SRowBuffPos* pPos, void** pVal);
dengyihao's avatar
dengyihao 已提交
49 50
void    releaseRowBuffPos(SRowBuffPos* pBuff);
bool    hasRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen);
5
54liuyao 已提交
51 52

SStreamSnapshot* getSnapshot(SStreamFileState* pFileState);
dengyihao's avatar
dengyihao 已提交
53 54 55 56
int32_t          flushSnapshot(SStreamFileState* pFileState, SStreamSnapshot* pSnapshot, bool flushState);
int32_t          recoverSnapshot(SStreamFileState* pFileState);

int32_t getSnapshotIdList(SStreamFileState* pFileState, SArray* list);
L
liuyao 已提交
57
int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark);
5
54liuyao 已提交
58 59 60 61 62 63

#ifdef __cplusplus
}
#endif

#endif  // _STREAM_FILE_STATE_H_