Java Code Examples for org.apache.hadoop.util.StringUtils#camelize()
The following examples show how to use
org.apache.hadoop.util.StringUtils#camelize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CPlanVectorPrimitivesTest.java From systemds with Apache License 2.0 | 5 votes |
@SuppressWarnings("incomplete-switch") private static void testVectorAggPrimitive(UnaryType aggtype, InputType type1) { try { //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 tmp = StringUtils.camelize(aggtype.name().split("_")[1]); String meName = "vect"+tmp.substring(0, tmp.length()-1); 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.getDenseBlockValues(), 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.slice(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; case ROW_MEANS: ret2 = in2.mean(); break; } //compare results TestUtils.compareCellValue(ret1, ret2, eps, false); } } catch( Exception ex ) { throw new RuntimeException(ex); } }
Example 2
Source File: CPlanVectorPrimitivesTest.java From systemds with Apache License 2.0 | 5 votes |
private static void testVectorUnaryPrimitive(UnaryType utype, InputType type1) { try { //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.getDenseBlockValues(), 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( in.slice(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); } }
Example 3
Source File: CPlanVectorPrimitivesTest.java From systemds with Apache License 2.0 | 5 votes |
@SuppressWarnings("incomplete-switch") private static void testVectorAggPrimitive(UnaryType aggtype, InputType type1) { try { //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 tmp = StringUtils.camelize(aggtype.name().split("_")[1]); String meName = "vect"+tmp.substring(0, tmp.length()-1); 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.getDenseBlockValues(), 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.slice(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; case ROW_MEANS: ret2 = in2.mean(); break; } //compare results TestUtils.compareCellValue(ret1, ret2, eps, false); } } catch( Exception ex ) { throw new RuntimeException(ex); } }
Example 4
Source File: CPlanVectorPrimitivesTest.java From systemds with Apache License 2.0 | 5 votes |
private static void testVectorUnaryPrimitive(UnaryType utype, InputType type1) { try { //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.getDenseBlockValues(), 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( in.slice(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); } }
Example 5
Source File: EntityOutputFomat.java From accumulo-recipes with Apache License 2.0 | 4 votes |
protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) { return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "." + StringUtils.camelize(e.name().toLowerCase()); }
Example 6
Source File: EventOutputFormat.java From accumulo-recipes with Apache License 2.0 | 4 votes |
protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) { return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "." + StringUtils.camelize(e.name().toLowerCase()); }
Example 7
Source File: EventQueue.java From hadoop-ozone with Apache License 2.0 | 3 votes |
/** * Add new handler to the event queue. * <p> * By default a separated single thread executor will be dedicated to * deliver the events to the registered event handler. * * @param event Triggering event. * @param handler Handler of event (will be called from a separated * thread) * @param handlerName The name of handler (should be unique together with * the event name) * @param <PAYLOAD> The type of the event payload. * @param <EVENT_TYPE> The type of the event identifier. */ public <PAYLOAD, EVENT_TYPE extends Event<PAYLOAD>> void addHandler( EVENT_TYPE event, EventHandler<PAYLOAD> handler, String handlerName) { validateEvent(event); Preconditions.checkNotNull(handler, "Handler name should not be null."); String executorName = StringUtils.camelize(event.getName()) + EXECUTOR_NAME_SEPARATOR + handlerName; this.addHandler(event, new SingleThreadExecutor<>(executorName), handler); }