MapReduce 編程練手

來源:互聯網
上載者:User

1:資料集。http://earthquake.usgs.gov/earthquakes/eqarchives/epic/epic_global.php

PDE    1973  01 12 115656     37.93  -90.52  20  3.2 LgSLM   4F. .......       PDE    1973  01 30 071636.60 -17.56  167.85   3              3F. .......       PDE    1973  02 04 091042.20  -3.76  151.96  19              3F. .......       PDE    1973  02 15 230608.90  36.81 -115.90   4              3F. .......       PDE    1973  02 15 231457.10  36.81 -115.91   4              3F. .......       PDE    1973  02 20 113848.80  45.01   36.41  17  4.2 mbGS    4F. .......       PDE    1973  02 21 144557.30  34.06 -119.04   8  5.9 MLPAS   7C. .......       PDE    1973  02 25 100944.80  34.73  132.34  19  4.2 mbGS    3F. .......       PDE    1973  02 28 082132.30  39.72  -75.44  14  3.8 LgSLM   6F. .......       PDE    1973  03 09 190912.80 -34.13  150.27  13  5.5 mbGS    6D. .......       PDE    1973  03 10 095000.30 -15.18 -173.52   8  5.6 mbGS    2F. .......       PDE    1973  03 22 211309.60  -5.47  151.27  18  4.9 mbGS    2F. .......       PDE    1973  03 24 003436.80  31.72  139.30  20  5.9 UKBRK   2F. .......       PDE    1973  03 29 175152.40  36.10  141.55  15  3.9 mbGS    2F. .......       PDE    1973  04 05 043208.10  11.94  122.50   6  5.4 mbGS    4F. .......       PDE    1973  04 07 193006.90  41.49   19.98  16  4.7 mbGS    6F. .......       PDE    1973  04 11 051218.10  64.61 -160.05  15  4.2 mbGS    5F. .......       PDE    1973  04 11 120610     38.81  140.80  15  4.4 mbGS    2F. .......       PDE    1973  04 13 144032.60  41.84   22.72   5              4F. .......       PDE    1973  04 29 143753.90  34.64   -4.07  19  4.6 mbGS    6F. .......       PDE    1973  05 05 074058.10  40.89  140.31  17  5.1 mbGS    6F. .......       PDE    1973  05 12 140502.80  -3.94  152.06  14  5.6 mbGS    3F. .......       PDE    1973  05 12 162009.20  -3.73  152.08  13  6.0 UKPAS   5F. .......      

2:代碼:

package com.mojia.mr.demo;public class Parser {private String line;public Parser(String line) {this.line = line;}public String getYear() {int index = line.indexOf("PDE");String year = line.substring(index + 7, index + 11);return year;}public boolean isBig() {String[] strs = line.split(" ");String temp = "";for (String str : strs) {if (str.contains("F.") || str.contains("D.") || str.contains("M.")|| str.contains("CM") || str.contains("FM")|| str.contains(".M")) {temp = str;}}if (temp.equals("")) {System.out.println("temp=" + temp);String leverStr = "";if (temp.endsWith("F.")) {leverStr = temp.replace("F.", "");} else if (temp.endsWith("F")) {leverStr = temp.replace("F", "");}int lever = -1;try {lever = Integer.parseInt(leverStr);} catch (Exception e) {System.out.println("format error");}if (lever >= 4) {return true;}}return false;}}

3: 圖表展示

見下面圖形。X軸表示時間1980--2009

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.