Numerical value matching method and device, computer equipment and medium

By encoding and sorting the values ​​in the data matching table using binary encoding, the problem of excessive memory consumption in traditional numerical matching methods is solved, achieving efficient memory utilization and a balance between performance and efficiency.

CN121858786APending Publication Date: 2026-04-14QINGYI SHANGHAI INTELLIGENT TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Traditional numerical matching methods consume a lot of memory when stored in memory, leading to a performance-resource balance problem.

Method used

The data matching table is encoded using a binary encoding method to generate encoded values, which are then sorted and stored in an in-memory data structure. Lightweight decoding is performed by concatenating high and low bits using std::set. As a sorting container.

Benefits of technology

It effectively reduces memory usage, decreasing it from 6714MB to 4578MB, which is only 68% of the original, while maintaining efficient numerical matching performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121858786A_ABST
    Figure CN121858786A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a numerical value matching method and device, computer equipment and a medium, and relates to the field of computer algorithms, and the method comprises the following steps: based on a data matching table, carrying out binary coding on each first matching numerical value and a corresponding second matching numerical value in the data matching table to generate a coding numerical value, a plurality of coding values are obtained; sorting the plurality of coding numerical values and then storing the coding numerical values in a data structure of a memory; in a numerical value matching process, receiving a to-be-matched first matching numerical value, and searching a coding numerical value associated with the to-be-matched first matching numerical value in the data structure; and extracting a second matching numerical value corresponding to the to-be-matched first matching numerical value from the searched coding numerical values. According to the scheme, the problem that a large amount of memory is occupied due to direct storage of the data matching table is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer algorithms, and in particular to a numerical matching method, apparatus, computer equipment, and medium. Background Technology

[0002] In the field of computer data processing, "numerical matching" is a high-frequency and critical fundamental operation, and a common programming scenario. Its core requirement is to construct a data matching table (as shown in Table 1 below) based on two integer sets {A} and {B} with a relationship (one-to-one or one-to-many), and to implement the function of "quickly querying the corresponding set b ∈ B given a ∈ A". For example, based on a value a in {A}, the results of finding one or more values ​​b corresponding to a in {B} are shown in Table 2 below. This operation is widely used in scenarios such as device parameter association (e.g., matching device ID with operating status code), user behavior analysis (e.g., matching user identifier with operation record), and industrial data mapping (e.g., matching sensor number with collected values). Its performance (matching efficiency) and resource consumption (memory usage) directly affect the operational stability and response speed of the upper-layer business system.

[0003] Table 1

[0004] Table 2

[0005] In real-world projects, the values ​​of {A} and {B} often cluster within a certain range. This clustering of values ​​is quite common and has a certain degree of universality. For example: The range of values ​​for a∈A is [0, 2]. m ] The range of values ​​for b∈B is [0,2]. n ] And the sum of m and n is no greater than 64: m + n ≤ 64 For example, suppose m=48, n=16, that is: The range of values ​​for a∈A is [0, 2]. 48 ] The range of values ​​for b∈B is [0,2]. 16 ] And 48 + 16 <= 64.

[0006] From the perspective of technological development and engineering practice, the industry currently has two mainstream solutions for numerical matching scenarios. However, due to limitations in technical principles and structural characteristics, both suffer from significant performance-resource imbalances, as detailed below: Traditional in-memory solutions: Key-value storage system based on MultiMap To meet the requirement of "low-latency matching," the industry generally uses in-memory data structures to build matching tables, among which MultiMap (such as std::multimap in the C++ standard library) is the most widely used solution. Its technical logic is as follows: using 'a' from set {A} as the key and 'b' from set {B} as the value, a key-value pair data structure M is constructed, such as M:MultiMap.<Key,Value> The matching table is written into this structure one by one; when performing a matching operation, the corresponding Value (b) is directly extracted by locating the key (a) by its index. Taking C++ as an example, based on the scenario assumed in this article, std::multimap is selected.<uint64_t, uint16_t> Taking a data matching table with 100,000,000 entries as an example, the memory usage after building the numerical matching table in memory is 6714 MB, indicating a significant memory consumption. From a technical perspective, this solution relies on the red-black tree underlying MultiMap, and although the query time complexity can reach O(log n+k) (where n is the total number of entries and k is the number of target entries b), which can meet the latency requirements of high-frequency matching scenarios, it suffers from structural redundancy in terms of memory resource consumption, leading to the problem of high memory usage. Summary of the Invention

[0007] In view of this, embodiments of the present invention provide a numerical matching method to solve the technical problem that the traditional numerical matching method in the prior art, which uses a one-to-one storage of numerical matching tables in memory, results in excessive memory consumption. The method includes: Based on the data matching table, each first matching value and its corresponding second matching value in the data matching table are binary encoded to generate coded values, resulting in multiple coded values. A data structure in memory is used to sort and store multiple coded values. During the numerical matching process, the first matching numerical value to be matched is received, and the encoded numerical value associated with the first matching numerical value to be matched is searched in the data structure. Extract the second matching value that corresponds to the first matching value to be matched from the found encoded values.

[0008] This invention also provides a numerical matching device to solve the technical problem that traditional numerical matching methods, which use a one-to-one storage of numerical matching tables in memory, result in excessive memory consumption. The device includes: The numerical encoding module is used to perform binary encoding on each first matching value and the corresponding second matching value in the data matching table based on the data matching table, generate encoded values, and obtain multiple encoded values. The numerical storage module is used to sort and store multiple coded numerical values ​​in a data structure in memory. The numerical lookup module is used to receive the first matching numerical value to be matched during the numerical matching process and search for the encoded numerical value associated with the first matching numerical value to be matched in the data structure. The numerical matching module is used to extract the second matching value that corresponds to the first matching value to be matched from the found encoded numerical values.

[0009] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any of the above-mentioned numerical matching methods to solve the technical problem in the prior art where traditional numerical matching uses a one-to-one method of storing numerical matching tables in memory, resulting in excessive memory usage.

[0010] This invention also provides a computer-readable storage medium storing a computer program that executes any of the above-described numerical matching methods, in order to solve the technical problem that traditional numerical matching in the prior art uses a one-to-one method of storing numerical matching tables in memory, resulting in excessive memory consumption.

[0011] Compared with the prior art, the beneficial effects that the above-mentioned at least one technical solution adopted in the embodiments of this specification can achieve include at least the following: It proposes to perform binary encoding on each first matching value and its corresponding second matching value in the data matching table to generate encoded values, obtaining multiple encoded values, and then sorting and storing these multiple encoded values ​​in a data structure in memory for numerical matching or querying, thus avoiding the problem of excessive memory usage caused by directly storing the data matching table; taking a 64-bit operating system as an example, and taking a data matching table with a scale of 100,000,000 entries as an example, after constructing the numerical matching table in memory, the memory usage before applying this method is 6714MB, and after applying this method, the memory usage is 4578MB, only 68% of the previous memory usage. The data display results clearly show that the data is not compressed, reducing memory space usage; and the lightweight high- and low-bit decoding reduces memory usage without complex calculations or additional storage. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1This is a flowchart of a numerical matching method provided in an embodiment of the present invention; Figure 2 This is a structural diagram of a computer device provided in an embodiment of the present invention; Figure 3 This is a structural diagram of a numerical matching device provided in an embodiment of the present invention. Detailed Implementation

[0014] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0015] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. This application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0016] In this embodiment of the invention, a numerical matching method is provided, such as... Figure 1 As shown, the method includes: Step 101: Based on the data matching table, perform binary encoding on each first matching value and the corresponding second matching value in the data matching table to generate encoded values, thus obtaining multiple encoded values; Step 102: Sort the multiple coded values ​​and store them in a data structure in memory; Step 103: During the numerical matching process, receive the first matching numerical value to be matched, and search for the encoded numerical value associated with the first matching numerical value to be matched in the data structure. Step 104: Extract the second matching value from the found encoded values ​​that corresponds to the first matching value to be matched.

[0017] Depend on Figure 1As shown in the flowchart, in this embodiment of the invention, the proposed numerical matching method involves binary encoding each first matching value and its corresponding second matching value in the data matching table to generate encoded values. Multiple encoded values ​​are then sorted and stored in a memory data structure for numerical matching or querying, avoiding the problem of excessive memory usage caused by directly storing the data matching table. Taking a 64-bit operating system as an example, and a data matching table with 100,000,000 entries, the memory usage before constructing the numerical matching table in memory was 6714MB, and after applying this method, it was reduced to 4578MB, only 68% of the previous usage. The data clearly shows that the data is uncompressed, reducing memory usage. Lightweight decoding using high and low bits eliminates the need for complex calculations or additional storage, further reducing memory consumption. This method includes the following steps: In practical implementation, to achieve lightweight decoding during the numerical matching process, a lossless binary encoding method is proposed, which concatenates the high and low bits of the first matched value and the corresponding second matched value to generate encoded values. For example, based on a data matching table, each first matched value and its corresponding second matched value in the data matching table are binary encoded to generate encoded values, resulting in multiple encoded values, including: The binary value range of the first matching value is a first preset number of bits, and the binary value range of the second matching value is a second preset number of bits. The sum of the first preset number of bits and the second preset number of bits is less than or equal to the total number of bits in binary (the total number of bits in binary can be 64, 128, etc.). The binary number of bits of the first matching value and the binary number of the second matching value are respectively used as the high-order bits and low-order bits of the encoded value to generate a binary encoded value (specifically, the binary number of bits of the first matching value can be used as the high-order bits of the encoded value, and the binary number of bits of the second matching value can be used as the low-order bits of the encoded value; or, the binary number of bits of the first matching value can be used as the low-order bits of the encoded value, and the binary number of bits of the second matching value can be used as the high-order bits of the encoded value).

[0018] In specific implementation, in order to use the binary bits of the first matching value and the second matching value as the high and low bits of the encoded value respectively, this can be achieved by shifting the binary bits of either the first or second matching value and then concatenating them. For example, shifting the binary bits of the first matching value to the left by a second preset number of bits, leaving a second preset number of low bits, and then concatenating the binary bits of the second matching value to the second preset number of low bits to generate the encoded value, in which case the binary bits of the first matching value are used as the high bits of the encoded value; or, shifting the binary bits of the first matching value to the right by a second preset number of bits, leaving a second preset number of high bits, and then concatenating the binary bits of the second matching value to the second preset number of high bits to generate the encoded value, in which case the binary bits of the first matching value are used as the low bits of the encoded value.

[0019] For example, the lossless encoding method for a and b based on "high and low bit splitting and concatenation" takes a∈A in the range [0,2]. 48 The range of values ​​for b∈B is [0,2]. 16 The data 'a' (i.e., the first matching value mentioned above, where 48 is the first preset number of bits) and 'b' (i.e., the second matching value mentioned above, where 16 is the second preset number of bits) can be losslessly encoded into a 2^32-bit array. 64 In the numerical value c (i.e., the encoded value mentioned above), let the range of c∈C be [0, 2]. 64 Specifically, shift 'a' left by 16 bits to occupy the high 48 bits of 'c', and directly fill the low 16 bits of 'b' corresponding to 'a' into 'c'. By shifting 'a' in the binary representation of each entry in the numerical matching table left by 16 bits to occupy the high 48 bits of 'c', leaving 16 low bits empty, and then copying the binary data of 'b' to the 16 low bits empty after shifting 'a' left, the encoded data 'c' is obtained. This achieves a lossless and unique mapping of two independent numerical values ​​to a single 64-bit numerical value 'c', without data truncation or precision loss, ensuring that different (a, b) pairs can each correspond to a unique 'c', avoiding conflicts. During numerical matching or querying, the corresponding 'b' can also be completely extracted from 'c' in reverse.

[0020] Specifically, assuming that after encoding a value c, a is encoded into the high-order bits of c and b is encoded into the low-order bits of c, then after sorting c by size, the encoded values ​​will still follow the size order of a, making each encoded c unique and non-repeating.

[0021] Specifically, this method of generating encoded values ​​compresses two data dimensions into a single data dimension, reducing storage redundancy. After encoding, only 64 bits of 'c' need to be stored (instead of 64 bits of 'a+b', which seems to have the same number of bits, but avoids the index storage overhead of dual-table joins). Combined with subsequent storage structure optimization, it ultimately achieves a low memory footprint of 4578MB for 100 million entries. At the same time, it provides the foundation for efficient matching with "single value range search" (that is, the size of 'c' is determined by the high 48 bits of 'a', and the low 16 bits of 'b' only affect the sorting of 'c' under the same 'a', ensuring that "sorting by 'c' is sorting by 'a'", laying the foundation for subsequent range search).

[0022] Specifically, the use of encoded values ​​solves the problem in traditional schemes where a and b need to be stored separately (e.g., using std::pair).<uint64_t,uint16_t> (Or two independent tables), which will generate additional memory overhead of "storage of a (48 bits / row) + storage of b (16 bits / row)," and the frequent matching of indexes is required when performing multi-table join queries, resulting in low efficiency.

[0023] In specific implementation, each first matching value and its corresponding second matching value in the data matching table are binary encoded to generate an encoded value, including: If the first matching value corresponds to multiple second matching values, then the first matching value and each corresponding second matching value are used to generate an encoded value.

[0024] In practical implementation, in order to complete the programming scenario of data matching, it is necessary to sort c and store it in memory. In the process of storing coded values, multiple coded values ​​are sorted by a sorting container and stored in a data structure in memory.

[0025] For example, taking C++ as an example, to meet the requirements of ordering and range lookup in the encoded C code, std::set is the appropriate choice.<uint64_t> As a sorted container data structure, rather than a general-purpose container (such as std::vector, std::unordered_set), let this in-memory data structure be: Setc Similarly, taking a data matching table with 100,000,000 entries as an example, after converting the numerical matching table into encoded numerical values ​​in memory, the memory usage is only 4578 MB, compared to 6714 MB before applying this method, making the memory usage only 68% of the previous amount.

[0026] Specifically, std::set is implemented internally as a red-black tree, with elements sorted in ascending order by default. No additional sorting operation is required on the encoded c, saving preprocessing time. std::set natively provides the lower_bound and upper_bound functions, which can locate the range of "minimum value - maximum value of c" in O(log n) time complexity and directly extract the target c without traversing the entire table.

[0027] If a generic container is used, the following problems may occur: If using std::vector: c needs to be sorted first (sorting 100 million entries is time-consuming), and range searches require manual implementation of binary search, resulting in high code complexity and low efficiency; If std::unordered_set is used, although inserting / querying a single element is efficient, it does not support ordered range search and cannot meet the core requirement of "finding the range of c based on a and then searching for c in batches". If std::map<uint64_t,uint16_t> : Requires storage<c,b> The key-value pair occupies an additional 16 bits of memory for 'b', which contradicts the core goal of "reducing memory usage".

[0028] According to this method, std::set is used.<uint64_t> As a sorting container data structure, it can solve the above three problems and achieve coordinated optimization of "storage-search": it reduces memory usage through the non-redundant storage of std::set (only storing c), and ensures matching efficiency through its efficient range search function. Even with 100 million entries, it can still quickly respond to the request of "find b given a", thus balancing the issues of memory and performance.

[0029] In practical implementation, the programming scenario of numerical matching refers to finding one or more values ​​b corresponding to a in the numerical matching table, given a value 'a'. To achieve accurate and efficient finding of the one or more values ​​b corresponding to 'a', a method is proposed whereby, during the numerical matching process, a first matching value to be matched is received, and the encoded value associated with the first matching value to be matched is searched in the data structure, including: According to the binary encoding method of the encoded value, the binary bits of the first matching value to be matched are used as the high or low bits of the encoded value, and all other binary bits of the encoded value are set to 0 to obtain the minimum value of the search range. All other binary bits of the encoded value are set to 1 to obtain the maximum value of the search range. In the data structure, one or more encoded values ​​belonging to the search range are searched as encoded values ​​associated with the first matching value to be matched.

[0030] For example, based on the aforementioned encoding method of the value c, in the binary level, after shifting a left by 16 bits, all the empty lower 16 bits are set to 0, which is the minimum possible value of c, and all the empty lower 16 bits are set to 1, which is the maximum possible value of c. In the data structure, one or more encoded values ​​belonging to the search range are searched as encoded values ​​associated with the first matching value to be matched. Since the search range is strongly bound to a, each a corresponds to a unique search range of c, and the search range only includes all c after the encoding of a, without the c of other a mixed in, which can ensure the accuracy of the search results.

[0031] Specifically, this range-based search process transforms the many-to-many matching process between a and b into a single-value range search process for c. The search efficiency depends only on the number of c (not the number of b), and the time complexity of range search in std::set is O(logn+k) (where k is the number of target c), thus solving the traversal efficiency problem of traditional multimap.

[0032] In specific implementation, during the process of extracting the second matching value corresponding to the first matching value, the method proposed is to extract the second matching value corresponding to the first matching value to be matched from the found encoded value, including: From the found encoded values, extract the binary values ​​excluding the high or low bits of the first matching value to be matched, and obtain the second matching value corresponding to the first matching value to be matched.

[0033] For example, a lightweight decoding logic is designed that extracts only the second matching value of the corresponding high or low bits of c. This eliminates the need for complex calculations or additional storage. For instance, by performing the bitwise operation b = c & 0xFFFF (where 0xFFFF represents 16 bits of all 1s), the lower 16 bits of c are directly extracted, which is the b before encoding. There is no need to store a or other auxiliary information; b can be independently recovered using only c. The time complexity of the decoding process is O(1). This achieves a lightweight closed loop for encoding and decoding c. Encoding requires only 2 bitwise operations (left shift + bitwise OR), and decoding requires only 1 bitwise operation (bitwise AND), with no additional calculation or storage costs. This ensures end-to-end efficiency of the matching process while avoiding the introduction of new memory overhead during decoding.

[0034] In practice, the implementation process of the above numerical matching method is described below, taking a 64-bit operating system as an example: Step 1: For each entry 'a' in the numerical matching table, shift 16 bits to the left in its binary representation. Then, copy the corresponding binary data 'b' to the 16 lower bits vacated after shifting 'a'. This yields the encoded data 'c' (as shown in Table 3 below).

[0035] Table 3

[0036] Step 2: Sort the multiple coded values ​​using a sorting container and store them in a data structure in memory.

[0037] To complete the data matching programming scenario, it's necessary to sort the data in C and store it in memory. Here, we'll use C++ as an example and choose std::set.<uint64_t> As a sorting container data structure, let this in-memory data structure be: Set c Similarly, taking a data matching table with 100,000,000 entries as an example, after converting the numerical matching table into encoded numerical values ​​'c' in memory, the memory usage is only 4578MB.

[0038] Step 3: As explained above, the C encoding method and the C data structure Set in memory are described. c This step will explain how to complete the numerical matching programming scenario, as follows: The programming scenario for numerical matching refers to finding one or more values ​​b corresponding to a in a numerical matching table, given a value 'a'. In the current state, this can be accomplished using the following steps: Given a, determine the search range for the value c. Based on the aforementioned encoding method for the value c, in binary, shift a left by 16 bits, then set all the empty lower 16 bits to 0, representing the minimum possible value of c, and set all the empty lower 16 bits to 1, representing the maximum possible value of c. Here, we still use a = 314159265359 as an example (as shown in Table 4 below).

[0039] Table 4

[0040] Search for c in `Stet` based on the range of values ​​specified by c. Typically, sorted data structures provide methods for retrieving elements from a range of values; for example, C++'s `std::set` provides this. lower_bound and upper_bound Two functions can retrieve all possible values ​​of c within the range of their maximum and minimum values. If only one c is found, it means that a in the numerical matching table corresponds to only one b. If multiple c are found, it means that a in the numerical matching table corresponds to multiple b.

[0041] Step 4: From the found encoded values, extract the binary values ​​excluding the high or low bits of the first matching value to be matched, to obtain the second matching value corresponding to the first matching value to be matched.

[0042] Obtain the value of b from c. The previous step has already yielded the specific value of c. Therefore, by deriving the encoding method, we can determine how to obtain the value of b from c (as shown in Table 5 below). At this point, the numerical matching programming scenario has been successfully completed.

[0043] Table 5

[0044] In this embodiment, a computer device is provided, such as... Figure 2 As shown, it includes a memory 201, a processor 202, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any of the numerical matching methods described above.

[0045] Specifically, the computer device can be a computer terminal, a server, or a similar computing device.

[0046] In this embodiment, a computer-readable storage medium is provided, which stores a computer program that performs any of the numerical matching methods described above.

[0047] Specifically, computer-readable storage media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer-readable storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable storage media does not include transient media, such as modulated data signals and carrier waves.

[0048] Based on the same inventive concept, this invention also provides a numerical matching device, as described in the following embodiments. Since the principle of the numerical matching device in solving the problem is similar to that of the numerical matching method, the implementation of the numerical matching device can refer to the implementation of the numerical matching method, and repeated details will not be elaborated further. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0049] Figure 3 This is a structural block diagram of a numerical matching device according to an embodiment of the present invention, such as... Figure 3 As shown, it includes: Numerical encoding module 301: Based on the data matching table, it performs binary encoding on each first matching value and the corresponding second matching value in the data matching table to generate encoded values, thus obtaining multiple encoded values; Numerical storage module 302: Stores multiple coded numerical values ​​in a data structure in memory after sorting them; Numerical lookup module 303: During the numerical matching process, it receives the first matching numerical value to be matched and searches for the encoded numerical value associated with the first matching numerical value to be matched in the data structure. Numerical matching module 304: Extracts the second matching value corresponding to the first matching value to be matched from the found encoded numerical values.

[0050] In one embodiment, the numerical matching module is further configured to: have a binary value range of the first matched numerical value that is a first preset number of bits, have a binary value range of the second matched numerical value that is a second preset number of bits, and have the sum of the first preset number of bits and the second preset number of bits that is less than or equal to the total number of bits in binary; and use the binary number of bits of the first matched numerical value and the binary number of bits of the second matched numerical value as the high and low bits of the encoded numerical value, respectively, to generate a binary encoded numerical value.

[0051] In one embodiment, the numerical matching module is further configured to generate an encoded numerical value by combining the first matched numerical value with each corresponding second matched numerical value if the first matched numerical value corresponds to multiple second matched numerical values.

[0052] In one embodiment, the numerical matching module is further configured to sort multiple coded numerical values ​​using a sorting container and then store them in a data structure in memory.

[0053] In one embodiment, the numerical matching module is further configured to, according to the binary encoding method of the encoded numerical value, use the binary bits of the first matching numerical value to be matched as the high or low bits of the encoded numerical value, set all other binary bits of the encoded numerical value to 0 to obtain the minimum value of the search range, and set all other binary bits of the encoded numerical value to 1 to obtain the maximum value of the search range; and search in the data structure for one or more encoded numerical values ​​belonging to the search range as encoded numerical values ​​associated with the first matching numerical value to be matched.

[0054] In one embodiment, the numerical matching module is further configured to extract, from the found encoded numerical values, the binary values ​​excluding the high-order or low-order binary bits of the first matching numerical value to be matched, to obtain the second matching numerical value corresponding to the first matching numerical value to be matched.

[0055] The embodiments of this invention achieve the following technical effects: A binary encoding method is proposed for each first matching value and its corresponding second matching value in the data matching table to generate encoded values. Multiple encoded values ​​are then sorted and stored in a memory-based data structure for numerical matching or querying, avoiding the problem of excessive memory usage caused by directly storing the data matching table. Taking a 64-bit operating system as an example, and a data matching table with 100,000,000 entries, the memory usage before constructing the numerical matching table in memory is 6714MB, while after applying this method, it is only 4578MB, representing only 68% of the previous usage. The data display clearly shows that the data is uncompressed, reducing disk space usage. Lightweight high- and low-bit decoding eliminates the need for complex calculations or additional storage, further reducing memory usage.

[0056] Obviously, those skilled in the art should understand that the modules or steps of the above-described embodiments of the present invention can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the embodiments of the present invention are not limited to any particular hardware and software combination.

[0057] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A numerical matching method, characterized in that, include: Based on the data matching table, each first matching value and its corresponding second matching value in the data matching table are binary encoded to generate coded values, resulting in multiple coded values. A data structure in memory is used to sort and store multiple coded values. During the numerical matching process, the first matching numerical value to be matched is received, and the encoded numerical value associated with the first matching numerical value to be matched is searched in the data structure. Extract the second matching value that corresponds to the first matching value to be matched from the found encoded values.

2. The method as described in claim 1, characterized in that, Each first matching value and its corresponding second matching value in the data matching table are binary encoded to generate an encoded value, including: The binary value range of the first matching value is a first preset number of bits, and the binary value range of the second matching value is a second preset number of bits. The sum of the first preset number of bits and the second preset number of bits is less than or equal to the total number of bits in the binary representation. The binary bits of the first and second matched values ​​are used as the high and low bits of the encoded value, respectively, to generate the binary encoded value.

3. The method as described in claim 1, characterized in that, Each first matching value and its corresponding second matching value in the data matching table are binary encoded to generate an encoded value, including: If the first matching value corresponds to multiple second matching values, then the first matching value and each corresponding second matching value are used to generate an encoded value.

4. The method as described in claim 1, characterized in that, A data structure that stores multiple coded values ​​in memory after sorting them includes: Multiple coded values ​​are sorted and stored in a memory data structure using a sorting container.

5. The method according to any one of claims 1 to 4, characterized in that, Receive a first matching value to be matched, and search for the encoded value associated with the first matching value to be matched in the data structure, including: According to the binary encoding method of the encoded value, the binary bits of the first matching value to be matched are used as the high or low bits of the encoded value, and all other binary bits of the encoded value are set to 0 to obtain the minimum value of the search range. All other binary bits of the encoded value are set to 1 to obtain the maximum value of the search range. In the data structure, one or more coded values ​​belonging to the search range are searched as coded values ​​associated with the first matching value to be matched.

6. The method as described in claim 5, characterized in that, Extract the second matching value corresponding to the first matching value to be matched from the found encoded values, including: From the found encoded values, extract the binary values ​​excluding the high or low bits of the first matching value to be matched, and obtain the second matching value corresponding to the first matching value to be matched.

7. A numerical matching device, characterized in that, include: The numerical encoding module is used to perform binary encoding on each first matching value and the corresponding second matching value in the data matching table based on the data matching table, generate encoded values, and obtain multiple encoded values. The numerical storage module is used to sort and store multiple coded numerical values ​​in a data structure in memory. The numerical lookup module is used to receive the first matching numerical value to be matched during the numerical matching process and search for the encoded numerical value associated with the first matching numerical value to be matched in the data structure. The numerical matching module is used to extract the second matching value that corresponds to the first matching value to be matched from the found encoded numerical values.

8. The apparatus as claimed in claim 7, characterized in that, The numerical encoding module is configured such that the binary value range of the first matched numerical value is a first preset number of bits, the binary value range of the second matched numerical value is a second preset number of bits, and the sum of the first preset number of bits and the second preset number of bits is less than or equal to the total number of bits in the binary representation. The binary bits of the first and second matched values ​​are used as the high and low bits of the encoded value, respectively, to generate the binary encoded value.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the numerical matching method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that performs the numerical matching method according to any one of claims 1 to 6.