📄 isdirectsubclassof.java
字号:
/* Sesame - Storage and Querying architecture for RDF and RDF Schema * Copyright (C) 2001-2005 Aduna * * Contact: * Aduna * Prinses Julianaplein 14 b * 3817 CS Amersfoort * The Netherlands * tel. +33 (0)33 465 99 87 * fax. +33 (0)33 465 99 87 * * http://aduna.biz/ * http://www.openrdf.org/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package org.openrdf.sesame.sail.test.benchmark.tests;import java.util.Iterator;import org.openrdf.model.Resource;import org.openrdf.sesame.sail.RdfSchemaSource;import org.openrdf.sesame.sail.test.benchmark.model.Binary;import org.openrdf.sesame.sail.test.benchmark.pools.RdfSchemaSourcePool;/** * Tests performance of org.openrdf.sesame.sail.RdfSchemaSource.isDirectSubClassOf. * * @author Peter van 't Hof. * @version %I%, %G% */public class IsDirectSubClassOf extends RdfSchemaSourceBMTestB {/*-------------+| Constructors |+-------------*/ /** * Creates a new benchmark test which tests * org.openrdf.sesame.sail.RdfSchemaSource.isDirectSubClassOf. * * @param rdfSchemaSource RdfSchemaSource to test. */ public IsDirectSubClassOf(RdfSchemaSource rdfSchemaSource) { super("isDirectSubClassOf", rdfSchemaSource); _needsPool = true; }/*--------+| Methods |+--------*/ /* Queries if a subClass which is a subClass of superClass is a * subClass of superClass. */ protected void _testA() { Iterator i = _cutDown(RdfSchemaSourcePool.directSubClassOfRelations, 100).iterator(); while (i.hasNext()) { Binary subClassOfRelation = (Binary)i.next(); Resource subClass = (Resource)subClassOfRelation.getLeft(); Resource superClass = (Resource)subClassOfRelation.getRight(); _startA(); _isDirectSubClassOf(subClass, superClass, true); _stopA(); } } protected void _testB() { // Part one: query if resources are a subClass of eachother, pattern // consists of resources which do not exist, resources which do exist but // are no class and classes. Iterator noClassesIter = _cutDown(RdfSchemaSourcePool.noClasses, 100).iterator(); Iterator classesIter = _cutDown(RdfSchemaSourcePool.classes, 100).iterator(); while (noClassesIter.hasNext() && classesIter.hasNext()) { Resource noClass = (Resource)noClassesIter.next(); Resource classResource = (Resource)classesIter.next(); _startB(); _isDirectSubClassOf(noClass, RdfSchemaSourcePool.noSubject, false); _isDirectSubClassOf(RdfSchemaSourcePool.noSubject, noClass, false); _isDirectSubClassOf(noClass, noClass, false); _isDirectSubClassOf(classResource, RdfSchemaSourcePool.noSubject, false); _isDirectSubClassOf(RdfSchemaSourcePool.noSubject, classResource, false); _isDirectSubClassOf(noClass, classResource, false); _isDirectSubClassOf(classResource, noClass, false); _stopB(7); } // Part two: query if subclass which is NOT a subClass of superClass // is a subClass of superClass. Iterator i = _cutDown(RdfSchemaSourcePool.noSubClassOfRelations, 100).iterator(); while (i.hasNext()) { Binary subClassOfRelation = (Binary)i.next(); Resource subClass = (Resource)subClassOfRelation.getLeft(); Resource superClass = (Resource)subClassOfRelation.getRight(); _startB(); _isDirectSubClassOf(subClass, superClass, false); _stopB(); } } protected void _isDirectSubClassOf( Resource subClass, Resource superClass, boolean expected) { if (expected != _rdfSchemaSource.isDirectSubClassOf(subClass, superClass)) { _error("isDirectSubClassOf(" + subClass + ", " + superClass + ") should be " + expected); } } public String toString() { return _toString("True", "False"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -