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

H
Hongze Cheng 已提交
16 17
#include "tdbInt.h"

H
more  
Hongze Cheng 已提交
18 19
#define BTREE_MAX_DEPTH 20

H
Hongze Cheng 已提交
20 21 22 23 24 25 26 27 28
struct SBTree {
  SPgno   root;
  int     keyLen;
  int     valLen;
  SPFile *pFile;
  int (*FKeyComparator)(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2);
};

struct SBtCursor {
H
more  
Hongze Cheng 已提交
29 30
  SBTree *  pBt;
  i8        iPage;
H
refact  
Hongze Cheng 已提交
31 32
  // SMemPage *pPage;
  // SMemPage *apPage[BTREE_MAX_DEPTH + 1];
H
Hongze Cheng 已提交
33 34
};

H
refact  
Hongze Cheng 已提交
35 36 37 38 39
// typedef struct SMemPage {
//   u8    isInit;
//   u8    isLeaf;
//   SPgno pgno;
// } SMemPage;
H
more  
Hongze Cheng 已提交
40

H
Hongze Cheng 已提交
41 42 43 44 45 46 47 48 49 50 51
int tdbBtreeOpen(SPgno root, SBTree **ppBt) {
  *ppBt = NULL;
  /* TODO */
  return 0;
}

int tdbBtreeClose(SBTree *pBt) {
  // TODO
  return 0;
}

H
more  
Hongze Cheng 已提交
52 53 54
int tdbBtreeCursor(SBTree *pBt, SBtCursor *pCur) {
  pCur->pBt = pBt;
  pCur->iPage = -1;
H
more  
Hongze Cheng 已提交
55
  /* TODO */
H
more  
Hongze Cheng 已提交
56 57 58 59 60 61 62 63 64
  return 0;
}

int tdbBtreeCursorMoveTo(SBtCursor *pCur) {
  /* TODO */
  return 0;
}

static int tdbBtreeCursorMoveToRoot(SBtCursor *pCur) {
H
more  
Hongze Cheng 已提交
65
  SPFile *pFile;
H
refact  
Hongze Cheng 已提交
66
  SPage * pPage;
H
more  
Hongze Cheng 已提交
67 68 69 70 71 72 73

  pFile = pCur->pBt->pFile;

  pPage = tdbPFileGet(pFile, pCur->pBt->root);
  if (pPage == NULL) {
    return -1;
  }
H
more  
Hongze Cheng 已提交
74 75

  return 0;
H
more  
Hongze Cheng 已提交
76
}