tresultBuf.h 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#ifndef TDENGINE_VNODEQUERYUTIL_H
#define TDENGINE_VNODEQUERYUTIL_H

#ifdef __cplusplus
extern "C" {
#endif

#include "os.h"
#include "textbuffer.h"

typedef struct SIDList {
  uint32_t alloc;
  int32_t  size;
  int32_t* pData;
} SIDList;

17
typedef struct SQueryDiskbasedResultBuf {
18 19 20 21 22 23 24 25 26 27 28 29
  int32_t  numOfRowsPerPage;
  int32_t  numOfPages;
  int64_t  totalBufSize;
  int32_t  fd;                  // data file fd
  int32_t  allocateId;          // allocated page id
  int32_t  incStep;             // minimum allocated pages
  char*    pBuf;                // mmap buffer pointer
  char*    path;                // file path
  
  uint32_t numOfAllocGroupIds;  // number of allocated id list
  void*    idsTable;            // id hash table
  SIDList* list;                // for each id, there is a page id list
30
} SQueryDiskbasedResultBuf;
31 32 33 34 35 36 37 38

/**
 * create disk-based result buffer
 * @param pResultBuf
 * @param size
 * @param rowSize
 * @return
 */
39
int32_t createDiskbasedResultBuffer(SQueryDiskbasedResultBuf** pResultBuf, int32_t size, int32_t rowSize);
40 41 42 43 44 45 46 47

/**
 *
 * @param pResultBuf
 * @param groupId
 * @param pageId
 * @return
 */
48
tFilePage* getNewDataBuf(SQueryDiskbasedResultBuf* pResultBuf, int32_t groupId, int32_t* pageId);
49 50 51 52 53 54

/**
 *
 * @param pResultBuf
 * @return
 */
55
int32_t getNumOfRowsPerPage(SQueryDiskbasedResultBuf* pResultBuf);
56 57 58 59 60 61 62

/**
 *
 * @param pResultBuf
 * @param groupId
 * @return
 */
63
SIDList getDataBufPagesIdList(SQueryDiskbasedResultBuf* pResultBuf, int32_t groupId);
64 65 66 67 68 69 70

/**
 * get the specified buffer page by id
 * @param pResultBuf
 * @param id
 * @return
 */
71
tFilePage* getResultBufferPageById(SQueryDiskbasedResultBuf* pResultBuf, int32_t id);
72 73 74 75 76 77

/**
 * get the total buffer size in the format of disk file
 * @param pResultBuf
 * @return
 */
78
int32_t getResBufSize(SQueryDiskbasedResultBuf* pResultBuf);
79 80 81 82 83 84

/**
 * get the number of groups in the result buffer
 * @param pResultBuf
 * @return
 */
85
int32_t getNumOfResultBufGroupId(SQueryDiskbasedResultBuf* pResultBuf);
86 87 88 89 90

/**
 * destroy result buffer
 * @param pResultBuf
 */
91
void destroyResultBuf(SQueryDiskbasedResultBuf* pResultBuf);
92 93 94 95 96 97 98 99 100 101 102 103 104

/**
 *
 * @param pList
 * @return
 */
int32_t getLastPageId(SIDList *pList);

#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_VNODEQUERYUTIL_H