From 60c7db430113e9190935385073d39f582d41d20d Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Wed, 5 Oct 2016 15:29:40 -0700 Subject: [PATCH] Pre: Make testing consistent by sorting fulltext values before inserting. This sorts fulltext values inserted in a single transaction, not across transactions. This makes the rowids assigned in the fulltext_values table internally consistent, even as the order of entities and datoms changes (as the transaction applying algorithm evolves over time). The test changes simply make the fulltext values sort easily. In theory, these fulltext values could be very large, and sorting might be very expensive. In practice, we expect values to differ in their first few characters, so that this is efficient (i.e., proportional to the number of fulltext values inserted and not their size). --- src/common/datomish/db.cljc | 4 ++-- test/datomish/db_test.cljc | 42 ++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/common/datomish/db.cljc b/src/common/datomish/db.cljc index f0d9c0d5..a76611f5 100644 --- a/src/common/datomish/db.cljc +++ b/src/common/datomish/db.cljc @@ -383,7 +383,7 @@ (ref? a) ; index_vaet (unique? a) ; unique_value tag]])) - ops + (sort-by (fn [[_ _ _ v]] v) ops) ;; Make testing easier by sorting by string values. TODO: discuss expense. (range initial-many-searchid 999999999)) ["UPDATE fulltext_values SET searchid = NULL WHERE searchid IS NOT NULL"])) @@ -412,7 +412,7 @@ "INSERT INTO temp.tx_lookup_before (e0, a0, v0, tx0, added0, value_type_tag0) VALUES " "(?, ?, (SELECT rowid FROM fulltext_values WHERE searchid = ?), ?, 0, ?)") e a searchid tx tag]])) - ops + (sort-by (fn [[_ _ _ v]] v) ops) ;; Make testing easier by sorting by string values. TODO: discuss expense. (range initial-one-searchid 999999999)) ["UPDATE fulltext_values SET searchid = NULL WHERE searchid IS NOT NULL"])) diff --git a/test/datomish/db_test.cljc b/test/datomish/db_test.cljc index dd8531bd..3cb47020 100644 --- a/test/datomish/db_test.cljc +++ b/test/datomish/db_test.cljc @@ -644,11 +644,11 @@ (let [tx0 (:tx (