In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to use containers to store tabular data in big data. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Method 1. Map is used to store the data for the row. Then put multiple map into the list. (the container can hold anything)
Public class TestStoreData {public static void main (String [] args) {Map row1=new HashMap (); row1.put ("id", 1001); row1.put ("name", "Zhang San"); row1.put ("salary", 2009); row1.put ("entry date", "2009"); Map row2=new HashMap (); row2.put ("id", 1002); row2.put ("name", "Zhao Si"); row2.put ("salary", 50) Row2.put ("entry date", "2010"); List table=new ArrayList (); table.add (row1); table.add (row2); for (Map row:table) {Set keyset=row.keySet (); for (String key:keyset) {System.out.print (key+row.get (key) + ");} System.out.println () } output result name Zhang San salary 200 id1001 entry date 2009 name Zhao Si salary 50 id1002 entry date 2010
Method 2: use Javabean and list to store the entire table
Public class TestStoreDatatwo {public static void main (String [] args) {Stu stu1=new Stu (1, "li", 100.0); Stu stu2=new Stu (2, "li", 100.0); List list=new ArrayList (); list.add (stu1); list.add (stu2); for (Stu stu:list) {System.out.println (stu);}} class Stu {int id;String name;Double salary Public Stu () {} public Stu (int id, String name, Double salary) {this.id = id;this.name = name;this.salary = salary;} public int getId () {return id;} public void setId (int id) {this.id = id;} public String getName () {return name;} public void setName (String name) {this.name = name;} public Double getSalary () {return salary } public void setSalary (Double salary) {this.salary = salary;} @ Override public String toString () {return "id:" + id + ", name:" + name + ", salary:" + salary;}} above is how big data uses containers to store tabular data. If you happen to have similar doubts, please refer to the above analysis for understanding. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.