當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。