tolog updates
Post on 29-Jun-2015
4.232 Views
Preview:
DESCRIPTION
TRANSCRIPT
tolog updates
TMRA 2009, November 12, LeipzigLars Marius Garshol, <larsga@bouvet.no>
Why an update language?
• Easier to use than the API– empowers new groups of users
• Potentially better performance than the API
• Can be embedded in various DSLs• Architectural benefits– enables JDBC-like API– easily accessible over the network
Why one based on tolog?
• TMQL was not ready at the time– in fact, it still isn’t
• We have a tolog implementation– implementing the query part is the biggest job
• So tolog was the pragmatic choice
What it contains
• INSERT: add new data to topic map using CTM
• DELETE: remove data from topic map• MERGE: merge objects• UPDATE: change existing values
The language
DELETE
• Static form– delete lmg
• Dynamic form– delete $person from instance-of($person,
person)
Deletion effects
• Deleting topic removes– from scope– from topic types– objects typed with– as reifier
• Topic map– Topic
• Name– Variant
• Occurrence• Association
– Role
Delete functions
• Used for removing values from set properties– delete subject-identifier(topic,
“http://ex.org/tst”)– delete item-identifier(topic, “file://...#tst”)– delete subject-locator(topic, “http://ex.org”)
• Other functions– scope($statement, $topic)– reifies($reified, $reifier)– direct-instance-of($topic, $type)
MERGE
• Static form– MERGE topic1, topic2
• Dynamic form– MERGE $p1, $p2 FROM
instance-of($p1, person),instance-of($p2, person),
email($p1, $email),
email($p2, $email)
INSERT
• Static formINSERT lmg isa person; - “Lars Marius Garshol”
.
• Dynamic formINSERT
tmcl:belongs-to-
schema(tmcl:container : $s, tmcl:containee: $c) FROM instance-of($c, tmcl:constraint)
Another INSERT example
• INSERT $topic $psi . FROMinstance-of($topic,
$type),instance-of($type, psi-type),
topic-name($topic, $name),value($name, $value),
str:translate($value, $token, ..., ...), str:concat($psi,
“http://psi.example.org/...”)
Yet another
• INSERT event-in-year(event: $e, year: $y) FROM start-date($e, $date),
str:substring($y, $date, 4)
Ugliness with INSERT
• Other statements can use %parameter% syntax– in INSERT this is not possible in the CTM part– have to say FROM $a = %a% to translate
• May need to project away variables used in query but not in CTM– right now this is done via an implicit
projection– not clear whether this will confuse users or
not
UPDATE
• Static form– UPDATE value(@3421, “New name”)
• Dynamic form– UPDATE value($TN, “Ontopia”)
FROM topic-name(oks, $TN)
The UPDATE functions
• value($object, $string)– works on topic name, variant, occurrence
• resource($object, $string)– works on variant and occurrence
Considerations
New API
• Old API has QueryProcessorIF methods– QueryResultIF execute(String)– ParsedQueryIF parse(String)
• New API adds– int update(String)– ParsedModificationStatementIF
parseUpdate(String)– also adds ParsedStatementIF as common
interface
New access methods
• Omnigator query plug-in– being extended to support updates
• TMRAP web service– being extended with a tolog-update request
A scripting language?
• Considering to make a language supporting batches of statements– that is, running series of modification
statements– perhaps also setting variables
• Not clear what features are needed– for loops? if? etc
Implementation
• Mostly straightforward...– new classes to represent parsed versions of
new statements– all reference the class for SELECT statements
for their FROM subqueries
• ...except CTM parsing– requires two different Antlr parsers (CTM &
tolog)– had to split the query string in advance, then
pass different pieces to different parsers
Concerns
• Is it expressive enough?– just about any modification can be expressed– however, it might require many statements
• Do INSERT statements need “if”?– to handle missing values, for example
• Rules and templates– currently, these cannot be defined in
modification statements– is that a bug? or a feature?
Current status
• All four statement types implementated• Test suite added• Some minor nits still need sorting out
Future work
• Start using the language• Write documentation!• Hand it over to users• See how it goes
top related