Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use containers to store tabular data in big data

Shulou Source: shulou.com Published: 2022-06-01 04:56:07 09月29日 Update

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.

Tags: Data storage name date salary container table content method Zhang San analysis professional thing small and medium rich in content multiple that is articles more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Microsoft Huawei Apple Shulou Information