Created
June 1, 2015 20:51
-
-
Save favila/0a93bd6ac552d0d0ed11 to your computer and use it in GitHub Desktop.
Find the bootstrap transactions for a datomic database. Bootstrap transactions are the first few transactions which create all the datoms necessary for datomic to work (e.g., the initial partitions, types, attributes, and tx functions). They are not accessible directly via the transaction log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Result of bootstrap-txes function above under datomic 0.9.5173 | |
;; Bootstrap transactions are 0, | |
;; More bootstrap transactions or datoms may be added in later datomic versions. | |
;; First non-bootstrap transaction is always T >= 1000. | |
;; Format is [[t [[e a v tx added] ...] ...] ...] | |
[[0 | |
[[0 10 :db.part/db 13194139533312 true] | |
[1 10 :db/add 13194139533312 true] | |
[2 10 :db/retract 13194139533312 true] | |
[3 10 :db.part/tx 13194139533312 true] | |
[4 10 :db.part/user 13194139533312 true] | |
[10 10 :db/ident 13194139533312 true] | |
[11 10 :db.install/partition 13194139533312 true] | |
[12 10 :db.install/valueType 13194139533312 true] | |
[13 10 :db.install/attribute 13194139533312 true] | |
[14 10 :db.install/function 13194139533312 true] | |
[15 10 :db/excise 13194139533312 true] | |
[16 10 :db.excise/attrs 13194139533312 true] | |
[17 10 :db.excise/beforeT 13194139533312 true] | |
[18 10 :db.excise/before 13194139533312 true] | |
[19 10 :db.alter/attribute 13194139533312 true] | |
[20 10 :db.type/ref 13194139533312 true] | |
[21 10 :db.type/keyword 13194139533312 true] | |
[22 10 :db.type/long 13194139533312 true] | |
[23 10 :db.type/string 13194139533312 true] | |
[24 10 :db.type/boolean 13194139533312 true] | |
[25 10 :db.type/instant 13194139533312 true] | |
[26 10 :db.type/fn 13194139533312 true] | |
[27 10 :db.type/bytes 13194139533312 true] | |
[35 10 :db.cardinality/one 13194139533312 true] | |
[36 10 :db.cardinality/many 13194139533312 true] | |
[37 10 :db.unique/value 13194139533312 true] | |
[38 10 :db.unique/identity 13194139533312 true] | |
[39 10 :fressian/tag 13194139533312 true] | |
[40 10 :db/valueType 13194139533312 true] | |
[41 10 :db/cardinality 13194139533312 true] | |
[42 10 :db/unique 13194139533312 true] | |
[43 10 :db/isComponent 13194139533312 true] | |
[44 10 :db/index 13194139533312 true] | |
[45 10 :db/noHistory 13194139533312 true] | |
[46 10 :db/lang 13194139533312 true] | |
[47 10 :db/code 13194139533312 true] | |
[48 10 :db.lang/clojure 13194139533312 true] | |
[49 10 :db.lang/java 13194139533312 true] | |
[50 10 :db/txInstant 13194139533312 true] | |
[51 10 :db/fulltext 13194139533312 true] | |
[52 10 :db/fn 13194139533312 true] | |
[53 10 :db.bootstrap/part 13194139533312 true]]] | |
[54 | |
[[0 11 0 13194139533366 true] | |
[0 11 3 13194139533366 true] | |
[0 11 4 13194139533366 true] | |
[0 12 20 13194139533366 true] | |
[0 12 21 13194139533366 true] | |
[0 12 22 13194139533366 true] | |
[0 12 23 13194139533366 true] | |
[0 12 24 13194139533366 true] | |
[0 12 25 13194139533366 true] | |
[0 12 26 13194139533366 true] | |
[0 12 27 13194139533366 true] | |
[0 13 10 13194139533366 true] | |
[0 13 11 13194139533366 true] | |
[0 13 12 13194139533366 true] | |
[0 13 13 13194139533366 true] | |
[0 13 14 13194139533366 true] | |
[0 13 15 13194139533366 true] | |
[0 13 16 13194139533366 true] | |
[0 13 17 13194139533366 true] | |
[0 13 18 13194139533366 true] | |
[0 13 19 13194139533366 true] | |
[0 13 39 13194139533366 true] | |
[0 13 40 13194139533366 true] | |
[0 13 41 13194139533366 true] | |
[0 13 42 13194139533366 true] | |
[0 13 43 13194139533366 true] | |
[0 13 44 13194139533366 true] | |
[0 13 45 13194139533366 true] | |
[0 13 46 13194139533366 true] | |
[0 13 47 13194139533366 true] | |
[0 13 50 13194139533366 true] | |
[0 13 51 13194139533366 true] | |
[0 13 52 13194139533366 true] | |
[0 14 54 13194139533366 true] | |
[0 14 55 13194139533366 true] | |
[10 40 21 13194139533366 true] | |
[10 41 35 13194139533366 true] | |
[10 42 38 13194139533366 true] | |
[11 40 20 13194139533366 true] | |
[11 41 36 13194139533366 true] | |
[12 40 20 13194139533366 true] | |
[12 41 36 13194139533366 true] | |
[13 40 20 13194139533366 true] | |
[13 41 36 13194139533366 true] | |
[14 40 20 13194139533366 true] | |
[14 41 36 13194139533366 true] | |
[15 40 20 13194139533366 true] | |
[15 41 35 13194139533366 true] | |
[16 40 20 13194139533366 true] | |
[16 41 36 13194139533366 true] | |
[17 40 22 13194139533366 true] | |
[17 41 35 13194139533366 true] | |
[18 40 25 13194139533366 true] | |
[18 41 35 13194139533366 true] | |
[19 40 20 13194139533366 true] | |
[19 41 36 13194139533366 true] | |
[20 39 :ref 13194139533366 true] | |
[21 39 :key 13194139533366 true] | |
[22 39 :int 13194139533366 true] | |
[23 39 :string 13194139533366 true] | |
[24 39 :bool 13194139533366 true] | |
[25 39 :inst 13194139533366 true] | |
[26 39 :datomic/fn 13194139533366 true] | |
[27 39 :bytes 13194139533366 true] | |
[39 40 21 13194139533366 true] | |
[39 41 35 13194139533366 true] | |
[39 44 true 13194139533366 true] | |
[40 40 20 13194139533366 true] | |
[40 41 35 13194139533366 true] | |
[41 40 20 13194139533366 true] | |
[41 41 35 13194139533366 true] | |
[42 40 20 13194139533366 true] | |
[42 41 35 13194139533366 true] | |
[43 40 24 13194139533366 true] | |
[43 41 35 13194139533366 true] | |
[44 40 24 13194139533366 true] | |
[44 41 35 13194139533366 true] | |
[45 40 24 13194139533366 true] | |
[45 41 35 13194139533366 true] | |
[46 40 20 13194139533366 true] | |
[46 41 35 13194139533366 true] | |
[47 40 23 13194139533366 true] | |
[47 41 35 13194139533366 true] | |
[47 51 true 13194139533366 true] | |
[50 40 25 13194139533366 true] | |
[50 41 35 13194139533366 true] | |
[50 44 true 13194139533366 true] | |
[51 40 24 13194139533366 true] | |
[51 41 35 13194139533366 true] | |
[52 40 26 13194139533366 true] | |
[52 41 35 13194139533366 true] | |
[54 10 :db.fn/retractEntity 13194139533366 true] | |
[54 46 48 13194139533366 true] | |
[54 | |
47 | |
"(clojure.core/fn [db e] (datomic.builtins/build-retract-args db e))" | |
13194139533366 | |
true] | |
[55 10 :db.fn/cas 13194139533366 true] | |
[55 46 48 13194139533366 true] | |
[55 | |
47 | |
"(clojure.core/fn [db e a ov nv] (datomic.builtins/compare-and-swap db e a ov nv))" | |
13194139533366 | |
true] | |
[13194139533366 | |
50 | |
#inst "1970-01-01T00:00:00.000-00:00" | |
13194139533366 | |
true]]] | |
[56 | |
[[0 12 56 13194139533368 true] | |
[0 12 57 13194139533368 true] | |
[0 12 58 13194139533368 true] | |
[0 12 59 13194139533368 true] | |
[0 12 60 13194139533368 true] | |
[0 12 61 13194139533368 true] | |
[0 13 62 13194139533368 true] | |
[56 10 :db.type/uuid 13194139533368 true] | |
[56 39 :uuid 13194139533368 true] | |
[57 10 :db.type/double 13194139533368 true] | |
[57 39 :double 13194139533368 true] | |
[58 10 :db.type/float 13194139533368 true] | |
[58 39 :float 13194139533368 true] | |
[59 10 :db.type/uri 13194139533368 true] | |
[59 39 :uri 13194139533368 true] | |
[60 10 :db.type/bigint 13194139533368 true] | |
[60 39 :bigint 13194139533368 true] | |
[61 10 :db.type/bigdec 13194139533368 true] | |
[61 39 :bigdec 13194139533368 true] | |
[62 10 :db/doc 13194139533368 true] | |
[62 40 23 13194139533368 true] | |
[62 41 35 13194139533368 true] | |
[62 51 true 13194139533368 true] | |
[13194139533368 | |
50 | |
#inst "1970-01-01T00:00:00.000-00:00" | |
13194139533368 | |
true]]] | |
[63 | |
[[0 | |
62 | |
"Name of the system partition. The system partition includes the core of datomic, as well as user schemas: type definitions, attribute definitions, partition definitions, and data function definitions." | |
13194139533375 | |
true] | |
[1 | |
62 | |
"Primitive assertion. All transactions eventually reduce to a collection of primitive assertions and retractions of facts, e.g. [:db/add fred :age 42]." | |
13194139533375 | |
true] | |
[2 | |
62 | |
"Primitive retraction. All transactions eventually reduce to a collection of assertions and retractions of facts, e.g. [:db/retract fred :age 42]." | |
13194139533375 | |
true] | |
[3 | |
62 | |
"Partition used to store data about transactions. Transaction data always includes a :db/txInstant which is the transaction's timestamp, and can be extended to store other information at transaction granularity." | |
13194139533375 | |
true] | |
[4 | |
62 | |
"Name of the user partition. The user partition is analogous to the default namespace in a programming language, and should be used as a temporary home for data during interactive development." | |
13194139533375 | |
true] | |
[10 | |
62 | |
"Attribute used to uniquely name an entity." | |
13194139533375 | |
true] | |
[11 | |
62 | |
"System attribute with type :db.type/ref. Asserting this attribute on :db.part/db with value v will install v as a partition." | |
13194139533375 | |
true] | |
[12 | |
62 | |
"System attribute with type :db.type/ref. Asserting this attribute on :db.part/db with value v will install v as a value type." | |
13194139533375 | |
true] | |
[13 | |
62 | |
"System attribute with type :db.type/ref. Asserting this attribute on :db.part/db with value v will install v as an attribute." | |
13194139533375 | |
true] | |
[14 | |
62 | |
"System attribute with type :db.type/ref. Asserting this attribute on :db.part/db with value v will install v as a data function." | |
13194139533375 | |
true] | |
[19 | |
62 | |
"System attribute with type :db.type/ref. Asserting this attribute on :db.part/db with value v will alter the definition of existing attribute v." | |
13194139533375 | |
true] | |
[20 | |
62 | |
"Value type for references. All references from one entity to another are through attributes with this value type." | |
13194139533375 | |
true] | |
[21 | |
62 | |
"Value type for keywords. Keywords are used as names, and are interned for efficiency. Keywords map to the native interned-name type in languages that support them." | |
13194139533375 | |
true] | |
[22 | |
62 | |
"Fixed integer value type. Same semantics as a Java long: 64 bits wide, two's complement binary representation." | |
13194139533375 | |
true] | |
[23 62 "Value type for strings." 13194139533375 true] | |
[24 62 "Boolean value type." 13194139533375 true] | |
[25 | |
62 | |
"Value type for instants in time. Stored internally as a number of milliseconds since midnight, January 1, 1970 UTC. Representation type will vary depending on the language you are using." | |
13194139533375 | |
true] | |
[26 | |
62 | |
"Value type for database functions. See Javadoc for Peer.function." | |
13194139533375 | |
true] | |
[27 | |
62 | |
"Value type for small binaries. Maps to byte array on the JVM." | |
13194139533375 | |
true] | |
[35 | |
62 | |
"One of two legal values for the :db/cardinality attribute. Specify :db.cardinality/one for single-valued attributes, and :db.cardinality/many for many-valued attributes." | |
13194139533375 | |
true] | |
[36 | |
62 | |
"One of two legal values for the :db/cardinality attribute. Specify :db.cardinality/one for single-valued attributes, and :db.cardinality/many for many-valued attributes." | |
13194139533375 | |
true] | |
[37 | |
62 | |
"Specifies that an attribute's value is unique. Attempts to create a new entity with a colliding value for a :db.unique/value will fail." | |
13194139533375 | |
true] | |
[38 | |
62 | |
"Specifies that an attribute's value is unique. Attempts to create a new entity with a colliding value for a :db.unique/value will become upserts." | |
13194139533375 | |
true] | |
[39 | |
62 | |
"Keyword-valued attribute of a value type that specifies the underlying fressian type used for serialization." | |
13194139533375 | |
true] | |
[40 | |
62 | |
"Property of an attribute that specifies the attribute's value type. Built-in value types include, :db.type/keyword, :db.type/string, :db.type/ref, :db.type/instant, :db.type/long, :db.type/bigdec, :db.type/boolean, :db.type/float, :db.type/uuid, :db.type/double, :db.type/bigint, :db.type/uri." | |
13194139533375 | |
true] | |
[41 | |
62 | |
"Property of an attribute. Two possible values: :db.cardinality/one for single-valued attributes, and :db.cardinality/many for many-valued attributes. Defaults to :db.cardinality/one." | |
13194139533375 | |
true] | |
[42 | |
62 | |
"Property of an attribute. If value is :db.unique/value, then attribute value is unique to each entity. Attempts to insert a duplicate value for a temporary entity id will fail. If value is :db.unique/identity, then attribute value is unique, and upsert is enabled. Attempting to insert a duplicate value for a temporary entity id will cause all attributes associated with that temporary id to be merged with the entity already in the database. Defaults to nil." | |
13194139533375 | |
true] | |
[43 | |
62 | |
"Property of attribute whose vtype is :db.type/ref. If true, then the attribute is a component of the entity referencing it. When you query for an entire entity, components are fetched automatically. Defaults to nil." | |
13194139533375 | |
true] | |
[44 | |
62 | |
"Property of an attribute. If true, create an AVET index for the attribute. Defaults to false." | |
13194139533375 | |
true] | |
[45 | |
62 | |
"Property of an attribute. If true, past values of the attribute are not retained after indexing. Defaults to false." | |
13194139533375 | |
true] | |
[46 | |
62 | |
"Attribute of a data function. Value is a keyword naming the implementation language of the function. Legal values are :db.lang/java and :db.lang/clojure" | |
13194139533375 | |
true] | |
[47 | |
62 | |
"String-valued attribute of a data function that contains the function's source code." | |
13194139533375 | |
true] | |
[48 | |
62 | |
"Value of :db/lang attribute, specifying that a data function is implemented in Clojure." | |
13194139533375 | |
true] | |
[49 | |
62 | |
"Value of :db/lang attribute, specifying that a data function is implemented in Java." | |
13194139533375 | |
true] | |
[50 | |
62 | |
"Attribute whose value is a :db.type/instant. A :db/txInstant is recorded automatically with every transaction." | |
13194139533375 | |
true] | |
[51 | |
62 | |
"Property of an attribute. If true, create a fulltext search index for the attribute. Defaults to false." | |
13194139533375 | |
true] | |
[52 | |
62 | |
"A function-valued attribute for direct use by transactions and queries." | |
13194139533375 | |
true] | |
[54 | |
62 | |
"Retract all facts about an entity, including references from other entities and component attributes recursively." | |
13194139533375 | |
true] | |
[55 | |
62 | |
"Compare and swap the value of an entity's attribute." | |
13194139533375 | |
true] | |
[56 | |
62 | |
"Value type for UUIDs. Maps to java.util.UUID on the JVM." | |
13194139533375 | |
true] | |
[57 | |
62 | |
"Floating point value type. Same semantics as a Java double: double-precision 64-bit IEEE 754 floating point." | |
13194139533375 | |
true] | |
[58 | |
62 | |
"Floating point value type. Same semantics as a Java float: single-precision 32-bit IEEE 754 floating point." | |
13194139533375 | |
true] | |
[59 | |
62 | |
"Value type for URIs. Maps to java.net.URI on the JVM." | |
13194139533375 | |
true] | |
[60 | |
62 | |
"Value type for arbitrary precision integers. Maps to java.math.BigInteger on the JVM." | |
13194139533375 | |
true] | |
[61 | |
62 | |
"Value type for arbitrary precision floating point numbers. Maps to java.math.BigDecimal on the JVM." | |
13194139533375 | |
true] | |
[62 62 "Documentation string for an entity." 13194139533375 true] | |
[13194139533375 | |
50 | |
#inst "1970-01-01T00:00:00.000-00:00" | |
13194139533375 | |
true]]]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[datomic.api :as d]) | |
(def dburi "datomic:mem://bootstrap-txes") | |
(d/create-database dburi) | |
(def conn (d/connect dburi)) | |
(defn bootstrap-txes [db] | |
(let [bootstrap-txes (->> (d/seek-datoms db :aevt :db/txInstant) | |
(take-while #(= (:v %) #inst "1970-01-01T00:00:00.000-00:00")) | |
(map :e)) | |
tx-ranges (partition 2 1 (conj bootstrap-txes 0 nil))] | |
(mapv (juxt (comp d/tx->t second) | |
(fn [[from to]] | |
(mapv (juxt :e :a :v :tx :added) | |
(cond-> db from (d/since from) to (d/as-of to) true (d/datoms :eavt))))) | |
tx-ranges))) | |
(bootstrap-txes (d/db conn)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment