Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.6k views
in Technique[技术] by (71.8m points)

1万个时间字符串排序并根据连续的key计数 求解

近期在工作中遇到一个时间排序并计数的问题,
hbase rowkey排序,rowkey:YYYYMMDDHHMMSS+类别2位+类型2位
先按时间倒序排序,再根据统一类别计数
例如:
时间:20200501185520 类别:02 类型:01,则rowkey: 202005011855200201

N个rowkey
20190501 18:55:20 02 01
20200311 17:55:20 01 01
20200521 23:55:20 04 01
20100101 18:52:20 05 01
20200501 18:53:20 07 01
20200503 07:55:20 01 01
20200501 18:51:20 02 01
20200501 11:55:20 01 01
20200504 18:55:20 02 01
20200501 10:55:20 01 01
20200501 18:55:23 02 01
20200501 18:55:20 02 01
20200501 18:55:22 03 01
20200501 08:55:20 04 01
20210301 21:55:20 02 01
20200501 11:55:20 02 01

排序并根据连续的“类别”计数后结果为
20210301 21:55:20 02 01 count:1
20200521 23:55:20 04 01 count:1
20200504 18:55:20 02 01 count:1
20200503 07:55:20 01 01 count:1
20200501 18:55:23 02 01 count:1
20200501 18:55:20 02 01 count:2
20200501 18:53:20 07 01 count:1
.
.
.
.

求解:1万条这样的数据的排序算法,或者说应该用什么排序比较好


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...