官术网_书友最值得收藏!

  • Mastering Apache Storm
  • Ankit Jain
  • 214字
  • 2021-07-02 20:32:27

The Storm data model

The basic unit of data that can be processed by a Storm application is called a tuple. Each tuple consists of a predefined list of fields. The value of each field can be a byte, char, integer, long, float, double, Boolean, or byte array. Storm also provides an API to define your own datatypes, which can be serialized as fields in a tuple.

A tuple is dynamically typed, that is, you just need to define the names of the fields in a tuple and not their datatype. The choice of dynamic typing helps to simplify the API and makes it easy to use. Also, since a processing unit in Storm can process multiple types of tuples, it's not practical to declare field types.

Each of the fields in a tuple can be accessed by its name, getValueByField(String), or its positional index, getValue(int), in the tuple. Tuples also provide convenient methods such as getIntegerByField(String) that save you from typecasting the objects. For example, if you have a Fraction (numerator, denominator) tuple, representing fractional numbers, then you can get the value of the numerator by either using getIntegerByField("numerator") or getInteger(0).

You can see the full set of operations supported by org.apache.storm.tuple.Tuple in the Java doc that is located at https://storm.apache.org/releases/1.0.2/javadocs/org/apache/storm/tuple/Tuple.html.

主站蜘蛛池模板: 府谷县| 方正县| 盈江县| 平谷区| 盖州市| 彰化市| 海口市| 出国| 嘉黎县| 建昌县| 晋城| 炎陵县| 南京市| 肥西县| 闵行区| 交城县| 荔波县| 保康县| 奇台县| 彰武县| 永丰县| 铜川市| 北票市| 黎川县| 葵青区| 石楼县| 平和县| 林芝县| 怀宁县| 安阳市| 花莲县| 金平| 社会| 辽源市| 宁远县| 濮阳县| 瑞昌市| 城固县| 和林格尔县| 万源市| 临湘市|