add an interface for index db query
This commit is contained in:
parent
dfaa78daf6
commit
d22d069bd9
|
@ -220,6 +220,40 @@ int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen) {
|
||||
SBTC btc;
|
||||
SCell *pCell;
|
||||
int cret;
|
||||
void *pTKey;
|
||||
void *pTVal;
|
||||
SCellDecoder cd;
|
||||
|
||||
tdbBtcOpen(&btc, pBt);
|
||||
|
||||
tdbBtCursorMoveTo(&btc, pKey, kLen, &cret);
|
||||
if (cret) {
|
||||
return cret;
|
||||
}
|
||||
|
||||
pCell = tdbPageGetCell(btc.pPage, btc.idx);
|
||||
tdbBtreeDecodeCell(btc.pPage, pCell, &cd);
|
||||
|
||||
pTKey = TDB_REALLOC(*ppKey, cd.kLen);
|
||||
pTVal = TDB_REALLOC(*ppVal, cd.vLen);
|
||||
|
||||
if (pTKey == NULL || pTVal == NULL) {
|
||||
TDB_FREE(pTKey);
|
||||
TDB_FREE(pTVal);
|
||||
}
|
||||
|
||||
*ppKey = pTKey;
|
||||
*ppVal = pTVal;
|
||||
*pkLen = cd.kLen;
|
||||
*vLen = cd.vLen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tdbBtCursorMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||
int ret;
|
||||
SBTree *pBt;
|
||||
|
|
|
@ -96,6 +96,10 @@ int tdbDbGet(TDB *pDb, const void *pKey, int kLen, void **ppVal, int *vLen) {
|
|||
return tdbBtreeGet(pDb->pBt, pKey, kLen, ppVal, vLen);
|
||||
}
|
||||
|
||||
int tdbDbPGet(TDB *pDb, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen) {
|
||||
return tdbBtreePGet(pDb->pBt, pKey, kLen, ppKey, pkLen, ppVal, vLen);
|
||||
}
|
||||
|
||||
int tdbDbcOpen(TDB *pDb, TDBC **ppDbc) {
|
||||
int ret;
|
||||
TDBC *pDbc = NULL;
|
||||
|
|
|
@ -43,6 +43,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, FKeyComparator kcmpr, SB
|
|||
int tdbBtreeClose(SBTree *pBt);
|
||||
int tdbBtCursorInsert(SBTC *pCur, const void *pKey, int kLen, const void *pVal, int vLen);
|
||||
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen);
|
||||
int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen);
|
||||
|
||||
// SBTC
|
||||
int tdbBtcOpen(SBTC *pCur, SBTree *pBt);
|
||||
|
|
|
@ -29,6 +29,7 @@ int tdbDbClose(TDB *pDb);
|
|||
int tdbDbDrop(TDB *pDb);
|
||||
int tdbDbInsert(TDB *pDb, const void *pKey, int keyLen, const void *pVal, int valLen);
|
||||
int tdbDbGet(TDB *pDb, const void *pKey, int kLen, void **ppVal, int *vLen);
|
||||
int tdbDbPGet(TDB *pDb, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen);
|
||||
|
||||
// TDBC
|
||||
int tdbDbcOpen(TDB *pDb, TDBC **ppDbc);
|
||||
|
|
Loading…
Reference in New Issue