use of org.apache.lucene.store.ByteBuffersDirectory in project jena by apache.
the class TestTextTxn method create.
private Dataset create() {
Dataset ds1 = factory.create();
Directory dir = new ByteBuffersDirectory();
EntityDefinition eDef = new EntityDefinition("iri", "text");
eDef.setPrimaryPredicate(RDFS.label);
TextIndex tidx = new TextIndexLucene(dir, new TextIndexConfig(eDef));
Dataset ds = TextDatasetFactory.create(ds1, tidx);
return ds;
}
use of org.apache.lucene.store.ByteBuffersDirectory in project jena by apache.
the class TestTextNonTxn method create.
private Dataset create() {
Dataset ds1 = factory.create();
Directory dir = new ByteBuffersDirectory();
EntityDefinition eDef = new EntityDefinition("iri", "text");
eDef.setPrimaryPredicate(RDFS.label);
TextIndex tidx = new TextIndexLucene(dir, new TextIndexConfig(eDef));
Dataset ds = TextDatasetFactory.create(ds1, tidx);
return ds;
}
use of org.apache.lucene.store.ByteBuffersDirectory in project jena by apache.
the class TestTextNonTxnTDB1 method create.
private static Dataset create() {
Dataset ds1 = TDBFactory.createDataset();
Directory dir = new ByteBuffersDirectory();
EntityDefinition eDef = new EntityDefinition("iri", "text");
eDef.setPrimaryPredicate(RDFS.label);
TextIndex tidx = new TextIndexLucene(dir, new TextIndexConfig(eDef));
Dataset ds = TextDatasetFactory.create(ds1, tidx);
return ds;
}
use of org.apache.lucene.store.ByteBuffersDirectory in project jena by apache.
the class TestLuceneWithMultipleThreads method testReadInMiddleOfWrite.
@Test
public void testReadInMiddleOfWrite() throws InterruptedException, ExecutionException {
final DatasetGraphText dsg = (DatasetGraphText) TextDatasetFactory.createLucene(DatasetGraphFactory.create(), new ByteBuffersDirectory(), new TextIndexConfig(entDef));
final Dataset ds = DatasetFactory.wrap(dsg);
final ExecutorService execService = Executors.newSingleThreadExecutor();
final Future<?> f = execService.submit(new Runnable() {
@Override
public void run() {
// Hammer the dataset with a series of read queries
while (!Thread.interrupted()) {
dsg.begin(ReadWrite.READ);
try {
QueryExecution qExec = QueryExecutionFactory.create("select * where { ?s ?p ?o }", ds);
ResultSet rs = qExec.execSelect();
while (rs.hasNext()) {
rs.next();
}
dsg.commit();
} finally {
dsg.end();
}
}
}
});
dsg.begin(ReadWrite.WRITE);
try {
Model m = ds.getDefaultModel();
m.add(ResourceFactory.createResource("http://example.org/"), RDFS.label, "entity");
// Sleep for a bit so that the reader thread can get in between these two writes
Thread.sleep(100);
m.add(ResourceFactory.createResource("http://example.org/"), RDFS.comment, "comment");
dsg.commit();
} finally {
dsg.end();
}
execService.shutdownNow();
execService.awaitTermination(1000, TimeUnit.MILLISECONDS);
// If there was an exception in the read thread then Future.get() will throw an ExecutionException
assertTrue(f.get() == null);
}
use of org.apache.lucene.store.ByteBuffersDirectory in project jena by apache.
the class TestTextGraphIndexExtra method textDataset.
static Dataset textDataset(Dataset dataset) {
EntityDefinition entdef = new EntityDefinition("uri", "text", "graph", rdfsLabel);
TextIndex textIndex = TextDatasetFactory.createLuceneIndex(new ByteBuffersDirectory(), new TextIndexConfig(entdef));
return TextDatasetFactory.create(dataset, textIndex, true);
}
Aggregations