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 > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you what data types are in Hadoop, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
one。 Hadoop built-in data types
BooleanWritable: standard Boolean value
ByteWritable: single byte value
DoubleWritable: double byte numeric
FloatWritable: floating point number
IntWritable: integer number
LongWritable: number of long integers
Text: text stored in UTF8 format
NullWritable: used when key or value is empty
All the data types in Hadoop implement the Writable interface so that the data defined with these types can be transferred over the network and stored in files.
two。 Implementation of user-defined data types
1. Inherit the interface Writable and implement its methods write () and readFields () so that the data can be serialized to complete network transfer or file input / output
two。 If this data needs to be used as a primary key key, or when you need to compare numeric values, you need to implement the WritalbeComparable interface and implement its methods write (), readFields (), CompareTo ().
3. Data type, there must be a no-parameter constructor, to facilitate reflection, to create objects.
4. In custom data types, it is recommended to use java's native data types, and it is best not to use Hadoop data types that encapsulate native types. Eg.int x; / / IntWritable String s; / / Text
Public class Point3D implements WritableComparable
{
Private float x,y,z
Public float getX () {return x;}
Public float getY () {return y;}
Public float getZ () {return z;}
Public Point3D () {}
Public void readFields (DataInput in) throws IOException
{
X = in.readFloat ()
Y = in.readFloat ()
Z = in.readFloat ()
}
Public void write (DataOutput out) throws IOException
{
Out.writeFloat (x)
Out.writeFloat (y)
Out.writeFloat (z)
}
Public int CompareTo (Point3D p)
{
/ / the specific implementation compares the size of the current coordinate point this (x _ journal y ~ z) with the specified point p (x _ journal y _ z).
/ and output:-1 (less than), 0 (equal to), 1 (greater than)
}
}
What are the data types in Hadoop? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, 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.