Skip to content

Commit

Permalink
GH-4119 add option to configure an LMDB store from the workbench (#4120)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad authored Sep 1, 2022
1 parent 09b4a41 commit 320d36f
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Configuration template for an LmdbStore
#
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix rep: <http://www.openrdf.org/config/repository#>.
@prefix sr: <http://www.openrdf.org/config/repository/sail#>.
@prefix sail: <http://www.openrdf.org/config/sail#>.
@prefix ns: <http://www.openrdf.org/config/sail/native#>.
@prefix sb: <http://www.openrdf.org/config/sail/base#>.

[] a rep:Repository ;
rep:repositoryID "{%Repository ID|lmdb%}" ;
rdfs:label "{%Repository title|LMDB Store%}" ;
rep:repositoryImpl [
rep:repositoryType "openrdf:SailRepository" ;
sr:sailImpl [
sail:sailType "rdf4j:LmdbStore" ;
sb:evaluationStrategyFactory "{%EvaluationStrategyFactory|org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory%}"
]
].
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
import org.eclipse.rdf4j.sail.config.SailFactory;
import org.eclipse.rdf4j.sail.config.SailImplConfig;
import org.eclipse.rdf4j.sail.lmdb.LmdbStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A {@link SailFactory} that creates {@link LmdbStore}s based on RDF configuration data.
*
*/
public class LmdbStoreFactory implements SailFactory {

private static final Logger logger = LoggerFactory.getLogger(LmdbStoreFactory.class);

/**
* The type of repositories that are created by this factory.
*
Expand All @@ -48,6 +51,11 @@ public Sail getSail(SailImplConfig config) throws SailConfigException {
throw new SailConfigException("Invalid Sail type: " + config.getType());
}

return new LmdbStore(config instanceof LmdbStoreConfig ? (LmdbStoreConfig) config : new LmdbStoreConfig());
if (config instanceof LmdbStoreConfig) {
return new LmdbStore(((LmdbStoreConfig) config));
} else {
logger.warn("Config is instance of {} is not LmdbStoreConfig.", config.getClass().getName());
return new LmdbStore();
}
}
}
86 changes: 86 additions & 0 deletions tools/workbench/src/main/webapp/transformations/create-lmdb.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sparql="http://www.w3.org/2005/sparql-results#" xmlns="http://www.w3.org/1999/xhtml">

<xsl:include href="../locale/messages.xsl" />

<xsl:variable name="title">
<xsl:value-of select="$repository-create.title" />
</xsl:variable>

<xsl:include href="template.xsl" />

<xsl:template match="sparql:sparql">
<form action="create" method="post">
<table class="dataentry">
<tbody>
<tr>
<th>
<xsl:value-of select="$repository-type.label" />
</th>
<td>
<select id="type" name="type">
<option value="lmdb">
LMDB Store
</option>
</select>
</td>
<td></td>
</tr>
<tr>
<th>
<xsl:value-of select="$repository-id.label" />
</th>
<td>
<input type="text" id="id" name="Repository ID" size="16"
value="lmdb" />
</td>
<td></td>
</tr>
<tr>
<th>
<xsl:value-of select="$repository-title.label" />
</th>
<td>
<input type="text" id="title" name="Repository title" size="48"
value="LMDB store" />
</td>
<td></td>
</tr>
<tr>
<th>
<xsl:value-of select="$repository-evaluation-mode.label" />
</th>
<td>
<select id="evalStratFactory" name="EvaluationStrategyFactory">
<option selected="selected"
value="org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory">
Strict
</option>
<option
value="org.eclipse.rdf4j.query.algebra.evaluation.impl.ExtendedEvaluationStrategyFactory">
Extended
</option>
</select>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input type="button" value="{$cancel.label}" style="float:right"
data-href="repositories"
onclick="document.location.href=this.getAttribute('data-href')" />
<input id="create" type="button" value="{$create.label}"
onclick="checkOverwrite()" />
</td>
</tr>
</tbody>
</table>
</form>
<script src="../../scripts/create.js" type="text/javascript">
</script>
</xsl:template>

</xsl:stylesheet>
1 change: 1 addition & 0 deletions tools/workbench/src/main/webapp/transformations/create.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
SPARQL endpoint proxy
</option>
<option value="federate">Federation</option>
<option value="lmdb">LMDB Store</option>
</select>
</td>
<td></td>
Expand Down

0 comments on commit 320d36f

Please sign in to comment.