`
tenght
  • 浏览: 50386 次
社区版块
存档分类
最新评论

Reducer for the maximum temperature example

 
阅读更多

import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class MaxTemperatureReducer
  extends Reducer<Text, IntWritable, Text, IntWritable> {
  
  @Override
  public void reduce(Text key, Iterable<IntWritable> values,
      Context context)
      throws IOException, InterruptedException {
    
    int maxValue = Integer.MIN_VALUE;
    for (IntWritable value : values) {
      maxValue = Math.max(maxValue, value.get());
    }
    context.write(key, new IntWritable(maxValue));
  }
}
Four formal type parameters are used to specify the input and output types, this
time for the reduce function. The input types of the reduce function must match the
output types of the map function: Text and IntWritable. And in this case, the output
types of the reduce function are Text and IntWritable, for a year and its maximum
temperature, which we find by iterating through the temperatures and comparing each
with a record of the highest found so far.

针对reduce函数也有四个形式参数类型用于指定其输入和输出类型。reduce函数的输入类型必须与

map函数的输出类型相匹配:即Text类型和IntWritable类型。在这种情况下,reduce函数的输出类型

是Text类型和IntWritable类型,对应于年份和最高气温。该最高气温是通过循环比较当前气温与已得

到的最高气温获得的。

分享到:
评论

相关推荐

    二级减速器课程设计说明书reducer design specification.doc

    Main contents of this manual is for the design of belt conveyor drive system, the V belt transmission and twoestage cylindrical gear reducer, used in the design and calculation to the "machine design ...

    Design of a Planetary-Cyclo-Drive Speed Reducer

    The company has given the necessary input data for the model. They have also provided a real cyclodrive reducer for further analyses. To obtain the dimensions and forming the geometry of the gears, ...

    Elasticsearch for Hadoop

    Understanding the reducer Understanding the driver Using the old API – org.apache.hadoop.mapred Going real — network monitoring data Getting and understanding the data Knowing the problems ...

    实现动态加载reducer简化reducer的代码分块

    本文将深入探讨如何实现动态加载Reducer,以简化Reducer的代码分块,提高应用的加载速度和运行效率。 Reducer是Redux状态管理库中的核心组件,它负责处理应用程序的状态更新。在传统的Redux架构中,所有的Reducer...

    2.wordcount-Reducer类编写.mp4

    wordcount编写及测试演示 环境是win10+eclipse centos7+hadoop2.7.3 2.wordcount-Reducer类编写.mp4

    Mapper类和Reducer类代码编写所需的全部基本jar包

    5. **ecj-4.3.1.jar** - Eclipse Compiler for Java,用于编译Java源代码。在某些情况下,Hadoop可能使用这个编译器来编译MapReduce任务的源代码。 6. **netty-all-4.0.23.Final.jar** - Netty是一个高性能、异步...

    让一个reducer产生多个输出文件.docx

    for (Text value : values) { // 假设value中包含了需要分类的信息 String[] parts = value.toString().split(","); String category = parts[0]; String data = parts[1]; // 根据category写入不同的文件 ...

    simplest-redux-example-master

    "simplest-redux-example-master" 是一个针对Redux的简单示例项目,旨在帮助开发者理解Redux的基本概念和工作流程。这个项目通常会包含一系列文件,展示如何创建Redux store、定义reducer、编写action以及与React...

    PDF减肥大师(ORPALIS PDF Reducer) v1.1.12 官方版.zip

    PDF减肥大师(ORPALIS PDF Reducer)这套可以有效降低 PDF 文件档案大小并保持文件内容清晰度的免费软件用处多多哦!可以保持PDF阅读体验不变的情况下提高清晰度,减小体积,实在是好助手! 使用方法简述1.在 Source ...

    CADICAE system for the ring planetary reducer with small tooth number diference* (2002年)

    A CAD/CAE system of the ring-type planetary reducer with small tooth number difference is presented. It is a parameterized CAD/CAE system adopting the object-oriented technique and comprising in ...

    STRESS REDUCER DESKTOP DESTROYER

    Desktop Games (also known as Stress Reducer or Stress Relief) - play with your Windows desktop. You can chop it, cut it, shoot to pieces, repaint, stamp it. Or put termites on it and after that hunt ...

    cpp-Linux内核源码树Reducer

    Linux内核源码树Reducer是针对Linux内核源代码进行分析和优化的工具,它主要用于减少内核源码树的大小,以便于开发者更高效地理解和研究特定的内核功能。这个项目通常对那些需要频繁浏览和分析内核源码的开发者或者...

    GEE问题:使用reduceRegion求单点均值过程中出现值不一样的情况如何解决?.pdf

    Either the reducer must have the same number of inputs as the input image has bands, or it must have a single input and will be repeated for each band. Returns a dictionary of the reducer's outputs.

    圆柱电池滚槽机机构设计.doc

    The fourth chapter focuses on the selection and calculation of key components, such as the motor, reducer, coupling, and bearings, necessary for the efficient operation of the slotting machine....

    react-Reason风格的Reducer组件使用ES6Classes

    在React开发中,Reducer是Redux库中的核心概念,它负责管理应用的状态。当我们结合ReasonML的编程风格与ES6 Classes,可以创建出高效且可维护的Reducer组件。本篇文章将深入探讨如何在React项目中使用ES6 Classes...

    react-reducer-example

    Create React App入门 该项目是通过引导的。 可用脚本 在项目目录中,可以运行: yarn start 在开发模式下运行应用程序。 打开在浏览器中查看它。 如果您进行编辑,则页面将重新加载。 您还将在控制台中看到任何...

    Mapper_mapper_

    #!/usr/bin/env python&quot;&quot;&quot;mapper.py&quot;&quot;&quot;import sys# input comes from STDIN ... the input for reducer.py # # tab-delimited; the trivial word count is 1 print '%s\t%s' % (word 1)

    saga-reducer-factory:一个实用工具,用于创建一对传奇和匹配的reducer,以最小化样板

    因此,我认为将sagas和reducer视为一个整体会更好。 该模块可帮助我们以减少样板的方式实现这一目标。 安装 $ npm i -S saga-reducer-factory 用法 佐贺模块 import SagaReducerFactory from 'saga-reducer-factory...

    cuit大数据实验3 111111111111111

    The experiment is based on a scenario where a social media website has 800,000 user login records, and the website operator wants to analyze user behavior by extracting the number of login times for ...

    Laravel开发-json-reducer

    在Laravel框架中,开发一个`json-reducer`是为了优化JSON输出,特别是在处理大量数据时,减少内存占用和提高性能。这个工具可能涉及到对模型、集合以及数组的操作,旨在通过智能地缩减数组的大小,来生成更轻量级的...

Global site tag (gtag.js) - Google Analytics