本文整理匯總了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);
}