indexInt.h 2.6 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 36 37
struct SIndex {
#ifdef USE_LUCENE 
 index_t *index; 
#endif  
dengyihao's avatar
dengyihao 已提交
38 39
 void     *cache;
 void     *tindex; 
dengyihao's avatar
dengyihao 已提交
40 41 42 43 44
 SHashObj *fieldObj;// < field name, field id> 
 
 int64_t  suid;      // current super table id, -1 is normal table    
 int      fieldId;  // field id allocated to cache
 int32_t  cVersion; // current version allocated to cache 
dengyihao's avatar
dengyihao 已提交
45
 pthread_mutex_t mtx;
dengyihao's avatar
dengyihao 已提交
46 47 48 49 50 51
};   

struct SIndexOpts {
#ifdef USE_LUCENE 
  void *opts; 
#endif  
dengyihao's avatar
dengyihao 已提交
52 53
  int32_t numOfItermLimit;
  int8_t  mergeInterval; 
dengyihao's avatar
dengyihao 已提交
54 55
};

dengyihao's avatar
dengyihao 已提交
56 57 58 59 60 61 62
struct SIndexMultiTermQuery {
  EIndexOperatorType opera;   
  SArray *query;
};

// field and key;
typedef struct SIndexTerm {
dengyihao's avatar
dengyihao 已提交
63
  uint8_t type;  // term data type, str/interger/json
dengyihao's avatar
dengyihao 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77
  char    *key;
  int32_t nKey;
  char    *val;
  int32_t nVal;
} SIndexTerm;

typedef struct SIndexTermQuery {
  SIndexTerm*     field_value;
  EIndexQueryType type;
} SIndexTermQuery;


SIndexTerm *indexTermCreate(const char *key, int32_t nKey, const char *val, int32_t nVal);
void        indexTermDestroy(SIndexTerm *p);
dengyihao's avatar
dengyihao 已提交
78 79 80 81 82 83 84 85 86 87


#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 已提交
88 89 90 91
#ifdef __cplusplus
}
#endif

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