indexInt.h 2.9 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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 _TD_INDEX_INT_H_
#define _TD_INDEX_INT_H_

dengyihao's avatar
dengyihao 已提交
19
#include "index.h"
dengyihao's avatar
dengyihao 已提交
20
#include "index_fst.h"
dengyihao's avatar
dengyihao 已提交
21
#include "tlog.h"
dengyihao's avatar
dengyihao 已提交
22 23
#include "thash.h"
#include "taos.h"
dengyihao's avatar
dengyihao 已提交
24 25 26 27 28 29

#ifdef USE_LUCENE
#include <lucene++/Lucene_c.h>
#endif


H
refact  
Hongze Cheng 已提交
30 31 32 33
#ifdef __cplusplus
extern "C" {
#endif

dengyihao's avatar
dengyihao 已提交
34 35
typedef enum {kTypeValue, kTypeDeletion} STermValueType ;

dengyihao's avatar
dengyihao 已提交
36 37 38 39
typedef struct SIndexStat {
  int32_t totalAdded;   //  
  int32_t totalDeled;   //
  int32_t totalUpdated; // 
dengyihao's avatar
dengyihao 已提交
40 41
  int32_t totalTerms;   //  
  int32_t distinctCol; // distinct column 
dengyihao's avatar
dengyihao 已提交
42 43
} SIndexStat; 

dengyihao's avatar
dengyihao 已提交
44 45 46 47
struct SIndex {
#ifdef USE_LUCENE 
 index_t *index; 
#endif  
dengyihao's avatar
dengyihao 已提交
48 49
 void     *cache;
 void     *tindex; 
dengyihao's avatar
dengyihao 已提交
50
 SHashObj *colObj;// < field name, field id> 
dengyihao's avatar
dengyihao 已提交
51 52
 
 int64_t  suid;      // current super table id, -1 is normal table    
dengyihao's avatar
dengyihao 已提交
53
 int      colId;  // field id allocated to cache
dengyihao's avatar
dengyihao 已提交
54
 int32_t  cVersion; // current version allocated to cache 
dengyihao's avatar
dengyihao 已提交
55 56

 SIndexStat stat;
dengyihao's avatar
dengyihao 已提交
57
 pthread_mutex_t mtx;
dengyihao's avatar
dengyihao 已提交
58 59 60 61 62
};   

struct SIndexOpts {
#ifdef USE_LUCENE 
  void *opts; 
dengyihao's avatar
dengyihao 已提交
63 64 65 66 67 68 69
#endif   

#ifdef USE_INVERTED_INDEX
  int32_t cacheSize;  // MB  
  // add cache module later
#endif

dengyihao's avatar
dengyihao 已提交
70 71
};

dengyihao's avatar
dengyihao 已提交
72 73 74 75 76 77 78
struct SIndexMultiTermQuery {
  EIndexOperatorType opera;   
  SArray *query;
};

// field and key;
typedef struct SIndexTerm {
dengyihao's avatar
dengyihao 已提交
79 80 81 82 83 84 85
  int64_t           suid; 
  SIndexOperOnColumn operType; // oper type, add/del/update
  uint8_t            colType;  // term data type, str/interger/json
  char    *colName;
  int32_t nColName;
  char    *colVal;
  int32_t nColVal;
dengyihao's avatar
dengyihao 已提交
86 87 88
} SIndexTerm;

typedef struct SIndexTermQuery {
dengyihao's avatar
dengyihao 已提交
89 90
  SIndexTerm*     term;
  EIndexQueryType qType;
dengyihao's avatar
dengyihao 已提交
91 92 93
} SIndexTermQuery;


dengyihao's avatar
dengyihao 已提交
94 95 96 97 98 99 100 101 102

#define indexFatal(...) do { if (sDebugFlag & DEBUG_FATAL) { taosPrintLog("index FATAL ", 255, __VA_ARGS__); }}     while(0)
#define indexError(...) do { if (sDebugFlag & DEBUG_ERROR) { taosPrintLog("index ERROR ", 255, __VA_ARGS__); }}     while(0)
#define indexWarn(...)  do { if (sDebugFlag & DEBUG_WARN)  { taosPrintLog("index WARN ", 255, __VA_ARGS__); }}      while(0)
#define indexInfo(...)  do { if (sDebugFlag & DEBUG_INFO)  { taosPrintLog("index ", 255, __VA_ARGS__); }}           while(0)
#define indexDebug(...) do { if (sDebugFlag & DEBUG_DEBUG) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); }} while(0)
#define indexTrace(...) do { if (sDebugFlag & DEBUG_TRACE) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); }} while(0)


H
refact  
Hongze Cheng 已提交
103 104 105 106
#ifdef __cplusplus
}
#endif

dengyihao's avatar
dengyihao 已提交
107
#endif /*_TD_INDEX_INT_H_*/