High-concurrency data processing method and device based on compressed bitmap and storage medium

By adopting a high-concurrency data processing method based on compressed bitmaps in large-scale data processing, using the read-write lock mechanism and optimized data storage structure, the problems of uneven data storage and thread safety are solved, and efficient concurrent processing and stability are achieved. .

CN118838918APending Publication Date: 2024-10-25CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410154937.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2024-10-25

AI Technical Summary

Technical Problem

The existing technology has uneven data storage, serious waste of resources and thread safety issues in large-scale data processing, which affects query efficiency and concurrent processing capabilities.

Method used

Adopt a high-concurrency data processing method based on compressed bitmaps, read and update the number table in parallel through multiple threads, use read lock and write lock mechanisms to ensure thread safety, avoid read and write conflicts, and optimize the data storage structure to adapt to changes in data volume.

Benefits of technology

It achieves efficient concurrent data processing, reduces resource waste, improves query efficiency and thread safety, and ensures the stability and efficiency of the data processing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118838918A_ABST
    Figure CN118838918A_ABST
Patent Text Reader

Abstract

The invention provides a high-concurrency data processing method and device based on a compressed bitmap and a storage medium. The method comprises the following steps: acquiring user numbers in a plurality of pieces of to-be-processed service information; judging whether the user numbers are matched with the user numbers in a number table or not through a plurality of first threads, and obtaining the user numbers matched with the number table; wherein each first thread corresponds to one piece of service information, each first thread performs reading operation on the number table through a read lock, and the read locks among the plurality of first threads do not conflict; adding and deleting information of a target user number is received through a second thread, the first thread is blocked, the second thread executes the adding and deleting information operation through a write lock so as to update a number table, and the second thread and the first thread are mutually exclusive; and performing service processing according to the matched user number. According to the method provided by the invention, the security of a big data processing thread is improved, and meanwhile, the high efficiency of high-concurrency data processing is also improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a high-concurrency data processing method, device and storage medium based on a compressed bitmap. Background Art

[0002] Generally speaking, for large-scale data processing, due to the large number of upstream messages, the data needs to be processed extremely quickly, and high concurrency must be met while ensuring thread safety.

[0003] The industry processes large-scale data using bit array storage. However, bit array storage has serious resource waste and uneven storage, which seriously affects query efficiency.

[0004] As a data structure used for efficient and accurate statistical operations on big data, efficient compressed bitmap has problems such as thread safety. Summary of the invention

[0005] The present application provides a high-concurrency data processing method, device and storage medium based on compressed bitmaps, which are used to solve the problems of uneven data storage, affecting query efficiency, and thread safety issues during read and write operations when performing high-concurrency data processing in the prior art.

[0006] In a first aspect, the present application provides a high-concurrency data processing method based on a compressed bitmap, the method comprising:

[0007] Acquire multiple pieces of service information to be processed, each of which includes a user number;

[0008] Determine whether the user number in each service information matches the user number in the number table through multiple first threads, and obtain the matching user number matching the number table; wherein each first thread corresponds to one service information, each first thread reads the number table through a read lock, and the read locks between the multiple first threads do not conflict; wherein the number table is implemented by a compressed bitmap;

[0009] If the addition and deletion information including the target user number is received through the second thread, the first thread is blocked, and the addition and deletion information is executed through the second thread to update the number table, wherein the second thread performs addition and deletion operations on the number table through a write lock, and the second thread and the first thread are mutually exclusive;

[0010] Business processing is performed according to the matched user number.

[0011] In a possible implementation, receiving the addition and deletion information including the target user number through the second thread, blocking the first thread, and executing the addition and deletion information through the second thread includes:

[0012] Starting a thread pool, wherein the thread pool includes a plurality of second threads;

[0013] Controlling the plurality of second threads to cyclically acquire the addition and deletion information for adding and deleting the target user number in a preset sequence, wherein the preset sequence is that the start time of the second thread in the latter position is earlier than the end time of the second thread in the former position;

[0014] When any second thread reads the addition and deletion information, the first thread is blocked, and the addition and deletion operations on the number table are performed through the second thread.

[0015] In a possible implementation, controlling the plurality of second threads to cyclically acquire the addition and deletion information for adding and deleting the target user number in a preset order includes:

[0016] For each second thread, the second thread detects new Kafka messages in real time;

[0017] If the new Kafka message includes a user number and an add / delete operation instruction, the add / delete information is obtained according to the new Kafka message.

[0018] In a possible implementation, before determining whether the user number in each service information matches the user number in the number table through the multiple first threads, the method further includes:

[0019] Acquiring telecommunication history data, wherein the telecommunication history data includes user numbers for which service processing has been performed;

[0020] The user number in the telecommunication history data is read through a third thread and written into the number table, wherein the third thread completes the read and write operations through a competitive lock, and when the third thread is working, other threads are blocked.

[0021] In a possible implementation, determining whether the user number in each service information matches the user number in the number table through the multiple first threads includes:

[0022] Determine, by using a plurality of first threads, whether there is a user number matching the user number in a number table of a preset data structure, wherein the preset data structure splits the long type data of 2N bits into a high-order N-bit keyword and a low-order N-bit value, and stores the low-order N-bit value in a container;

[0023] Among them, the same container includes multiple low-order N-bit values, the same container corresponds to the same keyword, the keyword is used as a query index for the user number, and the query index and the low-order N-bit value correspond to the user number stored in the number table.

[0024] In a possible implementation, the method further includes:

[0025] When storing a new user number in the number table, the type of the container may change as the amount of data changes;

[0026] Wherein, when the amount of data in the number table is less than or equal to the first capacity, the type of the container is the first type;

[0027] When the amount of data in the number table is greater than the first capacity, a second capacity corresponding to the second mode and a third capacity of the third mode are obtained, and a type corresponding to a smaller capacity between the second capacity and the third capacity is selected as the type of the container.

[0028] In a possible implementation, the read lock and the write lock are both object locks.

[0029] In a second aspect, the present application provides a device for high-concurrency data processing based on a compressed bitmap, the device comprising:

[0030] An acquisition module, used for acquiring a plurality of service information to be processed, each of which includes a user number;

[0031] A judgment module, used to judge whether the user number in each service information matches the user number in the number table through multiple first threads, and obtain a matching user number that matches the number table; wherein each first thread corresponds to one service information, each first thread reads the number table through a read lock, and the read locks between the multiple first threads do not conflict; wherein the number table is implemented by a compressed bitmap;

[0032] An update module, configured to block the first thread if adding or deleting information including a target user number is received through a second thread, and execute the adding or deleting information through the second thread to update the number table, wherein the second thread performs adding or deleting operations on the number table through a write lock, and the second thread and the first thread are mutually exclusive;

[0033] The processing module performs service processing according to the matched user number.

[0034] In a third aspect, the present application provides a device for high-concurrency data processing based on a compressed bitmap, the device comprising:

[0035] Processor and memory;

[0036] The memory stores computer-executable instructions;

[0037] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs various optional high-concurrency data processing methods as in the first aspect.

[0038] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, various optional high-concurrency data processing methods based on compressed bitmaps of the first aspect are implemented.

[0039] The present application provides a method, device, equipment and storage medium for high-concurrency data processing based on compressed bitmaps, wherein the method matches multiple first threads with a number table through the acquired user number, and at the same time, the second thread adds and deletes user target information and updates the number table. When the second thread adds and deletes the target user number, the first thread operation is blocked, the number table information is updated, and finally the corresponding business processing is performed. In addition, the present application adds a read lock and a write lock to the first thread and the second thread respectively, so that the read thread and the write thread will not conflict with each other, thereby improving the security during the data processing process. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0041] Figure 1 A flow chart of a high-concurrency data processing method based on a compressed bitmap provided in an embodiment of the present application Figure 1 .

[0042] Figure 2 A flow chart of a high-concurrency data processing method based on a compressed bitmap provided in an embodiment of the present application Figure 2 .

[0043] Figure 3 A flow chart of a high-concurrency data processing method based on a compressed bitmap provided in an embodiment of the present application Figure 3 .

[0044] Figure 4 A schematic diagram of a high-concurrency data processing device based on a compressed bitmap provided in an embodiment of the present application.

[0045] Figure 5 A schematic diagram of a high-concurrency data processing device based on a compressed bitmap provided in an embodiment of the present application.

[0046] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0047] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0048] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0049] First, the terms involved in this application are explained:

[0050] Flink: is an open source stream processing framework, whose core is a distributed stream data flow engine written in Java and Scala. Flink executes any stream data program in a data parallel and pipeline manner. Flink's pipeline runtime system can execute batch and stream processing programs.

[0051] Kafka: is an open source stream processing platform written in Scala and Java; Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action stream data of consumers on the website. This action (web browsing, search and other user actions) is a key factor in many social functions on the modern network. This data is usually solved by processing logs and log aggregation due to throughput requirements. For log data and offline analysis systems like Hadoop, but with the limitation of real-time processing, this is a viable solution. Kafka aims to unify online and offline message processing through Hadoop's parallel loading mechanism, and also to provide real-time messages through clusters.

[0052] Efficient Compression Bitmap (RBM): is a data structure used to perform statistical operations on extremely large amounts of data at the big data level with relative efficiency and absolute accuracy. Its basis is the bit array (bitmap). When using the bit array to store data, take the mobile phone number commonly used in the communication field as an example (in actual production, considering user privacy issues, the mobile phone number will be encrypted and stored in a complex string format. The example here is simplified to store the mobile phone number in digital format, the same below).

[0053] Among them, Roaring64NavigableMap is a 64-bit efficient compressed bitmap. It first splits the 64-bit long type data stored in it into two parts. The high 32 bits of the first part are used as the key to identify the low 32 bits of the second part, and the second part is stored as the value in the corresponding RoaringBitmap.

[0054] RoaringBitMap divides 32-bit unsigned integers into buckets according to the high 16 bits, that is, there may be a maximum of 2 to the 16th power = 65536 buckets, which are called containers. When storing data, the container is found according to the high 16 bits of the data. If it cannot be found, a new container will be created and the low 16 bits will be placed in this container. In other words, a RoaringBitmap is a collection of many containers. There is also a key-value correspondence relationship within the collection. The key is the first half of the 16 bits of the int type. The key array is always kept in order to facilitate binary search. The second half of the 16 bits are regarded as the value and stored in the container. Among them, the container has the following three forms:

[0055] ArrayContainer: directly stores the second half of the 16 bits as a short type, without any compression, and the binary search complexity is O(logn). Assuming there are N numbers, the storage space for storing them using ArrayContainer is 2B*N. According to the source code, the maximum number it can store is default_max_size=4096. If it exceeds this value, it will automatically convert to BitmapContainer type.

[0056] BitmapContainer: Uses an array of longs to store bitmap data. The second half of the 16 bits is treated as a 16-bit integer with a value range of 0 to 65536. Each of these values ​​occupies one bit for storage, requiring a total of 65536 bits, or 1024 long types (each long type provides 64 bits), or 8KB of storage space. Because each number is identified by one bit, it can be directly addressed by the subscript, with a complexity of only O(1). However, this type will generate a long[] array with a length of 1024 when initialized. Even if only one number is stored, 8KB of storage space will be wasted.

[0057] RunContainer: A container based on the run length encoding algorithm. For consecutive numbers, it only records the initial number and the subsequent number, which has a good compression effect on continuous data.

[0058] In the prior art, for large-scale data, the underlying logic of the industry's processing is to use bit array storage. Bit array storage of numbers is not perfect and has two main problems: first, no matter how many numbers need to be recorded in the actual business, the memory space required for storage remains unchanged, and the sparser the numbers, the more serious the waste of resources; second, for example, actual mobile phone numbers generally start with 1, which is an 11-digit integer concentrated in certain number segments. At the same time, there are Internet of Things numbers and private network numbers with different digits. The number storage is uneven, which seriously affects the query efficiency.

[0059] In order to solve the above problems, the industry has proposed compression methods such as WAH, EWAH, Concise and RBM based on run-length encoding (RLE). However, RBM only supports storing integers of the length of int type variables, and the improved storage data structure has thread safety issues.

[0060] For example, a common mobile phone number is 11 digits. In the Java language commonly used for big data processing, this exceeds the maximum value of the int data type, 2147483647 (2^31-1), and needs to be stored as a long variable. It can be noticed that this will cause a huge waste of resources. The maximum value of the long data type is 9223372036854775807 (2^63-1), which is far more than an 11-digit mobile phone number or a special IoT or private network number, and also far more than the total number of user mobile phone numbers in actual business. This requires us to consider using other data types to store and operate mobile phone numbers.

[0061] However, when using the RBM data type to store and operate mobile phone numbers, if some threads trigger container changes, such as a write thread adding or deleting numbers from the number table, exceeding the original container's memory usage change boundary, thereby triggering the container to shrink, and the original thread has not yet completed the query operation, thread insecurity will occur. Due to business needs, this large-scale read and write conflict is inevitable.

[0062] Therefore, the present application provides a high-concurrency data processing method based on compressed bitmaps. The method can read data in parallel from a number table that stores numbers, and realize high-concurrency data processing by combining read-write locks. By using read-write locks, read locks and read locks are not mutually exclusive, only read locks and write locks are mutually exclusive. High-concurrency reads can be processed in parallel, and read operations are blocked only during write operations. Therefore, under the premise of ensuring thread safety, the program running efficiency is not affected during most of the program running time.

[0063] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0064] First, the storage structure of the number table in the present application is described in detail. The structure of the number table can be a preset structure based on an efficient compression bitmap.

[0065] The preset data structure splits the 2N-bit long type data into a high-order N-bit keyword and a low-order N-bit value, and stores the low-order N-bit value in a container;

[0066] The preset data structure in the number table is implemented based on an efficient compression bitmap (RoaingBitmap). In the specific implementation process, the 64-bit data is split, the high 32 bits are used as a keyword (key), the low 32 bits of the second part are identified, and the low 32 bits of the second part are stored as a value (value) in the corresponding high-bit compression map;

[0067] Those skilled in the art can understand that the efficient compression bitmap is a collection of multiple containers, and there is a corresponding relationship between key and value within the collection. The corresponding relationship is set by the efficient compression bitmap data structure itself or is set by those skilled in the art according to their own needs, and will not be elaborated here.

[0068] Among them, the same container includes multiple low-order N-bit values, and the same container corresponds to the same keyword (key). The keyword is used as a query index for the user number. The query index and the low-order N-bit value correspond to the user number stored in the number table.

[0069] Furthermore, after the above splitting, a plurality of 32-bit values ​​identifying the second part are included in the same container, and the container corresponds to a keyword. In the specific implementation process, the keyword is searched for an index, and the lower 32-bit value corresponding to the keyword is found, and then the user number in the corresponding number table is found. In this embodiment, the container can be the above-mentioned ArrayContainer, BitmapContainer or RunContainer, and this embodiment does not impose any special restrictions on the container.

[0070] When storing a new user number in the number table, the type of the container may change as the amount of data changes;

[0071] As mentioned above, the three types of containers store different amounts of data, and the type of container will change as the amount of data changes.

[0072] Wherein, when the amount of data in the number table is less than or equal to the first capacity, the type of the container is the first type;

[0073] In a specific implementation process, when the amount of data in the number table is less than or equal to the first capacity, the container type storing the data is a first type container;

[0074] When the amount of data in the number table is greater than the first capacity, a second capacity corresponding to the second mode and a third capacity of the third mode are obtained, and a type corresponding to a smaller capacity between the second capacity and the third capacity is selected as the type of the container.

[0075] Furthermore, if the amount of data in the number table is greater than the first capacity, the data will be converted into the data type required for storage in the second or third type of container, and then the data capacity of the converted data type will be compared to select the container type with a smaller data capacity.

[0076] Those skilled in the art can understand that, in the actual implementation process, if the amount of data in the number table is less than or equal to 4096, the container for storing the data is of ArrayContainer type; when the amount of data in the number table is greater than 4096, the data in the number table will be converted into BitmapContainer type, and the size will be compared with the memory required by the RunContainer type, and a storage form with smaller memory usage will be selected.

[0077] By storing the user numbers in the number table in the above manner, the problem of uneven data storage and waste of resources during data storage can be effectively avoided; at the same time, by distributing the stored data in the above manner, the subsequent large-scale data processing of the method of the present invention can be more efficient and faster.

[0078] Figure 1 A method for high-concurrency data processing based on compressed bitmap provided in the embodiment of the present application Figure 1 .like Figure 1 As shown, the method includes:

[0079] S101, obtaining a plurality of service information to be processed, each of which includes a user number;

[0080] In this embodiment, the service information may be service information in various service processing processes, and the service may be, for example, a call service, a text message service, a data service, and the like.

[0081] When processing these services, the corresponding service information is obtained, and the service information may include the user number and the type and processing items of the service to be processed, etc. The user number may be an IoT number, a mobile phone number, or some special numbers, etc.

[0082] Furthermore, in this embodiment, a plurality of business information may be acquired in batches through the batch processing function of Flink, and a plurality of first threads may be started to process the business information.

[0083] S102, determining, through a plurality of first threads, whether a user number in each service information matches a user number in a number table;

[0084] S104. If there is a match, obtain a matching user number that matches the number table; wherein each first thread corresponds to a service information, each first thread reads the number table through a read lock, and the read locks between multiple first threads do not conflict; wherein the number table is implemented by a compressed bitmap.

[0085] In order to process multiple pieces of service information, in this embodiment, multiple first threads are used to process multiple pieces of service information in parallel. Specifically, each first thread processes one piece of service information.

[0086] For each first thread, the first thread user determines whether the user number in the service information matches the user number in the number table, that is, determines whether the user number is the user number stored in the number table. If the user number is stored, a matching user number matching the number table is obtained.

[0087] The number table is stored by compressed bitmap, and the details can be referred to the above embodiment. The number table stores the numbers that can perform the corresponding services, that is, the numbers stored in the number table can perform the subsequent service processing flow, and the numbers not stored in the number table cannot perform the subsequent service process.

[0088] When multiple first threads are started to read and match business information, in order to avoid the influence of other threads on the first threads, read locks are added to the multiple first threads, thereby blocking the operations of other threads. Those skilled in the art can understand that the multiple read locks corresponding to the multiple first threads do not conflict with each other, so that the multiple first threads can work normally.

[0089] S103: Whether the addition and deletion information including the target user number is received through the second thread, if yes, execute S105, if no, continue to execute S102;

[0090] S105. Block the first thread, and execute the addition and deletion of information through the second thread to update the number table, wherein the second thread performs addition and deletion operations on the number table through a write lock, and the second thread and the first thread are mutually exclusive.

[0091] Those skilled in the art can understand that S102 and S103 have no strict timing relationship and can be performed simultaneously. When the second thread detects addition or deletion information, S102 stops executing. If no addition or deletion information is detected, the two are performed synchronously.

[0092] In the specific implementation process, the second thread is used to write the number table based on the target user number in the addition and deletion information, thereby updating the number information in the number table. The write operation includes writing or deleting, specifically writing or deleting, and the operation is performed according to the instructions of the addition and deletion information.

[0093] When the second thread performs a write operation, that is, writes or deletes a user number in the number table, the shrinkage of the container is triggered, which will affect the read operation of the first thread in S102. Therefore, in this embodiment of the present application, a write lock is added to the second thread to block the first thread from performing a read operation on the number table information. After the second thread is executed and the number table is updated, the first thread starts to execute again. That is, in the above process, the second thread and the first thread are mutually exclusive.

[0094] S106: Perform service processing according to the matched user number.

[0095] The matched user number is a number stored in the number table and can be used for subsequent business processing, so the user number is sent to the downstream for corresponding business processing. This application does not make any specific restrictions on the specific implementation of the downstream.

[0096] The high-concurrency data processing method based on compressed bitmap provided in this embodiment matches multiple first threads with the number table through the acquired user number, and at the same time, the second thread adds and deletes the user target information and updates the number table. When the second thread adds and deletes the target user number, the first thread operation is blocked, the number table information is updated, and finally the corresponding business processing is performed. In this embodiment, read locks and write locks are respectively added to the first thread and the second thread, so that the read thread and the write thread will not conflict with each other, thereby improving the security in the data processing process.

[0097] Figure 2 A method for high-concurrency data processing based on compressed bitmap provided in the embodiment of the present application Figure 2 .like Figure 2 As shown, in the above embodiment Figure 1 Based on the embodiment, the process of adding and deleting the second thread is described in detail. The method includes:

[0098] S201, start a thread pool, wherein the thread pool includes a plurality of second threads;

[0099] In order to process multiple user numbers in the number table, that is, to update multiple user numbers in the number table, in this embodiment, a thread pool is first started, and the thread pool is configured to include multiple second threads. In the specific implementation process, the multiple second threads are used to obtain addition and deletion information, and according to the indication of the addition and deletion information, add or delete the user numbers in the number table.

[0100] S202, controlling the plurality of second threads to cyclically acquire addition and deletion information for adding and deleting target user numbers in a preset sequence, wherein the preset sequence is that the start time of a later second thread is earlier than the end time of a previous second thread;

[0101] In this embodiment, when multiple second threads in the thread pool perform add and delete operations, in order to avoid conflicts between the multiple second threads and to be able to obtain newly added add and delete information in a timely manner, and then to update the user numbers in the number table in an orderly manner, it is necessary to pre-set the execution operation order of the multiple second threads. The pre-setting is to set a sequence of execution for the multiple second threads, and a single second thread independently performs operations in sequence according to the set sequence.

[0102] Those skilled in the art can understand that the preset sequence is that the start time of the second thread is earlier than the end time of the second thread, that is, before the execution of the first thread ends, the second thread starts to start the execution operation, thereby realizing an infinite loop and detecting and obtaining addition and deletion information at any time.

[0103] Those skilled in the art can understand that the setting of the preset sequence satisfies that different second threads will not perform add / delete operations at the same time, that is, will not perform write operations at the same time, and this embodiment does not impose any special restrictions on the setting of the specific preset sequence. In addition, the add / delete operations of the second threads can be optionally set to be mutually exclusive to avoid multiple second threads performing write operations at the same time, which may cause thread confusion.

[0104] Furthermore, in this embodiment, each second thread will detect new Kafka messages in real time according to a preset sequence. It can be understood by those skilled in the art that Kafka, as an open source stream processing platform, processes action stream data with high throughput, and detects Kafka messages in real time through the second thread, that is, detects Kafka action stream data; if the new Kafka message includes a user number and an add / delete operation indication, the second thread will perform an add / delete operation on the user number in the number table according to the new Kafka message.

[0105] In this embodiment, for each of the multiple second threads in the thread pool, a new Kafka message is detected in real time, and when the multiple second threads perform preset sequential operations, the acquired addition and deletion messages can be detected in time. In this embodiment, by detecting the Kafka message of the second thread in real time, the entire program is ensured to process data efficiently and safely, making the program more intelligent, efficient and convenient.

[0106] S203: When any second thread reads the addition and deletion information, the first thread is blocked, and the addition and deletion operations are performed on the number table through the second thread.

[0107] In this embodiment, when multiple threads in the thread pool perform add / delete operations, when any second thread in the thread pool performs add / delete operations, any update is performed on the user number in the number table; when multiple second threads perform operations and the user number in the number table is updated, the first thread will be blocked, and the first thread will execute again after the multiple second threads in the thread pool have completed execution.

[0108] It can be understood by those skilled in the art that when the multiple second threads in the thread pool perform add and delete operations, a write lock is added to the multiple second threads in the thread pool to block the first thread from reading the number table information. After all the multiple second threads in the thread pool have been executed and the number table has been updated, the first thread starts to execute the corresponding operation; that is, the multiple second threads in the thread pool are mutually exclusive with the first thread.

[0109] Correspondingly, in this embodiment, if the new Kafka message includes multiple user numbers and indications of addition and deletion operations, the multiple second threads in the thread pool will perform addition and deletion operations on the user numbers in the number table according to the multiple new Kafka messages. Those skilled in the art can also understand that when multiple new Kafka messages make indications, the multiple second threads will perform addition and deletion operations according to a preset order; and before the multiple second threads complete the addition and deletion operations in sequence, the first thread will be blocked.

[0110] The method for high-concurrency data processing based on compressed bitmap provided in this embodiment is to match multiple first threads with the number table through the obtained user number, and at the same time, the second thread performs addition and deletion operations on the user target information to update the number table. At the same time, considering that there are multiple second threads operating on the user target information, a thread pool is set, and the thread pool includes multiple second threads, and the second threads perform addition and deletion operations in a preset order, and finally perform business processing according to the matched user number. This embodiment ensures that high-concurrency data processing can be achieved by setting a thread pool and presetting the execution order of multiple second threads, while also effectively ensuring the thread safety of the program and the business stability of the program.

[0111] Figure 3 A flow chart of a high-concurrency data processing method based on a compressed bitmap provided in an embodiment of the present application Figure 3 .like Figure 3 As shown, in the above embodiment Figure 1 On this basis, the initial formation process of the number table is described in detail.

[0112] S301, obtaining telecommunication history data, where the telecommunication history data includes user numbers that have been serviced;

[0113] In this embodiment, the telecommunications historical data may be telecommunications data that has been processed in the past, including user numbers in previously processed call services, text message services, broadband services, data services, communication network services, transaction processing services, electronic data interchange services, and other services.

[0114] S302: Read the user number in the telecommunication history data through a third thread and write it into the number table, wherein the third thread completes the read and write operations through a competitive lock, and when the third thread is working, other threads are blocked.

[0115] For the above-mentioned telecommunications historical data with a huge amount of data, the user numbers in the historical data are read through the third thread and written into the number table. Since the user numbers in the number table are in a write state at this time, a single third thread is started through a competitive lock. When the third thread performs a write operation, other threads are blocked from executing.

[0116] Specifically, the telecommunications historical data is stored in the hive library. A single thread is started in each processing task to connect to the hive library through a competitive lock. The read result is stored in the number table of the data structure mentioned above to complete the initialization of the program.

[0117] The high-concurrency data processing method based on compressed bitmap provided in this embodiment starts a single third thread through a competitive lock to read historical data, further improving the reading of user numbers in historical data when filtering big data, making the entire high-concurrency data processing program efficient and secure.

[0118] Figure 4 A schematic diagram of a high-concurrency data processing device based on a compressed bitmap provided by an embodiment of the present invention. Figure 4 As shown, the device 40 provided in this embodiment includes: an acquisition module 401, a determination module 402, an update module 403 and a processing module 404;

[0119] The acquisition module 401 is used to acquire a plurality of service information to be processed, each of which includes a user number;

[0120] The judgment module 402 is used to judge whether the user number in each service information matches the user number in the number table through multiple first threads, and obtain the matching user number matching the number table; wherein each first thread corresponds to one service information, each first thread reads the number table through a read lock, and the read locks between the multiple first threads do not conflict; wherein the number table is implemented by a compressed bitmap;

[0121] An updating module 403 is configured to block the first thread if adding or deleting information including a target user number is received through a second thread, and execute the adding or deleting information through the second thread to update the number table, wherein the second thread performs adding or deleting operations on the number table through a write lock, and the second thread and the first thread are mutually exclusive;

[0122] The processing module 404 performs service processing according to the matched user number.

[0123] The device provided in this embodiment can be used to execute the above method embodiment. Its implementation process and implementation principle are similar to those of the above method embodiment, and this embodiment will not be repeated here.

[0124] Figure 5 A schematic diagram of a high-concurrency data processing device based on a compressed bitmap provided by an embodiment of the present invention. Figure 5 As shown, the device 50 includes:

[0125] Processor 501 and memory 502;

[0126] The memory 502 stores computer-executable instructions;

[0127] The at least one processor 501 executes the computer execution instructions stored in the memory 501, so that the at least one processor 501 performs various optional high-concurrency data processing methods as in the first aspect.

[0128] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0129] In the above Figure 5 In the illustrated embodiment, it should be understood that the processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0130] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk storage.

[0131] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0132] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0133] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0134] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0135] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0136] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as: Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0137] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0138] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0139] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0140] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A high-concurrency data processing method based on compressed bitmap, characterized in that: include: Acquire multiple pieces of service information to be processed, each of which includes a user number; Determine whether the user number in each service information matches the user number in the number table through multiple first threads, and obtain the matching user number matching the number table; wherein each first thread corresponds to one service information, each first thread reads the number table through a read lock, and the read locks between the multiple first threads do not conflict; wherein the number table is implemented by a compressed bitmap; If the addition and deletion information including the target user number is received through the second thread, the first thread is blocked, and the addition and deletion information is executed through the second thread to update the number table, wherein the second thread performs addition and deletion operations on the number table through a write lock, and the second thread and the first thread are mutually exclusive; Business processing is performed according to the matched user number.

2. The method according to claim 1, characterized in that The receiving the addition and deletion information including the target user number through the second thread, blocking the first thread, and executing the addition and deletion information through the second thread includes: Starting a thread pool, wherein the thread pool includes a plurality of second threads; Controlling the plurality of second threads to cyclically acquire the addition and deletion information for adding and deleting the target user number in a preset sequence, wherein the preset sequence is that the start time of the second thread in the latter position is earlier than the end time of the second thread in the former position; When any second thread reads the addition and deletion information, the first thread is blocked, and the addition and deletion operations on the number table are performed through the second thread.

3. The method according to claim 2, characterized in that The controlling the plurality of second threads to cyclically obtain the addition and deletion information for adding and deleting the target user number in a preset order includes: For each second thread, the second thread detects new Kafka messages in real time; If the new Kafka message includes a user number and an add / delete operation instruction, the add / delete information is obtained according to the new Kafka message.

4. The method according to claim 1, characterized in that: Before determining whether the user number in each service information matches the user number in the number table through the multiple first threads, the method further includes: Acquiring telecommunication history data, wherein the telecommunication history data includes user numbers for which service processing has been performed; The user number in the telecommunication history data is read through a third thread and written into the number table, wherein the third thread completes the read and write operations through a competitive lock, and when the third thread is working, other threads are blocked.

5. The method according to claim 1, characterized in that In the filtering program, judging whether the user number in each service information matches the user number in the number table through multiple first threads includes: Determine, by using a plurality of first threads, whether there is a user number matching the user number in a number table of a preset data structure, wherein the preset data structure splits the long type data of 2N bits into a high-order N-bit keyword and a low-order N-bit value, and stores the low-order N-bit value in a container; Among them, the same container includes multiple low-order N-bit values, the same container corresponds to the same keyword, the keyword is used as a query index for the user number, and the query index and the low-order N-bit value correspond to the user number stored in the number table.

6. The method according to claim 5, characterized in that The method further comprises: When storing a new user number in the number table, the type of the container may change as the amount of data changes; Wherein, when the amount of data in the number table is less than or equal to the first capacity, the type of the container is the first type; When the amount of data in the number table is greater than the first capacity, a second capacity corresponding to the second mode and a third capacity of the third mode are obtained, and a type corresponding to a smaller capacity between the second capacity and the third capacity is selected as the type of the container.

7. The method according to any one of claims 1 to 4, characterized in that: The read lock and the write lock are both object locks.

8. A high-concurrency data processing device based on compressed bitmap, characterized in that: The device comprises: An acquisition module, used for acquiring a plurality of service information to be processed, each of which includes a user number; A judgment module, used to judge whether the user number in each service information matches the user number in the number table through multiple first threads, and obtain a matching user number that matches the number table; wherein each first thread corresponds to one service information, each first thread reads the number table through a read lock, and the read locks between the multiple first threads do not conflict; wherein the number table is implemented by a compressed bitmap; An update module, configured to block the first thread if adding or deleting information including a target user number is received through a second thread, and execute the adding or deleting information through the second thread to update the number table, wherein the second thread performs adding or deleting operations on the number table through a write lock, and the second thread and the first thread are mutually exclusive; The processing module performs service processing according to the matched user number.

9. A high-concurrency data processing device based on compressed bitmap, characterized in that: The device comprises: a processor and a memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the high-concurrency data processing method based on compressed bitmap according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the processor executes the computer-executable instructions, the high-concurrency data processing method based on compressed bitmap as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Retrieval method and device, medium and computing equipment

    CN116226497A

  • Call bill data query method and device, equipment and medium

    CN117435556A