当前位置: 首页>>代码示例>>Java>>正文


Java CompilerHints类代码示例

本文整理汇总了Java中org.apache.flink.api.common.operators.CompilerHints的典型用法代码示例。如果您正苦于以下问题:Java CompilerHints类的具体用法?Java CompilerHints怎么用?Java CompilerHints使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompilerHints类属于org.apache.flink.api.common.operators包,在下文中一共展示了CompilerHints类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AbstractConfigBuilder

import org.apache.flink.api.common.operators.CompilerHints; //导入依赖的package包/类
/**
 * Creates a new builder for the given configuration.
 *
 * @param contract The contract from which the the compiler hints are used. 
 *                 If contract is null, new compiler hints are generated.  
 * @param config The configuration into which the parameters will be written.
 */
protected AbstractConfigBuilder(Operator<?> contract, Configuration config) {
	super(config);
	
	if (contract != null) {
		this.hints = new RecordFormatCompilerHints(contract.getCompilerHints());
		
		// initialize with 2 bytes length for the header (its actually 3, but one is skipped on the first field
		this.hints.addWidthRecordFormat(2);
	}
	else {
		this.hints = new RecordFormatCompilerHints(new CompilerHints());
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:21,代码来源:CsvInputFormat.java

示例2: computeOutputEstimates

import org.apache.flink.api.common.operators.CompilerHints; //导入依赖的package包/类
/**
 * Causes this node to compute its output estimates (such as number of rows, size in bytes)
 * based on the inputs and the compiler hints. The compiler hints are instantiated with conservative
 * default values which are used if no other values are provided. Nodes may access the statistics to
 * determine relevant information.
 * 
 * @param statistics
 *        The statistics object which may be accessed to get statistical information.
 *        The parameter may be null, if no statistics are available.
 */
public void computeOutputEstimates(DataStatistics statistics) {
	// sanity checking
	for (DagConnection c : getIncomingConnections()) {
		if (c.getSource() == null) {
			throw new CompilerException("Bug: Estimate computation called before inputs have been set.");
		}
	}
	
	// let every operator do its computation
	computeOperatorSpecificDefaultEstimates(statistics);
	
	if (this.estimatedOutputSize < 0) {
		this.estimatedOutputSize = -1;
	}
	if (this.estimatedNumRecords < 0) {
		this.estimatedNumRecords = -1;
	}
	
	// overwrite default estimates with hints, if given
	if (getOperator() == null || getOperator().getCompilerHints() == null) {
		return ;
	}
	
	CompilerHints hints = getOperator().getCompilerHints();
	if (hints.getOutputSize() >= 0) {
		this.estimatedOutputSize = hints.getOutputSize();
	}
	
	if (hints.getOutputCardinality() >= 0) {
		this.estimatedNumRecords = hints.getOutputCardinality();
	}
	
	if (hints.getFilterFactor() >= 0.0f) {
		if (this.estimatedNumRecords >= 0) {
			this.estimatedNumRecords = (long) (this.estimatedNumRecords * hints.getFilterFactor());
			
			if (this.estimatedOutputSize >= 0) {
				this.estimatedOutputSize = (long) (this.estimatedOutputSize * hints.getFilterFactor());
			}
		}
		else if (this instanceof SingleInputNode) {
			OptimizerNode pred = ((SingleInputNode) this).getPredecessorNode();
			if (pred != null && pred.getEstimatedNumRecords() >= 0) {
				this.estimatedNumRecords = (long) (pred.getEstimatedNumRecords() * hints.getFilterFactor());
			}
		}
	}
	
	// use the width to infer the cardinality (given size) and vice versa
	if (hints.getAvgOutputRecordSize() >= 1) {
		// the estimated number of rows based on size
		if (this.estimatedNumRecords == -1 && this.estimatedOutputSize >= 0) {
			this.estimatedNumRecords = (long) (this.estimatedOutputSize / hints.getAvgOutputRecordSize());
		}
		else if (this.estimatedOutputSize == -1 && this.estimatedNumRecords >= 0) {
			this.estimatedOutputSize = (long) (this.estimatedNumRecords * hints.getAvgOutputRecordSize());
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:70,代码来源:OptimizerNode.java

示例3: computeOutputEstimates

import org.apache.flink.api.common.operators.CompilerHints; //导入依赖的package包/类
/**
 * Causes this node to compute its output estimates (such as number of rows, size in bytes)
 * based on the inputs and the compiler hints. The compiler hints are instantiated with conservative
 * default values which are used if no other values are provided. Nodes may access the statistics to
 * determine relevant information.
 * 
 * @param statistics
 *        The statistics object which may be accessed to get statistical information.
 *        The parameter may be null, if no statistics are available.
 */
public void computeOutputEstimates(DataStatistics statistics) {
	// sanity checking
	for (PactConnection c : getIncomingConnections()) {
		if (c.getSource() == null) {
			throw new CompilerException("Bug: Estimate computation called before inputs have been set.");
		}
	}
	
	// let every operator do its computation
	computeOperatorSpecificDefaultEstimates(statistics);
	
	if (this.estimatedOutputSize < 0) {
		this.estimatedOutputSize = -1;
	}
	if (this.estimatedNumRecords < 0) {
		this.estimatedNumRecords = -1;
	}
	
	// overwrite default estimates with hints, if given
	if (getPactContract() == null || getPactContract().getCompilerHints() == null) {
		return ;
	}
	
	CompilerHints hints = getPactContract().getCompilerHints();
	if (hints.getOutputSize() >= 0) {
		this.estimatedOutputSize = hints.getOutputSize();
	}
	
	if (hints.getOutputCardinality() >= 0) {
		this.estimatedNumRecords = hints.getOutputCardinality();
	}
	
	if (hints.getFilterFactor() >= 0.0f) {
		if (this.estimatedNumRecords >= 0) {
			this.estimatedNumRecords = (long) (this.estimatedNumRecords * hints.getFilterFactor());
			
			if (this.estimatedOutputSize >= 0) {
				this.estimatedOutputSize = (long) (this.estimatedOutputSize * hints.getFilterFactor());
			}
		}
		else if (this instanceof SingleInputNode) {
			OptimizerNode pred = ((SingleInputNode) this).getPredecessorNode();
			if (pred != null && pred.getEstimatedNumRecords() >= 0) {
				this.estimatedNumRecords = (long) (pred.getEstimatedNumRecords() * hints.getFilterFactor());
			}
		}
	}
	
	// use the width to infer the cardinality (given size) and vice versa
	if (hints.getAvgOutputRecordSize() >= 1) {
		// the estimated number of rows based on size
		if (this.estimatedNumRecords == -1 && this.estimatedOutputSize >= 0) {
			this.estimatedNumRecords = (long) (this.estimatedOutputSize / hints.getAvgOutputRecordSize());
		}
		else if (this.estimatedOutputSize == -1 && this.estimatedNumRecords >= 0) {
			this.estimatedOutputSize = (long) (this.estimatedNumRecords * hints.getAvgOutputRecordSize());
		}
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:70,代码来源:OptimizerNode.java

示例4: RecordFormatCompilerHints

import org.apache.flink.api.common.operators.CompilerHints; //导入依赖的package包/类
private RecordFormatCompilerHints(CompilerHints parent) {
	copyFrom(parent);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:4,代码来源:CsvInputFormat.java


注:本文中的org.apache.flink.api.common.operators.CompilerHints类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。