index_tfile.h 2.2 KB
Newer Older
dengyihao's avatar
dengyihao 已提交
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 __INDEX_TFILE_H__
#define __INDEX_TFILE_H__

#include "index.h"
#include "indexInt.h"
#include "tlockfree.h"
dengyihao's avatar
dengyihao 已提交
21
#include "index_tfile.h"
dengyihao's avatar
dengyihao 已提交
22
#include "index_fst_counting_writer.h"
dengyihao's avatar
dengyihao 已提交
23
#include "index_fst.h"
dengyihao's avatar
dengyihao 已提交
24 25 26 27 28

#ifdef __cplusplus
extern "C" {
#endif

dengyihao's avatar
dengyihao 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  

typedef struct TFileCacheKey {
  uint64_t   suid;
  uint8_t    colType;
  int32_t    version;
  const char *colName;
  int32_t    nColName;
} TFileCacheKey; 


// table cache
// refactor to LRU cache later
typedef struct TFileCache {
  SHashObj *tableCache;        
  int16_t  capacity;
  // add more param  
} TFileCache;


dengyihao's avatar
dengyihao 已提交
49 50
typedef struct TFileWriter {
  FstBuilder *fb;
dengyihao's avatar
dengyihao 已提交
51
  WriterCtx  *wc; 
dengyihao's avatar
dengyihao 已提交
52 53 54 55 56
} TFileWriter;

typedef struct TFileReader {
  T_REF_DECLARE() 
  Fst *fst;
dengyihao's avatar
dengyihao 已提交
57
  
dengyihao's avatar
dengyihao 已提交
58 59
} TFileReader; 

dengyihao's avatar
dengyihao 已提交
60
typedef struct IndexTFile {
dengyihao's avatar
dengyihao 已提交
61
  char *path;
dengyihao's avatar
dengyihao 已提交
62 63
  TFileReader *tb;
  TFileWriter *tw;      
dengyihao's avatar
dengyihao 已提交
64 65
} IndexTFile;

dengyihao's avatar
dengyihao 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
typedef struct TFileWriterOpt {
  uint64_t suid;
  int8_t   colType;
  char     *colName;  
  int32_t  nColName; 
  int32_t  version;
} TFileWriterOpt; 

typedef struct TFileReaderOpt {
  uint64_t suid; 
  char     *colName;
  int32_t  nColName; 
  
} TFileReaderOpt;

// tfile cache 
TFileCache *tfileCacheCreate();
void tfileCacheDestroy(TFileCache *tcache);
TFileReader* tfileCacheGet(TFileCache *tcache, TFileCacheKey *key);
void tfileCachePut(TFileCache *tcache, TFileCacheKey *key, TFileReader *reader);
  
TFileWriter *tfileWriterCreate(const char *suid, const char *colName);
dengyihao's avatar
dengyihao 已提交
88 89 90

IndexTFile *indexTFileCreate();

dengyihao's avatar
dengyihao 已提交
91
int indexTFilePut(void *tfile, SIndexTerm *term,  uint64_t uid); 
dengyihao's avatar
dengyihao 已提交
92 93 94

int indexTFileSearch(void *tfile, SIndexTermQuery *query, SArray *result);

dengyihao's avatar
dengyihao 已提交
95

dengyihao's avatar
dengyihao 已提交
96 97 98 99 100 101 102 103 104
#ifdef __cplusplus
}


#endif



#endif