Definition of hashcode() in Feature is deficient, leading to extreme times to load shape files

Description

Loading a shape file with a large number of features takes an inordinately large amount of time. On closer investigation, this was found to be the result of a large number of calls to the equals() method in DefaultFeature. On closer inspection, it was found that the hashcode() method in DefaultFeature consistently returned 0, leading to the performance issue.

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:15 PM

CodeHaus Comment From: ianschneider - Time: Wed, 28 Jan 2004 11:26:15 -0600
---------------------
Further investigation showed that the problem comes from hashCode in FeatureType. If the FeatureType has an empty namespace, the hashCode of this string becomes 0, which quickly makes everything else, well, 0.

Due to the immutable nature of FeatureType, it would be prudent to calculate the FeatureType hash at instantiation and store it.

codehaus
April 10, 2015, 3:15 PM

CodeHaus Comment From: ianschneider - Time: Wed, 28 Jan 2004 17:33:11 -0600
---------------------
Affected Versions:

DefaultFeature 1.14

DefaultFeatureType 1.15

DefaultAttributeType 1.22

Thanks Julian, for taking the time to track this down and point it out. It was indeed severe, as a several MB shapefile would take 80 seconds to load with the broken behavior, and only 1.8 seconds with the fixes.

codehaus
April 10, 2015, 3:15 PM

CodeHaus Comment From: jelliott - Time: Thu, 29 Jan 2004 04:57:35 -0600
---------------------
Thanks very much for the fix, and for your prompt attention to this problem!

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Priority

Medium
Configure