Tolog Updates

23
tolog updates TMRA 2009, November 12, Leipzig Lars Marius Garshol, <[email protected]>

description

Describes the update language part of the tolog query language for Topic Maps.

Transcript of Tolog Updates

Page 1: Tolog Updates

tolog updates

TMRA 2009, November 12, LeipzigLars Marius Garshol, <[email protected]>

Page 2: Tolog Updates

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

Page 3: Tolog Updates

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

Page 4: Tolog Updates

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

Page 5: Tolog Updates

The language

Page 6: Tolog Updates

DELETE

• Static form– delete lmg

• Dynamic form– delete $person from instance-of($person,

person)

Page 7: Tolog Updates

Deletion effects

• Deleting topic removes– from scope– from topic types– objects typed with– as reifier

• Topic map– Topic

• Name– Variant

• Occurrence• Association

– Role

Page 8: Tolog Updates

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)

Page 9: Tolog Updates

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)

Page 10: Tolog Updates

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)

Page 11: Tolog Updates

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/...”)

Page 12: Tolog Updates

Yet another

• INSERT event-in-year(event: $e, year: $y) FROM start-date($e, $date),

str:substring($y, $date, 4)

Page 13: Tolog Updates

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

Page 14: Tolog Updates

UPDATE

• Static form– UPDATE value(@3421, “New name”)

• Dynamic form– UPDATE value($TN, “Ontopia”)

FROM topic-name(oks, $TN)

Page 15: Tolog Updates

The UPDATE functions

• value($object, $string)– works on topic name, variant, occurrence

• resource($object, $string)– works on variant and occurrence

Page 16: Tolog Updates

Considerations

Page 17: Tolog Updates

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

Page 18: Tolog Updates

New access methods

• Omnigator query plug-in– being extended to support updates

• TMRAP web service– being extended with a tolog-update request

Page 19: Tolog Updates

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

Page 20: Tolog Updates

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

Page 21: Tolog Updates

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?

Page 22: Tolog Updates

Current status

• All four statement types implementated• Test suite added• Some minor nits still need sorting out

Page 23: Tolog Updates

Future work

• Start using the language• Write documentation!• Hand it over to users• See how it goes