Package org.voltdb.jni

Examples of org.voltdb.jni.ExecutionEngineJNI


    }

    @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) {}
    }
View Full Code Here


    }

    @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) {}
    }
View Full Code Here

        HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
        ExecutionEngine eeTemp = null;
        try {
            if (m_backend == BackendTarget.NATIVE_EE_JNI) {
                eeTemp =
                    new ExecutionEngineJNI(
                        m_context.cluster.getRelativeIndex(),
                        m_siteId,
                        m_partitionId,
                        CoreUtils.getHostIdFromHSId(m_siteId),
                        hostname,
View Full Code Here

TOP

Related Classes of org.voltdb.jni.ExecutionEngineJNI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.