Hello everyone,
I'm pretty new to UIMA and I'm currently developping a statistical annotator
that has to use a hashtable for efficiency purposes (I need to store all
annotations based on several feature values and to be able to retrieve
efficiently one of them knowing these feature values).
I then wanted to implement a specific hash function (hashCode) and equals
method to map two different feature structures (but considered equal) into
the same hashCode value. So I have tried to override the hashCode method of
my feature structure class.
However after that, the UIMA CAS Visual Debugger crashed completely.
After a little analysis of the stacktrace and the source code, it seems that
it comes from the class FSTreeModel at line 80: we use "fs.hashCode()"
(making the assumption that this returns an address).
So my question is : is there another known way of doing what I want (without
too performance costs) or is it necessary to change this "fs.hashCode()"
into something like "((TOP) fs).getAddress()" ?
For further informations, here is a part of the stack trace and the hashCode
method that caused it (contained in a class extending AnnotationBase):
Exception in thread "AWT-EventQueue-0"
java.lang.ArrayIndexOutOfBoundsException: 3347558
at org.apache.uima.cas.impl.CASImpl.getHeapValue(CASImpl.java:1957)
at org.apache.uima.tools.cvd.FSNode.getType(FSNode.java:331)
at org.apache.uima.tools.cvd.FSNode.initChildren(FSNode.java:107)
at org.apache.uima.tools.cvd.FSTreeNode.getChildCount(FSTreeNode.java:55)
at
org.apache.uima.tools.cvd.FSTreeModel.getChildCount(FSTreeModel.java:180)
at org.apache.uima.tools.cvd.FSTreeModel.isLeaf(FSTreeModel.java:187)
public int hashCode() {
int hashCode = 1;
for(int i = 0; i < this.getLemmas().size(); i++)
{
String lemma = this.getLemmas().get(i);
hashCode = 31 * hashCode + (lemma == null ? 0 : lemma.hashCode());
}
return hashCode;
}
|