本文整理了Java中org.apache.commons.rdf.api.Dataset.size()
方法的一些代码示例,展示了Dataset.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dataset.size()
方法的具体详情如下:
包路径:org.apache.commons.rdf.api.Dataset
类名称:Dataset
方法名:size
[英]Number of quads contained by the dataset.
The count of a set does not include duplicates, consistent with the Quad#equals(Object) equals method for each Quad.
[中]数据集包含的四边形数。
集合的计数不包括重复项,这与每个四元组的Quad#equals(Object)equals方法一致。
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void size() throws Exception {
assertEquals(10, dataset.size());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void size() throws Exception {
assertEquals(1, dataset.size());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void remove() throws Exception {
final long fullSize = dataset.size();
dataset.remove(Optional.of(graph1), alice, knows, bob);
final long shrunkSize = dataset.size();
assertEquals(1, fullSize - shrunkSize);
assertEquals(shrunkSize, dataset.size()); // unchanged
assertTrue(dataset.size() > shrunkSize);
assertEquals(shrunkSize, dataset.size());
assertEquals(shrunkSize - 1, dataset.size());
dataset.remove(otherQuad);
assertEquals(shrunkSize - 1, dataset.size()); // no change
assertTrue(dataset.size() >= shrunkSize);
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testAuditCreation() {
final Dataset dataset = rdf.createDataset();
final AuditService svc = new DefaultAuditService() {};
svc.creation(subject, mockSession).forEach(dataset::add);
assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent(),
"Graph and dataset sizes don't match for creation event!");
assertTrue(dataset.contains(null, null, type, AS.Create), "as:Create type not in create dataset!");
assertAll("Event property check", checkEventProperties(dataset));
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testCollectDataset() {
final Dataset dataset = generate(() -> rdf.createQuad(getIRI(), getIRI(), getIRI(), getIRI()))
.parallel().limit(size).collect(toDataset());
assertTrue(size >= dataset.size(), "Generated dataset has too many triples!");
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void clear() throws Exception {
dataset.clear();
assertFalse(dataset.contains(null, alice, knows, bob));
assertEquals(0, dataset.size());
dataset.clear(); // no-op
assertEquals(0, dataset.size());
assertFalse(dataset.contains(null, null, null, null)); // nothing here
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testAuditUpdate() {
final Dataset dataset = rdf.createDataset();
final AuditService svc = new DefaultAuditService() {};
svc.update(subject, mockSession).forEach(dataset::add);
assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
assertTrue(dataset.contains(null, null, type, AS.Update));
assertAll("Event property check", checkEventProperties(dataset));
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testAuditDeletion() {
final Dataset dataset = rdf.createDataset();
final AuditService svc = new DefaultAuditService() {};
svc.deletion(subject, mockSession).forEach(dataset::add);
assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent(),
"Graph and dataset sizes don't match for deletion event!");
assertTrue(dataset.contains(null, null, type, AS.Delete), "as:Delete type not in delete dataset!");
assertAll("Event property check", checkEventProperties(dataset));
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testCollectDatasetConcurrent() {
final Dataset dataset = generate(() -> rdf.createQuad(getIRI(), getIRI(), getIRI(), getIRI()))
.parallel().limit(size).collect(toDataset().concurrent());
assertTrue(size >= dataset.size(), "Generated dataset has too many triples!");
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void iterate() throws Exception {
Assume.assumeTrue(dataset.size() > 0);
final List<Quad> quads = new ArrayList<>();
for (final Quad t : dataset.iterate()) {
quads.add(t);
assertEquals(dataset.size(), quads.size());
count++;
assertEquals(dataset.size(), count);
代码示例来源:origin: org.apache.commons/commons-rdf-jena
@Test
public void datasetImplToStringTest() {
RDF rdf = createFactory();
JenaDataset jena = (JenaDataset) rdf.createDataset();
final IRI graph = rdf.createIRI("http://example.com/");
final IRI s = rdf.createIRI("http://example.com/s");
final IRI p = rdf.createIRI("http://example.com/p");
final Literal literal123 = rdf.createLiteral("123", Types.XSD_INTEGER);
jena.add(graph, s, p, literal123);
String out = jena.toString();
assertEquals("<http://example.com/s> <http://example.com/p> \"123\"^^<http://www"
+ ".w3.org/2001/XMLSchema#integer> <http://example.com/> .\n", out);
assertEquals(10L, dataset.size());
}
}
代码示例来源:origin: trellis-ldp/trellis
private Stream<Executable> checkEventProperties(final Dataset dataset) {
return Stream.of(
() -> assertTrue(dataset.contains(null, null, type, PROV.Activity), "missing prov:Activity triple!"),
() -> assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null),
"missing prov:wasGeneratedBy triple!"),
() -> assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousAgent),
"missing prov:wasAssociatedWith triple!"),
() -> assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.AdministratorAgent),
"missing prov:actedOnBehalfOf triple!"),
() -> assertTrue(dataset.contains(null, null, PROV.atTime,
rdf.createLiteral(created.toString(), XSD.dateTime)), "missing prov:atTime triple!"),
() -> assertEquals(6L, dataset.size(), "Incorrect dataset size!"));
}
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testAppendSemantics() {
final Quad testFirstQuad = createQuad(testResourceId3, testResourceId2, testResourceId1, badId);
final Quad testSecondQuad = createQuad(testResourceId3, testResourceId2, testResourceId1, badId);
// store some data in mutable and immutable sides under the same resource ID
final Resource testFirstResource = new TestResource(testResourceId3, testFirstQuad);
assertNull(testable.add(testResourceId3, testFirstResource.dataset()).toCompletableFuture().join(),
"Couldn't create an immutable resource!");
final Resource testSecondResource = new TestResource(testResourceId3, testSecondQuad);
assertNull(testable.add(testResourceId3, testSecondResource.dataset()).toCompletableFuture().join(),
"Couldn't add to an immutable resource!");
final Resource retrieved = testable.get(testResourceId3).toCompletableFuture().join();
assertEquals(testResourceId3, retrieved.getIdentifier(), "Resource was retrieved with wrong ID!");
final Dataset quads = retrieved.dataset();
assertTrue(quads.contains(testFirstQuad), "Resource was retrieved without its immutable data!");
assertTrue(quads.contains(testSecondQuad), "Resource was retrieved without its mutable data!");
quads.remove(testFirstQuad);
quads.remove(testSecondQuad);
assertEquals(0, quads.size(), "Resource was retrieved with too much data!");
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testMergingBehavior() {
final Quad testMutableQuad = createQuad(testResourceId2, testResourceId2, testResourceId1, badId);
final Quad testImmutableQuad = createQuad(testResourceId2, testResourceId2, testResourceId1, badId);
// store some data in mutable and immutable sides under the same resource ID
final Resource testMutableResource = new TestResource(testResourceId2, testMutableQuad);
assertNull(testable.create(Metadata.builder(testMutableResource).build(), testMutableResource.dataset())
.toCompletableFuture().join(), "Couldn't create a resource!");
final Resource testImmutableResource = new TestResource(testResourceId2, testImmutableQuad);
assertNull(testable.add(testResourceId2, testImmutableResource.dataset()).toCompletableFuture().join(),
"Couldn't create an immutable resource!");
final Resource retrieved = testable.get(testResourceId2).toCompletableFuture().join();
assertEquals(testMutableResource.getIdentifier(), retrieved.getIdentifier(),
"Resource was retrieved with wrong ID!");
final Dataset quads = retrieved.dataset();
assertTrue(quads.contains(testImmutableQuad), "Resource was retrieved without its immutable data!");
assertTrue(quads.contains(testMutableQuad), "Resource was retrieved without its mutable data!");
quads.remove(testImmutableQuad);
quads.remove(testMutableQuad);
assertEquals(0, quads.size(), "Resource was retrieved with too much data!");
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testDatasetConversion() {
final Dataset dataset = simpleRdf.createDataset();
dataset.add(simpleRdf.createQuad(PreferUserManaged, subject, SKOS.prefLabel, literal));
dataset.add(simpleRdf.createQuad(PreferUserManaged, subject, type, SKOS.Concept));
dataset.add(simpleRdf.createQuad(PreferUserManaged, subject, DC.subject, AS.Activity));
assertEquals(3L, dataset.size(), "Confirm dataset size");
assertTrue(TriplestoreUtils.asJenaDataset(dataset).containsNamedModel(PreferUserManaged.getIRIString()),
"Confirm presence of trellis:PreferUserManaged named graph");
assertNotEquals(TriplestoreUtils.asJenaDataset(dataset).asDatasetGraph(),
TriplestoreUtils.asJenaDataset(dataset).asDatasetGraph(), "Confirm dataset has been converted");
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testDatasetNoConversion() {
final Dataset dataset = jenaRdf.createDataset();
dataset.add(jenaRdf.createQuad(PreferUserManaged, subject, SKOS.prefLabel, literal));
dataset.add(jenaRdf.createQuad(PreferUserManaged, subject, type, SKOS.Concept));
dataset.add(jenaRdf.createQuad(PreferUserManaged, subject, DC.subject, AS.Activity));
assertEquals(3L, dataset.size(), "Confirm dataset size");
assertTrue(TriplestoreUtils.asJenaDataset(dataset).containsNamedModel(PreferUserManaged.getIRIString()),
"Confirm presence of trellis:PreferUserManaged named graph");
assertEquals(TriplestoreUtils.asJenaDataset(dataset).asDatasetGraph(),
TriplestoreUtils.asJenaDataset(dataset).asDatasetGraph(), "Confirm datasets are equal");
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
factory = createFactory();
dataset = factory.createDataset();
assertEquals(0, dataset.size());
内容来源于网络,如有侵权,请联系作者删除!