本文整理汇总了Java中org.apache.flink.api.java.tuple.Tuple2.getField方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple2.getField方法的具体用法?Java Tuple2.getField怎么用?Java Tuple2.getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.java.tuple.Tuple2
的用法示例。
在下文中一共展示了Tuple2.getField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectData
import org.apache.flink.api.java.tuple.Tuple2; //导入方法依赖的package包/类
private Map<Integer, Collection<String>> collectData(MutableObjectIterator<Tuple2<Integer, String>> iter)
throws Exception
{
Map<Integer, Collection<String>> map = new HashMap<Integer, Collection<String>>();
Tuple2<Integer, String> pair = new Tuple2<Integer, String>();
while ((pair = iter.next(pair)) != null) {
final Integer key = pair.getField(0);
if (!map.containsKey(key)) {
map.put(key, new ArrayList<String>());
}
Collection<String> values = map.get(key);
final String value = pair.getField(1);
values.add(value);
}
return map;
}
示例2: collectData
import org.apache.flink.api.java.tuple.Tuple2; //导入方法依赖的package包/类
private Map<Integer, Collection<String>> collectData(MutableObjectIterator<Tuple2<Integer, String>> iter)
throws Exception {
final Map<Integer, Collection<String>> map = new HashMap<>();
Tuple2<Integer, String> pair = new Tuple2<>();
while ((pair = iter.next(pair)) != null) {
final Integer key = pair.getField(0);
if (!map.containsKey(key)) {
map.put(key, new ArrayList<String>());
}
Collection<String> values = map.get(key);
final String value = pair.getField(1);
values.add(value);
}
return map;
}
示例3: collectData
import org.apache.flink.api.java.tuple.Tuple2; //导入方法依赖的package包/类
private Map<Integer, Collection<String>> collectData(MutableObjectIterator<Tuple2<Integer, String>> iter)
throws Exception
{
Map<Integer, Collection<String>> map = new HashMap<Integer, Collection<String>>();
Tuple2<Integer, String> pair = new Tuple2<Integer, String>();
while ((pair = iter.next(pair)) != null) {
final Integer key = pair.getField(0);
if (!map.containsKey(key)) {
map.put(key, new ArrayList<String>());
}
Collection<String> values = map.get(key);
final String value = pair.getField(1);
values.add(value);
}
return map;
}
示例4: join
import org.apache.flink.api.java.tuple.Tuple2; //导入方法依赖的package包/类
@Override
public void join(Tuple2<Integer, String> rec1, Tuple2<Integer, String> rec2, Collector<Tuple2<Integer, String>> out) throws Exception {
final Integer key = rec1 != null ? (Integer) rec1.getField(0) : (Integer) rec2.getField(0);
final String value1 = rec1 != null ? (String) rec1.getField(1) : null;
final String value2 = rec2 != null ? (String) rec2.getField(1) : null;
Collection<Match> matches = this.toRemoveFrom.get(key);
if (matches == null) {
Assert.fail("Match " + key + " - " + value1 + ":" + value2 + " is unexpected.");
}
boolean contained = matches.remove(new Match(value1, value2));
if (!contained) {
Assert.fail("Produced match was not contained: " + key + " - " + value1 + ":" + value2);
}
if (matches.isEmpty()) {
this.toRemoveFrom.remove(key);
}
}
示例5: unwrap
import org.apache.flink.api.java.tuple.Tuple2; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <V> V unwrap(Tuple2<K, V> t) {
return t == null ? null : (V) (t.getField(1));
}
示例6: persist
import org.apache.flink.api.java.tuple.Tuple2; //导入方法依赖的package包/类
public void persist(Tuple2<String, Float> tuple){
final TransactionSnapshot ts = new TransactionSnapshot(tuple.getField(0), tuple.getField(1));
transactionSnapshotRepo.save(ts);
}