Lines Matching defs:pNode

140513     NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
140523 nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
140528 if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
140533 Blob *pBlk = &pNode->block;
140542 blobGrowBuffer(&pNode->key, nTerm, &rc);
140545 if( pNode->key.n ){
140552 memcpy(pNode->key.a, zTerm, nTerm);
140553 pNode->key.n = nTerm;
140559 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
140561 assert( pNode->block.nAlloc>=p->nNodeSize );
140562 pNode->block.a[0] = (char)iLayer;
140563 pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);
140565 iNextPtr = pNode->iBlock;
140566 pNode->iBlock++;
140567 pNode->key.n = 0;
140580 ** stored in blob *pNode. The node need not contain any terms, but the
140595 ** It is assumed that the buffer associated with pNode is already large
140603 Blob *pNode, /* Current node image to append to */
140617 assert( pNode->n>0 );
140618 assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
140629 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
140631 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);
140632 memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);
140633 pNode->n += nSuffix;
140636 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);
140637 memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);
140638 pNode->n += nDoclist;
140641 assert( pNode->n<=pNode->nAlloc );
140752 NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
140753 if( pNode->block.n>0 ) break;
140754 assert( *pRc || pNode->block.nAlloc==0 );
140755 assert( *pRc || pNode->key.nAlloc==0 );
140756 sqlite3_free(pNode->block.a);
140757 sqlite3_free(pNode->key.a);
140793 NodeWriter *pNode = &pWriter->aNodeWriter[i];
140794 if( pNode->block.n>0 && rc==SQLITE_OK ){
140795 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
140797 sqlite3_free(pNode->block.a);
140798 sqlite3_free(pNode->key.a);
140952 NodeWriter *pNode;
140964 pNode = &pWriter->aNodeWriter[nHeight];
140965 pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
140966 blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);
140968 memcpy(pNode->block.a, aRoot, nRoot);
140969 pNode->block.n = nRoot;
140974 pNode = &pWriter->aNodeWriter[i];
140976 rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
140978 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
140980 memcpy(pNode->key.a, reader.term.a, reader.term.n);
140981 pNode->key.n = reader.term.n;
140985 pNode = &pWriter->aNodeWriter[i-1];
140986 pNode->iBlock = reader.iChild;
140988 blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
140990 memcpy(pNode->block.a, aBlock, nBlock);
140991 pNode->block.n = nBlock;
141206 static void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){
141207 pNode->a[0] = (char)iHeight;
141209 assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );
141210 pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);
141212 assert( pNode->nAlloc>=1 );
141213 pNode->n = 1;
144981 #define NCELL(pNode) readInt16(&(pNode)->zData[2])
145139 ** Add node pNode to the node hash table.
145141 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
145143 assert( pNode->pNext==0 );
145144 iHash = nodeHash(pNode->iNode);
145145 pNode->pNext = pRtree->aHash[iHash];
145146 pRtree->aHash[iHash] = pNode;
145150 ** Remove node pNode from the node hash table.
145152 static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
145154 if( pNode->iNode!=0 ){
145155 pp = &pRtree->aHash[nodeHash(pNode->iNode)];
145156 for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }
145157 *pp = pNode->pNext;
145158 pNode->pNext = 0;
145169 RtreeNode *pNode;
145170 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
145171 if( pNode ){
145172 memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
145173 pNode->zData = (u8 *)&pNode[1];
145174 pNode->nRef = 1;
145175 pNode->pParent = pParent;
145176 pNode->isDirty = 1;
145179 return pNode;
145193 RtreeNode *pNode;
145198 if( (pNode = nodeHashLookup(pRtree, iNode)) ){
145199 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
145200 if( pParent && !pNode->pParent ){
145202 pNode->pParent = pParent;
145204 pNode->nRef++;
145205 *ppNode = pNode;
145214 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
145215 if( !pNode ){
145218 pNode->pParent = pParent;
145219 pNode->zData = (u8 *)&pNode[1];
145220 pNode->nRef = 1;
145221 pNode->iNode = iNode;
145222 pNode->isDirty = 0;
145223 pNode->pNext = 0;
145224 memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
145238 if( pNode && iNode==1 ){
145239 pRtree->iDepth = readInt16(pNode->zData);
145249 if( pNode && rc==SQLITE_OK ){
145250 if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
145256 if( pNode!=0 ){
145257 nodeHashInsert(pRtree, pNode);
145261 *ppNode = pNode;
145263 sqlite3_free(pNode);
145271 ** Overwrite cell iCell of node pNode with the contents of pCell.
145275 RtreeNode *pNode, /* The node into which the cell is to be written */
145277 int iCell /* Index into pNode into which pCell is written */
145280 u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
145285 pNode->isDirty = 1;
145289 ** Remove the cell with index iCell from node pNode.
145291 static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){
145292 u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
145294 int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;
145296 writeInt16(&pNode->zData[2], NCELL(pNode)-1);
145297 pNode->isDirty = 1;
145301 ** Insert the contents of cell pCell into node pNode. If the insert
145304 ** If there is not enough free space in pNode, return SQLITE_FULL.
145308 RtreeNode *pNode, /* Write new cell into this node */
145311 int nCell; /* Current number of cells in pNode */
145312 int nMaxCell; /* Maximum number of cells for pNode */
145315 nCell = NCELL(pNode);
145319 nodeOverwriteCell(pRtree, pNode, pCell, nCell);
145320 writeInt16(&pNode->zData[2], nCell+1);
145321 pNode->isDirty = 1;
145330 static int nodeWrite(Rtree *pRtree, RtreeNode *pNode){
145332 if( pNode->isDirty ){
145334 if( pNode->iNode ){
145335 sqlite3_bind_int64(p, 1, pNode->iNode);
145339 sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
145341 pNode->isDirty = 0;
145343 if( pNode->iNode==0 && rc==SQLITE_OK ){
145344 pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
145345 nodeHashInsert(pRtree, pNode);
145355 static int nodeRelease(Rtree *pRtree, RtreeNode *pNode){
145357 if( pNode ){
145358 assert( pNode->nRef>0 );
145359 pNode->nRef--;
145360 if( pNode->nRef==0 ){
145361 if( pNode->iNode==1 ){
145364 if( pNode->pParent ){
145365 rc = nodeRelease(pRtree, pNode->pParent);
145368 rc = nodeWrite(pRtree, pNode);
145370 nodeHashDelete(pRtree, pNode);
145371 sqlite3_free(pNode);
145379 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
145384 RtreeNode *pNode, /* The node from which to extract the ID */
145387 assert( iCell<NCELL(pNode) );
145388 return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);
145392 ** Return coordinate iCoord from cell iCell in node pNode.
145396 RtreeNode *pNode, /* The node from which to extract a coordinate */
145401 readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
145405 ** Deserialize cell iCell of node pNode. Populate the structure pointed
145410 RtreeNode *pNode, /* The node containing the cell to be read */
145417 pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
145418 pData = pNode->zData + (12 + pRtree->nBytesPerCell*iCell);
145742 ** One of the cells in node pNode is guaranteed to have a 64-bit
145747 RtreeNode *pNode,
145752 int nCell = NCELL(pNode);
145755 if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
145764 ** Return the index of the cell containing a pointer to node pNode
145765 ** in its parent. If pNode is the root node, return -1.
145767 static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
145768 RtreeNode *pParent = pNode->pParent;
145770 return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
145997 RtreeNode *pNode;
146008 pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);
146010 nCell = NCELL(pNode);
146014 u8 *pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);
146082 RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);
146084 *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell);
146098 RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);
146103 sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));
146106 nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c);
146530 RtreeNode *pNode;
146531 rc = nodeAcquire(pRtree, 1, 0, &pNode);
146540 int nCell = NCELL(pNode);
146554 nodeGetCell(pRtree, pNode, iCell, &cell);
146568 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
146569 nodeRelease(pRtree, pNode);
146570 pNode = pChild;
146573 *ppLeaf = pNode;
146579 ** the node pNode. This function updates the bounding box cells in
146584 RtreeNode *pNode, /* Adjust ancestry of this node. */
146587 RtreeNode *p = pNode;
146874 RtreeNode *pNode,
146883 nodeReference(pNode);
146884 pChild->pParent = pNode;
146887 return xSetMapping(pRtree, iRowid, pNode->iNode);
146892 RtreeNode *pNode,
146900 int nCell = NCELL(pNode);
146921 nodeGetCell(pRtree, pNode, i, &aCell[i]);
146923 nodeZero(pRtree, pNode);
146927 if( pNode->iNode==1 ){
146928 pRight = nodeNew(pRtree, pNode);
146929 pLeft = nodeNew(pRtree, pNode);
146931 pNode->isDirty = 1;
146932 writeInt16(pNode->zData, pRtree->iDepth);
146934 pLeft = pNode;
146967 if( pNode->iNode==1 ){
146998 if( pNode->iNode==1 ){
147069 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
147075 assert( pNode->nRef==1 );
147078 rc = nodeParentIndex(pRtree, pNode, &iCell);
147080 pParent = pNode->pParent;
147081 pNode->pParent = 0;
147093 sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);
147100 sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);
147109 nodeHashDelete(pRtree, pNode);
147110 pNode->iNode = iHeight;
147111 pNode->pNext = pRtree->pDeleted;
147112 pNode->nRef++;
147113 pRtree->pDeleted = pNode;
147118 static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
147119 RtreeNode *pParent = pNode->pParent;
147123 int nCell = NCELL(pNode);
147124 RtreeCell box; /* Bounding box for pNode */
147125 nodeGetCell(pRtree, pNode, 0, &box);
147128 nodeGetCell(pRtree, pNode, ii, &cell);
147131 box.iRowid = pNode->iNode;
147132 rc = nodeParentIndex(pRtree, pNode, &ii);
147142 ** Delete the cell at index iCell of node pNode. After removing the
147145 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
147149 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
147156 nodeDeleteCell(pRtree, pNode, iCell);
147163 pParent = pNode->pParent;
147164 assert( pParent || pNode->iNode==1 );
147166 if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){
147167 rc = removeNode(pRtree, pNode, iHeight);
147169 rc = fixBoundingBox(pRtree, pNode);
147178 RtreeNode *pNode,
147195 nCell = NCELL(pNode)+1;
147218 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
147240 nodeZero(pRtree, pNode);
147244 nodeInsertCell(pRtree, pNode, p);
147247 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
147249 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
147254 rc = fixBoundingBox(pRtree, pNode);
147257 /* Find a node to store this cell in. pNode->iNode currently contains
147278 ** Insert cell pCell into node pNode. Node pNode is the head of a
147283 RtreeNode *pNode,
147292 nodeReference(pNode);
147293 pChild->pParent = pNode;
147296 if( nodeInsertCell(pRtree, pNode, pCell) ){
147297 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){
147298 rc = SplitNode(pRtree, pNode, pCell, iHeight);
147301 rc = Reinsert(pRtree, pNode, pCell, iHeight);
147304 rc = AdjustTree(pRtree, pNode, pCell);
147307 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
147309 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
147316 static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){
147319 int nCell = NCELL(pNode);
147324 nodeGetCell(pRtree, pNode, ii, &cell);
147326 /* Find a node to store this cell in. pNode->iNode currently contains
147329 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
147332 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);