Package hivemall.knn.distance

Examples of hivemall.knn.distance.PopcountUDF


public class bBitMinHashUDFTest {

    @Test
    public void test() throws HiveException {
        bBitMinHashUDF bbminhash = new bBitMinHashUDF();
        PopcountUDF popcnt = new PopcountUDF();

        String a1 = bbminhash.evaluate(Arrays.asList("a", "b", "c"), false).toString();
        String a2 = bbminhash.evaluate(Arrays.asList("a", "b"), false).toString();
        Assert.assertFalse("a1: " + a1, bigint(a1).compareTo(bigint(0L)) < 0);
        Assert.assertFalse("a2: " + a2, bigint(a2).compareTo(bigint(0L)) < 0);
        Assert.assertTrue(popcnt.evaluate(a1, a2).get() > 0);

        String b1 = bbminhash.evaluate(Arrays.asList("a"), false).toString();
        String b2 = bbminhash.evaluate(Arrays.asList("b", "c"), false).toString();
        Assert.assertFalse("b1: " + b1, bigint(b1).compareTo(bigint(0L)) < 0);
        Assert.assertFalse("b2: " + b2, bigint(b2).compareTo(bigint(0L)) < 0);
        Assert.assertTrue(popcnt.evaluate(a1, a2).get() > popcnt.evaluate(b1, b2).get());

        String c1 = bbminhash.evaluate(Arrays.asList("a", "b", "c", "d", "e"), false).toString();
        String c2 = bbminhash.evaluate(Arrays.asList("b", "c", "e", "d"), false).toString();
        Assert.assertTrue(popcnt.evaluate(c1, c2).get() > popcnt.evaluate(a1, a2).get());
    }
View Full Code Here

TOP

Related Classes of hivemall.knn.distance.PopcountUDF

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.