notes:internals:trie
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| notes:internals:trie [2025/08/11 20:10] – created smj-edison | notes:internals:trie [2025/09/07 01:51] (current) – smj-edison | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Part 1: the Trie ===== | + | ===== The Trie ===== |
| - | A Trie is the data structure that underlies Folk's database. It is the index to all Wishes, Claims, and Whens. The Trie works by inserting and removing Clauses. A Clause is an array of space-seperated words, | + | A Trie is the data structure that underlies Folk's database. It is the database' |
| + | Let's look at an example Statement | ||
| - | Let's insert | + | Let's insert |
| {{notes: | {{notes: | ||
| - | As you can see, the Clause has been turned into a set of nodes in the Trie. Let's try inserting another Clause, "the sky has clouds": | + | As you can see, the Clause has been turned into a set of nodes in the Trie. |
| + | Let's try inserting another Clause, "the sky has clouds": | ||
| {{notes: | {{notes: | ||
| - | A Trie is just a tree, with each level being one word*. | + | As seen, a Trie is just a tree, with each successive Term placed |
| - | We've now covered inserting, but what about querying? Let's try querying for "the sky has clouds" | + | We've now covered inserting, but what about querying? Let's try querying |
| + | for "the sky has clouds" | ||
| {{notes: | {{notes: | ||
| Line 24: | Line 27: | ||
| {{notes: | {{notes: | ||
| - | Notice how we never had to check "blue", since that was on a separate branch of the Trie. When there' | + | It seems that "the sky has clouds" |
| + | Notice how we never had to check the Term " | ||
| + | When there' | ||
| + | it traverses. | ||
| - | * Technically, | + | There' |
| + | Let's look at the previous Trie example, but now with values: | ||
| + | {{notes: | ||
| + | |||
| + | If we to rerun the query "the sky has clouds", | ||
| + | also get the value " | ||
| + | |||
| + | === Footnotes === | ||
| + | * Technically, | ||
| + | not for each word. It makes more sense to be for each word in Folk though. | ||
notes/internals/trie.1754943029.txt.gz · Last modified: by smj-edison
