JP2019204473A - Method for writing plurality of small files of 2 mb or smaller to hdfs having data merge module and hbase cash module on the basis of hadoop - Google Patents

Method for writing plurality of small files of 2 mb or smaller to hdfs having data merge module and hbase cash module on the basis of hadoop Download PDF

Info

Publication number
JP2019204473A
JP2019204473A JP2018147289A JP2018147289A JP2019204473A JP 2019204473 A JP2019204473 A JP 2019204473A JP 2018147289 A JP2018147289 A JP 2018147289A JP 2018147289 A JP2018147289 A JP 2018147289A JP 2019204473 A JP2019204473 A JP 2019204473A
Authority
JP
Japan
Prior art keywords
file
user
small
files
access
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2018147289A
Other languages
Japanese (ja)
Other versions
JP6642650B2 (en
Inventor
謝桂園
Guiyuan Xie
魏文国
Wenguo Wei
蔡君
Jun Cai
趙慧民
Huimin Zhao
彭建烽
Jianfeng Peng
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Polytechnic Normal University
Original Assignee
Guangdong Polytechnic Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Polytechnic Normal University filed Critical Guangdong Polytechnic Normal University
Publication of JP2019204473A publication Critical patent/JP2019204473A/en
Application granted granted Critical
Publication of JP6642650B2 publication Critical patent/JP6642650B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

To disclose a method for writing a large number of small files on the basis of Hadoop.SOLUTION: A writing method is applied to an HDFS system having a data merge module and an HBase cash module. The method receives a command for writing small files inputted by a user, inquires the HBase cash module according to a user ID and the name of the small file, uploads first file content to which the small file is written to the HBase cash module when the file content is inquired first and updates the content, inquires a database of an HDFS system when the content is not inquired, and uploads second file content to which the small file is written and updates the content when the second file content is inquired. The writing method can improve read efficiency of a small file.SELECTED DRAWING: Figure 1

Description

本発明はコンピュータテクノロジー分野に関し、具体的には、Hadoopに基づく大量の小さなファイルの書き込みメソッドに関する。   The present invention relates to the field of computer technology, and more particularly to a method for writing a large number of small files based on Hadoop.

Hadoopは2005年にApache FoundationによってLuceneのサブプロジェクトであるNutchの一部分として正式に導入されたものである。Hadoopの最も重要な二つの設計はHDFSとMapReduceである。HDFSは大量なデータをストレージし、ファイルがデータブロックの形でシステムにストレージされる。また、HDFSのデータブロックは通常のディスクに定義されたデータブロック(通常は512B)よりも遥かに大きく、HDFSの現在のデフォルトブロックサイズは128MBである。もしHDFSにストレージされたファイルのサイズが128に超えると、HDFSは該ファイルを複数のブロックサイズのブロックに分割し、別々にストレージする。また、HDFSが絶えずに小さなファイルをTBひいてはPBレベルまでストレージし続けると、小さなファイルの問題が発生し、此れは、大量のメタデータがHDFSのプライマリノードのnamenodeにストレージされるため、namenodeの負荷が大幅に増加し、システムの読み取りパフォーマンスに影響するためである。その中に、小さなファイルのサイズが2MBに定義され、つまり、HDFSがファイルをストレージする中で、ファイルのサイズが2Mまたは2M以下であると、小さなファイルとして定義される。   Hadoop was officially introduced in 2005 by Apache Foundation as part of Lucene, a subproject of Lucene. The two most important Hadoop designs are HDFS and MapReduce. HDFS stores a large amount of data, and files are stored in the system in the form of data blocks. Also, the HDFS data block is much larger than the data block defined for a normal disk (usually 512B), and the current default block size of HDFS is 128 MB. If the size of a file stored in HDFS exceeds 128, HDFS divides the file into blocks having a plurality of block sizes and stores them separately. Also, if HDFS keeps storing small files continuously to TB and eventually to PB level, there will be a problem of small files, because a large amount of metadata is stored in the namenode of the primary node of HDFS. This is because the load increases significantly and affects the read performance of the system. Among them, the size of a small file is defined as 2 MB, that is, when the file size is 2M or 2M or less while HDFS is storing the file, it is defined as a small file.

大量な小さなファイルの処理について、現有の技術においては、若干の小さなファイルを一つのブロックサイズの大きなファイルにマージすることであり、ファイル間の関連性を考慮せず、小さなファイルの読み込み効率が望ましくなくなる。 Regarding the processing of a large number of small files, the current technology is to merge a few small files into one large block size file, and the efficiency of reading small files is desirable without considering the relationship between files. Disappear.

中国特許出願公開第103605479号明細書Chinese Patent Application No. 10365479

本発明の実施例が提供するHadoopに基づく大量の小さなファイルの書き込みメソッドは、小さなファイルのマージ及びHBaseキャッシングメカニズムと合わせた後で、書き込まれた小さなファイルの読み取りをもっと容易くし、小さなファイルの読み取り効率を向上させることができる。   The method of writing a large number of small files based on Hadoop provided by an embodiment of the present invention makes it easier to read a small file written after combining with a small file merge and HBase caching mechanism, and reads a small file. Efficiency can be improved.

本発明の実施例が提供するHadoopに基づく大量の小さなファイルの書き込みメソッドについては、前記書き込みメソッドがデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、前記書き込みメソッドが: For a method for writing a large number of small files based on Hadoop provided by an embodiment of the present invention, the write method is applied to an HDFS system including a data merge module and an HBase cache module, and the write method is:

ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、その中に、前記小さなファイルの書き込みコマンドがユーザIDと小さなファイルの名前を含み、 Receiving a small file write command input by a user, wherein the small file write command includes a user ID and a small file name;

ユーザIDと前記小さなファイルの名前によって前記HBaseキャッシュモジュールを照会し、 Query the HBase cache module by user ID and the name of the small file;

対応するファイル内容が出たら、前記HBaseキャッシュモジュールによって照会された最初のファイルコンテンツに戻り、前記小さなファイルを書き込み、小さなファイルの書き込まれた最初のファイルコンテンツを前記HBaseキャッシュモジュールにアップロードして更新し、対応するファイル内容が出ないと、前記小さなファイルのファイル名によって前記HDFSシステムのデータベースを照会し、対応するファイルコンテツが照会されたかどうかを判断し、 Once the corresponding file content is available, return to the initial file content queried by the HBase cache module, write the small file, and upload and update the initial file content written for the small file to the HBase cache module. If the corresponding file content does not appear, the HDFS system database is queried with the file name of the small file to determine whether the corresponding file content has been queried,

イエスであれば、前記データベースに照会された第二のファイルコンテンツに戻り、前記小さなファイルを書き込み、前記小さなファイルの書き込まれた第二のファイルコンテンツを前記データベースにアップロードして更新し、 If yes, go back to the second file content queried in the database, write the small file, upload the updated second file content of the small file to the database and update,

そうでなければ、HadooparchiveツールのAPIを呼び出して前記小さなファイルのファイル名と対応するHARファイルにアクセスし、前記小さなファイルを書き込み、前記小さなファイルの書き込まれたHARファイルを前記データベースにアップロードして更新する。 Otherwise, call the Hadooprchive tool API to access the HAR file corresponding to the file name of the small file, write the small file, and upload and update the HAR file with the small file written to the database To do.

更に、前記データマージモジュールが採用するデータマージメソッドは: Furthermore, the data merge method employed by the data merge module is:

ステップA:クライアントがストレージされるファイルをアップロードした後で、HDFSのすべてのファイルをトラバースし、ユーザアクセスプリファレンスモデルを組み合わせて、前記ストレージされるファイルの関連ファイルコレクションを見つけ、その中に、前記ユーザアクセスプリファレンスモデルがユーザアクセスログレコードに基づき、 Step A: After the client uploads the stored file, traverse all the files in HDFS and combine the user access preference model to find the relevant file collection of the stored file, in which the said The user access preference model is based on user access log records,

ステップB:前記関連ファイルコレクションのミドルファイルと前記ストレージされるファイルを順にマージするキューに追加する。 Step B: Add the middle file of the related file collection and the stored file to the queue to be merged in order.

ステップC:前記マージするキューのすべてのファイルの総サイズが128 MBを超えるかどうかを判断し、イエスであれば、ステップDに進み、そうでなければ、ステップEに進み、 Step C: Determine whether the total size of all files in the queue to be merged exceeds 128 MB. If yes, go to Step D, otherwise go to Step E.

ステップD:前記マージするキューのすべてのファイルを一つのデータブロックにマージし、前記マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップBに戻り、 Step D: Merge all the files of the queue to be merged into one data block, clear the file information of the queue to be merged, delete the source file of the merged file, return to Step B,

ステップE:前記関連ファイルコレクションのミドルファイルと前記ストレージされるファイルが全部前記マージするキューに追加されたかどうかを判断し、イエスであれば、前記マージするキューのすべてのファイルを一つのデータブロックにマージし、前記マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップFに進み、そうでなければ、ステップBに進む。 Step E: It is determined whether all the middle files of the related file collection and the stored files are added to the merge queue. If yes, all the files of the merge queue are combined into one data block. Merge, clear the file information of the queue to be merged, delete the source file of the merged file, proceed to step F, otherwise proceed to step B.

ステップF:すべてのマージしたデータブロックをHDFSシステムにストレージする。 Step F: Store all merged data blocks in the HDFS system.

更に、その特徴は、前記プリファレンスモデルがユーザアクセスログレコードから統計されたもので、具体的には: In addition, the feature is that the preference model is statistics from user access log records, specifically:

前記ユーザアクセスログレコードからアクティブユーザセットを統計し、 Statistics active user sets from the user access log records;

前記アクティブユーザセットにアクセスされた小さなファイルをBeanオブジェクトで表し、前記小さなファイルがサイズが2MB又は2MB以下のファイルに指し、その中に、前記オブジェクトのプロパティが該小さなファイルにアクセスユーザID、ユーザにアクセスされた小さなファイル名及び該小さなファイルがアクセスされた回数を含み、 A small file accessed by the active user set is represented by a Bean object, and the small file points to a file having a size of 2 MB or less, and the property of the object includes an access user ID and a user Including the name of the accessed small file and the number of times the small file has been accessed,

JDBCテクノロジを合わせて、前記beanオブジェクトをMysqlデーターベースに永続化してストレージし、ストレージされたデータによって、任意の二つの異なるアクセス動作の類似性をアカウントし、 Together with the JDBC technology, the bean object is persisted and stored in a MySQL database, and the stored data accounts for the similarity of any two different access operations,

任意の二つの異なるアクセス動作の類似性が正の場合、前記任意の二つのアクセス動作のユーザが類似ユーザであり、類似ユーザのIDを記録して関連ファイルセットによって類似ユーザにアクセスされ、関連付けられたファイルの情報をストレージし、 If the similarity between any two different access operations is positive, the user of any two access operations is a similar user, and the similar user ID is recorded and accessed by the related file set to be associated with the similar user. Store the file information,

前記関連ファイルセットによって、前記ユーザアクセスプリファレンスモデルを構築する。 The user access preference model is constructed by the related file set.

更に、その特徴は、前記HBaseキャッシュモジュールが採用するキャッシュメソッドは: Further, the cache method employed by the HBase cache module is:

ユーザアクセスログレコードを取得し、前記ユーザアクセスログレコードからアクティブユーザセットを統計し、 Obtaining a user access log record, statistics an active user set from the user access log record,

対数線形モデルを合わせ、前記アクティブユーザセットの各アクテイブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順でソートし、ファイルの上位20%をホットスポットファイルとしてマークし、 Combine log-linear models, account for popularity predictions of files accessed by each active user in the active user set, sort each file in descending order by popularity predictions, and mark the top 20% of files as hotspot files And

前記ホットスポットファイルを取得し、Hbaseデータベースを使って前記ホットスポットファイルの関連情報をキャッシュする。 The hot spot file is acquired, and related information of the hot spot file is cached using an Hbase database.

更に、前記前記ユーザアクセスログレコードからアクティブユーザセットを統計するについて、具体的には: Further on statistics of active user sets from the user access log record, specifically:

アクセスされたソースの接尾辞がjpgであるレコード行を前記ユーザアクセスログレコードからフィルタリングし、その中に、前記レコード行がユーザID、アクセスページURL、アクセス開始時刻、アクセス状況、アクセストラフィックを含み、 Filtering record rows from the user access log record with the accessed source suffix jpg, wherein the record row includes a user ID, access page URL, access start time, access status, access traffic;

レコード解析クラスを作成して前記レコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、 Create a record parsing class to parse the record row, use a 2D array to store the visitor IP and the name of the small file,

ビジターIPを前記二次元配列でトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、前記HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、 Traversing the visitor IP with the two-dimensional array, using the HashMap collection to statistic the traffic of each visitor IP, the Key value of the HashMap collection is the visitor IP, the Value value is the traffic,

前記HashMapコレクションをValue値の降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージし、アクティブユーザセットとしてマークし、 Sort the HashMap collection in descending order of Value values, filter the top 20% of visitor IPs, use the ArrayList collection to store the IP subset, mark it as an active user set,

更に、対数線形モデルをあわせて、前記アクティブユーザセットの各アクティブユーザにアクサスされたファイルの人気予測値をアカウントして、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークし、具体的には: In addition, logarithmic linear models are combined to account for the popularity prediction value of the file accessed by each active user in the active user set, and each file is sorted in descending order by popularity prediction value, and the top 20% of the file is hot. Mark as a spot file, specifically:

ArrayListコレクションから抽出されたビジターIPを、前記二次元配列から抽出されたビジターIPと照合し、 Matching the visitor IP extracted from the ArrayList collection with the visitor IP extracted from the two-dimensional array;

一致が出たら、合致するビジターIPをキーワードとして、各ユーザのアクセス開始時刻を照会して、対数線形モデルを合わせ、前記アクティブユーザセットの各アクティブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークし、 When a match is found, the access start time of each user is inquired using the matching visitor IP as a keyword, the logarithmic linear model is matched, and the popularity prediction value of the file accessed by each active user of the active user set is accounted for. , Sort each file in descending order by popularity prediction, mark the top 20% of files as hotspot files,

前記対数線形モデルは:

Figure 2019204473
であり、 The log-linear model is:
Figure 2019204473
And

その中に、

Figure 2019204473
がファイルiの人気予測値であり、
Figure 2019204473
がファイルiが観測期間中のトラフィックであり、観測期間の長さがtである。 Among them,
Figure 2019204473
Is the popularity prediction for file i,
Figure 2019204473
File i is the traffic during the observation period, and the length of the observation period is t.

本発明の実施例を実施すると、以下の有益効果が出る: Implementation of embodiments of the present invention has the following beneficial effects:

本発明の実施例が提供するHadoopに基づく大量の小さなファイルの書き込みメソッドについては、該書き込みメソッドはデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、該読み込みメソッドは:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、その中に、小さなファイルの書き込みコマンドがユーザーIDと小さなファイルの名前を含み、ユーザIDと小さなファイルの名前によってHBaseキャッシュモジュールを照会し、対応する最初のファイルコンテンツが照会されたら、最初のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた最初のファイルコンテンツをHBaseキャッシュモジュールにアップロードして更新し、対応する最初のファイルコンテンツが照会されなかったら、HDFSデータベースを照会し、成功すれば、照会された第二のファイルコンテンツに戻り、小さなファイルの書き込まれた第二のファイルコンテンツをデータベースにアップロードして更新し、失敗すれば、HadooparchiveツールのAPIを呼び出して対応するHARファイルにアクセスし、小さなファイルを書き込み、小さなファイルの書き込まれたHARファイルをデータベースにアップロードして更新する。小さなファイル間の関連性とホットスポットファイルを考慮しない既存技術と比べ、本発明の書き込みメソッドは小さなファイルのマージ及びHBaseキャッシングメカニズムと合わせた後で、書き込まれた小さなファイルの読み取りをもっと容易くし、小さなファイルの読み取り効率を向上させることができる。 For the method of writing a large number of small files based on Hadoop provided by the embodiment of the present invention, the write method is applied to an HDFS system including a data merge module and an HBase cache module, and the read method is input by: user A small file write command is received, in which the small file write command includes the user ID and the name of the small file, queries the HBase cache module by the user ID and the name of the small file, and the corresponding first file content Is queried, it returns to the first file content, writes a small file, and uploads the first file content written for the small file to the HBase cache module. If the corresponding first file content is not queried, the HDFS database is queried, and if successful, it returns to the queried second file content and the second file content with the small file written If it fails, the API of the Hadooparkive tool is accessed to access the corresponding HAR file, a small file is written, and the HAR file in which the small file is written is uploaded to the database and updated. Compared to existing technology that does not consider the relationship between small files and hotspot files, the writing method of the present invention makes it easier to read the written small files after combining with the small file merging and HBase caching mechanism, The reading efficiency of small files can be improved.

本発明の実施例を実施すると、以下の有益効果が出る: Implementation of embodiments of the present invention has the following beneficial effects:

本発明の実施例が提供するHadoopに基づく大量の小さなファイルの書き込みメソッドについては、該書き込みメソッドはデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、該読み込みメソッドは:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、その中に、小さなファイルの書き込みコマンドがユーザーIDと小さなファイルの名前を含み、ユーザIDと小さなファイルの名前によってHBaseキャッシュモジュールを照会し、対応する最初のファイルコンテンツが照会されたら、最初のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた最初のファイルコンテンツをHBaseキャッシュモジュールにアップロードして更新し、対応する最初のファイルコンテンツが照会されなかったら、HDFSデータベースを照会し、成功すれば、照会された第二のファイルコンテンツに戻り、小さなファイルの書き込まれた第二のファイルコンテンツをデータベースにアップロードして更新し、失敗すれば、HadooparchiveツールのAPIを呼び出して対応するHARファイルにアクセスし、小さなファイルを書き込み、小さなファイルの書き込まれたHARファイルをデータベースにアップロードして更新する。小さなファイル間の関連性とホットスポットファイルを考慮しない既存技術と比べ、本発明の書き込みメソッドは小さなファイルのマージ及びHBaseキャッシングメカニズムと合わせた後で、書き込まれた小さなファイルの読み取りをもっと容易くし、小さなファイルの読み取り効率を向上させることができる。 For the method of writing a large number of small files based on Hadoop provided by the embodiment of the present invention, the write method is applied to an HDFS system including a data merge module and an HBase cache module, and the read method is input by: user A small file write command is received, in which the small file write command includes the user ID and the name of the small file, queries the HBase cache module by the user ID and the name of the small file, and the corresponding first file content Is queried, it returns to the first file content, writes a small file, and uploads the first file content written for the small file to the HBase cache module. If the corresponding first file content is not queried, the HDFS database is queried, and if successful, it returns to the queried second file content and the second file content with the small file written If it fails, the API of the Hadooparkive tool is accessed to access the corresponding HAR file, a small file is written, and the HAR file in which the small file is written is uploaded to the database and updated. Compared to existing technology that does not consider the relationship between small files and hotspot files, the writing method of the present invention makes it easier to read the written small files after combining with the small file merging and HBase caching mechanism, The reading efficiency of small files can be improved.

図1は本発明の提供するHadoopに基づく大量の小さなファイルの書き込みメソッドの実施例のプロセス見取り図である。FIG. 1 is a process sketch of an embodiment of a method for writing a large number of small files based on Hadoop provided by the present invention. 図2は本発明の提供するデータマージメソッドの実施例のプロセス見取り図である。FIG. 2 is a process sketch of an embodiment of the data merge method provided by the present invention. 図3は本発明の提供するキャッシュメソッドの実施例のプロセス見取り図である。FIG. 3 is a process sketch of an embodiment of the cache method provided by the present invention. 図4は本発明の提供するキャッシュメソッドのもう一つの実施例のプロセス見取り図である。FIG. 4 is a process sketch of another embodiment of the cache method provided by the present invention.

下記に本発明の実施例の中の附図を交え、本発明の実施例の技術方案を明確にはっきり説明し、説明した実施例がただ本発明の一部分の実施例で、全部の実施例ではないである。本発明の実施例に基づいて、本領域の普通技術者が創造的な労働を払わないことを前提に得る全部のその他の実施例は本発明の保護範囲に所属する The accompanying drawings in the embodiments of the present invention are described below, the technical solutions of the embodiments of the present invention are clearly explained, and the described embodiments are only a part of the embodiments of the present invention and not all the embodiments. It is. Based on the embodiments of the present invention, all other embodiments obtained on the assumption that ordinary engineers in this area do not pay creative labor belong to the protection scope of the present invention.

図1を参照し、本発明の提供するHadoopに基づく大量の小さなファイルの書き込みメソッドの実施例のプロセス見取り図であり、該メソッドがステップ101からステップ106までを含む。該書き込みメソッドはデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、各ステップは以下を含む: Referring to FIG. 1, a process sketch of an embodiment of a method for writing a large number of small files based on Hadoop provided by the present invention includes steps 101 to 106. The write method is applied to an HDFS system comprising a data merge module and an HBase cache module, and each step includes:

ステップ101:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、その中に、前記小さなファイルの書き込みコマンドがユーザIDと小さなファイルの名前を含む。   Step 101: Receive a small file write command input by a user, wherein the small file write command includes a user ID and a small file name.

ステップ102:ユーザIDと前記小さなファイルの名前によって前記HBaseキャッシュモジュールを照会し、対応するファイルコンテンツが照会されたかどうかを判断し、イエスであれば、ステップ105に進み、そうでなければ、ステップ103に進む。 Step 102: Query the HBase cache module by user ID and the name of the small file to determine whether the corresponding file content has been queried, if yes, go to step 105, otherwise, step 103 Proceed to

ステップ103:小さなファイルの名前により前記HDFSシステムのデータベースを照会し、対応する第二のファイルコンテンツが照会されたかどうかを判断し、イエスであれば、ステップ106に進み、そうでなければ、ステップ104に進む。 Step 103: Query the HDFS system database by the name of the small file to determine whether the corresponding second file content has been queried; if yes, go to step 106; Proceed to

ステップ104:HadooparchiveツールのAPIを呼び出して小さなファイルのファイル名と対応するHARファイルにアクセスし、小さなファイルの書き込まれたHARファイルをデータベースにアップロードして更新する。 Step 104: Call an API of the Hadooparkive tool to access the HAR file corresponding to the file name of the small file, and upload and update the HAR file in which the small file is written to the database.

ステップ105:最初のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた最初のファイルコンテンツをHBaseキャッシュモジュールにアップロードして更新する。 Step 105: Return to the first file content, write a small file, and upload and update the first file content with the small file written to the HBase cache module.

ステップ106:データベースに照会された第二のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた第二のファイルコンテンツをデータベースにアップロードして更新する。 Step 106: Return to the second file content queried in the database, write a small file, and upload and update the second file content in which the small file is written to the database.

図2を参照し、図2は本発明の提供するデータマージメソッドの実施例のプロセス見取り図であり、本発明のデータマージモジュールには図2の示すデータマージメソッドが採用され、ステップAからステップFまでを含み、各ステップは以下のように: Referring to FIG. 2, FIG. 2 is a process sketch of an embodiment of the data merge method provided by the present invention. The data merge method of the present invention employs the data merge method shown in FIG. Each step is as follows:

ステップA:クライアントがストレージされるファイルをアップロードした後で、HDFSのすべてのファイルをトラバースし、ユーザアクセスプリファレンスモデルを組み合わせて、前記ストレージされるファイルの関連ファイルコレクションを見つけ、その中に、前記ユーザアクセスプリファレンスモデルがユーザアクセスログレコードに基づき、 Step A: After the client uploads the stored file, traverse all the files in HDFS and combine the user access preference model to find the relevant file collection of the stored file, in which the said The user access preference model is based on user access log records,

本実施例において、ユーザアクセスプリファレンスモデルがユーザアクセスログレコードから統計されたもので、具体的には:ユーザアクセスログレコードからアクティブユーザセットを統計し、アクティブユーザセットにアクセスされた小さなファイルをbeanオブジェクトで表し、小さなファイルがサイズが2MB又は2MB以下のファイルであり、その中に、beanオブジェクトのプロパティが該小さなファイルにアクセスしたユーザID、ユーザにアクセスされた小さなファイルの名前及び該小さなファイルがアクセスされた回数を含み、JDBCテクノロジを合わせて、beanオブジェクトをMysqlデータベースに永続化してストレージし、ストレージされたデータによって、任意の二つの異なるアクセス動作の類似性をアカウントし、任意の二つの異なるアクセス動作の類似性が正であれば、任意の二つのアクセス動作のユーザが類似ユーザであり、類似ユーザのIDを記録して関連ファイルセットを使ってすべての類似ユーザにアクセスされ、関連付けられたファイル情報をストレージし、関連ファイルセットによって、ユーザアクセスプリファレンスモデルを構築する。 In this embodiment, the user access preference model is statistically calculated from the user access log record. Specifically: the active user set is statistically calculated from the user access log record, and the small file accessed by the active user set is bean. A small file is a file whose size is 2 MB or 2 MB or less, and in which the bean object property is the user ID that accessed the small file, the name of the small file accessed by the user, and the small file Include the number of accesses, combine JDBC technology, store bean objects persistently in the MySQL database, and the similarity of any two different access behaviors depending on the stored data If you account and the similarity of any two different access actions is positive, the user of any two access actions is a similar user, record the similar user's ID and use the related file set to find all similarities The user accesses and stores the associated file information, and builds the user access preference model with the related file set.

本実施例において、ユーザアクセスログレコードからアクティブユーザセットを統計し、具体的には:アクセスされたソースの接尾辞がjpgであるレコード行をユーザアクセスログレコードからフィルタリングし、その中に、レコード行がユーザID、アクセスページURL、アクセス開始時刻、アクセス状況、アクセストラフィックを含み、レコード解析クラスを作成して前記レコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、ビジターIPを二次元配列でトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、HashMapコレクションをValue値の降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージし、アクティブユーザセットとしてマークする。 In this example, the active user set is statistics from the user access log record, specifically: record rows with the suffix of the accessed source are jpg from the user access log record, in which the record row Contains user ID, access page URL, access start time, access status, access traffic, creates record analysis class to analyze the record row, and stores visitor IP and small file name using 2D array Traverse the visitor IP in a two-dimensional array, use the HashMap collection to statistic the traffic for each visitor IP, the key value for the HashMap collection is visitor IP, the value is traffic, and the HashMap collection Sort by descending alue value, filters the 20% upper visitor IP, the IP subnet to storage using ArrayList collection, marked as active user set.

本発明のモデルの構築過程をもっとよく説明するために、下記の例えにより説明し、具体的な実現する過程が以下のように: In order to better explain the process of building the model of the present invention, it is explained by the following illustration, and the specific realization process is as follows:

(1)正規表現を使用してアクセスされたソースの接尾辞がjpgであるレコード行をフィルタリングする。 (1) Filter record rows whose source suffix is jpg accessed using regular expressions.

(2)ログ解析クラスを作成してレコード行の五つのコンポーネントを別々に解析し、二次元配列を使ってビジターIPと小さなファイルの名前をストレージする。 (2) Create a log analysis class to analyze the five components of the record row separately, and store the visitor IP and the name of the small file using a two-dimensional array.

(3)二次元配列のビジターIP要素をトラバースし、各ビジターIPのトラフィックをカウンタするカウンタを設計する。HashMapコレクションを使って、ビジターIPをKey値とし、Value値が該ビジターのトラフィックである。 (3) A counter that traverses the two-dimensional array of visitor IP elements and counts the traffic of each visitor IP is designed. Using the HashMap collection, the visitor IP is a key value, and the value value is the traffic of the visitor.

(4)ステップ3で生成されたHashMapコレクションをValue値にしたがって降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションで該IPサブセットをストレージし、アクティブユーザセットとしてマークする。 (4) Sort the HashMap collection generated in step 3 in descending order according to Value values, filter the top 20% of visitor IPs, store the IP subset in the ArrayList collection, and mark it as the active user set.

(5)一つのbeanオブジェクトによってアクティブユーザセットにアクセスされた小さなファイルを抽象に表し、オブジェクトのプロパティが該小さなファイルをアクセスしたユーザID、ユーザにアクセスされた小さなファイルの名前及び該小さなファイルがアクセスされた回数を含む。メソッドはプロパティを取得するget及びsetメソッドである。 (5) An abstract representation of a small file accessed to the active user set by one bean object, where the object properties are the user ID that accessed the small file, the name of the small file accessed by the user, and the small file accessed Including the number of times The methods are get and set methods for acquiring properties.

(6)JDBCテクノロジbeanオブジェクトをMysqlデータベースに結合して永続にストレージし、以下の形式のテーブルが形成される: (6) Join the JDBC object bean object to the MySQL database and store it persistently to form a table of the form:

Figure 2019204473
Figure 2019204473

(7)20行の二行の間にデータを取り込み、数式

Figure 2019204473
によって二つの異なるユーザアクセス作動の類似性をカウンタする。その中に、本発明はピアソン相関係数を使用して類似のユーザを決定し、スコアリング行列Rを指定し、ユーザaとユーザbの類似性をsim(a,b)で表し、r及びrが「ユーザ−トラフィック」ストアリングマトリックスのストアリングデータである。 (7) Take data between two lines of 20 lines, formula
Figure 2019204473
Counters the similarity of two different user access actions. Among them, the present invention uses the Pearson correlation coefficient to determine similar users, specifies a scoring matrix R, expresses the similarity between user a and user b as sim (a, b), and r a and r b is - a "user traffic" store ring data store ring matrix.

(8)ここで、sim(a,b)の値が正の値であれば、二人の異なるユーザが類似ユーザであると判定され、そのユーザIDが記録される。 (8) Here, if the value of sim (a, b) is a positive value, it is determined that two different users are similar users, and the user IDs are recorded.

(9)類似ユーザのユーザIDに基づいて、一つのコレクションを使用して、類似ユーザにアクセスされ、関連付けられているすべてのファイル情報をストレージする。 (9) Based on the user ID of the similar user, all file information accessed and related by the similar user is stored using one collection.

ステップB:関連ファイルコレクションのミドルファイルとストレージされるファイルを順にマージするキューに追加する。 Step B: Add the middle file of the related file collection and the stored file to the queue to be merged in order.

ステップC:マージするキューのすべてのファイルの総サイズが128 MBを超えるかどうかを判断し、イエスであれば、ステップDに進み、そうでなければ、ステップEに進む。 Step C: Determine whether the total size of all files in the queue to be merged exceeds 128 MB. If yes, go to step D, otherwise go to step E.

ステップD:マージするキューのすべてのファイルを一つのデータブロックにマージし、マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップBに戻る。 Step D: Merge all files in the queue to be merged into one data block, clear file information in the queue to be merged, delete the source file of the merged file, and return to Step B.

ステップE:関連ファイルコレクションのミドルファイルとストレージされるファイルが全部マージするキューに追加されたかどうかを判断し、イエスであれば、マージするキューのすべてのファイルを一つのデータブロックにマージし、マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップFに進み、そうでなければ、ステップBに進む。 Step E: Determine whether all of the middle files in the related file collection and the stored files have been added to the merge queue, and if yes, merge all the files in the merge queue into one data block and merge The file information of the queue to be cleared is cleared, the source file of the merged file is deleted, and the process proceeds to Step F. Otherwise, the process proceeds to Step B.

ステップF:すべてのマージしたデータブロックをHDFSシステムにストレージする。 Step F: Store all merged data blocks in the HDFS system.

図3を参照し、図3は本発明が提供するキャッシュメソッドの実施例のプロセス見取り図である。本発明のHBaseキャッシュモデルが図3のキャッシュメソッドを採用し、該メソッドはステップ301からステップ303までを含み、各ステップが以下のように: Reference is made to FIG. 3, which is a process sketch of an embodiment of the cache method provided by the present invention. The HBase cache model of the present invention employs the cache method of FIG. 3, which includes steps 301 through 303, with each step as follows:

ステップ301:ユーザアクセスログレコードを取得し、ユーザアクセスログレコードからアクティブユーザセットを統計する。 Step 301: Obtain a user access log record and statistic an active user set from the user access log record.

本実施例の中に、ステップ301においてユーザアクセスログレコードからアクティブユーザセットを統計し、具体的には:アクセスされたソースの接尾辞がjpgであるレコード行をユーザアクセスログレコードからフィルタリングし、その中に、レコード行がユーザIP、アクセスページURL、アクセス開始時刻、アクセス状況及びアクセストラフィックを含み、ログ解析クラスを作成してレコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、二次元配列のビジターIPをトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、HashMapコレクションをValue値によって降順にソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージしてアクティブユーザセットとしてマークする。 In this embodiment, in step 301, the active user set is statistically analyzed from the user access log record, and specifically: the record line whose accessed source suffix is jpg is filtered from the user access log record; Inside, record line contains user IP, access page URL, access start time, access status and access traffic, create log analysis class to analyze record line, visitor IP and small file using 2D array , Traverse the visitor IP in a two-dimensional array, use the HashMap collection to stat the traffic for each visitor IP, the Key value in the HashMap collection is the visitor IP, the Value value is the traffic, and the HashMap Sorted in descending order collection by Value value, filters the 20% upper visitor IP, marked as active user set and storage the IP subset using ArrayList collection.

本発明のステップ301においてアクティブユーザセットをカウントする目的は、小さなファイルへのユーザのアクセスが均一なランダムではなくパレート分布法則に近いのである。すなわち、ほとんどのI/Oが少量の人気データへのアクセスをリクエストし、トラフィックの80%がデータの20%に集中している。したがって、ファイルシステムにストレージされた大量の小さなファイルからモデルを介してホットスポットファイルを予測してキャッシュすることができれば、ユーザのデータへのアクセスの効率を上げられる。 The purpose of counting the active user set in step 301 of the present invention is that the user's access to small files is close to Pareto distribution law rather than uniform random. That is, most I / Os request access to a small amount of popular data, with 80% of the traffic concentrated on 20% of the data. Therefore, if a hot spot file can be predicted and cached from a large number of small files stored in the file system through a model, the efficiency of access to user data can be increased.

ステップ302:対数線形モデルをあわせて、アクティブユーザセットの各アクティブユーザにアクサスされたファイルの人気予測値をアカウントして、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークする。 Step 302: Combine log-linear models to account for the popularity predictions of the file accessed for each active user in the active user set, sort each file in descending order by popularity prediction, and hot the top 20% of the files Mark as a spot file.

本実施例において、ステップ302は具体的には:ArrayListコレクションから抽出されたビジターIPを、二次元配列から抽出されたビジターIPと照合し、一致が出たら、合致するビジターIPをキーワードとして、各ユーザのアクセス開始時刻を照会して、対数線形モデルを合わせ、アクティブユーザセットの各アクティブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークする。 In this embodiment, the step 302 is specifically: matching the visitor IP extracted from the ArrayList collection with the visitor IP extracted from the two-dimensional array, and if a match is found, each matching visitor IP is used as a keyword. Queries the user's access start time, fits a log-linear model, accounts for popularity estimates of files accessed by each active user in the active user set, sorts each file in descending order by popularity prediction, Mark the top 20% as hotspot files.

対数線形モデルは:

Figure 2019204473
であり、 The log-linear model is:
Figure 2019204473
And

その中に、

Figure 2019204473
がファイルiの人気予測値であり、
Figure 2019204473
がファイルiが観測期間中のトラフィックであり、観測期間の長さがtである。
Figure 2019204473

Figure 2019204473
が線形関係の関連パラメータであり、線形回帰法によって最適値をアカウントすることができる。 Among them,
Figure 2019204473
Is the popularity prediction for file i,
Figure 2019204473
File i is the traffic during the observation period, and the length of the observation period is t.
Figure 2019204473
When
Figure 2019204473
Are related parameters of the linear relationship, and the optimal value can be accounted for by linear regression.

本発明の対数線形モデルにおいて記載された観測期間の長さtの定義は:ユーザアクセスログレコードのレコード行のアクセス開始時刻要素とユーザアクセスログレコードを収集した時刻との時間差である。例えば、収集されたユーザアクセスログレコードの時点が30/Jan/2018:17:38:20で、ユーザアクセスログレコードのレコード行のアクセス開始時刻が29/Jan/2018:10:35:15で、観測期間の長さが29/Jan/2018:10:35:15から30/Jan/2018:17:38:20までの時間差であり、アカウントしやすいために、期間の長さが時間単位にする。 The definition of the observation period length t described in the logarithmic linear model of the present invention is: the time difference between the access start time element of the record row of the user access log record and the time when the user access log record is collected. For example, the collected user access log record time point is 30 / Jan / 2018: 17: 38: 20, and the access start time of the record line of the user access log record is 29 / Jan / 2018: 10: 35: 15, The length of the observation period is the time difference from 29 / Jan / 2018: 10: 35: 15 to 30 / Jan / 2018: 17: 38: 20, and the length of the period is in units of time because it is easy to account .

ステップ303:ホットスポットファイルを取得し、Hbaseデータベースを採用してホットスポットファイルの関連情報をキャッシュする。 Step 303: Acquire a hot spot file and cache the related information of the hot spot file by adopting the Hbase database.

本実施例においては、Hbaseデータベースを採用してホットスポットファイルの関連情報をキャッシュし、HBaseのテーブル名値がビジターIDであり、HBaseのRowKeyが小さなファイルの名前であり、HBaseのファミリ名が「ファイルコンテンツ」であり、Value値すなわちセル値が小さなファイルのコンテンツである。ユーザがHBaseの小さなファイルにアクセス時に、ユーザIDをテーブル名とし、アクセスする小さなファイルの名前をHBaseのget()メソッドのパラメータとすれば、対応する小さなファイルのコンテンツを取得できる。 In this embodiment, the Hbase database is used to cache the related information of the hot spot file, the table name value of the HBase is the visitor ID, the RowKey of the HBase is the name of the small file, and the family name of the HBase is “ “File content”, which is the content of a file having a small Value value, ie, cell value. When a user accesses a small HBase file, the contents of the corresponding small file can be acquired if the user ID is a table name and the name of the small file to be accessed is a parameter of the HBase get () method.

本発明のキャッシュメソッドをもっと詳しく説明するため、図4を参照し、図4は本発明の提供するキャッシュメソッドのもう一つの実施例のプロセス見取り図である。図4が示すように、該プロセスが:ユーザアクセスレコードセット→正規表現が需要するレコード行をフィルタリングする→レコード行を解析する→beanオブジェクトでレコード行情報をカプセル化する→JDBC APIを調査研究してbeanオブジェクトをMysqlデータベースに永続化する→二次元配列によってビジターIPと小さなファイルの名前情報をストレージする→配列をトラバースし、ビジタートラフィックを統計する→ビジタートラフィックによってサーとし、ArrayListコレクションを使ってアクティブユーザセットのユーザIPをストレージする→二次元配列をアクティブユーザセットのビジターIPと照合する→一致が出たら、ビジターIPをキーワードとして、ユーザアクセス開始時刻とトラフィックを抽出する→ファイル人気予測数式によってファイル人気値をアカウントする→ファイル人気値をサートし、ホットスポットファイルをマークする→HBaseによってホットスポットファイルの関連情報をキャッシュする。 To describe the cache method of the present invention in more detail, please refer to FIG. 4, which is a process sketch of another embodiment of the cache method provided by the present invention. As FIG. 4 shows, the process is as follows: user access record set → filtering record rows required by regular expressions → analyzing record rows → encapsulating record row information with bean object → researching the JDBC API Persist bean object in Mysql database → Store visitor IP and small file name information by 2D array → Traverse array and statistics visitor traffic → Use visitor traffic as sir and active using ArrayList collection The user IP of the user set is stored → The two-dimensional array is checked with the visitor IP of the active user set. Tsu to extract the click → by file popular prediction formula to account the file popularity value → to insert the file popularity value, to cache the relevant information of the hot spot file by → HBase to mark the hot spot file.

上記からわかったことは、本発明の実施例の提供するHadoopに基づく大量の小さなファイルの読み込みメソッドにおいて、該読み込みメソッドがデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用される。該読み込みメソッドは、ユーサーによってインプットされる小さなファイルの読み込みコマンドを受信し、その中に、小さなファイルの読み込みコマンドがユーザIDと小さなファイルの名前を含み、ユーザIDと小さなファイルの名前でHBaseキャッシュモジュールを照会し、対応するファイルコンテンツが出たら、照会されたファイルコンテンツに戻り、対応するファイルコンテンツが出ないと、HDFSシステムのデータベースを照会し、成功したら、照会されたファイルコンテンツに戻り、失敗したら、HadooparchiveツールのAPIを呼び出し、対応するHARファイルにアクセスしてHARファイルに戻る。現有技術と比べて、小さなファイルの間のアソシエーションとホットスポットファイルを問わず、本発明の読み込みメソッドは小さなファイルとHBaseキャッシングメカニズムがマージされた後で、小さなファイルの読み込み効率を上げられる。 As can be seen from the above, in the method for reading a large number of small files based on Hadoop provided by the embodiment of the present invention, the read method is applied to an HDFS system including a data merge module and an HBase cache module. The read method receives a small file read command input by the user, and the small file read command includes a user ID and a small file name, and the HBase cache module includes the user ID and the small file name. If the corresponding file content appears, return to the inquired file content. If the corresponding file content does not appear, query the HDFS system database. If successful, return to the inquired file content. , Calls the API of the Hadooparkive tool, accesses the corresponding HAR file, and returns to the HAR file. Compared to current technology, regardless of the association between small files and hotspot files, the reading method of the present invention can increase the efficiency of reading small files after the small file and HBase caching mechanism are merged.

更に、本発明はデータマージメソッドを提供し、小さなファイルの読み込み効率を高め、HDFSシステムでのnamenodeメモリの消費を削減する。 Furthermore, the present invention provides a data merge method, which increases the efficiency of reading small files and reduces the consumption of namode memory in the HDFS system.

更に、本発明のデータマージメソッドには、複数の関連付けられた小さなファイルが一つの大きなファイルにマージされてシステムにストレージされ、システムのnamenodeノードが一つの大きなファイルの対応するメタデータをストレージし、namenodeノードの維持する必要のあるメタデータの量が大幅に減少し、メモリ消費量も減少になる。 Furthermore, in the data merge method of the present invention, a plurality of associated small files are merged into one large file and stored in the system, and the system's namenode node stores the corresponding metadata of one large file, The amount of metadata that the namenode node needs to maintain is greatly reduced and memory consumption is also reduced.

更に、本発明のデータマージメソッドには、関連ファイルが同じの一つの大きなファイルにストレージされ、ファイルがマージされた後で同じデータノードの同じデータブロックの中にストレージされる。ファイルへのユーザのリクエストに強い関連性があれば、すなわち、ユーザに耐えずにアクセスされた小さなファイルが同じ大きなファイルにマージされば、ファイルアクセスの原則によると、システムはより近いdatanodeノードのデータブロックを読み込み、つまり絶えずに同じdatanodeのデータブロックからデータを読み込み、こうして異なるファイルにアクセス時に異なるデータノードの間にジャンプしなくで済み、ディスクアドレッシングのオーバーヘッドが削減され、占められるシステムリソースが比較的に少なくなり、ファイルの読み込み効率を大きく高める。 Furthermore, in the data merge method of the present invention, related files are stored in the same large file and are stored in the same data block of the same data node after the files are merged. If there is a strong relevance to the user's request for the file, i.e., a small file accessed without enduring the user is merged into the same large file, according to the principle of file access, the system will use the data of the closer datanode node. Read blocks, that is, constantly read data from the same datanode data block, thus avoiding jumping between different data nodes when accessing different files, reducing disk addressing overhead and occupying relatively less system resources The file reading efficiency is greatly increased.

更に、本発明が提供するキャッシュメソッドには、現有技術と比べてユーザにアクセスされたホットスポットファイルを考慮せず、本発明はHBaseによってホッとスポットファイルをキャッシュし、キャッシュヒット率を高めるだけでなく、ファイルの読み込み効率も上げる。 In addition, the cache method provided by the present invention does not consider hot spot files accessed by the user compared to the existing technology, and the present invention only caches spot files by HBase to increase the cache hit rate. In addition, it increases the efficiency of reading files.

当業者は、上記の実施形態を実施するプロセスの全部または一部を理解することができ、コンピュータプログラムによって関連するハードウェアを指示することで完了することができ、前記のプログラムがコンピュター可読記憶媒体にストレージされることができ、該プログラムが実行される時に、上記の各メソッドの実施例のプロセスが含まれる。その中に、前記の記憶媒体が磁気ディスク、光ディスク、読み出し専用メモリ(Read−Only Memory,ROM)またはランダムアクセスメモリ(Random Access Memory,RAM)であってもよい。 A person skilled in the art can understand all or part of the process of implementing the above embodiments, and can be completed by indicating the relevant hardware by means of a computer program, said program being a computer readable storage medium Each of the above method embodiment processes is included when the program is executed. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM).

以上に述べたのは本発明の優先された実施形態であり、注意すべきのは、本技術分野の一般的な技術員にとって、本発明の原理から離れないことを前提として、若干な改善や飾りができ、これらの改善や飾りも本発明の保護範囲に含まれる。 The above is a preferred embodiment of the present invention, and it should be noted that it should be noted that a general engineer in the technical field will make slight improvements and decorations on the assumption that the principle of the present invention is not departed. These improvements and decorations are also included in the protection scope of the present invention.

本発明はコンピュータテクノロジー分野に関し、具体的には、Hadoopに基づいて、データマージモジュールとHBaseキャッシュモジュールを備えるHDFSに複数の2MB以下の小さなファイルを書き込む方法に関する。 The present invention relates to the field of computer technology, and more particularly, to a method of writing a plurality of small files of 2 MB or less to HDFS having a data merge module and an HBase cache module based on Hadoop .

Hadoopは2005年にApache FoundationによってLuceneのサブプロジェクトであるNutchの一部分として正式に導入されたものである。Hadoopの最も重要な二つの設計はHDFSとMapReduceである。HDFSは大量なデータをストレージし、ファイルがデータブロックの形でシステムにストレージされる。また、HDFSのデータブロックは通常のディスクに定義されたデータブロック(通常は512B)よりも遥かに大きく、HDFSの現在のデフォルトブロックサイズは128MBである。もしHDFSにストレージされたファイルのサイズが128に超えると、HDFSは該ファイルを複数のブロックサイズのブロックに分割し、別々にストレージする。また、HDFSが絶えずに小さなファイルをTBひいてはPBレベルまでストレージし続けると、小さなファイルの問題が発生し、此れは、大量のメタデータがHDFSのプライマリノードのnamenodeにストレージされるため、namenodeの負荷が大幅に増加し、システムの読み取りパフォーマンスに影響するためである。その中に、小さなファイルのサイズが2MBに定義され、つまり、HDFSがファイルをストレージする中で、ファイルのサイズが2Mまたは2M以下であると、小さなファイルとして定義される。   Hadoop was officially introduced in 2005 by Apache Foundation as part of Lucene, a subproject of Lucene. The two most important Hadoop designs are HDFS and MapReduce. HDFS stores a large amount of data, and files are stored in the system in the form of data blocks. Also, the HDFS data block is much larger than the data block defined for a normal disk (usually 512B), and the current default block size of HDFS is 128 MB. If the size of a file stored in HDFS exceeds 128, HDFS divides the file into blocks having a plurality of block sizes and stores them separately. Also, if HDFS keeps storing small files continuously to TB and eventually to PB level, there will be a problem of small files, because a large amount of metadata is stored in the namenode of the primary node of HDFS. This is because the load increases significantly and affects the read performance of the system. Among them, the size of a small file is defined as 2 MB, that is, when the file size is 2M or 2M or less while HDFS is storing the file, it is defined as a small file.

大量な小さなファイルの処理について、現有の技術においては、若干の小さなファイルを一つのブロックサイズの大きなファイルにマージすることであり、ファイル間の関連性を考慮せず、小さなファイルの読み込み効率が望ましくなくなる。 Regarding the processing of a large number of small files, the current technology is to merge a few small files into one large block size file, and the efficiency of reading small files is desirable without considering the relationship between files. Disappear.

中国特許出願公開第103605479号明細書Chinese Patent Application No. 10365479

本発明の実施例が提供するHadoopに基づいて、データマージモジュールとHBaseキャッシュモジュールを備えるHDFSに複数の2MB以下の小さなファイルを書き込む方法は、小さなファイルのマージ及びHBaseキャッシングメカニズムと合わせた後で、書き込まれた小さなファイルの読み取りをもっと容易くし、小さなファイルの読み取り効率を向上させることができる。 Based on Hadoop provided by an embodiment of the present invention, a method of writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module is combined with a small file merge and HBase caching mechanism. This makes it easier to read small written files and improves the reading efficiency of small files.

本発明の実施例が提供するHadoopに基づいて、データマージモジュールとHBaseキャッシュモジュールを備えるHDFSに複数の2MB以下の小さなファイルを書き込む方法については、前記書き込みメソッドがデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、前記書き込みメソッドが: According to the Hadoop provided by the embodiment of the present invention, for a method of writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module, the write method includes the data merge module and the HBase cache module. Applied to HDFS system, the write method is:

ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、前記書き込みコマンド中にユーザIDと小さなファイルの名前を含み、 Receiving a small file write command input by the user, including a user ID and a small file name in the write command ;

ユーザIDと前記小さなファイルの名前によって前記HBaseキャッシュモジュールを照会し、 Query the HBase cache module by user ID and the name of the small file;

対応するファイル内容が出たら、前記HBaseキャッシュモジュールによって照会された第一のファイルコンテンツに前記小さなファイルを書き込み、小さなファイルの書き込まれた第一のファイルコンテンツを前記HBaseキャッシュモジュールにアップロードして更新し、対応するファイル内容が出ないと、前記小さなファイルのファイル名によって前記HDFSシステムのデータベースを照会し、対応するファイルコンテツが照会されたかどうかを判断し、 If you get the corresponding file contents, the HBase said to first file content is queried by the cache module writes a small file, and uploading the first file contents that have been written a small file to the HBase cache module Update and if the corresponding file content does not appear, query the HDFS system database by the file name of the small file to determine whether the corresponding file content has been queried;

イエスであれば、前記データベースに照会された第二のファイルコンテンツに前記小さなファイルを書き込み、前記小さなファイルの書き込まれた第二のファイルコンテンツを前記データベースにアップロードして更新し、 If yes, write the small file to the second file content queried in the database, upload the updated second file content of the small file to the database and update,

そうでなければ、HadooparchiveツールのAPIを呼び出して前記小さなファイルのファイル名と対応するHARファイルにアクセスし、前記小さなファイルを書き込み、前記小さなファイルの書き込まれたHARファイルを前記データベースにアップロードして更新する。 Otherwise, call the Hadooprchive tool API to access the HAR file corresponding to the file name of the small file, write the small file, and upload and update the HAR file with the small file written to the database To do.

更に、前記データマージモジュールが採用するデータマージメソッドは: Furthermore, the data merge method employed by the data merge module is:

ステップA:クライアントがストレージされるファイルをアップロードした後で、HDFSのすべてのファイルをトラバースし、ユーザアクセスプリファレンスモデルを用いて、前記ストレージされるファイルの関連ファイルコレクションを見つけ、ここで、前記ユーザアクセスプリファレンスモデルはユーザアクセスログレコードに基づいている、 Step A: After the client uploads the stored file, traverse all the files in HDFS and use the user access preference model to find the relevant file collection of the stored file , where the user The access preference model is based on user access log records,

ステップB:前記関連ファイルコレクションのミドルファイルと前記ストレージされるファイルを順にマージするキューに追加する。 Step B: Add the middle file of the related file collection and the stored file to the queue to be merged in order.

ステップC:前記マージするキューのすべてのファイルの総サイズが128 MBを超えるかどうかを判断し、イエスであれば、ステップDに進み、そうでなければ、ステップEに進み、 Step C: Determine whether the total size of all files in the queue to be merged exceeds 128 MB. If yes, go to Step D, otherwise go to Step E.

ステップD:前記マージするキューのすべてのファイルを一つのデータブロックにマージし、前記マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップBに戻り、 Step D: Merge all the files of the queue to be merged into one data block, clear the file information of the queue to be merged, delete the source file of the merged file, return to Step B,

ステップE:前記関連ファイルコレクションのミドルファイルと前記ストレージされるファイルが全部前記マージするキューに追加されたかどうかを判断し、イエスであれば、前記マージするキューのすべてのファイルを一つのデータブロックにマージし、前記マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップFに進み、そうでなければ、ステップBに進む。 Step E: It is determined whether all the middle files of the related file collection and the stored files are added to the merge queue. If yes, all the files of the merge queue are combined into one data block. Merge, clear the file information of the queue to be merged, delete the source file of the merged file, proceed to step F, otherwise proceed to step B.

ステップF:すべてのマージしたデータブロックをHDFSシステムにストレージする。 Step F: Store all merged data blocks in the HDFS system.

更に、その特徴は、前記プリファレンスモデルがユーザアクセスログレコードから統計されたもので、具体的には: In addition, the feature is that the preference model is statistics from user access log records, specifically:

前記ユーザアクセスログレコードからアクティブユーザセットを統計し、 Statistics active user sets from the user access log records;

前記アクティブユーザセットにアクセスされた小さなファイルをBeanオブジェクトで表し、前記小さなファイルがサイズが2MB又は2MB以下のファイルに指し、その中に、前記オブジェクトのプロパティが該小さなファイルにアクセスユーザID、ユーザにアクセスされた小さなファイル名及び該小さなファイルがアクセスされた回数を含み、 A small file accessed by the active user set is represented by a Bean object, and the small file points to a file having a size of 2 MB or less, and the property of the object includes an access user ID and a user Including the name of the accessed small file and the number of times the small file has been accessed,

JDBCテクノロジを用いて、前記beanオブジェクトをMysqlデーターベースに永続化してストレージし、ストレージされたデータによって、任意の二つの異なるアクセス動作の類似性をアカウントし、 Using the JDBC technology, the bean object is stored persistently in a MySQL database, and the stored data accounts for the similarity of any two different access operations,

任意の二つの異なるアクセス動作の類似性が正の場合、前記任意の二つのアクセス動作のユーザが類似ユーザであり、類似ユーザのIDを記録して関連ファイルセットによって類似ユーザにアクセスされ、関連付けられたファイルの情報をストレージし、 If the similarity between any two different access operations is positive, the user of any two access operations is a similar user, and the similar user ID is recorded and accessed by the related file set to be associated with the similar user. Store the file information,

前記関連ファイルセットによって、前記ユーザアクセスプリファレンスモデルを構築する。 The user access preference model is constructed by the related file set.

更に、その特徴は、前記HBaseキャッシュモジュールが採用するキャッシュメソッドは: Further, the cache method employed by the HBase cache module is:

ユーザアクセスログレコードを取得し、前記ユーザアクセスログレコードからアクティブユーザセットを統計し、 Obtaining a user access log record, statistics an active user set from the user access log record,

対数線形モデルを用いて、前記アクティブユーザセットの各アクテイブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順でソートし、ファイルの上位20%をホットスポットファイルとしてマークし、 The logarithmic linear model is used to account for the popularity prediction value of the file accessed by each active user of the active user set, and each file is sorted in descending order according to the popularity prediction value, and the top 20% of the files are used as hot spot files. Mark

前記ホットスポットファイルを取得し、Hbaseデータベースを使って前記ホットスポットファイルの関連情報をキャッシュする。 The hot spot file is acquired, and related information of the hot spot file is cached using an Hbase database.

更に、前記前記ユーザアクセスログレコードからアクティブユーザセットを統計するについて、具体的には: Further on statistics of active user sets from the user access log record, specifically:

アクセスされたソースの接尾辞がjpgであるレコード行を前記ユーザアクセスログレコードからフィルタリングし、その中に、前記レコード行がユーザID、アクセスページURL、アクセス開始時刻、アクセス状況、アクセストラフィックを含み、 Filtering record rows from the user access log record with the accessed source suffix jpg, wherein the record row includes a user ID, access page URL, access start time, access status, access traffic;

レコード解析クラスを作成して前記レコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、 Create a record parsing class to parse the record row, use a 2D array to store the visitor IP and the name of the small file,

ビジターIPを前記二次元配列でトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、前記HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、 Traversing the visitor IP with the two-dimensional array, using the HashMap collection to statistic the traffic of each visitor IP, the Key value of the HashMap collection is the visitor IP, the Value value is the traffic,

前記HashMapコレクションをValue値の降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージし、アクティブユーザセットとしてマークし、 Sort the HashMap collection in descending order of Value values, filter the top 20% of visitor IPs, use the ArrayList collection to store the IP subset, mark it as an active user set,

更に、対数線形モデルをあわせて、前記アクティブユーザセットの各アクティブユーザにアクサスされたファイルの人気予測値をアカウントして、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークし、具体的には: In addition, logarithmic linear models are combined to account for the popularity prediction value of the file accessed by each active user in the active user set, and each file is sorted in descending order by popularity prediction value, and the top 20% of the file is hot. Mark as a spot file, specifically:

ArrayListコレクションから抽出されたビジターIPを、前記二次元配列から抽出されたビジターIPと照合し、 Matching the visitor IP extracted from the ArrayList collection with the visitor IP extracted from the two-dimensional array;

一致が出たら、合致するビジターIPをキーワードとして、各ユーザのアクセス開始時刻を照会して、対数線形モデルを用いて、前記アクティブユーザセットの各アクティブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークし、 If a match is found, the access start time of each user is queried using the matching visitor IP as a keyword, and the popularity prediction value of the file accessed by each active user of the active user set is accounted using a logarithmic linear model. Sort each file in descending order by popularity prediction, mark the top 20% of files as hotspot files,

前記対数線形モデルは:

Figure 2019204473
であり、 The log-linear model is:
Figure 2019204473
And

その中に、

Figure 2019204473
がファイルiの人気予測値であり、
Figure 2019204473
がファイルiが観測期間中のトラフィックであり、観測期間の長さがtである。 Among them,
Figure 2019204473
Is the popularity prediction for file i,
Figure 2019204473
File i is the traffic during the observation period, and the length of the observation period is t.

本発明の実施例を実施すると、以下の有益効果が出る: Implementation of embodiments of the present invention has the following beneficial effects:

本発明の実施例が提供するHadoopに基づいて、データマージモジュールとHBaseキャッシュモジュールを備えるHDFSに複数の2MB以下の小さなファイルを書き込む方法については、該書き込みメソッドはデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、該読み込みメソッドは:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、前記書き込みコマンド中にユーザIDと小さなファイルの名前によってHBaseキャッシュモジュールを照会し、対応する最初のファイルコンテンツが照会されたら、最初のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた第一のファイルコンテンツをHBaseキャッシュモジュールにアップロードして更新し、対応する最初のファイルコンテンツが照会されなかったら、HDFSデータベースを照会し、成功すれば、照会された第二のファイルコンテンツに戻り、小さなファイルの書き込まれた第二のファイルコンテンツをデータベースにアップロードして更新し、失敗すれば、HadooparchiveツールのAPIを呼び出して対応するHARファイルにアクセスし、小さなファイルを書き込み、小さなファイルの書き込まれたHARファイルをデータベースにアップロードして更新する。小さなファイル間の関連性とホットスポットファイルを考慮しない既存技術と比べ、本発明の書き込みメソッドは小さなファイルのマージ及びHBaseキャッシングメカニズムと合わせた後で、書き込まれた小さなファイルの読み取りをもっと容易くし、小さなファイルの読み取り効率を向上させることができる。 According to the Hadoop provided by the embodiment of the present invention, for a method of writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module, the write method includes a data merge module and an HBase cache module. Applied to HDFS system, the read method receives a small file write command input by the user, queries the HBase cache module by the user ID and small file name during the write command, and the corresponding first file When the content is queried, return to the first file content, writing small files, HBase cache the first file contents that have been written a small file If uploaded to the module and updated and the corresponding first file content is not queried, the HDFS database is queried, and if successful, it returns to the queried second file content and the second file with the small file written Update the file contents by uploading to the database, and if it fails, call the API of the Hadooparkive tool to access the corresponding HAR file, write a small file, and upload the HAR file with the small file written to the database for update To do. Compared to existing technology that does not consider the relationship between small files and hotspot files, the writing method of the present invention makes it easier to read the written small files after combining with the small file merging and HBase caching mechanism, The reading efficiency of small files can be improved.

本発明の実施例を実施すると、以下の有益効果が出る: Implementation of embodiments of the present invention has the following beneficial effects:

本発明の実施例が提供するHadoopに基づいて、データマージモジュールとHBaseキャッシュモジュールを備えるHDFSに複数の2MB以下の小さなファイルを書き込む方法については、該書き込みメソッドはデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、該読み込みメソッドは:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、前記書き込みコマンド中にユーザIDと小さなファイルの名前によってHBaseキャッシュモジュールを照会し、対応する最初のファイルコンテンツが照会されたら、最初のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた第一のファイルコンテンツをHBaseキャッシュモジュールにアップロードして更新し、対応する最初のファイルコンテンツが照会されなかったら、HDFSデータベースを照会し、成功すれば、照会された第二のファイルコンテンツに戻り、小さなファイルの書き込まれた第二のファイルコンテンツをデータベースにアップロードして更新し、失敗すれば、HadooparchiveツールのAPIを呼び出して対応するHARファイルにアクセスし、小さなファイルを書き込み、小さなファイルの書き込まれたHARファイルをデータベースにアップロードして更新する。小さなファイル間の関連性とホットスポットファイルを考慮しない既存技術と比べ、本発明の書き込みメソッドは小さなファイルのマージ及びHBaseキャッシングメカニズムと合わせた後で、書き込まれた小さなファイルの読み取りをもっと容易くし、小さなファイルの読み取り効率を向上させることができる。 According to the Hadoop provided by the embodiment of the present invention, for a method of writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module, the write method includes a data merge module and an HBase cache module. Applied to HDFS system, the read method receives a small file write command input by the user, queries the HBase cache module by the user ID and small file name during the write command, and the corresponding first file When the content is queried, return to the first file content, writing small files, HBase cache the first file contents that have been written a small file If uploaded to the module and updated and the corresponding first file content is not queried, the HDFS database is queried, and if successful, it returns to the queried second file content and the second file with the small file written Update the file contents by uploading to the database, and if it fails, call the API of the Hadooparkive tool to access the corresponding HAR file, write a small file, and upload the HAR file with the small file written to the database for update To do. Compared to existing technology that does not consider the relationship between small files and hotspot files, the writing method of the present invention makes it easier to read the written small files after combining with the small file merging and HBase caching mechanism, The reading efficiency of small files can be improved.

図1は本発明の提供するHadoopに基づく大量の小さなファイルの書き 込みメソッドの実施例のプロセス見取り図である。FIG. 1 is a process sketch of an embodiment of a method for writing a large number of small files based on Hadoop provided by the present invention. 図2は本発明の提供するデータマージメソッドの実施例のプロセス見取り図である。FIG. 2 is a process sketch of an embodiment of the data merge method provided by the present invention. 図3は本発明の提供するキャッシュメソッドの実施例のプロセス見取り図である。FIG. 3 is a process sketch of an embodiment of the cache method provided by the present invention. 図4は本発明の提供するキャッシュメソッドのもう一つの実施例のプロセス見取り図である。FIG. 4 is a process sketch of another embodiment of the cache method provided by the present invention.

下記に本発明の実施例の中の附図を交え、本発明の実施例の技術方案を明確にはっきり説明し、説明した実施例がただ本発明の一部分の実施例で、全部の実施例ではないである。本発明の実施例に基づいて、本領域の普通技術者が創造的な労働を払わないことを前提に得る全部のその他の実施例は本発明の保護範囲に所属する The accompanying drawings in the embodiments of the present invention are described below, the technical solutions of the embodiments of the present invention are clearly explained, and the described embodiments are only a part of the embodiments of the present invention and not all the embodiments. It is. Based on the embodiments of the present invention, all other embodiments obtained on the assumption that ordinary engineers in this area do not pay creative labor belong to the protection scope of the present invention.

図1を参照し、本発明の提供するHadoopに基づいて、データマージモジュールとHBaseキャッシュモジュールを備えるHDFSに複数の2MB以下の小さなファイルを書き込む方法の実施例のプロセス見取り図であり、該メソッドがステップ101からステップ106までを含む。該書き込みメソッドはデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、各ステップは以下を含む: Referring to FIG. 1 , based on the Hadoop provided by the present invention, there is a process sketch of an embodiment of a method for writing a plurality of small files of 2 MB or less to an HDFS having a data merge module and an HBase cache module. 101 to step 106 are included. The write method is applied to an HDFS system comprising a data merge module and an HBase cache module, and each step includes:

ステップ101:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、前記書き込みコマンド中にユーザIDと小さなファイルの名前を含む。 Step 101: A small file write command input by a user is received , and a user ID and a small file name are included in the write command .

ステップ102:ユーザIDと前記小さなファイルの名前によって前記HBaseキャッシュモジュールを照会し、対応するファイルコンテンツが照会されたかどうかを判断し、イエスであれば、ステップ105に進み、そうでなければ、ステップ103に進む。 Step 102: Query the HBase cache module by user ID and the name of the small file to determine whether the corresponding file content has been queried, if yes, go to step 105, otherwise, step 103 Proceed to

ステップ103:小さなファイルの名前により前記HDFSシステムのデータベースを照会し、対応する第二のファイルコンテンツが照会されたかどうかを判断し、イエスであれば、ステップ106に進み、そうでなければ、ステップ104に進む。 Step 103: Query the HDFS system database by the name of the small file to determine whether the corresponding second file content has been queried; if yes, go to step 106; Proceed to

ステップ104:HadooparchiveツールのAPIを呼び出して小さなファイルのファイル名と対応するHARファイルにアクセスし、小さなファイルの書き込まれたHARファイルをデータベースにアップロードして更新する。 Step 104: Call an API of the Hadooparkive tool to access the HAR file corresponding to the file name of the small file, and upload and update the HAR file in which the small file is written to the database.

ステップ105:最初のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた第一のファイルコンテンツをHBaseキャッシュモジュールにアップロードして更新する。 Step 105: Return to the first file content, write a small file, and upload and update the first file content written with the small file to the HBase cache module.

ステップ106:データベースに照会された第二のファイルコンテンツに戻り、小さなファイルを書き込み、小さなファイルの書き込まれた第二のファイルコンテンツをデータベースにアップロードして更新する。 Step 106: Return to the second file content queried in the database, write a small file, and upload and update the second file content in which the small file is written to the database.

図2を参照し、図2は本発明の提供するデータマージメソッドの実施例のプロセス見取り図であり、本発明のデータマージモジュールには図2の示すデータマージメソッドが採用され、ステップAからステップFまでを含み、各ステップは以下のように: Referring to FIG. 2, FIG. 2 is a process sketch of an embodiment of the data merge method provided by the present invention. The data merge method of the present invention employs the data merge method shown in FIG. Each step is as follows:

ステップA:クライアントがストレージされるファイルをアップロードした後で、HDFSのすべてのファイルをトラバースし、ユーザアクセスプリファレンスモデルを用いて、前記ストレージされるファイルの関連ファイルコレクションを見つけ、ここで、前記ユーザアクセスプリファレンスモデルはユーザアクセスログレコードに基づいている、 Step A: After the client uploads the stored file, traverse all the files in HDFS and use the user access preference model to find the relevant file collection of the stored file , where the user The access preference model is based on user access log records,

本実施例において、ユーザアクセスプリファレンスモデルがユーザアクセスログレコードから統計されたもので、具体的には:ユーザアクセスログレコードからアクティブユーザセットを統計し、アクティブユーザセットにアクセスされた小さなファイルをbeanオブジェクトで表し、小さなファイルがサイズが2MB又は2MB以下のファイルであり、その中に、beanオブジェクトのプロパティが該小さなファイルにアクセスしたユーザID、ユーザにアクセスされた小さなファイルの名前及び該小さなファイルがアクセスされた回数を含み、JDBCテクノロジを用いて、beanオブジェクトをMysqlデータベースに永続化してストレージし、ストレージされたデータによって、任意の二つの異なるアクセス動作の類似性をアカウントし、任意の二つの異なるアクセス動作の類似性が正であれば、任意の二つのアクセス動作のユーザが類似ユーザであり、類似ユーザのIDを記録して関連ファイルセットを使ってすべての類似ユーザにアクセスされ、関連付けられたファイル情報をストレージし、関連ファイルセットによって、ユーザアクセスプリファレンスモデルを構築する。 In this embodiment, the user access preference model is statistically calculated from the user access log record. Specifically: the active user set is statistically calculated from the user access log record, and the small file accessed by the active user set is bean. A small file is a file whose size is 2 MB or 2 MB or less, and in which the bean object property is the user ID that accessed the small file, the name of the small file accessed by the user, and the small file Including the number of times it was accessed, and using JDBC technology to store the bean object persistently in the MySQL database, depending on the stored data, the similarity of any two different access operations If you account and the similarity of any two different access actions is positive, the user of any two access actions is a similar user, record the similar user's ID and use the related file set to find all similarities The user accesses and stores the associated file information, and builds the user access preference model with the related file set.

本実施例において、ユーザアクセスログレコードからアクティブユーザセットを統計し、具体的には:アクセスされたソースの接尾辞がjpgであるレコード行をユーザアクセスログレコードからフィルタリングし、その中に、レコード行がユーザID、アクセスページURL、アクセス開始時刻、アクセス状況、アクセストラフィックを含み、レコード解析クラスを作成して前記レコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、ビジターIPを二次元配列でトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、HashMapコレクションをValue値の降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージし、アクティブユーザセットとしてマークする。 In this example, the active user set is statistics from the user access log record, specifically: record rows with the suffix of the accessed source are jpg from the user access log record, in which the record row Contains user ID, access page URL, access start time, access status, access traffic, creates record analysis class to analyze the record row, and stores visitor IP and small file name using 2D array Traverse the visitor IP in a two-dimensional array, use the HashMap collection to statistic the traffic for each visitor IP, the key value for the HashMap collection is visitor IP, the value is traffic, and the HashMap collection Sort by descending alue value, filters the 20% upper visitor IP, the IP subnet to storage using ArrayList collection, marked as active user set.

本発明のモデルの構築過程をもっとよく説明するために、下記の例えにより説明し、具体的な実現する過程が以下のように: In order to better explain the process of building the model of the present invention, it is explained by the following illustration, and the specific realization process is as follows:

(1)正規表現を使用してアクセスされたソースの接尾辞がjpgであるレコード行をフィルタリングする。 (1) Filter record rows whose source suffix is jpg accessed using regular expressions.

(2)ログ解析クラスを作成してレコード行の五つのコンポーネントを別々に解析し、二次元配列を使ってビジターIPと小さなファイルの名前をストレージする。 (2) Create a log analysis class to analyze the five components of the record row separately, and store the visitor IP and the name of the small file using a two-dimensional array.

(3)二次元配列のビジターIP要素をトラバースし、各ビジターIPのトラフィックをカウンタするカウンタを設計する。HashMapコレクションを使って、ビジターIPをKey値とし、Value値が該ビジターのトラフィックである。 (3) A counter that traverses the two-dimensional array of visitor IP elements and counts the traffic of each visitor IP is designed. Using the HashMap collection, the visitor IP is a key value, and the value value is the traffic of the visitor.

(4)ステップ3で生成されたHashMapコレクションをValue値にしたがって降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションで該IPサブセットをストレージし、アクティブユーザセットとしてマークする。 (4) Sort the HashMap collection generated in step 3 in descending order according to Value values, filter the top 20% of visitor IPs, store the IP subset in the ArrayList collection, and mark it as the active user set.

(5)一つのbeanオブジェクトによってアクティブユーザセットにアクセスされた小さなファイルを抽象に表し、オブジェクトのプロパティが該小さなファイルをアクセスしたユーザID、ユーザにアクセスされた小さなファイルの名前及び該小さなファイルがアクセスされた回数を含む。メソッドはプロパティを取得するget及びsetメソッドである。 (5) An abstract representation of a small file accessed to the active user set by one bean object, where the object properties are the user ID that accessed the small file, the name of the small file accessed by the user, and the small file accessed Including the number of times The methods are get and set methods for acquiring properties.

(6)JDBCテクノロジbeanオブジェクトをMysqlデータベースに結合して永続にストレージし、以下の形式のテーブルが形成される: (6) Join the JDBC object bean object to the MySQL database and store it persistently to form a table of the form:

Figure 2019204473
Figure 2019204473

(7)20行の二行の間にデータを取り込み、数式

Figure 2019204473
によって二つの異なるユーザアクセス作動の類似性をカウンタする。その中に、本発明はピアソン相関係数を使用して類似のユーザを決定し、スコアリング行列Rを指定し、ユーザaとユーザbの類似性をsim(a,b)で表し、ra及びrbが「ユーザ−トラフィック」ストアリングマトリックスのストアリングデータである。 (7) Take data between two lines of 20 lines, formula
Figure 2019204473
Counters the similarity of two different user access actions. Among them, the present invention uses the Pearson correlation coefficient to determine similar users, specifies a scoring matrix R, expresses the similarity between user a and user b as sim (a, b), and ra and rb is the storing data of the “user-traffic” storing matrix.

(8)ここで、sim(a,b)の値が正の値であれば、二人の異なるユーザが類似ユーザであると判定され、そのユーザIDが記録される。 (8) Here, if the value of sim (a, b) is a positive value, it is determined that two different users are similar users, and the user IDs are recorded.

(9)類似ユーザのユーザIDに基づいて、一つのコレクションを使用して、類似ユーザにアクセスされ、関連付けられているすべてのファイル情報をストレージする。 (9) Based on the user ID of the similar user, all file information accessed and related by the similar user is stored using one collection.

ステップB:関連ファイルコレクションのミドルファイルとストレージされるファイルを順にマージするキューに追加する。 Step B: Add the middle file of the related file collection and the stored file to the queue to be merged in order.

ステップC:マージするキューのすべてのファイルの総サイズが128 MBを超えるかどうかを判断し、イエスであれば、ステップDに進み、そうでなければ、ステップEに進む。 Step C: Determine whether the total size of all files in the queue to be merged exceeds 128 MB. If yes, go to step D, otherwise go to step E.

ステップD:マージするキューのすべてのファイルを一つのデータブロックにマージし、マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップBに戻る。 Step D: Merge all files in the queue to be merged into one data block, clear file information in the queue to be merged, delete the source file of the merged file, and return to Step B.

ステップE:関連ファイルコレクションのミドルファイルとストレージされるファイルが全部マージするキューに追加されたかどうかを判断し、イエスであれば、マージするキューのすべてのファイルを一つのデータブロックにマージし、マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップFに進み、そうでなければ、ステップBに進む。 Step E: Determine whether all of the middle files in the related file collection and the stored files have been added to the merge queue, and if yes, merge all the files in the merge queue into one data block and merge The file information of the queue to be cleared is cleared, the source file of the merged file is deleted, and the process proceeds to Step F. Otherwise, the process proceeds to Step B.

ステップF:すべてのマージしたデータブロックをHDFSシステムにストレージする。 Step F: Store all merged data blocks in the HDFS system.

図3を参照し、図3は本発明が提供するキャッシュメソッドの実施例のプロセス見取り図である。本発明のHBaseキャッシュモデルが図3のキャッシュメソッドを採用し、該メソッドはステップ301からステップ303までを含み、各ステップが以下のように: Reference is made to FIG. 3, which is a process sketch of an embodiment of the cache method provided by the present invention. The HBase cache model of the present invention employs the cache method of FIG. 3, which includes steps 301 through 303, with each step as follows:

ステップ301:ユーザアクセスログレコードを取得し、ユーザアクセスログレコードからアクティブユーザセットを統計する。 Step 301: Obtain a user access log record and statistic an active user set from the user access log record.

本実施例の中に、ステップ301においてユーザアクセスログレコードからアクティブユーザセットを統計し、具体的には:アクセスされたソースの接尾辞がjpgであるレコード行をユーザアクセスログレコードからフィルタリングし、その中に、レコード行がユーザIP、アクセスページURL、アクセス開始時刻、アクセス状況及びアクセストラフィックを含み、ログ解析クラスを作成してレコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、二次元配列のビジターIPをトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、HashMapコレクションをValue値によって降順にソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージしてアクティブユーザセットとしてマークする。 In this embodiment, in step 301, the active user set is statistically analyzed from the user access log record, and specifically: the record line whose accessed source suffix is jpg is filtered from the user access log record; Inside, record line contains user IP, access page URL, access start time, access status and access traffic, create log analysis class to analyze record line, visitor IP and small file using 2D array , Traverse the visitor IP in a two-dimensional array, use the HashMap collection to stat the traffic for each visitor IP, the Key value in the HashMap collection is the visitor IP, the Value value is the traffic, and the HashMap Sorted in descending order collection by Value value, filters the 20% upper visitor IP, marked as active user set and storage the IP subset using ArrayList collection.

本発明のステップ301においてアクティブユーザセットをカウントする目的は、小さなファイルへのユーザのアクセスが均一なランダムではなくパレート分布法則に近いのである。すなわち、ほとんどのI/Oが少量の人気データへのアクセスをリクエストし、トラフィックの80%がデータの20%に集中している。したがって、ファイルシステムにストレージされた大量の小さなファイルからモデルを介してホットスポットファイルを予測してキャッシュすることができれば、ユーザのデータへのアクセスの効率を上げられる。 The purpose of counting the active user set in step 301 of the present invention is that the user's access to small files is close to Pareto distribution law rather than uniform random. That is, most I / Os request access to a small amount of popular data, with 80% of the traffic concentrated on 20% of the data. Therefore, if a hot spot file can be predicted and cached from a large number of small files stored in the file system through a model, the efficiency of access to user data can be increased.

ステップ302:対数線形モデルをあわせて、アクティブユーザセットの各アクティブユーザにアクサスされたファイルの人気予測値をアカウントして、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークする。 Step 302: Combine log-linear models to account for the popularity predictions of the file accessed for each active user in the active user set, sort each file in descending order by popularity prediction, and hot the top 20% of the files Mark as a spot file.

本実施例において、ステップ302は具体的には:ArrayListコレクションから抽出されたビジターIPを、二次元配列から抽出されたビジターIPと照合し、一致が出たら、合致するビジターIPをキーワードとして、各ユーザのアクセス開始時刻を照会して、対数線形モデルを用いて、アクティブユーザセットの各アクティブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークする。 In this embodiment, the step 302 is specifically: matching the visitor IP extracted from the ArrayList collection with the visitor IP extracted from the two-dimensional array, and if a match is found, each matching visitor IP is used as a keyword. Queries the user's access start time, uses a log-linear model to account for the popularity predictions of the files accessed by each active user in the active user set, sorts each file in descending order by popularity prediction value, and Mark the top 20% of as hotspot files.

対数線形モデルは:

Figure 2019204473
であり、 The log-linear model is:
Figure 2019204473
And

その中に、

Figure 2019204473
がファイルiの人気予測値であり、
Figure 2019204473
がファイルiが観測期間中のトラフィックであり、観測期間の長さがtである。
Figure 2019204473

Figure 2019204473
が線形関係の関連パラメータであり、線形回帰法によって最適値をアカウントすることが
できる。 Among them,
Figure 2019204473
Is the popularity prediction for file i,
Figure 2019204473
File i is the traffic during the observation period, and the length of the observation period is t.
Figure 2019204473
When
Figure 2019204473
Are related parameters of the linear relationship, and the optimal value can be accounted for by linear regression.

本発明の対数線形モデルにおいて記載された観測期間の長さtの定義は:ユーザアクセスログレコードのレコード行のアクセス開始時刻要素とユーザアクセスログレコードを収集した時刻との時間差である。例えば、収集されたユーザアクセスログレコードの時点が30/Jan/2018:17:38:20で、ユーザアクセスログレコードのレコード行のアクセス開始時刻が29/Jan/2018:10:35:15で、観測期間の長さが29/Jan/2018:10:35:15から30/Jan/2018:17:38:20までの時間差であり、アカウントしやすいために、期間の長さが時間単位にする。 The definition of the observation period length t described in the logarithmic linear model of the present invention is: the time difference between the access start time element of the record row of the user access log record and the time when the user access log record is collected. For example, the collected user access log record time point is 30 / Jan / 2018: 17: 38: 20, and the access start time of the record line of the user access log record is 29 / Jan / 2018: 10: 35: 15, The length of the observation period is the time difference from 29 / Jan / 2018: 10: 35: 15 to 30 / Jan / 2018: 17: 38: 20, and the length of the period is in units of time because it is easy to account .

ステップ303:ホットスポットファイルを取得し、Hbaseデータベースを採用してホットスポットファイルの関連情報をキャッシュする。 Step 303: Acquire a hot spot file and cache the related information of the hot spot file by adopting the Hbase database.

本実施例においては、Hbaseデータベースを採用してホットスポットファイルの関連情報をキャッシュし、HBaseのテーブル名値がビジターIDであり、HBaseのRowKeyが小さなファイルの名前であり、HBaseのファミリ名が「ファイルコンテンツ」であり、Value値すなわちセル値が小さなファイルのコンテンツである。ユーザがHBaseの小さなファイルにアクセス時に、ユーザIDをテーブル名とし、アクセスする小さなファイルの名前をHBaseのget()メソッドのパラメータとすれば、対応する小さなファイルのコンテンツを取得できる。 In this embodiment, the Hbase database is used to cache the related information of the hot spot file, the table name value of the HBase is the visitor ID, the RowKey of the HBase is the name of the small file, and the family name of the HBase is “ “File content”, which is the content of a file having a small Value value, ie, cell value. When a user accesses a small HBase file, the contents of the corresponding small file can be acquired if the user ID is a table name and the name of the small file to be accessed is a parameter of the HBase get () method.

本発明のキャッシュメソッドをもっと詳しく説明するため、図4を参照し、図4は本発明の提供するキャッシュメソッドのもう一つの実施例のプロセス見取り図である。図4が示すように、該プロセスが:ユーザアクセスレコードセット→正規表現が需要するレコード行をフィルタリングする→レコード行を解析する→beanオブジェクトでレコード行情報をカプセル化する→JDBC APIを調査研究してbeanオブジェクトをMysqlデータベースに永続化する→二次元配列によってビジターIPと小さなファイルの名前情報をストレージする→配列をトラバースし、ビジタートラフィックを統計する→ビジタートラフィックによってサーとし、ArrayListコレクションを使ってアクティブユーザセットのユーザIPをストレージする→二次元配列をアクティブユーザセットのビジターIPと照合する→一致が出たら、ビジターIPをキーワードとして、ユーザアクセス開始時刻とトラフィックを抽出する→ファイル人気予測数式によってファイル人気値をアカウントする→ファイル人気値をサートし、ホットスポットファイルをマークする→HBaseによってホットスポットファイルの関連情報をキャッシュする。 To describe the cache method of the present invention in more detail, please refer to FIG. 4, which is a process sketch of another embodiment of the cache method provided by the present invention. As FIG. 4 shows, the process is as follows: user access record set → filtering record rows required by regular expressions → analyzing record rows → encapsulating record row information with bean object → researching the JDBC API Persist bean object in Mysql database → Store visitor IP and small file name information by 2D array → Traverse array and statistics visitor traffic → Use visitor traffic as sir and active using ArrayList collection The user IP of the user set is stored → The two-dimensional array is checked with the visitor IP of the active user set. Tsu to extract the click → by file popular prediction formula to account the file popularity value → to insert the file popularity value, to cache the relevant information of the hot spot file by → HBase to mark the hot spot file.

上記からわかったことは、本発明の実施例の提供するHadoopに基づく大量の小さなファイルの読み込みメソッドにおいて、該読み込みメソッドがデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用される。該読み込みメソッドは、ユーサーによってインプットされる小さなファイルの読み込みコマンドを受信し、前記書き込みコマンド中にユーザIDと小さなファイルの名前を含み、ユーザIDと小さなファイルの名前でHBaseキャッシュモジュールを照会し、対応するファイルコンテンツが出たら、照会されたファイルコンテンツに戻り、対応するファイルコンテンツが出ないと、HDFSシステムのデータベースを照会し、成功したら、照会されたファイルコンテンツに戻り、失敗したら、HadooparchiveツールのAPIを呼び出し、対応するHARファイルにアクセスしてHARファイルに戻る。現有技術と比べて、小さなファイルの間のアソシエーションとホットスポットファイルを問わず、本発明の読み込みメソッドは小さなファイルとHBaseキャッシングメカニズムがマージされた後で、小さなファイルの読み込み効率を上げられる。 As can be seen from the above, in the method for reading a large number of small files based on Hadoop provided by the embodiment of the present invention, the read method is applied to an HDFS system including a data merge module and an HBase cache module. The read method receives a small file read command input by the user, includes a user ID and a small file name in the write command , queries the HBase cache module with the user ID and the small file name, and If the file content to be returned is found, the screen returns to the queried file content. If the corresponding file content is not found, the HDFS system database is queried. If the file content is successful, the query returns to the queried file content. To access the corresponding HAR file and return to the HAR file. Compared to existing technologies, regardless of the association between small files and hotspot files, the read method of the present invention can increase the efficiency of reading small files after the small file and HBase caching mechanism are merged.

更に、本発明はデータマージメソッドを提供し、小さなファイルの読み込み効率を高め、HDFSシステムでのnamenodeメモリの消費を削減する。 Furthermore, the present invention provides a data merge method, which increases the efficiency of reading small files and reduces the consumption of namode memory in the HDFS system.

更に、本発明のデータマージメソッドには、複数の関連付けられた小さなファイルが一つの大きなファイルにマージされてシステムにストレージされ、システムのnamenodeノードが一つの大きなファイルの対応するメタデータをストレージし、namenodeノードの維持する必要のあるメタデータの量が大幅に減少し、メモリ消費量も減少になる。 Furthermore, in the data merge method of the present invention, a plurality of associated small files are merged into one large file and stored in the system, and the system's namenode node stores the corresponding metadata of one large file, The amount of metadata that the namenode node needs to maintain is greatly reduced and memory consumption is also reduced.

更に、本発明のデータマージメソッドには、関連ファイルが同じの一つの大きなファイルにストレージされ、ファイルがマージされた後で同じデータノードの同じデータブロックの中にストレージされる。ファイルへのユーザのリクエストに強い関連性があれば、すなわち、ユーザに耐えずにアクセスされた小さなファイルが同じ大きなファイルにマージされば、ファイルアクセスの原則によると、システムはより近いdatanodeノードのデータブロックを読み込み、つまり絶えずに同じdatanodeのデータブロックからデータを読み込み、こうして異なるファイルにアクセス時に異なるデータノードの間にジャンプしなくで済み、ディスクアドレッシングのオーバーヘッドが削減され、占められるシステムリソースが比較的に少なくなり、ファイルの読み込み効率を大きく高める。 Furthermore, in the data merge method of the present invention, related files are stored in the same large file and are stored in the same data block of the same data node after the files are merged. If there is a strong relevance to the user's request for the file, i.e., a small file accessed without enduring the user is merged into the same large file, according to the principle of file access, the system will use the data of the closer datanode node. Read blocks, that is, constantly read data from the same datanode data block, thus avoiding jumping between different data nodes when accessing different files, reducing disk addressing overhead and occupying relatively less system resources The file reading efficiency is greatly increased.

更に、本発明が提供するキャッシュメソッドには、現有技術と比べてユーザにアクセスされたホットスポットファイルを考慮せず、本発明はHBaseによってホッとスポットファイルをキャッシュし、キャッシュヒット率を高めるだけでなく、ファイルの読み込み効率も上げる。 In addition, the cache method provided by the present invention does not consider hot spot files accessed by the user compared to the existing technology, and the present invention only caches spot files by HBase to increase the cache hit rate. In addition, it increases the efficiency of reading files.

当業者は、上記の実施形態を実施するプロセスの全部または一部を理解することができ、コンピュータプログラムによって関連するハードウェアを指示することで完了することができ、前記のプログラムがコンピュター可読記憶媒体にストレージされることができ、該プログラムが実行される時に、上記の各メソッドの実施例のプロセスが含まれる。その中に、前記の記憶媒体が磁気ディスク、光ディスク、読み出し専用メモリ(Read−Only Memory,ROM)またはランダムアクセスメモリ(Random Access Memory,RAM)であってもよい。 A person skilled in the art can understand all or part of the process of implementing the above embodiments, and can be completed by indicating the relevant hardware by means of a computer program, said program being a computer readable storage medium Each of the above method embodiment processes is included when the program is executed. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM).

以上に述べたのは本発明の優先された実施形態であり、注意すべきのは、本技術分野の一般的な技術員にとって、本発明の原理から離れないことを前提として、若干な改善や飾りができ、これらの改善や飾りも本発明の保護範囲に含まれる。 The above is a preferred embodiment of the present invention, and it should be noted that it should be noted that a general engineer in the technical field will make slight improvements and decorations on the assumption that the principle of the present invention is not departed. These improvements and decorations are also included in the protection scope of the present invention.

Claims (1)

Hadoopに基づく大量の小さなファイルの書き込みメソッドは、前記書き込みメソッドがデータマージモジュールとHBaseキャッシュモジュールを備えるHDFSシステムに適用され、前記書き込みメソッドが以下を含む:ユーサーによってインプットされる小さなファイルの書き込みコマンドを受信し、その中に、前記小さなファイルの書き込みコマンドがユーザIDと小さなファイルの名前を含み、ユーザIDと前記小さなファイルの名前によって前記HBaseキャッシュモジュールを照会し、対応するファイル内容が出たら、前記HBaseキャッシュモジュールによって照会された最初のファイルコンテンツに戻り、前記小さなファイルを書き込み、小さなファイルの書き込まれた最初のファイルコンテンツを前記HBaseキャッシュモジュールにアップロードして更新し、対応するファイル内容が出ないと、前記小さなファイルのファイル名によって前記HDFSシステムのデータベースを照会して対応するファイルコンテツが照会されたかどうかを判断し、イエスであれば、前記データベースに照会された第二のファイルコンテンツに戻り、前記小さなファイルを書き込み、前記小さなファイルの書き込まれた第二のファイルコンテンツを前記データベースにアップロードして更新し、そうでなければ、HadooparchiveツールのAPIを呼び出して前記小さなファイルのファイル名と対応するHARファイルにアクセスし、前記小さなファイルを書き込み、前記小さなファイルの書き込まれたHARファイルを前記データベースにアップロードして更新し、前記データマージモジュールが採用するデータマージメソッドは以下を含む:ステップA:クライアントがストレージされるファイルをアップロードした後で、HDFSのすべてのファイルをトラバースし、ユーザアクセスプリファレンスモデルを組み合わせて、前記ストレージされるファイルの関連ファイルコレクションを見つけ、その中に、前記ユーザアクセスプリファレンスモデルがユーザアクセスログレコードに基づき、ステップB:前記関連ファイルコレクションのミドルファイルと前記ストレージされるファイルを順にマージするキューに追加し、ステップC:前記マージするキューのすべてのファイルの総サイズが128 MBを超えるかどうかを判断し、イエスであれば、ステップDに進み、そうでなければ、ステップEに進み、ステップD:前記マージするキューのすべてのファイルを一つのデータブロックにマージし、前記マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップBに戻り、ステップE:前記関連ファイルコレクションのミドルファイルと前記ストレージされるファイルが全部前記マージするキューに追加されたかどうかを判断し、イエスであれば、前記マージするキューのすべてのファイルを一つのデータブロックにマージし、前記マージするキューのファイル情報をクリアし、マージしたファイルのソースファイルを削除して、ステップFに進み、そうでなければ、ステップBに進む。ステップF:すべてのマージしたデータブロックをHDFSシステムにストレージする。前記プリファレンスモデルがユーザアクセスログレコードから統計されたもので、具体的には:前記ユーザアクセスログレコードからアクティブユーザセットを統計し、前記アクティブユーザセットにアクセスされた小さなファイルをBeanオブジェクトで表し、前記小さなファイルがサイズが2MB又は2MB以下のファイルに指し、その中に、前記オブジェクトのプロパティが該小さなファイルにアクセスユーザID、ユーザにアクセスされた小さなファイル名及び該小さなファイルがアクセスされた回数を含み、JDBCテクノロジを合わせて、前記beanオブジェクトをMysqlデーターベースに永続化してストレージし、ストレージされたデータによって、任意の二つの異なるアクセス動作の類似性をアカウントし、任意の二つの異なるアクセス動作の類似性が正の場合、前記任意の二つのアクセス動作のユーザが類似ユーザであり、類似ユーザのIDを記録して関連ファイルセットによって類似ユーザにアクセスされ、関連付けられたファイルの情報をストレージし、前記関連ファイルセットによって、前記ユーザアクセスプリファレンスモデルを構築し、前記HBaseキャッシュモジュールが採用するキャッシュメソッドは:ユーザアクセスログレコードを取得し、前記ユーザアクセスログレコードからアクティブユーザセットを統計し、対数線形モデルを合わせ、前記アクティブユーザセットの各アクテイブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順でソートし、ファイルの上位20%をホットスポットファイルとしてマークし、前記ホットスポットファイルを取得し、Hbaseデータベースを使って前記ホットスポットファイルの関連情報をキャッシュする。前記前記ユーザアクセスログレコードからアクティブユーザセットを統計するについて、具体的には:アクセスされたソースの接尾辞がjpgであるレコード行を前記ユーザアクセスログレコードからフィルタリングし、その中に、前記レコード行がユーザID、アクセスページURL、アクセス開始時刻、アクセス状況、アクセストラフィックを含み、レコード解析クラスを作成して前記レコード行を解析し、二次元配列を使用してビジターIPと小さなファイルの名前をストレージし、ビジターIPを前記二次元配列でトラバースし、HashMapコレクションを使用して各ビジターIPのトラフィックを統計し、前記HashMapコレクションのKey値がビジターIPであり、Value値がトラフィックであり、前記HashMapコレクションをValue値の降順でソートし、ビジターIPの上位20%をフィルタリングし、ArrayListコレクションを使用して該IPサブセットをストレージし、アクティブユーザセットとしてマークし、対数線形モデルをあわせて、前記アクティブユーザセットの各アクティブユーザにアクサスされたファイルの人気予測値をアカウントして、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークし、具体的には:ArrayListコレクションから抽出されたビジターIPを、前記二次元配列から抽出されたビジターIPと照合し、一致が出たら、合致するビジターIPをキーワードとして、各ユーザのアクセス開始時刻を照会して、対数線形モデルを合わせ、前記アクティブユーザセットの各アクティブユーザにアクセスされたファイルの人気予測値をアカウントし、人気予測値によって各ファイルを降順にソートし、ファイルの上位20%をホットスポットファイルとしてマークし、前記対数線形モデルは:
Figure 2019204473
であり、その中に、
Figure 2019204473
がファイルiの人気予測値であり、
Figure 2019204473
がファイルiが観測期間中のトラフィックであり、観測期間の長さがtである。
A large number of small file write methods based on Hadoop are applied to an HDFS system in which the write method includes a data merge module and an HBase cache module, and the write method includes: a small file write command input by the user The small file write command includes a user ID and the name of the small file, and queries the HBase cache module by the user ID and the name of the small file. Return to the first file content queried by the HBase cache module, write the small file, and write the first file content written for the small file to the HBa e Upload to the cache module and update, and if the corresponding file content does not appear, query the HDFS system database by the file name of the small file to determine whether the corresponding file content is queried, If there is, return to the second file content queried in the database, write the small file, upload the updated second file content of the small file to the database, otherwise, Access the HAR file corresponding to the file name of the small file by calling the API of the Hadooparkive tool, write the small file, and upload the HAR file in which the small file is written to the database The data merge method employed by the data merge module includes the following: Step A: After the client uploads the stored file, it traverses all the files in HDFS and sets the user access preference model In combination, find a related file collection of the stored file, in which the user access preference model is based on a user access log record, step B: the middle file of the related file collection and the stored file Step C: Determine if the total size of all files in the merge queue exceeds 128 MB, if yes, go to step D, otherwise Proceed to Step E, Step D: Merge all files in the queue to be merged into one data block, clear file information in the queue to be merged, delete the source file of the merged file, go to Step B Returning, Step E: It is determined whether all the middle files of the related file collection and the files to be stored have been added to the merge queue. If yes, all the files in the merge queue are stored as one data. Merge into the block, clear the file information of the queue to be merged, delete the source file of the merged file, proceed to step F, otherwise proceed to step B. Step F: Store all merged data blocks in the HDFS system. The preference model is statistics from user access log records, specifically: statistics active user set from the user access log record, and represents a small file accessed by the active user set as a bean object; The small file points to a file having a size of 2 MB or less, and the property of the object includes the access user ID to the small file, the name of the small file accessed by the user, and the number of times the small file has been accessed. In addition, with the JDBC technology, the bean object is persisted and stored in the MySQL database, and the stored data accounts for the similarity of any two different access operations, and any If the similarity of two different access operations is positive, the user of any two access operations is a similar user, records the ID of the similar user, is accessed by the similar user by the related file set, and the associated file The cache method that stores information, builds the user access preference model by the related file set, and adopts the HBase cache module: obtains the user access log record, and obtains the active user set from the user access log record. Statistics, combined logarithmic linear model, accounted for popularity predictions of files accessed by each active user in the active user set, sorted each file in descending order by popularity prediction value, hot the top 20% of files Mark as pot file, to get the hot spot files, caches the related information of the hot spot file using Hbase database. For statistics of the active user set from the user access log record, specifically: Filter record rows from the user access log record with the suffix of the accessed source being jpg, in which the record row Contains user ID, access page URL, access start time, access status, access traffic, creates record analysis class to analyze the record row, and stores visitor IP and small file name using 2D array The visitor IP is traversed in the two-dimensional array, the traffic of each visitor IP is statistically analyzed using the HashMap collection, the Key value of the HashMap collection is the visitor IP, the Value value is the traffic, and the Hash sort the ap collection in descending order of Value, filter the top 20% of visitor IPs, use the ArrayList collection to store the IP subset, mark it as an active user set, and combine the log-linear model to Account the popularity prediction value of the file accessed for each active user in the user set, sort each file in descending order by popularity prediction value, and mark the top 20% of the files as hotspot files, specifically: The visitor IP extracted from the ArrayList collection is collated with the visitor IP extracted from the two-dimensional array, and when a match is found, the access start time of each user is inquired using the matching visitor IP as a keyword, and the logarithmic linear Model Account for popularity prediction values of files accessed by each active user of the active user set, sort each file in descending order by popularity prediction value, mark the top 20% of files as hot spot files, and logarithmically The linear model is:
Figure 2019204473
And in that,
Figure 2019204473
Is the popularity prediction for file i,
Figure 2019204473
File i is the traffic during the observation period, and the length of the observation period is t.
JP2018147289A 2018-05-22 2018-08-04 Method for writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module based on Hadoop Expired - Fee Related JP6642650B2 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810500092.8 2018-05-22
CN201810500092.8A CN108932287B (en) 2018-05-22 2018-05-22 A kind of mass small documents wiring method based on Hadoop

Publications (2)

Publication Number Publication Date
JP2019204473A true JP2019204473A (en) 2019-11-28
JP6642650B2 JP6642650B2 (en) 2020-02-05

Family

ID=64449331

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2018147289A Expired - Fee Related JP6642650B2 (en) 2018-05-22 2018-08-04 Method for writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module based on Hadoop

Country Status (2)

Country Link
JP (1) JP6642650B2 (en)
CN (1) CN108932287B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143158A (en) * 2019-12-04 2020-05-12 武汉光谷信息技术股份有限公司 Monitoring data real-time storage method and system, electronic equipment and storage medium
CN111813749A (en) * 2020-08-21 2020-10-23 网易(杭州)网络有限公司 File filtering method and device, electronic equipment and storage medium
CN112532724A (en) * 2020-11-27 2021-03-19 上海爱数信息技术股份有限公司 File transmission system and method thereof
CN115599792A (en) * 2022-12-13 2023-01-13 深圳市润信数据技术有限公司(Cn) Internet of things big data classification storage method
CN116069741A (en) * 2023-02-20 2023-05-05 北京集度科技有限公司 File processing method, apparatus and computer program product

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111913917A (en) * 2020-07-24 2020-11-10 北京锐安科技有限公司 File processing method, device, equipment and medium
CN117519608B (en) * 2023-12-27 2024-03-22 泰安北航科技园信息科技有限公司 Big data server with Hadoop as core

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102332029B (en) * 2011-10-15 2013-04-17 西安交通大学 Hadoop-based mass classifiable small file association storage method
CN102902716A (en) * 2012-08-27 2013-01-30 苏州两江科技有限公司 Storage system based on Hadoop distributed computing platform
CN103246700B (en) * 2013-04-01 2016-08-10 厦门市美亚柏科信息股份有限公司 Mass small documents low delay based on HBase storage method
CN103176754A (en) * 2013-04-02 2013-06-26 浪潮电子信息产业股份有限公司 Reading and storing method for massive amounts of small files
CN103530387A (en) * 2013-10-22 2014-01-22 浪潮电子信息产业股份有限公司 Improved method aimed at small files of HDFS
CN103577123B (en) * 2013-11-12 2016-06-22 河海大学 A kind of small documents optimization based on HDFS stores method
CN103678491A (en) * 2013-11-14 2014-03-26 东南大学 Method based on Hadoop small file optimization and reverse index establishment
CN103856567B (en) * 2014-03-26 2017-05-17 西安电子科技大学 Small file storage method based on Hadoop distributed file system
CN105205082A (en) * 2014-06-27 2015-12-30 国际商业机器公司 Method and system for processing file storage in HDFS
CN104536959B (en) * 2014-10-16 2018-03-06 南京邮电大学 A kind of optimization method of Hadoop accessing small high-volume files
CN105183839A (en) * 2015-09-02 2015-12-23 华中科技大学 Hadoop-based storage optimizing method for small file hierachical indexing
CN105404652A (en) * 2015-10-29 2016-03-16 河海大学 Mass small file processing method based on HDFS
CN105631010A (en) * 2015-12-29 2016-06-01 成都康赛信息技术有限公司 Optimization method based on HDFS small file storage
CN106909651A (en) * 2017-02-23 2017-06-30 郑州云海信息技术有限公司 A kind of method for being write based on HDFS small documents and being read
CN107391280A (en) * 2017-07-31 2017-11-24 郑州云海信息技术有限公司 A kind of reception of small documents and storage method and device
CN107741947B (en) * 2017-08-30 2020-04-24 浙江九州量子信息技术股份有限公司 Method for storing and acquiring random number key based on HDFS file system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143158A (en) * 2019-12-04 2020-05-12 武汉光谷信息技术股份有限公司 Monitoring data real-time storage method and system, electronic equipment and storage medium
CN111143158B (en) * 2019-12-04 2023-05-16 武汉光谷信息技术股份有限公司 Monitoring data real-time storage method, system, electronic equipment and storage medium
CN111813749A (en) * 2020-08-21 2020-10-23 网易(杭州)网络有限公司 File filtering method and device, electronic equipment and storage medium
CN112532724A (en) * 2020-11-27 2021-03-19 上海爱数信息技术股份有限公司 File transmission system and method thereof
CN115599792A (en) * 2022-12-13 2023-01-13 深圳市润信数据技术有限公司(Cn) Internet of things big data classification storage method
CN116069741A (en) * 2023-02-20 2023-05-05 北京集度科技有限公司 File processing method, apparatus and computer program product

Also Published As

Publication number Publication date
JP6642650B2 (en) 2020-02-05
CN108932287B (en) 2019-11-29
CN108932287A (en) 2018-12-04

Similar Documents

Publication Publication Date Title
JP6695537B2 (en) How to read multiple small files of 2MB or less from HDFS with data merge module and HBase cache module based on Hadoop
JP6642650B2 (en) Method for writing a plurality of small files of 2 MB or less to HDFS including a data merge module and an HBase cache module based on Hadoop
JP6642651B2 (en) Storage method using user access preference model
Sharma et al. A brief review on leading big data models
KR102564170B1 (en) Method and device for storing data object, and computer readable storage medium having a computer program using the same
WO2017097231A1 (en) Topic processing method and device
CN110291518A (en) Merge tree garbage index
CN109558084B (en) Data processing method and related equipment
US10650017B1 (en) Tiered storage for data processing
CN110188080A (en) Telefile Research of data access performance optimization based on client high-efficiency caching
CN103019887A (en) Data backup method and device
CN105683928B (en) For the method for data cache policies, server and memory devices
JP6696062B2 (en) How to cache multiple 2MB or smaller files based on Hadoop
CN112262379A (en) Storing data items and identifying stored data items
US20110179013A1 (en) Search Log Online Analytic Processing
CN110858210A (en) Data query method and device
CN108763458B (en) Content characteristic query method, device, computer equipment and storage medium
CN103324762A (en) Hadoop-based index creation method and indexing method thereof
US9275091B2 (en) Database management device and database management method
US9594785B2 (en) Database management device and database management method
CN110019870B (en) Image retrieval method and system based on memory image cluster
Lu et al. Research on Cassandra data compaction strategies for time-series data
CN116820323A (en) Data storage method, device, electronic equipment and computer readable storage medium
CN110990394B (en) Method, device and storage medium for counting number of rows of distributed column database table
US10037155B2 (en) Preventing write amplification during frequent data updates

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20181119

A871 Explanation of circumstances concerning accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A871

Effective date: 20181119

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20181120

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20190814

A975 Report on accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A971005

Effective date: 20190903

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20190909

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20190910

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20191209

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20191216

R150 Certificate of patent or registration of utility model

Ref document number: 6642650

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees