WO2018149078A1 - 数据处理的方法、装置、设备以及计算机可读存储介质 - Google Patents
数据处理的方法、装置、设备以及计算机可读存储介质 Download PDFInfo
- Publication number
- WO2018149078A1 WO2018149078A1 PCT/CN2017/090047 CN2017090047W WO2018149078A1 WO 2018149078 A1 WO2018149078 A1 WO 2018149078A1 CN 2017090047 W CN2017090047 W CN 2017090047W WO 2018149078 A1 WO2018149078 A1 WO 2018149078A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- thread
- processing
- processed
- unprocessed
- 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.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5044—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering hardware capabilities
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/466—Transaction processing
Definitions
- the present invention belongs to the field of data processing technologies, and in particular, to a data processing method, apparatus, device, and computer readable storage medium.
- the existing processing of big data usually adopts a single-thread-by-piece data processing method, and has the following disadvantages: (1) As the amount of data increases, the processing time also increases, and the processing efficiency is low; Single-threaded processing, not taking full advantage of hardware resources.
- the present invention provides a data processing method, apparatus, device, and computer readable storage medium to solve the problem that the existing single-thread data processing is long in consumption and the hardware resource utilization rate is low.
- the present invention provides a data processing method, the method comprising:
- each fragment data corresponds to at least one thread.
- the present invention provides an apparatus for data processing, the apparatus comprising:
- a data acquisition module configured to acquire data to be processed, where the data to be processed is preprocessed data
- a data fragmentation module configured to: after receiving the predetermined instruction, segment the data to be processed according to a preset rule to obtain a plurality of fragmentation data;
- a data processing module configured to perform multi-thread processing on the plurality of fragment data, wherein each fragment data corresponds to at least one thread.
- the present invention provides a data processing device, where the data processing device includes: a processor, a memory, and a data processing system, where the data processing system is stored in the memory, including At least one computer readable instruction executable by the processor to:
- each fragment data corresponds to at least one thread.
- the invention provides a computer readable storage medium storing at least one computer readable instruction executable by a processor to:
- each fragment data corresponds to at least one thread.
- the present invention has the beneficial effects compared with the prior art: the present invention performs fragmentation by processing the data, and processes the fragmented data by multi-threading, wherein each fragmentation data corresponds to at least one thread. Since each piece of data is processed concurrently, the waiting time of data processing is reduced, and the efficiency of data processing is improved. Moreover, multi-threaded processing can make more efficient use of processor resources, thus solving the problem of low utilization of existing hardware resources.
- the invention has the advantages of convenient operation, simple implementation and strong ease of use and practicability.
- FIG. 1 is a schematic flowchart of an implementation process of a data processing method according to an embodiment of the present invention
- FIG. 2 is a schematic structural diagram of a device for data processing according to an embodiment of the present invention.
- FIG. 3 is a schematic structural diagram of another component of an apparatus for data processing according to an embodiment of the present invention.
- FIG. 1 is a flowchart of an implementation of a data processing method according to an embodiment of the present invention, which mainly includes the following steps:
- Step S101 Acquire data to be processed, where the data to be processed is preprocessed data.
- the pre-processing includes, but is not limited to, de-duplication processing.
- the deduplication processing includes:
- the method of using the deduplication process relies on less labor, and can effectively improve the accuracy and efficiency of deduplication.
- Step S102 After receiving the predetermined instruction, the data to be processed is fragmented according to a preset rule to obtain a plurality of fragment data.
- the data to be processed may be fragmented according to the number of preset threads, and multiple pieces of fragment data are obtained to ensure that each fragment data corresponds to at least one thread.
- the embodiment of the present invention may further construct a plurality of threads after obtaining the plurality of fragment data, wherein the number of the threads is greater than or equal to the number of the fragment data.
- the fragmenting the data according to a preset rule in the embodiment of the present invention may further include:
- the data is fragmented by using the above preferred solution. If the data to be processed is obtained for the first time, any one of the foregoing two alternatives may be adopted. The first acquired data is fragmented, and the data amount of the first acquired data and the number of fragmented data are recorded.
- the embodiment of the present invention may slice the data to be processed according to a preset rule after receiving a predetermined instruction sent by the user.
- the predetermined instruction may be triggered by a physical button or triggered by a predetermined touch operation instruction.
- the sliding track is vertically sliding, determining whether the displacement of the longitudinal sliding of the two touch points is greater than a preset first threshold, Whether the distance difference between the final points of the two touch points is less than a preset second threshold, and whether the speed at which the two touch points slide is greater than a preset third threshold; or when the touch action is detected as two points After the sliding track is slid in the opposite direction, it is determined whether the displacement of the two touch points in the opposite direction is greater than the preset first threshold, and the distance difference between the final touch points of the two touch points is greater than the preset fourth.
- a threshold value a threshold value, and whether the speed at which the two touch points slide is greater than a preset third threshold value. If yes (ie, the above three condition determination results are all "Yes"), it is determined that the predetermined instruction is triggered, and the preset is started. Setting a rule to slice the data to be processed; if not, that is, if at least one of the determination results of the above three conditions is "No", the process is not executed, and the current is ended. For, i.e. the data to be processed does not fragmented.
- Step S103 Perform multi-thread processing on the plurality of fragment data, where each fragment data corresponds to at least one thread.
- each fragment data determines whether the data amount of each fragment data is the same, and if yes, randomly assigning at least one thread for processing each fragment data; if not, according to the data size of each fragment data Choose the thread that handles the best performance for processing. For example, the data amount of each piece of data is in descending order, B, C, and the processing performance of each thread is 1, 2, 3 in order of high to low; then the largest amount of data is A, Select the thread with the highest processing performance; the remaining B and C have the largest amount of data B, and the remaining threads 2 and 3 select the thread with the highest processing performance; Finally, the corresponding thread for each piece of data is Al, B. -2, C-3.
- the data to be processed is sliced, and the data after the fragmentation is processed by using multiple threads, which can effectively reduce the waiting time of data processing and improve the efficiency of data processing.
- multi-threaded processing can make more efficient use of processor resources, thus solving the problem of low utilization of existing hardware resources.
- the embodiment of the present invention may also process the unprocessed data of the thread.
- the number of completed threads or the number of threads whose unprocessed data is less than the third preset value is re-sliced, and the re-sliced data is forwarded to the processed thread or the unprocessed data is less than the third preset value. Thread processing, which can effectively ensure the processing of data.
- the embodiment of the present invention creates a new thread, forwards the unprocessed data of the thread to the new thread processing, and marks the thread that fails the data processing. Or end the thread;
- the unprocessed data of the thread may be forwarded to the thread corresponding to the last fragment data.
- the data volume of the last fragment data is generally small (for example, 97 M data, 10 equal parts according to the rounding principle, the data volume of the last fragment data is 7M) Therefore, the thread processing corresponding to the last fragment data is relatively short, and the unprocessed data of the thread that failed in data processing can be forwarded to the thread corresponding to the last fragment data.
- the embodiment of the present invention first detects whether the unprocessed data of the thread is greater than a fourth preset value, and if so, creates a new thread, and the thread is not processed. Data is forwarded to the new thread for processing, and the thread that failed the data processing is marked or the thread is terminated; if not, the data originally divided by the last fragment data is detected and/or the last fragment data is not Whether the processed data is the least, if it is the least, the unprocessed data of the thread is forwarded to the thread corresponding to the last fragment data.
- the embodiment of the present invention first obtains one thread with the least amount of unprocessed data, and forwards the unprocessed data of the thread to the thread corresponding to the last fragment data; For each thread that fails to process each data, create a new thread, and forward the unprocessed data of the data processing failed thread to a new thread, where each processing fails.
- the unprocessed data of the thread corresponds to at least one new thread.
- the number of threads that fail to be processed by the data is three, namely, thread 1, thread 2, and thread 3, wherein, if thread 1 has the least amount of unprocessed data, the unprocessed data corresponding to thread 1 is forwarded to the last one.
- the thread processing corresponding to the fragment data For thread 2 and thread 3, create at least two new threads, such as thread 4 and thread 5, forward thread 2 unprocessed data to thread 4 for processing, and thread 3 unprocessed data to thread 5 for processing. It is also possible to create three new threads, for example, threads 6, 7, 8, 9, and forward unprocessed data of thread 2 to threads 6, 7 and unprocessed data of thread 3 to threads 8, 9 for processing. According to the actual situation, it will not be repeated here.
- FIG. 2 is a schematic structural diagram of a device for data processing according to an embodiment of the present invention. For the convenience of description, only parts related to the embodiment of the present invention are shown.
- the device for data processing may be a software unit, a hardware unit or a unit that is built in a terminal (for example, a computer), or may be integrated into the terminal as a separate pendant.
- the device for data processing includes:
- the data obtaining module 21 is configured to acquire data to be processed, where the data to be processed is preprocessed data;
- the data fragmentation module 22 is configured to: after receiving the predetermined instruction, segment the data to be processed according to a preset rule to obtain a plurality of fragment data;
- the data processing module 23 is configured to perform multi-thread processing on the plurality of fragment data, wherein each fragment data corresponds to at least one thread.
- the data fragmentation module 22 includes:
- the recording unit 221 is configured to record the data amount X of the data to be processed last time and the number Q of the last fragmentation data;
- the obtaining unit 222 is configured to acquire a data amount Y of the current data to be processed
- the fragmentation unit 224 is configured to slice the current data to be processed according to the P, and obtain P pieces of slice data.
- the device further includes:
- the thread construction module 24 is configured to slice the data to be processed according to a preset rule, and obtain multiple After fragmenting the data, a plurality of threads are constructed, wherein the number of threads is greater than or equal to the number of the fragmented data.
- the data processing module 23 includes:
- the first processing unit 231 is configured to determine whether the data amount of each fragment data is the same, and if yes, randomly allocate at least one thread for processing each fragment data; if not, according to each fragment data The amount of data is sequentially selected to process the thread with the best performance;
- the second processing unit 232 is configured to: when the data processing speed of a thread is less than the first preset value and/or the processing time is greater than the second preset value, the unprocessed data of the thread is processed according to the processed The number of threads or the number of threads whose unprocessed data is smaller than the third preset value is fragmented again, and the data after the fragmentation is forwarded to the processed thread or the thread whose unprocessed data is smaller than the third preset value is processed. Wherein each thread corresponds to one piece of data that is again fragmented;
- the third processing unit 233 when there is a thread that fails data processing, first detecting whether the unprocessed data of the thread is greater than a fourth preset value, and if so, creating a new thread, the unprocessed data of the thread Forwarding to the new thread processing, and marking or ending the thread that failed the data processing; if not, detecting that the first fragmented data is initially divided and/or the last fragmented data is currently unprocessed Whether the data is the least, if it is the least, the unprocessed data of the thread is forwarded to the thread corresponding to the last fragment data; when there are N data processing failure threads, one of the unprocessed data is the least thread Corresponding unprocessed data is forwarded to the thread processing corresponding to the last fragment data, and at least N-1 new threads are created for the remaining N-1 data processing failed threads, and the thread that failed the data processing is not The processed data is forwarded to the new thread processing, where each data processing failed thread unprocessed data corresponds
- each functional module in the foregoing device may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit, and the integrated unit may be implemented in the form of hardware. , can also be implemented in the form of software functional units.
- the specific names of the functional modules are only for It is convenient to distinguish between each other and is not intended to limit the scope of protection of the present application.
- FIG. 3 is a schematic block diagram of an apparatus for data processing according to Embodiment 3 of the present invention.
- the apparatus for data processing as shown may include: one or more processors 301 (only one shown); one or more input devices 302 (only one shown), one or more outputs Device 303 (only one is shown), memory 304.
- the above processor 301, input device 302, output device 303, and memory 304 are connected by a bus 305.
- the memory 302 is used to store instructions, the processor 301
- the processor 301 is configured to acquire data to be processed by using the input device 302, where the to-be-processed data is pre-processed data;
- the processor 301 is further configured to: after receiving the predetermined instruction by the input device 302, segment the data to be processed according to a preset rule, obtain a plurality of fragment data, and obtain a plurality of fragment data.
- the plurality of fragmented data are multi-threaded, wherein each of the fragmented data corresponds to at least one thread.
- the processor 301 is further configured to record the data quantity X of the last data to be processed and the quantity Q of the last fragmented data, and acquire the current data to be processed by the input device 302.
- the processor 301 is further configured to slice the data to be processed according to a preset rule, and after obtaining multiple pieces of fragment data, construct a plurality of threads, where the number of the threads Greater than or equal to the number of fragmented data.
- the processor 301 is further configured to determine whether the data amount of each fragment data is the same, and if yes, randomly allocate at least one thread for processing each fragment data; if not, according to each The data size of the fragmented data is sequentially selected to be processed by the thread with the best processing performance;
- the processor 301 is further configured to: when the data processing speed of a thread is less than the first preset value or the processing time is greater than the second preset value, the unprocessed data of the thread is processed according to The number of completed threads or the number of threads whose unprocessed data is less than the third preset value is re-sliced, and the re-sliced data is forwarded to the processed thread or the unprocessed data is less than the third preset value. Thread processing; wherein each thread corresponds to one piece of data that is fragmented again.
- the processor 301 is further configured to: when there is a thread that fails data processing, first detect whether the unprocessed data of the thread is greater than a fourth preset value, and if so, create a new thread, The unprocessed data of the thread is forwarded to the new thread processing, and the thread that failed the data processing is marked or the thread is terminated; if not, the data originally divided by the last fragment data is detected and/or the last one Whether the data currently unprocessed by the fragment data is the least, if it is the least, the unprocessed data of the thread is forwarded to the thread corresponding to the last fragment data; when there are N data processing failure threads, one of them will be The unprocessed data corresponding to the thread with the least unprocessed data is forwarded to the thread processing corresponding to the last fragment data, and at least N-1 new threads are created for the remaining N-1 data processing failed threads, Data processing failed thread unprocessed data is forwarded to new thread processing, where each data processing failed
- the embodiment of the present invention may also display a process of data processing by using the output device 303.
- the memory 304 is configured to store a software program and a module.
- the processor 301 executes various functional applications and data processing by running software programs and modules stored in the memory 304.
- the processor 301 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processor). , DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc.
- the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
- the input device 302 may include a touch panel, a fingerprint sensor (for collecting fingerprint information of the user and direction information of the fingerprint), a microphone, a data receiving interface, and the like.
- the output device 303 can include a display (LC D, etc.), a speaker, a data transmission interface, and the like.
- the memory 304 can include read only memory and random access memory and provides instructions and data to the processor 301.
- a portion of memory 304 may also include non-volatile random access memory.
- the memory 304 can also store information of the device type.
- the processor 301, the input device 302, the output device 303, and the memory 304 described in the embodiment of the present invention may be described in the embodiment of the data processing method provided by the embodiment of the present invention.
- the implementation manner described in the apparatus for data processing in the second embodiment can also be implemented, and details are not described herein again.
- Embodiment 4 of the present invention further provides a data processing device, where the data processing device includes: a processor, a memory, and a data processing system, where the data processing system is stored in the memory, including at least A computer readable instruction, the at least one computer readable instruction being executable by the processor to:
- each fragment data corresponds to at least one thread.
- the fragmenting the data to be processed according to a preset rule comprises:
- performing multi-thread processing on the multiple fragment data includes:
- the at least one computer readable instruction may also be executed by the processor to: • [0097] construct a plurality of threads, wherein the number of threads is greater than or equal to the number of sliced data.
- the performing multi-thread processing on the multiple fragment data further includes:
- the unprocessed data of the thread is smaller according to the number of processed threads or unprocessed data.
- the number of threads of the third preset value is fragmented again, and the data after the fragmentation is forwarded to the processed thread or the thread whose unprocessed data is smaller than the third preset value; wherein, each thread corresponds to one thread Fragmented data again.
- the performing multi-thread processing on the multiple fragment data further includes:
- the unprocessed data corresponding to the thread with the least unprocessed data is forwarded to the thread processing corresponding to the last fragment data, and processed for the remaining N-1 data.
- the failed thread creating at least N-1 new threads, forwarding the unprocessed data of the data processing failed thread to a new thread processing, wherein each data processing failed thread unprocessed data corresponds to at least one new one Thread, where N is an integer greater than one.
- Embodiment 5 of the present invention also provides a computer readable storage medium storing at least one computer readable instruction executable by a processor to:
- the fragmenting the data to be processed according to a preset rule comprises:
- the current data to be processed is fragmented according to the P, and P pieces of fragment data are obtained.
- the at least one computer readable instruction is further executable by the processor to:
- performing multi-thread processing on the multiple fragment data includes:
- the performing multi-thread processing on the multiple fragment data further includes:
- the unprocessed data of the thread is smaller according to the number of processed threads or the unprocessed data.
- the number of threads of the third preset value is fragmented again, and the data after the fragmentation is forwarded to the processed thread or the thread whose unprocessed data is smaller than the third preset value; wherein, each thread corresponds to one thread Fragmented data again.
- the performing multi-thread processing on the multiple fragment data further includes:
- the unprocessed data corresponding to the thread with the least unprocessed data is forwarded to the thread processing corresponding to the last fragment data, and processed for the remaining N-1 data.
- the failed thread creating at least N-1 new threads, forwarding the unprocessed data of the data processing failed thread to a new thread processing, wherein each data processing failed thread unprocessed data corresponds to at least one new one Thread, where N is an integer greater than one.
- the disclosed data processing method, apparatus, device, and computer readable storage medium may be implemented in other manners.
- the embodiments described above are merely illustrative, for example, the division of the modules or units is merely a logical function. Can be divided, the actual implementation can have another way of division, for example, multiple units or components can be combined or can be integrated into another system, or some features can be ignored, or not executed.
- the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
- the unit described as a separate component may or may not be physically distributed, and the component displayed as a unit may or may not be a physical unit, that is, may be located in one place, or may be distributed to multiple On the network unit. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
- each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
- the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
- the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
- the medium includes a plurality of instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the methods of the various embodiments of the embodiments of the present invention.
- the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (R 0M, Read-Only Memory), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. medium.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Retry When Errors Occur (AREA)
Abstract
数据处理的方法、装置、设备以及计算机可读存储介质。所述方法包括:获取待处理的数据,所述待处理的数据为预处理后的数据;在接收到预定指令时,按预设规则对所述待处理的数据进行分片,获得多个分片数据;对所述多个分片数据进行多线程处理,其中每个分片数据对应至少一个线程。通过对所述数据进行分片,采用多线程处理分片后的数据,可以有效提高数据处理的效率以及硬件资源的利用率。
Description
发明名称:数据处理的方法、 装置、 设备以及计算机可读存储介质 技术领域
[0001] 本发明属于数据处理技术领域, 尤其涉及数据处理的方法、 装置、 设备以及计 算机可读存储介质。
背景技术
[0002] 现有对大数据的处理, 通常采用的是单线程逐条数据处理的方式, 存在如下缺 点: (1) 随着数据量的增加, 处理吋间也增长, 处理效率较低; (2) 单线程 处理方式, 没有充分利用硬件资源。
[0003] 故, 有必要提出一种新的技术方案, 以解决上述技术问题。
技术问题
[0004] 鉴于此, 本发明提供一种数据处理的方法、 装置、 设备以及计算机可读存储介 质, 以解决现有单线程数据处理耗吋较长、 硬件资源利用率低的问题。
问题的解决方案
技术解决方案
[0005] 第一方面, 本发明提供了一种数据处理的方法, 所述方法包括:
[0006] 获取待处理的数据, 所述待处理的数据为预处理后的数据;
[0007] 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获得多个分 片数据;
[0008] 对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一个线程。
[0009] 第二方面, 本发明提供了一种数据处理的装置, 所述装置包括:
[0010] 数据获取模块, 用于获取待处理的数据, 所述待处理的数据为预处理后的数据
[0011] 数据分片模块, 用于在接收到预定指令吋, 按预设规则对所述待处理的数据进 行分片, 获得多个分片数据;
[0012] 数据处理模块, 用于对所述多个分片数据进行多线程处理, 其中每个分片数据 对应至少一个线程。
[0013] 第三方面, 本发明提供了一种数据处理的设备, 所述数据处理的设备包括: 处 理器、 存储器及数据处理的系统, 所述数据处理的系统存储于所述存储器中, 包括至少一个计算机可读指令, 该至少一个计算机可读指令可被所述处理器执 行, 以实现以下操作:
[0014] 获取待处理的数据, 所述待处理的数据为预处理后的数据;
[0015] 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获得多个分 片数据;
[0016] 对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一个线程。
[0017] 第四方面, 本发明提供了一种计算机可读存储介质, 所述计算机可读存储介质 存储有至少一个可被处理器执行以实现以下操作的计算机可读指令:
[0018] 获取待处理的数据, 所述待处理的数据为预处理后的数据;
[0019] 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获得多个分 片数据;
[0020] 对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一个线程。
发明的有益效果
有益效果
[0021] 本发明与现有技术相比存在的有益效果是: 本发明通过对待处理的数据进行分 片, 并采用多线程处理分片后的数据, 其中每个分片数据对应至少一个线程。 由于每个分片数据都是并发处理的, 从而减少了数据处理的等待吋间, 提高了 数据处理的效率。 而且, 多线程的处理方式可以更有效的利用处理器资源, 从 而解决现有硬件资源利用率低的问题。 本发明操作方便、 实现简单, 具有较强 的易用性和实用性。
对附图的简要说明
附图说明
[0022] 为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例或现有技术描 述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是 本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动性 的前提下, 还可以根据这些附图获得其他的附图。
[0023] 图 1是本发明实施例提供的数据处理的方法的实现流程示意图;
[0024] 图 2是本发明实施例提供的数据处理的装置的组成结构示意图;
[0025] 图 3是本发明实施例提供的数据处理的装置的另一组成结构示意图。
本发明的实施方式
[0026] 以下描述中, 为了说明而不是为了限定, 提出了诸如特定系统结构、 技术之类 的具体细节, 以便透切理解本发明实施例。 然而, 本领域的技术人员应当清楚 , 在没有这些具体细节的其它实施例中也可以实现本发明。 在其它情况中, 省 略对众所周知的系统、 装置、 电路以及方法的详细说明, 以免不必要的细节妨 碍本发明的描述。
[0027] 为了说明本发明所述的技术方案, 下面通过具体实施例来进行说明。
[0028] 请参阅图 1, 为本发明实施例提供的数据处理的方法的实现流程, 其主要包括 以下步骤:
[0029] 步骤 S101, 获取待处理的数据, 所述待处理的数据为预处理后的数据。
[0030] 在本发明实施例中, 所述预处理包括但不限于去重处理。 其中, 所述去重处理 包括:
[0031] 数据之间两两进行相似度比对, 根据相似度进行打分, 并按照得分的高低进行 相似度排序, 最后再由人工排査去重。
[0032] 采用该去重处理的方式依赖人工较少, 并可有效提高去重的准确率以及效率。
[0033] 步骤 S102, 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获得多个分片数据。
[0034] 可选的, 本发明实施例可以根据预设线程的数量对所述待处理的数据进行分片 , 获得多个分片数据, 以保证每个分片数据对应至少一个线程。
[0035] 可选的, 本发明实施例还可以在获得多个分片数据之后, 构建多个线程, 其中 所述线程的数量大于或等于所述分片数据的数量。
[0036] 较佳的, 本发明实施例所述按预设规则对所述数据进行分片还可以包括:
[0037] 记录上一次待处理的数据的数据量 X以及上一次分片数据的数量 Q;
[0038] 获取当前待处理的数据的数据量 Y;
[0039] 根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
[0040] 根据所述 P对所述当前待处理的数据进行分片, 获得 P个分片数据。
[0041] 需要说明的是, 本发明实施例在采用上述较佳方案对数据进行分片吋, 如果是 第一次获取待处理的数据, 则可以采用上述两个可选方案中的任一方案对所述 第一次获取的数据进行分片, 并记录所述第一次获取的数据的数据量以及分片 数据的数量。
[0042] 另外, 为了避免误操作, 本发明实施例可以在接收到用户发出的预定指令后再 按预设规则对所述待处理的数据进行分片。 其中, 所述预定指令可以通过某一 物理按键触发, 也可以通过预定的触摸操作指令触发。 示例性的, 可以在监测 到用户在终端触摸屏上的触摸动作为两点触摸且滑动轨迹为纵向相对滑动后, 判断两触摸点纵向相对滑动的位移是否同吋大于预设的第一阈值、 所述两触摸 点最终落点的距离差是否小于预设的第二阈值、 且所述两触摸点滑动的速度是 否同吋大于预设的第三阈值; 或者在监测到所述触摸动作为两点触摸且所述滑 动轨迹为相反方向滑动后, 判断两触摸点相反方向滑动的位移是否同吋大于预 设的第一阈值、 所述两触摸点最终落点的距离差是否大于预设的第四阈值、 且 所述两触摸点滑动的速度是否同吋大于预设的第三阈值, 若是 (即上述三个条 件判断结果都为"是") , 则确定触发所述预定指令, 幵始按预设规则对所述待处 理的数据进行分片; 若否, 即上述三个条件的判断结果至少有一个为"否", 则不 执行, 结束当前操作, 即不对所述待处理的数据进行分片。
[0043] 步骤 S103, 对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少 一个线程。
[0044] 具体的, 判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随 机分配至少一个线程进行处理; 若否, 则根据每个分片数据的数据量大小依次 选择处理性能最优的线程进行处理。 例如每个分片数据的数据量从大到小的顺 序依次为 、 B、 C, 每个线程的处理性能从高到低的顺序依次为 1、 2、 3; 则数 据量最大的为 A, 选择处理性能最高的线程 1 ; 剩下的 B和 C中数据量最大的为 B , 在剩下的线程 2和 3中选择处理性能最高的线程 2; 最后每片数据对应的线程为 A-l、 B-2、 C-3。
[0045] 本发明实施例通过对待处理的数据进行分片, 并采用多线程处理分片后的数据 , 可有效减少数据处理的等待吋间, 提高数据处理的效率。 而且, 多线程的处 理方式可以更有效的利用处理器资源, 从而解决现有硬件资源利用率低的问题
[0046] 较佳的, 当某线程的数据处理速度小于第一预设值和 /或处理吋间大于第二预 设值吋, 本发明实施例还可以对该线程未处理的数据按照已处理完的线程的数 量或者未处理数据小于第三预设值的线程的数量进行再次分片, 并将再次分片 后的数据转发给已处理完的线程或者未处理数据小于第三预设值的线程处理, 从而能够有效保证数据的及吋处理。
[0047] 另外, 当某线程的数据处理失败吋, 本发明实施例会创建新的线程, 将该线程 未处理的数据转发给所述新的线程处理, 并对所述数据处理失败的线程进行标 记或结束该线程;
[0048] 较佳的, 当某线程的数据处理失败吋, 还可以将该线程未处理的数据转发给最 后一个分片数据对应的线程处理。
[0049] 在实际的数据处理中发现, 最后一个分片数据的数据量一般都较少 (例如, 97 M数据, 按照取整原则进行 10等份, 则最后一个分片数据的数据量为 7M) , 因 此最后一个分片数据对应的线程处理吋间较短, 可以将数据处理失败的线程未 处理的数据转发给最后一个分片数据对应的线程处理。
[0050] 较佳的, 当存在某一个数据处理失败的线程吋, 本发明实施例先检测该线程未 处理的数据是否大于第四预设值, 若是, 创建新的线程, 将该线程未处理的数 据转发给所述新的线程处理, 并对所述数据处理失败的线程进行标记或结束该 线程; 若否, 检测最后一个分片数据最初所划分的数据和 /或最后一个分片数据 未处理的数据是否为最少, 若为最少, 则将该线程未处理的数据转发给最后一 个分片数据对应的线程处理。
[0051] 当存在多个数据处理失败的线程吋, 本发明实施例先获取其中一个未处理数据 最少的线程, 并将该线程未处理的数据转发给最后一个分片数据对应的线程处 理; 再针对剩余的每一个数据处理失败的线程, 创建多个新的线程, 将所述数 据处理失败的线程未处理的数据转发给的新的线程处理, 其中每一个处理失败
的线程未处理的数据对应至少一个新的线程。
[0052] 例如, 数据处理失败的线程为三个, 分别为线程 1、 线程 2以及线程 3, 其中, 线程 1对应的未处理数据最少, 则将该线程 1对应的未处理数据转发给最后一个 分片数据对应的线程处理。 针对线程 2和线程 3, 创建至少两个新的线程, 例如 线程 4和线程 5, 将线程 2未处理的数据转发给线程 4处理, 线程 3未处理的数据转 发给线程 5处理。 也可以创建三个新的线程, 例如线程 6、 7、 8、 9, 将线程 2未 处理的数据转发给线程 6、 7处理, 线程 3未处理的数据转发给线程 8、 9处理, 具 体可以根据实际情况而定, 在此不再赘述。
[0053] 请参阅图 2, 为本发明实施例提供的数据处理的装置的组成结构示意图。 为了 便于说明, 仅示出了与本发明实施例相关的部分。
[0054] 所述数据处理的装置可以是内置于终端 (例如计算机) 内的软件单元、 硬件单 元或者是软硬结合的单元, 也可以作为独立的挂件集成到所述终端中。
[0055] 所述数据处理的装置包括:
[0056] 数据获取模块 21, 用于获取待处理的数据, 所述待处理的数据为预处理后的数 据;
[0057] 数据分片模块 22, 用于在接收到预定指令吋, 按预设规则对所述待处理的数据 进行分片, 获得多个分片数据;
[0058] 数据处理模块 23, 用于对所述多个分片数据进行多线程处理, 其中每个分片数 据对应至少一个线程。
[0059] 可选的, 所述数据分片模块 22包括:
[0060] 记录单元 221, 用于记录上一次待处理的数据的数据量 X以及上一次分片数据的 数量 Q;
[0061] 获取单元 222, 用于获取当前待处理的数据的数据量 Y;
[0062] 计算单元 223, 用于根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
[0063] 分片单元 224, 用于根据所述 P对所述当前待处理的数据进行分片, 获得 P个分 片数据。
[0064] 可选的, 所述装置还包括:
[0065] 线程构建模块 24, 用于在按预设规则对所述待处理的数据进行分片, 获得多个
分片数据之后, 构建多个线程, 其中所述线程的数量大于或等于所述分片数据 的数量。
[0066] 可选的, 所述数据处理模块 23包括:
[0067] 第一处理单元 231, 用于判断每个分片数据的数据量是否相同, 若是, 则针对 每个分片数据随机分配至少一个线程进行处理; 若否, 则根据每个分片数据的 数据量大小依次选择处理性能最优的线程进行处理;
[0068] 第二处理单元 232, 用于当某线程的数据处理速度小于第一预设值和 /或处理吋 间大于第二预设值吋, 对该线程未处理的数据按照已处理完的线程的数量或者 未处理数据小于第三预设值的线程的数量进行再次分片, 并将再次分片后的数 据转发给已处理完的线程或者未处理数据小于第三预设值的线程处理; 其中, 每个线程对应一个再次分片的数据;
[0069] 第三处理单元 233, 当存在某一个数据处理失败的线程吋, 先检测该线程未处 理的数据是否大于第四预设值, 若是, 创建新的线程, 将该线程未处理的数据 转发给所述新的线程处理, 并对所述数据处理失败的线程进行标记或结束该线 程; 若否, 检测最后一个分片数据最初所划分的数据和 /或最后一个分片数据当 前未处理的数据是否为最少, 若为最少, 则将该线程未处理的数据转发给最后 一个分片数据对应的线程处理; 当存在 N个数据处理失败的线程吋, 将其中一个 未处理数据最少的线程对应的未处理数据转发给最后一个分片数据对应的线程 处理, 并针对剩余的 N-1个数据处理失败的线程, 创建至少 N-1个新的线程, 将 所述数据处理失败的线程未处理的数据转发给新的线程处理, 其中每一个数据 处理失败的线程未处理的数据对应至少一个新的线程, 其中 N为大于 1的整数。
[0070] 所属领域的技术人员可以清楚地了解到, 为了描述的方便和简洁, 仅以上述各 功能模块的划分进行举例说明, 实际应用中, 可以根据需要而将上述功能分配 由不同的功能单元、 模块完成, 即将所述装置的内部结构划分成不同的功能单 元或模块, 以完成以上描述的全部或者部分功能。 实施例中的各功能模块可以 集成在一个处理单元中, 也可以是各个单元单独物理存在, 也可以两个或两个 以上单元集成在一个单元中, 上述集成的单元既可以采用硬件的形式实现, 也 可以采用软件功能单元的形式实现。 另外, 各功能模块的具体名称也只是为了
便于相互区分, 并不用于限制本申请的保护范围。 上述装置中模块的具体工作 过程, 可以参考前述方法实施例中的对应过程, 在此不再赘述。
[0071] 请参阅图 3, 是本发明实施例三提供的数据处理的装置的示意框图。 如图所示 的该数据处理的装置可以包括: 一个或多个处理器 301 (图中仅示出一个) ; 一 个或多个输入设备 302 (图中仅示出一个) , 一个或多个输出设备 303 (图中仅 示出一个) 、 存储器 304。 上述处理器 301、 输入设备 302、 输出设备 303、 存储 器 304通过总线 305连接。 存储器 302用于存储指令, 处理器 301
用于执行存储器 302存储的指令。 其中:
[0072] 所述处理器 301, 用于通过所述输入设备 302获取待处理的数据, 所述待处理的 数据为预处理后的数据;
[0073] 所述处理器 301, 还用于在通过所述输入设备 302接收到预定指令吋, 按预设规 则对所述待处理的数据进行分片, 获得多个分片数据, 并对所述多个分片数据 进行多线程处理, 其中每个分片数据对应至少一个线程。
[0074] 可选的, 所述处理器 301还用于记录上一次待处理的数据的数据量 X以及上一次 分片数据的数量 Q, 并通过所述输入设备 302获取当前待处理的数据的数据量 Y, 根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y), 根据所述 P对所述当前待处理的 数据进行分片, 获得 P个分片数据。
[0075] 可选的, 所述处理器 301还用于在按预设规则对所述待处理的数据进行分片, 获得多个分片数据之后, 构建多个线程, 其中所述线程的数量大于或等于所述 分片数据的数量。
[0076] 可选的, 所述处理器 301还用于判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随机分配至少一个线程进行处理; 若否, 则根据每个分片 数据的数据量大小依次选择处理性能最优的线程进行处理;
[0077] 可选的, 所述处理器 301还用于当某线程的数据处理速度小于第一预设值或者 处理吋间大于第二预设值吋, 对该线程未处理的数据按照已处理完的线程的数 量或者未处理数据小于第三预设值的线程的数量进行再次分片, 并将再次分片 后的数据转发给已处理完的线程或者未处理数据小于第三预设值的线程处理; 其中, 每个线程对应一个再次分片的数据。
[0078] 可选的, 所述处理器 301还用于当存在某一个数据处理失败的线程吋, 先检测 该线程未处理的数据是否大于第四预设值, 若是, 创建新的线程, 将该线程未 处理的数据转发给所述新的线程处理, 并对所述数据处理失败的线程进行标记 或结束该线程; 若否, 检测最后一个分片数据最初所划分的数据和 /或最后一个 分片数据当前未处理的数据是否为最少, 若为最少, 则将该线程未处理的数据 转发给最后一个分片数据对应的线程处理; 当存在 N个数据处理失败的线程吋, 将其中一个未处理数据最少的线程对应的未处理数据转发给最后一个分片数据 对应的线程处理, 并针对剩余的 N-1个数据处理失败的线程, 创建至少 N-1个新 的线程, 将所述数据处理失败的线程未处理的数据转发给新的线程处理, 其中 每一个数据处理失败的线程未处理的数据对应至少一个新的线程, 其中 N为大于 1的整数。
[0079] 可选的, 本发明实施例还可以通过输出设备 303显示数据处理的过程。
[0080] 所述存储器 304, 用于存储软件程序以及模块。 所述处理器 301通过运行存储在 所述存储器 304的软件程序以及模块, 从而执行各种功能应用以及数据处理。
[0081] 应当理解, 在本发明实施例中, 所述处理器 301可以是中央处理单元 (Central Processing Unit, CPU) , 该处理器还可以是其他通用处理器、 数字信号处理器 (Digital Signal Processor, DSP)、 专用集成电路 (Application Specific Integrated Circuit, ASIC)、 现成可编程门阵列(Field-Programmable Gate Array, FPGA)或 者其他可编程逻辑器件、 分立门或者晶体管逻辑器件、 分立硬件组件等。 通用 处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
[0082] 输入设备 302可以包括触控板、 指纹采传感器 (用于采集用户的指纹信息和指 纹的方向信息) 、 麦克风、 数据接收接口等。 输出设备 303可以包括显示器 (LC D等) 、 扬声器、 数据发送接口等。
[0083] 该存储器 304可以包括只读存储器和随机存取存储器, 并向处理器 301提供指令 和数据。 存储器 304的一部分还可以包括非易失性随机存取存储器。 例如, 存储 器 304还可以存储设备类型的信息。
[0084] 具体实现中, 本发明实施例中所描述的处理器 301、 输入设备 302、 输出设备 30 3、 存储器 304可执行本发明实施例提供的数据处理的方法的实施例中所描述的
实现方式, 也可执行实施例二所述数据处理的装置中所描述的实现方式, 在此 不再赘述。
[0085] 本发明实施例四还提供一种数据处理的设备, 所述数据处理的设备包括: 处理 器、 存储器及数据处理的系统, 所述数据处理的系统存储于所述存储器中, 包 括至少一个计算机可读指令, 该至少一个计算机可读指令可被所述处理器执行 , 以实现以下操作:
[0086] 获取待处理的数据, 所述待处理的数据为预处理后的数据;
[0087] 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获得多个分 片数据;
[0088] 对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一个线程。
[0089] 可选地, 所述按预设规则对所述待处理的数据进行分片包括:
[0090] 记录上一次待处理的数据的数据量 X以及上一次分片数据的数量 Q;
[0091] 获取当前待处理的数据的数据量 Y;
[0092] 根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
[0093] 根据所述 P对所述当前待处理的数据进行分片, 获得 P个分片数据。
[0094] 可选地, 对所述多个分片数据进行多线程处理包括:
[0095] 判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随机分配至 少一个线程进行处理; 若否, 则根据每个分片数据的数据量大小依次选择处理 性能最优的线程进行处理。
[0096] 可选地, 在按预设规则对所述待处理的数据进行分片, 获得多个分片数据之后
, 所述至少一个计算机可读指令还可被所述处理器执行, 以实现以下操作: : [0097] 构建多个线程, 其中所述线程的数量大于或等于所述分片数据的数量。
[0098] 可选地, 所述对所述多个分片数据进行多线程处理还包括:
[0099] 当某线程的数据处理速度小于第一预设值和 /或处理吋间大于第二预设值吋, 对该线程未处理的数据按照已处理完的线程的数量或者未处理数据小于第三预 设值的线程的数量进行再次分片, 并将再次分片后的数据转发给已处理完的线 程或者未处理数据小于第三预设值的线程处理; 其中, 每个线程对应一个再次 分片的数据。
[0100] 可选地于, 所述对所述多个分片数据进行多线程处理还包括:
[0101] 当存在某一个数据处理失败的线程吋, 先检测该线程未处理的数据是否大于第 四预设值, 若是, 创建新的线程, 将该线程未处理的数据转发给所述新的线程 处理, 并对所述数据处理失败的线程进行标记或结束该线程; 若否, 检测最后 一个分片数据最初所划分的数据和 /或最后一个分片数据当前未处理的数据是否 为最少, 若为最少, 则将该线程未处理的数据转发给最后一个分片数据对应的 线程处理;
[0102] 当存在 N个数据处理失败的线程吋, 将其中一个未处理数据最少的线程对应的 未处理数据转发给最后一个分片数据对应的线程处理, 并针对剩余的 N-1个数据 处理失败的线程, 创建至少 N-1个新的线程, 将所述数据处理失败的线程未处理 的数据转发给新的线程处理, 其中每一个数据处理失败的线程未处理的数据对 应至少一个新的线程, 其中 N为大于 1的整数。
[0103] 本发明实施例五还提供一种计算机可读存储介质, 所述计算机可读存储介质存 储有至少一个可被处理器执行以实现以下操作的计算机可读指令:
[0104] 获取待处理的数据, 所述待处理的数据为预处理后的数据;
[0105] 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获得多个分 片数据;
[0106] 对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一个线程。
[0107] 可选地, 所述按预设规则对所述待处理的数据进行分片包括:
[0108] 记录上一次待处理的数据的数据量 X以及上一次分片数据的数量 Q;
[0109] 获取当前待处理的数据的数据量 Y;
[0110] 根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
[0111] 根据所述 P对所述当前待处理的数据进行分片, 获得 P个分片数据。
[0112] 可选地, 所述至少一个计算机可读指令还可被所述处理器执行, 以实现以下操 作:
[0113] 构建多个线程, 其中所述线程的数量大于或等于所述分片数据的数量。
[0114] 可选地, 对所述多个分片数据进行多线程处理包括:
[0115] 判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随机分配至
少一个线程进行处理; 若否, 则根据每个分片数据的数据量大小依次选择处理 性能最优的线程进行处理。
[0116] 可选地, 所述对所述多个分片数据进行多线程处理还包括:
[0117] 当某线程的数据处理速度小于第一预设值和 /或处理吋间大于第二预设值吋, 对该线程未处理的数据按照已处理完的线程的数量或者未处理数据小于第三预 设值的线程的数量进行再次分片, 并将再次分片后的数据转发给已处理完的线 程或者未处理数据小于第三预设值的线程处理; 其中, 每个线程对应一个再次 分片的数据。
[0118] 可选地, 所述对所述多个分片数据进行多线程处理还包括:
[0119] 当存在某一个数据处理失败的线程吋, 先检测该线程未处理的数据是否大于第 四预设值, 若是, 创建新的线程, 将该线程未处理的数据转发给所述新的线程 处理, 并对所述数据处理失败的线程进行标记或结束该线程; 若否, 检测最后 一个分片数据最初所划分的数据和 /或最后一个分片数据当前未处理的数据是否 为最少, 若为最少, 则将该线程未处理的数据转发给最后一个分片数据对应的 线程处理;
[0120] 当存在 N个数据处理失败的线程吋, 将其中一个未处理数据最少的线程对应的 未处理数据转发给最后一个分片数据对应的线程处理, 并针对剩余的 N-1个数据 处理失败的线程, 创建至少 N-1个新的线程, 将所述数据处理失败的线程未处理 的数据转发给新的线程处理, 其中每一个数据处理失败的线程未处理的数据对 应至少一个新的线程, 其中 N为大于 1的整数。
[0121] 本领域普通技术人员可以意识到, 结合本文中所公幵的实施例描述的各示例的 单元及算法步骤, 能够以电子硬件、 或者计算机软件和电子硬件的结合来实现 。 这些功能究竟以硬件还是软件方式来执行, 取决于技术方案的特定应用和设 计约束条件。 专业技术人员可以对每个特定的应用来使用不同方法来实现所描 述的功能, 但是这种实现不应认为超出本发明的范围。
[0122] 在本发明所提供的实施例中, 应该理解到, 所揭露的数据处理的方法、 装置、 设备以及计算机可读存储介质, 可以通过其它的方式实现。 例如, 以上所描述 的实施例仅仅是示意性的, 例如, 所述模块或单元的划分, 仅仅为一种逻辑功
能划分, 实际实现吋可以有另外的划分方式, 例如多个单元或组件可以结合或 者可以集成到另一个系统, 或一些特征可以忽略, 或不执行。 另一点, 所显示 或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口, 装置或 单元的间接耦合或通讯连接, 可以是电性, 机械或其它的形式。
[0123] 所述作为分离部件说明的单元可以是或者也可以不是物理上分幵的, 作为单元 显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可 以分布到多个网络单元上。 可以根据实际的需要选择其中的部分或者全部单元 来实现本实施例方案的目的。
[0124] 另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元中, 也可 以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一个单元中。 上述集成的单元既可以采用硬件的形式实现, 也可以采用软件功能单元的形式 实现。
[0125] 所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用 吋, 可以存储在一个计算机可读取存储介质中。 基于这样的理解, 本发明实施 例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部 或部分可以以软件产品的形式体现出来, 该计算机软件产品存储在一个存储介 质中, 包括若干指令用以使得一台计算机设备 (可以是个人计算机, 服务器, 或者网络设备等) 或处理器 (processor) 执行本发明实施例各个实施例所述方法 的全部或部分步骤。 而前述的存储介质包括: U盘、 移动硬盘、 只读存储器 (R 0M, Read-Only Memory) 、 随机存取存储器 (RAM, Random Access Memory ) 、 磁碟或者光盘等各种可以存储程序代码的介质。
[0126] 以上所述实施例仅用以说明本发明的技术方案, 而非对其限制; 尽管参照前述 实施例对本发明进行了详细的说明, 本领域的普通技术人员应当理解: 其依然 可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分技术特征进 行等同替换; 而这些修改或者替换, 并不使相应技术方案的本质脱离本发明实 施例各实施例技术方案的精神和范围。
Claims
[权利要求 1] 一种数据处理的方法, 其特征在于, 所述方法包括:
获取待处理的数据, 所述待处理的数据为预处理后的数据; 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获 得多个分片数据;
对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一 个线程。
[权利要求 2] 如权利要求 1所述的方法, 其特征在于, 所述按预设规则对所述待处 理的数据进行分片包括:
记录上一次待处理的数据的数据量 X以及上一次分片数据的数量 Q; 获取当前待处理的数据的数据量 Y;
根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
根据所述 P对所述当前待处理的数据进行分片, 获得 P个分片数据。
[权利要求 3] 如权利要求 1所述的方法, 其特征在于, 在按预设规则对所述待处理 的数据进行分片, 获得多个分片数据之后, 还包括:
构建多个线程, 其中所述线程的数量大于或等于所述分片数据的数量
[权利要求 4] 如权利要求 1所述的方法, 其特征在于, 对所述多个分片数据进行多 线程处理包括:
判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随 机分配至少一个线程进行处理; 若否, 则根据每个分片数据的数据量 大小依次选择处理性能最优的线程进行处理。
[权利要求 5] 如权利要求 1至 4任一项所述的方法, 其特征在于, 所述对所述多个分 片数据进行多线程处理还包括:
当某线程的数据处理速度小于第一预设值和 /或处理吋间大于第二预 设值吋, 对该线程未处理的数据按照已处理完的线程的数量或者未处 理数据小于第三预设值的线程的数量进行再次分片, 并将再次分片后 的数据转发给已处理完的线程或者未处理数据小于第三预设值的线程
处理; 其中, 每个线程对应一个再次分片的数据。
[权利要求 6] 如权利要求 1至 4任一项所述的方法, 其特征在于, 所述对所述多个分 片数据进行多线程处理还包括:
当存在某一个数据处理失败的线程吋, 先检测该线程未处理的数据是 否大于第四预设值, 若是, 创建新的线程, 将该线程未处理的数据转 发给所述新的线程处理, 并对所述数据处理失败的线程进行标记或结 束该线程; 若否, 检测最后一个分片数据最初所划分的数据和 /或最 后一个分片数据当前未处理的数据是否为最少, 若为最少, 则将该线 程未处理的数据转发给最后一个分片数据对应的线程处理; 当存在 N个数据处理失败的线程吋, 将其中一个未处理数据最少的线 程对应的未处理数据转发给最后一个分片数据对应的线程处理, 并针 对剩余的 N-1个数据处理失败的线程, 创建至少 N-1个新的线程, 将 所述数据处理失败的线程未处理的数据转发给新的线程处理, 其中每 一个数据处理失败的线程未处理的数据对应至少一个新的线程, 其中 N为大于 1的整数。
[权利要求 7] —种数据处理的装置, 其特征在于, 所述装置包括:
数据获取模块, 用于获取待处理的数据, 所述待处理的数据为预处理 后的数据;
数据分片模块, 用于在接收到预定指令吋, 按预设规则对所述待处理 的数据进行分片, 获得多个分片数据;
数据处理模块, 用于对所述多个分片数据进行多线程处理, 其中每个 分片数据对应至少一个线程。
[权利要求 8] 如权利要求 7所述的装置, 其特征在于, 所述数据分片模块包括: 记录单元, 用于记录上一次待处理的数据的数据量 X以及上一次分片 数据的数量 Q;
获取单元, 用于获取当前待处理的数据的数据量 Y;
计算单元, 用于根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
分片单元, 用于根据所述 P对所述当前待处理的数据进行分片, 获得
P个分片数据。
[权利要求 9] 如权利要求 7所述的装置, 其特征在于, 所述装置还包括:
线程构建模块, 用于在按预设规则对所述待处理的数据进行分片, 获 得多个分片数据之后, 构建多个线程, 其中所述线程的数量大于或等 于所述分片数据的数量。
[权利要求 10] 如权利要求 7至 9任一项所述的装置, 其特征在于, 所述数据处理模块 包括:
第一处理单元, 用于判断每个分片数据的数据量是否相同, 若是, 则 针对每个分片数据随机分配至少一个线程进行处理; 若否, 则根据每 个分片数据的数据量大小依次选择处理性能最优的线程进行处理; 第二处理单元, 用于当某线程的数据处理速度小于第一预设值和 /或 处理吋间大于第二预设值吋, 对该线程未处理的数据按照已处理完的 线程的数量或者未处理数据小于第三预设值的线程的数量进行再次分 片, 并将再次分片后的数据转发给已处理完的线程或者未处理数据小 于第三预设值的线程处理; 其中, 每个线程对应一个再次分片的数据 第三处理单元, 用于当存在某一个数据处理失败的线程吋, 先检测该 线程未处理的数据是否大于第四预设值, 若是, 创建新的线程, 将该 线程未处理的数据转发给所述新的线程处理, 并对所述数据处理失败 的线程进行标记或结束该线程; 若否, 检测最后一个分片数据最初所 划分的数据和 /或最后一个分片数据当前未处理的数据是否为最少, 若为最少, 则将该线程未处理的数据转发给最后一个分片数据对应的 线程处理; 当存在 N个数据处理失败的线程吋, 将其中一个未处理数 据最少的线程对应的未处理数据转发给最后一个分片数据对应的线程 处理, 并针对剩余的 N-1个数据处理失败的线程, 创建至少 N-1个新 的线程, 将所述数据处理失败的线程未处理的数据转发给新的线程处 理, 其中每一个数据处理失败的线程未处理的数据对应至少一个新的 线程, 其中 N为大于 1的整数。
[权利要求 11] 一种数据处理的设备, 其特征在于, 所述数据处理的设备包括: 处理 器、 存储器及数据处理的系统, 所述数据处理的系统存储于所述存储 器中, 包括至少一个计算机可读指令, 该至少一个计算机可读指令可 被所述处理器执行, 以实现以下操作:
获取待处理的数据, 所述待处理的数据为预处理后的数据; 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获 得多个分片数据;
对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一
[权利要求 12] 如权利要求 11所述的数据处理的设备, 其特征在于, 所述按预设规则 对所述待处理的数据进行分片包括:
记录上一次待处理的数据的数据量 X以及上一次分片数据的数量 Q; 获取当前待处理的数据的数据量 Y;
根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
根据所述 P对所述当前待处理的数据进行分片, 获得 P个分片数据。
[权利要求 13] 如权利要求 11所述的数据处理的设备, 其特征在于, 对所述多个分片 数据进行多线程处理包括:
判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随 机分配至少一个线程进行处理; 若否, 则根据每个分片数据的数据量 大小依次选择处理性能最优的线程进行处理。
[权利要求 14] 如权利要求 11所述的数据处理的设备, 其特征在于, 所述至少一个计 算机可读指令还可被所述处理器执行, 以实现以下操作:
构建多个线程, 其中所述线程的数量大于或等于所述分片数据的数量
[权利要求 15] 如权利要求 11至 14任一项所述的数据处理的设备, 其特征在于, 所述 对所述多个分片数据进行多线程处理还包括:
当某线程的数据处理速度小于第一预设值和 /或处理吋间大于第二预 设值吋, 对该线程未处理的数据按照已处理完的线程的数量或者未处
理数据小于第三预设值的线程的数量进行再次分片, 并将再次分片后 的数据转发给已处理完的线程或者未处理数据小于第三预设值的线程 处理; 其中, 每个线程对应一个再次分片的数据。
[权利要求 16] 如权利要求 11至 14任一项所述的数据处理的设备, 其特征在于, 所述 对所述多个分片数据进行多线程处理还包括:
当存在某一个数据处理失败的线程吋, 先检测该线程未处理的数据是 否大于第四预设值, 若是, 创建新的线程, 将该线程未处理的数据转 发给所述新的线程处理, 并对所述数据处理失败的线程进行标记或结 束该线程; 若否, 检测最后一个分片数据最初所划分的数据和 /或最 后一个分片数据当前未处理的数据是否为最少, 若为最少, 则将该线 程未处理的数据转发给最后一个分片数据对应的线程处理; 当存在 N个数据处理失败的线程吋, 将其中一个未处理数据最少的线 程对应的未处理数据转发给最后一个分片数据对应的线程处理, 并针 对剩余的 N-1个数据处理失败的线程, 创建至少 N-1个新的线程, 将 所述数据处理失败的线程未处理的数据转发给新的线程处理, 其中每 一个数据处理失败的线程未处理的数据对应至少一个新的线程, 其中 N为大于 1的整数。
[权利要求 17] —种计算机可读存储介质, 其特征在于, 所述计算机可读存储介质存 储有至少一个可被处理器执行以实现以下操作的计算机可读指令: 获取待处理的数据, 所述待处理的数据为预处理后的数据; 在接收到预定指令吋, 按预设规则对所述待处理的数据进行分片, 获 得多个分片数据;
对所述多个分片数据进行多线程处理, 其中每个分片数据对应至少一 个线程。
[权利要求 18] 如权利要求 17所述的一种计算机可读存储介质, 其特征在于, 所述按 预设规则对所述待处理的数据进行分片包括:
记录上一次待处理的数据的数据量 X以及上一次分片数据的数量 Q; 获取当前待处理的数据的数据量 Y;
根据所述 X、 Q、 Y, 计算获得 P=INT(X*Q/Y);
根据所述 P对所述当前待处理的数据进行分片, 获得 P个分片数据。 如权利要求 17所述的一种计算机可读存储介质, 其特征在于, 所述至 少一个计算机可读指令还可被所述处理器执行, 以实现以下操作: 构建多个线程, 其中所述线程的数量大于或等于所述分片数据的数量 如权利要求 17所述的一种计算机可读存储介质, 其特征在于, 对所述 多个分片数据进行多线程处理包括:
判断每个分片数据的数据量是否相同, 若是, 则针对每个分片数据随 机分配至少一个线程进行处理; 若否, 则根据每个分片数据的数据量 大小依次选择处理性能最优的线程进行处理。
如权利要求 17至 20任一项所述的一种计算机可读存储介质, 其特征在 于, 所述对所述多个分片数据进行多线程处理还包括:
当某线程的数据处理速度小于第一预设值和 /或处理吋间大于第二预 设值吋, 对该线程未处理的数据按照已处理完的线程的数量或者未处 理数据小于第三预设值的线程的数量进行再次分片, 并将再次分片后 的数据转发给已处理完的线程或者未处理数据小于第三预设值的线程 处理; 其中, 每个线程对应一个再次分片的数据。
如权利要求 17至 20任一项所述的一种计算机可读存储介质, 其特征在 于, 所述对所述多个分片数据进行多线程处理还包括:
当存在某一个数据处理失败的线程吋, 先检测该线程未处理的数据是 否大于第四预设值, 若是, 创建新的线程, 将该线程未处理的数据转 发给所述新的线程处理, 并对所述数据处理失败的线程进行标记或结 束该线程; 若否, 检测最后一个分片数据最初所划分的数据和 /或最 后一个分片数据当前未处理的数据是否为最少, 若为最少, 则将该线 程未处理的数据转发给最后一个分片数据对应的线程处理; 当存在 N个数据处理失败的线程吋, 将其中一个未处理数据最少的线 程对应的未处理数据转发给最后一个分片数据对应的线程处理, 并针
对剩余的 N-l个数据处理失败的线程, 创建至少 N-1个新的线程, 将 所述数据处理失败的线程未处理的数据转发给新的线程处理, 其中每 一个数据处理失败的线程未处理的数据对应至少一个新的线程, 其中 N为大于 1的整数。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710083459.6 | 2017-02-16 | ||
| CN201710083459.6A CN106980538A (zh) | 2017-02-16 | 2017-02-16 | 数据处理的方法及装置 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018149078A1 true WO2018149078A1 (zh) | 2018-08-23 |
Family
ID=59338650
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/090047 Ceased WO2018149078A1 (zh) | 2017-02-16 | 2017-06-26 | 数据处理的方法、装置、设备以及计算机可读存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN106980538A (zh) |
| WO (1) | WO2018149078A1 (zh) |
Families Citing this family (12)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108259243A (zh) * | 2018-01-12 | 2018-07-06 | 深圳市卓讯信息技术有限公司 | 基于微服务技术架构的数据处理方法、终端及计算机存储介质 |
| CN110704517B (zh) * | 2018-06-21 | 2023-01-17 | 北京国双科技有限公司 | 一种生成任务的方法、装置、存储介质及处理器 |
| CN109359152B (zh) * | 2018-12-07 | 2021-01-29 | 泰康保险集团股份有限公司 | 基于切片的编码映射方法、装置、电子设备、存储介质 |
| CN111008073A (zh) * | 2019-11-22 | 2020-04-14 | 珠海格力电器股份有限公司 | 一种数据处理方法及装置 |
| CN111221652A (zh) * | 2020-01-03 | 2020-06-02 | 北京百度网讯科技有限公司 | 数据处理方法和装置 |
| CN111752961B (zh) * | 2020-06-29 | 2025-05-30 | 深圳前海微众银行股份有限公司 | 一种数据处理方法及装置 |
| CN112836210B (zh) * | 2021-01-22 | 2026-01-13 | 支付宝(杭州)数字服务技术有限公司 | 一种程序运行方法及系统 |
| CN114692133B (zh) * | 2021-01-22 | 2025-08-29 | 支付宝(杭州)信息技术有限公司 | 一种程序运行方法及系统 |
| CN113761299A (zh) * | 2021-08-17 | 2021-12-07 | 成都安恒信息技术有限公司 | 一种基于数据处理时延的多线程物理排序方法及系统 |
| CN114064693A (zh) * | 2021-11-17 | 2022-02-18 | 中国建设银行股份有限公司 | 处理账户数据的方法、装置、电子设备和计算机可读介质 |
| CN115576995B (zh) * | 2022-11-09 | 2023-06-09 | 广州海量数据库技术有限公司 | 一种基于OpenGauss数据库的流数据加载方法 |
| CN116431653A (zh) * | 2023-04-11 | 2023-07-14 | 平安科技(深圳)有限公司 | 大批量数据处理方法、装置、电子设备及存储介质 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106021543A (zh) * | 2016-05-26 | 2016-10-12 | 中国农业银行股份有限公司 | 一种数据预处理方法及装置 |
| CN106156049A (zh) * | 2015-03-27 | 2016-11-23 | 天脉聚源(北京)科技有限公司 | 一种数据读取的方法和系统 |
| CN106202374A (zh) * | 2016-07-07 | 2016-12-07 | 无锡天脉聚源传媒科技有限公司 | 一种数据处理方法及装置 |
| CN106407231A (zh) * | 2015-08-03 | 2017-02-15 | 天脉聚源(北京)科技有限公司 | 一种数据多线程导出方法及系统 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104102475B (zh) * | 2013-04-11 | 2018-10-02 | 腾讯科技(深圳)有限公司 | 分布式并行任务处理的方法、装置及系统 |
| CN105700938B (zh) * | 2016-01-15 | 2019-02-19 | 浪潮通用软件有限公司 | 一种多线程处理数据的方法及装置 |
| CN105975331A (zh) * | 2016-04-26 | 2016-09-28 | 浪潮(北京)电子信息产业有限公司 | 一种数据并行处理方法及装置 |
-
2017
- 2017-02-16 CN CN201710083459.6A patent/CN106980538A/zh active Pending
- 2017-06-26 WO PCT/CN2017/090047 patent/WO2018149078A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106156049A (zh) * | 2015-03-27 | 2016-11-23 | 天脉聚源(北京)科技有限公司 | 一种数据读取的方法和系统 |
| CN106407231A (zh) * | 2015-08-03 | 2017-02-15 | 天脉聚源(北京)科技有限公司 | 一种数据多线程导出方法及系统 |
| CN106021543A (zh) * | 2016-05-26 | 2016-10-12 | 中国农业银行股份有限公司 | 一种数据预处理方法及装置 |
| CN106202374A (zh) * | 2016-07-07 | 2016-12-07 | 无锡天脉聚源传媒科技有限公司 | 一种数据处理方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN106980538A (zh) | 2017-07-25 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2018149078A1 (zh) | 数据处理的方法、装置、设备以及计算机可读存储介质 | |
| CN113568940B (zh) | 数据查询的方法、装置、设备以及存储介质 | |
| CN103984776B (zh) | 一种识别重复图片的方法、图片搜索去重方法及其装置 | |
| KR102567285B1 (ko) | 모바일 비디오 서치 기법 | |
| CN103248711B (zh) | 一种文件上传的方法和服务器 | |
| CN103699585B (zh) | 文件的元数据存储以及文件恢复的方法、装置和系统 | |
| US10771358B2 (en) | Data acquisition device, data acquisition method and storage medium | |
| US20170201566A1 (en) | File downloading method, apparatus, and terminal device | |
| CN103823792B (zh) | 从文本文档中检测热点事件的方法和设备 | |
| TW201227292A (en) | Method and apparatus to perform concurrent read and write memory operations | |
| CN107193813A (zh) | 数据表连接方式处理方法及装置 | |
| WO2023165272A1 (zh) | 数据存储及查询 | |
| CN113760509B (zh) | 一种超时管理方法、装置及电子设备 | |
| CN104252406B (zh) | 数据处理的方法及装置 | |
| CN113204665B (zh) | 图像检索方法、装置、电子设备及计算机可读存储介质 | |
| CN113918527B (zh) | 一种基于文件缓存的调度方法、装置与计算设备 | |
| CN111970357A (zh) | 视频上传方法、装置及系统 | |
| WO2021108978A1 (zh) | 验证人节点选择方法、电子设备、系统及介质 | |
| CN103970769B (zh) | 图像检索方法及装置 | |
| JP2019016402A (ja) | 走査対象情報を走査する方法、装置、及びコンピュータデバイス | |
| CN109359060B (zh) | 数据抽取方法、装置、计算设备及计算机存储介质 | |
| WO2015067145A1 (zh) | 应用识别方法与装置 | |
| CN103019610A (zh) | 对象选择方法及终端 | |
| CN106412088B (zh) | 一种数据同步方法及终端 | |
| CN104572687A (zh) | 微博传播的关键用户识别方法和装置 |
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: 17896732 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 21/11/2019) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17896732 Country of ref document: EP Kind code of ref document: A1 |