org.semanticweb.HermiT.tableau.ExtensionTableWithTupleIndexes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.semanticweb.hermit Show documentation
Show all versions of org.semanticweb.hermit Show documentation
HermiT is reasoner for ontologies written using the Web Ontology Language (OWL). Given an OWL file, HermiT can determine whether or not the ontology is consistent, identify subsumption relationships between classes, and much more.
This is the maven build of HermiT and is designed for people who wish to use HermiT from within the OWL API. It is now versioned in the main HermiT version repository, although not officially supported by the HermiT developers.
The version number of this package is a composite of the HermiT version and a value representing the OWLAPI release it is compatible with. Note that the group id for the upstream HermiT is com.hermit-reasoner, while this fork is released under net.sourceforge.owlapi.
This fork exists to allow HermiT users to use newer OWLAPI versions than the ones supported by the original HermiT codebase.
This package includes the Jautomata library (http://jautomata.sourceforge.net/), and builds with it directly. This library appears to be no longer under active development, and so a "fork" seems appropriate. No development is intended or anticipated on this code base.
The newest version!
/* Copyright 2008, 2009, 2010 by the Oxford University Computing Laboratory
This file is part of HermiT.
HermiT 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 3 of the License, or
(at your option) any later version.
HermiT 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 HermiT. If not, see .
*/
package org.semanticweb.HermiT.tableau;
import java.io.Serializable;
import org.semanticweb.HermiT.model.AtomicConcept;
import org.semanticweb.HermiT.model.AtomicRole;
import org.semanticweb.HermiT.model.Concept;
import org.semanticweb.HermiT.model.InternalDatatype;
/**
* This extension table is for use with binary and ternary assertions (not
* description graphs).
* @see ExtensionTableWithFullIndex
*/
public class ExtensionTableWithTupleIndexes extends ExtensionTable {
private static final long serialVersionUID=-684536236157965372L;
protected final TupleIndex[] m_tupleIndexes;
protected final Object[] m_auxiliaryTuple;
/**
* @param tableau tableau
* @param tupleArity tupleArity
* @param needsDependencySets needsDependencySets
* @param tupleIndexes tupleIndexes
*/
public ExtensionTableWithTupleIndexes(Tableau tableau,int tupleArity,boolean needsDependencySets,TupleIndex[] tupleIndexes) {
super(tableau,tupleArity,needsDependencySets);
m_tupleIndexes=tupleIndexes;
m_auxiliaryTuple=new Object[m_tupleArity];
}
@Override
public int sizeInMemory() {
int size=m_tupleTable.sizeInMemory();
for (int i=m_tupleIndexes.length-1;i>=0;--i)
size+=m_tupleIndexes[i].sizeInMemoy();
return size;
}
@Override
public boolean addTuple(Object[] tuple,DependencySet dependencySet,boolean isCore) {
if (m_tableauMonitor!=null)
m_tableauMonitor.addFactStarted(tuple,isCore);
if (isTupleActive(tuple) && (m_tableau.m_needsThingExtension || !AtomicConcept.THING.equals(tuple[0])) && (m_tableau.m_needsRDFSLiteralExtension || !InternalDatatype.RDFS_LITERAL.equals(tuple[0]))) {
int firstFreeTupleIndex=m_tupleTable.getFirstFreeTupleIndex();
int addTupleIndex=m_tupleIndexes[0].addTuple(tuple,firstFreeTupleIndex);
if (addTupleIndex==firstFreeTupleIndex) {
for (int index=1;index=0;--index) {
int[] indexingSequence=m_tupleIndexes[index].getIndexingSequence();
int boundPrefixSize=0;
for (int position=0;positionboundPrefixSizeInSelected) {
selectedTupleIndex=m_tupleIndexes[index];
boundPrefixSizeInSelected=boundPrefixSize;
}
}
if (selectedTupleIndex==null)
return new UnindexedRetrieval(bindingPositions,bindingsBuffer,tupleBuffer,ownsBuffers,extensionView);
else
return new IndexedRetrieval(selectedTupleIndex,bindingPositions,bindingsBuffer,tupleBuffer,ownsBuffers,extensionView);
}
@Override
protected void removeTuple(int tupleIndex) {
m_tupleTable.retrieveTuple(m_auxiliaryTuple,tupleIndex);
for (int index=m_tupleIndexes.length-1;index>=0;--index)
m_tupleIndexes[index].removeTuple(m_auxiliaryTuple);
postRemove(m_auxiliaryTuple,tupleIndex);
}
@Override
public void clear() {
super.clear();
for (int index=m_tupleIndexes.length-1;index>=0;--index)
m_tupleIndexes[index].clear();
}
protected class IndexedRetrieval extends TupleIndex.TupleIndexRetrieval implements Retrieval,Serializable {
private static final long serialVersionUID=2180748099314801734L;
protected final int[] m_bindingPositions;
protected final Object[] m_tupleBuffer;
protected final boolean m_ownsBuffers;
protected final ExtensionTable.View m_extensionView;
protected final boolean m_checkTupleSelection;
protected DependencySet m_dependencySet;
protected boolean m_isCore;
protected int m_firstTupleIndex;
protected int m_afterLastTupleIndex;
public IndexedRetrieval(TupleIndex tupleIndex,int[] bindingPositions,Object[] bindingsBuffer,Object[] tupleBuffer,boolean ownsBuffers,View extensionView) {
super(tupleIndex,bindingsBuffer,createSelectionArray(bindingPositions,tupleIndex.m_indexingSequence));
m_ownsBuffers=ownsBuffers;
m_bindingPositions=bindingPositions;
m_extensionView=extensionView;
m_tupleBuffer=tupleBuffer;
int numberOfBoundPositions=0;
for (int index=m_bindingPositions.length-1;index>=0;--index)
if (m_bindingPositions[index]!=-1)
numberOfBoundPositions++;
m_checkTupleSelection=(numberOfBoundPositions>m_selectionIndices.length);
}
@Override
public ExtensionTable getExtensionTable() {
return ExtensionTableWithTupleIndexes.this;
}
@Override
public ExtensionTable.View getExtensionView() {
return m_extensionView;
}
@Override
public void clear() {
if (m_ownsBuffers) {
for (int index=m_bindingsBuffer.length-1;index>=0;--index)
m_bindingsBuffer[index]=null;
for (int index=m_tupleBuffer.length-1;index>=0;--index)
m_tupleBuffer[index]=null;
}
}
@Override
public int[] getBindingPositions() {
return m_bindingPositions;
}
@Override
public Object[] getBindingsBuffer() {
return m_bindingsBuffer;
}
@Override
public Object[] getTupleBuffer() {
return m_tupleBuffer;
}
@Override
public DependencySet getDependencySet() {
return m_dependencySet;
}
@Override
public boolean isCore() {
return m_isCore;
}
@Override
public void open() {
switch (m_extensionView) {
case EXTENSION_THIS:
m_firstTupleIndex=0;
m_afterLastTupleIndex=m_afterExtensionThisTupleIndex;
break;
case EXTENSION_OLD:
m_firstTupleIndex=0;
m_afterLastTupleIndex=m_afterExtensionOldTupleIndex;
break;
case DELTA_OLD:
m_firstTupleIndex=m_afterExtensionOldTupleIndex;
m_afterLastTupleIndex=m_afterExtensionThisTupleIndex;
break;
case TOTAL:
m_firstTupleIndex=0;
m_afterLastTupleIndex=m_afterDeltaNewTupleIndex;
break;
default:
break;
}
super.open();
while (!afterLast()) {
int tupleIndex=getCurrentTupleIndex();
if (m_firstTupleIndex<=tupleIndex && tupleIndex=0;--index)
if (m_bindingPositions[index]!=-1 && !m_tupleBuffer[index].equals(m_bindingsBuffer[m_bindingPositions[index]]))
return false;
return true;
}
}
protected static int[] createSelectionArray(int[] bindingPositions,int[] indexingSequence) {
int boundPrefixLength=0;
for (int index=0;index