本文整理汇总了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());
}
}
示例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());
}
}
}
示例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());
}
}
}
示例4: RecordFormatCompilerHints
import org.apache.flink.api.common.operators.CompilerHints; //导入依赖的package包/类
private RecordFormatCompilerHints(CompilerHints parent) {
copyFrom(parent);
}