2017-01-26 00:13:56 +00:00
|
|
|
[package]
|
|
|
|
name = "mentat_db"
|
|
|
|
version = "0.0.1"
|
2017-02-20 17:35:32 +00:00
|
|
|
workspace = ".."
|
2017-01-26 00:13:56 +00:00
|
|
|
|
2018-06-13 15:49:40 +00:00
|
|
|
[features]
|
|
|
|
default = []
|
|
|
|
sqlcipher = ["rusqlite/sqlcipher"]
|
|
|
|
|
2017-01-26 00:13:56 +00:00
|
|
|
[dependencies]
|
2018-06-06 01:23:59 +00:00
|
|
|
failure = "0.1.1"
|
|
|
|
failure_derive = "0.1.1"
|
2018-04-24 22:04:00 +00:00
|
|
|
indexmap = "1"
|
2017-11-21 16:24:08 +00:00
|
|
|
itertools = "0.7"
|
2017-05-03 19:53:16 +00:00
|
|
|
lazy_static = "0.2"
|
2018-05-01 20:46:03 +00:00
|
|
|
log = "0.4"
|
2017-11-21 16:24:08 +00:00
|
|
|
ordered-float = "0.5"
|
2017-05-03 19:53:16 +00:00
|
|
|
time = "0.1"
|
Add type checking and constraint checking to the transactor. (#663, #532, #679)
This should address #663, by re-inserting type checking in the
transactor stack after the entry point used by the term builder.
Before this commit, we were using an SQLite UNIQUE index to assert
that no `[e a]` pair, with `a` a cardinality one attribute, was
asserted more than once. However, that's not in line with Datomic,
which treats transaction inputs as a set and allows a single datom
like `[e a v]` to appear multiple times. It's both awkward and not
particularly efficient to look for _distinct_ repetitions in SQL, so
we accept some runtime cost in order to check for repetitions in the
transactor. This will allow us to address #532, which is really about
whether we treat inputs as sets. A side benefit is that we can
provide more helpful error messages when the transactor does detect
that the input truly violates the cardinality constraints of the
schema.
This commit builds a trie while error checking and collecting final
terms, which should be fairly efficient. It also allows a simpler
expression of input-provided :db/txInstant datoms, which in turn
uncovered a small issue with the transaction watcher, where-by the
watcher would not see non-input-provided :db/txInstant datoms.
This transition to Datomic-like input-as-set semantics allows us to
address #532. Previously, two tempids that upserted to the same entid
would produce duplicate datoms, and that would have been rejected by
the transactor -- correctly, since we did not allow duplicate datoms
under the input-as-list semantics. With input-as-set semantics,
duplicate datoms are allowed; and that means that we must allow
tempids to be equivalent, i.e., to resolve to the same tempid.
To achieve this, we:
- index the set of tempids
- identify tempid indices that share an upsert
- map tempids to a dense set of contiguous integer labels
We use the well-known union-find algorithm, as implemented by
petgraph, to efficiently manage the set of equivalent tempids.
Along the way, I've fixed and added tests for two small errors in the
transactor. First, don't drop datoms resolved by upsert (#679).
Second, ensure that complex upserts are allocated.
I don't know quite what happened here. The Clojure implementation
correctly kept complex upserts that hadn't resolved as complex
upserts (see
https://github.com/mozilla/mentat/blob/9a9dfb502acf5e4cdb1059d4aac831d7603063c8/src/common/datomish/transact.cljc#L436)
and then allocated complex upserts if they didn't resolve (see
https://github.com/mozilla/mentat/blob/9a9dfb502acf5e4cdb1059d4aac831d7603063c8/src/common/datomish/transact.cljc#L509).
Based on the code comments, I think the Rust implementation must have
incorrectly tried to optimize by handling all complex upserts in at
most a single generation of evolution, and that's just not correct.
We're effectively implementing a topological sort, using very specific
domain knowledge, and its not true that a node in a topological sort
can be considered only once!
2018-04-30 22:16:05 +00:00
|
|
|
petgraph = "0.4.12"
|
2017-01-26 00:13:56 +00:00
|
|
|
|
|
|
|
[dependencies.rusqlite]
|
2018-02-22 19:41:57 +00:00
|
|
|
version = "0.13"
|
2018-02-13 16:25:58 +00:00
|
|
|
features = ["limits"]
|
2017-01-26 00:13:56 +00:00
|
|
|
|
|
|
|
[dependencies.edn]
|
|
|
|
path = "../edn"
|
|
|
|
|
2017-02-04 00:51:13 +00:00
|
|
|
[dependencies.mentat_core]
|
|
|
|
path = "../core"
|
|
|
|
|
2018-05-04 19:56:00 +00:00
|
|
|
[dependencies.mentat_sql]
|
|
|
|
path = "../sql"
|
|
|
|
|
2017-02-08 22:04:32 +00:00
|
|
|
# Should be dev-dependencies.
|
|
|
|
[dependencies.tabwriter]
|
|
|
|
version = "1.0.3"
|
2018-05-01 20:46:03 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
env_logger = "0.5"
|