]
Sanne Grinovero reassigned HSEARCH-237:
---------------------------------------
Assignee: Sanne Grinovero
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: