本文整理汇总了Java中org.voltdb.jni.ExecutionEngineJNI类的典型用法代码示例。如果您正苦于以下问题:Java ExecutionEngineJNI类的具体用法?Java ExecutionEngineJNI怎么用?Java ExecutionEngineJNI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionEngineJNI类属于org.voltdb.jni包,在下文中一共展示了ExecutionEngineJNI类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSameLongHash
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
public void testSameLongHash() {
ExecutionEngine ee = new ExecutionEngineJNI(null, 1, 1, 0, 0, "");
/**
* Run with 100k of random values and make sure C++ and Java hash to
* the same value.
*/
for (int i = 0; i < 100000; i++) {
int partitionCount = r.nextInt(1000) + 1;
// this will produce negative values, which is desired here.
long valueToHash = r.nextLong();
int eehash = ee.hashinate(valueToHash, partitionCount);
int javahash = TheHashinator.hashinate(valueToHash, partitionCount);
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash > -1);
}
}
示例2: testSameStringHash
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
public void testSameStringHash() {
ExecutionEngine ee = new ExecutionEngineJNI(null, 1, 1, 0, 0, "");
for (int i = 0; i < 100000; i++) {
int partitionCount = r.nextInt(1000) + 1;
String valueToHash = Long.toString(r.nextLong());
int eehash = ee.hashinate(valueToHash, partitionCount);
int javahash = TheHashinator.hashinate(valueToHash, partitionCount);
if (eehash != javahash) {
partitionCount++;
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
}
}
示例3: testExpectNonZeroHash
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
public void testExpectNonZeroHash() throws Exception {
int partitionCount = 3;
final byte configBytes[] = TheHashinator.getConfigureBytes(partitionCount);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
HashinatorConfig config = TheHashinator.getCurrentConfig();
ExecutionEngine ee =
new ExecutionEngineJNI(
1,
1,
0,
0,
"",
100,
config);
long valueToHash = hashinatorType == HashinatorType.ELASTIC ? 39: 2;
int eehash = ee.hashinate(valueToHash, config);
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);
assertNotSame(0, eehash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
try { ee.release(); } catch (Exception e) {}
}
示例4: testSameLongHash
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
public void testSameLongHash() throws Exception {
byte configBytes[] = TheHashinator.getConfigureBytes(1);
ExecutionEngine ee = new ExecutionEngineJNI(1, 1, 0, 0, "", 100, new HashinatorConfig(hashinatorType, configBytes, 0, 0));
/**
* Run with 10k of random values and make sure C++ and Java hash to
* the same value.
*/
for (int i = 0; i < 1500; i++) {
final int partitionCount = r.nextInt(1000) + 1;
configBytes = TheHashinator.getConfigureBytes(partitionCount);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
// this will produce negative values, which is desired here.
final long valueToHash = r.nextLong();
final int javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(),
valueToHash);
final int eehash = ee.hashinate(valueToHash, TheHashinator.getCurrentConfig());
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 > -1);
}
try { ee.release(); } catch (Exception e) {}
}
示例5: testSameStringHash
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
public void testSameStringHash() throws Exception {
byte configBytes[] = TheHashinator.getConfigureBytes(1);
ExecutionEngine ee =
new ExecutionEngineJNI(
1,
1,
0,
0,
"",
100,
new HashinatorConfig(hashinatorType, configBytes, 0, 0));
for (int i = 0; i < 1500; i++) {
int partitionCount = r.nextInt(1000) + 1;
configBytes = TheHashinator.getConfigureBytes(partitionCount);
String valueToHash = Long.toString(r.nextLong());
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
int eehash = ee.hashinate(valueToHash, TheHashinator.getCurrentConfig());
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);
partitionCount++;
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
}
try { ee.release(); } catch (Exception e) {}
}
示例6: testSameBytesHash
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
public void testSameBytesHash() throws Exception {
ExecutionEngine ee =
new ExecutionEngineJNI(
1,
1,
0,
0,
"",
100,
new HashinatorConfig(hashinatorType, TheHashinator.getConfigureBytes(6), 0, 0));
for (int i = 0; i < 2500; i++) {
int partitionCount = r.nextInt(1000) + 1;
byte[] valueToHash = new byte[r.nextInt(1000)];
r.nextBytes(valueToHash);
final byte configBytes[] = TheHashinator.getConfigureBytes(partitionCount);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
int eehash = ee.hashinate(valueToHash, TheHashinator.getCurrentConfig());
int javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromClass(byte[].class).getValue(),
valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d bytes %d partitions => EE: %d Java: %d\n",
VoltType.typeFromObject(valueToHash).toSQLString(),
valueToHash.length, partitionCount, eehash, javahash);
partitionCount++;
}
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
assertEquals(eehash, javahash);
}
try { ee.release(); } catch (Exception e) {}
}
示例7: testSameLongHash1
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
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) {}
}
示例8: testEdgeCases
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
public void testEdgeCases() throws Exception {
byte configBytes[] = TheHashinator.getConfigureBytes(1);
ExecutionEngine ee =
new ExecutionEngineJNI(
1,
1,
0,
0,
"",
100,
new HashinatorConfig(hashinatorType, configBytes, 0, 0));
/**
* Run with 100k of random values and make sure C++ and Java hash to
* the same value.
*/
for (int i = 0; i < 500; i++) {
int partitionCount = r.nextInt(1000) + 1;
long[] values = new long[] {
Long.MIN_VALUE, Long.MAX_VALUE, Long.MAX_VALUE - 1, Long.MIN_VALUE + 1
};
configBytes = TheHashinator.getConfigureBytes(partitionCount);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
for (long valueToHash : values) {
int eehash = ee.hashinate(valueToHash, TheHashinator.getCurrentConfig());
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);
}
}
try { ee.release(); } catch (Exception e) {}
}
示例9: testNulls
import org.voltdb.jni.ExecutionEngineJNI; //导入依赖的package包/类
@Test
public void testNulls() throws Exception {
ExecutionEngine ee =
new ExecutionEngineJNI(
1,
1,
0,
0,
"",
100,
new HashinatorConfig(hashinatorType, TheHashinator.getConfigureBytes(2), 0, 0));
final byte configBytes[] = TheHashinator.getConfigureBytes(2);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
int jHash =
TheHashinator.getPartitionForParameter(VoltType.TINYINT.getValue(), new Byte(VoltType.NULL_TINYINT));
int cHash = ee.hashinate(VoltType.NULL_TINYINT, TheHashinator.getCurrentConfig());
assertEquals(0, jHash);
assertEquals(jHash, cHash);
System.out.println("jhash " + jHash + " chash " + cHash);
jHash = TheHashinator.getPartitionForParameter(VoltType.SMALLINT.getValue(),
new Short(VoltType.NULL_SMALLINT));
cHash = ee.hashinate(VoltType.NULL_SMALLINT, TheHashinator.getCurrentConfig());
assertEquals(0, jHash);
assertEquals(jHash, cHash);
System.out.println("jhash " + jHash + " chash " + cHash);
jHash = TheHashinator.getPartitionForParameter(VoltType.INTEGER.getValue(),
new Integer(VoltType.NULL_INTEGER));
cHash = ee.hashinate(
VoltType.NULL_INTEGER,
TheHashinator.getCurrentConfig());
assertEquals(0, jHash);
assertEquals(jHash, cHash);
System.out.println("jhash " + jHash + " chash " + cHash);
jHash = TheHashinator.getPartitionForParameter(VoltType.BIGINT.getValue(), new Long(VoltType.NULL_BIGINT));
cHash = ee.hashinate(
VoltType.NULL_BIGINT,
TheHashinator.getCurrentConfig());
assertEquals(0, jHash);
assertEquals(jHash, cHash);
System.out.println("jhash " + jHash + " chash " + cHash);
jHash = TheHashinator.getPartitionForParameter(VoltType.STRING.getValue(),
VoltType.NULL_STRING_OR_VARBINARY);
cHash = ee.hashinate(
VoltType.NULL_STRING_OR_VARBINARY,
TheHashinator.getCurrentConfig());
assertEquals(0, jHash);
assertEquals(jHash, cHash);
System.out.println("jhash " + jHash + " chash " + cHash);
jHash = TheHashinator.getPartitionForParameter(VoltType.VARBINARY.getValue(), null);
cHash = ee.hashinate(
null,
TheHashinator.getCurrentConfig());
assertEquals(0, jHash);
assertEquals(jHash, cHash);
System.out.println("jhash " + jHash + " chash " + cHash);
try { ee.release(); } catch (Exception e) {}
}