Triggers
This commit is contained in:
parent
876df62269
commit
37eed486c0
1 changed files with 18 additions and 6 deletions
|
@ -315,8 +315,11 @@ The above code presents the creation of a new index on the database
|
||||||
.I cars .
|
.I cars .
|
||||||
An index requires a name (a simple string), which simply is "name" in this case since the indexed value is the name of the cars.
|
An index requires a name (a simple string), which simply is "name" in this case since the indexed value is the name of the cars.
|
||||||
An index also requires a callback, a procedure to extract the value used for indexing.
|
An index also requires a callback, a procedure to extract the value used for indexing.
|
||||||
In this case, the procedure takes a car as a parameter and returns its "name" attribute.
|
In this case, the procedure takes a car as a parameter and returns its "name" attribute\*[*].
|
||||||
This procedure can be arbitrary complex and include any necessary data transformation.
|
.FOOTNOTE1
|
||||||
|
This procedure can be arbitrarily complex and include any necessary data transformation.
|
||||||
|
For example, the netlibre project (discussed later in the papper) indexes their users' email, but emails are first encoded in base64 to avoid messing around with the file-system.
|
||||||
|
.FOOTNOTE2
|
||||||
|
|
||||||
Once the index has been created, every inserted or modified entry in the database will be indexed.
|
Once the index has been created, every inserted or modified entry in the database will be indexed.
|
||||||
Adding a trigger provides an
|
Adding a trigger provides an
|
||||||
|
@ -390,8 +393,8 @@ end
|
||||||
# Shortcut:
|
# Shortcut:
|
||||||
cars_by_color = database.new_partition "color", &.color
|
cars_by_color = database.new_partition "color", &.color
|
||||||
.SOURCE
|
.SOURCE
|
||||||
.QE
|
|
||||||
As with basic indexes, once the partition is asked to the database, every new or modified entry will be indexed.
|
As with basic indexes, once the partition is asked to the database, every new or modified entry will be indexed.
|
||||||
|
.QE
|
||||||
|
|
||||||
.KS
|
.KS
|
||||||
Let's imagine having 3 cars, one is blue and the other two are red.
|
Let's imagine having 3 cars, one is blue and the other two are red.
|
||||||
|
@ -463,17 +466,26 @@ Listing all the fast cars is simple as running
|
||||||
in the
|
in the
|
||||||
.DIRECTORY db-cars/tags/by_keywords/fast
|
.DIRECTORY db-cars/tags/by_keywords/fast
|
||||||
directory!
|
directory!
|
||||||
|
And only a simple intersection of the files that are several directories is necessary to get cars which are both fast and cheap for example\*[*].
|
||||||
.QE
|
.QE
|
||||||
.KE
|
.KE
|
||||||
|
.FOOTNOTE1
|
||||||
|
A simple command is necessary to get cars that are both fast and cheap:
|
||||||
|
.br
|
||||||
|
.COMMAND "ls fast/* cheap/* | cut -f 2 -d '/' | sort | uniq -c | awk '{ print $1, $2 }' | grep ^2"
|
||||||
|
.br
|
||||||
|
This may appear barbaric for the unprepared mind, but this one-liner only includes basic commands most sysadmin understand and perhaps use daily.
|
||||||
|
Also, this can be as easily hidden in a very nice user-friendly command.
|
||||||
|
.FOOTNOTE2
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.SSS Side note about triggers
|
.SSS Side note about triggers
|
||||||
DODB presents a few possible triggers (basic indexes, partitions and tags) which respond to an obvious need for fast searches.
|
DODB presents a few possible triggers (basic indexes, partitions and tags) which respond to an obvious need for fast searches and retrevial.
|
||||||
Though, their implementation via the creation of symlinks is the result of a certain vision about how a database should behave in order to provide a practical way for users to sort the entries.
|
Though, their implementation via the creation of symlinks is the result of a certain vision about how a database should behave in order to provide a practical way for users to play with the entries outside the application.
|
||||||
The implementation can be completely changed.
|
The implementation can be completely changed.
|
||||||
|
|
||||||
Also, other kinds of triggers could
|
Other kinds of triggers could
|
||||||
.B easily
|
.B easily
|
||||||
be implemented in addition of those presented.
|
be implemented in addition of those presented.
|
||||||
The new triggers may have completely different objectives than providing a file-system representation of the data.
|
The new triggers may have completely different objectives than providing a file-system representation of the data.
|
||||||
|
|
Loading…
Add table
Reference in a new issue