.toString(SEPARATOR)); if(parts.length == 6) { if(parts[0].equals(ATTEMPT)) { if(!parts[3].equals("m") && !parts[3].equals("r")) { throw new Exception(); } long result = Long.parseLong(parts[4]); if(result >= numTasks) { //if taskid >= numtasks throw new Exception("TaskAttemptId string : " + taskAttemptIDstr + " parse ID [" + result + "] >= numTasks[" + numTasks + "] .."); } return result + 1; } } } catch (Exception e) {} throw new IllegalArgumentException("TaskAttemptId string : " + taskAttemptIDstr + " is not properly formed"); } } 有一张去重后的用户id(字符串类型)表,须要位每个用户id生成一个独一的数值型seq:
- ADD jar file:///tmp/udf.jar;
- CREATE temporary function seq2 as 'com.lxw1234.hive.udf.RowSeq2';
-
- hive>> desc lxw_all_ids;
- OK
- id string
推荐阅读
软件开发人员的编程障碍,你知道多少?
没有人知足Java开辟人员这种已经“竭尽全力”改变世界的速度,每小我都欲望代码像消防水管里的水一样可以或许源源赓续地流出来,但没有人愿意供给给开辟人员更好地完成工作的前>>>详细阅读
本文标题:Hive、MapReduce、Spark分布式生成唯一数值型ID
地址:http://www.17bianji.com/lsqh/34744.html
1/2 1