Adding Filter in Hadoop Mapper Class
There is my solutions to tackle the disk spaces shortage problem I described in the previous post. The core principle of the solution is to reduce the number of output records at Mapper stage; the method I used is Filter , adding a filter,
There is my solutions to tackle the disk spaces shortage problem I described in the previous post. The core principle of the solution is to reduce the number of output records at Mapper stage; the method I used is Filter, adding a filter, which I will explain later, to decrease the output records of Mapper, which in turn significantly decrease the Mapper’s Spill records, and fundamentally decrease the disk space usages. After applying the filter, with 30,661 records. some 200MB data set as inputs, the total Spill Records is 25,471,725, and it only takes about 509MB disk spaces!
Followed Filter
And now I’m going to reveal what’s kinda Filter it looks like, and how did I accomplish that filter. The true face of the FILTER is called Followed Filter, it filters users from computing co-followed combinations if their followed number does not satisfy a certain number, called Followed Threshold.
Followed Filter is used to reduce the co-followed combinations at Mapper stage. Say we set the followed threshold to 100, meaning users who doesn’t own 100 fans(be followed by 100 other users) will be ignored during co-followed combinations computing stage(to get the actual number of the threshold we need analyze statistics of user’s followed number of our data set).
Reason
Choosing followed filter is reasonable because how many user follows is a metric of user’s popularity/famousness.
HOW
In order to accomplish it, we need:
First, counting user’s followed number among our data set, which needs a new MapReduce Job;
Second, choosing a followed threshold after analyze the statistics perspective of followed number data set got in first step;
Third, using DistrbutedCache of Hadoop to cache users who satisfy the filter to all Mappers;
Forth, adding followed filter to Mapper class, only users satisfy filter condition will be passed into co-followed combination computing phrase;
Fifth, adding co-followed filter/threshold in Reducer side if necessary.
Outcomes
Here is the Hadoop Job Summary, after applying the followed filter with followed threshold of 1000, that means only users who are followed by 1000 users will have the opportunity to co-followed combinations, compared with the Job Summary in my previous post, most all metrics have significant improvements:
Counter | Map | Reduce | Total |
Bytes Written | 0 | 1,798,185 | 1,798,185 |
Bytes Read | 203,401,876 | 0 | 203,401,876 |
FILE_BYTES_READ | 405,219,906 | 52,107,486 | 457,327,392 |
HDFS_BYTES_READ | 203,402,751 | 0 | 203,402,751 |
FILE_BYTES_WRITTEN | 457,707,759 | 52,161,704 | 509,869,463 |
HDFS_BYTES_WRITTEN | 0 | 1,798,185 | 1,798,185 |
Reduce input groups | 0 | 373,680 | 373,680 |
Map output materialized bytes | 52,107,522 | 0 | 52,107,522 |
Combine output records | 22,202,756 | 0 | 22,202,756 |
Map input records | 30,661 | 0 | 30,661 |
Reduce shuffle bytes | 0 | 52,107,522 | 52,107,522 |
Physical memory (bytes) snapshot | 2,646,589,440 | 116,408,320 | 2,762,997,760 |
Reduce output records | 0 | 373,680 | 373,680 |
Spilled Records | 22,866,351 | 2,605,374 | 25,471,725 |
Map output bytes | 2,115,139,050 | 0 | 2,115,139,050 |
Total committed heap usage (bytes) | 2,813,853,696 | 84,738,048 | 2,898,591,744 |
CPU time spent (ms) | 5,766,680 | 11,210 | 5,777,890 |
Virtual memory (bytes) snapshot | 9,600,737,280 | 1,375,002,624 | 10,975,739,904 |
SPLIT_RAW_BYTES | 875 | 0 | 875 |
Map output records | 117,507,725 | 0 | 117,507,725 |
Combine input records | 137,105,107 | 0 | 137,105,107 |
Reduce input records | 0 | 2,605,374 | 2,605,374 |
P.S.
Frankly Speaking, chances are I am on the wrong way to Hadoop Programming, since I’m palying Pesudo Distribution Hadoop
with my personal computer, which has 4 CUPs and 4G RAM, in real Hadoop Cluster disk spaces might never be a trouble, and all the tuning work I have done may turn into meaningless efforts. Before the Followed Filter, I also did some Hadoop tuning like customed Writable class, RawComparator, block size and io.sort.mb, etc.
---EOF---
原文地址:Adding Filter in Hadoop Mapper Class, 感谢原作者分享。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











Java エラー: Hadoop エラー、対処方法と回避方法 Hadoop を使用してビッグ データを処理する場合、タスクの実行に影響を与え、データ処理の失敗を引き起こす可能性のある Java 例外エラーが頻繁に発生します。この記事では、一般的な Hadoop エラーをいくつか紹介し、それらに対処および回避する方法を示します。 Java.lang.OutOfMemoryErrorOutOfMemoryError は、Java 仮想マシンのメモリ不足によって発生するエラーです。 Hadoop の場合

SpringBoot プロジェクトで、永続層フレームワークとして MyBatis が使用されている場合、自動インジェクションを使用するとマッパーが null ポインター例外を報告するという問題が発生する可能性があります。これは、自動挿入中に SpringBoot が MyBatis の Mapper インターフェイスを正しく識別できず、追加の構成が必要になるためです。 1. Mapper インターフェイスにアノテーションを追加する @Mapper アノテーションを Mapper インターフェイスに追加して、このインターフェイスが Mapper インターフェイスでありプロキシする必要があることを SpringBoot に伝えます。例は次のとおりです: @MapperpublicinterfaceUserMapper{//...}2
![「[Vue 警告]: フィルターを解決できませんでした」エラーを解決する方法](https://img.php.cn/upload/article/000/887/227/169243040583797.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
「[Vuewarn]:Failedtoresolvefilter」エラーを解決する方法 Vue を使用した開発プロセス中に、「[Vuewarn]:Failedtoresolvefilter」というエラー メッセージが表示されることがあります。このエラー メッセージは通常、テンプレートで未定義のフィルターを使用したときに発生します。この記事では、このエラーを解決する方法を説明し、対応するコード例を示します。 Vue を使用しているとき

mybatis mybatis.mapper-locations=classpath*:com/springboot/mapper/*.xml のマッパー ファイル スキャン パス内のすべてのマッパー マッピング ファイル、またはリソース mybatis.mapper-locations=classpath*:mapper/** の下のマッパー マッピング ファイルを指定します。 /*.xmlmybatis は複数のスキャンパスを設定します。書き込み方法は Baidu から取得しましたが、非常に面倒です。少し整理しましょう。最近プロジェクトを解体したところ、小さな問題が発生しました。少し記録します。

ビッグデータ時代の到来に伴い、データの処理と保存の重要性がますます高まっており、大量のデータをいかに効率的に管理、分析するかが企業にとっての課題となっています。 Apache Foundation の 2 つのプロジェクトである Hadoop と HBase は、ビッグ データのストレージと分析のためのソリューションを提供します。この記事では、ビッグデータのストレージとクエリのために Beego で Hadoop と HBase を使用する方法を紹介します。 1. Hadoop と HBase の概要 Hadoop は、オープンソースの分散ストレージおよびコンピューティング システムです。

データ量が増加し続けるにつれて、従来のデータ処理方法ではビッグデータ時代がもたらす課題に対処できなくなります。 Hadoop は、ビッグ データ処理において単一ノード サーバーによって引き起こされるパフォーマンスのボトルネック問題を、分散ストレージと大量のデータの処理を通じて解決する、オープン ソースの分散コンピューティング フレームワークです。 PHP は、Web 開発で広く使用されているスクリプト言語であり、迅速な開発と容易なメンテナンスという利点があります。この記事では、ビッグデータ処理に PHP と Hadoop を使用する方法を紹介します。 HadoopとはHadoopとは

Java ビッグ データ テクノロジ スタック: Hadoop、Spark、Kafka などのビッグ データ分野における Java のアプリケーションを理解します。データ量が増加し続けるにつれて、今日のインターネット時代ではビッグ データ テクノロジが注目のトピックになっています。ビッグデータの分野では、Hadoop、Spark、Kafka などのテクノロジーの名前をよく耳にします。これらのテクノロジーは重要な役割を果たしており、広く使用されているプログラミング言語である Java もビッグデータの分野で大きな役割を果たしています。この記事では、Java のアプリケーション全般に焦点を当てます。

1: JDK1のインストール 以下のコマンドを実行して、JDK1.8のインストールパッケージをダウンロードします。 wget--no-check-certificatehttps://repo.huaweicloud.com/java/jdk/8u151-b12/jdk-8u151-linux-x64.tar.gz2. 次のコマンドを実行して、ダウンロードした JDK1.8 インストール パッケージを解凍します。 。 tar-zxvfjdk-8u151-linux-x64.tar.gz3. JDK パッケージを移動して名前を変更します。 mvjdk1.8.0_151//usr/java84. Java 環境変数を設定します。エコー'
