public void testSameLongHash1() throws Exception {
int partitionCount = 2;
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), TheHashinator.getConfigureBytes(partitionCount));
HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
ExecutionEngine ee =
new ExecutionEngineJNI(
1,
1,
0,
0,
"",
100,
hashinatorConfig);
long valueToHash = 0;
int eehash = ee.hashinate(valueToHash, hashinatorConfig);
int javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(),
valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n",
VoltType.typeFromObject(valueToHash).toSQLString(),
valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
valueToHash = 1;
eehash = ee.hashinate(valueToHash, hashinatorConfig);
javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(),
valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n",
VoltType.typeFromObject(valueToHash).toSQLString(),
valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
valueToHash = 2;
eehash = ee.hashinate(valueToHash, hashinatorConfig);
javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(),
valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n",
VoltType.typeFromObject(valueToHash).toSQLString(),
valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
valueToHash = 3;
eehash = ee.hashinate(valueToHash, hashinatorConfig);
javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(),
valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n",
VoltType.typeFromObject(valueToHash).toSQLString(),
valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
try { ee.release(); } catch (Exception e) {}
}