1.先定义好可以自定义排序的bean对象class,属性就只需要用来排名的id, 以及用来赋值原始数据的num 2.写好get、set、序列化、反序列化方法、tostring(用来打印数据)、 以及排序方法(自定义排序规则) 3.排序规则:根据bean对象中的原始数据来排序 当this.num>o.getNum() 返回1, 等于时返回0,小于时返回-1, 来正序排序 4.写好mapper类,定义好输入输出参数,入参固定是 每行数据的偏移量以及类型 5.已知每行数据都是一个数字 这里就不用去进行切割,直接进行赋值即可,然后将获取到的值set到bean对象中,在将bean对象作为key (需要进行排序的)然后value不需要东西则直接使用NullWritable,输出即可通过自定义的排序bean对象进行排序 6.到了reduce阶段,定义好全局变量id 作为排名,然后遍历具有相同key的values,因为在前面是排好序的数据的,这里就直接在遍历的时候 将id赋值给bean对象作为排名的id,并且遍历一次,id++一次。这样就能 给正序返回的数据进行排名赋值了 7.这里就写好启动类即可(按照固定参数写好即可,不做过多描述)然后设置reducetaskwei1或者不设置(默认为1) 8.将三个文件放在同一个文件夹下(我这里为了方便是将输入输出文件地址在代码中写死了的),直接读取整个文件夹,在设置好输出地址即可(输出地址不可存在)
lgstudy-worker's Introduction
lgstudy-worker's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.