package com.mapr.drill;

/**
 * Created by tdunning on 7/22/15.
 */
public class BinaryIntConverter {
}

@@ -22,83 +22,1005 @@
 l;%0A%0A
-/**%0A * Created by tdunning on 7/22/15.%0A */%0Apublic class BinaryIntConverter %7B
+import org.apache.drill.exec.expr.DrillSimpleFunc;%0Aimport org.apache.drill.exec.expr.annotations.FunctionTemplate;%0Aimport org.apache.drill.exec.expr.annotations.Output;%0Aimport org.apache.drill.exec.expr.annotations.Param;%0Aimport org.apache.drill.exec.expr.holders.IntHolder;%0Aimport org.apache.drill.exec.expr.holders.VarBinaryHolder;%0A%0A/**%0A * This is a helper UDF that converts bytes in big-endian format into an integer that%0A * Drill can use.%0A */%0Apublic class BinaryIntConverter %7B%0A    /**%0A     * Converts 4 byte big-endian values into integers.%0A     */%0A    @FunctionTemplate(isRandom = true, name = %22byte2int%22, scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)%0A    public static class BigEndianInt implements DrillSimpleFunc %7B%0A        @Param%0A        VarBinaryHolder raw;%0A%0A        @Output%0A        IntHolder output;%0A%0A        public void setup() %7B%0A        %7D%0A%0A        public void eval() %7B%0A            output.value = raw.buffer.getInt(0);%0A        %7D%0A    %7D
 %0A%7D%0A

Convert binary bytes to integer