⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdfschemasourcepool.java

📁 这是外国一个开源推理机
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*  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.pools;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import org.openrdf.vocabulary.RDFS;import org.openrdf.model.BNode;import org.openrdf.model.Resource;import org.openrdf.model.Statement;import org.openrdf.model.URI;import org.openrdf.model.Value;import org.openrdf.model.impl.URIImpl;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.util.BMUtil;/** * Pool used by benchmark test for testing of implementations of * nl.aidministrator.sail.RdfSchemaSource. * * @author Peter van 't Hof * @version %I%, %G% */public class RdfSchemaSourcePool extends RdfSourcePool {/*----------+| Variables |+----------*/	// RdfSchemaSource which to extract pool from.	protected RdfSchemaSource _rdfSchemaSource;	/**	 * List of explicit statements.	 */	public static List explicitStatements;	/**	 * List of explicit statements which do not exist.	 */	public static List noExplicitStatements;	/**	 * List of proper members of some class, e.g. every resource.	 */	public static List resources;	/**	 * List of resources which are a not proper member of some class.	 */	public static List notProperMembers;	/**	 * List of resources which are no class.	 */	public static List noClasses;	/**	 * List of resources which are no property.	 */	public static List noProperties;	/**	 * List of literals.	 */	public static List literals;	/**	 * List of classes.	 */	public static List classes;	/**	 * List of classes which can be instantiated by some resource.	 */	public static List classes2;	/**	 * List of classes which are a direct superClass of some subClass.	 */	public static List directSuperClasses;	/**	 * List of classes which are a superClass of some subClass.	 */	public static List superClasses;	/**	 * List of classes which have no subClass.	 */	public static List leafClasses;	/**	 * List of classes which are a direct subClass of some superClass.	 */	public static List directSubClasses;	/**	 * List of classes which are a subClass of some superClass.	 */	public static List subClasses;	/**	 * List of classes which have no superClass.	 */	public static List rootClasses;	/**	 * List of classes which are proper instantiated.	 */	public static List properInstantiatedClasses;	/**	 * List of classes which are instantiated.	 */	public static List instantiatedClasses;	/**	 * List of classes which are not proper instantiated.	 */	public static List notProperInstantiatedClasses;	/**	 * List of classes which are not instantiated.	 */	public static List notInstantiatedClasses;	/**	 * List of properties.	 */	public static List properties;	/**	 * List of properties which are a direct superProperty of some subProperty.	 */	public static List directSuperProperties;	/**	 * List of properties which are a superProperty of some subProperty.	 */	public static List superProperties;	/**	 * List of properties which have no subProperty.	 */	public static List leafProperties;	/**	 * List of properties which are a direct subProperty of some superProperty.	 */	public static List directSubProperties;	/**	 * List of properties which are a subProperty of some superProperty.	 */	public static List subProperties;	/**	 * List of properties which have no superProperty.	 */	public static List rootProperties;	/**	 * List of direct subClassOf relations represented by object Binary.	 */	public static List directSubClassOfRelations;	/**	 * List of subClassOf relations represented by class Binary, including	 * indirect.	 */	public static List subClassOfRelations;	/**	 * List of indirect subClassOf relations represented by object Binary.	 */ 	public static List indirectSubClassOfRelations;	/**	 * List of Binaries. Each Binary represents two classes which are no	 * subClass of eachother.	 */	public static List noSubClassOfRelations;	/**	 * List of direct subPropertyOf relations represented by object Binary.	 */	public static List directSubPropertyOfRelations;	/**	 * List of subPropertyOf relations represented by object Binary, including	 * indirect.	 */	public static List subPropertyOfRelations;	/**	 * List of indirect subPropertyOf relations represented by object Binary.	 */	public static List indirectSubPropertyOfRelations;	/**	 * List of Binaries. Each Binary represents two properties which are no	 * subProperty of eachother.	 */	public static List noSubPropertyOfRelations;	/**	 * List of proper instanceOf relations represented by object Binary.	 */ 	public static List properInstanceOfRelations;	/**	 * List of instanceOf relations represented by property Binary, including	 * indirect.	 */	public static List instanceOfRelations;	/**	 * List of not proper instanceOf relations represented by object Binary.	 */	public static List notProperInstanceOfRelations;	/**	 * List of Binaries. Each Binary represents an instance and a class, which	 * are no instanceOf eachother.	 */	public static List noInstanceOfRelations;	/* Buffers. These variables are used several times by the pool. To speed up	 * the proces of creating the pool of creating the pool, they are initialized	 * only once and stored in memory.	 */	protected static List _classes;	// Classes which can be instantiated by some resource.	protected static List _classesX;	/* Map with key Resource representing a class and value List representing	 * subClasses of key.	 */	protected Map _subClasses;	/* Map with key Resource representing a class and value Integer representing	 * number of direct subClasses of key.	 */	protected Map _numbersOfDirectSubClasses;	protected Map _numbersOfSubClasses;	// List of all subClassOf relations represented by object Binary.	protected List _subClassOf;	protected List _directSubClassOf;	protected Map _numbersOfProperInstances;	protected Map _numbersOfInstances;	protected List _properties;	protected Map _subProperties;	protected Map _numbersOfDirectSubProperties;	protected Map _numbersOfDirectSuperProperties;	protected Map _numbersOfSubProperties;	protected List _subPropertyOf;	protected List _directSubPropertyOf;/*-------------+| Constructors |+-------------*/	/**	 * Creates a new pool which contains variables which are used by benchmark	 * test for testing of org.openrdf.sesame.sail.RdfSchemaSource.	 *	 * @param rdfSchemaSource RdfSchemaSource which to extract variables from.	 */	public RdfSchemaSourcePool(RdfSchemaSource rdfSchemaSource) {		super(rdfSchemaSource);		_rdfSchemaSource = rdfSchemaSource;		_subClasses = new HashMap();		_numbersOfDirectSubClasses = new HashMap();		_numbersOfSubClasses = new HashMap();		_subClassOf = new ArrayList();		_directSubClassOf = new ArrayList();		_numbersOfProperInstances = new HashMap();		_numbersOfInstances = new HashMap();		_subProperties = new HashMap();		_numbersOfDirectSubProperties = new HashMap();		_numbersOfDirectSuperProperties = new HashMap();		_numbersOfSubProperties = new HashMap();		_subPropertyOf = new ArrayList();		_directSubPropertyOf = new ArrayList();	}/*--------+| Methods |+--------*/	protected void _initialize() {		// Initialize buffers.		_status("Buffering...");		// Create a List of all classes which can be instantiated by a resource,		// e.g. all classes except rdfs:Literal.		_classes = _toList(_rdfSchemaSource.getClasses());		Set set = new HashSet(_classes);		set.remove(new URIImpl(RDFS.LITERAL));		_classesX = new ArrayList(set);		Iterator i = _classes.iterator();		while (i.hasNext()) {			URI classResource = (URI)i.next();			// Collect and buffer all direct subClassOf relations. Also count			// and buffer number of direct subClassOf relations. 			int directSubClasses = 0;			StatementIterator j = _rdfSchemaSource.getDirectSubClassOf(null, classResource); 			while (j.hasNext()) {  				Statement stat = j.next();				Resource subClass = stat.getSubject();				// Don't store bNodes as their IDs may vary between different				// repositories or even different runs on the same repository.				if (subClass instanceof URI) {					_directSubClassOf.add(new Binary(subClass, classResource));					directSubClasses++;				}  			} 	 		j.close();	 		_numbersOfDirectSubClasses.put(classResource, new Integer(directSubClasses));			// Collect and buffer all subClassOf relations. Also count and buffer			// number of subClasses and subClasses.  			List subClasses = new ArrayList();	 		j = _rdfSchemaSource.getSubClassOf(null, classResource); 		 	while (j.hasNext()) {				Statement stat = j.next();	 		 	Resource subClass = stat.getSubject();				// Don't store bNodes as their IDs may vary between different				// repositories or even different runs on the same repository.				if (subClass instanceof URI) {					_subClassOf.add(new Binary(subClass, classResource));					subClasses.add(subClass);				}  			}	  		j.close();		 	_subClasses.put(classResource, subClasses); 	 		_numbersOfSubClasses.put(classResource, new Integer(subClasses.size()));			// Collect and buffer number of proper instances			int properInstancesOf = 0;			StatementIterator k = _rdfSchemaSource.getDirectType(null, classResource);			while (k.hasNext()) {				k.next();				properInstancesOf++;			}			k.close();			_numbersOfProperInstances.put(classResource, new Integer(properInstancesOf));			// Collect and buffer number of of instances.			int instancesOf = 0;			k = _rdfSchemaSource.getType(null, classResource);			while (k.hasNext()) {				k.next();				instancesOf++;			}			k.close();			_numbersOfInstances.put(classResource, new Integer(instancesOf));  		}		_properties = _toList(_rdfSchemaSource.getProperties());		i = _properties.iterator();		while (i.hasNext()) {			URI property = (URI)i.next();			int directSubProperties = 0;			StatementIterator j = _rdfSchemaSource.getDirectSubPropertyOf(null, property);			while (j.hasNext()) {				Statement stat = j.next();				Resource directSubProperty = stat.getSubject();				if (directSubProperty instanceof URI) {					_directSubPropertyOf.add(new Binary(directSubProperty, property));					directSubProperties++;				}			}			j.close();			_numbersOfDirectSubProperties.put(property, new Integer(directSubProperties));			List subProperties = new ArrayList();			j = _rdfSchemaSource.getSubPropertyOf(null, property);			while (j.hasNext()) {				Statement stat = j.next();				Resource subProperty = stat.getSubject();				if (subProperty instanceof URI) {					_subPropertyOf.add(new Binary(subProperty, property));					subProperties.add(subProperty);				}			}			j.close();			_subProperties.put(property, subProperties); 			_numbersOfSubProperties.put(property, new Integer(subProperties.size()));			// Count and buffer number of superProperties of property.			int superProperties = 0;			j = _rdfSchemaSource.getSubPropertyOf(property, null);			while (j.hasNext()) {				Value v = j.next().getObject();				if (v instanceof URI) {					superProperties++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -