Storm中Tuple.getStringByField(“ABC")的用途是什么 [英] what is use of Tuple.getStringByField("ABC") in Storm

查看:19
本文介绍了Storm中Tuple.getStringByField(“ABC")的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解 Apache Storm 中 Tuple.getStringByField("ABC") 的用法.

I am not able to understand the use of the Tuple.getStringByField("ABC") in Apache Storm.

代码如下:

   Public Void execute(Tuple input){ 
       try{
          if (input.getSourceStreamId.equals("signals"))
            {
                str=input.getStringByField("action")

                if ("refresh".equals(str))
                  {....}
             }
             }...

这里 input.getStringByField("action") 正在做的正是..

Here what is input.getStringByField("action") is doing exactly..

谢谢.

推荐答案

在风暴中,spout 和 bolt 都发出元组.但问题是每个元组中包含什么.每个 spout 和 bolt 都可以使用下面的方法来定义元组模式.

In storm, both spout and bolt emit tuple. But the question is what are contained in each tuple. Each spout and bolt can use the below method to define the tuple schema.

  @Override
  public void declareOutputFields(
      OutputFieldsDeclarer outputFieldsDeclarer)
  {
    // tell storm the schema of the output tuple
    // tuple consists of columns called 'mycolumn1' and 'mycolumn2'
    outputFieldsDeclarer.declare(new Fields("mycolumn1", "mycolumn2"));
  }

随后的 bolt 可以使用 getStringByField("mycolumn1") 根据列名检索值.

The subsequent bolt then can use getStringByField("mycolumn1") to retrieve the value based on column name.

这篇关于Storm中Tuple.getStringByField(“ABC")的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆