indexFstRegistry.h 1.9 KB
Newer Older
dengyihao's avatar
dengyihao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * 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 __FST_REGISTRY_H__
#define __FST_REGISTRY_H__

dengyihao's avatar
dengyihao 已提交
18 19 20 21
#ifdef __cplusplus
extern "C" {
#endif

dengyihao's avatar
dengyihao 已提交
22 23
#include "indexFstNode.h"
#include "indexFstUtil.h"
S
Shengliang Guan 已提交
24
#include "indexInt.h"
dengyihao's avatar
dengyihao 已提交
25

dengyihao's avatar
dengyihao 已提交
26
typedef struct FstRegistryCell {
27
  CompiledAddr    addr;
dengyihao's avatar
dengyihao 已提交
28
  FstBuilderNode* node;
dengyihao's avatar
dengyihao 已提交
29
} FstRegistryCell;
dengyihao's avatar
dengyihao 已提交
30

dengyihao's avatar
dengyihao 已提交
31
#define FST_REGISTRY_CELL_IS_EMPTY(cell) (cell->addr == NONE_ADDRESS)
32
#define FST_REGISTRY_CELL_INSERT(cell, tAddr) \
dengyihao's avatar
dengyihao 已提交
33 34 35
  do {                                        \
    cell->addr = tAddr;                       \
  } while (0)
dengyihao's avatar
dengyihao 已提交
36

37 38
// typedef struct FstRegistryCache {
//  SArray *cells;
dengyihao's avatar
dengyihao 已提交
39 40 41
//  uint32_t start;
//  uint32_t end;
//} FstRegistryCache;
dengyihao's avatar
dengyihao 已提交
42

43
typedef enum { FOUND, NOTFOUND, REJECTED } FstRegistryEntryState;
dengyihao's avatar
dengyihao 已提交
44 45 46

typedef struct FstRegistryEntry {
  FstRegistryEntryState state;
47
  CompiledAddr          addr;
dengyihao's avatar
dengyihao 已提交
48
  FstRegistryCell*      cell;
49
} FstRegistryEntry;
dengyihao's avatar
dengyihao 已提交
50

51
// Registry relation function
dengyihao's avatar
dengyihao 已提交
52
typedef struct FstRegistry {
dengyihao's avatar
dengyihao 已提交
53
  SArray*  table;      //<FstRegistryCell>
54 55 56
  uint64_t tableSize;  // num of rows
  uint64_t mruSize;    // num of columns
} FstRegistry;
dengyihao's avatar
dengyihao 已提交
57

58
//
dengyihao's avatar
dengyihao 已提交
59 60
FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize);
void         fstRegistryDestroy(FstRegistry* registry);
dengyihao's avatar
dengyihao 已提交
61

dengyihao's avatar
dengyihao 已提交
62 63
FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNode);
void              fstRegistryEntryDestroy(FstRegistryEntry* entry);
dengyihao's avatar
dengyihao 已提交
64

dengyihao's avatar
dengyihao 已提交
65 66 67 68
#ifdef __cplusplus
}
#endif

dengyihao's avatar
dengyihao 已提交
69
#endif