WO2017084509A1 - 基于MapReduce的数据处理方法及装置 - Google Patents

基于MapReduce的数据处理方法及装置 Download PDF

Info

Publication number
WO2017084509A1
WO2017084509A1 PCT/CN2016/104965 CN2016104965W WO2017084509A1 WO 2017084509 A1 WO2017084509 A1 WO 2017084509A1 CN 2016104965 W CN2016104965 W CN 2016104965W WO 2017084509 A1 WO2017084509 A1 WO 2017084509A1
Authority
WO
WIPO (PCT)
Prior art keywords
map
subfiles
sub
subfile
preset
Prior art date
Application number
PCT/CN2016/104965
Other languages
English (en)
French (fr)
Inventor
梁永锋
Original Assignee
阿里巴巴集团控股有限公司
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 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2017084509A1 publication Critical patent/WO2017084509A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/461Saving or restoring of program or task context
    • G06F9/463Program control block organisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]

Definitions

  • the present application relates to data warehousing technology, and in particular, to a data processing method and apparatus based on MapReduce.
  • Hadoop is a distributed system infrastructure that can process large amounts of data. It consists mainly of Hadoop Distributed File System (HDFS) and map reduction MapReduce. Among them, MapReduce is a distributed computing framework, mainly used for parallel computing of large-scale data sets. It is mainly divided into Map (mapping) task and Reduce (reduction) task. The processing logic of Map task and Reduce task respectively correspond to Map function and Reduce function.
  • HDFS Hadoop Distributed File System
  • the Hadoop distributed file system can be used to merge (cluster) data in large data sets according to certain rules.
  • data when data is merged in a large-scale data set, it is usually implemented by using a MapReduce job. Before a MapReduce job is started, the number of Map tasks and the number of Reduce tasks included in the MapReduce job need to be pre-configured.
  • the general process is: use Hadoop's data warehouse tool Hive to execute a SQL command, generate data files arranged in a certain order on HDFS, and then read the data files from HDFS by executing the Map task, and follow the rules.
  • the files to be merged are stored in the same path. Finally, the files to be merged stored in each path are merged separately by executing the Reduce task.
  • An object of the present application is to provide a data processing method and apparatus based on MapReduce, so as to solve the problem that the number of tasks pre-configured before the MapReduce job is started does not match the actual amount of data to be processed in the prior art. A problem that affects the efficiency with which the machine processes data.
  • a data processing method based on MapReduce comprising:
  • the data file is segmented according to the value of the preset field to obtain a first sub-file set including several sub-files;
  • a data processing device based on MapReduce comprising:
  • a sorting unit configured to sort the data to be processed according to the value of the preset field to obtain a data file including the sorted data
  • a segmentation unit configured to segment the data file according to a value of the preset field in a first Map task included in the first Map job, to obtain a first sub-file set including a plurality of sub-files;
  • a first determining unit configured to determine, from the first set of subfiles, a second set of subfiles including at least two subfiles to be merged;
  • a second determining unit configured to determine the number of the second subset of subfiles as the number of second Map tasks included in the second Map job
  • a merging unit configured to merge at least two subfiles to be merged included in the second subfile set in the second Map task included in the second Map job.
  • the sorted data files are segmented to obtain a first sub-file set including a plurality of sub-files; And after that, determining a second sub-file set to be merged in the first sub-file set; and determining, according to the determined number of second sub-file sets, the number of second Map tasks included in the second Map job; In each second Map task included in the second Map job, the sub-files in the second sub-file set that have the same value on the preset field are merged.
  • the embodiment of the present application implements data merge by using two MapReduce jobs with zero Reduce task (the first Map job and the second Map job), and the number of second Map tasks included in the second Map job. Is the number of second subfile sets determined according to the first Map job. The quantity (that is, the number of tasks that actually need to be merged) is determined.
  • the number of second task tasks included in the second Map job can be dynamically adjusted according to the number of second sub-files obtained by the first Map job, thereby solving the existing In the technology, before the MapReduce job is started, the number of pre-configured tasks (the number of Map tasks or the number of Reduced tasks) does not match the actual amount of data to be processed, and the efficiency of processing data by the machine is improved.
  • FIG. 1 is a flowchart of a data processing method based on MapReduce according to an embodiment of the present application
  • FIG. 2 is a data flow diagram of a data processing process in an embodiment of the present application.
  • FIG. 3 is a flowchart of a first Map job in an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a module of a data processing apparatus based on MapReduce according to an embodiment of the present disclosure.
  • the present application is based on MapReduce to implement data clustering on the Internet data platform.
  • the Internet data platform may be, for example, an E-Business Platform or a Third Party payment Platform.
  • a large amount of transaction data is generated every day.
  • Some merchants on the e-commerce platform may have a corresponding ERP (Enterprise Resource Planning) software platform.
  • ERP Enterprise Resource Planning
  • transaction data on each merchant's ERP software platform needs to be on the e-commerce platform.
  • the transaction data is consistent.
  • the current common practice is that the e-commerce platform generates transaction details files corresponding to each merchant (each merchant corresponds to a transaction detail file) according to the transaction data within a certain period of time or irregularly, and the generated transactions will be generated.
  • the detailed file is stored in a distributed file system HDFS, from The ERP software platform of each merchant can obtain the respective transaction detail files from the above HDFS.
  • the ERP software platform of each merchant can obtain the respective transaction detail files from the above HDFS.
  • FIG. 1 is a flowchart of a data processing method based on MapReduce according to an embodiment of the present application.
  • 2 is a data flow diagram of a data processing process in an embodiment of the present application. Referring to FIG. 1 and FIG. 2, in the embodiment of the present application, the method includes the following steps:
  • S101 Sort the data to be processed according to the value of the preset field to obtain a data file including the sorted data.
  • the method can adopt a Hadoop system and utilize the distributed file system HDFS to extract data and store data.
  • the preset field is pre-designated as a basis for the data sorting operation according to actual data merging (clustering) requirements.
  • the e-commerce platform can store the transaction data generated in a period of time in the data warehouse (Hadoop), and can use Hadoop's data warehouse tool Hive to execute a Sql statement (instruction), thereby performing the unordered data stored in the data warehouse. Ordering.
  • the transaction data stored in the data warehouse can be sorted according to the value of the preset field (C1: Merchant ID) to obtain a data file containing the sorted transaction data, and the obtained data file can be stored in the HDFS.
  • the original transaction data (identified by the merchant ID) stored by Hadoop includes:
  • the data warehouse tool Hive is used to execute a Sql statement for sorting, and the obtained transaction data includes:
  • a plurality of data files equally divided according to a certain size can be obtained, for example, 0.TXT, 1.TXT, 2.TXT (file name).
  • 0.TXT, 1.TXT, 2.TXT file name
  • only one package can be stored in the storage path DIR1.
  • S102 In the first Map task included in the first Map job, segment the data file according to the value of the preset field to obtain a first sub-file set including several sub-files; wherein each of the sub-files The data contained in the data has the same value on the preset field.
  • the first Map job MapReduce job with zero number of tasks
  • the first Map job includes a plurality of first Map tasks
  • the data source of the first Map job is in the storage path DIR1.
  • data files The slice of each first Map task may default to, for example, 64M of data.
  • the data is read from the storage path DIR1 by calling the Map function, and the data file in the DIR1 is segmented according to the value of the preset field to obtain the first one including the plurality of subfiles. Subfile collection.
  • step S102 includes:
  • S1022 Determine whether the read data is consistent with the value of the previous data stored in the cache on the preset field.
  • step S1025 It is judged whether the first Map task is finished, and if so, the process proceeds to step S103; if not, the process returns to step S1021.
  • the first Map task included in the first Map job is: Task0 and Task1 (Map Task ID), wherein the data read by Task0 is assumed to include all data in the data file 0.TXT, And part of the data in the data file 1.TXT; the data read by Task1 includes part of the data in the data file 1.TXT, and all the data in the data file 2.TXT.
  • Task1 Three subfiles can be obtained through Task1, for example:
  • the merchant n.TXT (file name) contains data: ⁇ business n, merchant n, merchant n ⁇ .
  • the sorted data files can be separately segmented to obtain a plurality of subfiles, and the data contained in each subfile is in a preset field.
  • the values on are consistent, that is, a subfile contains only data for one merchant ID.
  • the resulting first set of subfiles Q1 is, for example:
  • the data in the first subset of the foregoing subfiles that can be segmented is stored in the storage path DIR2 (defined herein as the second preset path) in the HDFS.
  • the path name of the storage path (sub-path) of each sub-file in the second preset path DIR2 may include the ID of the first Map task corresponding to the sub-file, and the sub-files stored in the second preset path DIR2
  • the file name contains the value of the preset field corresponding to the subfile. For example, the path name of the storage path stored by "Business 1.TXT" obtained by Task0 is DIR2/0, and the path name of the storage path stored by "Business 2.TXT" obtained by Task0 is DIR2/0. ....
  • the storage manner of the first sub-file set obtained above, the naming manner of the storage path, and the naming manner of the file name are not limited to the above contents.
  • S103 Determine, from the first set of subfiles, a second set of subfiles including at least two subfiles to be merged.
  • the first Map job includes a plurality of first Map tasks, and may cause the sub-files obtained by the adjacent two or more first Map tasks to include data on the preset field.
  • the values are consistent (for example, the sub-file "merchant 2.TXT” obtained by Task0 and the sub-file “merchant 2.TXT” obtained by Task1 have the same value in the preset field (merchant ID) as "merchant 2", then it can be determined
  • These two sub-files are the transaction data files of the same merchant, that is, the sub-files to be merged.
  • the obtained file to be merged is two sub-files respectively obtained by two adjacent two first Map tasks.
  • the files to be merged may also be three or more sub-files obtained by slicing three or more adjacent first Map tasks.
  • a merchant's transaction data may be very large, which may result in more Map tasks to segment the transaction data of this merchant.
  • each set of sub-files to be merged (at least two) is determined as a second sub-file set Q2, then according to the traversal Group sub-files to be merged, you can get multiple second sub-file sets Q2 (second sub-file The number of collections is equal to the number of groups of subfiles to be merged).
  • the obtained second sub-file set Q2 may include:
  • S104 Determine the number of the second sub-file set Q2 as the number of second Map tasks included in the second Map job.
  • At least two sub-files included in each second sub-file set Q2 may be respectively stored in the same sub-path under the first preset path DIR3.
  • the DIR3 neutrons may be used according to the above.
  • the number of paths determines the number of Map tasks in the second Map job.
  • each second subfile set Q2 may be moved from the second preset path DIR2 to the same subpath under the first preset path DIR3.
  • the sub-files obtained by the first Map task may not be stored, but when the sub-files to be merged are determined, the merged sub-processes are respectively processed.
  • Files and subfiles that do not need to be merged are stored separately, and their storage methods and storage paths are not limited.
  • the step of storing the subfiles in Q2 further includes:
  • a new sub-path can be created one by one in DIR3, for example: "merchant 2" (storage path name), and the original to be merged is stored in DIR/0.
  • the sub-file "Business 2.TXT” and the sub-file “Business 2.TXT” originally stored in DIR/1 are moved to DIR3/Business 2, and the file names of the two sub-files are respectively changed to "0.TXT” , "1.TXT".
  • all sub-paths of the corresponding DIR3 are obtained according to the number of sub-files to be merged.
  • the storage mode of the DIR3, the naming manner of the storage path, and the naming manner of the file name are not limited to the above.
  • each second Map task uses one subpath of the above DIR3 as a slice of the Map method, and each second Map task usually only needs to call the Map function once. Read all the subfiles to be merged in the current subpath, sort them according to the file name, and finally merge the sorted files to obtain a merged transaction data file corresponding to a merchant ID.
  • the data to be processed in the Internet can be merged according to the value of the preset field by using the first Map job and the second Map job.
  • the transaction data file of each merchant ID obtained by the combination may be stored in the second preset path DIR2 (because the DIR2 includes the transaction data file corresponding to the remaining merchant IDs that do not need to be merged), so that the e-commerce can be merged.
  • the transaction data files corresponding to all the merchant IDs on the platform are extracted by the ERP software platform of each merchant.
  • the method further includes: corresponding to each second map task in the second Map job and a value of a corresponding preset field.
  • the step S105 may specifically include: in each second Map task included in the second Map job, reading a value corresponding to the preset field according to a value of a preset field corresponding to the second Map task At least two of the second subset of subfiles are merged.
  • the sub-files to be merged included in the determined second sub-file set Q2 may be stored in the same large storage path (do not split each sub-path), corresponding to the same merchant ID.
  • the plurality of subfiles to be merged may be, for example, "Business 2-1.TXT", "Business 2-2.TXT", .... Therefore, in each second Map task included in the second Map job, each second Map task may be correspondingly associated with the value of the corresponding preset field, thereby respectively specifying that each second Map task should be read. Take the second subfile collection Q2.
  • the file name of the subfile read by the second Map task Task20 includes the merchant ID “Business 2”
  • the file name of the subfile read by the second Map task Task 21 includes the merchant ID “Business 6”, etc. Wait.
  • all the sub-files to be merged of a certain merchant ID (preset field) to be merged can be read and sequentially merged from the above-mentioned large storage path by each second Map task. deal with.
  • the alternative embodiments of the present application are not limited to the above enumerated contents, and are not enumerated one by one.
  • the embodiment of the present application further provides a data processing device based on MapReduce.
  • the device can be implemented by software, or can be implemented by hardware or a combination of hardware and software.
  • the central processing unit (CPU) of the server reads and writes the corresponding computer program instructions into the memory.
  • FIG. 4 is a schematic diagram of a module of a data processing apparatus based on MapReduce according to an embodiment of the present disclosure.
  • the functions of the units in the device are similar to those of the steps in the above method. Therefore, the device can refer to the specific content of the foregoing method embodiments.
  • the device includes:
  • the sorting unit 101 is configured to sort the data to be processed according to the value of the preset field to obtain a data file including the sorted data;
  • the segmentation unit 102 is configured to segment the data file according to the value of the preset field in a first Map task included in the first Map job, to obtain a first sub-file set including a plurality of sub-files;
  • a first determining unit 103 configured to determine, from the first set of subfiles, a second set of subfiles including at least two subfiles to be merged;
  • a second determining unit 104 configured to determine the number of the second subset of subfiles as the number of second Map tasks included in the second Map job;
  • the merging unit 105 is configured to merge at least two sub-files to be merged included in the second sub-file set in the second Map task included in the second Map job.
  • the first determining unit 103 is specifically configured to:
  • the device further includes:
  • a first storage unit configured to store at least two subfiles included in each second subfile set in the same subpath under the first preset path
  • the second determining unit 104 is specifically configured to:
  • the number of sub-paths included in the first preset path is determined as the number of Map tasks in the second Map job.
  • the merging unit 105 is specifically configured to:
  • the device further includes:
  • Corresponding unit configured to correspond each second Map task in the second Map job with a value of a corresponding preset field
  • the merging unit 105 is specifically configured to:
  • each second Map task included in the second Map job according to the preset word corresponding to the second Map task a value of the segment, reading at least two subfiles in the second subfile set corresponding to the value of the preset field and merging.
  • the device further includes:
  • a second storage unit configured to store, in the second preset path, the subfile obtained by dividing each of the first Map tasks included in the first Map job;
  • the first storage unit is specifically configured to:
  • the second storage unit further includes:
  • a second file name determining unit configured to determine that a file name of the subfile stored in the second preset path includes a value of a preset field corresponding to the subfile
  • a second path name determining unit configured to determine, in the storage path name corresponding to the subfile stored in the second preset path, an ID of the first Map task corresponding to the subfile;
  • the first storage unit further includes:
  • a first file name determining unit configured to determine, in a file name of the subfile in the first preset path, an ID of a first Map task corresponding to the subfile;
  • the first path name determining unit is configured to determine that a corresponding sub path name of the sub file in the first preset path includes a value of the corresponding preset field.
  • the preset field is a merchant ID in transaction data generated by an internet transaction platform.
  • the sorted data file is segmented to obtain a first sub-file including several sub-files. a set of files; and thereafter, determining a second set of subfiles to be merged in the first set of subfiles; and determining the number of second Map tasks included in the second Map job according to the determined number of second subsets of subfiles
  • the sub-files in which the data included in the second sub-file set has the same value on the preset field are merged.
  • the embodiment of the present application implements data merge by using two MapReduce jobs with zero Reduce task (the first Map job and the second Map job), and the number of second Map tasks included in the second Map job. It is determined according to the number of second sub-file sets determined in the first Map job (that is, the number of tasks that actually need to be merged). Based on the above content, when the amount of data to be processed changes, the number of second task tasks included in the second Map job can be dynamically adjusted according to the number of second sub-files obtained by the first Map job, thereby solving the existing In the technology, before the MapReduce job starts, The number of pre-configured tasks (the number of Map tasks or the number of Reduced tasks) does not match the actual amount of data to be processed.
  • the number of pre-configured Map tasks is N, Reduce.
  • the number of tasks is M.
  • the number of Map tasks is much larger than the number of Reduced tasks. This may result in too few default Reduce tasks, which may result in a Reduce task requiring the consolidation of two or more merchant data. , thus affecting the efficiency of data processing.
  • the embodiment of the present application ensures that in the second Map job, each second Map task only merges data of one merchant in the second Map job, thereby improving the efficiency of the machine processing data.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • the application can be described in the general context of computer-executable instructions executed by a computer, such as a program module.
  • program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • the present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program modules can be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种基于MapReduce的数据处理方法及装置,解决现有技术中为MapReduce作业预先配置的任务数无法与实际情况相符的问题。所述方法包括:将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件(S101);在第一Map作业包含的第一Map任务中,按照所述预设字段的值切分所述数据文件,得到包含若干子文件的第一子文件集合(S102);从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合(S103);将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量(S104);在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两个待合并的子文件进行合并(S105)。

Description

基于MapReduce的数据处理方法及装置
本申请要求2015年11月17日递交的申请号为201510789816.1、发明名称为“基于MapReduce的数据处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据仓库技术,特别涉及一种基于MapReduce的数据处理方法及装置。
背景技术
Hadoop是一个能够对大量数据进行处理的分布式系统基础框架,主要由Hadoop分布式文件系统(Hadoop Distributed File System,HDFS)和映射归约MapReduce组成。其中,MapReduce是一种分布式计算框架,主要用于大规模数据集的并行运算,其主要分为Map(映射)任务和Reduce(归约)任务,Map任务和Reduce任务的处理逻辑分别对应于Map函数和Reduce函数。
在一些应用中,利用Hadoop分布式文件系统可以根据一定的规则对大规模数据集中的数据进行合并(聚类)。现有技术中,在进行大规模数据集中的数据合并时,通常是利用一个MapReduce作业来实现,在一个MapReduce作业启动之前,需要预先配置该MapReduce作业中包含的Map任务数和Reduce任务数。其大致过程是:利用Hadoop的数据仓库工具Hive来执行一条sql指令,在HDFS上生成按照一定次序进行排列的数据文件,然后,通过执行Map任务,从HDFS上读取上述数据文件,并按照规则将需要合并的文件存放于同一个路径中;最终,通过执行Reduce任务,将各个路径中存放的需要合并的文件分别作合并。
上述现有技术中,由于MapReduce作业包含的任务数均是在MapReduce作业启动之前预先配置好的,而在实际业务运行过程中,待处理的数据量并不是固定的,从而可能导致在MapReduce作业启动之前预先配置的任务数与实际待处理的数据量不匹配,影响机器处理数据的效率。
发明内容
本申请实施例的目的是提供一种基于MapReduce的数据处理方法及装置,以解决现有技术中在MapReduce作业启动之前预先配置的任务数与实际待处理的数据量不匹配, 影响机器处理数据的效率的问题。
为解决上述技术问题,本申请实施例提供的基于MapReduce的数据处理方法及装置是这样实现的:
一种基于MapReduce的数据处理方法,包括:
将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件;
在第一Map作业包含的第一Map任务中,按照所述预设字段的值切分所述数据文件,得到包含若干子文件的第一子文件集合;
从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合;
将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量;
在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两个待合并的子文件进行合并。
一种基于MapReduce的数据处理装置,包括:
排序单元,用于将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件;
切分单元,用于在第一Map作业包含的第一Map任务中,按照所述预设字段的值切分所述数据文件,得到包含若干子文件的第一子文件集合;
第一确定单元,用于从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合;
第二确定单元,用于将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量;
合并单元,用于在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两个待合并的子文件进行合并。
由以上本申请各实施例提供的技术方案可见,在第一Map作业包含的每个第一Map任务中,对排序后的数据文件进行切分,得到包含若干子文件的第一子文件集合;并在此之后,确定第一子文件集合中的待合并的第二子文件集合;并根据确定的第二子文件集合的数量来确定第二Map作业包含的第二Map任务的数量;最终,在第二Map作业包含的每个第二Map任务中,将所述第二子文件集合中的包含的数据在预设字段上的值一致的子文件进行合并。在上述过程中,本申请实施例通过两个Reduce任务为零的MapReduce作业(上述第一Map作业和第二Map作业)来实现数据合并,并且第二Map作业中包含的第二Map任务的数量是根据第一Map作业中确定的第二子文件集合的数 量(也就是实际需要进行合并的任务数)来确定的。基于上述内容,当待处理的数据量发生变化时,可以动态地根据第一Map作业得到的第二子文件集合数,来调整第二Map作业包含的第二Map任务的数量,从而解决现有技术中在MapReduce作业启动之前,所预先配置的任务数(Map任务数或Reduce任务数)与实际待处理的数据量不匹配的问题,提升机器处理数据的效率。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本申请一实施例提供的基于MapReduce的数据处理方法的流程图;
图2为本申请一实施例中数据处理过程的数据流图;
图3为本申请一实施例中第一Map作业的流程图;
图4为本申请一实施例提供的基于MapReduce的数据处理装置的模块示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。
本申请基于MapReduce来实现互联网数据平台上的数据聚类,互联网数据平台可以例如是电子商务平台(E-Business Platform)或第三方支付平台(Third party payment Platform)等。以电子商务平台为例,随着业务发展,每天会产生大量的交易数据。该电子商务平台上的某些商家可以有相应的ERP(Enterprise Resource Planning,企业资源计划)软件平台,在实际应用中,每个商家的ERP软件平台上的交易数据需要与该电子商务平台上的交易数据保持一致。目前的通用做法是,电子商务平台定时或不定时地根据一定时间内的交易数据,生成与每个商家对应的交易明细文件(每个商家对应于一个交易明细文件),并将生成的这些交易明细文件存放于一个分布式文件系统HDFS中,从 而各个商家的ERP软件平台可以从上述HDFS中获取各自的交易明细文件。目前,随着电子商务平台上交易数据量及商家数量的攀升,如何通过MapReduce和分布式文件系统HDFS进行数据聚类,以高效地生成每个商家的交易明细文件,是本申请的技术方案旨在解决的问题。
图1为本申请一实施例提供的基于MapReduce的数据处理方法的流程图。图2为本申请一实施例中数据处理过程的数据流图。配合参照图1和图2所示,本申请实施例中,所述方法包括如下步骤:
S101:将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件。
本实施例中,本方法可以采用Hadoop系统,并利用分布式文件系统HDFS来提取数据和存储数据。其中,所述预设字段是根据实际的数据合并(聚类)需求而预先指定的用来作为数据排序操作的依据。
以电子商务平台上的交易数据的合并为例。电子商务平台可以将一段时间内产生的交易数据存放在数据仓库(Hadoop)中,可以利用Hadoop的数据仓库工具Hive来执行一条Sql语句(指令),从而对数据仓库中存放的无序数据进行有序排列。
上述sql语句例如是:
“INSERT OVERWRITE DIRECTORY‘DIR1’SELECT C1C2…FROM T DISTRIBUT BY C1SORT BY C1”。
其中,对于一笔交易数据而言,可以包含多个字段,例如,C1:商家ID,C2:商品名称/ID,C3:交易金额。通过执行上述sql语句,可以将数据仓库中存储的交易数据按照预设字段(C1:商家ID)的值进行排序,得到包含排序的交易数据的数据文件,并可以将得到的数据文件存放在HDFS中的存储路径DIR1下。
参照图2所示,例如,Hadoop存储的原始交易数据(以商家ID来标识)包括:
{商家1、商家2、商家3、商家2、商家n、商家1、商家2、商家3、商家2、商家n、商家1、商家2、商家3、商家2、商家n};
通过数据仓库工具Hive来执行一条Sql语句进行排序,得到的交易数据包括:
{商家1、商家1、商家1、商家1、商家1、商家1、商家2、商家2、商家2、商家3、商家3、商家3、商家n、商家n、商家n};
在存储路径DIR1中,可以得到多个按照一定的大小进行均分的数据文件,例如,0.TXT,1.TXT,2.TXT(文件名)。当然,在该存储路径DIR1中也可以只存储一个包 含排序后的交易数据的数据文件。
值得一提的是,对数据仓库中的原始交易数据进行排序的具体过程并不限于上述内容。
S102:在第一Map作业包含的第一Map任务中,按照所述预设字段的值切分所述数据文件,得到包含若干子文件的第一子文件集合;其中,每个所述子文件中包含的数据在所述预设字段上的值一致。
本实施例中,生成第一Map作业(Reduce任务数为零的MapReduce作业),该第一Map作业包含多个第一Map任务,并且该第一Map作业的数据来源是上述存储路径DIR1中的数据文件。每个第一Map任务的分片可以默认为例如64M的数据。在每个第一Map任务中,通过调用Map函数来从上述存储路径DIR1中读取数据,以按照上述预设字段的值将DIR1中的数据文件进行切分,得到包含多个子文件的第一子文件集合。
参照图3所示,为该步骤S102的具体过程,包括:
S1021:逐一读取排序得到的数据文件中的数据。
S1022:判断读取的数据与缓存中存放的上一个数据在预设字段上的值是否一致。
S1023:若一致,则将读取的数据写入缓存中。
S1024:若不一致,则将当前缓存的数据全部写入HDFS中(作为一个子文件)。
S1025:判断第一Map任务是否结束,若是,转而执行步骤S103;若否,返回到步骤S1021。
继续参照图2,举例而言,若第一Map作业包含的第一Map任务是:Task0和Task1(Map任务ID),其中,假设Task0读取的数据包含数据文件0.TXT中的全部数据、及数据文件1.TXT中的部分数据;Task1读取的数据包含数据文件1.TXT中的部分数据、及数据文件2.TXT中的全部数据。
通过执行上述步骤S1021~S1025,可以通过Task0得到两个子文件(本文列举的子文件以预设字段的值来标识)例如是:
商家1.TXT(文件名),包含的数据是:{商家1、商家1、商家1、商家1、商家1、商家1};
商家2.TXT(文件名),包含的数据是:{商家2}。
通过Task1可以得到三个子文件例如是:
商家2.TXT(文件名),包含的数据是:{商家2、商家2};
商家3.TXT(文件名),包含的数据是:{商家3、商家3、商家3};
商家n.TXT(文件名),包含的数据是:{商家n、商家n、商家n}。
可以看出,在该第一Map作业中包含的每个第一Map任务中,可以分别将排序得到的数据文件进行切分,得到多个子文件,并且每个子文件中包含的数据在预设字段上的值是一致的,也就是说,一个子文件中只包含一个商家ID的数据。从而得到的第一子文件集合Q1例如是:
{商家1.TXT、商家2.TXT、商家2.TXT、商家3.TXT、商家n.TXT、……}。
优选地,本申请实施例中,可以切分得到的上述第一子文件集合中的数据存放于HDFS中存储路径DIR2(本文定义为第二预设路径)下。并且,每个子文件在第二预设路径DIR2中的存储路径(子路径)的路径名可以包含该子文件对应的第一Map任务的ID,该第二预设路径DIR2中存放的子文件的文件名中包含该子文件对应的预设字段的值。例如:由Task0切分得到的“商家1.TXT”存放的存储路径的路径名是DIR2/0,由Task0切分得到的“商家2.TXT”存放的存储路径的路径名是DIR2/0,……。
值得一提的是,上述得到的第一子文件集合的存储方式和存储路径的命名方式、文件名的命名方式均并不限于上述内容。
S103:从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合。
在上述步骤S102中,由于第一Map作业中包含多个第一Map任务,并且可能导致相邻的两个或两个以上的第一Map任务得到的子文件包含的数据在预设字段上的值一致(例如,Task0得到的子文件“商家2.TXT”和Task1得到的子文件“商家2.TXT”在预设字段(商家ID)上的值同是“商家2”),则可以确定这两个子文件是同一个商家的交易数据文件,即是待合并处理的子文件。
一般地,可以判断前一个第一Map任务切分得到的最后一个子文件与后一个第二Map任务切分得到的第一个子文件在上述预设字段上的值是否一致,若一致,则确定这两个子文件属于待合并的子文件。在上述例子中,得到的待合并的文件是由两个相邻的两个第一Map任务分别切分得到的两个子文件。然而,在其他的例子中,待合并的文件也可以是相邻的三个或更多个的第一Map任务切分得到的三个或更多个子文件。在实际应用过程中,一个商家的交易数据可能会非常多,这样可能导致由更多个Map任务来针对这一个商家的交易数据来作切分。通过遍历上述第一子文件集合Q1,可以确定所有待合并的子文件,若将每一组待合并的子文件(至少两个)确定为一个第二子文件集合Q2,则根据遍历得到的多组待合并的子文件,可以得到多个第二子文件集合Q2(第二子文件 集合的数量与待合并的子文件的组数相等)。举例而言,得到的第二子文件集合Q2可以包括:
{存储在DIR2/0下的“商家2.TXT”,存储在DIR2/1下的“商家2.TXT”};
{存储在DIR2/4下的“商家6.TXT”,存储在DIR2/5下的“商家6.TXT”,存储在DIR2/6下的“商家6.TXT”};
……
S104:将第二子文件集合Q2的数量确定为第二Map作业中包含的第二Map任务的数量。
在本申请可选的实施例中,可以将每个第二子文件集合Q2中的包含的至少两个子文件分别存放于第一预设路径DIR3下的同一个子路径中。相应地,当第一Map作业结束,并且将每个第二子文件集合Q2中包含的待合并的子文件存放于第一预设路径DIR3中的各个子路径下之后,可以根据上述DIR3中子路径的数量来确定第二Map作业中Map任务数。
在本申请优选的实施例中,可以将每个第二子文件集合Q2中包含的至少两个子文件从第二预设路径DIR2移到第一预设路径DIR3下的同一个子路径中。当然,在替代的方案中,在未确定得到待合并的子文件时,可以不对第一Map任务得到的子文件进行存储,而是在确定得到待合并的子文件时,再分别对待合并的子文件及不需进行合并的子文件分别进行存储,其存储方式和存储路径均不受限制。
通过将确定的待合并的第二子文件集合Q2中的子文件从DIR2移动到DIR3中,并且按照预设字段的值,在DIR3下的同一个子路径中存放同一个商家ID的子文件。为了便于实现第二Map作业的合并操作,存储Q2中的子文件的步骤还包括:
确定第一预设路径DIR3中的子文件的文件名中包含该子文件对应的第一Map任务的ID;确定第一预设路径DIR3中的子文件的对应的子路径名包含该对应的预设字段的值。
在上述例子中,确定得到第二子文件集合Q2后,可以在DIR3中逐一新建一个子路径,例如:“商家2”(存储路径名),并将待合并的原本存放于DIR/0中的子文件“商家2.TXT”和原本存放于DIR/1中的子文件“商家2.TXT”移动到DIR3/商家2中,并且将这两个子文件的文件名分别修改为“0.TXT”、“1.TXT”。依次类推,根据待合并的子文件的数量,得到对应的DIR3的所有子路径。如前所述,DIR3中的存储方式和存储路径的命名方式、文件名的命名方式均并不限于上述内容。
S105:在第二Map作业包含的第二Map任务中,将第二子文件集合Q2中包含的至少两个待合并的子文件进行合并。
在第二Map作业中,以DIR3中的数据作为数据来源,每个第二Map任务将上述DIR3中一个子路径作为一个Map方法的分片,每个第二Map任务通常只需调用一次Map函数,读取当前子路径中的所有待合并的子文件,并按照文件名进行排序,最后对排序后的文件进行合并,得到一个合并后的与某商家ID对应的交易数据文件。
至此,可以通过第一Map作业和第二Map作业实现对互联网中的待处理数据按照预设字段的值进行合并。最终,可以将合并得到的各个商家ID的交易数据文件存放于上述第二预设路径DIR2中(因为DIR2中包含不需作合并的其余商家ID对应的交易数据文件),从而可以合并得到电子商务平台上所有商家ID对应的交易数据文件,以供各个商家的ERP软件平台进行提取。
在本申请其他可行的实施例中,上述步骤S104之后,步骤S105之前,所述方法还包括:将所述第二Map作业中每个第二Map任务与相应的预设字段的值进行对应。相应地,上述步骤S105可以具体包括:在第二Map作业包含的每个第二Map任务中,根据该第二Map任务对应的预设字段的值,读取与所述预设字段的值对应的所述第二子文件集合中的至少两个子文件并进行合并。
在第一Map作业中,可以将确定的第二子文件集合Q2中包含的待合并的子文件存放在同一个大的存储路径中(不切分各个子路径),对于同一个商家ID对应的多个待合并的子文件,在其文件的命名上,可以例如是:“商家2-1.TXT”,“商家2-2.TXT”,……。从而,在第二Map作业中包含的每个第二Map任务中,可以通过预先将每个第二Map任务与相应的预设字段的值进行对应,从而分别指定每个第二Map任务应该读取的第二子文件集合Q2。例如:通过配置,第二Map任务Task20读取的子文件的文件名中包含商家ID“商家2”,第二Map任务Task21读取的子文件的文件名中包含商家ID“商家6”,等等。通过这样的机制,可以通过每个第二Map任务,分别从上述大的存储路径中,按照顺序读取到需要合并的某个商家ID(预设字段)的所有待合并的子文件并作合并处理。本申请替代的实施例并不限于上述列举的内容,不再一一列举。
与上述方法流程对应的,本申请的实施例还提供了一种基于MapReduce的数据处理装置。该装置可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。以软件实现为例,作为逻辑意义上的装置,是通过服务器的中央处理器(Central Process Unit,CPU)将对应的计算机程序指令读取到内存中运行形成的。
图4为本申请一实施例提供的基于MapReduce的数据处理装置的模块示意图。其中,该装置中各单元的功能与上述方法中各步骤的功能类似,故该装置可以参照上述方法实施例的具体内容。该装置包括:
排序单元101,用于将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件;
切分单元102,用于在第一Map作业包含的第一Map任务中,按照所述预设字段的值切分所述数据文件,得到包含若干子文件的第一子文件集合;
第一确定单元103,用于从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合;
第二确定单元104,用于将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量;
合并单元105,用于在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两个待合并的子文件进行合并。
本申请实施例中,所述第一确定单元103具体用于:
确定由至少两个相邻的第一Map任务得到的、且包含的数据在所述预设字段上的值一致的至少两个子文件,得到所述第二子文件集合。
本申请实施例中,所述装置还包括:
第一存储单元,用于将每个第二子文件集合中的包含的至少两个子文件存放于第一预设路径下的同一个子路径中;
所述第二确定单元104具体用于:
将所述第一预设路径下包含的子路径的数量确定为所述第二Map作业中的Map任务数。
所述合并单元105具体用于:
在第二Map作业包含的第二Map任务中,读取所述第一预设路径下的同一个子路径中的至少两个子文件并进行合并。
本申请实施例中,所述装置还包括:
对应单元,用于将所述第二Map作业中每个第二Map任务与相应的预设字段的值进行对应;
所述合并单元105具体用于:
在第二Map作业包含的每个第二Map任务中,根据该第二Map任务对应的预设字 段的值,读取与所述预设字段的值对应的所述第二子文件集合中的至少两个子文件并进行合并。
本申请实施例中,所述装置还包括:
第二存储单元,用于将在第一Map作业包含的每一个第一Map任务中切分得到的子文件存储于第二预设路径中;
所述第一存储单元具体用于:
将所述第二子文件集合中的包含的数据在所述预设字段上的值一致的至少两个子文件从所述第二预设路径移到第一预设路径下的同一个子路径中。
本申请实施例中,所述第二存储单元还包括:
第二文件名确定单元,用于确定所述第二预设路径中存放的子文件的文件名中包含该子文件对应的预设字段的值;
第二路径名确定单元,用于确定所述第二预设路径中存放的子文件对应的存储路径名中包含该子文件对应的第一Map任务的ID;
所述第一存储单元还包括:
第一文件名确定单元,用于确定所述第一预设路径中的子文件的文件名中包含该子文件对应的第一Map任务的ID;
第一路径名确定单元,用于确定所述第一预设路径中的子文件的对应的子路径名包含该对应的预设字段的值。
本申请实施例中,所述预设字段是互联网交易平台生成的交易数据中的商家ID。
综上,由以上本申请各实施例提供的技术方案可见,在第一Map作业包含的每个第一Map任务中,对排序后的数据文件进行切分,得到包含若干子文件的第一子文件集合;并在此之后,确定第一子文件集合中的待合并的第二子文件集合;并根据确定的第二子文件集合的数量来确定第二Map作业包含的第二Map任务的数量;最终,在第二Map作业包含的每个第二Map任务中,将所述第二子文件集合中的包含的数据在预设字段上的值一致的子文件进行合并。在上述过程中,本申请实施例通过两个Reduce任务为零的MapReduce作业(上述第一Map作业和第二Map作业)来实现数据合并,并且第二Map作业中包含的第二Map任务的数量是根据第一Map作业中确定的第二子文件集合的数量(也就是实际需要进行合并的任务数)来确定的。基于上述内容,当待处理的数据量发生变化时,可以动态地根据第一Map作业得到的第二子文件集合数,来调整第二Map作业包含的第二Map任务的数量,从而解决现有技术中在MapReduce作业启动之前, 所预先配置的任务数(Map任务数或Reduce任务数)与实际待处理的数据量不匹配的问题,例如,在现有技术中一个MapReduce作业启动之前,预先配置的Map任务数是N,Reduce任务数是M,而一般情况下,Map任务数远大于Reduce任务数,这样便可能导致预设的Reduce任务数过少,进而导致一个Reduce任务需要对两个或两个以上的商家数据进行合并,从而影响数据处理的效率。本申请实施例通过上述两个Map作业,来确保在第二Map作业中,每个第二Map任务都只是针对一个商家的数据进行合并,从而提升机器处理数据的效率。
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性 的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。

Claims (14)

  1. 一种基于MapReduce的数据处理方法,其特征在于,包括:
    将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件;
    在第一Map作业包含的第一Map任务中,按照所述预设字段的值切分所述数据文件,得到包含若干子文件的第一子文件集合;
    从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合;
    将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量;
    在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两个待合并的子文件进行合并。
  2. 根据权利要求1所述的方法,其特征在于,从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合,包括:
    确定由至少两个相邻的第一Map任务得到的、且包含的数据在所述预设字段上的值一致的至少两个子文件,得到所述第二子文件集合。
  3. 根据权利要求1所述的方法,其特征在于,确定所述第二子文件集合之后,将所述第二子文件集合中的子文件进行合并之前,还包括:
    将每个第二子文件集合中的包含的至少两个子文件存放于第一预设路径下的同一个子路径中;
    将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量,具体包括:
    将所述第一预设路径下包含的子路径的数量确定为所述第二Map作业中的Map任务数;
    在第二Map作业包含的第二Map任务中,将所述第二子文件集合中的子文件进行合并,具体包括:
    在第二Map作业包含的第二Map任务中,读取所述第一预设路径下的同一个子路径中的至少两个子文件并进行合并。
  4. 根据权利要求1所述的方法,其特征在于,将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量之后,将所述第二子文件集合中的包含的子文件进行合并之前,还包括:
    将所述第二Map作业中每个第二Map任务与相应的预设字段的值进行对应;
    在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两 个待合并的子文件进行合并,具体包括:
    在第二Map作业包含的每个第二Map任务中,根据该第二Map任务对应的预设字段的值,读取与所述预设字段的值对应的所述第二子文件集合中的至少两个子文件并进行合并。
  5. 根据权利要求3所述的方法,其特征在于,在第一Map作业包含的第一Map任务中,得到所述第一子文件集合之后,确定所述第二子文件集合之前,还包括:
    将在第一Map作业包含的每一个第一Map任务中切分得到的子文件存储于第二预设路径中;
    将所述第二子文件集合中的包含的数据在所述预设字段上的值一致的至少两个子文件存放于第一预设路径下的同一个子路径中,具体包括:
    将所述第二子文件集合中的包含的数据在所述预设字段上的值一致的至少两个子文件从所述第二预设路径移到第一预设路径下的同一个子路径中。
  6. 根据权利要求5所述的方法,其特征在于,将在第一Map作业包含的每一个第一Map任务中切分得到的子文件存储于第二预设路径中,还包括:
    确定所述第二预设路径中存放的子文件的文件名中包含该子文件对应的预设字段的值;
    确定所述第二预设路径中存放的子文件对应的存储路径名中包含该子文件对应的第一Map任务的ID;
    将所述第二子文件集合中的包含的数据在所述预设字段上的值一致的至少两个子文件从所述第二预设路径移到第一预设路径下的同一个子路径中,还包括:
    确定所述第一预设路径中的子文件的文件名中包含该子文件对应的第一Map任务的ID;
    确定所述第一预设路径中的子文件的对应的子路径名包含该对应的预设字段的值。
  7. 根据权利要求1所述的方法,其特征在于,所述预设字段是互联网交易平台生成的交易数据中的商家ID。
  8. 一种基于MapReduce的数据处理装置,其特征在于,包括:
    排序单元,用于将待处理的数据按照预设字段的值进行排序,得到包含排序后的数据的数据文件;
    切分单元,用于在第一Map作业包含的第一Map任务中,按照所述预设字段的值 切分所述数据文件,得到包含若干子文件的第一子文件集合;
    第一确定单元,用于从所述第一子文件集合中,确定包含至少两个待合并的子文件的第二子文件集合;
    第二确定单元,用于将所述第二子文件集合的数量确定为第二Map作业中包含的第二Map任务的数量;
    合并单元,用于在第二Map作业包含的第二Map任务中,将所述第二子文件集合中包含的至少两个待合并的子文件进行合并。
  9. 根据权利要求8所述的装置,其特征在于,所述第一确定单元具体用于:
    确定由至少两个相邻的第一Map任务得到的、且包含的数据在所述预设字段上的值一致的至少两个子文件,得到所述第二子文件集合。
  10. 根据权利要求8所述的装置,其特征在于,所述装置还包括:
    第一存储单元,用于将每个第二子文件集合中的包含的至少两个子文件存放于第一预设路径下的同一个子路径中;
    所述第二确定单元具体用于:
    将所述第一预设路径下包含的子路径的数量确定为所述第二Map作业中的Map任务数;
    所述合并单元具体用于:
    在第二Map作业包含的第二Map任务中,读取所述第一预设路径下的同一个子路径中的至少两个子文件并进行合并。
  11. 根据权利要求8所述的装置,其特征在于,所述装置还包括:
    对应单元,用于将所述第二Map作业中每个第二Map任务与相应的预设字段的值进行对应;
    所述合并单元具体用于:
    在第二Map作业包含的每个第二Map任务中,根据该第二Map任务对应的预设字段的值,读取与所述预设字段的值对应的所述第二子文件集合中的至少两个子文件并进行合并。
  12. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    第二存储单元,用于将在第一Map作业包含的每一个第一Map任务中切分得到的子文件存储于第二预设路径中;
    所述第一存储单元具体用于:
    将所述第二子文件集合中的包含的数据在所述预设字段上的值一致的至少两个子文件从所述第二预设路径移到第一预设路径下的同一个子路径中。
  13. 根据权利要求12所述的装置,其特征在于,所述第二存储单元还包括:
    第二文件名确定单元,用于确定所述第二预设路径中存放的子文件的文件名中包含该子文件对应的预设字段的值;
    第二路径名确定单元,用于确定所述第二预设路径中存放的子文件对应的存储路径名中包含该子文件对应的第一Map任务的ID;
    所述第一存储单元还包括:
    第一文件名确定单元,用于确定所述第一预设路径中的子文件的文件名中包含该子文件对应的第一Map任务的ID;
    第一路径名确定单元,用于确定所述第一预设路径中的子文件的对应的子路径名包含该对应的预设字段的值。
  14. 根据权利要求8所述的装置,其特征在于,所述预设字段是互联网交易平台生成的交易数据中的商家ID。
PCT/CN2016/104965 2015-11-17 2016-11-08 基于MapReduce的数据处理方法及装置 WO2017084509A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510789816.1A CN106708606B (zh) 2015-11-17 2015-11-17 基于MapReduce的数据处理方法及装置
CN201510789816.1 2015-11-17

Publications (1)

Publication Number Publication Date
WO2017084509A1 true WO2017084509A1 (zh) 2017-05-26

Family

ID=58717328

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/104965 WO2017084509A1 (zh) 2015-11-17 2016-11-08 基于MapReduce的数据处理方法及装置

Country Status (2)

Country Link
CN (1) CN106708606B (zh)
WO (1) WO2017084509A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111382128A (zh) * 2020-03-20 2020-07-07 中国邮政储蓄银行股份有限公司 一种文件的拆分方法、装置及计算机系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102163226A (zh) * 2011-04-12 2011-08-24 浙江大学 基于映射-化简和分词及邻接排序去重方法
CN102831102A (zh) * 2012-07-30 2012-12-19 北京亿赞普网络技术有限公司 一种在计算机集群上进行矩阵乘积运算的方法和系统
CN103500089A (zh) * 2013-09-18 2014-01-08 北京航空航天大学 一种适应于Mapreduce计算模型的小文件存储系统
CN104391748A (zh) * 2014-11-21 2015-03-04 浪潮电子信息产业股份有限公司 一种mapreduce计算过程优化方法
US20150066646A1 (en) * 2013-08-27 2015-03-05 Yahoo! Inc. Spark satellite clusters to hadoop data stores
CN104834557A (zh) * 2015-05-18 2015-08-12 成都博元科技有限公司 一种基于Hadoop的数据分析方法

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101285078B1 (ko) * 2009-12-17 2013-07-17 한국전자통신연구원 스트림 데이터에 대한 점진적인 맵리듀스 기반 분산 병렬 처리 시스템 및 방법
CN103399927B (zh) * 2013-08-05 2016-11-02 百度在线网络技术(北京)有限公司 分布式计算方法和装置
CN104679590B (zh) * 2013-11-27 2018-12-07 阿里巴巴集团控股有限公司 分布式计算系统中的Map优化方法及装置
CN103699441B (zh) * 2013-12-05 2017-07-18 深圳先进技术研究院 基于任务粒度的MapReduce报表任务执行方法
CN104978345B (zh) * 2014-04-09 2018-08-17 中国移动通信集团公司 一种基于MapReduce的数据处理方法和装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102163226A (zh) * 2011-04-12 2011-08-24 浙江大学 基于映射-化简和分词及邻接排序去重方法
CN102831102A (zh) * 2012-07-30 2012-12-19 北京亿赞普网络技术有限公司 一种在计算机集群上进行矩阵乘积运算的方法和系统
US20150066646A1 (en) * 2013-08-27 2015-03-05 Yahoo! Inc. Spark satellite clusters to hadoop data stores
CN103500089A (zh) * 2013-09-18 2014-01-08 北京航空航天大学 一种适应于Mapreduce计算模型的小文件存储系统
CN104391748A (zh) * 2014-11-21 2015-03-04 浪潮电子信息产业股份有限公司 一种mapreduce计算过程优化方法
CN104834557A (zh) * 2015-05-18 2015-08-12 成都博元科技有限公司 一种基于Hadoop的数据分析方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111382128A (zh) * 2020-03-20 2020-07-07 中国邮政储蓄银行股份有限公司 一种文件的拆分方法、装置及计算机系统

Also Published As

Publication number Publication date
CN106708606A (zh) 2017-05-24
CN106708606B (zh) 2020-07-07

Similar Documents

Publication Publication Date Title
US10701140B2 (en) Automated ETL resource provisioner
US11544623B2 (en) Consistent filtering of machine learning data
US9495197B2 (en) Reliable and scalable image transfer for data centers with low connectivity using redundancy detection
US11782892B2 (en) Method and system for migrating content between enterprise content management systems
US9971633B1 (en) Operation efficiency management with respect to application compile-time
US9063992B2 (en) Column based data transfer in extract, transform and load (ETL) systems
US9361323B2 (en) Declarative specification of data integration workflows for execution on parallel processing platforms
US20180074852A1 (en) Compact Task Deployment for Stream Processing Systems
US9372880B2 (en) Reclamation of empty pages in database tables
US20120054182A1 (en) Systems and methods for massive structured data management over cloud aware distributed file system
US9996597B2 (en) Unified mapreduce framework for large-scale data processing
US10706102B2 (en) Operation efficiency management with respect to application run-time
US10789272B2 (en) Scalable, distributed containerization across homogenous and heterogeneous data stores
US11169993B2 (en) Datastore mechanism for managing out-of-memory data
US11740825B2 (en) Object lifecycle management in a dispersed storage system
WO2017084509A1 (zh) 基于MapReduce的数据处理方法及装置
US10037241B2 (en) Category dependent pre-processor for batch commands
US10528400B2 (en) Detecting deadlock in a cluster environment using big data analytics
US20170344586A1 (en) De-Duplication Optimized Platform for Object Grouping

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16865686

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16865686

Country of ref document: EP

Kind code of ref document: A1