Package org.apache.flink.api.common.functions

Examples of org.apache.flink.api.common.functions.RichFunction


public class FunctionUtils {

  public static void openFunction (Function function, Configuration parameters) throws Exception{
    if (function instanceof RichFunction) {
      RichFunction richFunction = (RichFunction) function;
      richFunction.open (parameters);
    }
  }
View Full Code Here


    }
  }

  public static void closeFunction (Function function) throws Exception{
    if (function instanceof RichFunction) {
      RichFunction richFunction = (RichFunction) function;
      richFunction.close ();
    }
  }
View Full Code Here

    }
  }

  public static void setFunctionRuntimeContext (Function function, RuntimeContext context){
    if (function instanceof RichFunction) {
      RichFunction richFunction = (RichFunction) function;
      richFunction.setRuntimeContext(context);
    }
  }
View Full Code Here

    }
  }

  public static RuntimeContext getFunctionRuntimeContext (Function function, RuntimeContext defaultContext){
    if (function instanceof RichFunction) {
      RichFunction richFunction = (RichFunction) function;
      return richFunction.getRuntimeContext();
    }
    else {
      return defaultContext;
    }
  }
View Full Code Here

    try {
      AtomicInteger methodCounter = new AtomicInteger();
     
      ReduceOperator reduceOp = ReduceOperator.builder(new TestReduceFunction(methodCounter)).build();
     
      RichFunction reducer = (RichFunction) reduceOp.getUserCodeWrapper().getUserCodeObject();
     
      // test the method invocations
      reducer.close();
      reducer.open(new Configuration());
      assertEquals(2, methodCounter.get());
     
      // prepare the reduce / combine tests
      final List<Record> target = new ArrayList<Record>();
      Collector<Record> collector = new Collector<Record>() {
View Full Code Here

    try {
      AtomicInteger methodCounter = new AtomicInteger();
     
      CoGroupOperator coGroupOp = CoGroupOperator.builder(new TestCoGroupFunction(methodCounter), LongValue.class, 1, 2).build();
     
      RichFunction cogrouper = (RichFunction) coGroupOp.getUserCodeWrapper().getUserCodeObject();
     
      // test the method invocations
      cogrouper.close();
      cogrouper.open(new Configuration());
      assertEquals(2, methodCounter.get());
     
      // prepare the coGroup
      final List<Record> target = new ArrayList<Record>();
      Collector<Record> collector = new Collector<Record>() {
View Full Code Here

TOP

Related Classes of org.apache.flink.api.common.functions.RichFunction

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.