本文整理了Java中org.eclipse.rdf4j.model.util.Models.isomorphic()
方法的一些代码示例,展示了Models.isomorphic()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Models.isomorphic()
方法的具体详情如下:
包路径:org.eclipse.rdf4j.model.util.Models
类名称:Models
方法名:isomorphic
[英]Compares two RDF models, and returns true if they consist of isomorphic graphs and the isomorphic graph identifiers map 1:1 to each other. RDF graphs are isomorphic graphs if statements from one graphs can be mapped 1:1 on to statements in the other graphs. In this mapping, blank nodes are not considered mapped when having an identical internal id, but are mapped from one graph to the other by looking at the statements in which the blank nodes occur. A Model can consist of more than one graph (denoted by context identifiers). Two models are considered isomorphic if for each of the graphs in one model, an isomorphic graph exists in the other model, and the context identifiers of these graphs are either identical or (in the case of blank nodes) map 1:1 on each other.
[中]比较两个RDF模型,如果它们由同构图组成,并且同构图标识符相互映射为1:1,则返回true。如果一个图中的语句可以1:1映射到另一个图中的语句,那么RDF图就是同构图。在这种映射中,当具有相同的内部ID时,不考虑空白节点,而是通过查看出现空白节点的语句从一个图映射到另一个图。一个模型可以由多个图(由上下文标识符表示)组成。如果对于一个模型中的每个图,另一个模型中存在一个同构图,并且这些图的上下文标识符相同,或者(在空白节点的情况下)相互映射1:1,则两个模型被视为同构。
代码示例来源:origin: eclipse/rdf4j
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof Model) {
Model model = (Model)o;
return Models.isomorphic(this, model);
}
return false;
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof Model) {
Model model = (Model)o;
return Models.isomorphic(this, model);
}
return false;
}
代码示例来源:origin: eclipse/rdf4j
/**
* Compares two RDF models, defined by two statement collections, and returns <tt>true</tt> if they are
* equal. Models are equal if they contain the same set of statements. Blank node IDs are not relevant for
* model equality, they are mapped from one model to the other by using the attached properties.
*
* @deprecated since 2.8.0. Use {@link Models#isomorphic(Iterable, Iterable)} instead.
*/
@Deprecated
public static boolean equals(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2)
{
return isomorphic(model1, model2);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Compares two RDF models, defined by two statement collections, and returns <tt>true</tt> if they are
* equal. Models are equal if they contain the same set of statements. Blank node IDs are not relevant for
* model equality, they are mapped from one model to the other by using the attached properties.
*
* @deprecated since 2.8.0. Use {@link Models#isomorphic(Iterable, Iterable)} instead.
*/
@Deprecated
public static boolean equals(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2)
{
return isomorphic(model1, model2);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Compares two graph query results and returns {@code true} if they are equal. Two graph query results
* are considered equal if they are isomorphic graphs. Note that the method consumes both query results
* fully.
*
* @param result1
* the first query result to compare
* @param result2
* the second query result to compare.
* @return {@code true} iff the supplied graph query results are isomorphic graphs, {@code false}
* otherwise.
* @throws QueryEvaluationException
* @see {@link Models#isomorphic(Iterable, Iterable)}
*/
public static boolean equals(GraphQueryResult result1, GraphQueryResult result2)
throws QueryEvaluationException
{
Set<? extends Statement> graph1 = Iterations.asSet(result1);
Set<? extends Statement> graph2 = Iterations.asSet(result2);
return Models.isomorphic(graph1, graph2);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-query
/**
* Compares two graph query results and returns {@code true} if they are equal. Two graph query results
* are considered equal if they are isomorphic graphs. Note that the method consumes both query results
* fully.
*
* @param result1
* the first query result to compare
* @param result2
* the second query result to compare.
* @return {@code true} iff the supplied graph query results are isomorphic graphs, {@code false}
* otherwise.
* @throws QueryEvaluationException
* @see {@link Models#isomorphic(Iterable, Iterable)}
*/
public static boolean equals(GraphQueryResult result1, GraphQueryResult result2)
throws QueryEvaluationException
{
Set<? extends Statement> graph1 = Iterations.asSet(result1);
Set<? extends Statement> graph2 = Iterations.asSet(result2);
return Models.isomorphic(graph1, graph2);
}
代码示例来源:origin: eclipse/rdf4j
/**
* Compares two graph query results and returns {@code true} if they are equal. Two graph query results
* are considered equal if they are isomorphic graphs. Note that the method consumes both query results
* fully.
*
* @param result1
* the first query result to compare
* @param result2
* the second query result to compare.
* @return {@code true} iff the supplied graph query results are isomorphic graphs, {@code false}
* otherwise.
* @throws QueryEvaluationException
* @see {@link Models#isomorphic(Iterable, Iterable)}
*/
public static boolean equals(GraphQueryResult result1, GraphQueryResult result2)
throws QueryEvaluationException
{
Set<? extends Statement> graph1 = Iterations.asSet(result1);
Set<? extends Statement> graph2 = Iterations.asSet(result2);
return Models.isomorphic(graph1, graph2);
}
代码示例来源:origin: ontop/ontop
private void compareGraphs(Set<Statement> queryResult, Set<Statement> expectedResult)
throws Exception
if (!Models.isomorphic(expectedResult, queryResult)) {
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-model-testsuite
private void testFilesEqual(String file1, String file2)
throws Exception
{
Set<Statement> model1 = loadModel(file1);
Set<Statement> model2 = loadModel(file2);
// long startTime = System.currentTimeMillis();
boolean modelsEqual = Models.isomorphic(model1, model2);
// long endTime = System.currentTimeMillis();
// System.out.println("Model equality checked in " + (endTime - startTime)
// + "ms (" + file1 + ", " + file2
// + ")");
assertTrue(modelsEqual);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-serql-testsuite
if (!Models.isomorphic(actualStatements, expectedStatements)) {
代码示例来源:origin: eclipse/rdf4j
/**
* Compares the models in the default contexts of the two supplied repositories and returns true if they
* are equal. Models are equal if they contain the same set of statements. bNodes IDs are not relevant for
* model equality, they are mapped from one model to the other by using the attached properties. Note that
* the method pulls the entire default context of both repositories into main memory. Use with caution.
*/
public static boolean equals(Repository rep1, Repository rep2)
throws RepositoryException
{
// Fetch statements from rep1 and rep2
Set<Statement> model1, model2;
try (RepositoryConnection con1 = rep1.getConnection()) {
model1 = Iterations.asSet(con1.getStatements(null, null, null, true));
}
try (RepositoryConnection con2 = rep2.getConnection()) {
model2 = Iterations.asSet(con2.getStatements(null, null, null, true));
}
return Models.isomorphic(model1, model2);
}
代码示例来源:origin: franzinc/agraph-java-client
public static void assertRDFFilesIsomorphic(File expected, File actual, RDFFormat format) throws Exception {
final RDFFormat expectedFormat;
final RDFFormat actualFormat;
if (format == null) {
final RDFParserRegistry registry = RDFParserRegistry.getInstance();
expectedFormat =
registry.getFileFormatForFileName(expected.getName()).orElse(null);
actualFormat =
registry.getFileFormatForFileName(actual.getName()).orElse(null);
assertNotNull("Can't guess the expected file format", expectedFormat);
assertNotNull("Can't guess the actual file format", actualFormat);
} else {
expectedFormat = format;
actualFormat = format;
}
final Model expectedModel;
final Model actualModel;
try (final InputStream expectedStream = new FileInputStream(expected);
final InputStream actualStream = new FileInputStream(actual)) {
expectedModel = Rio.parse(expectedStream, "base://", expectedFormat);
actualModel = Rio.parse(actualStream, "base://", actualFormat);
}
assertTrue("RDF files are not isomorphic",
Models.isomorphic(expectedModel, actualModel));
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Compares the models in the default contexts of the two supplied repositories and returns true if they
* are equal. Models are equal if they contain the same set of statements. bNodes IDs are not relevant for
* model equality, they are mapped from one model to the other by using the attached properties. Note that
* the method pulls the entire default context of both repositories into main memory. Use with caution.
*/
public static boolean equals(Repository rep1, Repository rep2)
throws RepositoryException
{
// Fetch statements from rep1 and rep2
Set<Statement> model1, model2;
RepositoryConnection con1 = rep1.getConnection();
try {
model1 = Iterations.asSet(con1.getStatements(null, null, null, true));
}
finally {
con1.close();
}
RepositoryConnection con2 = rep2.getConnection();
try {
model2 = Iterations.asSet(con2.getStatements(null, null, null, true));
}
finally {
con2.close();
}
return Models.isomorphic(model1, model2);
}
内容来源于网络,如有侵权,请联系作者删除!