Lines Matching refs:pWriter
62646 Btree *pWriter; /* Btree with currently open write transaction */
63501 assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
63512 if( pBt->pWriter!=p && (pBt->btsFlags & BTS_EXCLUSIVE)!=0 ){
63513 sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);
63532 assert( p==pBt->pWriter );
63634 assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );
63647 assert( (pBt->btsFlags & BTS_PENDING)==0 || pBt->pWriter );
63648 if( pBt->pWriter==p ){
63649 pBt->pWriter = 0;
63670 if( pBt->pWriter==p ){
63672 pBt->pWriter = 0;
66615 pBlock = pBt->pWriter->db;
66693 assert( !pBt->pWriter );
66694 pBt->pWriter = p;
172790 SegmentWriter *pWriter = *ppWriter;
172792 if( !pWriter ){
172797 pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));
172798 if( !pWriter ) return SQLITE_NOMEM;
172799 memset(pWriter, 0, sizeof(SegmentWriter));
172800 *ppWriter = pWriter;
172803 pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);
172804 if( !pWriter->aData ) return SQLITE_NOMEM;
172805 pWriter->nSize = p->nNodeSize;
172811 pWriter->iFree = sqlite3_column_int64(pStmt, 0);
172812 pWriter->iFirst = pWriter->iFree;
172817 nData = pWriter->nData;
172819 nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);
172838 if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB;
172839 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
172856 rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);
172860 pWriter->nTerm = 0;
172872 pWriter->nLeafData += nReq;
172877 if( nReq>pWriter->nSize ){
172878 char *aNew = sqlite3_realloc(pWriter->aData, nReq);
172880 pWriter->aData = aNew;
172881 pWriter->nSize = nReq;
172883 assert( nData+nReq<=pWriter->nSize );
172886 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);
172887 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);
172889 memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);
172891 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);
172893 memcpy(&pWriter->aData[nData], aDoclist, nDoclist);
172894 pWriter->nData = nData + nDoclist;
172902 if( nTerm>pWriter->nMalloc ){
172903 char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);
172907 pWriter->nMalloc = nTerm*2;
172908 pWriter->zMalloc = zNew;
172909 pWriter->zTerm = zNew;
172911 assert( pWriter->zTerm==pWriter->zMalloc );
172913 memcpy(pWriter->zTerm, zTerm, nTerm);
172915 pWriter->zTerm = (char *)zTerm;
172917 pWriter->nTerm = nTerm;
172930 SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
172935 if( pWriter->pTree ){
172941 iLastLeaf = pWriter->iFree;
172942 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);
172944 rc = fts3NodeWrite(p, pWriter->pTree, 1,
172945 pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);
172949 pWriter->iFirst, iLastLeaf, iLast, pWriter->nLeafData, zRoot, nRoot);
172954 0, 0, 0, pWriter->nLeafData, pWriter->aData, pWriter->nData);
172964 static void fts3SegWriterFree(SegmentWriter *pWriter){
172965 if( pWriter ){
172966 sqlite3_free(pWriter->aData);
172967 sqlite3_free(pWriter->zMalloc);
172968 fts3NodeFree(pWriter->pTree);
172969 sqlite3_free(pWriter);
173759 SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
173818 rc = fts3SegWriterAdd(p, &pWriter, 1,
173822 assert_fts3_nc( pWriter || bIgnoreEmpty );
173830 if( pWriter ){
173831 rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);
173834 rc = fts3PromoteSegments(p, iNewLevel, pWriter->nLeafData);
173840 fts3SegWriterFree(pWriter);
174388 IncrmergeWriter *pWriter, /* Writer object */
174392 sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;
174398 NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
174541 IncrmergeWriter *pWriter, /* Writer object */
174554 pLeaf = &pWriter->aNodeWriter[0];
174567 pWriter->nWork++;
174582 rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
174596 pWriter->nLeafData += nSpace;
174626 IncrmergeWriter *pWriter, /* Merge-writer object */
174639 NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
174666 Blob *pBlock = &pWriter->aNodeWriter[1].block;
174671 &pBlock->a[1], pWriter->aNodeWriter[0].iBlock
174676 pRoot = &pWriter->aNodeWriter[iRoot];
174680 NodeWriter *pNode = &pWriter->aNodeWriter[i];
174691 pWriter->iAbsLevel+1, /* level */
174692 pWriter->iIdx, /* idx */
174693 pWriter->iStart, /* start_block */
174694 pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */
174695 pWriter->iEnd, /* end_block */
174696 (pWriter->bNoLeafData==0 ? pWriter->nLeafData : 0), /* end_block */
174777 IncrmergeWriter *pWriter /* Populate this object */
174798 fts3ReadEndBlockField(pSelect, 3, &iEnd, &pWriter->nLeafData);
174799 if( pWriter->nLeafData<0 ){
174800 pWriter->nLeafData = pWriter->nLeafData * -1;
174802 pWriter->bNoLeafData = (pWriter->nLeafData==0);
174849 pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
174850 pWriter->iStart = iStart;
174851 pWriter->iEnd = iEnd;
174852 pWriter->iAbsLevel = iAbsLevel;
174853 pWriter->iIdx = iIdx;
174856 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
174859 pNode = &pWriter->aNodeWriter[nHeight];
174860 pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
174872 pNode = &pWriter->aNodeWriter[i];
174884 pNode = &pWriter->aNodeWriter[i-1];
174969 IncrmergeWriter *pWriter /* Populate this object */
174993 pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);
174994 pWriter->iEnd = pWriter->iStart - 1;
174995 pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;
175004 rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
175007 pWriter->iAbsLevel = iAbsLevel;
175008 pWriter->nLeafEst = nLeafEst;
175009 pWriter->iIdx = iIdx;
175013 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
175439 IncrmergeWriter *pWriter; /* Writer object */
175446 const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);
175447 pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);
175448 if( !pWriter ) return SQLITE_NOMEM;
175449 pFilter = (Fts3SegFilter *)&pWriter[1];
175516 memset(pWriter, 0, nAlloc);
175548 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
175550 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
175553 if( rc==SQLITE_OK && pWriter->nLeafEst ){
175557 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
175559 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
175565 nRem -= (1 + pWriter->nWork);
175575 pWriter->nLeafData = pWriter->nLeafData * -1;
175577 fts3IncrmergeRelease(p, pWriter, &rc);
175578 if( nSeg==0 && pWriter->bNoLeafData==0 ){
175579 fts3PromoteSegments(p, iAbsLevel+1, pWriter->nLeafData);
175591 sqlite3_free(pWriter);
192126 sqlite3_stmt *pWriter;
192144 pWriter = pIter->pDelete;
192146 pWriter = pIter->pInsert;
192167 p->rc = sqlite3_bind_value(pWriter, i+1, pVal);
192186 p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);
192190 sqlite3_step(pWriter);
192191 p->rc = resetAndCollectError(pWriter, &p->zErrmsg);
204606 Fts5PoslistWriter *pWriter,
204611 sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);
206351 Fts5PoslistWriter *pWriter = &a[i].writer;
206352 if( a[i].pOut->n==0 || iPos!=pWriter->iPrev ){
206353 sqlite3Fts5PoslistWriterAppend(a[i].pOut, pWriter, iPos);
209441 sqlite3_stmt *pWriter; /* "INSERT ... %_data VALUES(?,?)" */
209889 if( p->pWriter==0 ){
209891 fts5IndexPrepareStmt(p, &p->pWriter, sqlite3_mprintf(
209898 sqlite3_bind_int64(p->pWriter, 1, iRowid);
209899 sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);
209900 sqlite3_step(p->pWriter);
209901 p->rc = sqlite3_reset(p->pWriter);
209902 sqlite3_bind_null(p->pWriter, 2);
212798 Fts5SegWriter *pWriter,
212802 assert( bFlush==0 || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n>0) );
212803 for(i=0; i<pWriter->nDlidx; i++){
212804 Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];
212809 FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),
212824 Fts5SegWriter *pWriter,
212827 if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
212829 pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl
212834 size_t nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);
212835 memset(&aDlidx[pWriter->nDlidx], 0, nByte);
212836 pWriter->aDlidx = aDlidx;
212837 pWriter->nDlidx = nLvl;
212848 static int fts5WriteFlushDlidx(Fts5Index *p, Fts5SegWriter *pWriter){
212853 if( pWriter->aDlidx[0].buf.n>0 && pWriter->nEmpty>=FTS5_MIN_DLIDX_SIZE ){
212856 fts5WriteDlidxClear(p, pWriter, bFlag);
212857 pWriter->nEmpty = 0;
212872 static void fts5WriteFlushBtree(Fts5Index *p, Fts5SegWriter *pWriter){
212875 assert( pWriter->iBtPage || pWriter->nEmpty==0 );
212876 if( pWriter->iBtPage==0 ) return;
212877 bFlag = fts5WriteFlushDlidx(p, pWriter);
212880 const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:"");
212883 sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);
212884 sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));
212889 pWriter->iBtPage = 0;
212903 Fts5SegWriter *pWriter, /* Writer object */
212906 fts5WriteFlushBtree(p, pWriter);
212908 fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
212909 pWriter->iBtPage = pWriter->writer.pgno;
212919 Fts5SegWriter *pWriter /* Writer object */
212923 if( pWriter->bFirstRowidInPage && pWriter->aDlidx[0].buf.n>0 ){
212924 Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[0];
212930 pWriter->nEmpty++;
212949 Fts5SegWriter *pWriter,
212957 Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];
212967 FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),
212970 fts5WriteDlidxGrow(p, pWriter, i+2);
212971 pDlidx = &pWriter->aDlidx[i];
212994 i64 iPgno = (i==0 ? pWriter->writer.pgno : pDlidx[-1].pgno);
213007 static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){
213009 Fts5PageWriter *pPage = &pWriter->writer;
213012 assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );
213018 if( pWriter->bFirstTermInPage ){
213021 fts5WriteBtreeNoTerm(p, pWriter);
213028 iRowid = FTS5_SEGMENT_ROWID(pWriter->iSegid, pPage->pgno);
213039 pWriter->nLeafWritten++;
213042 pWriter->bFirstTermInPage = 1;
213043 pWriter->bFirstRowidInPage = 1;
213055 Fts5SegWriter *pWriter,
213059 Fts5PageWriter *pPage = &pWriter->writer;
213060 Fts5Buffer *pPgidx = &pWriter->writer.pgidx;
213065 assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );
213070 fts5WriteFlushLeaf(p, pWriter);
213086 if( pWriter->bFirstTermInPage ){
213106 fts5WriteBtreeTerm(p, pWriter, n, pTerm);
213108 pPage = &pWriter->writer;
213122 pWriter->bFirstTermInPage = 0;
213124 pWriter->bFirstRowidInPage = 0;
213125 pWriter->bFirstRowidInDoclist = 1;
213127 assert( p->rc || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n==0) );
213128 pWriter->aDlidx[0].pgno = pPage->pgno;
213136 Fts5SegWriter *pWriter,
213140 Fts5PageWriter *pPage = &pWriter->writer;
213143 fts5WriteFlushLeaf(p, pWriter);
213149 if( pWriter->bFirstRowidInPage ){
213151 fts5WriteDlidxAppend(p, pWriter, iRowid);
213155 if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
213158 assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
213159 fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
213161 pWriter->iPrevRowid = iRowid;
213162 pWriter->bFirstRowidInDoclist = 0;
213163 pWriter->bFirstRowidInPage = 0;
213169 Fts5SegWriter *pWriter,
213173 Fts5PageWriter *pPage = &pWriter->writer;
213190 fts5WriteFlushLeaf(p, pWriter);
213203 Fts5SegWriter *pWriter, /* Writer object */
213207 Fts5PageWriter *pLeaf = &pWriter->writer;
213211 fts5WriteFlushLeaf(p, pWriter);
213215 fts5WriteFlushBtree(p, pWriter);
213221 fts5BufferFree(&pWriter->btterm);
213223 for(i=0; i<pWriter->nDlidx; i++){
213224 sqlite3Fts5BufferFree(&pWriter->aDlidx[i].buf);
213226 sqlite3_free(pWriter->aDlidx);
213231 Fts5SegWriter *pWriter,
213236 memset(pWriter, 0, sizeof(Fts5SegWriter));
213237 pWriter->iSegid = iSegid;
213239 fts5WriteDlidxGrow(p, pWriter, 1);
213240 pWriter->writer.pgno = 1;
213241 pWriter->bFirstTermInPage = 1;
213242 pWriter->iBtPage = 1;
213244 assert( pWriter->writer.buf.n==0 );
213245 assert( pWriter->writer.pgidx.n==0 );
213248 sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer);
213249 sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer);
213261 memset(pWriter->writer.buf.p, 0, 4);
213262 pWriter->writer.buf.n = 4;
213267 sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid);
213347 Fts5SegWriter *pWriter = (Fts5SegWriter*)pCtx;
213348 fts5WriteAppendPoslistData(p, pWriter, pChunk, nChunk);
214419 sqlite3_finalize(p->pWriter);