I think your test assertions are faulty, from https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Model.html#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. So size() is not guaranteed to include the count of inferred statements. If you want to count the size of an inference model you will need to iterate over the statements and count those directly as the Javadoc implies Rob On 21/09/2020, 10:27, "Martynas Jusevičius" <marty...@atomgraph.com> wrote: Alternatively, how do I create a read-only union which has all the statements of an InfModel? ModelFactory.createUnion() does not: Model union = ModelFactory.createUnion(ModelFactory.createDefaultModel(), infModel); assertEquals(infModel.size(), union.size()); expected:<1350> but was:<2264> On Mon, Sep 21, 2020 at 11:02 AM Martynas Jusevičius <marty...@atomgraph.com> wrote: > > Hi, > > I want to load an ontology with imports into an inference model, but > then materialize the triples as no further changes will be made to the > model and we would like to avoid the reasoner overhead for read-only > access. > > How does one do the materialization? Simple add() doesn't seem to cut it: > > @Test > public void testMaterialize() > { > OntModel infModel = > OntDocumentManager.getInstance().getOntology("https://www.w3.org/ns/ldt#", > OntModelSpec.OWL_MEM_RDFS_INF); > OntModel nonInfModel = > ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); > nonInfModel.add(infModel); > assertEquals(infModel.size(), nonInfModel.size()); > } > > expected:<1350> but was:<2264> > > > Martynas