Data query method and device, storage medium and electronic equipment

By using nonlinear functions in the database system to fit the mapping relationship between the keys and storage locations of stored data, the performance bottleneck problem of the traditional index mechanism in a high-concurrency environment is solved, and more efficient data query and storage are achieved.

CN120632164APending Publication Date: 2025-09-12ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510543201.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Traditional B+ tree or hash table indexing mechanisms are difficult to meet the query speed and storage efficiency requirements of large-scale data storage and processing systems in high-concurrency environments, and especially exhibit performance bottlenecks when quickly searching large-scale data.

Method used

A nonlinear function is used to fit the mapping relationship between the key and storage location of the stored data, the key value range of the data is divided into several key intervals, and an appropriate nonlinear function is selected for each interval to build an index model, and the data storage location is directly queried through the index model.

Benefits of technology

It improves the accuracy and efficiency of data query and meets the requirements of modern big data storage systems for efficient query and low latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632164A_ABST
    Figure CN120632164A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data query method, which comprises the following steps of: dividing the value range of keys of all possible data into a plurality of key intervals, fitting a mapping relationship between the keys of the stored data and the storage positions of the stored data by adopting a nonlinear function according to the keys of the stored data in each key interval, and when the target data is positioned, the key of the target data is directly input into the index model corresponding to the key interval where the key is located, so that the target storage position output by the index model can be obtained. By means of the index learning method, the mapping relation between the keys of the stored data and the storage positions is fitted through the nonlinear function, the index model can output the storage positions of the data more accurately according to the input keys, the data are queried directly through the index model, and the query efficiency can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a data query method, device, storage medium, and electronic device. Background Art

[0002] Currently, databases have been widely used in various fields. How to use databases to quickly query and process data is an eternal topic in database technology.

[0003] Typically, databases are designed with indexing mechanisms to query and process data. However, with the surge in data volume and increasing access frequency, traditional indexing mechanisms such as B+ trees and hash tables are gradually experiencing performance bottlenecks in high-concurrency environments. This is especially true when rapidly searching large amounts of data. Traditional methods based on B+ trees or hash tables face challenges in terms of query speed and storage efficiency.

[0004] Therefore, how to design a more efficient indexing mechanism has become a key issue in large-scale data storage and processing systems. Summary of the Invention

[0005] The embodiments of this specification provide a data query method, device, storage medium, and electronic device to partially solve the problems existing in the above-mentioned prior art.

[0006] The embodiments of this specification adopt the following technical solutions:

[0007] This specification provides a data query method, which includes:

[0008] Determine the value range of the data key;

[0009] Dividing the value range into a plurality of key intervals according to the keys of the stored data and the preset nonlinear functions;

[0010] For each key interval, according to the keys of the stored data in the key interval, a target nonlinear function is selected from each nonlinear function to fit the mapping relationship between the keys of the stored data and the storage locations of the stored data, and the fitted target nonlinear function is used as the index model corresponding to the key interval;

[0011] When locating the target storage location of the target data, the key interval where the target storage location is located is determined according to the key of the target data, as the target interval, the key of the target data is input into the index model corresponding to the target interval, and the target storage location output by the index model corresponding to the target interval is obtained.

[0012] This specification provides a data query device, which includes:

[0013] A determination module is used to determine the value range of the data key;

[0014] a partitioning module, configured to partition the value range into a plurality of key intervals according to the keys of the stored data and the preset nonlinear functions;

[0015] a fitting module configured to, for each key interval, select a target nonlinear function from among the nonlinear functions to fit the mapping relationship between the key of the stored data and the storage location of the stored data according to the key of the stored data in the key interval, and use the fitted target nonlinear function as the index model corresponding to the key interval;

[0016] The query module is used to determine the key interval where the target storage location is located based on the key of the target data when locating the target storage location of the target data, and input the key of the target data into the index model corresponding to the target interval as the target interval to obtain the target storage location output by the index model corresponding to the target interval.

[0017] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned data query method is implemented.

[0018] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned data query method is implemented.

[0019] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:

[0020] An embodiment of this specification discloses a data query method, which divides the value range of the key of all possible data into several key intervals, and uses a nonlinear function to fit the mapping relationship between the key of the stored data and the storage location of the stored data according to the key of the stored data in each key interval, to obtain an index model corresponding to the storage location interval. When locating the target data, the key of the target data is directly input into the index model corresponding to the key interval where it is located, and the target storage location output by the index model can be obtained. Through the above-mentioned learning index method, the mapping relationship between the key of the stored data and the storage location is fitted by a nonlinear function, so that the index model can output the storage location of the data more accurately according to the input key, and directly querying the data through the index model can also effectively improve the query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:

[0022] Figure 1 A flowchart of a data query method provided in an embodiment of this specification;

[0023] Figure 2 A schematic diagram of a tree structure constructed by the database system provided in the embodiments of this specification;

[0024] Figure 3 A schematic diagram of a data query device provided in an embodiment of this specification;

[0025] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0026] Learned indexing is a data indexing technology that uses index models to replace traditional index structures such as B-trees, B+ trees, and hash tables. Its core concept is to more efficiently predict the location of data by fitting the distribution patterns of stored data, reducing the computational overhead during queries and improving query efficiency. Current learned indexes use linear functions to fit the cumulative distribution function (CDF) of the keys of stored data. However, due to the limited ability of linear functions to fit data distribution, they often fail to fully utilize the complex characteristics of the data. When the data distribution is uneven or has complex nonlinear characteristics, the linear function's fitting accuracy is poor, and it cannot fully capture the data distribution patterns, making it difficult to meet the efficient query and low latency requirements of modern big data storage systems.

[0027] Based on this, the embodiment of this specification uses a nonlinear function to fit the CDF of the stored data. The system automatically divides the value range of the key of all possible data into appropriate intervals, and for each interval, automatically selects a suitable nonlinear function to fit the CDF of the stored data, which can effectively improve the fitting accuracy of the CDF of the stored data and achieve the purpose of efficient query.

[0028] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.

[0029] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.

[0030] Figure 1 A data query method flow diagram provided in an embodiment of this specification includes the following steps:

[0031] S100: Determine the value range of the data key.

[0032] In the embodiments of this specification, the Figure 1 The execution subject of the data query in the method shown may be a database system, specifically a server or server cluster used to host the database system. The following description will only take the database system as an example.

[0033] Examples of this specification Figure 1 Steps S100 to S104 are the process of building an index for stored data. When building an index, the database system first needs to determine the value range of all possible data keys. That is, the value range is the theoretical value range of the data key. Regardless of whether the data is already stored in the database system, as long as the theoretically possible values ​​of the data key are within this value range.

[0034] Generally, a database system will first generate a tree structure according to the key of the data. There are many ways to construct a tree structure. The following only uses the bottom-up construction method as an example to illustrate.

[0035] Assuming that theoretically the value range of the data key is 1 to 80, the value range can be divided into 8 key intervals, namely 1 to 10, 11 to 20, 21 to 30, and so on. Each leaf node corresponds to a key interval, so the 8 leaf nodes corresponding to the above 8 key intervals are determined, which is the bottom layer of the tree structure. Then, the first key in the key interval corresponding to each adjacent n leaf nodes is used as the key corresponding to the parent node of these two leaf nodes to construct the parent node of the leaf node. Assuming n is 2, the parent node of the leaf nodes corresponding to 1 to 10 and 11 to 20 is (1, 11), and the parent node of the leaf nodes corresponding to 21 to 30 and 31 to 40 is (21, 31), and so on. Then use the parent node as the child node, and again use the first key in the key corresponding to each adjacent n child node as the key corresponding to the parent node of these two child nodes, until the following is constructed. Figure 2 The tree structure shown is as follows.

[0036] Those skilled in the art should understand that there are more than one method for constructing a tree structure, and any method for constructing a tree structure can achieve the effect to be achieved in this specification. This specification does not limit the method for constructing a tree structure and the topological structure of the constructed tree.

[0037] Still Figure 2 For example, after building the tree structure, each leaf node can be assigned a slot, or storage location. However, it should be noted that when allocating slots to a leaf node, not every key in the key interval corresponding to the leaf node is assigned a corresponding slot. The actual number of slots allocated to a leaf node is less than the number of keys in the key interval corresponding to the leaf node.

[0038] For example, a leaf node may have a key range of 1 to 10, meaning it can store up to 10 data items. However, only three slots are allocated for this leaf node. This is because the key range 1 to 10 represents theoretically possible keys for data. In practice, the keys for the data to be stored are not generated sequentially from smallest to largest; they exhibit a certain degree of randomness. For example, at a certain moment, the three data items to be stored are user information for Zhang San, Li Si, and Wang Wu. The keys for these three data items determined based on their IDs (e.g., by hashing the user IDs) are 2, 5, and 9, respectively. However, the data items corresponding to the other keys in the key range 1 to 10 have not yet been generated. Therefore, the keys for the three data items to be stored are not sequentially 1, 2, and 3. If the leaf node is fully allocated slots based on the key range 1 to 10, some of these slots may remain idle for extended periods, resulting in a waste of storage resources. Therefore, the number of slots actually allocated for the leaf node is less than the number of keys in the key range corresponding to the leaf node.

[0039] However, this also leads to nonlinear distribution of data, which reduces the accuracy of using linear functions to fit the mapping relationship between data keys and storage locations in the learning index.

[0040] Continuing with the above example, the index model fitted by the learning index is a function that takes the data key as input and the data storage location as output, that is, y = n × f(x), where n is the total number of keys in the key interval of the leaf node, x is the data key, y is the data storage location, and f(x) represents the CDF of the data storage location with respect to x.

[0041] The key range corresponding to the leaf node is 1 to 10. Theoretically, if a slot is assigned to each key corresponding to the leaf node, for a total of 10 slots, then the above f(x) = x / n, and the index model is y = x. From this index model, it can be seen that the data with key 1 is stored in the first storage location, and the data with key n is stored in the nth storage location. At this time, the data distribution is a perfect linear distribution.

[0042] However, in the above example, only 3 slots are allocated to the leaf node. Zhang San's data with a key of 2 is stored in the first storage position, Li Si's data with a key of 5 is stored in the second storage position, and Wang Wu's data with a key of 9 is stored in the third storage position. This destroys the linearity of the data distribution. At this time, the index function y = n × f (x) that needs to be fitted needs to make y = 1 when x = 2, y = 2 when x = 5, and y = 3 when x = 9. This is also the reason why the linear function fitting method used in the current learning indexing method has poor accuracy.

[0043] Therefore, in the embodiment of this specification, the database system first determines the theoretical value range of the keys of all data. Regardless of whether a data has been stored in the database system at this time, as long as the theoretically possible values ​​of the key of the data are within the value range.

[0044] S102: Divide the value range into a plurality of key intervals according to the keys of the stored data and the preset nonlinear functions.

[0045] In the embodiments of this specification, regardless of whether the database system has previously generated the aforementioned tree structure, the database system can re-divide the value range of the data key. Because the embodiments of this specification require the use of a nonlinear function to fit the index model, the database system needs to re-divide the aforementioned value range so that each divided key interval is suitable for at least one preset nonlinear function fitting index model.

[0046] Specifically, the database system may first divide the value range into a to-be-determined interval with a default length according to the order of the key values ​​from small to large.

[0047] For example, assuming that the key value range is 1 to 80 and the default length is 10, then in ascending order of values, the undetermined intervals divided in the value range are 1 to 10.

[0048] After the pending interval is divided, the fitting loss of fitting the mapping relationship between the key and storage location of the data stored in the pending interval using at least one preset nonlinear function can be determined based on the key of the data stored in the pending interval and the preset nonlinear functions. That is, the database system needs to determine the fitting loss of fitting the CDF of the data stored in the pending interval using at least one nonlinear function. The fitting loss described in this specification is positively correlated with the target difference. The target difference refers to the difference between the storage location output by the fitted nonlinear function after inputting the key of the data stored in the pending interval into the fitted nonlinear function and the actual storage location of the stored data in the pending interval. The greater the difference, the greater the fitting loss, and vice versa.

[0049] When determining the fitting loss of at least one preset nonlinear function, the database system can directly use the nonlinear function to fit the CDF of the data stored in the undetermined interval, and determine the fitting loss based on the fitted nonlinear function. It can also use an estimation method to estimate the fitting loss of using the nonlinear function to fit the CDF of the data stored in the undetermined interval. The specific estimation method is not within the scope of protection of this specification.

[0050] The aforementioned preset nonlinear functions may be set as required, and may include polynomial interpolation functions (such as Lagrange interpolation functions, Newton interpolation functions, etc.), spline interpolation functions, etc.

[0051] After determining the fitting loss, the length of the pending interval can be adjusted until the fitting loss reaches the set loss threshold. The adjusted pending interval is then determined as the key interval. When adjusting the length of the pending interval, the key value range must still be re-divided into an interval of the adjusted length, in ascending order of key values.

[0052] For example, assuming the initial interval is 1 to 10, the database system uses a polynomial interpolation function to fit the CDF based on the stored data in the interval. If the fitting loss is less than a preset loss threshold, the interval can be further extended. Generally, the more stored data in the interval, the worse the fitting accuracy, that is, the greater the fitting loss. Therefore, the left endpoint of the interval can be kept unchanged, and the right endpoint can be increased until the stored data in the adjusted interval increases. The fitting loss of the adjusted interval can then be recalculated until the fitting loss reaches the loss threshold. If the fitting loss exceeds the preset loss threshold, the interval needs to be shortened. Therefore, the left endpoint of the interval can be kept unchanged, and the right endpoint can be decreased until the stored data in the adjusted interval decreases. The fitting loss of the adjusted interval can then be recalculated until the fitting loss reaches the loss threshold.

[0053] When the loss threshold is reached, the pending interval can be determined as a divided key interval, and key intervals can be further divided in the remaining intervals of the value range determined in step S100 except the divided key interval until the entire value range is divided.

[0054] In this way, the database system can automatically divide the key intervals suitable for fitting CDF.

[0055] S104: For each key interval, according to the key of the stored data in the key interval, select a target nonlinear function from each nonlinear function to fit the mapping relationship between the key of the stored data and the storage location of the stored data, and use the fitted target nonlinear function as the index model corresponding to the key interval.

[0056] After dividing the key intervals, the database system can select a suitable nonlinear function from the preset nonlinear functions for each key interval according to the distribution of the data stored in the key interval, as the target nonlinear function, use the target nonlinear function to fit the CDF of the data stored in the key interval, and use the fitted target nonlinear function as the index model corresponding to the key interval.

[0057] When selecting the target nonlinear function, the database system can still make a selection based on the fitting loss. Specifically, the database system can determine the fitting loss of fitting the mapping relationship between the key and storage location of the data stored in the key interval using each preset nonlinear function, and use the nonlinear function with the smallest fitting loss as the target nonlinear function. Similar to step S102, the database system can directly use each nonlinear function to fit the CDF of the data stored in the undetermined interval, determine the fitting loss based on the fitted nonlinear function, or use an estimation method to estimate the fitting loss of fitting the CDF of the data stored in the undetermined interval using each nonlinear function.

[0058] Thus, in practical applications, the above-mentioned steps S102 and S104 can be executed simultaneously. After determining the value range of the key of the data through step S100, the database system can first divide the value range into a predetermined interval with a default length in the order of the key value from small to large, and determine the fitting loss of each preset nonlinear function for fitting the mapping relationship between the key and storage location of the stored data in the predetermined interval. The nonlinear function with the smallest fitting loss is determined as the target nonlinear function, and it is determined whether the fitting loss of the target nonlinear function reaches a preset loss threshold. If not, the length of the predetermined interval is adjusted, and the adjusted predetermined interval is refitted using the target nonlinear function until the fitting loss reaches the set loss threshold. The predetermined interval with the adjusted length is determined as the key interval, and the target nonlinear function fitted at this time is determined as the index model of the key interval. At the same time, after all key intervals are determined, the database system can also construct the above-mentioned tree structure.

[0059] At this point, the database system has constructed an index for all stored data in the value range and a tree structure. Next, the data can be located using the tree structure and index, i.e., steps S106 to S108.

[0060] S106: When the target storage location of the target data is located, the key interval where the target storage location is located is determined according to the key of the target data as the target interval.

[0061] In an embodiment of the present specification, a database system may receive a request to locate a target storage location of target data. It should be noted that the target data corresponding to the target storage location to be located in the present specification is not necessarily stored data already stored in the database system. When the target data is stored data, the request to locate the target storage location of the target data may include a request to read the target data or a request to modify or delete the target data. When the target data is not stored data, the request to locate the target storage location of the target data may include a request to write the target data.

[0062] Regardless of whether the target data is already stored in the database system, the request for locating the target storage location of the target data will carry the key of the target data. Therefore, the database system can determine the key interval where the key of the target data is located based on the tree structure constructed above, as the target interval, that is, based on the key of the target data and the tree structure constructed above, determine the leaf node hit by the key of the target data.

[0063] S108: Input the key of the target data into the index model corresponding to the target interval, and obtain the target storage location output by the index model corresponding to the target interval.

[0064] After determining the target interval, the database system can input the target data's key into the index model corresponding to the target interval to obtain the target storage location output by the index model. Of course, the target storage location output by the index model may still have some deviation, but the index model fitted in steps S100-S104 is sufficiently accurate that, even with deviation, the target data's actual storage location is guaranteed to be near the target storage location output by the index model. Therefore, the database system can determine the target data's actual storage location within a preset neighborhood of the target storage location output by the index model.

[0065] Through the above method, the database system can automatically divide the value range of the keys of all possible data into several key intervals suitable for fitting with nonlinear functions. According to the keys of the stored data in each key interval, a suitable nonlinear function is automatically used to fit the mapping relationship between the keys of the stored data and the storage locations of the stored data, and an index model corresponding to the storage location interval is obtained. When locating the target data, the key of the target data is directly input into the index model corresponding to the key interval where it is located, and the target storage location output by the index model can be obtained. This allows the index model to output the storage location of the data more accurately according to the input key, and directly querying the data through the index model can also effectively improve the query efficiency.

[0066] Furthermore, when the request to locate the target storage location of target data is a request to read the target data, the database system may read the target data based on the target storage location. When the request is to modify or delete the target data, the database system may modify or delete the target data accordingly based on the target storage location. When the request is to write the target data, the database system may write the target data into the target interval based on the target storage location.

[0067] However, it should be noted that in order to ensure data consistency and take into account high concurrent access to the database system, when the target data is changed, deleted, and written, a locking mechanism needs to be introduced to lock the target data. The locks include atomic locks, optimistic locks, or lock-free data structures can be used to manage the data stored in the database system.

[0068] When the request is to write the target data, the database system writes the target data into the target interval rather than directly into the target storage location within the target interval because the target storage location (i.e., slot) within the target interval may not exist. For example, in the example above, only three slots are allocated for key interval 1-10. If the target storage location is 4-10, then the target storage location does not exist within the key interval.

[0069] If the target storage location exists in the target interval, the database system can first determine whether other data is already stored in the target storage location. If no other data is stored in the target storage location, the target data can be directly written to the target storage location. If other data is already stored in the target storage location, the target data can be written to other available storage locations in the target interval.

[0070] If the target storage location does not exist in the target interval, the database system may write the target data to other available storage locations in the target interval, or may add the target storage location in the target interval and write the target data to the added target storage location.

[0071] Furthermore, the above-mentioned operation of adding one or more available storage locations in the target interval is called expanding a leaf node. There is no restriction in this specification as to the rules for when the database system needs to expand a leaf node. However, when a leaf node is expanded, it is often necessary to adjust the storage locations of all stored data in the key interval corresponding to the leaf node, which will affect other processes that are currently reading and writing data stored in the leaf node, and do not meet the requirements of high concurrency. To this end, in an embodiment of this specification, a copy-on-write (COW) technology can be used to copy the leaf node that currently needs to be expanded to obtain a copy of the leaf node that currently needs to be expanded, that is, a copy of the target interval, which includes all available storage locations in the current target interval and all stored data in the target interval. After obtaining the copy, the database system can add a target storage location in the copy, and then write the target data to the target storage location added in the copy. After writing the target data, the copy written to the target data is used to replace the target interval. In this way, during the process of expanding the replica of the leaf node, the original leaf node can still support read and write access by other threads, meeting the high concurrency requirements of the database system.

[0072] The above is a data query method provided in an embodiment of this specification. Based on the same idea, this specification also provides corresponding devices, storage media and electronic devices.

[0073] Figure 3 A schematic diagram of a data query device provided in an embodiment of this specification, the device comprising:

[0074] Determination module 301, used to determine the value range of the key of the data;

[0075] A division module 302 is configured to divide the value range into a plurality of key intervals according to the keys of the stored data and the preset nonlinear functions;

[0076] A fitting module 303 is configured to select, for each key interval, a target nonlinear function from among the nonlinear functions based on the keys of the stored data in the key interval, to fit the mapping relationship between the keys of the stored data and the storage locations of the stored data, and use the fitted target nonlinear function as the index model corresponding to the key interval;

[0077] The query module 304 is used to determine the key interval where the target storage location is located based on the key of the target data when locating the target storage location of the target data, and input the key of the target data into the index model corresponding to the target interval as the target interval to obtain the target storage location output by the index model corresponding to the target interval.

[0078] Optionally, the division module 302 is specifically used to divide a pending interval with an interval length of a default length in the value range; determine the fitting loss of fitting the mapping relationship between the key and storage position of the stored data in the pending interval using at least one preset nonlinear function based on the key of the stored data in the pending interval and the preset nonlinear functions; adjust the length of the pending interval until the fitting loss reaches the set loss threshold, and determine the pending interval with the adjusted length as the key interval.

[0079] Optionally, the fitting module 303 is specifically configured to determine a fitting loss for fitting the mapping relationship between the keys and storage locations of the data stored in the key interval using each nonlinear function; and use the nonlinear function with the smallest fitting loss as the target nonlinear function.

[0080] Optionally, for any nonlinear function, a fitting loss of fitting the mapping relationship between the key and the storage location of the stored data using the nonlinear function is positively correlated with the target difference;

[0081] The target difference is the difference between the storage location output by the fitted nonlinear function obtained by inputting the key of the stored data into the fitted nonlinear function and the actual storage location of the stored data.

[0082] Optionally, the query module 304 is further configured to read the target data according to the target storage location; or write the target data into the target interval according to the target storage location.

[0083] Optionally, the query module 304 is specifically used to, if the target storage location exists in the target interval, write the target data to the target storage location; if the target storage location does not exist in the target interval, write the target data to other available storage locations in the target interval, or add the target storage location in the target interval and write the target data to the added target storage location.

[0084] Optionally, the query module 304 is specifically used to obtain a copy of the target interval, the copy including all available storage locations in the target interval and all stored data in the target interval; add the target storage location in the copy, and write the target data to the target storage location added in the copy; and replace the target interval with the copy of the target data written.

[0085] This specification also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can be used to execute the data query method provided above.

[0086] based on Figure 1 The data query method shown in this specification also provides Figure 4 The structural diagram of the electronic device shown in FIG. Figure 4 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile storage, and may also include other hardware required for its operations. The processor reads the corresponding computer program from the non-volatile storage into the memory and then runs it to implement the above-mentioned data query method.

[0087] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.

Claims

1. A data query method, comprising: Determine the value range of the data key; Dividing the value range into a plurality of key intervals according to the keys of the stored data and the preset nonlinear functions; For each key interval, according to the keys of the stored data in the key interval, a target nonlinear function is selected from each nonlinear function to fit the mapping relationship between the keys of the stored data and the storage locations of the stored data, and the fitted target nonlinear function is used as the index model corresponding to the key interval; When locating the target storage location of the target data, the key interval where the target storage location is located is determined according to the key of the target data, as the target interval, the key of the target data is input into the index model corresponding to the target interval, and the target storage location output by the index model corresponding to the target interval is obtained.

2. The method according to claim 1, wherein the value range is divided into a plurality of key intervals, specifically comprising: Dividing the value range into a to-be-determined interval with a default length; Determining, based on the keys of the stored data in the undetermined interval and the preset nonlinear functions, a fitting loss for fitting a mapping relationship between the keys of the stored data in the undetermined interval and the storage locations using at least one preset nonlinear function; The length of the pending interval is adjusted until the fitting loss reaches a set loss threshold, and the pending interval with the adjusted length is determined as a key interval.

3. The method according to claim 1, wherein selecting a target nonlinear function from among the nonlinear functions to fit the mapping relationship between the key of the stored data and the storage location of the stored data comprises: Determining a fitting loss for fitting each nonlinear function to a mapping relationship between keys and storage locations of stored data in the key interval; The nonlinear function with the smallest fitting loss is taken as the target nonlinear function.

4. The method of claim 2 or 3, wherein for any nonlinear function, a fitting loss of fitting the mapping relationship between the key and the storage location of the stored data using the nonlinear function is positively correlated with the target difference; The target difference is the difference between the storage location output by the fitted nonlinear function obtained by inputting the key of the stored data into the fitted nonlinear function and the actual storage location of the stored data.

5. The method of claim 1, further comprising: Reading the target data according to the target storage location; or The target data is written into the target interval according to the target storage location.

6. The method according to claim 5, wherein writing the target data into the target interval comprises: If the target storage location exists in the target interval, writing the target data into the target storage location; If the target storage location does not exist in the target interval, the target data is written to other available storage locations in the target interval, or the target storage location is added in the target interval, and the target data is written to the added target storage location.

7. The method according to claim 6, wherein adding the target storage location in the target interval comprises: Obtaining a copy of the target interval, the copy including all available storage locations in the target interval and all stored data in the target interval; Adding the target storage location in the copy, and writing the target data to the added target storage location in the copy; The target interval is replaced with a copy of the target data written thereto.

8. A data query device, comprising: A determination module is used to determine the value range of the data key; a partitioning module, configured to partition the value range into a plurality of key intervals according to the keys of the stored data and the preset nonlinear functions; a fitting module configured to, for each key interval, select a target nonlinear function from among the nonlinear functions to fit the mapping relationship between the key of the stored data and the storage location of the stored data according to the key of the stored data in the key interval, and use the fitted target nonlinear function as the index model corresponding to the key interval; The query module is used to determine the key interval where the target storage location is located based on the key of the target data when locating the target storage location of the target data, and input the key of the target data into the index model corresponding to the target interval as the target interval to obtain the target storage location output by the index model corresponding to the target interval.

9. A computer-readable storage medium storing a computer program, wherein the computer program implements the method according to any one of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.