Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...