本文整理了Java中com.hp.hpl.jena.rdf.model.Model.size()
方法的一些代码示例,展示了Model.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.size()
方法的具体详情如下:
包路径:com.hp.hpl.jena.rdf.model.Model
类名称:Model
方法名:size
[英]size will return the number of statements in a concrete model, for a virtualized model such as one created by an inference engine, it will return an estimated lower bound for the numberof statements in the model but it is possible for a subsequent listStatements on such a model to discover more statements than size() indicated.
[中]size将返回一个具体模型中的语句数,对于一个虚拟化模型,例如一个由推理机创建的模型,它将返回模型中语句数的估计下限,但这样一个模型上的后续listStatements可能会发现比size()指示的更多的语句。
代码示例来源:origin: fr.inria.eventcloud/eventcloud-api
/**
* {@inheritDoc}
*/
@Override
public long size() {
return super.object.size();
}
代码示例来源:origin: epimorphics/elda
/**
Answer the size of this result-set's model.
*/
public long modelSize() {
return model.merged.size();
}
代码示例来源:origin: bio2rdf/bio2rdf-scripts
public long size() {
return model.size();
}
代码示例来源:origin: bio2rdf/bio2rdf-scripts
public double getNumberOfTriples(Model model) {
return model.size();
}
代码示例来源:origin: org.semweb4j/rdf2go.impl.jena
@Override
public long size() throws ModelRuntimeException {
assertModel();
return (int)this.jenaModel.size();
}
代码示例来源:origin: org.semweb4j/rdf2go.impl.jena
@Override
public long size() throws ModelRuntimeException {
// Start with the size of the default graph
long size = this.dataset.getDefaultModel().size();
// Loop and add the sizes of all contained graphs
Iterator<String> it = this.dataset.listNames();
while (it.hasNext()) {
size += this.dataset.getNamedModel(it.next()).size();
}
return size;
}
代码示例来源:origin: org.cogchar/org.cogchar.lib.core.impl
/**
* Q: Under what conditions are we allowed to do this directly through Dataset.getNamedModel() actions? A: Not sure
* - the clean-est way is to generate SPARQL-UPDATE and apply. If we are allowed to modify the model directly using
* Jena API, then it will be sufficient (for immediate practical purposes) to delete all triples with actionIdent as
* SUBJECT.
*
* @param tas
*/
@Deprecated private void old_deleteThingAction(RepoClient rc, Ident graphID, ThingActionSpec tas) {
Ident actionID = tas.getActionSpecID();
Resource actionRes = rc.getDefaultRdfNodeTranslator().makeResourceForIdent(actionID);
//Repo.WithDirectory repo = rc.getRepo();
theLogger.error("FIXME: About to fetch a readonly model and then try to write to it, which will have no effect - FIXME!!!");
Model gm = rc.getNamedModelReadonly(graphID); // repo.getNamedModel(graphID); FIXME
theLogger.info("Prior to removal from {}, graph size is {}", graphID, gm.size());
gm.removeAll(actionRes, null, null);
theLogger.info("After remova from {}, graph size is {}", graphID, gm.size());
}
代码示例来源:origin: org.cogchar/org.cogchar.lib.core
/**
* Q: Under what conditions are we allowed to do this directly through Dataset.getNamedModel() actions?
* A: Not sure - the clean-est way is to generate SPARQL-UPDATE and apply.
* If we are allowed to modify the model directly using Jena API, then it will be sufficient (for immediate
* practical purposes) to delete all triples with actionIdent as SUBJECT.
* @param tas
*/
private void deleteThingAction(RepoClient rc, Ident graphID, ThingActionSpec tas) {
Ident actionID = tas.getActionSpecID();
Resource actionRes = rc.makeResourceForIdent(actionID);
Repo.WithDirectory repo = rc.getRepo();
Model gm = repo.getNamedModel(graphID);
theLogger.info("Prior to removal from {}, graph size is {}", graphID, gm.size());
gm.removeAll(actionRes, null, null);
theLogger.info("After remova from {}, graph size is {}", graphID, gm.size());
}
代码示例来源:origin: epimorphics/elda
public TDBSource( Resource endpoint ) {
super( endpoint );
String endpointString = endpoint.getURI();
String name = endpointString.substring( TDBManager.PREFIX.length() );
this.endpoint = endpointString;
this.sourceSet = TDBManager.getDataset();
if (name != null && !name.isEmpty()) {
this.source = TDBManager.getTDBModelNamed(name);
log.debug(
"TDB with endpoint '{}' has model with {} triples"
, endpointString, this.source.size()
);
if (this.source.isEmpty())
EldaException.EmptyTDB( name );
} else {
source = null;
log.info("using TDB whole dataset");
}
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core
/**
Intersect this with another model. As an attempt at optimisation, we try and ensure
we iterate over the smaller model first. Nowadays it's not clear that this is a good
idea, since <code>size()</code> can be expensive on database and inference
models.
@see com.hp.hpl.jena.rdf.model.Model#intersection(com.hp.hpl.jena.rdf.model.Model)
*/
@Override
public Model intersection( Model other )
{ return this.size() < other.size() ? intersect( this, other ) : intersect( other, this ); }
代码示例来源:origin: epimorphics/elda
@Test @Ignore public void testReadsJSON_LD() throws UnsupportedEncodingException {
Model reconstituted = ModelFactory.createDefaultModel();
String source = response;
reconstituted.read(new ByteArrayInputStream(source.getBytes("UTF-8")), "", "JSON-LD");
System.err.println(">> reconstituted "+ reconstituted.size() + " triples.");
reconstituted.write(System.err, "TURTLE");
System.err.println(">> done.");
}
代码示例来源:origin: bio2rdf/bio2rdf-scripts
public void insert(Model rdf, String graphUri, ProgressMonitor progressMonitor) throws DaoException {
int total = (int) rdf.size();
String sparql = null;
try {
int counter = 0;
for (StmtIterator i = rdf.listStatements(); i.hasNext();) {
Statement stmt = i.nextStatement();
sparql = "INSERT INTO GRAPH <" + graphUri + "> { " + NTripleStamentWriter.writeStament(stmt) + " }";
if (LOG.isDebugEnabled()) {
LOG.debug(sparql);
}
VirtuosoUpdateRequest vqe = VirtuosoUpdateFactory.create(sparql, virtGraph);
vqe.exec();
if (progressMonitor != null) {
progressMonitor.setProgress(++counter, total);
}
}
} catch (Exception e) {
throw new DaoException(sparql, e);
} finally {
virtGraph.close();
}
}
代码示例来源:origin: de.unibonn.iai.eis/luzzu-annotations
/**
* Creates quality metadata
*
* @return Dataset with quality metadata which needs to be attached to the assessed dataset.
* @throws MetadataException if there is no observation data calculated.
*/
public Dataset createQualityMetadata() throws MetadataException{
Model defaultModel = ModelFactory.createDefaultModel();
Dataset dataset = null;
if (this.metadata.size() == 0) throw new MetadataException("No Metric Observations Recorded");
defaultModel.add(qualityGraph, RDF.type, DAQ.QualityGraph);
defaultModel.add(qualityGraph, CUBE.structure, DAQ.dsd);
dataset = new DatasetImpl(defaultModel);
dataset.addNamedModel(this.qualityGraph.getURI(), this.metadata);
return dataset;
}
代码示例来源:origin: org.apache.odftoolkit/odfdom-java
/**
* Get RDF metadata from manifest.rdf and those rdf files registered in the
* manifest.xml as "application/rdf+xml" through GRDDL XSLT
* http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415072_253892949
*/
public Model getManifestRDFMetadata() throws Exception {
Model m = ModelFactory.createDefaultModel();
for (String internalPath : this.getPackage().getFilePaths()) {
if (Util.isSubPathOf(internalPath, this.getDocumentPath()) && this.getPackage().getMediaTypeString(internalPath).endsWith("application/rdf+xml")) {
Model m1 = ModelFactory.createDefaultModel();
String RDFBaseUri = Util.getRDFBaseUri(this.getPackage().getBaseURI(), internalPath);
m1.read(new InputStreamReader(this.getPackage().getInputStream(internalPath), "utf-8"), RDFBaseUri);
// remove the last SLASH at the end of the RDFBaseUri:
// test_rdfmeta.odt/ --> test_rdfmeta.odt
ResourceUtils.renameResource(m1.getResource(RDFBaseUri), RDFBaseUri.substring(0, RDFBaseUri.length() - 1));
if (m1.size() > 0) {
m = m.union(m1);
}
}
}
return m;
}
代码示例来源:origin: com.github.jsonld-java/jsonld-java-jena
private void checkRelative(Model model) {
assertEquals(1, model.size());
final Statement statement = model.listStatements().next();
assertEquals("http://example.com/value", statement.getPredicate().toString());
assertEquals("Test", statement.getString());
assertEquals("http://example.com/test", statement.getSubject().toString());
}
代码示例来源:origin: com.hp.hpl.jena/sdb
@Test public void rollback() {
Model model = SDBFactory.connectDefaultModel(store);
assertTrue("Initially empty", model.isEmpty());
model.begin();
model.add(RDF.type, RDF.type, RDF.type);
assertTrue("Uncommited triple can be seen", model.contains(RDF.type, RDF.type, RDF.type));
model.abort();
assertTrue("Nothing was added, the add aborted", model.isEmpty());
model.add(RDF.type, RDF.type, RDF.type);
assertEquals("Model contains 1 triple", 1l, model.size());
model.begin();
model.remove(RDF.type, RDF.type, RDF.type);
model.abort();
assertEquals("Model still contains 1 triple", 1l, model.size());
}
代码示例来源:origin: com.hp.hpl.jena/sdb
@Test public void model_4()
{
Model assem = FileManager.get().loadModel(dir+"graph-assembler.ttl") ;
Resource xDft = assem.getResource("http://example/test#graphDft") ;
Resource xNamed = assem.getResource("http://example/test#graphNamed") ;
Store store = create(assem) ;
Model model1 = (Model)Assembler.general.open(xDft) ;
Model model2 = (Model)Assembler.general.open(xNamed) ;
// Check they are not connected to the same place in the store
Resource s = model1.createResource() ;
Property p = model1.createProperty("http://example/p") ;
Literal o = model1.createLiteral("foo") ;
model1.add(s,p,o) ;
assertTrue(model1.contains(s, p, o)) ;
assertTrue(model1.size() == 1 ) ;
assertTrue(model2.size() == 0 ) ;
assertFalse(model1.isIsomorphicWith(model2)) ;
}
代码示例来源:origin: com.hp.hpl.jena/sdb
@Test public void connection_1()
{
SDBConnection conn1 = SDBFactory.createConnection(conn) ;
Store store1 = StoreFactory.create(storeDesc, conn1) ;
// Reset
store1.getTableFormatter().format();
SDBConnection conn2 = SDBFactory.createConnection(conn) ;
Store store2 = StoreFactory.create(storeDesc, conn2) ;
Model model1 = SDBFactory.connectDefaultModel(store1) ;
Model model2 = SDBFactory.connectDefaultModel(store2) ;
Resource s = model1.createResource() ;
Property p = model1.createProperty("http://example/p") ;
// These are autocommit so two stores should be OK (but not a good design paradigm)
model1.add(s, p, "model1") ;
model2.add(s, p, "model2") ;
assertEquals(2, model1.size()) ;
assertEquals(2, model2.size()) ;
assertTrue(model1.isIsomorphicWith(model2)) ;
}
}
代码示例来源:origin: com.hp.hpl.jena/tdb
@Test public void update3()
{
Dataset ds = TDBFactory.createDataset() ;
ds.asDatasetGraph().getDefaultGraph().add(t1) ;
ds.getNamedModel(graphName).getGraph().add(t1) ;
Model m = ds.getDefaultModel() ;
m.removeAll() ;
assertEquals(0, m.size()) ;
// But still in the other graph
assertTrue(ds.getNamedModel(graphName).getGraph().contains(t1)) ;
}
代码示例来源:origin: com.hp.hpl.jena/tdb
@Test public void update4()
{
Dataset ds = TDBFactory.createDataset() ;
ds.asDatasetGraph().getDefaultGraph().add(t1) ;
ds.getNamedModel(graphName).getGraph().add(t1) ;
Model m = ds.getNamedModel(graphName) ;
m.removeAll() ;
assertEquals(0, m.size()) ;
// But still in the other graph
assertTrue(ds.getDefaultModel().getGraph().contains(t1)) ;
}
内容来源于网络,如有侵权,请联系作者删除!