* mdocml: Try again to get the transfer from hash to btree working.
@ 2011-06-22 9:00 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-06-22 9:00 UTC (permalink / raw)
To: source
Log Message:
-----------
Try again to get the transfer from hash to btree working. This time
just closing and re-opening the database, as deleting records with
(*hash->del) either in the scan loop or after it causes uncertain
behaviour (left-over keys, mystery keys, etc.). This finally does the
Right Thing (tm).
Modified Files:
--------------
mdocml:
makewhatis.c
Revision Data
-------------
Index: makewhatis.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/makewhatis.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lmakewhatis.c -Lmakewhatis.c -u -p -r1.7 -r1.8
--- makewhatis.c
+++ makewhatis.c
@@ -306,23 +306,14 @@ main(int argc, char *argv[])
* For the keyword database, open a BTREE database that allows
* duplicates.
* For the index database, use a standard RECNO database type.
- * For the temporary keyword hashtable, use the HASH database
- * type.
*/
- hash = dbopen(NULL, MANDOC_FLAGS, 0644, DB_HASH, NULL);
- if (NULL == hash) {
- perror("hash");
- exit((int)MANDOCLEVEL_SYSERR);
- }
-
memset(&info, 0, sizeof(BTREEINFO));
info.flags = R_DUP;
db = dbopen(fbbuf, MANDOC_FLAGS, 0644, DB_BTREE, &info);
if (NULL == db) {
perror(fbbuf);
- (*hash->close)(hash);
exit((int)MANDOCLEVEL_SYSERR);
}
@@ -331,7 +322,6 @@ main(int argc, char *argv[])
if (NULL == db) {
perror(ibbuf);
(*db->close)(db);
- (*hash->close)(hash);
exit((int)MANDOCLEVEL_SYSERR);
}
@@ -358,6 +348,16 @@ main(int argc, char *argv[])
while (NULL != (fn = *argv++)) {
mparse_reset(mp);
+ if (hash)
+ (*hash->close)(hash);
+
+ hash = dbopen(NULL, MANDOC_FLAGS, 0644, DB_HASH, NULL);
+
+ if (NULL == hash) {
+ perror("hash");
+ exit((int)MANDOCLEVEL_SYSERR);
+ }
+
/* Parse and get (non-empty) AST. */
if (mparse_readfd(mp, -1, fn) >= MANDOCLEVEL_FATAL) {
@@ -422,11 +422,12 @@ main(int argc, char *argv[])
val.size = sizeof(vbuf);
val.data = vbuf;
+ printf("Added: %s (%zu): 0x%x\n",
+ (char *)key.data, key.size,
+ *(int *)val.data);
+
dbt_put(db, fbbuf, &key, &val);
- ch = (*hash->del)(hash, &key, R_CURSOR);
- if (ch < 0)
- break;
}
if (ch < 0) {
@@ -448,13 +449,16 @@ main(int argc, char *argv[])
val.data = dbuf.cp;
val.size = dbuf.len;
+ printf("Indexed: %s\n", fn);
+
dbt_put(idx, ibbuf, &key, &val);
rec++;
}
(*db->close)(db);
(*idx->close)(idx);
- (*hash->close)(hash);
+ if (hash)
+ (*hash->close)(hash);
mparse_free(mp);
@@ -771,9 +775,6 @@ hash_put(DB *db, const struct buf *buf,
static void
dbt_put(DB *db, const char *dbn, DBT *key, DBT *val)
{
-
- if (0 == key->size)
- return;
assert(key->size);
assert(val->size);
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-22 9:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-22 9:00 mdocml: Try again to get the transfer from hash to btree working kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).