• Home
  • Raw
  • Download

Lines Matching refs:pWriter

62630   Btree *pWriter;       /* Btree with currently open write transaction */
63485 assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
63496 if( pBt->pWriter!=p && (pBt->btsFlags & BTS_EXCLUSIVE)!=0 ){
63497 sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);
63516 assert( p==pBt->pWriter );
63618 assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );
63631 assert( (pBt->btsFlags & BTS_PENDING)==0 || pBt->pWriter );
63632 if( pBt->pWriter==p ){
63633 pBt->pWriter = 0;
63654 if( pBt->pWriter==p ){
63656 pBt->pWriter = 0;
66599 pBlock = pBt->pWriter->db;
66677 assert( !pBt->pWriter );
66678 pBt->pWriter = p;
172762 SegmentWriter *pWriter = *ppWriter;
172764 if( !pWriter ){
172769 pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));
172770 if( !pWriter ) return SQLITE_NOMEM;
172771 memset(pWriter, 0, sizeof(SegmentWriter));
172772 *ppWriter = pWriter;
172775 pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);
172776 if( !pWriter->aData ) return SQLITE_NOMEM;
172777 pWriter->nSize = p->nNodeSize;
172783 pWriter->iFree = sqlite3_column_int64(pStmt, 0);
172784 pWriter->iFirst = pWriter->iFree;
172789 nData = pWriter->nData;
172791 nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);
172810 if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB;
172811 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
172828 rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);
172832 pWriter->nTerm = 0;
172844 pWriter->nLeafData += nReq;
172849 if( nReq>pWriter->nSize ){
172850 char *aNew = sqlite3_realloc(pWriter->aData, nReq);
172852 pWriter->aData = aNew;
172853 pWriter->nSize = nReq;
172855 assert( nData+nReq<=pWriter->nSize );
172858 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);
172859 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);
172861 memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);
172863 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);
172865 memcpy(&pWriter->aData[nData], aDoclist, nDoclist);
172866 pWriter->nData = nData + nDoclist;
172874 if( nTerm>pWriter->nMalloc ){
172875 char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);
172879 pWriter->nMalloc = nTerm*2;
172880 pWriter->zMalloc = zNew;
172881 pWriter->zTerm = zNew;
172883 assert( pWriter->zTerm==pWriter->zMalloc );
172885 memcpy(pWriter->zTerm, zTerm, nTerm);
172887 pWriter->zTerm = (char *)zTerm;
172889 pWriter->nTerm = nTerm;
172902 SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
172907 if( pWriter->pTree ){
172913 iLastLeaf = pWriter->iFree;
172914 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);
172916 rc = fts3NodeWrite(p, pWriter->pTree, 1,
172917 pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);
172921 pWriter->iFirst, iLastLeaf, iLast, pWriter->nLeafData, zRoot, nRoot);
172926 0, 0, 0, pWriter->nLeafData, pWriter->aData, pWriter->nData);
172936 static void fts3SegWriterFree(SegmentWriter *pWriter){
172937 if( pWriter ){
172938 sqlite3_free(pWriter->aData);
172939 sqlite3_free(pWriter->zMalloc);
172940 fts3NodeFree(pWriter->pTree);
172941 sqlite3_free(pWriter);
173731 SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
173790 rc = fts3SegWriterAdd(p, &pWriter, 1,
173794 assert_fts3_nc( pWriter || bIgnoreEmpty );
173802 if( pWriter ){
173803 rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);
173806 rc = fts3PromoteSegments(p, iNewLevel, pWriter->nLeafData);
173812 fts3SegWriterFree(pWriter);
174360 IncrmergeWriter *pWriter, /* Writer object */
174364 sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;
174370 NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
174513 IncrmergeWriter *pWriter, /* Writer object */
174526 pLeaf = &pWriter->aNodeWriter[0];
174539 pWriter->nWork++;
174554 rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
174568 pWriter->nLeafData += nSpace;
174598 IncrmergeWriter *pWriter, /* Merge-writer object */
174611 NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
174638 Blob *pBlock = &pWriter->aNodeWriter[1].block;
174643 &pBlock->a[1], pWriter->aNodeWriter[0].iBlock
174648 pRoot = &pWriter->aNodeWriter[iRoot];
174652 NodeWriter *pNode = &pWriter->aNodeWriter[i];
174663 pWriter->iAbsLevel+1, /* level */
174664 pWriter->iIdx, /* idx */
174665 pWriter->iStart, /* start_block */
174666 pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */
174667 pWriter->iEnd, /* end_block */
174668 (pWriter->bNoLeafData==0 ? pWriter->nLeafData : 0), /* end_block */
174749 IncrmergeWriter *pWriter /* Populate this object */
174770 fts3ReadEndBlockField(pSelect, 3, &iEnd, &pWriter->nLeafData);
174771 if( pWriter->nLeafData<0 ){
174772 pWriter->nLeafData = pWriter->nLeafData * -1;
174774 pWriter->bNoLeafData = (pWriter->nLeafData==0);
174821 pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
174822 pWriter->iStart = iStart;
174823 pWriter->iEnd = iEnd;
174824 pWriter->iAbsLevel = iAbsLevel;
174825 pWriter->iIdx = iIdx;
174828 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
174831 pNode = &pWriter->aNodeWriter[nHeight];
174832 pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
174844 pNode = &pWriter->aNodeWriter[i];
174856 pNode = &pWriter->aNodeWriter[i-1];
174941 IncrmergeWriter *pWriter /* Populate this object */
174965 pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);
174966 pWriter->iEnd = pWriter->iStart - 1;
174967 pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;
174976 rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
174979 pWriter->iAbsLevel = iAbsLevel;
174980 pWriter->nLeafEst = nLeafEst;
174981 pWriter->iIdx = iIdx;
174985 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
175411 IncrmergeWriter *pWriter; /* Writer object */
175418 const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);
175419 pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);
175420 if( !pWriter ) return SQLITE_NOMEM;
175421 pFilter = (Fts3SegFilter *)&pWriter[1];
175488 memset(pWriter, 0, nAlloc);
175520 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
175522 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
175525 if( rc==SQLITE_OK && pWriter->nLeafEst ){
175529 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
175531 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
175537 nRem -= (1 + pWriter->nWork);
175547 pWriter->nLeafData = pWriter->nLeafData * -1;
175549 fts3IncrmergeRelease(p, pWriter, &rc);
175550 if( nSeg==0 && pWriter->bNoLeafData==0 ){
175551 fts3PromoteSegments(p, iAbsLevel+1, pWriter->nLeafData);
175563 sqlite3_free(pWriter);
192098 sqlite3_stmt *pWriter;
192116 pWriter = pIter->pDelete;
192118 pWriter = pIter->pInsert;
192139 p->rc = sqlite3_bind_value(pWriter, i+1, pVal);
192158 p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);
192162 sqlite3_step(pWriter);
192163 p->rc = resetAndCollectError(pWriter, &p->zErrmsg);
204578 Fts5PoslistWriter *pWriter,
204583 sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);
206323 Fts5PoslistWriter *pWriter = &a[i].writer;
206324 if( a[i].pOut->n==0 || iPos!=pWriter->iPrev ){
206325 sqlite3Fts5PoslistWriterAppend(a[i].pOut, pWriter, iPos);
209413 sqlite3_stmt *pWriter; /* "INSERT ... %_data VALUES(?,?)" */
209861 if( p->pWriter==0 ){
209863 fts5IndexPrepareStmt(p, &p->pWriter, sqlite3_mprintf(
209870 sqlite3_bind_int64(p->pWriter, 1, iRowid);
209871 sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);
209872 sqlite3_step(p->pWriter);
209873 p->rc = sqlite3_reset(p->pWriter);
209874 sqlite3_bind_null(p->pWriter, 2);
212770 Fts5SegWriter *pWriter,
212774 assert( bFlush==0 || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n>0) );
212775 for(i=0; i<pWriter->nDlidx; i++){
212776 Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];
212781 FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),
212796 Fts5SegWriter *pWriter,
212799 if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
212801 pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl
212806 size_t nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);
212807 memset(&aDlidx[pWriter->nDlidx], 0, nByte);
212808 pWriter->aDlidx = aDlidx;
212809 pWriter->nDlidx = nLvl;
212820 static int fts5WriteFlushDlidx(Fts5Index *p, Fts5SegWriter *pWriter){
212825 if( pWriter->aDlidx[0].buf.n>0 && pWriter->nEmpty>=FTS5_MIN_DLIDX_SIZE ){
212828 fts5WriteDlidxClear(p, pWriter, bFlag);
212829 pWriter->nEmpty = 0;
212844 static void fts5WriteFlushBtree(Fts5Index *p, Fts5SegWriter *pWriter){
212847 assert( pWriter->iBtPage || pWriter->nEmpty==0 );
212848 if( pWriter->iBtPage==0 ) return;
212849 bFlag = fts5WriteFlushDlidx(p, pWriter);
212852 const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:"");
212855 sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);
212856 sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));
212861 pWriter->iBtPage = 0;
212875 Fts5SegWriter *pWriter, /* Writer object */
212878 fts5WriteFlushBtree(p, pWriter);
212880 fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
212881 pWriter->iBtPage = pWriter->writer.pgno;
212891 Fts5SegWriter *pWriter /* Writer object */
212895 if( pWriter->bFirstRowidInPage && pWriter->aDlidx[0].buf.n>0 ){
212896 Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[0];
212902 pWriter->nEmpty++;
212921 Fts5SegWriter *pWriter,
212929 Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];
212939 FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),
212942 fts5WriteDlidxGrow(p, pWriter, i+2);
212943 pDlidx = &pWriter->aDlidx[i];
212966 i64 iPgno = (i==0 ? pWriter->writer.pgno : pDlidx[-1].pgno);
212979 static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){
212981 Fts5PageWriter *pPage = &pWriter->writer;
212984 assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );
212990 if( pWriter->bFirstTermInPage ){
212993 fts5WriteBtreeNoTerm(p, pWriter);
213000 iRowid = FTS5_SEGMENT_ROWID(pWriter->iSegid, pPage->pgno);
213011 pWriter->nLeafWritten++;
213014 pWriter->bFirstTermInPage = 1;
213015 pWriter->bFirstRowidInPage = 1;
213027 Fts5SegWriter *pWriter,
213031 Fts5PageWriter *pPage = &pWriter->writer;
213032 Fts5Buffer *pPgidx = &pWriter->writer.pgidx;
213037 assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );
213042 fts5WriteFlushLeaf(p, pWriter);
213058 if( pWriter->bFirstTermInPage ){
213078 fts5WriteBtreeTerm(p, pWriter, n, pTerm);
213080 pPage = &pWriter->writer;
213094 pWriter->bFirstTermInPage = 0;
213096 pWriter->bFirstRowidInPage = 0;
213097 pWriter->bFirstRowidInDoclist = 1;
213099 assert( p->rc || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n==0) );
213100 pWriter->aDlidx[0].pgno = pPage->pgno;
213108 Fts5SegWriter *pWriter,
213112 Fts5PageWriter *pPage = &pWriter->writer;
213115 fts5WriteFlushLeaf(p, pWriter);
213121 if( pWriter->bFirstRowidInPage ){
213123 fts5WriteDlidxAppend(p, pWriter, iRowid);
213127 if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
213130 assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
213131 fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
213133 pWriter->iPrevRowid = iRowid;
213134 pWriter->bFirstRowidInDoclist = 0;
213135 pWriter->bFirstRowidInPage = 0;
213141 Fts5SegWriter *pWriter,
213145 Fts5PageWriter *pPage = &pWriter->writer;
213162 fts5WriteFlushLeaf(p, pWriter);
213175 Fts5SegWriter *pWriter, /* Writer object */
213179 Fts5PageWriter *pLeaf = &pWriter->writer;
213183 fts5WriteFlushLeaf(p, pWriter);
213187 fts5WriteFlushBtree(p, pWriter);
213193 fts5BufferFree(&pWriter->btterm);
213195 for(i=0; i<pWriter->nDlidx; i++){
213196 sqlite3Fts5BufferFree(&pWriter->aDlidx[i].buf);
213198 sqlite3_free(pWriter->aDlidx);
213203 Fts5SegWriter *pWriter,
213208 memset(pWriter, 0, sizeof(Fts5SegWriter));
213209 pWriter->iSegid = iSegid;
213211 fts5WriteDlidxGrow(p, pWriter, 1);
213212 pWriter->writer.pgno = 1;
213213 pWriter->bFirstTermInPage = 1;
213214 pWriter->iBtPage = 1;
213216 assert( pWriter->writer.buf.n==0 );
213217 assert( pWriter->writer.pgidx.n==0 );
213220 sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer);
213221 sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer);
213233 memset(pWriter->writer.buf.p, 0, 4);
213234 pWriter->writer.buf.n = 4;
213239 sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid);
213319 Fts5SegWriter *pWriter = (Fts5SegWriter*)pCtx;
213320 fts5WriteAppendPoslistData(p, pWriter, pChunk, nChunk);
214391 sqlite3_finalize(p->pWriter);