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

查看:195
本文介绍了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")到底在做什么.

谢谢.

推荐答案

在暴风雨中,喷口和螺栓都发射出元组.但是问题是每个元组中包含什么.每个喷嘴和螺栓都可以使用以下方法来定义元组模式.

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"));
  }

随后的螺栓可以使用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天全站免登陆