更新hbase

This commit is contained in:
xiongraorao
2018-08-03 12:01:41 +08:00
parent a7c6568e6e
commit 5c1773e018
4 changed files with 69 additions and 3 deletions

View File

@ -37,6 +37,8 @@ dependencies {
// https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-mapreduce-client-core
compile group: 'org.apache.hadoop', name: 'hadoop-mapreduce-client-core', version: '2.7.4'
// https://mvnrepository.com/artifact/org.apache.hbase/hbase-client
compile group: 'org.apache.hbase', name: 'hbase-client', version: '1.2.6'
}

View File

@ -0,0 +1,35 @@
package com.raorao.java.thread;
import java.util.Iterator;
import java.util.PriorityQueue;
/**
* 得到TopN的方法使用优先队列.
*
* @author Xiong Raorao
* @since 2018-08-03-10:18
*/
public class TopN {
public static void main(String[] args) {
PriorityQueue<Integer> p = new PriorityQueue<>(5);
int[] aa = new int[] {1, 2, 3, 4, 77, 22, 42, 35, 8, 12};
for (int i : aa) {
if (p.size() < 5) {
p.offer(i);
} else {
if (i < p.peek()) {
// do nothing
} else {
p.offer(i);
p.poll();
}
}
}
Iterator<Integer> iterator = p.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
}
}