indexInt.h 3.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 21
#include "index_fst.h"
#include "taos.h"
22 23
#include "thash.h"
#include "tlog.h"
dengyihao's avatar
dengyihao 已提交
24 25 26 27 28

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

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

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

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

dengyihao's avatar
dengyihao 已提交
43
struct SIndex {
44 45 46 47 48 49 50 51 52 53 54 55 56 57
#ifdef USE_LUCENE
  index_t *index;
#endif
  void *    cache;
  void *    tindex;
  SHashObj *colObj;  // < field name, field id>

  int64_t suid;      // current super table id, -1 is normal table
  int     colId;     // field id allocated to cache
  int32_t cVersion;  // current version allocated to cache

  SIndexStat      stat;
  pthread_mutex_t mtx;
};
dengyihao's avatar
dengyihao 已提交
58 59

struct SIndexOpts {
60 61 62
#ifdef USE_LUCENE
  void *opts;
#endif
dengyihao's avatar
dengyihao 已提交
63 64

#ifdef USE_INVERTED_INDEX
65
  int32_t cacheSize;  // MB
dengyihao's avatar
dengyihao 已提交
66 67
  // add cache module later
#endif
dengyihao's avatar
dengyihao 已提交
68 69
};

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

// field and key;
typedef struct SIndexTerm {
77 78 79 80 81 82 83
  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 已提交
84 85 86
} SIndexTerm;

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

91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
#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)
dengyihao's avatar
dengyihao 已提交
127

H
refact  
Hongze Cheng 已提交
128 129 130 131
#ifdef __cplusplus
}
#endif

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