📄 rdfrepositorypool.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.pools;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.util.ArrayList;import java.util.List;import org.openrdf.sesame.sail.NamespaceIterator;import org.openrdf.sesame.sail.RdfRepository;import org.openrdf.sesame.sail.test.benchmark.model.BMNamespace;/** * Pool used by benchmark test for testing of implementations of * nl.aidministrator.RdfRepository. * * @author Peter van 't Hof * @version %I%, %G% */public class RdfRepositoryPool extends RdfSourcePool {/*----------+| Variables |+----------*/ // RdfRepository which to extract pool from. protected RdfRepository _rdfRepository; /** * Prefix which does not exist. */ public static String noPrefix; /** * Name which does not exist. */ public static String noName; /** * List of namespaces. */ public static List namespaces;/*-------------+| Constructors |+-------------*/ /** * Creates a new pool which contains variables which are used by benchmark * test for testing of org.openrdf.sesame.sail.RdfRepository. * * @param rdfRepository RdfRepository which to extract variables from. */ public RdfRepositoryPool(RdfRepository rdfRepository) { super(rdfRepository); _rdfRepository = rdfRepository; }/*--------+| Methods |+--------*/ protected void _load(ObjectInputStream inputStream) throws IOException, ClassNotFoundException { super._load(inputStream); noPrefix = (String)inputStream.readObject(); noName = (String)inputStream.readObject(); namespaces = (List)inputStream.readObject(); } protected void _save(ObjectOutputStream outputStream) throws IOException { super._save(outputStream); outputStream.writeObject(noPrefix); outputStream.writeObject(noName); outputStream.writeObject(namespaces); } protected void _initialize() { super._initialize(); _status("Creating a prefix which does not exist..."); noPrefix = "myPrefix"; _status("Creating a name which does not exist..."); noName = "myName"; _status("Searching for namespaces..."); namespaces = _getNamespaces(50); } /* Creates a List of namespaces retrieved from repository with size is * preferredSize. Namespaces in List are distributed evenly over repository. * * Optimized approach, combination of streaming and in memory... */ protected List _getNamespaces(int preferredSize) { // Iterate over all namespaces and add them to List. List all = new ArrayList(); NamespaceIterator i = _rdfSource.getNamespaces(); while (i.hasNext()) { i.next(); all.add(new BMNamespace(i.getPrefix(), i.getName())); } i.close(); int size = all.size(); if (size == 0) { _warning("Repository has no namespaces."); return all; } else { // Else distribute namespaces in all over new List. return _distribute(all, preferredSize); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -