Skip to content

Commit

Permalink
update brass dbcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangShangtong authored and ZhangShangtong committed Jul 30, 2014
1 parent fdd49dd commit 0ac583c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 32 deletions.
82 changes: 53 additions & 29 deletions xapian-core/backends/brass/brass_dbcheck.cc
Expand Up @@ -617,37 +617,61 @@ check_brass_table(const char * tablename, string filename,
}
lastdid += did;
bool bad = false;

// Read the data of skip-list format
while (true) {
Xapian::termcount wdf;
if (!unpack_uint(&pos, end, &wdf)) {
if (out)
*out << "Failed to unpack wdf" << endl;
++errors;
bad = true;
break;
}
++tf;
cf += wdf;

if (pos == end) break;

Xapian::docid inc;
if (!unpack_uint(&pos, end, &inc)) {
if (out)
*out << "Failed to unpack docid increase" << endl;
++errors;
bad = true;
break;
}
++inc;
did += inc;
if (did > lastdid) {
if (out)
*out << "docid " << did << " > last docid " << lastdid
<< endl;
++errors;
}
Xapian::docid inc = 0;
if (!unpack_uint(&pos, end, &inc)) {
if (out)
*out << "Failed to unpack docid increase" << endl;
++errors;
bad = true;
break;
}
while (inc == (unsigned)-1) {
if (!unpack_uint(&pos, end, &inc)) {
if (out)
*out << "Failed to unpack skip info" << endl;
++errors;
bad = true;
break;
}
if (!unpack_uint(&pos, end, &inc)) {
if (out)
*out << "Failed to unpack skip info" << endl;
++errors;
bad = true;
break;
}
if (!unpack_uint(&pos, end, &inc)) {
if (out)
*out << "Failed to unpack docid increase" << endl;
++errors;
bad = true;
break;
}
}
did += inc;
if (did > lastdid) {
if (out)
*out << "docid " << did << " > last docid " << lastdid
<< endl;
++errors;
}
Xapian::termcount wdf;
if (!unpack_uint(&pos, end, &wdf)) {
if (out)
*out << "Failed to unpack wdf" << endl;
++errors;
bad = true;
break;
}
++tf;
cf += wdf;

if (pos == end) break;
}

if (bad) {
continue;
}
Expand Down
17 changes: 14 additions & 3 deletions xapian-core/backends/brass/brass_postlist.cc
Expand Up @@ -1342,9 +1342,20 @@ SkipListWriter::merge_postlist_changes(const string& term)
* document ID of the first document in the chunk (encoded as length of
* representation in first byte, and then docid).
*
* there are two kinds of postlist,
* one is for document length, another is normal postlist storing wdf.
* doc length postlist adopts fixed-width format while normal postlist adopts skip-list format.
* There are two kinds of postlist:
* One is for storing document length, its termname is always a null string "",
* another is normal postlist storing wdf, it has normal termname.
* Document length postlist adopts fixed-width format while normal postlist adopts skip-list format.
*
* A chunk (except for the first chunk) contains:
*
* 1) bool - true if this is the last chunk.
* 2) difference between final docid in chunk and first docid.
* 3) data of fixed-width format or skip-list format
*
* The first chunk begins with the number of entries, the collection
* frequency, then the docid of the first document, then has the header of a
* standard chunk.
*/
BrassPostList::BrassPostList(intrusive_ptr<const BrassDatabase> this_db_,
const string & term_,
Expand Down

0 comments on commit 0ac583c

Please sign in to comment.