AKSW/Erfurt — Issue #11: Method to generate new URIs (like auto_increment)
Author: cweiske
Created: 2012-03-04 18:25:09+00:00
State: open

When adding new statements to a store/model that e.g. are blank nodes, or just URIs you don't care about, one often uses a URL like

> http://example.org/some/uri/$index

`$index` is being counted up here.

Currently, Erfurt offers no method to get a new URI based on the prefix (`http://example.org/some/uri/`), which makes it hard to continously generate such URIs among several PHP calls. It leads to code like this (from `Syntax/RdfParser/Adapter/Turtle.php`):

> while (true) {
> $id = self::BNODE_PREFIX . ++$this->_bnodeCounter;
> if (!isset($this->_usedBnodeIds[$id])) {
> break;
> }
> }

This is also the same code I have to use to do that in my application. This code is very slow if you have to do that against a database.

Erfurt should offer a method to create such incrementing URIs. I imagine something like this:

> var_dump($model->getNextFreeUri('http://example.org/some/uri/'));
> string(xx) "http://example.org/some/uri/3721"
> var_dump($model->getNextFreeUri('http://example.org/some/uri/'));
> string(xx) "http://example.org/some/uri/3722"