dataBufferInit(&pWriter->b, 0);
plwReset(pWriter, iDocid, iType);
}
-static PLWriter *plwNew(sqlite_int64 iDocid, DocListType iType){
- PLWriter *pWriter = malloc(sizeof(PLWriter));
- plwInit(pWriter, iDocid, iType);
- return pWriter;
-}
static void plwDestroy(PLWriter *pWriter){
dataBufferDestroy(&pWriter->b);
SCRAMBLE(pWriter);
}
-static void plwDelete(PLWriter *pWriter){
- plwDestroy(pWriter);
- free(pWriter);
+
+/*******************************************************************/
+/* DLCollector wraps PLWriter and DLWriter to provide a
+** dynamically-allocated doclist area to use during tokenization.
+**
+** dlcNew - malloc up and initialize a collector.
+** dlcDelete - destroy a collector and all contained items.
+** dlcAddPos - append position and offset information.
+** dlcAddDoclist - add the collected doclist to the given buffer.
+*/
+typedef struct DLCollector {
+ PLWriter plw;
+} DLCollector;
+
+static void dlcAddDoclist(DLCollector *pCollector, DataBuffer *b){
+ DLWriter dlw;
+ dlwInit(&dlw, pCollector->plw.iType, b);
+ plwDlwAdd(&pCollector->plw, &dlw);
+ dlwDestroy(&dlw);
+}
+static void dlcAddPos(DLCollector *pCollector, int iColumn, int iPos,
+ int iStartOffset, int iEndOffset){
+ plwAdd(&pCollector->plw, iColumn, iPos, iStartOffset, iEndOffset);
+}
+
+static DLCollector *dlcNew(sqlite_int64 iDocid, DocListType iType){
+ DLCollector *pCollector = malloc(sizeof(DLCollector));
+ plwInit(&pCollector->plw, iDocid, iType);
+ return pCollector;
+}
+static void dlcDelete(DLCollector *pCollector){
+ plwDestroy(&pCollector->plw);
+ SCRAMBLE(pCollector);
+ free(pCollector);
}
&pToken, &nTokenBytes,
&iStartOffset, &iEndOffset,
&iPosition) ){
- PLWriter *p;
+ DLCollector *p;
/* Positions can't be negative; we use -1 as a terminator internally. */
if( iPosition<0 ){
p = fts2HashFind(terms, pToken, nTokenBytes);
if( p==NULL ){
- p = plwNew(iDocid, DL_DEFAULT);
+ p = dlcNew(iDocid, DL_DEFAULT);
fts2HashInsert(terms, pToken, nTokenBytes, p);
}
if( iColumn>=0 ){
- plwAdd(p, iColumn, iPosition, iStartOffset, iEndOffset);
+ dlcAddPos(p, iColumn, iPosition, iStartOffset, iEndOffset);
}
}
typedef struct TermData {
const char *pTerm;
int nTerm;
- PLWriter *pWriter;
+ DLCollector *pCollector;
} TermData;
/* Orders TermData elements in strcmp fashion ( <0 for less-than, 0
assert( i<n );
pData[i].pTerm = fts2HashKey(e);
pData[i].nTerm = fts2HashKeysize(e);
- pData[i].pWriter = fts2HashData(e);
+ pData[i].pCollector = fts2HashData(e);
}
assert( i==n );
leafWriterInit(0, idx, &writer);
dataBufferInit(&dl, 0);
for(i=0; i<n; i++){
- DLWriter dlw;
dataBufferReset(&dl);
- dlwInit(&dlw, DL_DEFAULT, &dl);
- plwDlwAdd(pData[i].pWriter, &dlw);
+ dlcAddDoclist(pData[i].pCollector, &dl);
rc = leafWriterStep(v, &writer,
pData[i].pTerm, pData[i].nTerm, dl.pData, dl.nData);
- dlwDestroy(&dlw);
if( rc!=SQLITE_OK ) goto err;
}
- dataBufferDestroy(&dl);
rc = leafWriterFinalize(v, &writer);
err:
+ dataBufferDestroy(&dl);
free(pData);
leafWriterDestroy(&writer);
return rc;
/* clean up */
for(e=fts2HashFirst(&terms); e; e=fts2HashNext(e)){
- plwDelete(fts2HashData(e));
+ dlcDelete(fts2HashData(e));
}
fts2HashClear(&terms);
-C Modify\sthe\sinterface\sto\sthe\spager\ssub-system\sin\spreparation\sfor\sperforming\sIO\sin\sblocks\sbased\son\ssector-size,\snot\sdatabase\spage-size.\s(CVS\s3705)
-D 2007-03-19T17:44:27
+C Refactor\sPLWriter\sin\spreparation\sfor\sbuffered-document\schange.\nCurrently,\sPLWriter\s(Position\sList\sWriter)\screates\sa\slocally-owned\nDataBuffer\sto\swrite\sinto.\s\sThis\sis\snecessary\sto\ssupport\sdoclist\ncollection\sduring\stokenization,\swhere\sthere\sis\sno\sobvious\sbuffer\sto\nwrite\soutput\sto,\sbut\sis\snot\snecessary\sfor\sthe\sother\susers\sof\sPLWriter.\n\sThis\schange\sadds\sa\sDLCollector\s(Doc\sList\sCollector)\sstructure\sto\nhandle\sthe\stokenization\scase.\n\nAlso\sfix\sa\spotential\smemory\sleak\sin\swriteZeroSegment().\s\sIn\scase\sof\nerror\sfrom\sleafWriterStep(),\sthe\sDataBuffer\sdl\swas\sbeing\sleaked.\s(CVS\s3706)
+D 2007-03-20T23:52:38
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F ext/fts1/simple_tokenizer.c 1844d72f7194c3fd3d7e4173053911bf0661b70d
F ext/fts1/tokenizer.h 0c53421b832366d20d720d21ea3e1f6e66a36ef9
F ext/fts2/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts2/fts2.c a49ed7292cbacbfcde6fdee1be4f6529277be3fa
+F ext/fts2/fts2.c aba63e7f4892a2e7cf50054181cda3d246c3ba0a
F ext/fts2/fts2.h bbdab26d34f91974d5b9ade8b7836c140a7c4ce1
F ext/fts2/fts2_hash.c b3f22116d4ef0bc8f2da6e3fdc435c86d0951a9b
F ext/fts2/fts2_hash.h e283308156018329f042816eb09334df714e105e
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P c3c5f658cf9c69b6e81e63fbde5dd0a854be9fc7
-R 8bc9543d27c6957ab236f6b14f2fea11
-U danielk1977
-Z 733a417800b51f433ae2631c0b87c550
+P 7dc7658887046f066b564a5994578074a99756ba
+R 28415623e14534daa33e7418f28a0adb
+U shess
+Z d8903aa3843e1c017cd54e70c455deff