Steve Harris (theno23) wrote,
Steve Harris
theno23

INSERT/DELETE in 4store

The "delete" branch (so named because DELETE was much harder than INSERT to implement) of 4store http://github.com/garlik/4store/tree/delete has some basic support for adding a removing triples to/from graphs.

Examples:

PREFIX ex: <http://example.com/>
INSERT {
  GRAPH ex:mygraph {
    ex:a ex:p 12 .
    ex:a ex:q 23.0 .
    ex:a ex:r "foo"@en .
  }
}

PREFIX ex: <http://example.com/>
DELETE {
  GRAPH ex:mygraph {
    ex:a ex:p 12 .
  }
}

Caveats:

It behaves like a SPARQL 1.1 INSERT DATA, so no WHERE clause is allowed (the rasqal parser doesn't allow it, and the code doesn't support it even if it did).

Don't try to add bNodes, or you will just get an error.

Using variables will cause an error at best.

This code is not well tested, I pushed out the branch so that people can give it a go. If it works OK, and doesn't screw stores then we can look it merging it into the mainline code.

It fragments one of the indexes, so if you add and delete lots of triples to a graph then that index will grow quite large. It should be a huge problem, and it can be fixed retrospectively, but it's worth looking out for.

It's not well optimised, so the performance isn't all it could be. INSERTing or DELETEing large numbers of triples is especially inefficient. It wouldn't be much work to improve, but it's exactly the sort of thing I usually make a mess of.

If you try to INSERT/DELETE from/to the default graph:

INSERT { <x> <y> <z> }

It will end up using a graph called <default:>.

I guess DELETE could remove from all graphs, which would be a parallel to what SELECT does, but then it would be wildly different from INSERT, which I wasn't keen on either. INSERTing into all graphs, would be a bit... odd, and potentially very annoying.

- Steve

Tags: 4store, sparql
  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic
  • 3 comments