mox/vendor/github.com/mjl-/bstore
Mechiel Lukkien bf04fb8a1a
improve training of junk filter
before, we used heuristics to decide when to train/untrain a message as junk or
nonjunk: the message had to be seen, be in certain mailboxes. then if a message
was marked as junk, it was junk. and otherwise it was nonjunk. this wasn't good
enough: you may want to keep some messages around as neither junk or nonjunk.
and that wasn't possible.

ideally, we would just look at the imap $Junk and $NotJunk flags. the problem
is that mail clients don't set these flags, or don't make it easy. thunderbird
can set the flags based on its own bayesian filter. it has a shortcut for
marking Junk and moving it to the junk folder (good), but the counterpart of
notjunk only marks a message as notjunk without showing in the UI that it was
marked as notjunk. there is also no "move and mark as notjunk" mechanism. e.g.
"archive" does not mark a message as notjunk. ios mail and mutt don't appear to
have any way to see or change the $Junk and $NotJunk flags.

what email clients do have is the ability to move messages to other
mailboxes/folders. so mox now has a mechanism that allows you to configure
mailboxes that automatically set $Junk or $NotJunk (or clear both) when a
message is moved/copied/delivered to that folder. e.g. a mailbox called junk or
spam or rejects marks its messags as junk. inbox, postmaster, dmarc, tlsrpt,
neutral* mark their messages as neither junk or notjunk. other folders mark
their messages as notjunk. e.g. list/*, archive. this functionality is
optional, but enabled with the quickstart and for new accounts.

also, mox now keeps track of the previous training of a message and will only
untrain/train if needed. before, there probably have been duplicate or missing
(un)trainings.

this also includes a new subcommand "retrain" to recreate the junkfilter for an
account. you should run it after updating to this version. and you should
probably also modify your account config to include the AutomaticJunkFlags.
2023-02-11 23:00:12 +01:00
..
.gitignore mox! 2023-01-30 14:27:06 +01:00
default.go mox! 2023-01-30 14:27:06 +01:00
doc.go improve training of junk filter 2023-02-11 23:00:12 +01:00
equal.go mox! 2023-01-30 14:27:06 +01:00
exec.go mox! 2023-01-30 14:27:06 +01:00
export.go improve training of junk filter 2023-02-11 23:00:12 +01:00
format.md mox! 2023-01-30 14:27:06 +01:00
gendoc.sh mox! 2023-01-30 14:27:06 +01:00
keys.go mox! 2023-01-30 14:27:06 +01:00
LICENSE mox! 2023-01-30 14:27:06 +01:00
Makefile mox! 2023-01-30 14:27:06 +01:00
nonzero.go mox! 2023-01-30 14:27:06 +01:00
pack.go improve training of junk filter 2023-02-11 23:00:12 +01:00
parse.go improve training of junk filter 2023-02-11 23:00:12 +01:00
plan.go mox! 2023-01-30 14:27:06 +01:00
query.go mox! 2023-01-30 14:27:06 +01:00
README.md mox! 2023-01-30 14:27:06 +01:00
register.go mox! 2023-01-30 14:27:06 +01:00
stats.go mox! 2023-01-30 14:27:06 +01:00
store.go mox! 2023-01-30 14:27:06 +01:00
tags.go mox! 2023-01-30 14:27:06 +01:00
tx.go mox! 2023-01-30 14:27:06 +01:00

bstore is a database library for storing and quering Go struct data.

See https://pkg.go.dev/github.com/mjl-/bstore

MIT-licensed

Comparison

Bstore is designed as a small, pure Go library that still provides most of the common data consistency requirements for modest database use cases. Bstore aims to make basic use of cgo-based libraries, such as sqlite, unnecessary. Sqlite is a great library, but Go applications that require cgo are hard to cross-compile. With bstore, cross-compiling to most Go-supported platforms stays trivial. Although bstore is much more limited in so many aspects than sqlite, bstore also offers some advantages as well.

  • Cross-compilation and reproducibility: Trivial with bstore due to pure Go, much harder with sqlite because of cgo.
  • Code complexity: low with bstore (6k lines including comments/docs), high with sqlite.
  • Query language: mostly-type-checked function calls in bstore, free-form query strings only checked at runtime with sqlite.
  • Functionality: very limited with bstore, much more full-featured with sqlite.
  • Schema management: mostly automatic based on Go type definitions in bstore, manual with ALTER statements in sqlite.
  • Types and packing/parsing: automatic/transparent in bstore based on Go types (including maps, slices, structs and custom MarshalBinary encoding), versus manual scanning and parameter passing with sqlite with limited set of SQL types.
  • Performance: low to good performance with bstore, high performance with sqlite.
  • Database files: single file with bstore, several files with sqlite (due to WAL or journal files).
  • Test coverage: decent coverage but limited real-world for bstore, versus extremely thoroughly tested and with enormous real-world use.

FAQ

Q: Is bstore an ORM?

A: No. The API for bstore may look like an ORM. But instead of mapping bstore "queries" (function calls) to an SQL query string, bstore executes them directly without converting to a query language.

Q: How does bstore store its data?

A bstore database is a single-file BoltDB database. BoltDB provides ACID properties. Bstore uses a BoltDB "bucket" (key/value store) for each Go type stored, with multiple subbuckets: one for type definitions, one for the actual data, and one bucket per index. BoltDB stores data in a B+tree. See format.md for details.