本文整理汇总了Java中org.apache.flink.api.java.functions.SelectByMinFunction类的典型用法代码示例。如果您正苦于以下问题:Java SelectByMinFunction类的具体用法?Java SelectByMinFunction怎么用?Java SelectByMinFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SelectByMinFunction类属于org.apache.flink.api.java.functions包,在下文中一共展示了SelectByMinFunction类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: minBy
import org.apache.flink.api.java.functions.SelectByMinFunction; //导入依赖的package包/类
/**
* Applies a special case of a reduce transformation (minBy) on a grouped {@link DataSet}.
*
* <p>The transformation consecutively calls a {@link ReduceFunction}
* until only a single element remains which is the result of the transformation.
* A ReduceFunction combines two elements into one new element of the same type.
*
* @param fields Keys taken into account for finding the minimum.
* @return A {@link ReduceOperator} representing the minimum.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public ReduceOperator<T> minBy(int... fields) {
// Check for using a tuple
if (!this.inputDataSet.getType().isTupleType()) {
throw new InvalidProgramException("Method minBy(int) only works on tuples.");
}
return new ReduceOperator<T>(this, new SelectByMinFunction(
(TupleTypeInfo) this.inputDataSet.getType(), fields), Utils.getCallLocationName());
}
示例2: minBy
import org.apache.flink.api.java.functions.SelectByMinFunction; //导入依赖的package包/类
/**
* Applies a special case of a reduce transformation (minBy) on a grouped {@link DataSet}.<br/>
* The transformation consecutively calls a {@link ReduceFunction}
* until only a single element remains which is the result of the transformation.
* A ReduceFunction combines two elements into one new element of the same type.
*
* @param fields Keys taken into account for finding the minimum.
* @return A {@link ReduceOperator} representing the minimum.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public ReduceOperator<T> minBy(int... fields) {
// Check for using a tuple
if(!this.dataSet.getType().isTupleType()) {
throw new InvalidProgramException("Method minBy(int) only works on tuples.");
}
return new ReduceOperator<T>(this, new SelectByMinFunction(
(TupleTypeInfo) this.dataSet.getType(), fields));
}
示例3: minBy
import org.apache.flink.api.java.functions.SelectByMinFunction; //导入依赖的package包/类
/**
* Applies a special case of a reduce transformation (minBy) on a non-grouped {@link DataSet}.<br/>
* The transformation consecutively calls a {@link ReduceFunction}
* until only a single element remains which is the result of the transformation.
* A ReduceFunction combines two elements into one new element of the same type.
*
* @param fields Keys taken into account for finding the minimum.
* @return A {@link ReduceOperator} representing the minimum.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public ReduceOperator<T> minBy(int... fields) {
// Check for using a tuple
if(!this.type.isTupleType()) {
throw new InvalidProgramException("Method minBy(int) only works on tuples.");
}
return new ReduceOperator<T>(this, new SelectByMinFunction(
(TupleTypeInfo) this.type, fields));
}
示例4: minBy
import org.apache.flink.api.java.functions.SelectByMinFunction; //导入依赖的package包/类
/**
* Selects an element with minimum value.
*
* <p>The minimum is computed over the specified fields in lexicographical order.
*
* <p><strong>Example 1</strong>: Given a data set with elements <code>[0, 1], [1, 0]</code>, the
* results will be:
* <ul>
* <li><code>minBy(0)</code>: <code>[0, 1]</code></li>
* <li><code>minBy(1)</code>: <code>[1, 0]</code></li>
* </ul>
*
* <p><strong>Example 2</strong>: Given a data set with elements <code>[0, 0], [0, 1]</code>, the
* results will be:
* <ul>
* <li><code>minBy(0, 1)</code>: <code>[0, 0]</code></li>
* </ul>
*
* <p>If multiple values with minimum value at the specified fields exist, a random one will be
* picked.
*
* <p>Internally, this operation is implemented as a {@link ReduceFunction}.
*
* @param fields Field positions to compute the minimum over
* @return A {@link ReduceOperator} representing the minimum
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public ReduceOperator<T> minBy(int... fields) {
if (!getType().isTupleType()) {
throw new InvalidProgramException("DataSet#minBy(int...) only works on Tuple types.");
}
return new ReduceOperator<>(this, new SelectByMinFunction(
(TupleTypeInfo) getType(), fields), Utils.getCallLocationName());
}