flink 学习(一)——一些基础概念API

元组Tuple

学习链接

  • Tuple 是flink 一个很特殊的类型 (元组类型),是一个抽象类,共26个Tuple子类继承Tuple 他们是 Tuple0一直到Tuple25
  • Tuple后的数字,代表每一个元组中可用空间(理解为插槽也行,每个字段对应一个插槽)
public class Tuple2<T0, T1> extends Tuple {

	private static final long serialVersionUID = 1L;

	/** Field 0 of the tuple. */
	public T0 f0;
	/** Field 1 of the tuple. */
	public T1 f1;

	/**
	 * Creates a new tuple where all fields are null.
	 */
	public Tuple2() {}

	/**
	 * Creates a new tuple and assigns the given values to the tuple's fields.
	 *
	 * @param value0 The value for field 0
	 * @param value1 The value for field 1
	 */
	public Tuple2(T0 value0, T1 value1) {
		this.f0 = value0;
		this.f1 = value1;
	}
	'''还有别的方法'''
}

Collector

public interface Collector<T> {

	/**
	 * Emits a record.
	 *
	 * @param record The record to collect.
	 */
	void collect(T record);

	/**
	 * Closes the collector. If any data was buffered, that data will be flushed.
	 */
	void close();
}
  • Collects a record and forwards it. The collector is the “push” counterpart of the java.util.Iterator, which “pulls” data in.
  • 迭代器是一个list,把数据都放进去。而这个Collector是要把想要输出的结果都收集起来,然后再Push出去。
  • 可以通过collect()方法来把数据输出

Parameter Tool

flink提供了ParameTool来读取参数

DataString

keyBy

  • 按key重分区, 有点类似于groupBy,重新分组的意思
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值