• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >云计算 > 给大数据文件的每一行产生唯一的id,数据一行id

给大数据文件的每一行产生唯一的id,数据一行id

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含数据表的每一行称为,sql删除一行数据,两行数据合并成一行,多行数据合并成一行,sql插入一行数据等服务器相关知识,网友希望可以进行参考

给大数据文件的每一行产生唯一的id,数据一行id


给大数据文件的每一行产生唯一的id

4个主要思路:

1 单线程处理

2 普通多线程

3 hive

4 Hadoop

 

搜到一些参考资料


《Hadoop实战》的笔记-2、Hadoop输入与输出

https://book.douban.com/annotation/17068812/

TextInputFormat:文件偏移量:整行数据

但是这个偏移量,貌似是在一个文件的偏移,而不是全局。

 

Generate Auto-increment Id in Map-reduceJob

http://shzhangji.com/blog/2013/10/31/generate-auto-increment-id-in-map-reduce-job/

 

Generate unique customer id / insert uniquerows in hive

http://stackoverflow.com/questions/26855003/generate-unique-customer-id-insert-unique-rows-in-hive

 

Need to add auto increment column in atable using hive

http://stackoverflow.com/questions/23082763/need-to-add-auto-increment-column-in-a-table-using-hive

 

 

https://hadooptutorial.info/writing-custom-udf-in-hive-auto-increment-column-hive/

Here make sure that addition of annotation@UDFType(stateful = true) is required otherwisecounter value will not get increment in the Hive column, it will just returnvalue 1 for all the rows but not the actual row number.

 

最后我采取了用hive写udf的方案。


package hive.udf;
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.hive.ql.udf.UDFType;

/**
 * UDFRowSequence.
 */
@Description(name = "row_sequence",
    value = "_FUNC_() - Returns a generated row sequence number starting from 1")
@UDFType(deterministic = false, stateful = true)//stateful参数是必要的
public class UDFRowSequence extends UDF
{
  private int result;

  public UDFRowSequence() {
    result=0;
  }

  public int evaluate() {
	  result++;
    return result;
  }
}

// End UDFRowSequence.java

 

本文作者:linger

本文链接:http://blog.csdn.net/lingerlanlan/article/details/46430747



分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 给大数据文件的每一行产生唯一的id,数据一行id

相关文章

  • 高阶MapReduce_3_reducer侧联结原理,mapreduce原理
  • apache hadoop-2.6.0-CDH5.4.1 安装笔记,hadoop2.6.0安装
  • Hadoop之—— CentOS Warning: $HADOOP_HOME is deprecated解决方案,hadoopdeprecated
  • 深入理解kafka设计原理,深入理解kafka设计
  • Greenplum+Hadoop学习笔记-14-定义数据库对象之创建与管理序列、索引以及视图,hadoop-14-
  • Hadoop之——搭建ZooKeeper服务器集群,hadoopzookeeper
  • nova event机制分析,novaevent机制
  • Hadoop之—— Linux搭建hadoop环境(简化篇),linuxhadoop
  • 机器学习--k均值聚类(k-means)算法,--kk-means
  • K天熟悉Apache Storm (三),apachestorm

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • hadoop学习笔记(四)——eclipse+maven+hadoop2.5.2源码,hadoophadoop2.5.2
    • 通过iscsi协议使用ceph rbd,iscsi协议cephrbd
    • Cloud Foundry buildpack开发部署实例解析,foundrybuildpack
    • sqoop流程详解,sqoop详解
    • OpenStack Magnum 项目简介,openstackmagnum
    • NOSQL(二)聚合数据模型,nosql聚合数据模型
    • 几本京东上的CISCO云计算相关书籍,cisco相关书籍
    • 数据预处理-PDB文件,数据预处理-pdb
    • mahout简介及安装配置
    • pagerank算法的MapReduce实现,pagerankmapreduce

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有