org.apache.flink.api.common.operators.util.UserCodeObjectWrapper Java Examples

The following examples show how to use org.apache.flink.api.common.operators.util.UserCodeObjectWrapper. 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: JobTaskVertexTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputFormatVertex() {
	try {
		final TestInputFormat inputFormat = new TestInputFormat();
		final InputFormatVertex vertex = new InputFormatVertex("Name");
		new TaskConfig(vertex.getConfiguration()).setStubWrapper(new UserCodeObjectWrapper<InputFormat<?, ?>>(inputFormat));
		
		final ClassLoader cl = getClass().getClassLoader();
		
		vertex.initializeOnMaster(cl);
		InputSplit[] splits = vertex.getInputSplitSource().createInputSplits(77);
		
		assertNotNull(splits);
		assertEquals(1, splits.length);
		assertEquals(TestSplit.class, splits[0].getClass());
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #2
Source File: TaskTestBase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public void registerFileInputTask(AbstractInvokable inTask,
		Class<? extends DelimitedInputFormat<Record>> stubClass, String inPath, String delimiter)
{
	DelimitedInputFormat<Record> format;
	try {
		format = stubClass.newInstance();
	}
	catch (Throwable t) {
		throw new RuntimeException("Could not instantiate test input format.", t);
	}

	format.setFilePath(inPath);
	format.setDelimiter(delimiter);

	TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());
	dsConfig.setStubWrapper(new UserCodeObjectWrapper<>(format));

	this.inputSplitProvider.addInputSplits(inPath, 5);
}
 
Example #3
Source File: GenericDataSourceBase.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance for the given file using the given input format, using the default name.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo) {
	super(operatorInfo, DEFAULT_NAME);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
Example #4
Source File: TaskTestBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void registerFileOutputTask(FileOutputFormat<Record> outputFormat, String outPath) {
	TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());

	outputFormat.setOutputFilePath(new Path(outPath));
	outputFormat.setWriteMode(WriteMode.OVERWRITE);

	dsConfig.setStubWrapper(new UserCodeObjectWrapper<>(outputFormat));
}
 
Example #5
Source File: GenericDataSourceBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance for the given file using the given input format.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 * @param name The given name for the Pact, used in plans, logs and progress messages.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo, String name) {
	super(operatorInfo, name);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
Example #6
Source File: GenericDataSourceBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance for the given file using the given input format, using the default name.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo) {
	super(operatorInfo, DEFAULT_NAME);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
Example #7
Source File: GenericDataSourceBase.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance for the given file using the given input format.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 * @param name The given name for the Pact, used in plans, logs and progress messages.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo, String name) {
	super(operatorInfo, name);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
Example #8
Source File: GenericDataSourceBase.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance for the given file using the given input format.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 * @param name The given name for the Pact, used in plans, logs and progress messages.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo, String name) {
	super(operatorInfo, name);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
Example #9
Source File: GenericDataSourceBase.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance for the given file using the given input format, using the default name.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo) {
	super(operatorInfo, DEFAULT_NAME);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
Example #10
Source File: FlatMapOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public FlatMapOperatorBase(FT udf, UnaryOperatorInformation<IN, OUT> operatorInfo, String name) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, name);
}
 
Example #11
Source File: SortPartitionOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public SortPartitionOperatorBase(UnaryOperatorInformation<IN, IN> operatorInfo, Ordering partitionOrdering, String name) {
	super(new UserCodeObjectWrapper<NoOpFunction>(new NoOpFunction()), operatorInfo, name);
	this.partitionOrdering = partitionOrdering;
}
 
Example #12
Source File: PartitionOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public PartitionOperatorBase(UnaryOperatorInformation<IN, IN> operatorInfo, PartitionMethod pMethod, int[] keys, String name) {
	super(new UserCodeObjectWrapper<NoOpFunction>(new NoOpFunction()), operatorInfo, keys, name);
	this.partitionMethod = pMethod;
}
 
Example #13
Source File: InputOutputFormatContainer.java    From flink with Apache License 2.0 4 votes vote down vote up
public InputOutputFormatContainer addInputFormat(OperatorID operatorId, InputFormat<?, ?> inputFormat) {
	formats.addInputFormat(operatorId, new UserCodeObjectWrapper<>(inputFormat));
	return this;
}
 
Example #14
Source File: InputOutputFormatContainer.java    From flink with Apache License 2.0 4 votes vote down vote up
public InputOutputFormatContainer addOutputFormat(OperatorID operatorId, OutputFormat<?> outputFormat) {
	formats.addOutputFormat(operatorId, new UserCodeObjectWrapper<>(outputFormat));
	return this;
}
 
Example #15
Source File: InputOutputFormatContainer.java    From flink with Apache License 2.0 4 votes vote down vote up
public void write(TaskConfig config) {
	config.setStubWrapper(new UserCodeObjectWrapper<>(formats));
	config.setStubParameters(parameters);
}
 
Example #16
Source File: OuterJoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public OuterJoinOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo,
		int[] keyPositions1, int[] keyPositions2, String name, OuterJoinType outerJoinType) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, keyPositions1, keyPositions2, name);
	this.outerJoinType = outerJoinType;
}
 
Example #17
Source File: CrossOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public CrossOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
	this(new UserCodeObjectWrapper<FT>(udf), operatorInfo, name);
}
 
Example #18
Source File: JoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public JoinOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1, int[] keyPositions2, String name) {
	super(new UserCodeObjectWrapper<>(udf), operatorInfo, keyPositions1, keyPositions2, name);
}
 
Example #19
Source File: MapPartitionOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public MapPartitionOperatorBase(FT udf, UnaryOperatorInformation<IN, OUT> operatorInfo, String name) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, name);
}
 
Example #20
Source File: PartitionOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public PartitionOperatorBase(UnaryOperatorInformation<IN, IN> operatorInfo, PartitionMethod pMethod, String name) {
	super(new UserCodeObjectWrapper<NoOpFunction>(new NoOpFunction()), operatorInfo, name);
	this.partitionMethod = pMethod;
}
 
Example #21
Source File: CoGroupRawOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public CoGroupRawOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1, int[] keyPositions2, String name) {
	this(new UserCodeObjectWrapper<FT>(udf), operatorInfo, keyPositions1, keyPositions2, name);
}
 
Example #22
Source File: InnerJoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public InnerJoinOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1,
		int[] keyPositions2, String name) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, keyPositions1, keyPositions2, name);
}
 
Example #23
Source File: InputOutputFormatContainer.java    From flink with Apache License 2.0 4 votes vote down vote up
public void write(TaskConfig config) {
	config.setStubWrapper(new UserCodeObjectWrapper<>(formats));
	config.setStubParameters(parameters);
}
 
Example #24
Source File: InputOutputFormatContainer.java    From flink with Apache License 2.0 4 votes vote down vote up
public InputOutputFormatContainer addOutputFormat(OperatorID operatorId, OutputFormat<?> outputFormat) {
	formats.addOutputFormat(operatorId, new UserCodeObjectWrapper<>(outputFormat));
	return this;
}
 
Example #25
Source File: InputOutputFormatContainer.java    From flink with Apache License 2.0 4 votes vote down vote up
public InputOutputFormatContainer addInputFormat(OperatorID operatorId, InputFormat<?, ?> inputFormat) {
	formats.addInputFormat(operatorId, new UserCodeObjectWrapper<>(inputFormat));
	return this;
}
 
Example #26
Source File: FlatMapOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public FlatMapOperatorBase(FT udf, UnaryOperatorInformation<IN, OUT> operatorInfo, String name) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, name);
}
 
Example #27
Source File: SortPartitionOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public SortPartitionOperatorBase(UnaryOperatorInformation<IN, IN> operatorInfo, Ordering partitionOrdering, String name) {
	super(new UserCodeObjectWrapper<NoOpFunction>(new NoOpFunction()), operatorInfo, name);
	this.partitionOrdering = partitionOrdering;
}
 
Example #28
Source File: CrossOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public CrossOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
	this(new UserCodeObjectWrapper<FT>(udf), operatorInfo, name);
}
 
Example #29
Source File: JoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public JoinOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1, int[] keyPositions2, String name) {
	super(new UserCodeObjectWrapper<>(udf), operatorInfo, keyPositions1, keyPositions2, name);
}
 
Example #30
Source File: OuterJoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public OuterJoinOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo,
		int[] keyPositions1, int[] keyPositions2, String name, OuterJoinType outerJoinType) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, keyPositions1, keyPositions2, name);
	this.outerJoinType = outerJoinType;
}