-
Notifications
You must be signed in to change notification settings - Fork 9
Questions (re. interop with indexed.el) #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure what you mean by "incrementally"; in order to init the database every file you want needs to be parsed, but this process also notes the hash so that subsequent updates only consider files that have changed (ie have different hashes). The parser is basically just The short answer is they go in the properties table so the query would just be What happens after that would be up to you, since the output will just be a string. In the case of No, except for whatever I described here. There would probably just need to be a new table for keywords, since everything else is captured somewhere unless I missed something. Use case being to store the files not as raw text on disk but in a db instead? I haven't considered this since that wasn't the intended use case. I suppose it wouldn't be that hard to add if you wanted, and for those who don't need it then there would just be a column filled with NULL in the db. |
Re. multivalued properties. I'm not a huge SQL user, at all, so I may be sailing the wrong direction entirely. But to explain my idea. Let's say we have an Org entry that looks like
Now you see those properties have to be treated differently. So my idea of a (defvar splitters-alist
'(("ROAM_ALIASES" . split-string-and-unquote)
("ROAM_REFS" . indexed-roam-split-refs-field)
("CREATED" . list))
"Alist specifying how to split a property value.
Elements are (PROPERTY-NAME . SPLITTER), where:
- PROPERTY-NAME is a string in all-uppercase.
- SPLITTER is a function taking one string argument that is the whole
value of a property, and should return a list of strings.
Properties not in this list use the default splitter:
`split-like-official-org'.")
(defun split-like-official-org (value)
"Split VALUE the same way as `org-entry-get-multivalued-property'."
(mapcar #'org-entry-restore-space (split-string value)))
(defvar all-properties-ever (make-hash-table :test 'equal))
(dolist (entry (SOME-QUERY-GETTING-ALL-ENTRIES))
(cl-loop
for (name . value) in (entry-properties entry)
do (dolist (atom (funcall (or (cdr (assoc name splitters-alist))
#'split-like-official-org)
value))
(push (list id atom)
(gethash (downcase name) all-properties-ever))))) Now `all-properties-ever' is a table that looks like e.g.
which could then be used for CREATE TABLE queries. You'd perhaps have them auto-named as I figured that this would make it easier to write pure SQL queries like
(never mind the ugly method of date comparison, one could conceive of a splitter that transforms the date into something more suitable, but that's for another time) |
It sounds like what you really want is a way to store all possible values of a property ever seen in/across org files. The only difference with this and what I currently do with
If it were me I would make two tables for keys and values. Something like:
Then query like Making new tables for each property doesn't seem necessary or advantageous. It also has lots of problems (the schema is undefined, unclear how foreign keys would work, hard to predict which tables to query, performance, different permissions, etc). Its true you wouldn't necessarily know the property key/value pairs without querying the database initially, but this is easy: Does this all make sense? |
Uh oh!
There was an error while loading. Please reload this page.
Hi! I recently wrote the library https://github.com/meedstrom/indexed. Afterwards, I began considering how to design an all-new DB, and glad to see prior art here!
It seems great if I can make Indexed just copy the org-sql schemata, so we have interop.
Some questions if you don't mind:
org-element-parse-buffer
and therefore org-mode itself, but I could be wrong and you managed to optimize it.[2020-12-31 Wed 15:00]
?org-entry-get-multivalued-property
. There exist other properties that must be split in a different way. ROAM_ALIASES is split withsplit-string-and-unquote
; and ROAM_REFS is even more complicated - I have a function for that called indexed-roam-split-refs-field.The text was updated successfully, but these errors were encountered: