datahike-browser-tests 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +405 -0
- package/.circleci/scripts/gen_ci.clj +194 -0
- package/.cirrus.yml +60 -0
- package/.clj-kondo/babashka/sci/config.edn +1 -0
- package/.clj-kondo/babashka/sci/sci/core.clj +9 -0
- package/.clj-kondo/config.edn +95 -0
- package/.dir-locals.el +2 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/1-bug-report.yml +68 -0
- package/.github/ISSUE_TEMPLATE/2-feature-request.yml +28 -0
- package/.github/ISSUE_TEMPLATE/config.yml +6 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/native-image.yml +84 -0
- package/LICENSE +203 -0
- package/README.md +273 -0
- package/bb/deps.edn +9 -0
- package/bb/resources/github-fingerprints +3 -0
- package/bb/resources/native-image-tests/run-bb-pod-tests.clj +162 -0
- package/bb/resources/native-image-tests/run-libdatahike-tests +12 -0
- package/bb/resources/native-image-tests/run-native-image-tests +74 -0
- package/bb/resources/native-image-tests/run-python-tests +22 -0
- package/bb/resources/native-image-tests/testconfig.attr-refs.edn +6 -0
- package/bb/resources/native-image-tests/testconfig.edn +5 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/bb/resources/template/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/bb/resources/template/pom.xml +22 -0
- package/bb/src/tools/build.clj +132 -0
- package/bb/src/tools/clj_kondo.clj +32 -0
- package/bb/src/tools/deploy.clj +26 -0
- package/bb/src/tools/examples.clj +19 -0
- package/bb/src/tools/npm.clj +100 -0
- package/bb/src/tools/python.clj +14 -0
- package/bb/src/tools/release.clj +94 -0
- package/bb/src/tools/test.clj +148 -0
- package/bb/src/tools/version.clj +47 -0
- package/bb.edn +269 -0
- package/benchmark/src/benchmark/cli.clj +195 -0
- package/benchmark/src/benchmark/compare.clj +157 -0
- package/benchmark/src/benchmark/config.clj +316 -0
- package/benchmark/src/benchmark/measure.clj +187 -0
- package/benchmark/src/benchmark/store.clj +190 -0
- package/benchmark/test/benchmark/measure_test.clj +156 -0
- package/build.clj +30 -0
- package/config.edn +49 -0
- package/deps.edn +138 -0
- package/dev/sandbox.clj +82 -0
- package/dev/sandbox.cljs +127 -0
- package/dev/sandbox_benchmarks.clj +27 -0
- package/dev/sandbox_client.clj +87 -0
- package/dev/sandbox_transact_bench.clj +109 -0
- package/dev/user.clj +79 -0
- package/doc/README.md +96 -0
- package/doc/adl/README.md +6 -0
- package/doc/adl/adr-000-adr.org +28 -0
- package/doc/adl/adr-001-attribute-references.org +15 -0
- package/doc/adl/adr-002-build-tooling.org +54 -0
- package/doc/adl/adr-003-db-meta-data.md +52 -0
- package/doc/adl/adr-004-github-flow.md +40 -0
- package/doc/adl/adr-XYZ-template.md +30 -0
- package/doc/adl/index.org +3 -0
- package/doc/assets/datahike-logo.svg +3 -0
- package/doc/assets/datahiking-invoice.org +85 -0
- package/doc/assets/hhtree2.png +0 -0
- package/doc/assets/network_topology.svg +624 -0
- package/doc/assets/perf.png +0 -0
- package/doc/assets/schema_mindmap.mm +132 -0
- package/doc/assets/schema_mindmap.svg +970 -0
- package/doc/assets/temporal_index.mm +74 -0
- package/doc/backend-development.md +78 -0
- package/doc/bb-pod.md +89 -0
- package/doc/benchmarking.md +360 -0
- package/doc/bindings/edn-conversion.md +383 -0
- package/doc/cli.md +162 -0
- package/doc/cljdoc.edn +27 -0
- package/doc/cljs-support.md +133 -0
- package/doc/config.md +406 -0
- package/doc/contributing.md +114 -0
- package/doc/datalog-vs-sql.md +210 -0
- package/doc/datomic_differences.md +109 -0
- package/doc/development/pull-api-ns.md +186 -0
- package/doc/development/pull-frame-state-diagram.jpg +0 -0
- package/doc/distributed.md +566 -0
- package/doc/entity_spec.md +92 -0
- package/doc/gc.md +273 -0
- package/doc/java-api.md +808 -0
- package/doc/javascript-api.md +421 -0
- package/doc/libdatahike.md +86 -0
- package/doc/logging_and_error_handling.md +43 -0
- package/doc/norms.md +66 -0
- package/doc/schema-migration.md +85 -0
- package/doc/schema.md +287 -0
- package/doc/storage-backends.md +363 -0
- package/doc/store-id-refactoring.md +596 -0
- package/doc/time_variance.md +325 -0
- package/doc/unstructured.md +167 -0
- package/doc/versioning.md +261 -0
- package/examples/basic/README.md +19 -0
- package/examples/basic/deps.edn +6 -0
- package/examples/basic/docker-compose.yml +13 -0
- package/examples/basic/src/examples/core.clj +60 -0
- package/examples/basic/src/examples/schema.clj +155 -0
- package/examples/basic/src/examples/store.clj +60 -0
- package/examples/basic/src/examples/time_travel.clj +185 -0
- package/examples/java/.settings/org.eclipse.core.resources.prefs +3 -0
- package/examples/java/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/examples/java/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/examples/java/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/examples/java/README.md +162 -0
- package/examples/java/pom.xml +62 -0
- package/examples/java/src/main/java/examples/QuickStart.java +115 -0
- package/examples/java/src/main/java/examples/SchemaExample.java +148 -0
- package/examples/java/src/main/java/examples/TimeTravelExample.java +121 -0
- package/flake.lock +27 -0
- package/flake.nix +27 -0
- package/http-server/datahike/http/middleware.clj +75 -0
- package/http-server/datahike/http/server.clj +269 -0
- package/java/src/datahike/java/Database.java +274 -0
- package/java/src/datahike/java/Datahike.java +281 -0
- package/java/src/datahike/java/DatahikeGeneratedTest.java +349 -0
- package/java/src/datahike/java/DatahikeTest.java +370 -0
- package/java/src/datahike/java/EDN.java +170 -0
- package/java/src/datahike/java/IEntity.java +11 -0
- package/java/src/datahike/java/Keywords.java +161 -0
- package/java/src/datahike/java/SchemaFlexibility.java +52 -0
- package/java/src/datahike/java/Util.java +219 -0
- package/karma.conf.js +19 -0
- package/libdatahike/compile-cpp +7 -0
- package/libdatahike/src/datahike/impl/LibDatahikeBase.java +203 -0
- package/libdatahike/src/datahike/impl/libdatahike.clj +59 -0
- package/libdatahike/src/test_cpp.cpp +61 -0
- package/npm-package/PUBLISHING.md +140 -0
- package/npm-package/README.md +226 -0
- package/npm-package/package.template.json +34 -0
- package/npm-package/test-isomorphic.ts +281 -0
- package/npm-package/test.js +557 -0
- package/npm-package/typescript-test.ts +70 -0
- package/package.json +16 -0
- package/pydatahike/README.md +569 -0
- package/pydatahike/pyproject.toml +91 -0
- package/pydatahike/setup.py +42 -0
- package/pydatahike/src/datahike/__init__.py +134 -0
- package/pydatahike/src/datahike/_native.py +250 -0
- package/pydatahike/src/datahike/_version.py +2 -0
- package/pydatahike/src/datahike/database.py +722 -0
- package/pydatahike/src/datahike/edn.py +311 -0
- package/pydatahike/src/datahike/py.typed +0 -0
- package/pydatahike/tests/conftest.py +17 -0
- package/pydatahike/tests/test_basic.py +170 -0
- package/pydatahike/tests/test_database.py +51 -0
- package/pydatahike/tests/test_edn_conversion.py +299 -0
- package/pydatahike/tests/test_query.py +99 -0
- package/pydatahike/tests/test_schema.py +55 -0
- package/resources/clj-kondo.exports/io.replikativ/datahike/config.edn +5 -0
- package/resources/example_server.edn +4 -0
- package/shadow-cljs.edn +56 -0
- package/src/data_readers.clj +7 -0
- package/src/datahike/api/impl.cljc +176 -0
- package/src/datahike/api/specification.cljc +633 -0
- package/src/datahike/api/types.cljc +261 -0
- package/src/datahike/api.cljc +41 -0
- package/src/datahike/array.cljc +99 -0
- package/src/datahike/cli.clj +166 -0
- package/src/datahike/cljs.cljs +6 -0
- package/src/datahike/codegen/cli.clj +406 -0
- package/src/datahike/codegen/clj_kondo.clj +291 -0
- package/src/datahike/codegen/java.clj +403 -0
- package/src/datahike/codegen/naming.cljc +33 -0
- package/src/datahike/codegen/native.clj +559 -0
- package/src/datahike/codegen/pod.clj +488 -0
- package/src/datahike/codegen/python.clj +838 -0
- package/src/datahike/codegen/report.clj +55 -0
- package/src/datahike/codegen/typescript.clj +262 -0
- package/src/datahike/codegen/validation.clj +145 -0
- package/src/datahike/config.cljc +294 -0
- package/src/datahike/connections.cljc +16 -0
- package/src/datahike/connector.cljc +265 -0
- package/src/datahike/constants.cljc +142 -0
- package/src/datahike/core.cljc +297 -0
- package/src/datahike/datom.cljc +459 -0
- package/src/datahike/db/interface.cljc +119 -0
- package/src/datahike/db/search.cljc +305 -0
- package/src/datahike/db/transaction.cljc +937 -0
- package/src/datahike/db/utils.cljc +338 -0
- package/src/datahike/db.cljc +956 -0
- package/src/datahike/experimental/unstructured.cljc +126 -0
- package/src/datahike/experimental/versioning.cljc +172 -0
- package/src/datahike/externs.js +31 -0
- package/src/datahike/gc.cljc +69 -0
- package/src/datahike/http/client.clj +188 -0
- package/src/datahike/http/writer.clj +79 -0
- package/src/datahike/impl/entity.cljc +218 -0
- package/src/datahike/index/interface.cljc +93 -0
- package/src/datahike/index/persistent_set.cljc +469 -0
- package/src/datahike/index/utils.cljc +44 -0
- package/src/datahike/index.cljc +32 -0
- package/src/datahike/js/api.cljs +172 -0
- package/src/datahike/js/api_macros.clj +22 -0
- package/src/datahike/js.cljs +163 -0
- package/src/datahike/json.cljc +209 -0
- package/src/datahike/lru.cljc +146 -0
- package/src/datahike/migrate.clj +39 -0
- package/src/datahike/norm/norm.clj +245 -0
- package/src/datahike/online_gc.cljc +252 -0
- package/src/datahike/pod.clj +155 -0
- package/src/datahike/pull_api.cljc +325 -0
- package/src/datahike/query.cljc +1945 -0
- package/src/datahike/query_stats.cljc +88 -0
- package/src/datahike/readers.cljc +62 -0
- package/src/datahike/remote.cljc +218 -0
- package/src/datahike/schema.cljc +228 -0
- package/src/datahike/schema_cache.cljc +42 -0
- package/src/datahike/spec.cljc +101 -0
- package/src/datahike/store.cljc +80 -0
- package/src/datahike/tools.cljc +308 -0
- package/src/datahike/transit.cljc +80 -0
- package/src/datahike/writer.cljc +239 -0
- package/src/datahike/writing.cljc +362 -0
- package/src/deps.cljs +1 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/insert.cljc +76 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/upsert.cljc +128 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree.cljc +213 -0
- package/test/datahike/backward_compatibility_test/src/backward_test.clj +37 -0
- package/test/datahike/integration_test/config_record_file_test.clj +14 -0
- package/test/datahike/integration_test/config_record_test.clj +14 -0
- package/test/datahike/integration_test/depr_config_uri_test.clj +15 -0
- package/test/datahike/integration_test/return_map_test.clj +62 -0
- package/test/datahike/integration_test.cljc +67 -0
- package/test/datahike/norm/norm_test.clj +124 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/01-transact-basic-characters.edn +2 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/02 add occupation.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/checksums.edn +12 -0
- package/test/datahike/norm/resources/simple-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/checksums.edn +6 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/norm/resources/tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-fn-test/second/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/test/api_test.cljc +895 -0
- package/test/datahike/test/array_test.cljc +40 -0
- package/test/datahike/test/attribute_refs/datoms_test.cljc +140 -0
- package/test/datahike/test/attribute_refs/db_test.cljc +42 -0
- package/test/datahike/test/attribute_refs/differences_test.cljc +515 -0
- package/test/datahike/test/attribute_refs/entity_test.cljc +89 -0
- package/test/datahike/test/attribute_refs/pull_api_test.cljc +320 -0
- package/test/datahike/test/attribute_refs/query_find_specs_test.cljc +59 -0
- package/test/datahike/test/attribute_refs/query_fns_test.cljc +130 -0
- package/test/datahike/test/attribute_refs/query_interop_test.cljc +47 -0
- package/test/datahike/test/attribute_refs/query_not_test.cljc +193 -0
- package/test/datahike/test/attribute_refs/query_or_test.cljc +137 -0
- package/test/datahike/test/attribute_refs/query_pull_test.cljc +156 -0
- package/test/datahike/test/attribute_refs/query_rules_test.cljc +176 -0
- package/test/datahike/test/attribute_refs/query_test.cljc +241 -0
- package/test/datahike/test/attribute_refs/temporal_search.cljc +22 -0
- package/test/datahike/test/attribute_refs/transact_test.cljc +220 -0
- package/test/datahike/test/attribute_refs/utils.cljc +128 -0
- package/test/datahike/test/cache_test.cljc +38 -0
- package/test/datahike/test/components_test.cljc +92 -0
- package/test/datahike/test/config_test.cljc +158 -0
- package/test/datahike/test/core_test.cljc +105 -0
- package/test/datahike/test/datom_test.cljc +44 -0
- package/test/datahike/test/db_test.cljc +54 -0
- package/test/datahike/test/entity_spec_test.cljc +159 -0
- package/test/datahike/test/entity_test.cljc +103 -0
- package/test/datahike/test/explode_test.cljc +143 -0
- package/test/datahike/test/filter_test.cljc +75 -0
- package/test/datahike/test/gc_test.cljc +159 -0
- package/test/datahike/test/http/server_test.clj +192 -0
- package/test/datahike/test/http/writer_test.clj +86 -0
- package/test/datahike/test/ident_test.cljc +32 -0
- package/test/datahike/test/index_test.cljc +345 -0
- package/test/datahike/test/insert.cljc +125 -0
- package/test/datahike/test/java_bindings_test.clj +6 -0
- package/test/datahike/test/listen_test.cljc +41 -0
- package/test/datahike/test/lookup_refs_test.cljc +266 -0
- package/test/datahike/test/lru_test.cljc +27 -0
- package/test/datahike/test/migrate_test.clj +297 -0
- package/test/datahike/test/model/core.cljc +376 -0
- package/test/datahike/test/model/invariant.cljc +142 -0
- package/test/datahike/test/model/rng.cljc +82 -0
- package/test/datahike/test/model_test.clj +217 -0
- package/test/datahike/test/nodejs_test.cljs +262 -0
- package/test/datahike/test/online_gc_test.cljc +475 -0
- package/test/datahike/test/pod_test.clj +369 -0
- package/test/datahike/test/pull_api_test.cljc +474 -0
- package/test/datahike/test/purge_test.cljc +144 -0
- package/test/datahike/test/query_aggregates_test.cljc +101 -0
- package/test/datahike/test/query_find_specs_test.cljc +52 -0
- package/test/datahike/test/query_fns_test.cljc +523 -0
- package/test/datahike/test/query_interop_test.cljc +47 -0
- package/test/datahike/test/query_not_test.cljc +189 -0
- package/test/datahike/test/query_or_test.cljc +158 -0
- package/test/datahike/test/query_pull_test.cljc +147 -0
- package/test/datahike/test/query_rules_test.cljc +248 -0
- package/test/datahike/test/query_stats_test.cljc +218 -0
- package/test/datahike/test/query_test.cljc +984 -0
- package/test/datahike/test/schema_test.cljc +424 -0
- package/test/datahike/test/specification_test.cljc +30 -0
- package/test/datahike/test/store_test.cljc +78 -0
- package/test/datahike/test/stress_test.cljc +57 -0
- package/test/datahike/test/time_variance_test.cljc +518 -0
- package/test/datahike/test/tools_test.clj +134 -0
- package/test/datahike/test/transact_test.cljc +518 -0
- package/test/datahike/test/tuples_test.cljc +564 -0
- package/test/datahike/test/unstructured_test.cljc +291 -0
- package/test/datahike/test/upsert_impl_test.cljc +205 -0
- package/test/datahike/test/upsert_test.cljc +363 -0
- package/test/datahike/test/utils.cljc +110 -0
- package/test/datahike/test/validation_test.cljc +48 -0
- package/test/datahike/test/versioning_test.cljc +56 -0
- package/test/datahike/test.cljc +66 -0
- package/tests.edn +24 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<map version="freeplane 1.6.0">
|
|
2
|
+
<!--To view this file, download free mind mapping software Freeplane from http://freeplane.sourceforge.net -->
|
|
3
|
+
<node TEXT="Temporal Index" FOLDED="false" ID="ID_1420672071" CREATED="1562593263004" MODIFIED="1562593936990" STYLE="oval">
|
|
4
|
+
<font SIZE="18"/>
|
|
5
|
+
<hook NAME="MapStyle">
|
|
6
|
+
<properties edgeColorConfiguration="#808080ff,#ff0000ff,#0000ffff,#00ff00ff,#ff00ffff,#00ffffff,#7c0000ff,#00007cff,#007c00ff,#7c007cff,#007c7cff,#7c7c00ff" fit_to_viewport="false"/>
|
|
7
|
+
|
|
8
|
+
<map_styles>
|
|
9
|
+
<stylenode LOCALIZED_TEXT="styles.root_node" STYLE="oval" UNIFORM_SHAPE="true" VGAP_QUANTITY="24.0 pt">
|
|
10
|
+
<font SIZE="24"/>
|
|
11
|
+
<stylenode LOCALIZED_TEXT="styles.predefined" POSITION="right" STYLE="bubble">
|
|
12
|
+
<stylenode LOCALIZED_TEXT="default" ICON_SIZE="12.0 pt" COLOR="#000000" STYLE="fork">
|
|
13
|
+
<font NAME="SansSerif" SIZE="10" BOLD="false" ITALIC="false"/>
|
|
14
|
+
</stylenode>
|
|
15
|
+
<stylenode LOCALIZED_TEXT="defaultstyle.details"/>
|
|
16
|
+
<stylenode LOCALIZED_TEXT="defaultstyle.attributes">
|
|
17
|
+
<font SIZE="9"/>
|
|
18
|
+
</stylenode>
|
|
19
|
+
<stylenode LOCALIZED_TEXT="defaultstyle.note" COLOR="#000000" BACKGROUND_COLOR="#ffffff" TEXT_ALIGN="LEFT"/>
|
|
20
|
+
<stylenode LOCALIZED_TEXT="defaultstyle.floating">
|
|
21
|
+
<edge STYLE="hide_edge"/>
|
|
22
|
+
<cloud COLOR="#f0f0f0" SHAPE="ROUND_RECT"/>
|
|
23
|
+
</stylenode>
|
|
24
|
+
</stylenode>
|
|
25
|
+
<stylenode LOCALIZED_TEXT="styles.user-defined" POSITION="right" STYLE="bubble">
|
|
26
|
+
<stylenode LOCALIZED_TEXT="styles.topic" COLOR="#18898b" STYLE="fork">
|
|
27
|
+
<font NAME="Liberation Sans" SIZE="10" BOLD="true"/>
|
|
28
|
+
</stylenode>
|
|
29
|
+
<stylenode LOCALIZED_TEXT="styles.subtopic" COLOR="#cc3300" STYLE="fork">
|
|
30
|
+
<font NAME="Liberation Sans" SIZE="10" BOLD="true"/>
|
|
31
|
+
</stylenode>
|
|
32
|
+
<stylenode LOCALIZED_TEXT="styles.subsubtopic" COLOR="#669900">
|
|
33
|
+
<font NAME="Liberation Sans" SIZE="10" BOLD="true"/>
|
|
34
|
+
</stylenode>
|
|
35
|
+
<stylenode LOCALIZED_TEXT="styles.important">
|
|
36
|
+
<icon BUILTIN="yes"/>
|
|
37
|
+
</stylenode>
|
|
38
|
+
</stylenode>
|
|
39
|
+
<stylenode LOCALIZED_TEXT="styles.AutomaticLayout" POSITION="right" STYLE="bubble">
|
|
40
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level.root" COLOR="#000000" STYLE="oval" SHAPE_HORIZONTAL_MARGIN="10.0 pt" SHAPE_VERTICAL_MARGIN="10.0 pt">
|
|
41
|
+
<font SIZE="18"/>
|
|
42
|
+
</stylenode>
|
|
43
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,1" COLOR="#0033ff">
|
|
44
|
+
<font SIZE="16"/>
|
|
45
|
+
</stylenode>
|
|
46
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,2" COLOR="#00b439">
|
|
47
|
+
<font SIZE="14"/>
|
|
48
|
+
</stylenode>
|
|
49
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,3" COLOR="#990000">
|
|
50
|
+
<font SIZE="12"/>
|
|
51
|
+
</stylenode>
|
|
52
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,4" COLOR="#111111">
|
|
53
|
+
<font SIZE="10"/>
|
|
54
|
+
</stylenode>
|
|
55
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,5"/>
|
|
56
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,6"/>
|
|
57
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,7"/>
|
|
58
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,8"/>
|
|
59
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,9"/>
|
|
60
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,10"/>
|
|
61
|
+
<stylenode LOCALIZED_TEXT="AutomaticLayout.level,11"/>
|
|
62
|
+
</stylenode>
|
|
63
|
+
</stylenode>
|
|
64
|
+
</map_styles>
|
|
65
|
+
</hook>
|
|
66
|
+
<hook NAME="AutomaticEdgeColor" COUNTER="7" RULE="ON_BRANCH_CREATION"/>
|
|
67
|
+
<node TEXT="Query Engine" POSITION="right" ID="ID_1863830559" CREATED="1562593273134" MODIFIED="1562593288017">
|
|
68
|
+
<edge COLOR="#ff0000"/>
|
|
69
|
+
</node>
|
|
70
|
+
<node TEXT="Transactor" POSITION="left" ID="ID_1330328397" CREATED="1562593304683" MODIFIED="1562593311397">
|
|
71
|
+
<edge COLOR="#00ff00"/>
|
|
72
|
+
</node>
|
|
73
|
+
</node>
|
|
74
|
+
</map>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Backend Development
|
|
2
|
+
|
|
3
|
+
Datahike storage is built on top of [konserve](https://github.com/replikativ/konserve), a universal key-value store abstraction. To add a new storage backend to Datahike, you simply implement a konserve backend. Once your konserve backend is required and registered, Datahike will transparently work on top of it.
|
|
4
|
+
|
|
5
|
+
## Implementation Steps
|
|
6
|
+
|
|
7
|
+
1. **Implement a konserve backend** following the [konserve documentation](https://github.com/replikativ/konserve)
|
|
8
|
+
2. **Register your backend** by requiring it in your project
|
|
9
|
+
3. **Use it with Datahike** by specifying the backend keyword in your configuration
|
|
10
|
+
|
|
11
|
+
That's it! Datahike will automatically work with any konserve backend.
|
|
12
|
+
|
|
13
|
+
## Konserve Backend Documentation
|
|
14
|
+
|
|
15
|
+
See the [konserve documentation](https://github.com/replikativ/konserve) for:
|
|
16
|
+
- How to implement a new backend
|
|
17
|
+
- The konserve protocol specification
|
|
18
|
+
- Examples of existing backends
|
|
19
|
+
|
|
20
|
+
## Optional: Additional Datahike-Specific Support
|
|
21
|
+
|
|
22
|
+
While konserve backends work out of the box with Datahike, you can optionally add Datahike-specific optimizations:
|
|
23
|
+
|
|
24
|
+
### Serialization Handlers
|
|
25
|
+
|
|
26
|
+
For performance optimization, you can add custom serialization handlers for Datahike's data structures. See [datahike-lmdb](https://github.com/replikativ/datahike-lmdb) as an example, which installs LMDB-specific Datahike serialization handlers.
|
|
27
|
+
|
|
28
|
+
## Existing Backends
|
|
29
|
+
|
|
30
|
+
Datahike ships with built-in support for:
|
|
31
|
+
- `:memory` - In-memory storage (via konserve)
|
|
32
|
+
- `:file` - File-based storage (via konserve)
|
|
33
|
+
|
|
34
|
+
Additional backends available through konserve:
|
|
35
|
+
- [datahike-lmdb](https://github.com/replikativ/datahike-lmdb) - LMDB backend with optimized serialization
|
|
36
|
+
- [IndexedDB](https://github.com/replikativ/konserve-indexeddb) - Browser storage (via konserve)
|
|
37
|
+
- [PostgreSQL](https://github.com/replikativ/konserve-pg) - PostgreSQL backend (via konserve)
|
|
38
|
+
- Many more available in the [konserve ecosystem](https://github.com/replikativ/konserve)
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
Once your konserve backend is available, use it with Datahike by specifying the backend keyword:
|
|
43
|
+
|
|
44
|
+
```clojure
|
|
45
|
+
(require '[datahike.api :as d])
|
|
46
|
+
|
|
47
|
+
;; Example: using a custom backend
|
|
48
|
+
(def cfg {:store {:backend :your-backend-keyword
|
|
49
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440000"
|
|
50
|
+
;; ... backend-specific configuration
|
|
51
|
+
}})
|
|
52
|
+
|
|
53
|
+
(d/create-database cfg)
|
|
54
|
+
(def conn (d/connect cfg))
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Advanced: Custom Index Implementations
|
|
58
|
+
|
|
59
|
+
While less common than implementing backends, you can also implement custom index data structures for Datahike. This allows exploring different index algorithms optimized for specific use cases.
|
|
60
|
+
|
|
61
|
+
Datahike uses **persistent-set** as the default index. The **hitchhiker-tree** index (`:datahike.index/hitchhiker-tree`) is available for backwards compatibility and can be useful for certain workloads.
|
|
62
|
+
|
|
63
|
+
To implement a custom index:
|
|
64
|
+
|
|
65
|
+
1. Implement the index protocol (see existing implementations in `src/datahike/index/`)
|
|
66
|
+
2. Register your index implementation
|
|
67
|
+
3. Use it by specifying `:index :your-index-keyword` in the database configuration
|
|
68
|
+
|
|
69
|
+
Example configuration with custom index:
|
|
70
|
+
|
|
71
|
+
```clojure
|
|
72
|
+
(def cfg {:store {:backend :memory
|
|
73
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440000"}
|
|
74
|
+
:index :datahike.index/hitchhiker-tree ; or your custom index
|
|
75
|
+
:schema-flexibility :write})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This is an advanced topic primarily useful for research or highly specialized performance requirements.
|
package/doc/bb-pod.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Datahike babashka Pod
|
|
2
|
+
|
|
3
|
+
With the help of [the Datahike cli](doc/cli.md) we provide the possibility to run Datahike as a [babashka pod](https://book.babashka.org/#pods).
|
|
4
|
+
|
|
5
|
+
## Why Datahike as a babashka pod?
|
|
6
|
+
|
|
7
|
+
A babashka pod is a way to use Datahike in babashka without Datahike being built into the babashka binary. When you
|
|
8
|
+
don't want to run a whole JVM for a little script you can use babashka and write your script in your preferred language.
|
|
9
|
+
Babashka already has ways to persist data to other databases but Datahike adds the possibility to write to a durable
|
|
10
|
+
datalog database.
|
|
11
|
+
|
|
12
|
+
## babashka pod-registry
|
|
13
|
+
|
|
14
|
+
You can use the [official babashka pod-registry](https://github.com/babashka/pod-registry/tree/master/manifests/replikativ/datahike) to download the latest version of Datahike as a pod and run it with babashka.
|
|
15
|
+
|
|
16
|
+
## Compilation
|
|
17
|
+
|
|
18
|
+
Please run `bb ni-cli` inside the datahike repository. You'll need [GraalVM-JDK](https://www.graalvm.org/latest/getting-started/) installed with `native-compile` on your path, [babashka](https://babashka.org/) and [Clojure](https://clojure.org/guides/install_clojure).
|
|
19
|
+
|
|
20
|
+
## Maturity
|
|
21
|
+
|
|
22
|
+
This feature is not used in production so far. Please try it and [open issues on GitHub](https://github.com/replikativ/datahike/issues/new/choose) if you find a problem.
|
|
23
|
+
|
|
24
|
+
### Supported functionality
|
|
25
|
+
|
|
26
|
+
- as-of
|
|
27
|
+
- connect
|
|
28
|
+
- create-database
|
|
29
|
+
- database-exists?
|
|
30
|
+
- datoms (returns a seq of datoms as maps)
|
|
31
|
+
- db
|
|
32
|
+
- db-with
|
|
33
|
+
- delete-database
|
|
34
|
+
- entity (returns a simple map without further functionality)
|
|
35
|
+
- history
|
|
36
|
+
- metrics
|
|
37
|
+
- pull
|
|
38
|
+
- pull-many
|
|
39
|
+
- q
|
|
40
|
+
- release-db (release the DB-object to free memory)
|
|
41
|
+
- since
|
|
42
|
+
- schema
|
|
43
|
+
- transact (returns the transaction-report as map)
|
|
44
|
+
- with-db (a macro that avoids storing the DB-object)
|
|
45
|
+
|
|
46
|
+
## Example usage
|
|
47
|
+
|
|
48
|
+
```clojure
|
|
49
|
+
(ns pod
|
|
50
|
+
(:require [babashka.pods :as pods]))
|
|
51
|
+
|
|
52
|
+
(pods/load-pod 'replikativ/datahike "CURRENT") ;; Check https://github.com/babashka/pod-registry for latest version
|
|
53
|
+
|
|
54
|
+
(require '[datahike.pod :as d])
|
|
55
|
+
|
|
56
|
+
(def config {:store {:backend :file
|
|
57
|
+
:path "/tmp/bb-datahike-pod"}
|
|
58
|
+
:keep-history? true
|
|
59
|
+
:schema-flexibility :read})
|
|
60
|
+
|
|
61
|
+
(d/delete-database config)
|
|
62
|
+
|
|
63
|
+
(d/create-database config)
|
|
64
|
+
|
|
65
|
+
(def conn (d/connect config))
|
|
66
|
+
|
|
67
|
+
(d/transact conn [{:name "Alice", :age 20}
|
|
68
|
+
{:name "Bob", :age 30}
|
|
69
|
+
{:name "Charlie", :age 40}
|
|
70
|
+
{:age 15}])
|
|
71
|
+
|
|
72
|
+
(def db (d/db conn))
|
|
73
|
+
|
|
74
|
+
(d/q '[:find ?e ?n ?a
|
|
75
|
+
:where
|
|
76
|
+
[?e :name ?n]
|
|
77
|
+
[?e :age ?a]]
|
|
78
|
+
db)
|
|
79
|
+
|
|
80
|
+
(release-db db)
|
|
81
|
+
|
|
82
|
+
(d/pull (d/db conn) '[*] 3)
|
|
83
|
+
|
|
84
|
+
(with-db [db (db conn)]
|
|
85
|
+
(q {:query '{:find [?e ?a ?v]
|
|
86
|
+
:where
|
|
87
|
+
[[?e ?a ?v]]}}
|
|
88
|
+
db))
|
|
89
|
+
```
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# Benchmarking Datahike
|
|
2
|
+
|
|
3
|
+
There is a small command line utility integrated in this project to measure the performance of our *in-memory* and our *file* backend. It is also capable of comparing benchmarking results.
|
|
4
|
+
|
|
5
|
+
To run the benchmarks, navigate to the project folder in your console and run
|
|
6
|
+
```bash
|
|
7
|
+
clj -M:benchmark CMD [OPTIONS] [FILEPATHS]
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The command can either be `run` or `compare`.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Running Benchmarks
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
clj -M:benchmark run [OPTIONS] [OUTPUTFILEPATH]+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
|
|
21
|
+
| Short | Long | Description | Default |
|
|
22
|
+
|:-----:|---------------------------|------------------------------------------------------------------------|---------------|
|
|
23
|
+
| -u | --db-server-url URL | Base URL for datahike server for benchmark output. | |
|
|
24
|
+
| -n | --db-name DBNAME | Database name for datahike server for benchmark output. | |
|
|
25
|
+
| -g | --db-token TOKEN | Token for datahike server for benchmark output. | |
|
|
26
|
+
| -t | --tag TAG | Add tag to measurements; multiple tags possible. | `#{}` |
|
|
27
|
+
| -o | --output-format FORMAT | Short form of output format to use. | `edn` |
|
|
28
|
+
| -c | --config-name CONFIGNAME | Name of database configuration to use. | (all) |
|
|
29
|
+
| -d | --db-entity-counts VECTOR | Numbers of entities in database for which benchmarks should be run. | `[0 1000]` |
|
|
30
|
+
| -x | --tx-entity-counts VECTOR | Numbers of entities in transaction for which benchmarks should be run. | `[0 1000]` |
|
|
31
|
+
| -y | --data-types TYPEVECTOR | Vector of data types to test queries on. | `[:int :str]` |
|
|
32
|
+
| -z | --data-found-opts OPTS | Run query for existent or nonexistent values in the database. | `:all` |
|
|
33
|
+
| -i | --iterations ITERATIONS | Number of iterations of each measurement. | `10` |
|
|
34
|
+
| -f | --function FUNCTIONNAME | Name of function to test. | (all) |
|
|
35
|
+
| -q | --query QUERYNAME | Name of query to test. | (all) |
|
|
36
|
+
| -h | --help | Show help screen for tool usage. | |
|
|
37
|
+
|
|
38
|
+
### Examples
|
|
39
|
+
|
|
40
|
+
1) Benchmark *connection* time for databases with *1000 entities* (= 4000 datoms) and *file* backend with tag *feature* and output as *edn*
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
TIMBRE_LEVEL=':warn' clj -M:benchmark run -f :connection -d '[1000]' -c file -t feature -o edn feature.edn
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
2) Benchmark *transaction* time for *integer* datoms and 10 entities (= 40 datoms) per transaction using *memory* backend and output as csv
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
TIMBRE_LEVEL=':warn' clj -M:benchmark run -f :transaction -y '[:int]' -x '[10]' -c mem-set -o csv feature.csv
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
3) Benchmark *query* time for a *simple query* for all backends, for every configuration run the query *10 times* and take the average time
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
TIMBRE_LEVEL=':warn' clj -M:benchmark run -f :query -q :simple-query -i 10
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Possible Options
|
|
59
|
+
|
|
60
|
+
#### Database Configurations (-c)
|
|
61
|
+
|
|
62
|
+
Options for `-c`:
|
|
63
|
+
- `mem-set` for in-memory database with persistent-set index
|
|
64
|
+
- `mem-hht` for in-memory database with hitchhiker-tree index
|
|
65
|
+
- `file-set` for database with file store backend and persistent-set index
|
|
66
|
+
- `file-hht` for database with file store backend and hitchhiker-tree index
|
|
67
|
+
|
|
68
|
+
Implementations:
|
|
69
|
+
|
|
70
|
+
```clojure
|
|
71
|
+
(def db-configs
|
|
72
|
+
[{:config-name "mem-set"
|
|
73
|
+
:config {:store {:backend :memory :id #uuid "550e8400-e29b-41d4-a716-446655440000"}
|
|
74
|
+
:schema-flexibility :write
|
|
75
|
+
:keep-history? false
|
|
76
|
+
:index :datahike.index/persistent-set}}
|
|
77
|
+
{:config-name "mem-hht"
|
|
78
|
+
:config {:store {:backend :memory :id #uuid "550e8400-e29b-41d4-a716-446655440001"}
|
|
79
|
+
:schema-flexibility :write
|
|
80
|
+
:keep-history? false
|
|
81
|
+
:index :datahike.index/hitchhiker-tree}}
|
|
82
|
+
{:config-name "file-set"
|
|
83
|
+
:config {:store {:backend :file
|
|
84
|
+
:path "/tmp/performance-set"
|
|
85
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440002"}
|
|
86
|
+
:schema-flexibility :write
|
|
87
|
+
:keep-history? false
|
|
88
|
+
:index :datahike.index/persistent-set}}
|
|
89
|
+
{:config-name "file-hht"
|
|
90
|
+
:config {:store {:backend :file
|
|
91
|
+
:path "/tmp/performance-hht"
|
|
92
|
+
:id #uuid "550e8400-e29b-41d4-a716-446655440003"}
|
|
93
|
+
:schema-flexibility :write
|
|
94
|
+
:keep-history? false
|
|
95
|
+
:index :datahike.index/hitchhiker-tree}}])
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Tested Functions (-f)
|
|
99
|
+
|
|
100
|
+
Options for `-f`:
|
|
101
|
+
|
|
102
|
+
- `:connection`: Testing `datahike/connect`. Run can be configured via options `-c`, `-d`, `-i`
|
|
103
|
+
- `:transaction`: Testing `datahike/transact`. Run can be configured via options `-c`, `-d`, `-x`, `-i`
|
|
104
|
+
- `:query`: Testing `datahike/q`. Run can be configured via options `-c`, `-d`, `-y`, `-z`, `-i`, `-q`
|
|
105
|
+
|
|
106
|
+
#### Data Types (-z)
|
|
107
|
+
|
|
108
|
+
Used for query functions
|
|
109
|
+
|
|
110
|
+
Options for `-z`:
|
|
111
|
+
- `:int` for datatype `long`
|
|
112
|
+
- `:str` for data type `String`
|
|
113
|
+
|
|
114
|
+
#### Queries (-q)
|
|
115
|
+
|
|
116
|
+
Options for `-q`:
|
|
117
|
+
|
|
118
|
+
- Simple query: `:simple-query`
|
|
119
|
+
- Join queries: `:e-join-query` `:e-join-query-first-fixed` `:e-join-query-second-fixed` `:a-join-query` `:v-join-query`
|
|
120
|
+
- Predicate queries: `:equals-query` `:equals-query-1-fixed` `:less-than-query` `:less-than-query-1-fixed`
|
|
121
|
+
- Queries using arguments from bindings: `:scalar-arg-query` `:scalar-arg-query-with-join` `:vector-arg-query`
|
|
122
|
+
- Aggregate queries: `:stddev-query` `:variance-query` `:max-query` `:median-query` `:avg-query`
|
|
123
|
+
- Cache check queries: `:simple-query-first-run` `:simple-query-second-run`
|
|
124
|
+
|
|
125
|
+
If applicable, the queries are run for each different implemented data type, for data in the database and data not in the database.
|
|
126
|
+
|
|
127
|
+
##### Simple Query
|
|
128
|
+
|
|
129
|
+
Implementation:
|
|
130
|
+
|
|
131
|
+
```clojure
|
|
132
|
+
(defn simple-query [db attr val]
|
|
133
|
+
{:query (conj '[:find ?e :where]
|
|
134
|
+
(conj '[?e] attr val))
|
|
135
|
+
:args [db]})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
##### Join Queries
|
|
139
|
+
|
|
140
|
+
Implementation:
|
|
141
|
+
|
|
142
|
+
```clojure
|
|
143
|
+
(defn e-join-query [db attr1 attr2]
|
|
144
|
+
{:query (conj '[:find ?e :where]
|
|
145
|
+
(conj '[?e] attr1 '?v1)
|
|
146
|
+
(conj '[?e] attr2 '?v2))
|
|
147
|
+
:args [db]})
|
|
148
|
+
|
|
149
|
+
(defn a-join-query [db attr]
|
|
150
|
+
{:query (conj '[:find ?v1 ?v2 :where]
|
|
151
|
+
(conj '[?e1] attr '?v1)
|
|
152
|
+
(conj '[?e2] attr '?v2))
|
|
153
|
+
:args [db]})
|
|
154
|
+
|
|
155
|
+
(defn v-join-query [db attr1 attr2]
|
|
156
|
+
{:query (conj '[:find ?e1 ?e2 :where]
|
|
157
|
+
(conj '[?e1] attr1 '?v)
|
|
158
|
+
(conj '[?e2] attr2 '?v))
|
|
159
|
+
:args [db]})
|
|
160
|
+
|
|
161
|
+
(defn e-join-query-first-fixed [db attr1 val1 attr2]
|
|
162
|
+
{:query (conj '[:find ?v2 :where]
|
|
163
|
+
(conj '[?e] attr1 val1)
|
|
164
|
+
(conj '[?e] attr2 '?v2))
|
|
165
|
+
:args [db]})
|
|
166
|
+
|
|
167
|
+
(defn e-join-query-second-fixed [db attr1 attr2 val2]
|
|
168
|
+
{:query (conj '[:find ?v1 :where]
|
|
169
|
+
(conj '[?e] attr1 '?v1)
|
|
170
|
+
(conj '[?e] attr2 val2))
|
|
171
|
+
:args [db]})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
##### Predicate Queries
|
|
175
|
+
|
|
176
|
+
Implementation:
|
|
177
|
+
|
|
178
|
+
```clojure
|
|
179
|
+
(defn less-than-query [db attr]
|
|
180
|
+
{:query (conj '[:find ?e1 ?e2 :where]
|
|
181
|
+
(conj '[?e1] attr '?v1)
|
|
182
|
+
(conj '[?e2] attr '?v2)
|
|
183
|
+
'[(< ?v1 ?v2)])
|
|
184
|
+
:args [db]})
|
|
185
|
+
|
|
186
|
+
(defn equals-query [db attr]
|
|
187
|
+
{:query (conj '[:find ?e1 ?e2 :where]
|
|
188
|
+
(conj '[?e1] attr '?v1)
|
|
189
|
+
(conj '[?e2] attr '?v2)
|
|
190
|
+
'[(= ?v1 ?v2)])
|
|
191
|
+
:args [db]})
|
|
192
|
+
|
|
193
|
+
(defn less-than-query-1-fixed [db attr comp-val]
|
|
194
|
+
{:query (conj '[:find ?e :where]
|
|
195
|
+
(conj '[?e] attr '?v)
|
|
196
|
+
(conj '[]
|
|
197
|
+
(sequence (conj '[= ?v] comp-val))))
|
|
198
|
+
:args [db]})
|
|
199
|
+
|
|
200
|
+
(defn equals-query-1-fixed [db attr comp-val]
|
|
201
|
+
{:query (conj '[:find ?e :where]
|
|
202
|
+
(conj '[?e] attr '?v)
|
|
203
|
+
(conj '[]
|
|
204
|
+
(sequence (conj '[= ?v] comp-val))))
|
|
205
|
+
:args [db]})
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
##### Binding Queries
|
|
209
|
+
|
|
210
|
+
Implementation:
|
|
211
|
+
|
|
212
|
+
```clojure
|
|
213
|
+
(defn scalar-arg-query [db attr val]
|
|
214
|
+
{:query (conj '[:find ?e
|
|
215
|
+
:in $ ?v
|
|
216
|
+
:where]
|
|
217
|
+
(conj '[?e] attr '?v))
|
|
218
|
+
:args [db val]})
|
|
219
|
+
|
|
220
|
+
(defn scalar-arg-query-with-join [db attr val]
|
|
221
|
+
{:query (conj '[:find ?e1 ?e2 ?v2
|
|
222
|
+
:in $ ?v1
|
|
223
|
+
:where]
|
|
224
|
+
(conj '[?e1] attr '?v1)
|
|
225
|
+
(conj '[?e2] attr '?v2))
|
|
226
|
+
:args [db val]})
|
|
227
|
+
|
|
228
|
+
(defn vector-arg-query [db attr vals]
|
|
229
|
+
{:query (conj '[:find ?e
|
|
230
|
+
:in $ ?v
|
|
231
|
+
:where]
|
|
232
|
+
(conj '[?e] attr '?v))
|
|
233
|
+
:args [db vals]})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
##### Aggregate Queries
|
|
237
|
+
Only run for data type `:int`.
|
|
238
|
+
|
|
239
|
+
```clojure
|
|
240
|
+
[{:function :sum-query
|
|
241
|
+
:query {:query '[:find (sum ?x)
|
|
242
|
+
:in [?x ...]]
|
|
243
|
+
:args [(repeatedly (count entities) #(rand-int 100))]}}
|
|
244
|
+
|
|
245
|
+
{:function :avg-query
|
|
246
|
+
:query {:query '[:find (avg ?x)
|
|
247
|
+
:in [?x ...]]
|
|
248
|
+
:args [(repeatedly (count entities) #(rand-int 100))]}}
|
|
249
|
+
|
|
250
|
+
{:function :median-query
|
|
251
|
+
:query {:query '[:find (median ?x)
|
|
252
|
+
:in [?x ...]]
|
|
253
|
+
:args [(repeatedly (count entities) #(rand-int 100))]}}
|
|
254
|
+
{:function :variance-query
|
|
255
|
+
:query {:query '[:find (variance ?x)
|
|
256
|
+
:in [?x ...]]
|
|
257
|
+
:args [(repeatedly (count entities) #(rand-int 100))]}}
|
|
258
|
+
|
|
259
|
+
{:function :stddev-query
|
|
260
|
+
:query {:query '[:find (stddev ?x)
|
|
261
|
+
:in [?x ...]]
|
|
262
|
+
:args [(repeatedly (count entities) #(rand-int 100))]}}
|
|
263
|
+
|
|
264
|
+
{:function :max-query
|
|
265
|
+
:query {:query '[:find (max ?x)
|
|
266
|
+
:in [?x ...]]
|
|
267
|
+
:args [(repeatedly (count entities) #(rand-int 100))]}}]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
##### Cache check queries
|
|
271
|
+
|
|
272
|
+
Simple query with exact same configuration run twice. Identifiers are `:simple-query-first-run` for the first time it is run and `:simple-query-second-run` for the second run.
|
|
273
|
+
|
|
274
|
+
### Output Configuration
|
|
275
|
+
|
|
276
|
+
*Formats:*
|
|
277
|
+
- `remote-db`; using an instance of datahike-server to upload the results. The server configuration iscontrolled by options -u -n and -g
|
|
278
|
+
- `edn`
|
|
279
|
+
- `csv`
|
|
280
|
+
|
|
281
|
+
If an output filename is given the result is saved in a file instead of printed to stdout.
|
|
282
|
+
|
|
283
|
+
The edn output will look as follows:
|
|
284
|
+
|
|
285
|
+
```clojure
|
|
286
|
+
[ ;; ...
|
|
287
|
+
{:context {:dh-config {:schema-flexibility :write,
|
|
288
|
+
:keep-history? false,
|
|
289
|
+
:index :datahike.index/persistent-set,
|
|
290
|
+
:name "mem-set",
|
|
291
|
+
:backend :memory},
|
|
292
|
+
:function :vector-arg-query,
|
|
293
|
+
:db-entities 2500,
|
|
294
|
+
:db-datoms 10000,
|
|
295
|
+
:execution {:data-type :int,
|
|
296
|
+
:data-in-db? true}},
|
|
297
|
+
:time {:mean 0.17954399999999998,
|
|
298
|
+
:median 0.172268,
|
|
299
|
+
:std 0.02388124449855995,
|
|
300
|
+
:count 10,
|
|
301
|
+
:observations [0.173015 0.168094 0.174449 0.250349 0.169847 0.168364 0.168926 0.169352 0.172268 0.180776]},
|
|
302
|
+
:tag "bind-collection-bounds-opt"}
|
|
303
|
+
;; ...
|
|
304
|
+
]
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
## Comparing Benchmarks
|
|
309
|
+
|
|
310
|
+
Usage:
|
|
311
|
+
```bash
|
|
312
|
+
clj -A:benchmark compare [-p] [FILEPATHS]*
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The comparison tool gives the option to *compare any number of benchmarking results* using
|
|
316
|
+
a) textual *table* format (default) or
|
|
317
|
+
b) *plots* (if command line option `-p` has been given).
|
|
318
|
+
|
|
319
|
+
Please note:
|
|
320
|
+
1) At the moment the comparison tool can only *handle edn files* as input, so be aware of that and run the benchmarks with `--output edn` when you are planning to use this tool later.
|
|
321
|
+
2) Use *different tags* for the benchmarks you want to compare since the comparison tool assumes measurements with the same tag to belong to the same group of measurements.
|
|
322
|
+
|
|
323
|
+
Example for comparison table:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
clj -A:benchmark compare benchmarks1.edn benchmarks2.edn
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Example for comparison plots:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
clj -A:benchmark compare -p benchmarks1.edn benchmarks2.edn
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
The plots produced are scatter plots of the results combined with line plots using the median of the values for a measurement point.
|
|
336
|
+
|
|
337
|
+
If you want to see plots for a single benchmarking result, nothing keeps you from using the comparison tool on a single file.
|
|
338
|
+
|
|
339
|
+
### Measuring Performance Changes During Development
|
|
340
|
+
|
|
341
|
+
The comparison tool has proven valuable to our team for comparing different branches of the datahike project to detect performance regressions or improvements.
|
|
342
|
+
|
|
343
|
+
Workflow:
|
|
344
|
+
|
|
345
|
+
1) Run the benchmarks on the branch you are forking from with the option `--output edn` giving it an expressive tag, e.g. the name of the branch:
|
|
346
|
+
```bash
|
|
347
|
+
git checkout development
|
|
348
|
+
clj -A:benchmark run -t development -o edn development.edn
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
2) Run the benchmarks on your feature branch with the option `--output edn` giving it a tag, e.g. the name of your new feature:
|
|
352
|
+
```bash
|
|
353
|
+
git checkout feature
|
|
354
|
+
clj -A:benchmark run -t feature -o edn feature.edn
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
3) Run the comparison tool on any branch giving both of the previous output files as input:
|
|
358
|
+
```bash
|
|
359
|
+
clj -A:benchmark compare -p development.edn feature.edn
|
|
360
|
+
```
|