org.apache.flink.runtime.broadcast.BroadcastVariableMaterialization Java Examples

The following examples show how to use org.apache.flink.runtime.broadcast.BroadcastVariableMaterialization. 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: DistributedRuntimeUDFContext.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public <T> List<T> getBroadcastVariable(String name) {
	Preconditions.checkNotNull(name, "The broadcast variable name must not be null.");
	
	// check if we have an initialized version
	@SuppressWarnings("unchecked")
	BroadcastVariableMaterialization<T, ?> variable = (BroadcastVariableMaterialization<T, ?>) this.broadcastVars.get(name);
	if (variable != null) {
		try {
			return variable.getVariable();
		}
		catch (InitializationTypeConflictException e) {
			throw new RuntimeException("The broadcast variable '" + name + "' has been initialized by a prior call to a " + e.getType());
		}
	}
	else {
		throw new IllegalArgumentException("The broadcast variable with name '" + name + "' has not been set.");
	}
}
 
Example #2
Source File: DistributedRuntimeUDFContext.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public <T> List<T> getBroadcastVariable(String name) {
	Preconditions.checkNotNull(name, "The broadcast variable name must not be null.");
	
	// check if we have an initialized version
	@SuppressWarnings("unchecked")
	BroadcastVariableMaterialization<T, ?> variable = (BroadcastVariableMaterialization<T, ?>) this.broadcastVars.get(name);
	if (variable != null) {
		try {
			return variable.getVariable();
		}
		catch (InitializationTypeConflictException e) {
			throw new RuntimeException("The broadcast variable '" + name + "' has been initialized by a prior call to a " + e.getType());
		}
	}
	else {
		throw new IllegalArgumentException("The broadcast variable with name '" + name + "' has not been set.");
	}
}
 
Example #3
Source File: DistributedRuntimeUDFContext.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public <T> List<T> getBroadcastVariable(String name) {
	Preconditions.checkNotNull(name, "The broadcast variable name must not be null.");
	
	// check if we have an initialized version
	@SuppressWarnings("unchecked")
	BroadcastVariableMaterialization<T, ?> variable = (BroadcastVariableMaterialization<T, ?>) this.broadcastVars.get(name);
	if (variable != null) {
		try {
			return variable.getVariable();
		}
		catch (InitializationTypeConflictException e) {
			throw new RuntimeException("The broadcast variable '" + name + "' has been initialized by a prior call to a " + e.getType());
		}
	}
	else {
		throw new IllegalArgumentException("The broadcast variable with name '" + name + "' has not been set.");
	}
}
 
Example #4
Source File: BatchTask.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
protected <X> void readAndSetBroadcastInput(int inputNum, String bcVarName, DistributedRuntimeUDFContext context, int superstep) throws IOException {
	
	if (LOG.isDebugEnabled()) {
		LOG.debug(formatLogString("Setting broadcast variable '" + bcVarName + "'" + 
			(superstep > 1 ? ", superstep " + superstep : "")));
	}
	
	@SuppressWarnings("unchecked")
	final TypeSerializerFactory<X> serializerFactory =  (TypeSerializerFactory<X>) this.broadcastInputSerializers[inputNum];
	
	final MutableReader<?> reader = this.broadcastInputReaders[inputNum];

	BroadcastVariableMaterialization<X, ?> variable = getEnvironment().getBroadcastVariableManager().materializeBroadcastVariable(bcVarName, superstep, this, reader, serializerFactory);
	context.setBroadcastVariable(bcVarName, variable);
}
 
Example #5
Source File: DistributedRuntimeUDFContext.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public <T, C> C getBroadcastVariableWithInitializer(String name, BroadcastVariableInitializer<T, C> initializer) {
	Preconditions.checkNotNull(name, "The broadcast variable name must not be null.");
	Preconditions.checkNotNull(initializer, "The broadcast variable initializer must not be null.");

	// check if we have an initialized version
	@SuppressWarnings("unchecked")
	BroadcastVariableMaterialization<T, C> variable = (BroadcastVariableMaterialization<T, C>) this.broadcastVars.get(name);
	if (variable != null) {
		return variable.getVariable(initializer);
	}
	else {
		throw new IllegalArgumentException("The broadcast variable with name '" + name + "' has not been set.");
	}
}
 
Example #6
Source File: BatchTask.java    From flink with Apache License 2.0 5 votes vote down vote up
protected <X> void readAndSetBroadcastInput(int inputNum, String bcVarName, DistributedRuntimeUDFContext context, int superstep) throws IOException {
	
	if (LOG.isDebugEnabled()) {
		LOG.debug(formatLogString("Setting broadcast variable '" + bcVarName + "'" + 
			(superstep > 1 ? ", superstep " + superstep : "")));
	}
	
	@SuppressWarnings("unchecked")
	final TypeSerializerFactory<X> serializerFactory =  (TypeSerializerFactory<X>) this.broadcastInputSerializers[inputNum];
	
	final MutableReader<?> reader = this.broadcastInputReaders[inputNum];

	BroadcastVariableMaterialization<X, ?> variable = getEnvironment().getBroadcastVariableManager().materializeBroadcastVariable(bcVarName, superstep, this, reader, serializerFactory);
	context.setBroadcastVariable(bcVarName, variable);
}
 
Example #7
Source File: DistributedRuntimeUDFContext.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public <T, C> C getBroadcastVariableWithInitializer(String name, BroadcastVariableInitializer<T, C> initializer) {
	Preconditions.checkNotNull(name, "The broadcast variable name must not be null.");
	Preconditions.checkNotNull(initializer, "The broadcast variable initializer must not be null.");

	// check if we have an initialized version
	@SuppressWarnings("unchecked")
	BroadcastVariableMaterialization<T, C> variable = (BroadcastVariableMaterialization<T, C>) this.broadcastVars.get(name);
	if (variable != null) {
		return variable.getVariable(initializer);
	}
	else {
		throw new IllegalArgumentException("The broadcast variable with name '" + name + "' has not been set.");
	}
}
 
Example #8
Source File: BatchTask.java    From flink with Apache License 2.0 5 votes vote down vote up
protected <X> void readAndSetBroadcastInput(int inputNum, String bcVarName, DistributedRuntimeUDFContext context, int superstep) throws IOException {
	
	if (LOG.isDebugEnabled()) {
		LOG.debug(formatLogString("Setting broadcast variable '" + bcVarName + "'" + 
			(superstep > 1 ? ", superstep " + superstep : "")));
	}
	
	@SuppressWarnings("unchecked")
	final TypeSerializerFactory<X> serializerFactory =  (TypeSerializerFactory<X>) this.broadcastInputSerializers[inputNum];
	
	final MutableReader<?> reader = this.broadcastInputReaders[inputNum];

	BroadcastVariableMaterialization<X, ?> variable = getEnvironment().getBroadcastVariableManager().materializeBroadcastVariable(bcVarName, superstep, this, reader, serializerFactory);
	context.setBroadcastVariable(bcVarName, variable);
}
 
Example #9
Source File: DistributedRuntimeUDFContext.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public <T, C> C getBroadcastVariableWithInitializer(String name, BroadcastVariableInitializer<T, C> initializer) {
	Preconditions.checkNotNull(name, "The broadcast variable name must not be null.");
	Preconditions.checkNotNull(initializer, "The broadcast variable initializer must not be null.");

	// check if we have an initialized version
	@SuppressWarnings("unchecked")
	BroadcastVariableMaterialization<T, C> variable = (BroadcastVariableMaterialization<T, C>) this.broadcastVars.get(name);
	if (variable != null) {
		return variable.getVariable(initializer);
	}
	else {
		throw new IllegalArgumentException("The broadcast variable with name '" + name + "' has not been set.");
	}
}
 
Example #10
Source File: DistributedRuntimeUDFContext.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public void setBroadcastVariable(String name, BroadcastVariableMaterialization<?, ?> value) {
	this.broadcastVars.put(name, value);
}
 
Example #11
Source File: DistributedRuntimeUDFContext.java    From flink with Apache License 2.0 4 votes vote down vote up
public void setBroadcastVariable(String name, BroadcastVariableMaterialization<?, ?> value) {
	this.broadcastVars.put(name, value);
}
 
Example #12
Source File: DistributedRuntimeUDFContext.java    From flink with Apache License 2.0 4 votes vote down vote up
public void setBroadcastVariable(String name, BroadcastVariableMaterialization<?, ?> value) {
	this.broadcastVars.put(name, value);
}