Example usage for org.apache.hadoop.util StringUtils camelize

List of usage examples for org.apache.hadoop.util StringUtils camelize

Introduction

In this page you can find the example usage for org.apache.hadoop.util StringUtils camelize.

Prototype

public static String camelize(String s) 

Source Link

Document

Convert SOME_STUFF to SomeStuff

Usage

From source file:org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase.java

License:Apache License

/**
 * Provides a configuration key for a given feature enum, prefixed by the implementingClass
 *
 * @param implementingClass//from  w w  w.j  a  v a  2  s.  c o m
 *          the class whose name will be used as a prefix for the property configuration key
 * @param e
 *          the enum used to provide the unique part of the configuration key
 * @return the configuration key
 * @since 1.6.0
 */
protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) {
    return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "."
            + StringUtils.camelize(e.name().toLowerCase());
}

From source file:org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase.java

License:Apache License

/**
 * Provides a configuration key for a given feature enum.
 *
 * @param e//w  ww.  j a  v a  2s. c  om
 *          the enum used to provide the unique part of the configuration key
 * @return the configuration key
 */
protected static String enumToConfKey(Enum<?> e) {
    return e.getDeclaringClass().getSimpleName() + "." + StringUtils.camelize(e.name().toLowerCase());
}

From source file:org.apache.accumulo.core.client.mapreduce.lib.util.ConfiguratorBase.java

License:Apache License

/**
 * Provides a configuration key for a given feature enum, prefixed by the implementingClass
 *
 * @param implementingClass/* w w w.j a  v  a  2s .c om*/
 *          the class whose name will be used as a prefix for the property configuration key
 * @param e
 *          the enum used to provide the unique part of the configuration key
 * @return the configuration key
 * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
 * @since 1.5.0
 */
@Deprecated
protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) {
    return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "."
            + StringUtils.camelize(e.name().toLowerCase());
}

From source file:org.apache.sysml.test.integration.functions.codegen.CPlanVectorPrimitivesTest.java

License:Apache License

@SuppressWarnings("incomplete-switch")
private static void testVectorAggPrimitive(UnaryType aggtype, InputType type1) {
    try {/*  w w w  . j  a  v  a  2  s  . com*/
        //generate input data
        double sparsity = (type1 == InputType.VECTOR_DENSE) ? sparsity1 : sparsity2;
        MatrixBlock in = MatrixBlock.randOperations(m, n, sparsity, -1, 1, "uniform", 7);

        //get vector primitive via reflection
        String meName = "vect" + StringUtils.camelize(aggtype.name().split("_")[1].substring(0, 3));
        Method me = (type1 == InputType.VECTOR_DENSE)
                ? LibSpoofPrimitives.class.getMethod(meName,
                        new Class[] { double[].class, int.class, int.class })
                : LibSpoofPrimitives.class.getMethod(meName,
                        new Class[] { double[].class, int[].class, int.class, int.class, int.class });

        for (int i = 0; i < m; i++) {
            //execute vector primitive via reflection
            Double ret1 = (Double) ((type1 == InputType.VECTOR_DENSE)
                    ? me.invoke(null, in.getDenseBlock(), i * n, n)
                    : me.invoke(null, in.getSparseBlock().values(i), in.getSparseBlock().indexes(i),
                            in.getSparseBlock().pos(i), in.getSparseBlock().size(i), n));

            //execute comparison operation
            MatrixBlock in2 = in.sliceOperations(i, i, 0, n - 1, new MatrixBlock());
            Double ret2 = -1d;
            switch (aggtype) {
            case ROW_SUMS:
                ret2 = in2.sum();
                break;
            case ROW_MAXS:
                ret2 = in2.max();
                break;
            case ROW_MINS:
                ret2 = in2.min();
                break;
            }

            //compare results
            TestUtils.compareCellValue(ret1, ret2, eps, false);
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.apache.sysml.test.integration.functions.codegen.CPlanVectorPrimitivesTest.java

License:Apache License

private static void testVectorUnaryPrimitive(UnaryType utype, InputType type1) {
    try {/*from www  .  j  ava  2s .c om*/
        //generate input data
        double sparsity = (type1 == InputType.VECTOR_DENSE) ? sparsity1 : sparsity2;
        MatrixBlock in = MatrixBlock.randOperations(m, n, sparsity, -1, 1, "uniform", 7);

        //get vector primitive via reflection
        String meName = "vect" + StringUtils.camelize(utype.name().split("_")[1]) + "Write";
        Method me = (type1 == InputType.VECTOR_DENSE)
                ? LibSpoofPrimitives.class.getMethod(meName,
                        new Class[] { double[].class, int.class, int.class })
                : LibSpoofPrimitives.class.getMethod(meName,
                        new Class[] { double[].class, int[].class, int.class, int.class, int.class });

        for (int i = 0; i < m; i++) {
            //execute vector primitive via reflection
            double[] ret1 = (double[]) ((type1 == InputType.VECTOR_DENSE)
                    ? me.invoke(null, in.getDenseBlock(), i * n, n)
                    : me.invoke(null, in.getSparseBlock().values(i), in.getSparseBlock().indexes(i),
                            in.getSparseBlock().pos(i), in.getSparseBlock().size(i), n));

            //execute comparison operation
            String opcode = utype.name().split("_")[1].toLowerCase();
            UnaryOperator uop = new UnaryOperator(Builtin.getBuiltinFnObject(opcode));
            double[] ret2 = DataConverter
                    .convertToDoubleVector(((MatrixBlock) in.sliceOperations(i, i, 0, n - 1, new MatrixBlock())
                            .unaryOperations(uop, new MatrixBlock())), false);

            //compare results
            TestUtils.compareMatrices(ret1, ret2, eps);
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.apache.sysml.test.integration.functions.codegen.CPlanVectorPrimitivesTest.java

License:Apache License

private static void testVectorBinaryPrimitive(BinType bintype, InputType type1, InputType type2) {
    try {/* w  w w .  j a  va 2  s.c  o m*/
        //generate input data (scalar later derived if needed)
        double sparsityA = (type1 == InputType.VECTOR_DENSE) ? sparsity1 : sparsity2;
        MatrixBlock inA = MatrixBlock.randOperations(m, n, sparsityA, -5, 5, "uniform", 3);
        double sparsityB = (type2 == InputType.VECTOR_DENSE) ? sparsity1 : sparsity2;
        MatrixBlock inB = MatrixBlock.randOperations(m, n, sparsityB, -5, 5, "uniform", 7);

        //get vector primitive via reflection
        String meName = "vect" + StringUtils.camelize(bintype.name().split("_")[1]) + "Write";
        Method me = null;
        if (type1 == InputType.SCALAR && type2 == InputType.VECTOR_DENSE)
            me = LibSpoofPrimitives.class.getMethod(meName,
                    new Class[] { double.class, double[].class, int.class, int.class });
        else if (type1 == InputType.VECTOR_DENSE && type2 == InputType.SCALAR)
            me = LibSpoofPrimitives.class.getMethod(meName,
                    new Class[] { double[].class, double.class, int.class, int.class });
        else if (type1 == InputType.VECTOR_DENSE && type2 == InputType.VECTOR_DENSE)
            me = LibSpoofPrimitives.class.getMethod(meName,
                    new Class[] { double[].class, double[].class, int.class, int.class, int.class });
        else if (type1 == InputType.VECTOR_SPARSE && type2 == InputType.SCALAR)
            me = LibSpoofPrimitives.class.getMethod(meName,
                    new Class[] { double[].class, double.class, int[].class, int.class, int.class, int.class });
        else if (type1 == InputType.SCALAR && type2 == InputType.VECTOR_SPARSE)
            me = LibSpoofPrimitives.class.getMethod(meName,
                    new Class[] { double.class, double[].class, int[].class, int.class, int.class, int.class });
        else if (type1 == InputType.VECTOR_SPARSE && type2 == InputType.VECTOR_DENSE)
            me = LibSpoofPrimitives.class.getMethod(meName, new Class[] { double[].class, double[].class,
                    int[].class, int.class, int.class, int.class, int.class });

        for (int i = 0; i < m; i++) {
            //execute vector primitive via reflection
            double[] ret1 = null;
            if (type1 == InputType.SCALAR && type2 == InputType.VECTOR_DENSE)
                ret1 = (double[]) me.invoke(null, inA.max(), inB.getDenseBlock(), i * n, n);
            else if (type1 == InputType.VECTOR_DENSE && type2 == InputType.SCALAR)
                ret1 = (double[]) me.invoke(null, inA.getDenseBlock(), inB.max(), i * n, n);
            else if (type1 == InputType.VECTOR_DENSE && type2 == InputType.VECTOR_DENSE)
                ret1 = (double[]) me.invoke(null, inA.getDenseBlock(), inB.getDenseBlock(), i * n, i * n, n);
            else if (type1 == InputType.VECTOR_SPARSE && type2 == InputType.SCALAR)
                ret1 = (double[]) me.invoke(null, inA.getSparseBlock().values(i), inB.max(),
                        inA.getSparseBlock().indexes(i), inA.getSparseBlock().pos(i),
                        inA.getSparseBlock().size(i), n);
            else if (type1 == InputType.SCALAR && type2 == InputType.VECTOR_SPARSE)
                ret1 = (double[]) me.invoke(null, inA.max(), inB.getSparseBlock().values(i),
                        inB.getSparseBlock().indexes(i), inB.getSparseBlock().pos(i),
                        inB.getSparseBlock().size(i), n);
            else if (type1 == InputType.VECTOR_SPARSE && type2 == InputType.VECTOR_DENSE)
                ret1 = (double[]) me.invoke(null, inA.getSparseBlock().values(i), inB.getDenseBlock(),
                        inA.getSparseBlock().indexes(i), inA.getSparseBlock().pos(i), i * n,
                        inA.getSparseBlock().size(i), n);

            //execute comparison operation
            String opcode = Hop.getBinaryOpCode(OpOp2.valueOf(bintype.name().split("_")[1]));
            MatrixBlock in1 = inA.sliceOperations(i, i, 0, n - 1, new MatrixBlock());
            MatrixBlock in2 = inB.sliceOperations(i, i, 0, n - 1, new MatrixBlock());
            double[] ret2 = null;
            if (type1 == InputType.SCALAR) {
                ScalarOperator bop = InstructionUtils.parseScalarBinaryOperator(opcode, true);
                bop = bop.setConstant(inA.max());
                ret2 = DataConverter.convertToDoubleVector(
                        (MatrixBlock) in2.scalarOperations(bop, new MatrixBlock()), false);
            } else if (type2 == InputType.SCALAR) {
                ScalarOperator bop = InstructionUtils.parseScalarBinaryOperator(opcode, false);
                bop = bop.setConstant(inB.max());
                ret2 = DataConverter.convertToDoubleVector(
                        (MatrixBlock) in1.scalarOperations(bop, new MatrixBlock()), false);
            } else { //vector-vector
                BinaryOperator bop = InstructionUtils.parseBinaryOperator(opcode);
                ret2 = DataConverter.convertToDoubleVector(
                        (MatrixBlock) in1.binaryOperations(bop, in2, new MatrixBlock()), false);
            }

            //compare results
            TestUtils.compareMatrices(ret1, ret2, eps);
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}