MapReduce的input为包含小文件的zip压缩文件的相关实验

MapReduce数据压缩 MapReduce数据压缩Hadoop三个阶段Hadoop数据压缩压缩的基本原则MR支持的压缩编码编码/解码器压缩性能使用方式map端输出压缩reduce端输出压缩 Hadoop三个阶段 1)分布式文件系统HDFS 用于存储宏大数据量文件。 2)分布式编程框架MapReduce 用于分布式计算海量数据。 3)yarn框架 分布式调度平台,用于为MapReducer合理分配资源。 Hadoop数据压... 阅读详情

Hadoop中也支持很多种压缩算法,比如gzip, zip, lzo等。将多个小文件压缩成一个压缩文件,不仅能节省空间,而且还能减少NameNode的内存压力。而且,有一些压缩文件(比如zip)对于MapReduce具有可分割性,能被分割成若干个split,适合作为 MapReduce 的输入。当然,如果一个压缩文件的size并不大,那么即便它包含了一定数量的小文件,MapReduce Job也只会为它启动一个Map——这也解决了小文件引起大量map的问题。


Zip是使用很广的一种压缩格式,因此本文在此对其作一个小实验。


实验:WordCount——input为一个zip文件(5个小文件)

推荐一篇文章:http://cotdp.com/2012/07/hadoop-processing-zip-files-in-mapreduce/。 它里面引用的代码在github上能够找到, 比如:https://github.com/cotdp/com-cotdp-hadoop/blob/master/src/test/java/com/cotdp/hadoop/ZipFileTest.java。 感兴趣的朋友可以自己试一下。

注意:我们需要在MapReduce Job里面指定一个zip 对应的InputFormat,比如“job.setInputFormatClass(ZipFileInputFormat.class)”。

当执行完MapReduce Job后,可以看到只启动了一个Map:



MapReduce如何操作gz压缩包 MapReduce如何操作gz压缩包HDFS读取gz压缩包MapReduce如何做输入代码实例 HDFS读取gz压缩包 对于一些结构性和规律性特别好的数据而言,在集群里基本都是以gz来存储数据,压缩比例能达到1:100左右,还是挺可观的一种方法。但是问题就是,存是简单了,但是读取是有点费劲的。好在hadoop已经给我们做好了解压缩的方法。做成了gz数据流的方法,调用readline(),来进行读取操作。 package edu.bupt.trace; import org.apache.hadoop.co 阅读详情

相关推荐

mapreduceDemo.zip

主要包括mapreduce自定义分区,排序,分组的过程,最后以实际在生产中的小demo作为演示,可以让初学者对于mapreduce程序有更深层次的了解。

ZIP压缩输入/输出流

ZIP压缩管理文件(ZIP archive)是一种十分典型的文件压缩形式。关于ZIP压缩的I/O实现,在Java的内置类中提供了非常好用的相关类,所以其实现方式非常简单。本文将介绍 java.util.zip包中的ZipOutputStream与ZipInputStream类来实现文件的压缩/解压缩。

weixin_44860226的博客 7077

攻克TypeError: Cannot read properties of undefined (reading ‘NormalModule‘)的四种实战策略

本文详细解析了`TypeError: Cannot read properties of undefined (reading 'NormalModule')`错误的四种实战解决策略。从版本一致性检查、包管理器优化到依赖替换和构建环境配置,帮助开发者快速定位和解决Webpack构建过程中的常见问题,提升开发效率。

weixin_42523670的博客 243

文件包含漏洞(input、filter、zip)

可以访问请求的原始数据的只读流,将请求的数据当作php代码执行。当传入的参数作为文件名打开时,可以将参数设为php://input,同时post想设置的文件内容,php执行时会将post内容当作文件内容。从而导致任意代码执行。先访问这个页面然后抓包进行上传并访问恶意代码,可以看到phpinfo()已经执行。

m0_70349048的博客 2400

量子计算入门指南:密度算符的核心概念与应用解析

本文深入解析了量子计算中密度算符的核心概念与应用。作为描述量子系统“状态的状态”的关键数学工具,密度算符能有效处理混合态与子系统描述,是理解量子噪声、量子纠错和开放系统演化的基石。文章通过对比纯态与混合态,阐释了密度矩阵的数学定义与物理意义,并结合代码示例演示了其在实际量子计算问题中的强大威力。

day7的博客 469

Bellhop水声信道模型的仿真

Bellhop是一种基于射线追踪的水声信道模型,广泛用于预测水下环境中的声压场。它通过模拟声波在水中的传播路径,计算声场分布,适用于复杂的水下通信场景。

yt94832的博客 1315

input 限制 上传文件类型

在文件上传中使用 accept 属性,本例中的输入字段可以接受 GIF 和 JPEG 两种图像:<form> <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" /> </form>如果不限制图像的格式,可以写为:accept="image/*&

小远哥的博客 8716

银河麒麟V10离线升级OpenSSH实战:从编译到回滚全流程

OpenSSH作为Linux系统远程登录的核心组件,其版本升级直接关系到系统安全与等保合规。在信创环境下,银河麒麟V10自带的OpenSSH版本往往无法满足漏洞扫描与安全加固要求,而离线编译升级涉及依赖处理、编译参数、服务替换与回滚方案等多个技术环节。本文围绕银河麒麟V10(x86_64)平台,详细讲解OpenSSH离线升级的完整实操流程,包括环境摸底、依赖包安装、源码编译、配置文件兼容性处理、服务重启验证以及常见问题排查,并分享批量升级与安全加固的工程经验,帮助运维人员在不断网、不重装的前提下一次成功完成

weixin_30582943的博客 385

chrome浏览器input[type=file]选择zip、exe等文件卡顿解决办法

在chrome浏览器下,使用input[type=file]上传,点击打开对话框,选择.zip、exe、apk等文件后,再次点击打开对话框,则出现卡顿现象,大概会在5~10秒,经过排查搜索,发现是chrome浏览器自带的问题,但是观察一些上传组件确发现没有卡顿问题,因此拿出jquery-file-upload上传插件对源码进行分析,情况如下:   经过分析,发现jquery

u010576965的专栏 7222

STM32--LoRa通信模块

模块根据MD0的配置与AUX引脚的状态会进入不同的功能其中在通信功能下,包含4种工作模式。

qq_47258284的博客 1万+

FT601Q芯片深度解析:从USB3.0引脚定义到FPGA FIFO协议实战选型

本文深入解析FT601Q芯片在USB3.0接口设计与FPGA协议栈开发中的应用,详细介绍了USB3.0引脚定义、FT601Q芯片架构、245同步FIFO模式及硬件设计要点,帮助工程师实现高速数据传输系统。

weixin_30607659的博客 447

MapReduce中文件的压缩和解压

1.单个文件的压缩或解压 import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.hadoop.conf.Confi

3450

SAP FICO资产明细表开发说明书(包括测试样例、程序代码仅作参考,不保证一定可以运行)

SAP FICO资产明细表开发说明书(包括源代码,测试样例及FS)

我好像病了的博客 1469

mapreduce读取压缩文件

mapreduce读取压缩文件 转载于:https://www.cnblogs.com/0xcafedaddy/p/9147058.html

weixin_30344131的博客 621

基于 PID 算法的 STM32 步进电机高精度位置控制系统设计与实现(工业自动化应用)

硬件层面:选用 STM32F103C8T6+A4988 + 欧姆龙编码器的组合,兼顾工业可靠性与成本,接线需注意强弱电分离和信号抗干扰;软件层面:核心为位置式 PID 闭环控制,Mermaid 流程图清晰展现 “采集 - 运算 - 驱动” 的闭环逻辑,代码模块化易移植;性能层面:无负载定位误差≤±1 脉冲,带载误差≤±3 脉冲,满足工业自动化高精度位置控制需求。

weixin_42300449的博客 194

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Hadoop MapReduce处理海量小文件:压缩文件

在HDFS上存储文件,大量的小文件是非常消耗NameNode内存的,因为每个文件都会分配一个文件描述符,NameNode需要在启动的时候加载全部文件的描述信息,所以文件越多,对 NameNode来说开销越大。 我们可以考虑,将小文件压缩以后,再上传到HDFS中,这时只需要一个文件描述符信息,自然大大减轻了NameNode对内存使用的开销。MapReduce计算中,Hadoop内置提供了如下

haizhaopeng的专栏 3561

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HTML、 input;、accept 属性-规定能够通过文件上传进行提交的文件类型

定义和用法 文章地址:http://www.w3school.com.cn/tags/att_input_accept.asp accept 属性规定了可通过文件上传提交的服务器接受的文件类型。 注意:accept 属性仅适用于 <input type="file">。 提示:请不要将该属性作为您的验证工具。应该在服务器上对文件上传进行验证。 实例 规定在文件上传中...

李斌的BLOG 3万+

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

<input type="file" >判断上传的文件是zip和rar类型

                                        请选择上传的文件:                                     注:文件大小请控制在10M以内。                                        

huahuahailang的专栏 1万+

Hadoop MapReduce处理小的压缩文件:基于CombineFileInputFormat

处理压缩小文件的,不是压缩文件,代码也是可以用的,只是这时候每个split是一个小文件 其他就不在多说了,只是提供3个java文件,也只是些参考 CompressedCombineFileInputFormat .java package compressedCombineFile; import java.io.IOException; import org.apache.ha

caoyaqi的博客 677

6. FileInputFormat实现类

抽象类FileInputFormat`常见的`实现类`包括:TextInputFormat、KeyValueTextInputFormat、NLineInputFormat、CombineTextInputFormat和自定义InputFormat`等。

weixin_45267102的博客 774

Hadoop在MapReduce中使用压缩详解

 hadoop对于压缩文件的支持 hadoop对于压缩格式的是透明识别,我们的MapReduce任务的执行是透明的,hadoop能够自动为我们 将压缩的文件解压,而不用我们去关心。  如果我们压缩的文件有相应压缩格式的扩展名(比如lzo,gz,bzip2等),hadoop就会根据扩展名去选择解码器解压。 hadoop对每个压缩格式的支持,详细见下表:  压缩格式  工具  ...

weixin_33806300的博客 411

hadoop深入研究:(九)——mapreduce中的压缩

转载请注明出处:http://blog.youkuaiyun.com/lastsweetop/article/details/9187721 作为输入 当压缩文件做为mapreduce的输入时,mapreduce将自动通过扩展名找到相应的codec对其解压。 作为输出 当mapreduce的输出文件需要压缩时,可以更改mapred.output.compress为true,mapped.out

wisgood的专栏 7478

Hadoop入门——MapReduce中的压缩

作为输入 当压缩文件做为mapreduce的输入时,mapreduce将自动通过扩展名找到相应的codec对其解压。 作为输出 当mapreduce的输出文件需要压缩时,可以更改mapred.output.compress为true,mapped.output.compression.codec为想要使用的codec的类名就 可以了,当然你可以在代码中指定,通过调用FileOutputFo...

东天里的冬天 1488
上一篇: MapReduce的inputformat为CombineFileInputFormat的相关实验
下一篇: 关于 hadoop-2.2 配置中的 yarn.nodemanager.aux-services 项
坡上的云
博客等级 码龄20年 50粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值