This commit is contained in:
Hongze Cheng 2022-03-01 06:46:50 +00:00
parent 3902294f01
commit 8bd4beec94
4 changed files with 22 additions and 18 deletions

View File

@ -117,6 +117,9 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen) {
return -1; return -1;
} }
if (pCur->pPage->pHdr->nCells == 0) {
// Tree is empty
} else {
for (;;) { for (;;) {
int lidx, ridx, midx, c; int lidx, ridx, midx, c;
@ -136,6 +139,7 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen) {
ridx = ridx - 1; ridx = ridx - 1;
} }
} }
}
/* code */ /* code */
} }

View File

@ -38,7 +38,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
// pDb->pEnv // pDb->pEnv
pDb->pEnv = pEnv; pDb->pEnv = pEnv;
pFile = tdbEnvGetPFile(pEnv, fname); pFile = tdbEnvGetPager(pEnv, fname);
if (pFile == NULL) { if (pFile == NULL) {
snprintf(fFullName, TDB_FILENAME_LEN, "%s/%s", pEnv->rootDir, fname); snprintf(fFullName, TDB_FILENAME_LEN, "%s/%s", pEnv->rootDir, fname);
ret = tdbPagerOpen(pEnv->pCache, fFullName, &pFile); ret = tdbPagerOpen(pEnv->pCache, fFullName, &pFile);

View File

@ -64,7 +64,7 @@ int tdbEnvClose(STEnv *pEnv) {
return 0; return 0;
} }
SPager *tdbEnvGetPFile(STEnv *pEnv, const char *fname) { SPager *tdbEnvGetPager(STEnv *pEnv, const char *fname) {
// TODO // TODO
return NULL; return NULL;
} }

View File

@ -30,7 +30,7 @@ typedef struct STEnv {
int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv); int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv);
int tdbEnvClose(STEnv *pEnv); int tdbEnvClose(STEnv *pEnv);
SPager *tdbEnvGetPFile(STEnv *pEnv, const char *fname); SPager *tdbEnvGetPager(STEnv *pEnv, const char *fname);
#ifdef __cplusplus #ifdef __cplusplus
} }