Data query method, device, apparatus, and storage medium
By using hash indexes or B+ tree indexes, the index type is determined based on the target query information. This solves the problem of increased scan counts and longer query times caused by the absence of target query data in the cache, enabling rapid location of target query data and improving query efficiency.
Patent Information
- Application Number
- CN202310430330.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-20
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-04-20
AI Technical Summary
In existing technologies, when the target query data is not included in the cache, the number of scans and query time are increased, reducing query efficiency.
By employing hash index or B+ tree index strategies, the index type is determined based on the target query information, and the location information of the target query data is queried directly or according to the strategy, thereby reducing the number of scans and query time.
By using different index types, you can quickly locate the target query data, reduce the number of scans, and improve query efficiency.
Smart Images

Figure CN116483833B_ABST
Abstract
Description
Technical Field
[0001] This application relates to big data technology, and in particular to a data query method, apparatus, device and storage medium. Background Technology
[0002] With societal development, big data has become a highly sought-after field. To date, big data technologies in distributed storage and computing are relatively mature, capable of reliably addressing the large-scale computing needs of massive datasets. However, in data querying, locating the target query data within a vast amount of data remains a challenge.
[0003] In existing technologies, when an electronic device retrieves target query data from a local disk, the disk contains massive amounts of data. The electronic device needs to scan this massive amount of data one by one to locate the target query data. Alternatively, the electronic device can use a pre-calculation method to store each query result in a cache. When there is a next query request, the electronic device first checks the cache to see if the target query data is included. If it is, the target query data is retrieved or displayed; if not, the electronic device needs to scan the massive amount of data one by one until the target query data is found.
[0004] Therefore, scanning massive amounts of data one by one, and the fact that the cache has a certain probability of hitting the target query data, and that the current business scenarios are diverse and the target query data is often not hit by the cache, will increase the number of scans and query time, thus reducing query efficiency when the target query data is not in the cache. Summary of the Invention
[0005] This application provides a data query method, apparatus, device, and storage medium to solve the problem in the prior art that the cache does not include the target query data, which increases the number of scans and query time, and reduces query efficiency.
[0006] Firstly, this application provides a data query method, the method comprising:
[0007] The system receives a data query command sent by a control device; the data query command includes target query information; the target query information reflects the target query data.
[0008] The corresponding index type is determined based on the target query information; the index type is either a hash index or a B+ tree index.
[0009] In response to the index type being a Hash index, the location information corresponding to the target query data is directly queried from the preset mapping information according to the target query information and the Hash index strategy to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information.
[0010] In response to the index type being a B+ tree index, the location information corresponding to the target query data is queried according to the target query information, the preset mapping information, and the B+ tree index strategy to obtain the target location information.
[0011] Secondly, this application provides a data query device, the device comprising:
[0012] A receiving module is used to receive data query commands sent by a control device; the data query command includes target query information; the target query information reflects the target query data;
[0013] The determination module is used to determine the corresponding index type based on the target query information; the index type is either a hash index or a B+ tree index.
[0014] The query module is used to respond to the index type being a Hash index, and to directly query the location information corresponding to the target query data from the preset mapping information according to the target query information and the Hash index strategy, so as to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information.
[0015] The query module is used to respond to the fact that the index type is a B+ tree index, and to query the location information corresponding to the target query data according to the target query information, the preset mapping information and the B+ tree index strategy, so as to obtain the target location information.
[0016] Thirdly, this application provides an electronic device, including: a processor, and a memory and a receiver communicatively connected to the processor;
[0017] The memory stores computer-executed instructions; the receiver is used to receive data;
[0018] The processor executes computer execution instructions stored in the memory to implement the method as described in the first aspect above.
[0019] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect above.
[0020] This application provides a data query method, apparatus, device, and storage medium, specifically including: receiving a data query command sent by a control device; the data query command includes target query information; the target query information reflects target query data; determining the corresponding index type based on the target query information; the index type is a hash index or a B+ tree index; in response to the index type being a hash index, directly querying the location information corresponding to the target query data from preset mapping information based on the target query information and the hash index strategy to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information; in response to the index type being a B+ tree index, querying the location information corresponding to the target query data based on the target query information, the preset mapping information, and the B+ tree index strategy to obtain the target location information. In this application, the data query device first receives a data query command from the control device. The data query command includes target query information. The data query device then determines the corresponding index type based on the target query information. Since the target query information reflects the target query data, querying with an appropriate index type allows the target query data to be retrieved and its location information obtained. If the index type is a Hash index, the data query device can directly retrieve the location information corresponding to the target query data from preset mapping information, thereby obtaining the target location information. If the index type is a B+ tree index, the target query data will be queried according to the B+ tree index strategy. In this application, the data query device can determine the index type based on the target query information. The Hash index directly determines the location information of the target query data, thus reducing the number of scans the data query device needs to perform in massive amounts of data, allowing for rapid location of the target query data and obtaining its location information. Simultaneously, the B+ tree index, querying the target query data according to its corresponding strategy, also reduces the number of scans. Therefore, this application reduces query time and accelerates response time when querying target query data using different index types, thereby improving query efficiency. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0022] Figure 1 An application scenario diagram of a data query method provided in this application;
[0023] Figure 2 This is a schematic diagram of a data query method provided in Embodiment 1 of this application;
[0024] Figure 3 This is a schematic flowchart of a data query method provided in Embodiment 3 of this application;
[0025] Figure 4 This is a schematic diagram of a data query method provided in Embodiment 4 of this application;
[0026] Figure 5 This is a schematic flowchart of a data query method provided in Embodiment 5 of this application;
[0027] Figure 6 This is a schematic flowchart of a data query method provided in Embodiment Six of this application;
[0028] Figure 7 This is a schematic diagram of a target tree structure provided in Embodiment Six of this application;
[0029] Figure 8 This is a schematic flowchart of a data query method provided in Embodiment 7 of this application;
[0030] Figure 9 This is a schematic flowchart of a data query method provided in Embodiment 8 of this application;
[0031] Figure 10 This is a schematic diagram of a data query interaction provided in Embodiment 9 of this application;
[0032] Figure 11 This is a schematic diagram of a data query device provided in Embodiment 10 of this application;
[0033] Figure 12 This is a schematic diagram of the structure of an electronic device provided in Embodiment Eleven of this application.
[0034] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0035] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0036] The following is an explanation of the terms used in this application:
[0037] Hash Index: A hash index is a method for fast searching. It can quickly and directly determine the location of target query data within massive amounts of data using a hash indexing strategy. Hash indexes are unordered, making them suitable for point-to-point searches and small-range queries, thus enabling direct addressing.
[0038] B+ tree index: A strictly balanced search tree where the path length from the root node to every leaf node is the same, and data is sorted sequentially in the leaf nodes. B+ tree indexes are suitable for range queries.
[0039] In existing technologies, users can input target query data through electronic devices. When the electronic device retrieves the target query data from its local disk, which contains massive amounts of data, it needs to scan this massive dataset one by one to locate the target query data and its location information. Alternatively, the electronic device can use a pre-calculation method to store each query result in a cache. When a new query is needed, the electronic device first checks the cache to see if the target query data is included. If it is, it locates the target query data and retrieves or displays it; if not, it needs to scan the massive dataset one by one until the target query data is found.
[0040] Therefore, scanning massive amounts of data one by one, and the fact that the cache has a certain probability of hitting the target query data, and that the current business scenarios are diverse and the target query data is often not hit by the cache, will increase the number of scans and query time, thus reducing query efficiency when the target query data is not in the cache.
[0041] To address the shortcomings of existing technologies, the inventors of this solution have creatively designed a new approach. This solution provides a data query method that solves the problems of increased scanning times and reduced query efficiency in existing technologies. The data query device in this solution first receives a data query command from a control device, which includes target query information. The data query then determines the corresponding index type based on the target query information. If it is a Hash index, the data query device directly queries the location information corresponding to the target query data from a preset mapping information, thereby obtaining the target location information. In this solution, for the case of using a Hash index, since Hash indexes can be directly queried, this solution can quickly retrieve the target query data, reducing the number of scans of the target query data and thus improving query efficiency. Furthermore, when the index type is a B+ tree index, this solution can query the location information corresponding to the target query data according to the B+ tree index strategy. The use of a B+ tree index in this solution also reduces the scanning of the target query data, thus improving query efficiency and quickly finding the location information of the target query data.
[0042] The following describes the application scenarios of the data query method, apparatus, device, and storage medium provided in this application.
[0043] Figure 1 This is a diagram illustrating an application scenario for a data query method provided in this application. For example... Figure 1 As shown in the diagram, the application scenario includes a control device 101 and an electronic device 102.
[0044] The control device 101 is communicatively connected to the electronic device 102, and the connection method can be either wired or wireless.
[0045] The control device 101 can be any communication device, such as a mobile phone or a computer, and there are no restrictions here.
[0046] The electronic device 102 includes a data query device 103. The electronic device 102 can be a computer or the like, and there are no restrictions here.
[0047] Specifically, when a user has a query requirement, the user triggers the query requirement through the control device 101. The user inputs the target query information through the control device 101, which is the information to be queried by the user. The control device 101 generates a data query command, which includes the target query information and reflects the target query data.
[0048] Furthermore, the control device 101 sends a data query command to the electronic device 102, which in turn sends the data query command to the data query device 103. The data query device 103 determines the corresponding index type based on the target query information in the data query command. It should be noted that the data query command instructs the data query device 103 to initiate the data query process.
[0049] Furthermore, in response to the index type being Hash index, the data query device 103 directly queries the location information corresponding to the target query data from the preset mapping information based on the target query information and the Hash index strategy, thereby obtaining the target location information.
[0050] Alternatively, in response to an index type of B+ tree index, the data query device 103 queries the location information corresponding to the target query data based on the target query information, preset mapping information, and B+ tree index strategy, thereby obtaining the target location information.
[0051] Furthermore, the data query device 103 determines the target location information based on the above description, and can then display or obtain the target query data.
[0052] 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, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0053] It should be noted that the data query method, apparatus, device and storage medium provided in this application can be applied to the field of big data technology, or to any field other than big data. The application field of this application is not limited.
[0054] This application provides a data query method aimed at solving the above-mentioned technical problems in the prior art.
[0055] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0056] Example 1
[0057] Figure 2This is a schematic flowchart illustrating a data query method provided in Embodiment 1 of this application. The executing entity in this embodiment is a data query device, which is located within an electronic device. Figure 2 As shown, the specific steps are as follows.
[0058] S201, Receive a data query command sent by the control device; the data query command includes target query information; the target query information reflects the target query data.
[0059] The control device can be any communication device, such as a mobile phone or a computer, and there are no restrictions here.
[0060] The data query command is a command used to query data, instructing the data query device to initiate the data query process and retrieve the target query data and its location information from a massive dataset based on the target query information. The massive dataset is stored on the local disk of the data query device.
[0061] The target query information refers to the user's query requirements, which is the query information input by the data query device. For example, if the target query information is "COL1=12", the data query device needs to determine the location of the file "COL1=12" on the disk and locate it there. "COL1=12" can be the filename, the query field information corresponding to that file, or the identification code corresponding to the target query data; there are no restrictions here.
[0062] The target query information reflects the target query data, which is the data that the user actually wants to query. For example, if the target query information is "COL1=12", then the target query data is the file "COL1=12", which includes at least one piece of data that the user wants to query.
[0063] Specifically, the control device communicates with the electronic device, and a data query device is deployed in the electronic device. When the control device generates a data query command, it sends it to the data query device, and then the data query device receives the data query command.
[0064] It should be noted that after receiving a data query command, the data query device will initiate the data query process.
[0065] S202, determine the corresponding index type based on the target query information; the index type is either a hash index or a B+ tree index.
[0066] Specifically, the data query device determines the corresponding index type based on the nature and field format of the target query information.
[0067] Optionally, the data query device determines whether the target query information is a Hash index or a B+ tree index, thereby determining the corresponding index type; alternatively, the data query device determines whether the target query information field format is a Hash index field format or a B+ tree index field format, thereby determining the corresponding index type. No restrictions are placed on the method used to determine the index type.
[0068] S203, in response to the index type being a Hash index, the target query information is obtained by directly querying the location information corresponding to the target query data from the preset mapping information based on the target query information and the Hash index; the preset mapping information includes preset data information and its corresponding location information.
[0069] The preset mapping information consists of pre-defined or pre-calculated preset data and corresponding location information. The preset data can include a filename, the corresponding query field, and the corresponding identification code. For example, the preset data might be "COL1=5," with the corresponding location information being "A." Here, "COL1=5" and "A" are merely illustrative; "A" does not represent the actual location. It should be noted that the preset mapping information can be a hash table, and it can be updated based on new data entries.
[0070] Location information refers to information such as the coordinates of the data on the disk. The data query device can query and locate the data based on the location information. Target location information refers to the location information corresponding to the target query data, so the target query data can be queried and located based on the target location information.
[0071] Specifically, the data query device uses a hash index to query the target query data and retrieve the corresponding location information. Since the hash index has direct addressing capabilities, the data query device directly queries the location information corresponding to the target query data from the preset mapping information. Optionally, the data query device finds a mapping information in the preset mapping information that matches the target query information, then determines the location information corresponding to this mapping information as the location information corresponding to the target query data, and identifies it as the target location information.
[0072] S204, in response to the index type being B+ tree index, query the location information corresponding to the target query data based on the target query information, preset mapping information, and B+ tree index strategy to obtain the target location information.
[0073] Specifically, in response to a B+ tree index, the data query device determines the tree structure based on preset mapping information. Then, based on the target query information, the data query device sequentially identifies leaf nodes that match the target query information from left to right and from top to bottom. The location information contained in these matching leaf nodes determines the location information corresponding to the target query data, thereby obtaining the target location information. The leaf nodes in the tree structure contain preset data and its corresponding location information. In this embodiment, other methods can also be used to obtain the target location information, which are not limited here.
[0074] This embodiment provides a data query method, specifically including: receiving a data query command sent by a control device; the data query command includes target query information; the target query information reflects target query data; determining the corresponding index type based on the target query information; the index type is a hash index or a B+ tree index; in response to the index type being a hash index, directly querying the location information corresponding to the target query data from preset mapping information based on the target query information and the hash index strategy to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information; in response to the index type being a B+ tree index, querying the location information corresponding to the target query data based on the target query information, the preset mapping information, and the B+ tree index strategy to obtain the target location information. In this embodiment, the data query device first receives a data query command from the control device. The data query command includes target query information. The data query device then determines the corresponding index type based on the target query information. Since the target query information reflects the target query data, querying with an appropriate index type allows the target query data to be retrieved and its location information obtained. If the index type is a Hash index, the data query device can directly retrieve the location information corresponding to the target query data from the preset mapping information, thereby obtaining the target location information. If the index type is a B+ tree index, the target query data will be queried according to the B+ tree index strategy. In this embodiment, the data query device can determine the index type based on the target query information. The Hash index directly determines the location information of the target query data, thus reducing the number of scans the data query device performs in massive amounts of data, allowing for rapid location of the target query data and obtaining its location information. Simultaneously, the B+ tree index, querying the target query data according to its corresponding strategy, also reduces the number of scans. Therefore, in this embodiment, querying the target query data using different index types can reduce query time, accelerate response, and improve query efficiency.
[0075] Example 2
[0076] This embodiment is a further refinement of the first embodiment described above. This embodiment is an optional method for determining the corresponding index type based on the target query information, and the specific content is as follows.
[0077] Determine the target filtering conditions based on the target filtering fields included in the target query information; determine the corresponding index type based on the target filtering conditions.
[0078] The target filter field refers to the field included in the target query information used to determine the filtering conditions. For example, if the target query information is "COL1=12", then "=" is the target filter field.
[0079] The target filtering conditions include point-to-point filtering conditions or range filtering conditions. Point-to-point filtering conditions correspond to fields such as "=", "IN", and "<>". Optionally, if the data query device determines that the target filtering field is "=", then the target filtering condition to which this target filtering field belongs is determined to be a point-to-point filtering condition; or, if the data query device determines that the target filtering field is "IN", then the target filtering condition to which this target filtering field belongs is determined to be a point-to-point filtering condition; or, if the data query device determines that the target filtering field is "<>", then the target filtering condition to which this target filtering field belongs is determined to be a point-to-point filtering condition.
[0080] The filtering fields corresponding to the range filtering conditions are fields such as "<", ">", "≤", "≥", and "between". Optionally, if the data query device determines that the target filtering field is "<", then the target filtering condition to which the target filtering field belongs is determined to be a range filtering condition; or, if the data query device determines that the target filtering field is ">", then the target filtering condition to which the target filtering field belongs is determined to be a range filtering condition; or, if the data query device determines that the target filtering field is "≤", then the target filtering condition to which the target filtering field belongs is determined to be a range filtering condition. Alternatively, if any of the other filtering fields corresponding to the range filtering condition are used, then the target filtering condition to which the target filtering field belongs is determined to be a range filtering condition.
[0081] Furthermore, the data query device determines the corresponding index type based on the target filtering conditions.
[0082] This embodiment provides a data query method. When determining the corresponding index type based on target query information, the method specifically includes: determining the target filtering conditions based on the target filtering fields included in the target query information; and determining the corresponding index type based on the target filtering conditions. In this embodiment, the data query device can identify the target filtering fields included in the target query information. Different target filtering fields correspond to different target filtering conditions, so the data query device ultimately determines the index type based on the target filtering fields. Therefore, in this embodiment, the corresponding index type can be accurately determined through the target filtering fields.
[0083] Example 3
[0084] This embodiment is a further refinement of any of the above embodiments. In this embodiment, the target filtering condition is either a point-to-point filtering condition or a range filtering condition.
[0085] Among them, the point-to-point filtering condition refers to the condition corresponding to the equal value field.
[0086] Among them, the range filtering condition refers to the condition that the filtering field corresponds to the range field.
[0087] Figure 3 This is a schematic flowchart of a data query method provided in Embodiment 3 of this application. This embodiment is an optional method for determining the corresponding index type based on target filtering conditions, such as… Figure 3 As shown, the specific steps are as follows.
[0088] S301, in response to the target filter condition being a point lookup filter condition, determine the index type as a Hash index.
[0089] S302, in response to the target filtering condition being a range filtering condition, determine the index type based on the preset concurrency and target query information.
[0090] The preset concurrency level refers to the preset number of data items that the data query device can retrieve from the preset mapping information at one time through a hash index using a multi-concurrency mechanism. The preset concurrency level can be set in advance, and it can be adjusted according to the computing resources of the data query device.
[0091] Specifically, the data query device responds to the target filtering condition being a range filtering condition, and then determines the index type based on the preset concurrency level and the target query information. Optionally, the data query device can determine the index type based on the number of mapping information items in the target query information and the preset concurrency level.
[0092] This embodiment provides a data query method. In this embodiment, the target filtering condition is either a point-to-point filtering condition or a range filtering condition. When determining the corresponding index type based on the target filtering condition, in response to the target filtering condition being a point-to-point filtering condition, the index type is determined to be a Hash index; in response to the target filtering condition being a range filtering condition, the index type is determined based on a preset concurrency level and the target query information. In this embodiment, if the data query device determines that the target filtering condition is a point-to-point filtering condition, it determines the index to be a Hash index. For the target filtering condition being a range filtering condition, it further determines the index type based on the target query information and the preset concurrency level. Therefore, this embodiment can determine different index types based on different target filtering conditions, resulting in accurate index types. Furthermore, in this embodiment, determining the index based on the preset concurrency level makes the index type more consistent with actual conditions and more applicable.
[0093] Example 4
[0094] This embodiment is a further refinement of any of the above embodiments. Figure 4 This is a schematic flowchart of a data query method provided in Embodiment 4 of this application. This embodiment is an optional method for determining the index type based on a preset concurrency level and target query information, such as… Figure 4 As shown, the specific steps are as follows.
[0095] S401, determine the preset hash data that meets the range filtering conditions from the preset data information based on the target query information.
[0096] The preset hash data refers to preset data that meets the range filtering conditions. For example, assuming the target query information is "COL1≤12", the preset data includes "COL1=5", "COL1=12", "COL1=22", and "COL1=35". The preset data that meets the range filtering conditions are "COL1=5" and "COL1=12", and "COL1=5" and "COL1=12" are determined as the preset hash data.
[0097] S402, Calculate the number of preset hash data.
[0098] Specifically, the data query device calculates the number of preset hash data in S401 above. For example, according to the description in S401 above, the preset hash data are "COL1=5" and "COL1=12", and thus the number of preset hash data is calculated to be 2.
[0099] S403, in response to the preset concurrency number being greater than or equal to the preset number of hash data, determine the index type as a Hash index.
[0100] For example, assuming the preset concurrency is 3, the data query device determines that the preset concurrency (3) is greater than the preset number of hash data (2), and the data query device determines that the index type is a Hash index.
[0101] S404, in response to the preset concurrency number being less than the preset number of hash data, the index type is determined to be a B+ tree index.
[0102] For example, assuming the preset concurrency is 1, the data query device determines that the preset concurrency (1) is less than the preset number of hash data (2), and the data query device determines the B+ tree index.
[0103] It should be noted that, apart from point-to-point and range filtering conditions, other filtering conditions, such as aggregation and sorting, can be used to query the location information corresponding to the target query data using a B+ tree index.
[0104] This embodiment provides a data query method. When determining the index type based on a preset concurrency level and target query information, the method specifically includes: determining preset hash data that meets range filtering conditions from preset data information based on the target query information; calculating the number of preset hash data; determining the index type as a Hash index in response to a preset concurrency level greater than or equal to the number of preset hash data; and determining the index type as a B+ tree index in response to a preset concurrency level less than the number of preset hash data. In this embodiment, the data query device determines the preset hash data from the preset data information based on the target query information, then calculates the number of preset hash data, and further determines the index type based on the magnitude of the preset concurrency level and the number of preset hash data. Therefore, this embodiment determines the index type specifically based on the magnitude of the preset concurrency level and the number of preset hash data, and the determined index type is more applicable and better meets the performance requirements of the data query device.
[0105] Example 5
[0106] This embodiment is a further refinement of any of the above embodiments. Figure 5 This is a schematic flowchart of a data query method provided in Embodiment 5 of this application. This embodiment is an optional method for obtaining target location information by directly querying the location information corresponding to the target query data from preset mapping information based on target query information and a hash indexing strategy. Figure 5 As shown, the specific steps are as follows.
[0107] S501, if the target filtering condition is a point-to-point filtering condition, the corresponding preset mapping information in the target query information is directly obtained from the preset mapping information according to the Hash indexing strategy, and the location information corresponding to the target query data is queried according to the corresponding preset mapping information.
[0108] Specifically, the data query device identifies the target query information and scans and matches it in the preset mapping information according to the Hash indexing strategy. It determines that a certain preset data corresponds to the target query information and identifies the preset data and its location information as the preset mapping information corresponding to the target query information. This enables the direct acquisition of the preset mapping information corresponding to the target query information. At this time, the data query device will query the location information in the corresponding preset mapping information and identify the location information as the location information corresponding to the target query data.
[0109] For example, if the target query information is "COL1=12", the data query device determines that its target filtering condition is a point query filtering condition and determines that the index type is a Hash index. Therefore, the data query device scans the preset mapping information according to the Hash index strategy and matches the preset mapping information corresponding to the target query information. According to the example in S401 above, if the preset data includes "COL1=5", "COL1=12", "COL1=22" and "COL1=35", the data query device matches "COL1=12" in the preset data with the target query information, thereby determining the preset data "COL1=12" and its position information as the preset mapping information corresponding to the target query information.
[0110] S502, if the target filtering condition is a range filtering condition, and the preset concurrency is greater than or equal to the preset number of hash data, the preset mapping information corresponding to the preset hash data is directly obtained from the preset mapping information according to the Hash index strategy, and the location information corresponding to the target query data is queried from the corresponding preset mapping information.
[0111] Specifically, if the target filtering condition is a range filtering condition, and the preset concurrency is greater than or equal to the preset number of hash data, then the index type is determined to be a Hash index. The data query device directly obtains the preset mapping information corresponding to the preset hash data from the preset mapping information according to the Hash index strategy. Where there is at least one preset hash data, there is also at least one preset mapping information corresponding to the preset hash data, and the number corresponds.
[0112] Furthermore, the data query device queries the preset mapping information corresponding to the preset hash data one by one or in parallel, and determines the location information in the preset mapping information corresponding to the preset hash data as the location information corresponding to the target query data.
[0113] For example, if the target query information is "COL1≤12", then the preset hash data are "COL1=5" and "COL1=12", with a preset hash data count of 2. Assuming the preset concurrency is 3, the preset concurrency is greater than the preset hash data. The data query device determines the index type to be a Hash index, and then retrieves the preset mapping information corresponding to the preset hash data "COL1=5" and "COL1=12" from the preset mapping information. These are "COL1=5" and its position information, and "COL1=12" and its position information, respectively. It can be understood that there are two corresponding preset mapping information entries.
[0114] Furthermore, the data query device will perform sequential or parallel queries on the corresponding preset mapping information, determining the location information of the target query data as the preset mapping information "COL1=5" and its location information, and the location information of "COL1=12" and its location information. More specifically, assuming the location information of the preset mapping information "COL1=5" and its location information is A, the location information of "COL1=12" and its location information is B, and the target query data is the data in the file "COL1=5" and the data in the file "COL1=12", then location information A is determined as the location information corresponding to the target query data file "COL1=5", and location information B is determined as the location information corresponding to the target query data file "COL1=12".
[0115] Parallel query refers to the data query device simultaneously querying preset mapping information.
[0116] It should be noted that when using range filtering conditions, the target query information will reflect at least one target query data. Therefore, this step requires determining the location information corresponding to at least one target query data.
[0117] S503, determine the location information corresponding to the target query data as the target location information.
[0118] Specifically, according to the descriptions in S501 and S502 above, the location information corresponding to the target query data is determined as the target location information.
[0119] For example, according to S502, location information A is determined as the target location information of the target query data file "COL1=5", and location information B is determined as the target location information of the target query data file "COL1=12". Therefore, in S502, two target location information will be determined.
[0120] It should be noted that hash indexes respond faster than B+ tree indexes, resulting in higher query efficiency. Therefore, the index type (hash index or B+ tree index) can be controlled by adjusting the preset concurrency level.
[0121] This embodiment provides a data query method. When obtaining target location information by directly querying the location information corresponding to target query data from preset mapping information based on target query information and a hash indexing strategy, the method specifically includes: if the target filtering condition is a point-to-point filtering condition, obtaining the corresponding preset mapping information from the preset mapping information according to the hash indexing strategy, and querying the location information corresponding to the target query data based on the corresponding preset mapping information; if the target filtering condition is a range filtering condition, and the preset concurrency is greater than or equal to the preset number of hash data, obtaining the preset mapping information corresponding to the preset hash data from the preset mapping information according to the hash indexing strategy, and querying the location information corresponding to the target query data from the corresponding preset mapping information; and determining the location information corresponding to the target query data as the target location information. In this embodiment, if the filtering condition is a point-to-point query, the data query device directly obtains the preset mapping information corresponding to the target query information from the preset mapping information according to the Hash index strategy. Since the preset mapping information contains preset data and its location information, the data query device can accurately query the location information corresponding to the target query data based on the corresponding preset mapping information. If the filtering condition is a range query, and the preset concurrency is greater than or equal to the number of preset hash data, the data query device obtains the preset mapping information corresponding to the preset hash data from the preset mapping information according to the Hash index strategy, and then queries the location information corresponding to the target query data from the corresponding preset mapping information. Since there can be at least one preset hash data in this scheme, the Hash index can be used to query the location information of the target query data within a small range. Therefore, this embodiment can not only use the Hash index to implement point-to-point queries, but also to implement small-range queries. For small-range queries, the Hash index can save query time and improve query efficiency. For point-to-point queries, the location information corresponding to the target query data can be directly obtained, accelerating the response and also having high efficiency.
[0122] Example 6
[0123] This embodiment is a further refinement of any of the above embodiments. Figure 6 This is a schematic flowchart of a data query method provided in Embodiment Six of this application. This embodiment is an optional method for querying the location information corresponding to the target query data based on target query information, preset mapping information, and a B+ tree indexing strategy. Figure 6 As shown, the specific steps are as follows.
[0124] S601, Determine the target tree field from the target query information.
[0125] The target tree field refers to the creation field used to generate the tree structure.
[0126] For example, suppose the target query is "COL1≤12", where COL1 is the target tree field.
[0127] S602, Generate the target tree structure corresponding to the target tree field based on the target tree field, preset mapping information and B+ tree indexing strategy.
[0128] The preset mapping information can include preset data for various target tree fields. As shown in Table 1, Table 1 displays three target tree fields and their preset data, namely COL1, COL2, and COL3. Taking the target tree field as COL1 as an example, the preset data are "COL1=22", "COL1=35", "COL1=12", "COL1=45", "COL1=5", and "COL1=32". It should be noted that each preset data has its corresponding position information, which will not be elaborated in Table 1.
[0129] Table 1: Preset data.
[0130] COL1 COL2 COL3 22 3 65 35 5 766 12 16 4 45 543 4 5 43 3 32 44 6
[0131] Specifically, the data query device determines at least one preset data containing the target tree field from the preset mapping information, and then generates the target tree structure corresponding to the target tree field according to the B+ tree indexing strategy. It should be noted that the target tree structure contains at least one of the aforementioned preset data and its position information.
[0132] For example, assuming the target tree field is COL1, the data query device will generate the target tree structure corresponding to COL1 according to the preset mapping information corresponding to COL1 and the B+ tree indexing strategy. The preset mapping information corresponding to COL1 includes preset data corresponding to COL1 and its position information, namely "COL1=22" and its position information, "COL1=35" and its position information, "COL1=12" and its position information, "COL1=45" and its position information, "COL1=5" and its position information, and "COL1=32" and its position information.
[0133] Figure 7 This is a schematic diagram of a target tree structure provided in Embodiment Six of this application. Figure 7 The target tree structure generated based on Table 1 is as follows: Figure 7As shown, the target tree structure has three levels from top to bottom. The leaf nodes in the third level are the last leaf nodes, which can include preset data and their position information. The leaf nodes in the first and second levels only contain preset data. For example, the position information corresponding to "COL1=5" is 0x77, and the position information corresponding to "COL1=12" is 0x78. The first level is the first page, the second level includes the second and third pages, the second page branches downwards to form the fourth and fifth pages of the third level, and the third page branches downwards to form the sixth page. Each page includes at least one leaf node. For example, the third page includes one leaf node, and the fifth page includes two leaf nodes. It should be noted that the position information in this application does not represent actual real position information; it is only used for illustration, for example, 0x77 and 0x78.
[0134] S603, retrieve the location information corresponding to the target query data from the target tree structure based on the hierarchy of the target tree structure.
[0135] Specifically, the data query device performs a top-down and left-to-right query within the target tree structure according to its hierarchy, thereby retrieving the location information corresponding to the target query data.
[0136] For example, targeting Figure 7 Given the target tree structure, assuming the target query information is "COL1≤12", the target query data is the data corresponding to the file "COL1=5" and the data corresponding to the file "COL1=12". The preset hash data is "COL1=5" and "COL1=12", and the preset concurrency is 1. Therefore, it is determined that the preset concurrency is less than the preset number of hash data, so the index type is B+ tree index.
[0137] Furthermore, the data query device from Figure 7 In the target tree structure, the leaf nodes corresponding to "COL1=5" and "COL1=12" are retrieved, and then the location information corresponding to the preset data is retrieved from the leaf nodes. Finally, the corresponding location information is determined as the location information corresponding to the target query data.
[0138] This embodiment provides a data query method. When querying the location information corresponding to target query data based on target query information, preset mapping information, and a B+ tree indexing strategy, the method specifically includes: determining a target tree field from the target query information; generating a target tree structure corresponding to the target tree field based on the target tree field, preset mapping information, and B+ tree indexing strategy; and querying the location information corresponding to the target query data from the target tree structure based on the hierarchy of the target tree structure. In this embodiment, for the B+ tree index, the data query device determines the target tree field from the target query information, and then generates the target tree structure corresponding to the target tree based on the target tree field and preset mapping information according to the B+ tree indexing strategy. The data query device then queries the location information corresponding to the target query data in an orderly manner from the target tree structure according to the hierarchy of the target tree structure. Because the query is performed according to the hierarchy of the target tree structure, it has a certain regularity, thus reducing the number of scans, accelerating the response, and improving query efficiency.
[0139] In one approach, this embodiment is an optional method of retrieving the location information corresponding to the target query data from the target tree structure based on the hierarchy of the target tree structure, as detailed below.
[0140] Based on the hierarchical relationship of the target tree structure, determine the last leaf node where the target query information is located in the order from top to bottom and from left to right; determine the location information corresponding to the target query data from the last leaf node.
[0141] Specifically, the data query device determines the number of levels in the target tree structure based on its hierarchical relationship. Then, it identifies the leaf nodes corresponding to the target query information in each level, proceeding from top to bottom and left to right. From each leaf node, the query continues downwards in a top-down order. Within the same level, leaf nodes corresponding to the target query information are identified from left to right. In the last level, the corresponding leaf node is determined as the last leaf node containing the target query information. This last leaf node contains preset data and its location information. The preset data in the last leaf node corresponds to the target query information, and the location information in the last leaf node is used to determine the location information corresponding to the target query data.
[0142] For example, the target query information is "COL1≤12", that is, the target query information is "COL1=12" and "COL1=5". According to... Figure 7The target tree structure contains three levels: the first level, the second level, and the third level. Each level's leaf nodes contain preset data. The leaf nodes in the third level are the last leaf nodes, containing the preset data and its position information. In this example, taking "COL1=12" as an example, the data query device determines the size of "COL1=12" versus "COL1=5" and "COL1=35" in the first level. Since 12 is between 5 and 35, the query proceeds from the first level leaf nodes downwards to the second level, following a left-to-right order. First, it determines the size of the preset data "COL1=5" and "COL1=22" versus "COL1=12" in the second page of the second level. Since 12 is between 5 and 22, the query proceeds from the second page of the second level downwards to the third level, which includes the fourth and fifth pages. The leaf nodes on the fourth page include “COL1=5” and “COL1=12”, and the leaf nodes on the fifth page include “COL1=22” and “COL1=32”. The preset data included in the leaf nodes on the fourth page are determined from left to right to see if they correspond to the target query information. The leaf node on the fourth page with the second preset data “COL1=12” is found to be consistent with “COL1=12” in the target query information. Therefore, the second leaf node on the fourth page of the third layer is determined to be the last leaf node where the target query information is located, and the position information included in the last leaf node is determined to be the position information corresponding to the target query data.
[0143] This method provides a data query approach. When retrieving the location information corresponding to target query data from the target tree structure based on its hierarchy, the specific steps include: determining the last leaf node containing the target query information according to the hierarchical relationship of the target tree structure, in a top-to-bottom and left-to-right order; and determining the location information corresponding to the target query data from that last leaf node. In this embodiment, the data query device determines the last leaf node containing the target query information according to the hierarchical relationship of the target tree structure, in a top-to-bottom and left-to-right order, and then determines the location information corresponding to the target query data based on that last leaf node. Because the last leaf node can be determined according to the hierarchical relationship of the target tree structure, this embodiment can accurately determine the last leaf node corresponding to the target query information, and thus accurately determine the location information corresponding to the target query data. Furthermore, determining the last leaf node in a top-to-bottom and left-to-right order also reduces the number of scans, accelerates the response, and improves query efficiency.
[0144] Example 7
[0145] This embodiment is a further refinement of any of the above embodiments. Figure 8 This is a schematic flowchart of a data query method provided in Embodiment Seven of this application. Figure 8 As shown, the specific steps are as follows.
[0146] S801, Receives a data modification command sent by the control device; the target data modification command includes target query information and target modification requirements; the target modification requirements include target modification data.
[0147] The data modification command is an instruction to modify data. It includes the target query information and the target modification requirements. The target query information reflects the target query data.
[0148] The target modification requirement refers to the content that needs to be modified, including changing the target query data or a portion of the target query data to the target modified data. For example, suppose the target query data includes three data points: the first data, the second data, and the third data. The second data is modified to become the fourth data, where the fourth data is the target modified data.
[0149] S802, determine the corresponding index type based on the target query information, and query the target location information of the target query data.
[0150] Specifically, the data query device determines the index type according to the method described in the above embodiments and retrieves the target location information of the target query data.
[0151] S803 locates the target and queries data on the disk based on the target location information.
[0152] Among them, a disk refers to a space specifically used for storage, in which massive amounts of data are stored.
[0153] Specifically, the data query device locates the target query data on the disk based on the target location information. For example, the target query data is a file with "COL=12", and the target location information for "COL1=12" is 0x78. Therefore, the data query device locates the file with "COL1=12" based on 0x78.
[0154] S804 Modify the target query data according to the target modification requirements to obtain the target modified data.
[0155] Specifically, the target query data includes at least one piece of data, and the target modification requirement may include modifying at least one piece of data, as well as the target modified data corresponding to the modification of at least one piece of data.
[0156] As described in S801 above, assuming the target query data includes three data points: a first data point, a second data point, and a third data point, the second data point is modified to become a fourth data point, where the fourth data point is the target modified data. For example, if the second data point is AAA and the fourth data point is BBB, then AAA is modified to BBB, where BBB is the target modified data. Thus, the data query device modifies the data according to the target modification requirement to obtain the target modified data.
[0157] This embodiment provides a data query method, further comprising: receiving a data modification command sent by a control device; the target data modification command including target query information and target modification requirements; the target modification requirements including target modification data; determining the corresponding index type based on the target query information, and querying the target location information of the target query data; locating the target query data on the disk based on the target location information; and modifying the target query data according to the target modification requirements to obtain the target modification data. In this embodiment, the data query device determines the target query information and the target modification command based on the data modification command, then determines the index type based on the target query information, and queries the target location information of the target query data, thereby locating the target query data on the disk and modifying it according to the target modification requirements to obtain the target modification data. Therefore, this embodiment can realize the requirement of querying first and then modifying, accurately locate the target query data, and make corresponding modifications to it, thus this embodiment is applicable.
[0158] Example 8
[0159] This embodiment is a further refinement of any of the above embodiments. Figure 9 This is a schematic flowchart of a data query method provided in Embodiment 8 of this application. This embodiment represents an optional approach after obtaining target location information, such as... Figure 9 As shown, the specific steps are as follows.
[0160] S901 locates the target and queries data on the disk based on the target location information.
[0161] The implementation method for this step is the same as that for S803, and will not be repeated here.
[0162] S902, retrieve the target query data from the disk.
[0163] Specifically, the data query device retrieves the target query data from the disk. Assuming the target query data is a file named "COL1=12", the data query device will retrieve the file named "COL1=12".
[0164] S903, Generate a data query response; the data query response includes the target query data.
[0165] The data query response is a feedback mechanism for a data query. S904 displays the data query response.
[0166] Specifically, the data query device displays the data query response, thereby displaying the target query data.
[0167] This embodiment provides a data query method, which, after obtaining target location information, further includes: locating target query data on a disk based on the target location information; retrieving the target query data from the disk; generating a data query response; the data query response including the target query data; and displaying the data query response. In this embodiment, the data query device first locates the target query data on the disk, then retrieves the target query data and generates a data query response. The data query device then displays the data query response. Because the data query response includes the target query data, this embodiment can provide timely feedback on the query results.
[0168] Example 9
[0169] Figure 10 This is a schematic diagram of a data query interaction provided in Embodiment Nine of this application. The execution entity of this embodiment is a data query system, which includes a control device and an electronic device. The electronic device is equipped with a data query apparatus, as shown in the diagram. Figure 10 As shown, the specific steps are as follows.
[0170] S1001, The control device generates a data query command, which includes the target query information.
[0171] S1002, the control device sends a data query command to the electronic device.
[0172] S1003 The electronic device determines the target filtering condition based on the target filtering field in the target query information. If the target filtering condition is a point-to-point filtering condition, then execute 1004; if the target filtering condition is a range filtering condition, then execute S1005.
[0173] If the electronic device determines that the index type is a Hash index, then execute S1009.
[0174] S1005, the electronic device determines the preset hash data based on the target query information and the preset data information.
[0175] The S1006 electronic device calculates the number of preset hash data.
[0176] S1007 The electronic device determines whether the preset concurrent number is greater than or equal to the preset number of hash data. If yes, then execute S1004; if no, then execute S1008.
[0177] S1008, the electronic device determines that the index type is a B+ tree index and executes S1010.
[0178] S1009, the electronic device directly queries the location information corresponding to the target query data from the preset mapping information based on the target query information and the Hash index strategy, and continues to execute S1011.
[0179] S1010, the electronic device queries the location information corresponding to the target query data based on the target query information, the preset mapping information and the B+ tree index strategy, and continues to execute S1011.
[0180] S1011, the electronic device determines the location information corresponding to the target query data as the target location information.
[0181] S1012, the electronic device locates the target and queries the data from the disk based on the target location information.
[0182] S1013, The electronic device displays the target query data.
[0183] Example 10
[0184] The following is an embodiment of the device of this application. Figure 11 This is a schematic diagram of a data query device provided in Embodiment 10 of this application. The data query device 110 includes the following modules, such as... Figure 11 As shown.
[0185] The receiving module 1101 is used to receive a data query command sent by the control device; the data query command includes target query information; the target query information reflects the target query data;
[0186] The determination module 1102 is used to determine the corresponding index type based on the target query information; the index type is either a hash index or a B+ tree index.
[0187] The query module 1103 is used to respond to an index type of Hash index by directly querying the location information corresponding to the target query data from the preset mapping information according to the target query information and the Hash index strategy to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information.
[0188] The query module 1103 is used to respond to a B+ tree index by querying the location information corresponding to the target query data based on the target query information, preset mapping information, and B+ tree index strategy to obtain the target location information.
[0189] In one approach, the determining module 1102, when determining the corresponding index type based on the target query information, is used for:
[0190] Determine the target filtering conditions based on the target filtering fields included in the target query information; determine the corresponding index type based on the target filtering conditions.
[0191] In one approach, the target filtering condition is either a point-to-point filtering condition or a range filtering condition; the determination module 1102, when determining the corresponding index type based on the target filtering condition, is used for:
[0192] If the target filter condition is a point query filter condition, the index type is determined to be a hash index; if the target filter condition is a range filter condition, the index type is determined based on the preset concurrency and target query information.
[0193] In one approach, the determining module 1102, when determining the index type based on a preset concurrency level and target query information, is used for:
[0194] Based on the target query information, determine the preset hash data that meets the range filtering conditions from the preset data information; calculate the number of preset hash data; in response to the preset concurrency being greater than or equal to the preset number of hash data, determine the index type as a Hash index; in response to the preset concurrency being less than the preset number of hash data, determine the index type as a B+ tree index.
[0195] In one approach, the query module 1103, when obtaining the target location information by directly querying the location information corresponding to the target query data from the preset mapping information based on the target query information and the Hash indexing strategy, is used for:
[0196] If the target filtering condition is a point-to-point filtering condition, the corresponding preset mapping information in the target query information is directly obtained from the preset mapping information according to the Hash index strategy, and the location information corresponding to the target query data is queried according to the corresponding preset mapping information; if the target filtering condition is a range filtering condition, and the preset concurrency is greater than or equal to the preset number of hash data, the preset mapping information corresponding to the preset hash data is directly obtained from the preset mapping information according to the Hash index strategy, and the location information corresponding to the target query data is queried from the corresponding preset mapping information; the location information corresponding to the target query data is determined as the target location information.
[0197] In one embodiment, the query module 1103 is used to query the location information corresponding to the target query data based on the target query information, preset mapping information, and B+ tree indexing strategy, including:
[0198] Determine the target tree field from the target query information; generate the target tree structure corresponding to the target tree field based on the B+ tree index strategy, the preset mapping information, and the B+ tree index strategy; and retrieve the location information corresponding to the target query data from the target tree structure based on the hierarchy of the target tree structure.
[0199] In one approach, the query module 1103, when retrieving the location information corresponding to the target query data from the target tree structure based on the hierarchy of the target tree structure, is used for:
[0200] Based on the hierarchical relationship of the target tree structure, determine the last leaf node where the target query information is located in the order from top to bottom and from left to right; determine the location information corresponding to the target query data from the last leaf node.
[0201] In one embodiment, the device further includes: a positioning module and a modification module;
[0202] The receiving module 1101 is further configured to receive a data modification command sent by the control device; the target data modification command includes target query information and target modification requirements; the target modification requirements include target modification data; the determining module 1102 is further configured to determine the corresponding index type based on the target query information; the query module 1103 is further configured to query the target location information of the target query data; the positioning module is configured to locate the target query data on the disk based on the target location information; and the modification module is configured to modify the target query data according to the target modification requirements to obtain the target modification data.
[0203] In one embodiment, after obtaining the target location information, the device further includes: an acquisition module, a generation module, and a display module; wherein the positioning module is further configured to locate the target query data in the disk based on the target location information; the acquisition module is configured to acquire the target query data in the disk; the generation module is configured to generate a data query response; the data query response includes the target query data; and the display module is configured to display the data query response.
[0204] Example 11
[0205] Figure 12 This is a schematic diagram of the structure of an electronic device provided in Embodiment Eleven of this application. Figure 12 As shown, the electronic device 120 may include: a processor 1201, and a memory 1202 and a receiver 1203 communicatively connected to the processor 1201. The memory 1202 stores computer-executable instructions; the receiver 1203 is used to receive data; the processor 1201 executes the computer-executable instructions stored in the memory 1202 to implement any one of the method embodiments in Embodiments 1 to 9 above. The specific implementation methods and technical effects are similar, and will not be repeated here.
[0206] In this embodiment, the memory 1202 and the processor 1201 are connected via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0207] Example 12
[0208] This application provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, the computer-executable instructions are used to implement any one of the method embodiments 1 to 9 described above. The specific implementation methods and technical effects are similar and will not be repeated here.
[0209] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0210] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A data query method, characterized in that, The method includes: The system receives a data query command sent by a control device; the data query command includes target query information; the target query information reflects the target query data. The corresponding index type is determined based on the target query information; the index type is either a hash index or a B+ tree index. In response to the index type being a Hash index, the location information corresponding to the target query data is directly queried from the preset mapping information according to the target query information and the Hash index strategy to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information. In response to the index type being a B+ tree index, the location information corresponding to the target query data is queried according to the target query information, the preset mapping information, and the B+ tree index strategy to obtain the target location information; Determining the corresponding index type based on the target query information includes: The target filtering conditions are determined based on the target filtering fields included in the target query information. Determine the corresponding index type based on the target filtering conditions; The target filtering condition is either a point-based filtering condition or a range filtering condition; The step of determining the corresponding index type based on the target filtering conditions includes: In response to the target filtering condition being a point lookup filtering condition, the index type is determined to be a Hash index; In response to the target filtering condition being a range filtering condition, the index type is determined based on the preset concurrency level and the target query information; The step of determining the index type based on the preset concurrency level and the target query information includes: Based on the target query information, determine the preset hash data that meets the range filtering conditions from the preset data information; Calculate the number of the preset hash data; In response to the preset concurrency number being greater than or equal to the preset number of hash data, the index type is determined to be a Hash index; In response to the preset concurrency number being less than the preset number of hash data, the index type is determined to be a B+ tree index.
2. The method according to claim 1, characterized in that, The step of directly querying the location information corresponding to the target query data from the preset mapping information based on the target query information and the Hash indexing strategy to obtain the target location information includes: If the target filtering condition is a point query filtering condition, the corresponding preset mapping information in the target query information is directly obtained from the preset mapping information according to the Hash indexing strategy, and the location information corresponding to the target query data is queried according to the corresponding preset mapping information. If the target filtering condition is a range filtering condition, and the preset concurrency number is greater than or equal to the number of preset hash data, the preset mapping information corresponding to the preset hash data is directly obtained from the preset mapping information according to the Hash index strategy, and the location information corresponding to the target query data is queried from the corresponding preset mapping information. The location information corresponding to the target query data is determined as the target location information.
3. The method according to claim 1, characterized in that, The step of querying the location information corresponding to the target query data based on the target query information, the preset mapping information, and the B+ tree indexing strategy includes: Determine the target tree field from the target query information; The target tree structure corresponding to the target tree field is generated based on the target tree field, the preset mapping information, and the B+ tree indexing strategy; Based on the hierarchy of the target tree structure, the location information corresponding to the target query data is retrieved from the target tree structure.
4. The method according to claim 3, characterized in that, The step of retrieving the location information corresponding to the target query data from the target tree structure based on the hierarchy of the target tree structure includes: Based on the hierarchical relationship of the target tree structure, the last leaf node containing the target query information is determined in order from top to bottom and from left to right; The location information corresponding to the target query data is determined from the last leaf node.
5. The method according to claim 1, characterized in that, The method further includes: Receives a data modification command sent by a control device; the data modification command includes target query information and target modification requirements; the target modification requirements include target modification data; The corresponding index type is determined based on the target query information, and the target location information of the target query data is queried. The target query data is located on the disk based on the target location information; The target query data is modified according to the target modification requirements to obtain the target modified data.
6. The method according to any one of claims 1-5, characterized in that, After obtaining the target location information, the process also includes: The target query data is located on the disk based on the target location information; Retrieve the target query data from the disk; Generate a data query response; the data query response includes the target query data; Display the data query response.
7. A data query device, characterized in that, The device includes: A receiving module is used to receive data query commands sent by a control device; the data query command includes target query information; the target query information reflects the target query data; The determination module is used to determine the corresponding index type based on the target query information; the index type is either a hash index or a B+ tree index. The query module is used to respond to the index type being a Hash index, and to directly query the location information corresponding to the target query data from the preset mapping information according to the target query information and the Hash index strategy, so as to obtain the target location information; the preset mapping information includes preset data information and its corresponding location information. The query module is used to respond to the fact that the index type is B+ tree index, and to query the location information corresponding to the target query data according to the target query information, the preset mapping information and the B+ tree index strategy to obtain the target location information; The determining module, when determining the corresponding index type based on the target query information, is used for: The target filtering conditions are determined based on the target filtering fields included in the target query information. Determine the corresponding index type based on the target filtering conditions; The target filtering condition is a point-to-point filtering condition or a range filtering condition; the determining module, when determining the corresponding index type based on the target filtering condition, is used for: In response to the target filtering condition being a point lookup filtering condition, the index type is determined to be a Hash index; In response to the target filtering condition being a range filtering condition, the index type is determined based on the preset concurrency level and the target query information; The determining module, when determining the index type based on the preset concurrency level and the target query information, is used for: Based on the target query information, determine the preset hash data that meets the range filtering conditions from the preset data information; Calculate the number of the preset hash data; In response to the preset concurrency number being greater than or equal to the preset number of hash data, the index type is determined to be a Hash index; In response to the preset concurrency number being less than the preset number of hash data, the index type is determined to be a B+ tree index.
8. An electronic device, comprising: A processor, and a memory and a receiver communicatively connected to the processor; The memory stores computer-executed instructions; The receiver is used to receive data; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Data query method, data query device, electronic equipment and storage medium
CN113051268A