[hibernate-issues] [Hibernate-JIRA] Updated: (HSEARCH-237) IdHashShardingStrategy fails on IDs having negative hashcode
Sanne Grinovero (JIRA)
noreply at atlassian.com
Sun Sep 14 04:56:05 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sanne Grinovero updated HSEARCH-237:
------------------------------------
Fix Version/s: 3.1.0.Beta2
Summary: IdHashShardingStrategy fails on IDs having negative hashcode (was: IdHashShardingStrategy fails after 1.7M id is generated)
> IdHashShardingStrategy fails on IDs having negative hashcode
> ------------------------------------------------------------
>
> Key: HSEARCH-237
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-237
> Project: Hibernate Search
> Issue Type: Bug
> Affects Versions: 3.0.0.GA
> Reporter: Rafal Glowacz
> Assignee: Sanne Grinovero
> Fix For: 3.1.0.Beta2
>
> Original Estimate: 30 minutes
> Remaining Estimate: 30 minutes
>
> public class IdShardingStrategyTest extends TestCase
> {
> private IdHashShardingStrategy _defaultIdStrategy;
> private IdShardingStrategy _idStrategy;
> protected void setUp() throws Exception {
> _idStrategy = new IdShardingStrategy();
> _idStrategy.initialize(null, createDirectoryProviders());
> _defaultIdStrategy = new IdHashShardingStrategy();
> _defaultIdStrategy.initialize(null, createDirectoryProviders());
> }
> private DirectoryProvider[] createDirectoryProviders() {
> return new DirectoryProvider[]{new MockDirectoryProvider(),
> new MockDirectoryProvider(),
> new MockDirectoryProvider()};
> }
> public void testIdSharding() {
> long id = 1;
> long limit = 1000 * 1000000 * 1000000L;
> try {
> while (id < limit) {
> generateForAddition(_idStrategy, id);
> generateForDeletion(_idStrategy, id);
> id += 129653153;
> }
> } catch (Exception e) {
> fail("Couldn't get directory for id " + id);
> }
> }
> public void testIdHashSharding() {
> long id = 1;
> long limit = 1000 * 1000000 * 1000000L;
> try {
> while (id < limit) {
> generateForAddition(_defaultIdStrategy, id);
> generateForDeletion(_defaultIdStrategy, id);
> id += 129653153;
> }
> fail("Should fail with ArrayIndexOutOfBoundsException for long id");
> } catch (Exception e) {
> }
> }
> private MockDirectoryProvider generateForAddition(IndexShardingStrategy strategy, long id) {
> return (MockDirectoryProvider) strategy.getDirectoryProviderForAddition(null, id, id + "", null);
> }
> private DirectoryProvider[] generateForDeletion(IndexShardingStrategy strategy, long id) {
> return strategy.getDirectoryProvidersForDeletion(null, id, id + "");
> }
> }
> Workaround:
> Returned value is minus for id's bigger then 1.7M so for time being I added check like: return value < 0 ? -1 * value : value; Works fine for me.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list