index.h 2.7 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

H
refact  
Hongze Cheng 已提交
16 17
#ifndef _TD_INDEX_H_
#define _TD_INDEX_H_
H
refact  
Hongze Cheng 已提交
18

dengyihao's avatar
dengyihao 已提交
19 20 21
#include "os.h"
#include "tarray.h"

H
refact  
Hongze Cheng 已提交
22 23 24 25
#ifdef __cplusplus
extern "C" {
#endif

dengyihao's avatar
dengyihao 已提交
26
typedef struct SIndex SIndex;
dengyihao's avatar
dengyihao 已提交
27
typedef struct SIndexTerm SIndexTerm;
dengyihao's avatar
dengyihao 已提交
28
typedef struct SIndexOpts SIndexOpts;
dengyihao's avatar
dengyihao 已提交
29 30
typedef struct SIndexMultiTermQuery SIndexMultiTermQuery;
typedef struct SArray               SIndexMultiTerm;
dengyihao's avatar
dengyihao 已提交
31

dengyihao's avatar
dengyihao 已提交
32 33 34 35 36 37 38
typedef enum  {
   ADD_VALUE,    // add index colume value   
   DEL_VALUE,    // delete index column value  
   UPDATE_VALUE, // update index column value 
   ADD_INDEX,    // add index on specify column
   DROP_INDEX,   // drop existed index 
   DROP_SATBLE   // drop stable 
dengyihao's avatar
dengyihao 已提交
39
} SIndexOperOnColumn;
dengyihao's avatar
dengyihao 已提交
40

dengyihao's avatar
dengyihao 已提交
41
typedef enum  { MUST = 0, SHOULD = 1, NOT = 2 } EIndexOperatorType;
dengyihao's avatar
dengyihao 已提交
42
typedef enum  { QUERY_TERM = 0, QUERY_PREFIX = 1, QUERY_SUFFIX = 2,QUERY_REGEX = 3} EIndexQueryType;
dengyihao's avatar
dengyihao 已提交
43 44 45 46
/*
 * @param: oper 
 *
*/
dengyihao's avatar
dengyihao 已提交
47 48
SIndexMultiTermQuery *indexMultiTermQueryCreate(EIndexOperatorType oper);
void            indexMultiTermQueryDestroy(SIndexMultiTermQuery *pQuery);
dengyihao's avatar
dengyihao 已提交
49
int             indexMultiTermQueryAdd(SIndexMultiTermQuery *pQuery, SIndexTerm *term, EIndexQueryType type);
dengyihao's avatar
dengyihao 已提交
50 51 52 53 54
/* 
 * @param:    
 * @param:
 */
SIndex* indexOpen(SIndexOpts *opt, const char *path);
dengyihao's avatar
dengyihao 已提交
55 56 57 58 59
void  indexClose(SIndex *index);
int   indexPut(SIndex *index,    SIndexMultiTerm *terms, int uid);
int   indexDelete(SIndex *index, SIndexMultiTermQuery *query); 
int   indexSearch(SIndex *index, SIndexMultiTermQuery *query, SArray *result);
int   indexRebuild(SIndex *index, SIndexOpts *opt);
dengyihao's avatar
dengyihao 已提交
60 61 62 63
/*
 * @param
 * @param
 */
dengyihao's avatar
dengyihao 已提交
64
SIndexMultiTerm *indexMultiTermCreate(); 
dengyihao's avatar
dengyihao 已提交
65 66
int indexMultiTermAdd(SIndexMultiTerm  *terms, SIndexTerm *term);
void indexMultiTermDestroy(SIndexMultiTerm *terms);
dengyihao's avatar
dengyihao 已提交
67 68 69 70 71 72 73
/*
 * @param: 
 * @param:
 */
SIndexOpts *indexOptsCreate();
void       indexOptsDestroy(SIndexOpts *opts);

dengyihao's avatar
dengyihao 已提交
74 75 76 77 78 79 80 81 82 83 84

/*
 * @param:
 * @param:
 */

SIndexTerm *indexTermCreate(int64_t suid, SIndexOperOnColumn operType, uint8_t colType, 
                            const char *colName, int32_t nColName, const char *colVal, int32_t nColVal);
void        indexTermDestroy(SIndexTerm *p);


H
refact  
Hongze Cheng 已提交
85 86 87 88
#ifdef __cplusplus
}
#endif

dengyihao's avatar
dengyihao 已提交
89
#endif /*_TD_INDEX_H_*/