WO2020224216A1 - Bulk data processing method and apparatus, and computer device and storage medium - Google Patents

Bulk data processing method and apparatus, and computer device and storage medium Download PDF

Info

Publication number
WO2020224216A1
WO2020224216A1 PCT/CN2019/117745 CN2019117745W WO2020224216A1 WO 2020224216 A1 WO2020224216 A1 WO 2020224216A1 CN 2019117745 W CN2019117745 W CN 2019117745W WO 2020224216 A1 WO2020224216 A1 WO 2020224216A1
Authority
WO
WIPO (PCT)
Prior art keywords
batch
data
processed
batch data
target
Prior art date
Application number
PCT/CN2019/117745
Other languages
French (fr)
Chinese (zh)
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 WO2020224216A1 publication Critical patent/WO2020224216A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/951Indexing; Web crawling techniques

Definitions

  • This application relates to the field of data processing technology, and in particular to a method, device, computer equipment, and storage medium for processing mass data.
  • the embodiments of the present application provide a method, device, computer device, and storage medium for processing large quantities of data, aiming to solve the problem of long time-consuming processing of large quantities of data, repeated capture and missing processing.
  • an embodiment of the present application provides a method for processing large batch data, which includes: acquiring all batch data to be processed from a preset database and assigning a batch number to each batch of data to be processed; One of the batch numbers of the batch data to be processed is used as the target batch data, an exclusive lock is added to the target batch data and the target batch data is processed; if the target batch data processing is completed, all the data are obtained
  • the initial preset field value in the target batch data and submit the target batch data to the preset database according to the initial preset field value to release the exclusive lock; and download according to the batch number
  • the to-be-processed batch data of a batch number is processed as the target batch data until all the to-be-processed batch data of all batch numbers are processed.
  • an embodiment of the present application also provides a mass data processing device, which includes: a distribution unit, configured to obtain all batch data to be processed from a preset database and Allocate batch numbers; an exclusive unit for using the batch data to be processed of one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data; release Unit, configured to obtain the initial preset field value in the target batch data if the target batch data processing is completed, and submit the target batch data to the preset according to the initial preset field value Database to release the exclusive lock; a processing unit for processing the batch data to be processed with the next batch number as the target batch data according to the batch number until the batch number to be processed for all batch numbers All batch data is processed.
  • a distribution unit configured to obtain all batch data to be processed from a preset database and Allocate batch numbers
  • an exclusive unit for using the batch data to be processed of one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data
  • release Unit configured to obtain
  • an embodiment of the present application also provides a computer device, which includes a memory and a processor connected to the memory; the memory is used to store a computer program; the processor is used to run the A computer program to execute the following steps: obtain all batch data to be processed from a preset database and assign a batch number to each batch data to be processed; and assign the batch data to be processed with one of the batch numbers
  • the target batch data add an exclusive lock to the target batch data and process the target batch data; if the target batch data processing is completed, obtain the initial preset field value in the target batch data and Submit the target batch data to the preset database according to the initial preset field value to release the exclusive lock; use the batch data to be processed of the next batch number as the batch number according to the batch number
  • the target batch data is processed until the to-be-processed batch data of all batch numbers are all processed.
  • the embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the following steps: Obtain all the batch data to be processed from the preset database and assign a batch number to each batch data to be processed; take the batch data to be processed with one of the batch numbers as the target batch data, and Add an exclusive lock to the target batch data and process the target batch data; if the target batch data processing is completed, obtain the initial preset field value in the target batch data and change the value according to the initial preset field value The target batch data is submitted to the preset database to release the exclusive lock; the batch data to be processed of the next batch number is processed as the target batch data according to the batch number until all batches are processed The processing of the batch data to be processed of the minor number is completed.
  • FIG. 1 is a schematic flow chart of a method for processing large batch data provided by an embodiment of the application
  • FIG. 2 is a schematic diagram of a sub-flow of a method for processing large quantities of data provided by an embodiment of the application;
  • FIG. 3 is a schematic diagram of a sub-flow of a method for processing large batches of data provided by an embodiment of the application;
  • FIG. 4 is a schematic diagram of a sub-flow of a method for processing mass data according to an embodiment of the application
  • FIG. 5 is a schematic diagram of a sub-flow of a method for processing a large batch of data provided by an embodiment of the application;
  • FIG. 6 is a schematic block diagram of a mass data processing device provided by an embodiment of the application.
  • FIG. 7 is a schematic block diagram of specific units of a mass data processing device provided by an embodiment of the application.
  • FIG. 8 is a schematic block diagram of a computer device provided by an embodiment of the application.
  • Fig. 1 is a schematic flow chart of a method for processing large batch data according to an embodiment of the application.
  • the mass data processing method can be applied to the collection system and implemented in the server.
  • the collection system is an information system used by a lending company to control loan data.
  • the system includes a large amount of collection-related data. With the change of daily collection data, the collection system needs to process large quantities of collection data every day.
  • Existing databases usually use optimistic locking to manipulate data when processing data with fewer write operations. When operating data through optimistic locking, other threads will not modify the data by default, so the data will not be locked, just before updating the data Determine whether other threads have modified the data during this period.
  • FIG. 1 is a schematic flowchart of a method for processing large batches of data provided by an embodiment of the present application. As shown in the figure, the method includes the following steps S110-S140.
  • S110 Obtain all batch data to be processed from a preset database and assign a batch number to each batch data to be processed.
  • the preset database refers to the database of the collection system, and the collection data of the collection system is stored in the preset database.
  • the batch data to be processed refers to the collection data that needs to be processed in batches.
  • the batches of the batch data to be processed are pre-divided according to the data size. For example, the data size of the batch data to be processed is 100G in total, with 1G A batch of data to be processed is divided into 100 batches.
  • the batch number refers to the number assigned to the batch of data to be processed, and each batch of data to be processed is assigned a batch number, for example, Data processing001. The batch number is used to process the batch data to be processed, which can ensure that no processing is missed.
  • the step S110 may include steps S111-S113.
  • S112 Sort the batch data to be processed from small to large according to the batch number.
  • the processing starts from the smallest batch number according to the sorting order until the processing batch data of the largest batch number is processed, so as to ensure that no processing is missed.
  • S120 Use the batch data to be processed of one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data.
  • the exclusive lock is a locking mechanism in the pessimistic lock.
  • the exclusive lock is used to lock the data during the entire data processing process, and other processes cannot read or write the data.
  • the batch data to be processed with one of the batch numbers is used as the target batch data, and an exclusive lock mechanism is adopted. Lock the target batch of data to prevent other processes from reading and writing the processed target batch of data, so as to maintain the consistency of data read and write.
  • the step S120 may include steps S121-S124.
  • S121 Use the batch data to be processed of one of the batch numbers as target batch data.
  • the exclusive lock is a lock mechanism of the database itself. Therefore, when the exclusive lock is added to the target batch data, the exclusive lock mechanism of the preset database is directly called to lock the target batch data, specifically , The target batch data can be locked by adding for update in the execution statement for processing the target batch data. After the lock is locked, the target batch data is processed.
  • the processing performed on the target batch data includes data addition, deletion, and modification.
  • the initial preset field value refers to the preset field value when the target batch of data is first obtained from the preset database, and each batch of data to be processed includes a preset field value.
  • the preset field value can be a version number (version) or a timestamp (timestamp). If the preset field value is a version number, the specific form is a numeric field, such as 1, and the version number is incremented by one after the data update is completed, for example, the data with the version number of 1 is updated to 2; if the field value is preset It is a timestamp, and its specific form is a field of time type, for example, 2018.11.20, 00:00. The timestamp is updated every time the data update is completed.
  • Optimistic locking is achieved through initial preset field values.
  • other threads When acquiring the target batch data, other threads will not process the target batch data by default, but when the target batch data is processed and submitted to the preset database
  • the optimistic lock is triggered, and it is judged according to the initial preset field value whether other threads have modified the target batch data during the period from acquiring the target batch data to the completion of processing the target batch data. If other threads do not modify the target batch data during this period, submit the processed target batch data to the preset database to release the exclusive lock, and other threads can immediately modify the target batch The data was processed.
  • the step S130 may include steps S131-S134.
  • the initial preset field value can be obtained from the target batch data. Then, the current preset field value in the target batch data of the batch is read from the preset database. Then compare the initial preset field value of the target batch of data with the current preset field value. If the two are the same, it means that other threads are in the period from acquiring the target batch of data to processing the target batch of data.
  • the target batch data has not been modified. Since the exclusive lock mechanism of the preset database is automatically released when the database transaction is submitted, finally the processed target batch data is submitted to the preset database for update and then released to release the target batch data With the exclusive lock, other processes can immediately perform new processing on the target batch of data.
  • the initial preset field value of the target batch of data is not the same as the current preset field value, it means that during the period from the acquisition of the target batch of data to the completion of the processing of the target batch of data by other threads, The data has been modified, and the error message is returned to the collection system at this time for further processing by the collection system.
  • S140 Process the batch data to be processed of the next batch number as target batch data according to the batch number until all the batch data to be processed of all batch numbers are processed.
  • the processing starts from the batch data to be processed with the smallest batch number, and the batch data to be processed with the smallest batch number is processed, and then the batch to be processed with the next batch number is processed.
  • the secondary data will be processed one by one in the descending order of the assigned batch number.
  • the minimum batch number is 1.
  • the batch data to be processed with the batch number 2 is processed until all batch numbers are The batch data to be processed is all processed. According to the processing sequence of the batch number from small to large, it can be ensured that all the batch data to be processed can be processed to prevent the omission of processing.
  • the step S140 may include steps S141-S143.
  • S142 Determine whether the processing mark exists in the batch of data to be processed.
  • step S120 before processing the to-be-processed batch data of the next batch number, it is necessary to judge the currently processed batch-to-be-processed data, and determine whether the currently processed batch data Whether there is a processing mark, if there is a processing mark in the current batch of data to be processed, it means that the processing of the current batch of data to be processed has been completed, and the processing of the next batch of the batch of data to be processed starts, namely Return to step S120 to start processing the batch data to be processed with the next batch number, until all the batch data to be processed are completely processed.
  • this application When processing large batches of collection data, this application first uses optimistic locking to obtain the batch data to be processed from the preset database, first does not lock the batch data to be processed, and other threads can still lock the The batch data to be processed is operated. Then according to the order of the batch number, the batch data to be processed with the smallest batch number is processed first, and the batch data to be processed with the smallest batch number is used as the target batch data.
  • the batch data to be processed with the smallest batch number is used as the target batch data.
  • other threads cannot operate on the target batch data of the batch number at this time, but other threads can still perform operations on other batch numbers at this time. Of the batch of data to be processed.
  • the optimistic lock is triggered when submitted to the preset database to determine whether the target batch data of the batch number has been modified by other threads during the process. If it has not been modified by other threads during this period, submit the processed batch number of the target batch data to the preset database for update, and at the same time release the exclusive lock of the target batch data of the batch number , Other threads can immediately modify the target batch data of the batch number. Therefore, the collection data processed by the mass data processing method of the present application can quickly capture mass collection data, and has little impact on other threads when processing collection data, and other threads can quickly perform new processing and ensure data There is no repeated fetching and missing processing, which greatly improves the processing speed and efficiency of large quantities of data.
  • the embodiment of the application shows a data processing method, by acquiring all batch data to be processed from a preset database and assigning a batch number to each batch of data to be processed;
  • the batch data to be processed is used as the target batch data, an exclusive lock is added to the target batch data and the target batch data is processed; if the target batch data processing is completed, the initial batch data in the target batch data is obtained Preset field values and submit the target batch data to the preset database according to the initial preset field values to release the exclusive lock; according to the batch number, the pending batch number of the next batch number
  • the processed batch data is processed as the target batch data until the processing of the batch data to be processed of all batch numbers is completed, which can ensure that the data will not be repeatedly fetched and missed processing, and increase the processing speed of large batch data.
  • FIG. 6 is a schematic block diagram of a mass data processing apparatus 200 provided by an embodiment of the present application. As shown in FIG. 6, corresponding to the above mass data processing method, the present application also provides a mass data processing device 200.
  • the mass data processing device 200 includes a unit for executing the above mass data processing method, and the device can be configured in a server. Specifically, referring to FIG. 6, the mass data processing apparatus 200 includes: an allocation unit 210, an exclusive unit 220, a release unit 230 and a processing unit 240.
  • the allocation unit 210 is configured to obtain all batch data to be processed from a preset database and allocate a batch number to each batch data to be processed.
  • the allocation unit 210 includes: an acquisition subunit 211, an allocation subunit 212, and a sorting unit 213.
  • the obtaining subunit 211 is used to obtain all batch data to be processed from a preset database.
  • the allocation subunit 212 is configured to allocate batch numbers according to the batch quantity of the batch data to be processed.
  • the sorting unit 213 is configured to sort the batch data to be processed from small to large according to the batch number.
  • the exclusive unit 220 is configured to use the batch data to be processed with one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data.
  • the exclusive unit 220 includes a target unit 221, a calling unit 222, an adding unit 223 and a marking unit 224.
  • the target unit 221 is configured to use the batch data to be processed of one of the batch numbers as target batch data.
  • the calling unit 222 is configured to call the exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data.
  • the adding unit 223 is configured to process the target batch data to which the exclusive lock has been added.
  • the marking unit 224 is used to add a processing mark to the processed target batch data.
  • the releasing unit 230 is configured to obtain the initial preset field value in the target batch data and submit the target batch data to the target batch data according to the initial preset field value if the processing of the target batch data is completed.
  • the database is preset to release the exclusive lock.
  • the releasing unit 230 includes: a first acquiring unit 231, a second acquiring unit 232, a comparing unit 233 and a submitting unit 234.
  • the first obtaining unit 231 is configured to obtain an initial preset field value from the target batch data
  • the second obtaining unit 232 is configured to obtain the current preset field value of the target batch data from the preset database
  • the comparison unit 233 is configured to compare the initial preset field value with the current preset field value
  • the submitting unit 234 is configured to submit the target batch data to the preset database to release the exclusive lock if the initial preset field value is the same as the current preset field value.
  • the processing unit 240 is configured to process the to-be-processed batch data of the next batch number as target batch data according to the batch number until all the to-be-processed batch data of all batch numbers are processed.
  • the processing unit 240 includes: a third acquisition unit 241, a judgment unit 242 and a loop processing unit 243.
  • the third obtaining unit 241 is configured to obtain the batch data to be processed of the next batch number according to the batch number;
  • the determining unit 242 is configured to determine whether the processing mark exists in the batch of data to be processed
  • the loop processing unit 243 is configured to process the to-be-processed batch data of the next batch number as the target batch data if the processing mark exists in the to-be-processed batch data.
  • the above-mentioned mass data processing apparatus may be implemented in the form of a computer program, and the computer program may be run on a computer device as shown in FIG. 8.
  • FIG. 8 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • the computer device 500 may be a server.
  • the server may be an independent server or a server cluster composed of multiple servers.
  • the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
  • the non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032.
  • the computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a method for processing mass data.
  • the processor 502 is used to provide calculation and control capabilities to support the operation of the entire computer device 500.
  • the internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503.
  • the processor 502 can execute a large-scale data processing method.
  • the network interface 505 is used for network communication with other devices.
  • FIG. 8 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied.
  • the specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
  • the processor 502 is configured to run a computer program 5032 stored in a memory, so as to implement the mass data processing method in the embodiment of the present application.
  • the processor 502 may be a central processing unit (Central Processing Unit, CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), Application Specific Integrated Circuit (ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
  • the computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium.
  • the program instructions are executed by at least one processor in the computer system to implement the process steps of the foregoing method embodiments.
  • the storage medium may be a computer-readable storage medium.
  • the storage medium stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the mass data processing method described in the above embodiments.
  • the storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk or an optical disk, and other computer-readable storage media that can store program codes.
  • ROM Read-Only Memory
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of each unit is only a logical function division, and there may be other division methods in actual implementation.
  • multiple units or components can be combined or integrated into another system, or some features can be omitted or not implemented.
  • the steps in the method of the embodiment of the present application can be adjusted, merged, and deleted in order according to actual needs.
  • the units in the devices in the embodiments of the present application may be combined, divided, and deleted according to actual needs.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium.
  • the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium It includes several instructions to make a computer device (which may be a personal computer, a terminal, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.

Abstract

Disclosed are a bulk data processing method and apparatus, and a computer device and a storage medium. The present application is applied to the field of data updating of big data. The method comprises: acquiring all batches of data to be processed from a preset database, and allocating a batch number to each batch of data to be processed; taking a batch of data to be processed that has one of the batch numbers as a target batch of data, adding an exclusive lock to the target batch of data, and processing the target batch of data; if the processing of the target batch of data is completed, acquiring an initial preset field value in the target batch of data, and submitting the target batch of data to the preset database according to the initial preset field value in order to release the exclusive lock; and taking a batch of data to be processed that has the next batch number as a target batch of data according to the batch numbers, and processing same until the processing of all the batches of data to be processed that have the batch numbers is completed.

Description

大批量数据处理方法、装置、计算机设备及存储介质Mass data processing method, device, computer equipment and storage medium
本申请要求于2019年5月5日提交中国专利局、申请号为201910367480.8、申请名称为“大批量数据处理方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910367480.8, and the application name is "mass data processing methods, devices, computer equipment and storage media" on May 5, 2019. The reference is incorporated in this application.
技术领域Technical field
本申请涉及数据处理技术领域,尤其涉及一种大批量数据处理方法、装置、计算机设备及存储介质。This application relates to the field of data processing technology, and in particular to a method, device, computer equipment, and storage medium for processing mass data.
背景技术Background technique
随着经济与技术的发展,数据呈爆发式的增长,每天都会产生巨量的数据,每天都需要处理巨量的数据。特别是在催收领域中,催收数据具有数量级大、更新变化非常频繁的特点,通过策略引擎对动态更新的催收数据进行处理可有效地控制风险。因此,现有的催收系统每日都需要处理大批量的数据,然而大批量的数据在数据库中的读写耗时长,对服务器的压力大,容易导致出现重复抓取数据以及漏处理数据的情况。With the development of economy and technology, data is growing explosively, huge amounts of data are generated every day, and huge amounts of data need to be processed every day. Especially in the field of collection, collection data has the characteristics of large orders of magnitude and very frequent updates and changes. The process of dynamically updated collection data through the strategy engine can effectively control risks. Therefore, the existing collection system needs to process large quantities of data every day. However, the reading and writing of large quantities of data in the database takes a long time and puts a lot of pressure on the server, which easily leads to repeated data capture and omission of data processing. .
发明内容Summary of the invention
本申请实施例提供了一种大批量数据处理方法、装置、计算机设备及存储介质,旨在解决处理大批量数据耗时长,且出现重复抓取以及漏处理的问题。The embodiments of the present application provide a method, device, computer device, and storage medium for processing large quantities of data, aiming to solve the problem of long time-consuming processing of large quantities of data, repeated capture and missing processing.
第一方面,本申请实施例提供了一种大批量数据处理方法,其包括:从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。In the first aspect, an embodiment of the present application provides a method for processing large batch data, which includes: acquiring all batch data to be processed from a preset database and assigning a batch number to each batch of data to be processed; One of the batch numbers of the batch data to be processed is used as the target batch data, an exclusive lock is added to the target batch data and the target batch data is processed; if the target batch data processing is completed, all the data are obtained The initial preset field value in the target batch data and submit the target batch data to the preset database according to the initial preset field value to release the exclusive lock; and download according to the batch number The to-be-processed batch data of a batch number is processed as the target batch data until all the to-be-processed batch data of all batch numbers are processed.
第二方面,本申请实施例还提供了一种大批量数据处理装置,其包括:分配单元,用于从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;排他单元,用于将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;释放单元,用于若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;处理单元,用于根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。In the second aspect, an embodiment of the present application also provides a mass data processing device, which includes: a distribution unit, configured to obtain all batch data to be processed from a preset database and Allocate batch numbers; an exclusive unit for using the batch data to be processed of one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data; release Unit, configured to obtain the initial preset field value in the target batch data if the target batch data processing is completed, and submit the target batch data to the preset according to the initial preset field value Database to release the exclusive lock; a processing unit for processing the batch data to be processed with the next batch number as the target batch data according to the batch number until the batch number to be processed for all batch numbers All batch data is processed.
第三方面,本申请实施例还提供了一种计算机设备,其包括存储器以及与所述存储器相连的处理器;所述存储器用于存储计算机程序;所述处理器用于运行所述存储器中存储的计算机程序,以执行如下步骤:从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。In a third aspect, an embodiment of the present application also provides a computer device, which includes a memory and a processor connected to the memory; the memory is used to store a computer program; the processor is used to run the A computer program to execute the following steps: obtain all batch data to be processed from a preset database and assign a batch number to each batch data to be processed; and assign the batch data to be processed with one of the batch numbers As the target batch data, add an exclusive lock to the target batch data and process the target batch data; if the target batch data processing is completed, obtain the initial preset field value in the target batch data and Submit the target batch data to the preset database according to the initial preset field value to release the exclusive lock; use the batch data to be processed of the next batch number as the batch number according to the batch number The target batch data is processed until the to-be-processed batch data of all batch numbers are all processed.
第四方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器执行以下步骤:从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。In a fourth aspect, the embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the following steps: Obtain all the batch data to be processed from the preset database and assign a batch number to each batch data to be processed; take the batch data to be processed with one of the batch numbers as the target batch data, and Add an exclusive lock to the target batch data and process the target batch data; if the target batch data processing is completed, obtain the initial preset field value in the target batch data and change the value according to the initial preset field value The target batch data is submitted to the preset database to release the exclusive lock; the batch data to be processed of the next batch number is processed as the target batch data according to the batch number until all batches are processed The processing of the batch data to be processed of the minor number is completed.
附图说明Description of the drawings
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of the present application more clearly, the following will briefly introduce the drawings needed in the description of the embodiments. Obviously, the drawings in the following description are some embodiments of the present application. Ordinary technicians can obtain other drawings based on these drawings without creative work.
图1为本申请实施例提供的大批量数据处理方法的流程示意图;FIG. 1 is a schematic flow chart of a method for processing large batch data provided by an embodiment of the application;
图2为本申请实施例提供的大批量数据处理方法的子流程示意图;FIG. 2 is a schematic diagram of a sub-flow of a method for processing large quantities of data provided by an embodiment of the application;
图3为本申请实施例提供的大批量数据处理方法的子流程示意图;FIG. 3 is a schematic diagram of a sub-flow of a method for processing large batches of data provided by an embodiment of the application;
图4为本申请实施例提供的大批量数据处理方法的子流程示意图;FIG. 4 is a schematic diagram of a sub-flow of a method for processing mass data according to an embodiment of the application;
图5为本申请实施例提供的大批量数据处理方法的子流程示意图;FIG. 5 is a schematic diagram of a sub-flow of a method for processing a large batch of data provided by an embodiment of the application;
图6为本申请实施例提供的大批量数据处理装置的示意性框图;FIG. 6 is a schematic block diagram of a mass data processing device provided by an embodiment of the application;
图7为本申请实施例提供的大批量数据处理装置的具体单元的示意性框图;以及FIG. 7 is a schematic block diagram of specific units of a mass data processing device provided by an embodiment of the application; and
图8为本申请实施例提供的计算机设备的示意性框图。FIG. 8 is a schematic block diagram of a computer device provided by an embodiment of the application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that when used in this specification and the appended claims, the terms "including" and "including" indicate the existence of the described features, wholes, steps, operations, elements and/or components, but do not exclude one or The existence or addition of multiple other features, wholes, steps, operations, elements, components, and/or collections thereof.
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。It should also be understood that the terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in the specification of this application and the appended claims, unless the context clearly indicates other circumstances, the singular forms "a", "an" and "the" are intended to include plural forms.
还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It should be further understood that the term "and/or" used in the specification and appended claims of this application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations .
请参阅图1,图1为本申请实施例提供的大批量数据处理方法的示意性流程 图。该大批量数据处理方法可应用于催收系统中,在服务器中实现。催收系统是借贷公司用于管控借贷数据的信息系统,该系统中包括有大量的与催收相关的数据,且随着每日催收数据的变化,催收系统每日需要处理大批量的催收数据。现有的数据库在处理写操作较少的数据时,通常采用乐观锁来操作数据,通过乐观锁来操作数据时默认其他线程不会修改数据,因此不会对数据上锁,只是在更新数据前判断其他线程在此期间是否修改过数据,采用乐观锁操作数据效率高,但是产生的并发冲突多,降低性能;现有的数据库在处理写操作较多的数据时,通常采用悲观锁来操作数据,通过悲观锁处理数据时默认其他线程会修改数据,因此在操作数据之前先对数据上锁,上锁后的数据其他线程就不能对其进行操作,采用悲观锁操作数据并发冲突少,但是上锁的开销大,耗费资源,且线程时常需要挂起等待,降低性能。对于催收系统来说,每日都需要处理大批量的催收数据,催收数据不仅数据量级大,而且更新频繁。因此,采用本申请的大批量数据处理方法,通过乐观锁与悲观锁相结合的方式,可快速高效地处理大批量数据的同时,保证数据不会重复抓取以及漏处理。Please refer to Fig. 1. Fig. 1 is a schematic flow chart of a method for processing large batch data according to an embodiment of the application. The mass data processing method can be applied to the collection system and implemented in the server. The collection system is an information system used by a lending company to control loan data. The system includes a large amount of collection-related data. With the change of daily collection data, the collection system needs to process large quantities of collection data every day. Existing databases usually use optimistic locking to manipulate data when processing data with fewer write operations. When operating data through optimistic locking, other threads will not modify the data by default, so the data will not be locked, just before updating the data Determine whether other threads have modified the data during this period. Using optimistic locking to manipulate data is highly efficient, but it produces more concurrency conflicts and reduces performance; existing databases usually use pessimistic locks to manipulate data when processing data with more write operations , When processing data through pessimistic lock, other threads will modify the data by default. Therefore, the data is locked before the data is operated. After the data is locked, other threads cannot operate on it. The use of pessimistic lock to operate data has less concurrency conflicts, but on Locking is expensive and resource intensive, and threads often need to be suspended and wait, which reduces performance. For the collection system, a large amount of collection data needs to be processed every day, and the collection data is not only large in size, but also frequently updated. Therefore, by adopting the mass data processing method of the present application, through the combination of optimistic locking and pessimistic locking, mass data can be processed quickly and efficiently while ensuring that the data will not be repeatedly fetched or omitted.
图1是本申请实施例提供的大批量数据处理方法的流程示意图。如图所示,该方法包括以下步骤S110-S140。FIG. 1 is a schematic flowchart of a method for processing large batches of data provided by an embodiment of the present application. As shown in the figure, the method includes the following steps S110-S140.
S110、从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号。S110: Obtain all batch data to be processed from a preset database and assign a batch number to each batch data to be processed.
在一实施例中,预设数据库指的是催收系统的数据库,预设数据库中存储催收系统的催收数据。待处理批次数据指的是需要处理的以批次为单位的催收数据,待处理批次数据的批次根据数据大小预先划分好,例如,待处理批次数据的数据大小一共100G,以1G为一个批次划分为100个批次的待处理批次数据。批次号指的是分配给所述待处理批次数据的编号,每一批次的待处理数据均分配有一批次号,例如,Data processing001。通过批次号来处理所述待处理批次数据,可以保证不会遗漏处理。In one embodiment, the preset database refers to the database of the collection system, and the collection data of the collection system is stored in the preset database. The batch data to be processed refers to the collection data that needs to be processed in batches. The batches of the batch data to be processed are pre-divided according to the data size. For example, the data size of the batch data to be processed is 100G in total, with 1G A batch of data to be processed is divided into 100 batches. The batch number refers to the number assigned to the batch of data to be processed, and each batch of data to be processed is assigned a batch number, for example, Data processing001. The batch number is used to process the batch data to be processed, which can ensure that no processing is missed.
在一实施例中,如图2所示,所述步骤S110可包括步骤S111-S113。In an embodiment, as shown in FIG. 2, the step S110 may include steps S111-S113.
S111、从预设数据库中获取所有待处理批次数据。S111. Obtain all batch data to be processed from a preset database.
S111、根据所述待处理批次数据的批次数量分配批次号。S111. Assign a batch number according to the batch quantity of the batch data to be processed.
S112、根据所述批次号按照由小到大对所述待处理批次数据进行排序。S112: Sort the batch data to be processed from small to large according to the batch number.
在一实施例中,首先从预设数据库中获取所有待处理批次数据,然后根据 所获取的待处理批次数据的批次数量对每一批次的待处理批次数据均分配一个批次号,例如,待处理批次数据的批次数量为100,那么则对这100批的待处理批次数据从0到100一一分配一个批次号,最后再根据批次号按照由小到大的顺序进行排序。在处理待处理批次数据时,则根据该排序的顺序从最小的批次号开始进行处理直到处理完最大批次号的待处理批次数据,从而保证不会遗漏处理。In one embodiment, first obtain all the batch data to be processed from the preset database, and then assign a batch to each batch of batch data to be processed according to the batch quantity of the obtained batch data to be processed For example, if the batch number of the batch data to be processed is 100, then a batch number is assigned to the 100 batches of batch data from 0 to 100, and finally according to the batch number in ascending order Sort in big order. When processing the batch data to be processed, the processing starts from the smallest batch number according to the sorting order until the processing batch data of the largest batch number is processed, so as to ensure that no processing is missed.
S120、将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据。S120: Use the batch data to be processed of one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data.
在一实施例中,排他锁是悲观锁中的一种锁机制,排他锁用于在整个数据处理的过程中,将数据处于锁定状态,其他的进程不能读写数据。为了避免在处理数据的过程中,其他进程对处理中的数据进行读写而造成的数据读写不一致,将其中一个批次号的待处理批次数据作为目标批次数据,采用排他锁的机制锁定该目标批次数据,阻止其他进程对所处理的目标批次数据进行读写,从而保持数据读写的一致性。In one embodiment, the exclusive lock is a locking mechanism in the pessimistic lock. The exclusive lock is used to lock the data during the entire data processing process, and other processes cannot read or write the data. In order to avoid inconsistencies in data reading and writing caused by other processes reading and writing the data being processed during data processing, the batch data to be processed with one of the batch numbers is used as the target batch data, and an exclusive lock mechanism is adopted. Lock the target batch of data to prevent other processes from reading and writing the processed target batch of data, so as to maintain the consistency of data read and write.
在一实施例中,如图3所示,所述步骤S120可包括步骤S121-S124。In an embodiment, as shown in FIG. 3, the step S120 may include steps S121-S124.
S121、将其中一个批次号的所述待处理批次数据作为目标批次数据。S121: Use the batch data to be processed of one of the batch numbers as target batch data.
S122、调用所述预设数据库的排他锁机制对所述目标批次数据添加排他锁。S122. Call the exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data.
S123、对已添加所述排他锁的所述目标批次数据进行处理。S123. Process the target batch data to which the exclusive lock has been added.
S124、对处理完成的所述目标批次数据添加处理标记。S124: Add a processing mark to the processed target batch data.
在一实施例中,排他锁是数据库本身的一种锁机制,因此,在对所述目标批次数据添加排他锁时直接调用预设数据库的排他锁机制锁定所述目标批次数据,具体地,在处理所述目标批次数据的执行语句中加入for update即可实现锁定所述目标批次数据。上锁后则对所述目标批次数据进行处理,其中,所述目标批次数据所进行的处理包括数据的增、删以及改,例如,昨日张三新增贷款5万元,李四还款1万元,王五的借款记录已达五年,那么今日批量处理的所述目标批次数据包括在预设数据库中增加张三新增贷款5万元的记录,减少李四的贷款金额1万元,删除过期的王五的借款记录。处理完成所述目标批次数据后添加一个处理标记,表明该批次的所述待处理批次数据已处理完成。In one embodiment, the exclusive lock is a lock mechanism of the database itself. Therefore, when the exclusive lock is added to the target batch data, the exclusive lock mechanism of the preset database is directly called to lock the target batch data, specifically , The target batch data can be locked by adding for update in the execution statement for processing the target batch data. After the lock is locked, the target batch data is processed. The processing performed on the target batch data includes data addition, deletion, and modification. For example, yesterday, Zhang San added a loan of 50,000 yuan, and Li Si repaid 1 Ten thousand yuan, Wang Wu’s loan record has reached five years, so the target batch data processed in batches today includes the addition of Zhang San’s new loan of 50,000 yuan in the preset database, and the reduction of Li Si’s loan amount of 10,000 yuan. Delete the overdue Wang Wu's loan record. After processing the target batch of data, a processing mark is added to indicate that the processing of the batch of data to be processed has been completed.
S130、若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据 库以释放所述排他锁。S130. If the target batch data processing is completed, obtain an initial preset field value in the target batch data and submit the target batch data to the preset database according to the initial preset field value. Release the exclusive lock.
在一实施例中,初始预设字段值指的是从预设数据库中初次获取目标批次数据时的预设字段值,每一个批次的待处理数据均包含有一预设字段值。预设字段值可以为版本号(version),也可以为时间戳(timestamp)。若预设字段值为版本号,其具体形式为数字类型的字段,例如为1,每当数据更新完成后版本号加一,例如版本号为1的数据更新后为2;若预设字段值为时间戳,其具体形式为时间类型的字段,例如为2018.11.20,00:00,每当数据更新完成后更新时间戳。乐观锁通过初始预设字段值实现,在获取所述目标批次数据时默认其他线程不会对所述目标批次数据进行处理,而是在目标批次数据处理完成后提交到预设数据库时触发乐观锁,根据初始预设字段值判断在获取所述目标批次数据到处理完成所述目标批次数据期间其他线程是否对所述目标批次数据进行了修改。若在此期间其他线程没有对所述目标批次数据进行修改,则提交处理完成的所述目标批次数据至所述预设数据库中从而释放排他锁,其他线程马上即可对所述目标批次数据进行处理了。In one embodiment, the initial preset field value refers to the preset field value when the target batch of data is first obtained from the preset database, and each batch of data to be processed includes a preset field value. The preset field value can be a version number (version) or a timestamp (timestamp). If the preset field value is a version number, the specific form is a numeric field, such as 1, and the version number is incremented by one after the data update is completed, for example, the data with the version number of 1 is updated to 2; if the field value is preset It is a timestamp, and its specific form is a field of time type, for example, 2018.11.20, 00:00. The timestamp is updated every time the data update is completed. Optimistic locking is achieved through initial preset field values. When acquiring the target batch data, other threads will not process the target batch data by default, but when the target batch data is processed and submitted to the preset database The optimistic lock is triggered, and it is judged according to the initial preset field value whether other threads have modified the target batch data during the period from acquiring the target batch data to the completion of processing the target batch data. If other threads do not modify the target batch data during this period, submit the processed target batch data to the preset database to release the exclusive lock, and other threads can immediately modify the target batch The data was processed.
在一实施例中,如图3所示,所述步骤S130可包括步骤S131-S134。In an embodiment, as shown in FIG. 3, the step S130 may include steps S131-S134.
S131、从所述目标批次数据中获取初始预设字段值。S131. Obtain an initial preset field value from the target batch data.
S132、从所述预设数据库中获取所述目标批次数据的当前预设字段值。S132. Obtain the current preset field value of the target batch data from the preset database.
S133、将所述初始预设字段值与所述当前预设字段值进行对比。S133. Compare the initial preset field value with the current preset field value.
S134、若所述初始预设字段值与所述当前预设字段值相同,则提交所述目标批次数据至所述预设数据库以释放所述排他锁。S134: If the initial preset field value is the same as the current preset field value, submit the target batch data to the preset database to release the exclusive lock.
在一实施例中,由于预设字段值是所述目标批次数据中增加的一个字段值,因此从所述目标批次数据中即可获取到初始预设字段值。然后再从预设数据库中读取该批次的所述目标批次数据中的当前预设字段值。接着将所述目标批次数据的初始预设字段值和当前预设字段值进行对比,若两者相同,则说明在获取所述目标批次数据到处理完成所述目标批次数据期间其他线程没有对所述目标批次数据进行过修改。由于预设数据库的排他锁机制是在提交数据库事务时自行解除,因此最后再将处理完成的所述目标批次数据提交至所述预设数据库进行更新后即解除从而释放所述目标批次数据的所述排他锁,其他进程马上就可对所述目标批次数据进行新的处理。其中,若所述目标批次数据的初始预设字段值和当前预设字段值不相同,说明在获取所述目标批次数据到处理完成所 述目标批次数据期间其他线程对所述目标批次数据进行过修改,此时返回错误信息至催收系统,由催收系统进行进一步的处理。In one embodiment, since the preset field value is a field value added to the target batch data, the initial preset field value can be obtained from the target batch data. Then, the current preset field value in the target batch data of the batch is read from the preset database. Then compare the initial preset field value of the target batch of data with the current preset field value. If the two are the same, it means that other threads are in the period from acquiring the target batch of data to processing the target batch of data. The target batch data has not been modified. Since the exclusive lock mechanism of the preset database is automatically released when the database transaction is submitted, finally the processed target batch data is submitted to the preset database for update and then released to release the target batch data With the exclusive lock, other processes can immediately perform new processing on the target batch of data. Wherein, if the initial preset field value of the target batch of data is not the same as the current preset field value, it means that during the period from the acquisition of the target batch of data to the completion of the processing of the target batch of data by other threads, The data has been modified, and the error message is returned to the collection system at this time for further processing by the collection system.
S140、根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。S140: Process the batch data to be processed of the next batch number as target batch data according to the batch number until all the batch data to be processed of all batch numbers are processed.
在一实施例中,从最小批次号的所述待处理批次数据开始处理,处理完成最小批次号的所述待处理批次数据后再处理下一批次号的所述待处理批次数据,按照所分配的批次号由小到大的顺序一一处理。例如,最小批次号是1,当批次号为1的所述待处理批次数据处理完成后,处理批次号为2的所述待处理批次数据,直到所有批次号的所述待处理批次数据全部处理完成。通过批次号按照由小到大的处理顺序可以保证所有的所述待处理批次数据能够全部被处理防止出现遗漏处理的情况。In an embodiment, the processing starts from the batch data to be processed with the smallest batch number, and the batch data to be processed with the smallest batch number is processed, and then the batch to be processed with the next batch number is processed. The secondary data will be processed one by one in the descending order of the assigned batch number. For example, the minimum batch number is 1. After the processing of the batch data to be processed with the batch number 1 is completed, the batch data to be processed with the batch number 2 is processed until all batch numbers are The batch data to be processed is all processed. According to the processing sequence of the batch number from small to large, it can be ensured that all the batch data to be processed can be processed to prevent the omission of processing.
在一实施例中,如图4所示,所述步骤S140可包括步骤S141-S143。In an embodiment, as shown in FIG. 4, the step S140 may include steps S141-S143.
S141、根据所述批次号获取下一批次号的所述待处理批次数据。S141. Obtain the batch data to be processed of the next batch number according to the batch number.
S142、判断所述待处理批次数据是否存在所述处理标记。S142: Determine whether the processing mark exists in the batch of data to be processed.
S143、若所述待处理批次数据存在所述处理标记,将下一批次号的所述待处理批次数据作为目标批次数据进行处理。S143: If the processing mark exists in the batch data to be processed, the batch data to be processed with the next batch number is used as the target batch data for processing.
在一实施例中,在处理下一批次号的所述待处理批次数据之前,需要对当前处理的所述待处理批次数据进行判断,判断当前处理的所述待处理批次数据中是否存在处理标记,若当前的所述待处理批次数据中存在处理标记,说明当前的所述待处理批次数据已处理完成,开始处理下一批次的所述待处理批次数据,即返回至步骤S120开始对下一批次号的所述待处理批次数据进行处理,直至所有的所述待处理批次数据全部处理完成。其中,若当前的所述待处理批次数据中不存在处理标记,说明当前的所述待处理批次数据在处理的过程中发生了异常,例如,某条数据遗漏处理或者处理错误,则返回错误消息至催收系统,由催收系统追溯所述待处理批次数据以进行进一步的处理。In one embodiment, before processing the to-be-processed batch data of the next batch number, it is necessary to judge the currently processed batch-to-be-processed data, and determine whether the currently processed batch data Whether there is a processing mark, if there is a processing mark in the current batch of data to be processed, it means that the processing of the current batch of data to be processed has been completed, and the processing of the next batch of the batch of data to be processed starts, namely Return to step S120 to start processing the batch data to be processed with the next batch number, until all the batch data to be processed are completely processed. Wherein, if there is no processing mark in the current batch of data to be processed, it means that the current batch of data to be processed is abnormal during processing, for example, a certain piece of data is missing or processed incorrectly, then return The error message is sent to the collection system, and the collection system traces the batch data to be processed for further processing.
本申请在处理大批量的催收数据时,首先采用乐观锁的方式从预设数据库中获取待处理批次数据,先不对所述待处理批次数据上锁,其他线程此时依然可以对所述待处理批次数据进行操作。然后根据批次号的顺序首先处理最小批次号的所述待处理批次数据,将该最小批次号的所述待处理批次数据作为目标批次数据,在处理所述目标批次数据时对该批次号的所述目标批次数据添加排 他锁,其他线程此时不可以对该批次号的所述目标批次数据进行操作,但是其他线程此时依然可以对其他批次号的所述待处理批次数据进行操作。接着在该批次号的所述目标批次数据处理完成后,提交到预设数据库时触发乐观锁判断该批次号的所述目标批次数据在获取到处理期间是否被其他线程修改过,若在此期间未被其他线程修改过,则提交处理完成的该批次号的所述目标批次数据至预设数据库进行更新,同时释放该批次号的所述目标批次数据的排他锁,其他线程马上就可以对该批次号的所述目标批次数据进行修改。由此,采用本申请的大批量数据处理方法处理的催收数据,可快速抓取大批量的催收数据,在处理催收数据时对其他线程影响小,其他线程可快速进行新的处理,且保证数据不会重复抓取以及漏处理,极大地提高了大批量数据的处理速度和效率。When processing large batches of collection data, this application first uses optimistic locking to obtain the batch data to be processed from the preset database, first does not lock the batch data to be processed, and other threads can still lock the The batch data to be processed is operated. Then according to the order of the batch number, the batch data to be processed with the smallest batch number is processed first, and the batch data to be processed with the smallest batch number is used as the target batch data. When adding an exclusive lock to the target batch data of the batch number, other threads cannot operate on the target batch data of the batch number at this time, but other threads can still perform operations on other batch numbers at this time. Of the batch of data to be processed. Then, after the target batch data of the batch number is processed, the optimistic lock is triggered when submitted to the preset database to determine whether the target batch data of the batch number has been modified by other threads during the process. If it has not been modified by other threads during this period, submit the processed batch number of the target batch data to the preset database for update, and at the same time release the exclusive lock of the target batch data of the batch number , Other threads can immediately modify the target batch data of the batch number. Therefore, the collection data processed by the mass data processing method of the present application can quickly capture mass collection data, and has little impact on other threads when processing collection data, and other threads can quickly perform new processing and ensure data There is no repeated fetching and missing processing, which greatly improves the processing speed and efficiency of large quantities of data.
本申请实施例展示了一种数据处理方法,通过从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成,可实现保证数据不会重复抓取以及漏处理,提高大批量数据的处理速度。The embodiment of the application shows a data processing method, by acquiring all batch data to be processed from a preset database and assigning a batch number to each batch of data to be processed; The batch data to be processed is used as the target batch data, an exclusive lock is added to the target batch data and the target batch data is processed; if the target batch data processing is completed, the initial batch data in the target batch data is obtained Preset field values and submit the target batch data to the preset database according to the initial preset field values to release the exclusive lock; according to the batch number, the pending batch number of the next batch number The processed batch data is processed as the target batch data until the processing of the batch data to be processed of all batch numbers is completed, which can ensure that the data will not be repeatedly fetched and missed processing, and increase the processing speed of large batch data.
图6是本申请实施例提供的一种大批量数据处理装置200的示意性框图。如图6所示,对应于以上大批量数据处理方法,本申请还提供一种大批量数据处理装置200。该大批量数据处理装置200包括用于执行上述大批量数据处理方法的单元,该装置可以被配置于服务器中。具体地,请参阅图6,该大批量数据处理装置200包括:分配单元210、排他单元220、释放单元230以及处理单元240。FIG. 6 is a schematic block diagram of a mass data processing apparatus 200 provided by an embodiment of the present application. As shown in FIG. 6, corresponding to the above mass data processing method, the present application also provides a mass data processing device 200. The mass data processing device 200 includes a unit for executing the above mass data processing method, and the device can be configured in a server. Specifically, referring to FIG. 6, the mass data processing apparatus 200 includes: an allocation unit 210, an exclusive unit 220, a release unit 230 and a processing unit 240.
分配单元210,用于从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号。The allocation unit 210 is configured to obtain all batch data to be processed from a preset database and allocate a batch number to each batch data to be processed.
在一实施例中,如图7所示,所述分配单元210包括:获取子单元211、分配子单元212以及排序单元213。In an embodiment, as shown in FIG. 7, the allocation unit 210 includes: an acquisition subunit 211, an allocation subunit 212, and a sorting unit 213.
获取子单元211,用于从预设数据库中获取所有待处理批次数据。The obtaining subunit 211 is used to obtain all batch data to be processed from a preset database.
分配子单元212,用于根据所述待处理批次数据的批次数量分配批次号。The allocation subunit 212 is configured to allocate batch numbers according to the batch quantity of the batch data to be processed.
排序单元213,用于根据所述批次号按照由小到大对所述待处理批次数据进行排序。The sorting unit 213 is configured to sort the batch data to be processed from small to large according to the batch number.
排他单元220,用于将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据。The exclusive unit 220 is configured to use the batch data to be processed with one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data.
在一实施例中,如图7所示,所述排他单元220包括:目标单元221、调用单元222、添加单元223以及标记单元224。In an embodiment, as shown in FIG. 7, the exclusive unit 220 includes a target unit 221, a calling unit 222, an adding unit 223 and a marking unit 224.
目标单元221,用于将其中一个批次号的所述待处理批次数据作为目标批次数据。The target unit 221 is configured to use the batch data to be processed of one of the batch numbers as target batch data.
调用单元222,用于调用所述预设数据库的排他锁机制对所述目标批次数据添加排他锁。The calling unit 222 is configured to call the exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data.
添加单元223,用于对已添加所述排他锁的所述目标批次数据进行处理。The adding unit 223 is configured to process the target batch data to which the exclusive lock has been added.
标记单元224,用于对处理完成的所述目标批次数据添加处理标记。The marking unit 224 is used to add a processing mark to the processed target batch data.
释放单元230,用于若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁。The releasing unit 230 is configured to obtain the initial preset field value in the target batch data and submit the target batch data to the target batch data according to the initial preset field value if the processing of the target batch data is completed. The database is preset to release the exclusive lock.
在一实施例中,如图7所示,所述释放单元230包括:第一获取单元231、第二获取单元232、对比单元233以及提交单元234。In an embodiment, as shown in FIG. 7, the releasing unit 230 includes: a first acquiring unit 231, a second acquiring unit 232, a comparing unit 233 and a submitting unit 234.
第一获取单元231,用于从所述目标批次数据中获取初始预设字段值;The first obtaining unit 231 is configured to obtain an initial preset field value from the target batch data;
第二获取单元232,用于从所述预设数据库中获取所述目标批次数据的当前预设字段值;The second obtaining unit 232 is configured to obtain the current preset field value of the target batch data from the preset database;
对比单元233,用于将所述初始预设字段值与所述当前预设字段值进行对比;The comparison unit 233 is configured to compare the initial preset field value with the current preset field value;
提交单元234,用于若所述初始预设字段值与所述当前预设字段值相同,则提交所述目标批次数据至所述预设数据库以释放所述排他锁。The submitting unit 234 is configured to submit the target batch data to the preset database to release the exclusive lock if the initial preset field value is the same as the current preset field value.
处理单元240,用于根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。The processing unit 240 is configured to process the to-be-processed batch data of the next batch number as target batch data according to the batch number until all the to-be-processed batch data of all batch numbers are processed.
在一实施例中,如图7所示,所述处理单元240包括:第三获取单元241、判断单元242以及循环处理单元243。In an embodiment, as shown in FIG. 7, the processing unit 240 includes: a third acquisition unit 241, a judgment unit 242 and a loop processing unit 243.
第三获取单元241,用于根据所述批次号获取下一批次号的所述待处理批次数据;The third obtaining unit 241 is configured to obtain the batch data to be processed of the next batch number according to the batch number;
判断单元242,用于判断所述待处理批次数据是否存在所述处理标记;The determining unit 242 is configured to determine whether the processing mark exists in the batch of data to be processed;
循环处理单元243,用于若所述待处理批次数据存在所述处理标记,将下一批次号的所述待处理批次数据作为目标批次数据进行处理。The loop processing unit 243 is configured to process the to-be-processed batch data of the next batch number as the target batch data if the processing mark exists in the to-be-processed batch data.
需要说明的是,所属领域的技术人员可以清楚地了解到,上述大批量数据处理装置200和各单元的具体实现过程,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned mass data processing apparatus 200 and each unit can refer to the corresponding description in the foregoing method embodiment. For the convenience and conciseness of the description, This will not be repeated here.
上述大批量数据处理装置可以实现为一种计算机程序的形式,该计算机程序可以在如图8所示的计算机设备上运行。The above-mentioned mass data processing apparatus may be implemented in the form of a computer program, and the computer program may be run on a computer device as shown in FIG. 8.
请参阅图8,图8是本申请实施例提供的一种计算机设备的示意性框图。该计算机设备500可以是服务器,其中,服务器可以是独立的服务器,也可以是多个服务器组成的服务器集群。Please refer to FIG. 8. FIG. 8 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 500 may be a server. The server may be an independent server or a server cluster composed of multiple servers.
参阅图8,该计算机设备500包括通过系统总线501连接的处理器502、存储器和网络接口505,其中,存储器可以包括非易失性存储介质503和内存储器504。Referring to FIG. 8, the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
该非易失性存储介质503可存储操作系统5031和计算机程序5032。该计算机程序5032包括程序指令,该程序指令被执行时,可使得处理器502执行一种大批量数据处理方法。The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a method for processing mass data.
该处理器502用于提供计算和控制能力,以支撑整个计算机设备500的运行。The processor 502 is used to provide calculation and control capabilities to support the operation of the entire computer device 500.
该内存储器504为非易失性存储介质503中的计算机程序5032的运行提供环境,该计算机程序5032被处理器502执行时,可使得处理器502执行一种大批量数据处理方法。The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a large-scale data processing method.
该网络接口505用于与其它设备进行网络通信。本领域技术人员可以理解,图8中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备500的限定,具体的计算机设备500可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface 505 is used for network communication with other devices. Those skilled in the art can understand that the structure shown in FIG. 8 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
其中,所述处理器502用于运行存储在存储器中的计算机程序5032,以实 现本申请实施例的大批量数据处理方法。Wherein, the processor 502 is configured to run a computer program 5032 stored in a memory, so as to implement the mass data processing method in the embodiment of the present application.
应当理解,在本申请实施例中,处理器502可以是中央处理单元(Central Processing Unit,CPU),该处理器502还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable GateArray,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that, in this embodiment of the application, the processor 502 may be a central processing unit (Central Processing Unit, CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), Application Specific Integrated Circuit (ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
本领域普通技术人员可以理解的是实现上述实施例的方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成。该计算机程序包括程序指令,计算机程序可存储于一存储介质中,该存储介质为计算机可读存储介质。该程序指令被该计算机系统中的至少一个处理器执行,以实现上述方法的实施例的流程步骤。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the foregoing embodiments can be implemented by computer programs instructing relevant hardware. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the foregoing method embodiments.
因此,本申请还提供一种存储介质。该存储介质可以为计算机可读存储介质。该存储介质存储有计算机程序,该计算机程序被处理器执行时使处理器执行以上各实施例中所描述的大批量数据处理方法的步骤。Therefore, this application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the mass data processing method described in the above embodiments.
所述存储介质可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的计算机可读存储介质。The storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk or an optical disk, and other computer-readable storage media that can store program codes.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two, in order to clearly illustrate the hardware and software Interchangeability. In the above description, the composition and steps of each example have been generally described in terms of function. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的。例如,各个单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed device and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be omitted or not implemented.
本申请实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。 本申请实施例装置中的单元可以根据实际需要进行合并、划分和删减。另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。The steps in the method of the embodiment of the present application can be adjusted, merged, and deleted in order according to actual needs. The units in the devices in the embodiments of the present application may be combined, divided, and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,终端,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium It includes several instructions to make a computer device (which may be a personal computer, a terminal, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above are only specific implementations of this application, but the protection scope of this application is not limited to this. Anyone familiar with the technical field can easily think of various equivalents within the technical scope disclosed in this application. Modifications or replacements, these modifications or replacements shall be covered within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.

Claims (20)

  1. 一种大批量数据处理方法,包括:A method for processing large quantities of data, including:
    从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;Obtain all batch data to be processed from the preset database and assign a batch number to each batch data to be processed;
    将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;Taking the batch data to be processed of one of the batch numbers as target batch data, adding an exclusive lock to the target batch data, and processing the target batch data;
    若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;If the target batch data processing is completed, obtain the initial preset field value in the target batch data and submit the target batch data to the preset database according to the initial preset field value to release all State exclusive lock;
    根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。The batch data to be processed of the next batch number is processed as the target batch data according to the batch number until all the batch data to be processed of all batch numbers are processed.
  2. 根据权利要求1所述的大批量数据处理方法,其中,所述从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号,包括:The method for processing large batch data according to claim 1, wherein said acquiring all batch data to be processed from a preset database and assigning a batch number to each batch data to be processed comprises:
    从预设数据库中获取所有待处理批次数据;Obtain all batch data to be processed from the preset database;
    根据所述待处理批次数据的批次数量分配批次号;Allocating batch numbers according to the batch quantity of the batch data to be processed;
    根据所述批次号按照由小到大对所述待处理批次数据进行排序。Sort the batch data to be processed according to the batch number from small to large.
  3. 根据权利要求1所述的大批量数据处理方法,其中,所述将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据,包括:The method according to claim 1, wherein the batch data to be processed with one of the batch numbers is used as the target batch data, an exclusive lock is added to the target batch data, and all the batch data is processed State the target batch data, including:
    将其中一个批次号的所述待处理批次数据作为目标批次数据;Use the batch data to be processed of one of the batch numbers as the target batch data;
    调用所述预设数据库的排他锁机制对所述目标批次数据添加排他锁;Calling the exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data;
    对已添加所述排他锁的所述目标批次数据进行处理;Processing the target batch data to which the exclusive lock has been added;
    对处理完成的所述目标批次数据添加处理标记。Add a processing mark to the processed target batch data.
  4. 根据权利要求1所述的大批量数据处理方法,其中,所述获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁,包括:The method for processing mass data according to claim 1, wherein said acquiring an initial preset field value in said target batch data and submitting said target batch data to said target batch data according to said initial preset field value The preset database to release the exclusive lock includes:
    从所述目标批次数据中获取初始预设字段值;Obtaining initial preset field values from the target batch data;
    从所述预设数据库中获取所述目标批次数据的当前预设字段值;Acquiring the current preset field value of the target batch data from the preset database;
    将所述初始预设字段值与所述当前预设字段值进行对比;Comparing the initial preset field value with the current preset field value;
    若所述初始预设字段值与所述当前预设字段值相同,则提交所述目标批次数据至所述预设数据库以释放所述排他锁。If the initial preset field value is the same as the current preset field value, submit the target batch data to the preset database to release the exclusive lock.
  5. 根据权利要求3所述的大批量数据处理方法,其中,所述根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成,包括:The mass data processing method according to claim 3, wherein the batch data to be processed of the next batch number is processed as the target batch data according to the batch number until all batch numbers are The processing of the batch data to be processed is completed, including:
    根据所述批次号获取下一批次号的所述待处理批次数据;Acquiring the batch data to be processed of the next batch number according to the batch number;
    判断所述待处理批次数据是否存在所述处理标记;Determine whether the processing mark exists in the batch of data to be processed;
    若所述待处理批次数据存在所述处理标记,将下一批次号的所述待处理批次数据作为目标批次数据进行处理。If the processing mark exists in the batch data to be processed, the batch data to be processed with the next batch number is used as the target batch data for processing.
  6. 根据权利要求4所述的大批量数据处理方法,其中,所述初始预设字段值为版本号。The method for processing mass data according to claim 4, wherein the initial preset field value is a version number.
  7. 根据权利要求4所述的大批量数据处理方法,其中,所述初始预设字段值为时间戳。The method for processing mass data according to claim 4, wherein the initial preset field value is a timestamp.
  8. 一种大批量数据处理装置,包括:A mass data processing device, including:
    分配单元,用于从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;The allocation unit is configured to obtain all batch data to be processed from the preset database and allocate a batch number to each batch data to be processed;
    排他单元,用于将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;An exclusive unit, configured to use the batch data to be processed of one of the batch numbers as target batch data, add an exclusive lock to the target batch data, and process the target batch data;
    释放单元,用于若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;The releasing unit is configured to, if the processing of the target batch data is completed, obtain the initial preset field value in the target batch data and submit the target batch data to the preset according to the initial preset field value Set up a database to release the exclusive lock;
    处理单元,用于根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。The processing unit is configured to process the to-be-processed batch data of the next batch number as target batch data according to the batch number until all the to-be-processed batch data of all batch numbers are processed.
  9. 根据权利要求8所述的大批量数据处理装置,其中,所述分配单元包括:The mass data processing device according to claim 8, wherein the allocating unit comprises:
    获取子单元,用于从预设数据库中获取所有待处理批次数据;The acquiring subunit is used to acquire all the batch data to be processed from the preset database;
    分配子单元,用于根据所述待处理批次数据的批次数量分配批次号;An allocation sub-unit for allocating a batch number according to the batch quantity of the batch data to be processed;
    排序单元,用于根据所述批次号按照由小到大对所述待处理批次数据进行排序。The sorting unit is used to sort the batch data to be processed from small to large according to the batch number.
  10. 根据权利要求8所述的大批量数据处理装置,其中,所述排他单元包括:The mass data processing device according to claim 8, wherein the exclusive unit comprises:
    目标单元,用于将其中一个批次号的所述待处理批次数据作为目标批次数 据;The target unit is used to use the batch data to be processed of one of the batch numbers as target batch data;
    调用单元,用于调用所述预设数据库的排他锁机制对所述目标批次数据添加排他锁;A calling unit for calling an exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data;
    添加单元,用于对已添加所述排他锁的所述目标批次数据进行处理;The adding unit is used to process the target batch data to which the exclusive lock has been added;
    标记单元,用于对处理完成的所述目标批次数据添加处理标记。The marking unit is used to add a processing mark to the processed target batch data.
  11. 一种计算机设备,包括存储器以及与所述存储器相连的处理器;所述存储器用于存储计算机程序;所述处理器用于运行所述存储器中存储的计算机程序,以执行如下步骤:A computer device includes a memory and a processor connected to the memory; the memory is used to store a computer program; the processor is used to run the computer program stored in the memory to perform the following steps:
    从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;Obtain all batch data to be processed from the preset database and assign a batch number to each batch data to be processed;
    将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;Taking the batch data to be processed of one of the batch numbers as target batch data, adding an exclusive lock to the target batch data, and processing the target batch data;
    若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;If the target batch data processing is completed, obtain the initial preset field value in the target batch data and submit the target batch data to the preset database according to the initial preset field value to release all State exclusive lock;
    根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。The batch data to be processed of the next batch number is processed as the target batch data according to the batch number until all the batch data to be processed of all batch numbers are processed.
  12. 根据权利要求11所述的计算机设备,其中,所述从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号,包括:11. The computer device according to claim 11, wherein said acquiring all batch data to be processed from a preset database and assigning a batch number to each batch data to be processed comprises:
    从预设数据库中获取所有待处理批次数据;Obtain all batch data to be processed from the preset database;
    根据所述待处理批次数据的批次数量分配批次号;Allocating batch numbers according to the batch quantity of the batch data to be processed;
    根据所述批次号按照由小到大对所述待处理批次数据进行排序。Sort the batch data to be processed according to the batch number from small to large.
  13. 根据权利要求11所述的计算机设备,其中,所述将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据,包括:The computer device according to claim 11, wherein the batch data to be processed of one of the batch numbers is used as target batch data, an exclusive lock is added to the target batch data, and the target batch is processed Secondary data, including:
    将其中一个批次号的所述待处理批次数据作为目标批次数据;Use the batch data to be processed of one of the batch numbers as the target batch data;
    调用所述预设数据库的排他锁机制对所述目标批次数据添加排他锁;Calling the exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data;
    对已添加所述排他锁的所述目标批次数据进行处理;Processing the target batch data to which the exclusive lock has been added;
    对处理完成的所述目标批次数据添加处理标记。Add a processing mark to the processed target batch data.
  14. 根据权利要求11所述的计算机设备,其中,所述获取所述目标批次数据 中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁,包括:The computer device according to claim 11, wherein said acquiring the initial preset field value in the target batch data and submitting the target batch data to the preset according to the initial preset field value The database to release the exclusive lock, including:
    从所述目标批次数据中获取初始预设字段值;Obtaining initial preset field values from the target batch data;
    从所述预设数据库中获取所述目标批次数据的当前预设字段值;Acquiring the current preset field value of the target batch data from the preset database;
    将所述初始预设字段值与所述当前预设字段值进行对比;Comparing the initial preset field value with the current preset field value;
    若所述初始预设字段值与所述当前预设字段值相同,则提交所述目标批次数据至所述预设数据库以释放所述排他锁。If the initial preset field value is the same as the current preset field value, submit the target batch data to the preset database to release the exclusive lock.
  15. 根据权利要求13所述的计算机设备,其中,所述根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成,包括:The computer device according to claim 13, wherein the batch data of the next batch number to be processed is processed as target batch data according to the batch number until the batch number of all batch numbers is to be processed. All processing batch data is completed, including:
    根据所述批次号获取下一批次号的所述待处理批次数据;Acquiring the batch data to be processed of the next batch number according to the batch number;
    判断所述待处理批次数据是否存在所述处理标记;Determine whether the processing mark exists in the batch of data to be processed;
    若所述待处理批次数据存在所述处理标记,将下一批次号的所述待处理批次数据作为目标批次数据进行处理。If the processing mark exists in the batch data to be processed, the batch data to be processed with the next batch number is used as the target batch data for processing.
  16. 根据权利要求14所述的计算机设备,其中,所述初始预设字段值为版本号。The computer device according to claim 14, wherein the initial preset field value is a version number.
  17. 根据权利要求14所述的计算机设备,其中,所述初始预设字段值为时间戳。The computer device according to claim 14, wherein the initial preset field value is a timestamp.
  18. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器执行以下步骤:A computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor executes the following steps:
    从预设数据库中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号;Obtain all batch data to be processed from the preset database and assign a batch number to each batch data to be processed;
    将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据;Taking the batch data to be processed of one of the batch numbers as target batch data, adding an exclusive lock to the target batch data, and processing the target batch data;
    若所述目标批次数据处理完成,获取所述目标批次数据中的初始预设字段值并根据所述初始预设字段值将所述目标批次数据提交至所述预设数据库以释放所述排他锁;If the target batch data processing is completed, obtain the initial preset field value in the target batch data and submit the target batch data to the preset database according to the initial preset field value to release all State exclusive lock;
    根据所述批次号将下一批次号的所述待处理批次数据作为目标批次数据进行处理直至所有批次号的所述待处理批次数据全部处理完成。The batch data to be processed of the next batch number is processed as the target batch data according to the batch number until all the batch data to be processed of all batch numbers are processed.
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述从预设数据库 中获取所有待处理批次数据并对每个所述待处理批次数据分配批次号的步骤,包括:18. The computer-readable storage medium according to claim 18, wherein the step of acquiring all batch data to be processed from a preset database and assigning a batch number to each batch data to be processed comprises:
    从预设数据库中获取所有待处理批次数据;Obtain all batch data to be processed from the preset database;
    根据所述待处理批次数据的批次数量分配批次号;Allocating batch numbers according to the batch quantity of the batch data to be processed;
    根据所述批次号按照由小到大对所述待处理批次数据进行排序。Sort the batch data to be processed according to the batch number from small to large.
  20. 根据权利要求18所述的计算机可读存储介质,其中,所述将其中一个批次号的所述待处理批次数据作为目标批次数据,对所述目标批次数据添加排他锁并处理所述目标批次数据的步骤,包括:The computer-readable storage medium according to claim 18, wherein the batch data to be processed of one of the batch numbers is used as target batch data, an exclusive lock is added to the target batch data, and all the batch data is processed The steps to describe the target batch data include:
    将其中一个批次号的所述待处理批次数据作为目标批次数据;Use the batch data to be processed of one of the batch numbers as the target batch data;
    调用所述预设数据库的排他锁机制对所述目标批次数据添加排他锁;Calling the exclusive lock mechanism of the preset database to add an exclusive lock to the target batch of data;
    对已添加所述排他锁的所述目标批次数据进行处理;Processing the target batch data to which the exclusive lock has been added;
    对处理完成的所述目标批次数据添加处理标记。Add a processing mark to the processed target batch data.
PCT/CN2019/117745 2019-05-05 2019-11-13 Bulk data processing method and apparatus, and computer device and storage medium WO2020224216A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910367480.8A CN110263048A (en) 2019-05-05 2019-05-05 High-volume data processing method, device, computer equipment and storage medium
CN201910367480.8 2019-05-05

Publications (1)

Publication Number Publication Date
WO2020224216A1 true WO2020224216A1 (en) 2020-11-12

Family

ID=67914167

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/117745 WO2020224216A1 (en) 2019-05-05 2019-11-13 Bulk data processing method and apparatus, and computer device and storage medium

Country Status (2)

Country Link
CN (1) CN110263048A (en)
WO (1) WO2020224216A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263048A (en) * 2019-05-05 2019-09-20 平安科技(深圳)有限公司 High-volume data processing method, device, computer equipment and storage medium
CN111126948A (en) * 2019-12-02 2020-05-08 中国建设银行股份有限公司 Processing method and device for approval process
CN111611229B (en) * 2020-06-11 2023-05-26 上海乾臻信息科技有限公司 Data storage method and device for data storage
CN113094185A (en) * 2021-04-13 2021-07-09 中国工商银行股份有限公司 Method and device for detecting parallel data processing abnormity of database batch program
CN114756595B (en) * 2022-06-14 2022-08-26 希望知舟技术(深圳)有限公司 Data processing method and related device for database

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170046412A1 (en) * 2014-04-01 2017-02-16 Huawei Technologies Co., Ltd. Method for Querying and Updating Entries in a Database
CN109344164A (en) * 2018-10-31 2019-02-15 迈普通信技术股份有限公司 Date storage method and device
CN109460303A (en) * 2018-09-11 2019-03-12 阿里巴巴集团控股有限公司 A kind of data processing method and device, a kind of calculating equipment and storage medium
CN109542922A (en) * 2018-11-29 2019-03-29 泰康保险集团股份有限公司 For the processing method and related system of real-time service data
CN109656980A (en) * 2018-12-27 2019-04-19 Oppo(重庆)智能科技有限公司 Data processing method, electronic equipment, device and readable storage medium storing program for executing
CN110263048A (en) * 2019-05-05 2019-09-20 平安科技(深圳)有限公司 High-volume data processing method, device, computer equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7734604B1 (en) * 2000-11-16 2010-06-08 Teradata Us, Inc. Locking data in a database after an operation has begun
US6850938B1 (en) * 2001-02-08 2005-02-01 Cisco Technology, Inc. Method and apparatus providing optimistic locking of shared computer resources
CN104199869B (en) * 2014-08-18 2017-10-10 中国建设银行股份有限公司 A kind of business batch processing method, service server and system
CN107908344B (en) * 2017-11-08 2019-09-10 平安科技(深圳)有限公司 Method, apparatus, equipment and the computer readable storage medium for preventing interface from shaking
CN107957903B (en) * 2017-11-13 2020-11-10 中国平安财产保险股份有限公司 Asynchronous task scheduling method, server and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170046412A1 (en) * 2014-04-01 2017-02-16 Huawei Technologies Co., Ltd. Method for Querying and Updating Entries in a Database
CN109460303A (en) * 2018-09-11 2019-03-12 阿里巴巴集团控股有限公司 A kind of data processing method and device, a kind of calculating equipment and storage medium
CN109344164A (en) * 2018-10-31 2019-02-15 迈普通信技术股份有限公司 Date storage method and device
CN109542922A (en) * 2018-11-29 2019-03-29 泰康保险集团股份有限公司 For the processing method and related system of real-time service data
CN109656980A (en) * 2018-12-27 2019-04-19 Oppo(重庆)智能科技有限公司 Data processing method, electronic equipment, device and readable storage medium storing program for executing
CN110263048A (en) * 2019-05-05 2019-09-20 平安科技(深圳)有限公司 High-volume data processing method, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110263048A (en) 2019-09-20

Similar Documents

Publication Publication Date Title
WO2020224216A1 (en) Bulk data processing method and apparatus, and computer device and storage medium
US6889269B2 (en) Non-blocking concurrent queues with direct node access by threads
US20190213080A1 (en) Implementing Clone Snapshots In A Distributed Storage System
US7823157B2 (en) Dynamic queue for use in threaded computing environment
US11334474B2 (en) Fast change impact analysis tool for large-scale software systems
US10242044B2 (en) System and method of rolling upgrades of data traits
US10102047B2 (en) In-memory data analytic system that provides an integrated tracking mechanism for explicit memory resources
US20030041069A1 (en) System and method for managing bi-directional relationships between objects
JP5652480B2 (en) Database update notification method
US9330122B2 (en) System and method of dynamic data object upgrades
US8458511B2 (en) Fault isolation using code paths
US7752181B2 (en) System and method for performing a data uniqueness check in a sorted data set
US20190095475A1 (en) Atomic Updates of Versioned Data Structures
US9659041B2 (en) Model for capturing audit trail data with reduced probability of loss of critical data
US20130268503A1 (en) Database navigation of changes at commit time
US20210311755A1 (en) Schema-based classification of data on a system
JP2013186765A (en) Batch processing system, progress confirmation device, progress confirmation method and program
WO2020232892A1 (en) Method and apparatus for key management for blockchain, device, and storage medium
CN114846458A (en) Distributed serializable concurrency control scheme
US20150058292A1 (en) Resuming big data transformations
CN110727666A (en) Cache assembly, method, equipment and storage medium for industrial internet platform
US20190213081A1 (en) Multi-Role Application Orchestration In A Distributed Storage System
CN109710698A (en) A kind of data assemblage method, device, electronic equipment and medium
JP2013200601A (en) Database system, commitment method in database system, and program
JP2001134476A (en) Method for updating data base in a batch

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: 19927778

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: 19927778

Country of ref document: EP

Kind code of ref document: A1