What is the data model of the database?
This article mainly explains "what is the data model of the database". The content of the explanation is simple and clear, and it is easy to learn and understand. let's follow the editor's train of thought to study and learn "what is the data model of the database"!
Data model (Data Model)
Storm uses tuple as its data model. Each tuple is a pile of values, each value has a name, and each value can be of any type. In my understanding, a tuple can be seen as a java object with no methods. Overall, storm supports all basic types, strings, and byte arrays as value class types for tuple. You can also use your own defined types as value types, as long as you implement the corresponding serializer (serializer).
Each node in the topology must define each field of the tuple it wants to emit. For example, the following bolt defines that the tuple emitted by its lock contains two fields of type doble and triple.
Publicclass DoubleAndTripleBolt implements IRichBolt {private OutputCollectorBase _ collector; @ Override
Publicvoid prepare (Map conf, TopologyContext context, OutputCollectorBase collector) {
_ collector = collector;}
@ Override
Publicvoid execute (Tuple input) {int val = input.getInteger (0)
_ collector.emit (input, new Values (val*2, val*3)); _ collector.ack (input);}
@ Override
Publicvoid cleanup () {}
@ Override
Publicvoid declareOutputFields (OutputFieldsDeclarer declarer) {
Declarer.declare (new Fields ("double", "triple");}}
The declareOutputFields method defines the fields to output: ["double", "triple"]. We'll explain the rest of this bolt later.
Thank you for your reading. the above is the content of "what is the data model of the database". After the study of this article, I believe you have a deeper understanding of what the data model of the database is. The specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!