SQLite

Check-in [2cf4158ff0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add support for rowid.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | word-fuzzer
Files: files | file ages | folders
SHA1: 2cf4158ff051916717fc2c0f4b6332d5f6ea6e3d
User & Date: drh 2011-03-29 23:41:31.447
Context
2011-03-30
01:43
Move to an O(NlogN) algorithm for the priority queue. An insertion sort was way too slow. (check-in: 7958cbba73 user: drh tags: word-fuzzer)
2011-03-29
23:41
Add support for rowid. (check-in: 2cf4158ff0 user: drh tags: word-fuzzer)
18:21
The first simple test-case appears to be working now. (check-in: dd41155bc7 user: drh tags: word-fuzzer)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test_fuzzer.c.
82
83
84
85
86
87
88

89
90
91
92
93
94
95
};

#define FUZZER_HASH  4001    /* Hash table size */

/* A fuzzer cursor object */
struct fuzzer_cursor {
  sqlite3_vtab_cursor base;  /* Base class - must be first */

  fuzzer_vtab *pVtab;        /* The virtual table this cursor belongs to */
  fuzzer_cost rLimit;        /* Maximum cost of any term */
  fuzzer_stem *pStem;        /* Sorted list of stems for generating new terms */
  fuzzer_stem *pDone;        /* Stems already processed to completion */
  char *zBuf;                /* Temporary use buffer */
  int nBuf;                  /* Bytes allocated for zBuf */
  fuzzer_rule nullRule;      /* Null rule used first */







>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
};

#define FUZZER_HASH  4001    /* Hash table size */

/* A fuzzer cursor object */
struct fuzzer_cursor {
  sqlite3_vtab_cursor base;  /* Base class - must be first */
  sqlite3_int64 iRowid;      /* The rowid of the current word */
  fuzzer_vtab *pVtab;        /* The virtual table this cursor belongs to */
  fuzzer_cost rLimit;        /* Maximum cost of any term */
  fuzzer_stem *pStem;        /* Sorted list of stems for generating new terms */
  fuzzer_stem *pDone;        /* Stems already processed to completion */
  char *zBuf;                /* Temporary use buffer */
  int nBuf;                  /* Bytes allocated for zBuf */
  fuzzer_rule nullRule;      /* Null rule used first */
418
419
420
421
422
423
424


425
426
427
428
429
430
431
/*
** Advance a cursor to its next row of output
*/
static int fuzzerNext(sqlite3_vtab_cursor *cur){
  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;
  int rc;
  fuzzer_stem *pStem, *pNew;



  /* Use the element the cursor is currently point to to create
  ** a new stem and insert the new stem into the priority queue.
  */
  pStem = pCur->pStem;
  if( fuzzerCost(pStem)>0 ){
    rc = fuzzerRender(pStem, &pCur->zBuf, &pCur->nBuf);







>
>







419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
/*
** Advance a cursor to its next row of output
*/
static int fuzzerNext(sqlite3_vtab_cursor *cur){
  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;
  int rc;
  fuzzer_stem *pStem, *pNew;

  pCur->iRowid++;

  /* Use the element the cursor is currently point to to create
  ** a new stem and insert the new stem into the priority queue.
  */
  pStem = pCur->pStem;
  if( fuzzerCost(pStem)>0 ){
    rc = fuzzerRender(pStem, &pCur->zBuf, &pCur->nBuf);
506
507
508
509
510
511
512

513
514
515
516
517
518
519
  pCur->nullRule.pNext = pCur->pVtab->pRule;
  pCur->nullRule.rCost = 0;
  pCur->nullRule.nFrom = 0;
  pCur->nullRule.nTo = 0;
  pCur->nullRule.zFrom = "";
  pStem->pRule = &pCur->nullRule;
  pStem->n = pStem->nBasis;

  return SQLITE_OK;
}

/*
** Only the word and distance columns have values.  All other columns
** return NULL
*/







>







509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
  pCur->nullRule.pNext = pCur->pVtab->pRule;
  pCur->nullRule.rCost = 0;
  pCur->nullRule.nFrom = 0;
  pCur->nullRule.nTo = 0;
  pCur->nullRule.zFrom = "";
  pStem->pRule = &pCur->nullRule;
  pStem->n = pStem->nBasis;
  pCur->iRowid = 1;
  return SQLITE_OK;
}

/*
** Only the word and distance columns have values.  All other columns
** return NULL
*/
532
533
534
535
536
537
538
539
540
541

542
543
544
545
546
547
548
549
    /* All other columns are NULL */
    sqlite3_result_null(ctx);
  }
  return SQLITE_OK;
}

/*
** The rowid is always 0
*/
static int fuzzerRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){

  *pRowid = 0;  /* The rowid is always 0 */
  return SQLITE_OK;
}

/*
** When the fuzzer_cursor.rLimit value is 0 or less, that is a signal
** that the cursor has nothing more to output.
*/







|


>
|







536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
    /* All other columns are NULL */
    sqlite3_result_null(ctx);
  }
  return SQLITE_OK;
}

/*
** The rowid.
*/
static int fuzzerRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;
  *pRowid = pCur->iRowid;
  return SQLITE_OK;
}

/*
** When the fuzzer_cursor.rLimit value is 0 or less, that is a signal
** that the cursor has nothing more to output.
*/
tool/mkopts.tcl became executable.