OLD | NEW |
1 /* | 1 /* |
2 ** This program is a debugging and analysis utility that displays | 2 ** This program is a debugging and analysis utility that displays |
3 ** information about an FTS3 or FTS4 index. | 3 ** information about an FTS3 or FTS4 index. |
4 ** | 4 ** |
5 ** Link this program against the SQLite3 amalgamation with the | 5 ** Link this program against the SQLite3 amalgamation with the |
6 ** SQLITE_ENABLE_FTS4 compile-time option. Then run it as: | 6 ** SQLITE_ENABLE_FTS4 compile-time option. Then run it as: |
7 ** | 7 ** |
8 ** fts3view DATABASE | 8 ** fts3view DATABASE |
9 ** | 9 ** |
10 ** to get a list of all FTS3/4 tables in DATABASE, or do | 10 ** to get a list of all FTS3/4 tables in DATABASE, or do |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 " count(distinct idx)" | 391 " count(distinct idx)" |
392 " FROM (SELECT length(a.block) AS len, idx" | 392 " FROM (SELECT length(a.block) AS len, idx" |
393 " FROM '%q_segments' a JOIN '%q_segdir' b" | 393 " FROM '%q_segments' a JOIN '%q_segdir' b" |
394 " WHERE (a.blockid BETWEEN b.start_block" | 394 " WHERE (a.blockid BETWEEN b.start_block" |
395 " AND b.leaves_end_block)" | 395 " AND b.leaves_end_block)" |
396 " AND (b.level%%1024)==%d)", | 396 " AND (b.level%%1024)==%d)", |
397 pgsz-45, zTab, zTab, i); | 397 pgsz-45, zTab, zTab, i); |
398 if( sqlite3_step(pStmt)==SQLITE_ROW | 398 if( sqlite3_step(pStmt)==SQLITE_ROW |
399 && (nLeaf = sqlite3_column_int(pStmt, 0))>0 | 399 && (nLeaf = sqlite3_column_int(pStmt, 0))>0 |
400 ){ | 400 ){ |
401 int nIdx = sqlite3_column_int(pStmt, 5); | 401 nIdx = sqlite3_column_int(pStmt, 5); |
402 sqlite3_int64 sz; | 402 sqlite3_int64 sz; |
403 printf("For level %d:\n", i); | 403 printf("For level %d:\n", i); |
404 printf(" Number of indexes...................... %9d\n", nIdx); | 404 printf(" Number of indexes...................... %9d\n", nIdx); |
405 printf(" Number of leaf segments................ %9d\n", nLeaf); | 405 printf(" Number of leaf segments................ %9d\n", nLeaf); |
406 if( nIdx>1 ){ | 406 if( nIdx>1 ){ |
407 printf(" Average leaf segments per index........ %11.1f\n", | 407 printf(" Average leaf segments per index........ %11.1f\n", |
408 (double)nLeaf/(double)nIdx); | 408 (double)nLeaf/(double)nIdx); |
409 } | 409 } |
410 printf(" Total size of all leaf segments........ %9lld\n", | 410 printf(" Total size of all leaf segments........ %9lld\n", |
411 (sz = sqlite3_column_int64(pStmt, 1))); | 411 (sz = sqlite3_column_int64(pStmt, 1))); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 if( iLevel!=prevLevel ){ | 497 if( iLevel!=prevLevel ){ |
498 printf("level %2d idx %2d", iLevel, iIdx); | 498 printf("level %2d idx %2d", iLevel, iIdx); |
499 prevLevel = iLevel; | 499 prevLevel = iLevel; |
500 }else{ | 500 }else{ |
501 printf(" idx %2d", iIdx); | 501 printf(" idx %2d", iIdx); |
502 } | 502 } |
503 sqlite3_snprintf(sizeof(rtag), rtag, "r%lld", | 503 sqlite3_snprintf(sizeof(rtag), rtag, "r%lld", |
504 sqlite3_column_int64(pStmt,5)); | 504 sqlite3_column_int64(pStmt,5)); |
505 printf(" root %9s\n", rtag); | 505 printf(" root %9s\n", rtag); |
506 if( iLEnd>iStart ){ | 506 if( iLEnd>iStart ){ |
507 sqlite3_int64 iLower, iPrev, iX; | 507 sqlite3_int64 iLower, iPrev = 0, iX; |
508 if( iLEnd+1<=iEnd ){ | 508 if( iLEnd+1<=iEnd ){ |
509 sqlite3_bind_int64(pStmt2, 1, iLEnd+1); | 509 sqlite3_bind_int64(pStmt2, 1, iLEnd+1); |
510 sqlite3_bind_int64(pStmt2, 2, iEnd); | 510 sqlite3_bind_int64(pStmt2, 2, iEnd); |
511 iLower = -1; | 511 iLower = -1; |
512 while( sqlite3_step(pStmt2)==SQLITE_ROW ){ | 512 while( sqlite3_step(pStmt2)==SQLITE_ROW ){ |
513 iX = sqlite3_column_int64(pStmt2, 0); | 513 iX = sqlite3_column_int64(pStmt2, 0); |
514 if( iLower<0 ){ | 514 if( iLower<0 ){ |
515 iLower = iPrev = iX; | 515 iLower = iPrev = iX; |
516 }else if( iX==iPrev+1 ){ | 516 }else if( iX==iPrev+1 ){ |
517 iPrev = iX; | 517 iPrev = iX; |
(...skipping 23 matching lines...) Expand all Loading... |
541 sqlite3_finalize(pStmt2); | 541 sqlite3_finalize(pStmt2); |
542 } | 542 } |
543 | 543 |
544 /* | 544 /* |
545 ** Decode a single segment block and display the results on stdout. | 545 ** Decode a single segment block and display the results on stdout. |
546 */ | 546 */ |
547 static void decodeSegment( | 547 static void decodeSegment( |
548 const unsigned char *aData, /* Content to print */ | 548 const unsigned char *aData, /* Content to print */ |
549 int nData /* Number of bytes of content */ | 549 int nData /* Number of bytes of content */ |
550 ){ | 550 ){ |
551 sqlite3_int64 iChild; | 551 sqlite3_int64 iChild = 0; |
552 sqlite3_int64 iPrefix; | 552 sqlite3_int64 iPrefix; |
553 sqlite3_int64 nTerm; | 553 sqlite3_int64 nTerm; |
554 sqlite3_int64 n; | 554 sqlite3_int64 n; |
555 sqlite3_int64 iDocsz; | 555 sqlite3_int64 iDocsz; |
556 int iHeight; | 556 int iHeight; |
557 sqlite3_int64 i = 0; | 557 sqlite3_int64 i = 0; |
558 int cnt = 0; | 558 int cnt = 0; |
559 char zTerm[1000]; | 559 char zTerm[1000]; |
560 | 560 |
561 i += getVarint(aData, &n); | 561 i += getVarint(aData, &n); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 showSegmentStats(db, zTab); | 866 showSegmentStats(db, zTab); |
867 }else if( strcmp(zCmd,"stat")==0 ){ | 867 }else if( strcmp(zCmd,"stat")==0 ){ |
868 showStat(db, zTab); | 868 showStat(db, zTab); |
869 }else if( strcmp(zCmd,"vocabulary")==0 ){ | 869 }else if( strcmp(zCmd,"vocabulary")==0 ){ |
870 showVocabulary(db, zTab); | 870 showVocabulary(db, zTab); |
871 }else{ | 871 }else{ |
872 usage(argv[0]); | 872 usage(argv[0]); |
873 } | 873 } |
874 return 0; | 874 return 0; |
875 } | 875 } |
OLD | NEW |