Return-Path: Delivered-To: apmail-uima-user-archive@www.apache.org Received: (qmail 97262 invoked from network); 4 Apr 2011 21:41:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Apr 2011 21:41:08 -0000 Received: (qmail 75408 invoked by uid 500); 4 Apr 2011 21:41:08 -0000 Delivered-To: apmail-uima-user-archive@uima.apache.org Received: (qmail 75378 invoked by uid 500); 4 Apr 2011 21:41:08 -0000 Mailing-List: contact user-help@uima.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@uima.apache.org Delivered-To: mailing list user@uima.apache.org Received: (qmail 75370 invoked by uid 99); 4 Apr 2011 21:41:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2011 21:41:08 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msa@schor.com designates 69.93.243.29 as permitted sender) Received: from [69.93.243.29] (HELO gateway06.websitewelcome.com) (69.93.243.29) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 04 Apr 2011 21:41:00 +0000 Received: (qmail 22904 invoked from network); 4 Apr 2011 21:41:20 -0000 Received: from gator74.hostgator.com (67.18.27.130) by gateway06.websitewelcome.com with SMTP; 4 Apr 2011 21:41:20 -0000 Received: from [129.34.20.19] (port=26116 helo=[9.2.35.72]) by gator74.hostgator.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Q6rVn-0003dH-0Q for user@uima.apache.org; Mon, 04 Apr 2011 16:40:39 -0500 Message-ID: <4D9A3ADC.9060406@schor.com> Date: Mon, 04 Apr 2011 17:40:44 -0400 From: Marshall Schor User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: user@uima.apache.org Subject: Re: How to override hashCode for a feature structure ? References: <4D999F19.7070009@gmail.com> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator74.hostgator.com X-AntiAbuse: Original Domain - uima.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - schor.com X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: yktgi01e0-s5.watson.ibm.com ([9.2.35.72]) [129.34.20.19]:26116 I think the framework may be making more assumptions about feature structure hashcodes and equals. It might be better to use some kind of aggregation in your annotator, instead of subclassing. The idea would be to create a new Java class which contained a reference to the feature structure instance, but implemented whatever you needed for hashcode and equals. This would then be outside of any object that the UIMA Framework would know about, so you couldn't break anything... This would cost an extra Java object per feature structure, however, unless your application already was making use of a similar kind of object for other reasons... -Marshall On 4/4/2011 7:42 AM, Philippe Vanden Bossche wrote: > 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; > } >