[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-237) IdHashShardingStrategy fails after 1.7M id is generated

Sanne Grinovero (JIRA) noreply at atlassian.com
Tue Sep 9 21:13:04 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31127#action_31127 ] 

Sanne Grinovero commented on HSEARCH-237:
-----------------------------------------

I'm going near the limit soon too so I suppose this is urgent for me ;-)
thanks, good catch!

> IdHashShardingStrategy fails after 1.7M id is generated
> -------------------------------------------------------
>
>                 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
>   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