当前位置: 首页>>代码示例>>Java>>正文


Java ExecutionEngineJNI类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:TestTheHashinator.java

示例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);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:17,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:34,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:31,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:36,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:33,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:71,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:42,代码来源:TestTheHashinator.java

示例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) {}
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:64,代码来源:TestTheHashinator.java


注:本文中的org.voltdb.jni.ExecutionEngineJNI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。