Compare commits

..

No commits in common. "e1e83b42da04fa9a83bee54d4c54f2495740ba9f" and "f32acdc8dab364e814eec680d2b8210c0228436d" have entirely different histories.

4 changed files with 3 additions and 536 deletions

410
package-lock.json generated
View File

@ -1,416 +1,8 @@
{ {
"name": "jeremy-website", "name": "jeremy-website",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 2, "lockfileVersion": 1,
"requires": true, "requires": true,
"packages": {
"": {
"name": "jeremy-website",
"version": "1.0.0",
"dependencies": {
"moment": "^2.29.1",
"moment-timezone": "^0.5.32",
"obelix-plugin-excerpt": "^2.0.0",
"obelix-plugin-typography": "^1.0.2",
"typography-theme-moraga": "^0.16.19"
}
},
"node_modules/acorn": {
"version": "6.4.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/boolbase": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
},
"node_modules/cheerio": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.22.0.tgz",
"integrity": "sha1-qbqoYKP5tZWmuBsahocxIe06Jp4=",
"dependencies": {
"css-select": "~1.2.0",
"dom-serializer": "~0.1.0",
"entities": "~1.1.1",
"htmlparser2": "^3.9.1",
"lodash.assignin": "^4.0.9",
"lodash.bind": "^4.1.4",
"lodash.defaults": "^4.0.1",
"lodash.filter": "^4.4.0",
"lodash.flatten": "^4.2.0",
"lodash.foreach": "^4.3.0",
"lodash.map": "^4.4.0",
"lodash.merge": "^4.4.0",
"lodash.pick": "^4.2.1",
"lodash.reduce": "^4.4.0",
"lodash.reject": "^4.4.0",
"lodash.some": "^4.4.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/compass-vertical-rhythm": {
"version": "1.4.5",
"resolved": "https://registry.npmjs.org/compass-vertical-rhythm/-/compass-vertical-rhythm-1.4.5.tgz",
"integrity": "sha512-bJo3IYX7xmmZCDYjrT2XolaiNjGZ4E2JvUGxpdU0ecbH4ZLK786wvc8aHKVrGrKct9JlkmJbUi8YLrQWvOc+uA==",
"dependencies": {
"convert-css-length": "^1.0.1",
"object-assign": "^4.1.0",
"parse-unit": "^1.0.1"
}
},
"node_modules/console-polyfill": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/console-polyfill/-/console-polyfill-0.1.2.tgz",
"integrity": "sha1-ls/tUcr3gYn2mVcubxgnHcN8DjA="
},
"node_modules/convert-css-length": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/convert-css-length/-/convert-css-length-1.0.2.tgz",
"integrity": "sha512-ecV7j3hXyXN1X2XfJBzhMR0o1Obv0v3nHmn0UiS3ACENrzbxE/EknkiunS/fCwQva0U62X1GChi8GaPh4oTlLg==",
"dependencies": {
"console-polyfill": "^0.1.2",
"parse-unit": "^1.0.1"
}
},
"node_modules/css-select": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz",
"integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=",
"dependencies": {
"boolbase": "~1.0.0",
"css-what": "2.1",
"domutils": "1.5.1",
"nth-check": "~1.0.1"
}
},
"node_modules/css-what": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz",
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==",
"engines": {
"node": "*"
}
},
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/dom-serializer": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz",
"integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==",
"dependencies": {
"domelementtype": "^1.3.0",
"entities": "^1.1.1"
}
},
"node_modules/domelementtype": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz",
"integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w=="
},
"node_modules/domhandler": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz",
"integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==",
"dependencies": {
"domelementtype": "1"
}
},
"node_modules/domutils": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
"integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=",
"dependencies": {
"dom-serializer": "0",
"domelementtype": "1"
}
},
"node_modules/entities": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz",
"integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w=="
},
"node_modules/excerpt-html": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/excerpt-html/-/excerpt-html-1.2.1.tgz",
"integrity": "sha512-T/D/LpQrvw/dTnlfbDV5ZAuaIZsuR8SYdW1xBHeUoMCKPfTbO2yfjdrakmAMdrrkLRlWuXVlJloY3nP/WDAHMg==",
"dependencies": {
"acorn": "^6.0.5",
"cheerio": "^0.22.0",
"he": "^1.1.0",
"lodash.truncate": "^4.3.0",
"striptags": "^2.2.1"
}
},
"node_modules/gray-percentage": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/gray-percentage/-/gray-percentage-2.0.0.tgz",
"integrity": "sha1-tyonTRsTeRBKAFC2OyB9xT/lb5k="
},
"node_modules/he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"bin": {
"he": "bin/he"
}
},
"node_modules/htmlparser2": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz",
"integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==",
"dependencies": {
"domelementtype": "^1.3.1",
"domhandler": "^2.3.0",
"domutils": "^1.5.1",
"entities": "^1.1.1",
"inherits": "^2.0.1",
"readable-stream": "^3.1.1"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/lodash": {
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
},
"node_modules/lodash.assignin": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz",
"integrity": "sha1-uo31+4QesKPoBEIysOJjqNxqKKI="
},
"node_modules/lodash.bind": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/lodash.bind/-/lodash.bind-4.2.1.tgz",
"integrity": "sha1-euMBfpOWIqwxt9fX3LGzTbFpDTU="
},
"node_modules/lodash.defaults": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
"integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw="
},
"node_modules/lodash.filter": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz",
"integrity": "sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4="
},
"node_modules/lodash.flatten": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
"integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8="
},
"node_modules/lodash.foreach": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz",
"integrity": "sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM="
},
"node_modules/lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
},
"node_modules/lodash.map": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz",
"integrity": "sha1-dx7Hg540c9nEzeKLGTlMNWL09tM="
},
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
"node_modules/lodash.pick": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz",
"integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM="
},
"node_modules/lodash.reduce": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
},
"node_modules/lodash.reject": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.reject/-/lodash.reject-4.6.0.tgz",
"integrity": "sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU="
},
"node_modules/lodash.some": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz",
"integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0="
},
"node_modules/lodash.truncate": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz",
"integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM="
},
"node_modules/modularscale": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/modularscale/-/modularscale-1.0.2.tgz",
"integrity": "sha1-So8TrzKl5SFPxuLPxSkGSr/X2Hc=",
"dependencies": {
"lodash.isnumber": "^3.0.0"
}
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
},
"node_modules/moment-timezone": {
"version": "0.5.32",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.32.tgz",
"integrity": "sha512-Z8QNyuQHQAmWucp8Knmgei8YNo28aLjJq6Ma+jy1ZSpSk5nyfRT8xgUbSQvD2+2UajISfenndwvFuH3NGS+nvA==",
"dependencies": {
"moment": ">= 2.9.0"
},
"engines": {
"node": "*"
}
},
"node_modules/nth-check": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
"integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==",
"dependencies": {
"boolbase": "~1.0.0"
}
},
"node_modules/obelix-plugin-excerpt": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/obelix-plugin-excerpt/-/obelix-plugin-excerpt-2.0.0.tgz",
"integrity": "sha512-IrGAyLSBdciHaanA1MBTtS2TA+xjxcvmfS2ZUyp6fQwcC42mFP3nQfNplmemSG4/Ez1ecvKeqSkkTJNf69sOoA==",
"dependencies": {
"excerpt-html": "^1.2.1"
}
},
"node_modules/obelix-plugin-typography": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/obelix-plugin-typography/-/obelix-plugin-typography-1.0.2.tgz",
"integrity": "sha512-F/jD7GsZwws4Pcfe77A9HoMl95JVjwUl/v5A+NoKyMzVO8acFI9NV2W7YSOOG+cpjTqxP0u9+X0Xc4QbQW4QvQ==",
"dependencies": {
"typography": "^0.16.19"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/parse-unit": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parse-unit/-/parse-unit-1.0.1.tgz",
"integrity": "sha1-fhu21b7zh0wo45JSaiVBFwKR7s8="
},
"node_modules/readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"dependencies": {
"safe-buffer": "~5.2.0"
}
},
"node_modules/striptags": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/striptags/-/striptags-2.2.1.tgz",
"integrity": "sha1-TEULcI1BuL85zyTEn/I0/Gqr/TI="
},
"node_modules/typography": {
"version": "0.16.19",
"resolved": "https://registry.npmjs.org/typography/-/typography-0.16.19.tgz",
"integrity": "sha512-zfsyjPPB1RaK8TzU3REta6EGDZa++YQ6g/CWw7hy/8xQK1qyzFWisMIw5J+Yg1KyiVgcchmxlgMcMA6JAJ9oew==",
"dependencies": {
"compass-vertical-rhythm": "^1.4.5",
"decamelize": "^1.2.0",
"gray-percentage": "^2.0.0",
"lodash": "^4.13.1",
"modularscale": "^1.0.2",
"object-assign": "^4.1.0",
"typography-normalize": "^0.16.19"
}
},
"node_modules/typography-breakpoint-constants": {
"version": "0.16.19",
"resolved": "https://registry.npmjs.org/typography-breakpoint-constants/-/typography-breakpoint-constants-0.16.19.tgz",
"integrity": "sha512-vXjfV9hwAXIOf5+U5GN137ahBkK+sj1TJu/5ksmP+8XB/D80lmGb/m0nKviWaQ3t7HLrK848VGrFS+6E2vcmVg=="
},
"node_modules/typography-normalize": {
"version": "0.16.19",
"resolved": "https://registry.npmjs.org/typography-normalize/-/typography-normalize-0.16.19.tgz",
"integrity": "sha512-vtnSv/uGBZVbd4e/ZhZB9HKBgKKlWQUXw74+ADIHHxzKp27CEf8PSR8TX1zF2qSyQ9/qMdqLwXYz8yRQFq9JLQ=="
},
"node_modules/typography-theme-moraga": {
"version": "0.16.19",
"resolved": "https://registry.npmjs.org/typography-theme-moraga/-/typography-theme-moraga-0.16.19.tgz",
"integrity": "sha512-POIMoW6xqRTGeBtT0cbrrzL+eKj7Z+A+Wzu5kvtgJFY7lZ7KA9TcJBB2YuspLd2yHq5YMxiUBDQiHedb19ttww==",
"dependencies": {
"compass-vertical-rhythm": "^1.2.1",
"gray-percentage": "^2.0.0",
"typography-breakpoint-constants": "^0.16.19"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
}
},
"dependencies": { "dependencies": {
"acorn": { "acorn": {
"version": "6.4.2", "version": "6.4.2",

View File

@ -27,7 +27,7 @@
{{{ content }}} {{{ content }}}
</main> </main>
<footer> <footer>
© Jeremy Dormitzer 2020 - 2021 © Jeremy Dormitzer 2020
</footer> </footer>
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap" rel="stylesheet">

View File

@ -1,125 +0,0 @@
---
title: "State of unifyDB: 2021"
author: Jeremy Dormitzer
published: 2021-11-11
---
2021 is almost over! And it's been over a year since I've written anything about [my work-in-progress graph database unifyDB](./unifydb-dev-diary-0-intro.html). BUT just because I'm bad at blogging doesn't mean I haven't made any progress. In fact, a bunch of exciting stuff happened for unifyDB in 2021, and I'm going to info-dump it all on you 🙃.
## Aggregation, sorting and limiting
This one was really exciting, as it marked a huge step towards making unifyDB truly useful. I added the ability to aggregate, sort, and limit query results. Here's what the syntax looks like:
```clojure
{:find [?role (min ?age)]
:where [[_ :employee/role ?role]
[_ :employee/age ?age]]
:sort-by [(min ?age) :desc]
:limit 5}
```
Aggregate expressions appear in parentheses (like a function call) in the find clause - the `(min ?age)` in this example. This query will return five biggest minimum ages for every job role in a database of employee data.
One feature of this system I'm particularly proud of is implicit grouping. Take a look at that find clause again: `[?role (min ?age)]`. We are asking for both a non-aggregated variable, `?role`, and an aggregated one `?age`. In a SQL query, we'd need to specify how construct groups of roles before we can find the minimum age of each group using a `GROUP BY` clause:
```sql
SELECT role, min(age)
FROM employees
GROUP BY role
```
The unifydDB query engine is smart enough to figure out that we need to group the result set by `role` before finding the minimum age of each group. If we add additional scalar or aggregate variables in the find clause, the query engine will automatically construct the appropriate groups such that all scalar variables have single values in each group.
## Entity-level transactions and "pull" queries
unifyDB is technically a tuplestore - that is, its core unit of data is a "fact" tuple consisting of `[entity attribute value]` pairs. An entity is therefore represented as a set of data tuples:
```clojure
[[1 :name "Ben Bitdiddle"]
[1 :age 43]
[1 :role "Software Engineer"]]
```
This data format makes unifyDB highly flexible, able to answer not only questions about entities ("who has the software engineer role") but also questions about attributes ("what's the median age across all employees") and values. However, this flexibility comes at a cost: most programs (and programmers!) think in terms of entities. They talk about data shaped more like this:
```clojure
{:id 1
:name "Ben Bitdiddle"
:age 43
:role "Software Engineer"}
```
Requiring developers to transform entity-oriented data into fact-oriented data to fit unifyDB's internal data model imposes unnecessary cognitive load and violates one of unifyDB's core principles: meet the programmer where they are. In answer to this I added two features: entity transactions and "pull" queries.
Entity transactions allow data to enter the database in the shape of an entity map rather than as a set of facts. Here's how that looks:
```clojure
(transact! db
[{:unifydb/id "alyssa"
:name "Alyssa P. Hacker"
:age 37
:role {:title "Engineering Manager"
:salary 60000}}
{:unifydb/id "ben"
:name "Ben Bitdiddle"
:age 43
:supervisor "alyssa"
:role {:title "Software Engineer"
:salary 40000}}])
```
This transaction creates four new entities in the database: two employees and two roles (note the use of temporary IDs to map relationships between entities in the transaction). This transaction would expand to a set of facts that looks like this:
```clojure
[;; Alyssa
["alyssa" :name "Alyssa P. Hacker"]
["alyssa" :age 37]
["alyssa" :role "role1"]
;; Alyssa's role
["role1" :title "Engineering Manager"]
["role1" :salary 60000]
;; Ben
["ben" :name "Ben Bitdiddle"]
["ben" :age 43]
["ben" :supervisor "alyssa"]
["ben" :role "role2"]
;; Ben's role
["role2" :title "software Engineer"]
["role2" :salary 40000]]
```
This set of facts then gets transacted into the database normally, resolving the temporary ids (`"alyssa"`, `"ben"`, `"role1"`, `"role2"`) and making the facts available to be queried. As you can see, nested entities get flattened to be their own fact sets as well. This transformation maintains the flexibility of a fact-oriented data architecture while allowing developers to think in entity-oriented terms. And of course, for data that isn't inherently entity-oriented, raw fact tuples can still be transacted as usual.
On the query side, the new "pull" feature adds a similarly entity-oriented way to make queries. This feature adds new syntax to the find clause that allows users to specify the shape of data they want to return. It's probably easiest to understand with an example:
```clojure
{:find [(pull ?e [:name :age {:role [:title :salary]}])]
:where [[?e :name "Alyssa P. Hacker"]]}
```
Given the data used in the entity transaction example above, this query would return:
```clojure
[[{:name "Alyssa P. Hacker"
:age 37
:role {:title "Engineering Manager"
:salary 60000}}]]
```
Let's pull apart the pull syntax (heh, see what I did there?). A pull query is a list of attributes to return, with nested entities represented as sub-maps within the list. So the query `(pull ?e [:name :age {:role [:title :salary]}])` is asking for the `:name` and `:age` values for some entity `?e`, as well as the `:title` and `:salary` attributes of the entity whose id is the value of `?e`'s `:role` attribute. This system effectively separates the logic of finding the entity you want (in this case "the entity with `:name` `"Alyssa P. Hacker"`") from the logic of specifying which attributes of that entity you care about. This system also returns the data in the entity-oriented format that the rest of your program is already using.
Taken together, these two new features allow unifyDB to function as a document store in addition to its existing utility as a tuplestore. That's a huge boost for its use as a general-purpose application database.
## unifyDB presentation at Boston Clojure Meetup
I gave a talk on unifyDB for the [Boston Clojure Meetup](https://www.meetup.com/Boston-Clojure-Group/)! Due to my aforementioned lack of blogging, this is now the most in-depth look at the database available. I covered a brief history of the project, gave a demo of its capabilities at the time of recording, and answered some questions about the codebase. Do note that this was recorded before I added most of the features discussed in this post, so parts of the demo are slightly out of date. But on the whole it's still a worthwhile showcase of some of unifyDB's core features.
Here's the full recording:
<iframe style="margin: auto auto 2em auto;" width="560" height="315" src="https://www.youtube-nocookie.com/embed/hqQQyxeE-4Q" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
## What's next?
If you made it this far, thanks for sticking with me! I'm really excited about the improvements that came to unifyDB in 2021. But there's still quite a bit more to do before we can consider this thing released. In no particular order:
- the other flagship feature, built-in access management. Alongside historical queries (which is already implemented), this is the key problem I'm trying to solve with unifyDB. The access management feature will allow fine-grained access control, letting engineers enforce rules like "only authorized admins can see personally-identifying customer data" without needing to write custom code
- a built-in distributed key-value store. Right now unifyDB sits on top of existing key-value stores to provide the persistence layer. Before I consider this project finished it'll need to ship with a built-in distributed persistence layer
- codebase improvements: there are a number of changes I want to make to the existing codebase. On the top of this list is fixing my usage of the [Manifold](https://github.com/clj-commons/manifold) library - it provides a nice async abstraction layer but in many places I'm turning an async call into a blocking call by unwrapping a Manifold `deferred` instead of mapping over it. I'd also like to add better error handling and more end-to-end tests
Hopefully I'll be a bit more public with my development efforts in 2022. I'll try to post more frequent (and shorter!) blog posts. I'll also be posting more actively into the [#unifydb channel](https://clojurians.zulipchat.com/#narrow/stream/295957-unifydb) on the Clojurians Zulip chat, so check that out if you want to follow my progress.

View File

@ -47,7 +47,7 @@
</div> </div>
</main> </main>
<footer> <footer>
© Jeremy Dormitzer 2020 - 2021 © Jeremy Dormitzer 2020
</footer> </footer>
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap" rel="stylesheet">