當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。