📄 getsubpropertyof.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.StatementIterator;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.getSubPropertyOf. * * @author Peter van 't Hof. * @version %I%, %G% */public class GetSubPropertyOf extends RdfSchemaSourceBMTestB {/*-------------+| Constructors |+-------------*/ /** * Creates a new benchmark test which tests * org.openrdf.sesame.sail.RdfSchemaSource.getSubPropertyOf. * * @param rdfSchemaSource RdfSchemaSource to test. */ public GetSubPropertyOf(RdfSchemaSource rdfSchemaSource) { super("getSubPropertyOf", rdfSchemaSource); _needsPool = true; }/*--------+| Methods |+--------*/ // Gets subProperties of superProperties which have subProperties. protected void _testA() { // Part one: get all subPropertyOf relations. _startA(); _getSubPropertyOf(null, null, true); _stopA(); // Part two: get all subPropertyOf relations and query any combination // of sub- and superproperty. Iterator i = _cutDown(RdfSchemaSourcePool.subPropertyOfRelations, 32).iterator(); while (i.hasNext()) { Binary binary = (Binary)i.next(); Resource subProperty = (Resource)binary.getLeft(); Resource superProperty = (Resource)binary.getRight(); _startA(); _getSubPropertyOf(subProperty, null, true); _getSubPropertyOf(null, superProperty, true); _getSubPropertyOf(subProperty, superProperty, true); _stopA(3); } } // This method consists of two parts. See below. protected void _testB() { Iterator i = _cutDown(RdfSchemaSourcePool.noProperties, 32).iterator(); while (i.hasNext()) { Resource noProperty = (Resource)i.next(); _startB(); _getSubPropertyOf(noProperty, null, false); _getSubPropertyOf(null, noProperty, false); _getSubPropertyOf(noProperty, noProperty, false); _stopB(3); } } /* Call to RdfSchemaSource. Checks if result is equal to expected result. * SubProperties are iterated to simulate realworld use. */ protected void _getSubPropertyOf( Resource subProperty, Resource superProperty, boolean expected) { StatementIterator i = _rdfSchemaSource.getSubPropertyOf(subProperty, superProperty); if (i.hasNext() != expected) { String errMsg = "getSubPropertyOf(" + subProperty + ", " + superProperty + ") should return "; if (expected == false) { errMsg += "no "; } errMsg += "results."; _error(errMsg); } while (i.hasNext()) { _simulateUsage(i.next()); } i.close(); } public String toString() { return _toString("Results", "No results"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -