commit 588bb1debffd21b4100eb39304344f07d51c05d6
parent 8ca6e86b75adb546709fc776d36eeabd43eff1c5
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Mon, 26 Aug 2024 22:03:07 +0000
src/wdb: purge update, never used
Diffstat:
D | src/wdb/update.c | | | 99 | ------------------------------------------------------------------------------- |
1 file changed, 0 insertions(+), 99 deletions(-)
diff --git a/src/wdb/update.c b/src/wdb/update.c
@@ -1,99 +0,0 @@
-#include <u.h>
-#include <libc.h>
-#include <../util/util.h>
-#include <../tablist/tablist.h>
-enum {
- BSize = 1024 * 8,
- HSize = BSize / 2,
-};
-
-int db, bn;
-char *path, buf[BSize];
-TLdecoder *tldec;
-TLencoder *tlenc;
-Slice *query, *nodes;
-
-TLnode **
-find(TLnode *n)
-{
- TLnode **v, *m;
- int i;
- if (n->name == nil) return nil;
- for (i = 0; i < nodes->len; i++) {
- v = slicegetp(nodes, i);
- m = *v;
- if (m->name == nil) continue;
- if (memcmp(m->name->p, n->name->p, m->name->len) == 0)
- return v;
- }
- return nil;
-}
-
-void
-update(TLnode *n)
-{
- TLnode **v;
- v = find(n);
- if (v != nil) {
- *v = n;
- } else {
- nodes = sliceappendp(nodes, 1, &n);
- }
-}
-
-void
-usage(void)
-{
- fprint(2, "usage %s db_file < node\n", argv0);
- exits("usage");
-}
-
-void
-main(int argc, char *argv[])
-{
-
- fprint(2, "hello\n");
-
- int i;
-
- ARGBEGIN {
- default:
- usage();
- } ARGEND
-
- if (argc != 1) usage();
- path = argv[0];
- db = open(path, OREAD);
- if (db < 0) sysfatal("can't open db: %r");
-
- fprint(2, "reading query\n");
- tldec = initTLdecoder(nil);
- while((bn = read(0, buf, BSize)) > 0) {
- TLdecode(tldec, buf, bn);
- }
- if (bn < 0) sysfatal("%r");
- query = tldec->nodes;
- fprint(2, "qlen %d\n", query->len);
-
- tldec = initTLdecoder(path);
- while((bn = read(db, buf, BSize)) > 0) {
- TLdecode(tldec, buf, bn);
- }
- if (bn < 0) sysfatal("%r");
- nodes = tldec->nodes;
- close(db);
-
- for (i = 0; i < query->len; i++) {
- TLnode **v;
- v = slicegetp(query, i);
- update(*v);
- }
-
- db = open(path, OWRITE | OTRUNC);
- if (db < 0) sysfatal("%r");
- tlenc = initTLencoder(nodes);
- while((bn = TLencode(tlenc, buf, BSize)) > 0) {
- bn = write(db, buf, bn);
- if (bn < 0) sysfatal("%r");
- }
-}