Data searching method and device, electronic equipment and storage medium
By receiving input key values and querying associated key values to find target data, the problem of wasted storage space for key-value pairs in existing technologies is solved, and efficient data storage is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING HONGTENG INTELLIGENT TECH CO LTD
- Filing Date
- 2024-11-06
- Publication Date
- 2026-05-08
AI Technical Summary
Existing key-value pair storage methods require a lot of storage space because each key-value pair corresponds to a single piece of data, resulting in low storage efficiency.
By receiving input key values, it determines whether they contain the target key value. If not, it queries related key values and uses them to find the target data, thus avoiding the need to store each key value and its corresponding target data one by one.
While ensuring the target data is found, the database storage space requirements are reduced, and storage efficiency is improved.
Smart Images

Figure CN121996692A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a data retrieval method, apparatus, electronic device, and storage medium in the field of computers. Background Technology
[0002] Existing key-value pairs (KV) typically have one data item per key. During storage, these pairs need to be stored one-to-one so that during a query, the corresponding value can be found using the input key. However, this one-to-one storage method consumes a significant amount of storage space. Summary of the Invention
[0003] This application provides a data retrieval method, apparatus, electronic device, and storage medium, which can reduce the storage space of a database.
[0004] Firstly, a data retrieval method is provided, comprising: receiving a data request instruction sent by a user and obtaining an input key value from the data request instruction; if the input key value does not contain a first key value, determining that the key value in the input key value is a second key value, wherein the first key value is a key value directly corresponding to the target data; querying the target associated key value based on the second key value; if the target associated key value contains the first key value, searching for the target data corresponding to the first key value in the database and returning the target data to the user.
[0005] Secondly, an electronic device control apparatus is provided, the apparatus comprising:
[0006] The receiving unit is used to receive data request instructions sent by the user and obtain the input key value in the data request instructions;
[0007] The acquisition unit is used to determine that if the input key value does not contain the first key value, the key value in the input key value is the second key value, wherein the first key value is the key value directly corresponding to the target data;
[0008] The query unit is used to query the target associated key value based on the second key value;
[0009] The lookup unit is used to search for the target data corresponding to the first key value in the database if the target associated key value contains the first key value, and then return the target data to the user.
[0010] Thirdly, an electronic device is provided, comprising: a memory for storing executable program code; and a processor for calling and running the executable program code from the memory, causing the electronic device to perform the method described in the first aspect or any possible implementation thereof.
[0011] Fourthly, a computer-readable storage medium is provided that stores computer program code, which, when executed on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0012] In this embodiment, when the input key value in the request command sent by the user does not contain the first key value, it is determined that the key value contained in the input key value is the second key value. The target associated key value is queried based on the second key value, and then the target data queried by the data request is obtained through the first key value contained in the target associated key value. Since the target data queried by the data request can be found through the target associated key value queried by the input key value that does not contain the first key value, it is not necessary to store each key value and its corresponding target data in the database one by one. This achieves the goal of ensuring that the target data is found while reducing the storage space of the database. Attached Figure Description
[0013] Figure 1 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application;
[0014] Figure 2 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application;
[0015] Figure 3 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application;
[0016] Figure 4 This is a schematic diagram of a data search method provided in an embodiment of this application;
[0017] Figure 5 This is a schematic diagram of a data search method provided in an embodiment of this application;
[0018] Figure 6 This is a schematic diagram of the structure of a data search device provided in an embodiment of this application;
[0019] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0021] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0022] The following will combine Figures 1-7 The data search method provided in the embodiments of this application will be described in detail.
[0023] Please see Figure 1 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application. Figure 1 As shown, the method in this application embodiment may include the following steps S101-S103.
[0024] S101, receive the data request instruction sent by the user, and obtain the input key value in the data request instruction;
[0025] In one embodiment, a data request instruction can be a command or instruction to request data from a server or data source. Users can trigger data request instructions in web applications, the Internet of Things (IoT), or database operations to obtain the data they need.
[0026] Specifically, after receiving a data request instruction from a user, the system parses the instruction according to its format to obtain the input key-value pairs contained within it. These input key-value pairs can be based on the key-value pairs corresponding to the data required by the user.
[0027] Optionally, to improve the security of data retrieval, in this embodiment, the data request instruction can be encrypted before sending by pre-setting an encryption protocol. Correspondingly, after receiving the data request instruction sent by the user, the electronic device decrypts it to obtain the input key value contained in the data request instruction.
[0028] S102, if the input key value does not contain the first key value, then determine that the key value in the input key value is the second key value, wherein the first key value is the key value that directly corresponds to the target data;
[0029] In one embodiment, the first key value is a key value that allows direct reading of the target data. It is understood that the input key value can be a combination of multiple key values or a single key value. Therefore, in this embodiment, after obtaining the input key value in the data request instruction, it is determined whether the input key value contains the first key value by querying each key value one by one.
[0030] For example, the first key value can be "HashC", and the input key value in the data request instruction can be "HashA+HashB", or the input key value can also be "HashB". When the input key value can be "HashA+HashB", the electronic device compares the key values "HashA" and "HashB" contained in the input key value with the first key value "HashC" one by one, determines that there is no key value in the input key value that matches the first key value, determines that the input key value does not contain the first key value, and determines that the key values (HashA, HashB) in the input key value are the second key values.
[0031] S103, query the target associated key value based on the second key value;
[0032] Optionally, after determining that the input key value does not contain the first key value, the target associated key value can be queried from the pre-stored associated data based on the second key value. In this embodiment, the associated data stores the associated key values formed between the first key value and other key values. Therefore, after obtaining the second key value from the input key value, the target associated key value can be found in the associated data based on the second key value.
[0033] Optionally, in this embodiment, the associated data may include multiple associated key values. For example, the associated data may include associated key values such as "HashA+HashC" and "HashB+HashC". Therefore, if the input key value "HashA+HashB" in the data request instruction does not contain the first key value "HashC", then the key values "HashA" and "HashB" contained in the input key value are determined to be the second key values. Optionally, the second key value can be compared with the key values contained in the associated key values in the associated data to determine whether there is a key value in the associated key values that matches the second key value. If so, the associated key value containing that key value is determined to be the target associated key value retrieved based on the second key value.
[0034] For example, in this embodiment, the second key value "HashA" is compared with the associated key value in the associated data, and it is determined that the key value of the associated key value "HashA+HashC" includes "HashA" and "HashC". That is, there is a key value in the associated key value "HashA+HashC" that is consistent with the second key value "HashA". Then, the associated key value "HashA+HashC" is determined to be the target associated key value.
[0035] S104. If the target associated key value contains the first key value, then search for the target data corresponding to the first key value in the database and return the target data to the user.
[0036] In one embodiment, if a first key value is found in the target associated key value, the target data corresponding to the first key value is found in the database based on the first key value, and the target data is sent to the user.
[0037] Optionally, in this embodiment of the application, when sending the target data to the user, the target data can also be encrypted using a pre-set encryption protocol. After the user receives the target data, the target data can be decrypted according to the pre-set encryption protocol to obtain the target data, thus ensuring the security of the transmitted target data.
[0038] In this embodiment, when the input key value in the request command sent by the user does not contain the first key value, it is determined that the key value contained in the input key value is the second key value. The target associated key value is queried based on the second key value, and then the target data queried by the data request is obtained through the first key value contained in the target associated key value. Since the target data queried by the data request can be found through the target associated key value queried by the input key value that does not contain the first key value, it is not necessary to store each key value and its corresponding target data in the database one by one. This achieves the goal of ensuring that the target data is found while reducing the storage space of the database.
[0039] Please see Figure 2 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application. Figure 2 As shown, the method in this application embodiment may include the following steps S201-S206.
[0040] S201, Receive the data request instruction sent by the user and obtain the input key value in the data request instruction;
[0041] S202, if the input key value does not contain the first key value, then determine that the key value in the input key value is the second key value, wherein the first key value is the key value that directly corresponds to the target data;
[0042] Specifically, in the embodiments of this application, when it is determined that the input key value of the data request instruction sent by the user does not contain the first key value, the specific steps for determining the second key value of the input key value are described in the description of steps S101-S102 in the embodiments of the above specification, and will not be repeated here.
[0043] S203, determine any key value in the second key value as the third key value, and determine whether there is an associated key value containing the third key value in the associated data;
[0044] In one embodiment, if multiple second key values exist among the input key values that do not contain a first key value, then any one of the second key values is determined to be a third key value, thereby determining whether there is an associated key value containing the third key value in the associated data. Optionally, when determining any one of the multiple second key values to be a third key value, the third key value can be determined according to the order in which the second key values are read. For example, first, the second key value that is ranked first is determined to be the third key value, and then it is determined whether there is an associated key value containing the third key value in the associated data. The step of determining whether there is an associated key value containing the third key value in the associated data is similar to the step of finding the target associated key value based on the second key value in the above embodiment, and will not be described again here.
[0045] S204, if it exists, then determine that the associated key value is the target associated key value;
[0046] In one embodiment, when it is determined that there is an associated key value containing a third key value in the associated data, the associated key value is determined to be the target associated key value.
[0047] S205, if it does not exist, the third key value is filtered out from the second key value, and the process returns to the step of determining that any key value in the second key value is the third key value and determining whether there is an associated key value containing the third key value in the associated data, until the preset condition is met; the preset condition is that there is an associated key value containing the third key value in the associated data, or the number of key values in the second key value is 0;
[0048] In one embodiment, if it is determined that there is no key value in the associated key value of the associated data that matches the third key value, the third key value is filtered out from the second key value, and the process returns to the step of determining that any key value in the second key value is the third key value and determining whether there is an associated key value containing the third key value in the associated data, until it is determined that there is an associated key value containing the third key value in the associated data, or the number of key values in the second key value is 0. If it is determined that no target data corresponding to the input key value can be found, the message "No target data found" is returned to the user.
[0049] For example, the associated key value of the associated data includes "HashB+HashC". If the input key value in the received data request instruction is "HashA+HashB", the second key value of the input key value is determined to include "HashA" and "HashB", which contain two values. First, "HashA" is determined as the third key value. If no associated key value containing "HashA" is found in the associated key values of the associated data, then the third key value "HashA" is filtered out from the second key value. "HashB" is determined as the third key value. Then, if a key value consistent with "HashB" is found in the key values contained in the associated key values of the associated data, then the associated key value containing "HashB" is determined as the target associated key value.
[0050] S206. If the target associated key value contains the first key value, then search for the target data corresponding to the first key value in the database and return the target data to the user.
[0051] In one embodiment, if it is determined that the target associated key value contains a first key value, then the target data corresponding to the first key value is searched in the database and sent to the user.
[0052] Furthermore, in this embodiment of the application, after querying the target associated key value of the second key value in the associated data, if it is determined that the target associated key value does not contain the first key value, then the key value other than the third key value in the target associated key value is determined to be the fourth key value, the associated key value containing the fourth key value is determined in the associated data, and the associated key value containing the fourth key value is updated to the target associated key value.
[0053] For example, in the embodiments of this application, the associated key values in the associated data include: "HashA+HashC" and "HashB+HashA". It can be understood that in the embodiments of this application, since the length of the key value "HashC" is greater than the length of the key value "HashA", the key value "HashA" can be used instead of the key value "HashC" in the associated key values of the associated data, which can further reduce the storage space. If the length of the key value "HashC" is much greater than the length of the key value "HashA", and "HashC" is combined with multiple other key values to form associated key values, by using the key value "HashA" instead of the key value "HashC" in the associated key values, the large key value "HashC" can be avoided from occupying a large amount of storage space.
[0054] In cases where a shorter key value is used to replace a longer first key value in the associated key value of the associated data, if the first key value "HashC" is not present in the target associated key value "HashB+HashA" determined by the third key value "HashB", then the key value other than the third key value in the target associated key value can be determined to be the fourth key value, i.e., the key value "HashA". Then, the associated key value "HashA+HashC" containing the key value "HashA" can be determined in the associated data and updated to the target associated key value.
[0055] Furthermore, in this embodiment, if the input key value contains a first key value, and it is determined that the target data requested by the data request instruction can be obtained directly through the input key value, then the target data corresponding to the first key value is searched in the database, and the target data is returned to the user. For example, if the input key value in the received data request instruction is “HashA+HashC”, and it is determined that the first key value “HashC” exists in the input key value, then the target data can be obtained directly through the first key value.
[0056] In this embodiment, when the associated key value includes at least one second key value, any key value is determined to be a third key value from the second key value. Then, it is determined whether an associated key value containing the third key value exists in the associated data. If not, the third key value is deleted from the second key value, and the third key value is determined again from the second key value. This determines the target associated key value containing the third key value. By updating the third key value, the target associated key value in the associated data is queried. This accurately determines whether a target associated key value consisting of multiple second key values exists in the associated data, avoiding omissions that could prevent the target data corresponding to the input key value from being found. Furthermore, if the target associated key value does not contain a first key value, the target associated key is determined. The key value other than the third key value is the fourth key value. The associated key value containing the fourth key value is determined in the associated data. This associated key value containing the fourth key value is updated to the target associated key value. Since the target associated key value of the second key value is obtained by updating the target associated key value, the target data corresponding to the input key value is obtained. Therefore, even if a shorter key value is used to replace a longer first key value in the associated data, the target data corresponding to the input key value can still be obtained. This achieves the goal of obtaining the target data required by the input key value while further reducing the database storage space. Furthermore, by directly obtaining the target data through the first key value when the input key value contains the first key value, the target data can be obtained quickly.
[0057] Please see Figure 3 This is a flowchart illustrating a data retrieval method provided in an embodiment of this application. Figure 3 As shown, the method in this application embodiment may include the following steps S301-S303.
[0058] S301, Identify multiple key values corresponding to the same data in the database;
[0059] In one embodiment, data is read from the database, and the key-value pairs of the same data in the database are obtained. It is understood that the data contained in the database is vast and complex, and there are situations where different key-value pairs correspond to the same data. Storing key-value pairs and data one-to-one would undoubtedly consume a large amount of storage space. Therefore, in this embodiment, association key-value pairs are established for multiple key-value pairs corresponding to the same data, forming associated data.
[0060] S302, determine the first key value corresponding to the data among multiple key values;
[0061] In one embodiment, when multiple key values in the database are identical, a first key value corresponding to the data can be determined from among the multiple key values.
[0062] For example, if the database contains identical data with keys "HashA", "HashB", and "HashC", and the data is quite long, to reduce storage space, in this embodiment, any one of the keys "HashA", "HashB", and "HashC" can be designated as the first key. This first key is then associated with the data, allowing the data to be retrieved using that first key. Further, please refer to... Figure 4 The first key value "HashC" is associated with other key values "HashA" and "HashB" to obtain associated key values "HashA+HashC" and "HashB+HashC", thus obtaining the associated data.
[0063] If the received input key-value pairs are "HashB+HashC", "HashC", or "HashA+HashB+HashC", the target data is obtained directly based on the first key-value pair since the first key-value pair exists in the input key-value pairs. If the received input key-value pairs are "HashA+HashB" or "HashA", and the first key-value pair does not exist in the input key-value pairs, the target associated key-value pair "HashA+HashC" is found in the associated data using the second key-value pair "HashA". If the first key-value pair "HashA+HashC" exists in the target associated key-value pair, the target data is obtained based on the first key-value pair. If the received input key-value pair is "HashB", and the first key-value pair does not exist in the input key-value pairs, the target associated key-value pair "HashB+HashC" is found in the associated data using the second key-value pair "HashB". If the first key-value pair "HashB+HashC" exists in the target associated key-value pair, the target data is obtained based on the first key-value pair.
[0064] Furthermore, in this embodiment, the shortest key value can be selected from multiple key values corresponding to the same data as the first key value corresponding to the same data. This avoids the first key value directly corresponding to the data being a key value with a large length when establishing associated key values, thus saving storage space for associated key values.
[0065] For example, among the lengths of the key values "HashA", "HashB", and "HashC", if the length of the key value "HashC" is the smallest, then the key value "HashC" is determined to be the first key value.
[0066] S303, establish association key values between the first key value and other key values, and generate associated data.
[0067] Furthermore, in this embodiment of the application, after determining the first key value, when establishing the associated key value between the first key value and other key values besides the first key value, the first length of the first key value corresponding to the same data and the second length of other key values can be obtained. If there is any second length of any key value besides the first key value that is less than the first length of the first key value, then the key value corresponding to the smallest second length is determined to be the fifth key value, and an associated key value between the fifth key value and the first key value is constructed. Then, an associated key value between the fifth key value and the sixth key value is constructed to generate associated data, wherein the sixth key value is other key values besides the fifth key value and the first key value among the key values corresponding to the data.
[0068] For example, please see Figure 5 In this embodiment of the application, the data in the database containing the keys “HashA”, “HashB”, and “HashC” are identical. After selecting the key “HashC” as the first key, the first length of the key “HashC” is 128 bits, and the second lengths of the keys “HashA” and “HashB” are 64 bits and 256 bits, respectively. The other key with the smallest length in the second length is determined to be the fifth key, that is, “HashA” is determined to be the fifth key. Then, the associated key between the first key and the fifth key is constructed, that is, the associated key “HashA+HashC” is constructed, and the associated key “HashA+HashB” between the fifth key and the sixth key “HashB” is constructed.
[0069] Furthermore, in this embodiment, when a received input key value such as "HashB+HashC", "HashC", or "HashA+HashB+HashC" exists, the target data is directly obtained based on the first key value. When a received input key value such as "HashA+HashB" or "HashA" does not contain the first key value, the target associated key value "HashA+HashC" is found in the associated data using the second key value "HashA". Since the target associated key value "HashA+HashC" contains the first key value, the data is obtained based on the first key value. The target data is obtained. Given the input key "HashB", if the first key does not exist, the second key "HashB" from the input key is used to search for the target associated key "HashA+HashB" in the associated data. Since the first key does not exist in the target associated key "HashA+HashB", the key "HashA" (excluding the third key "HashB") is identified as the fourth key. Then, based on the fourth key, the target associated key "HashA+HashC" containing the fourth key is searched in the associated key data. Since it contains the first key, the target data is obtained based on the first key. This avoids repeatedly constructing long associated key relationships between the first key and other keys, reducing the storage space required for constructing associated key relationships.
[0070] In this embodiment, when multiple key values correspond to the same data in the database, a first key value is determined from among the multiple key values, and the first key value is associated with the other key values to obtain associated key values. Since the first key value is associated with the other key values, the data of the other key values can be stored through the associated key values, without having to store each key value and data individually, thus reducing the data storage space. Furthermore, by determining the shortest key value as the first key value, when constructing associated key values with the first key value and other key values, the storage of the longer first key value is avoided repeatedly, further reducing the data storage space. Moreover, when determining the longer key value as the first key value, the shortest key value among the key values is determined as the fifth key value, and associated key values are constructed between the fifth key value and the first key value, as well as between the fifth key value and the sixth key value. Since it is not necessary to construct associated key values between the longer first key value and other key values one by one, the storage space for constructing associated key values is reduced.
[0071] The following will combine Figure 6 This application provides a detailed description of the data search device provided in its embodiments. It should be noted that... Figure 6 The data search device in the present application is used to perform the data search function. Figures 1-5The methods shown in the embodiments are for illustrative purposes only, illustrating the parts relevant to the embodiments of this application. For specific technical details not disclosed, please refer to this application. Figures 1-5 The illustrated embodiment. Specifically, the data retrieval device includes: a receiving unit 11, an acquiring unit 12, a querying unit 13, and a searching unit 14.
[0072] The receiving unit 11 is used to receive a data request instruction sent by the user and obtain the input key value in the data request instruction;
[0073] The acquisition unit 12 is configured to determine that the key value in the input key value is the second key value if the input key value does not contain the first key value, wherein the first key value is the key value directly corresponding to the target data;
[0074] Query unit 13 is used to query the target associated key value based on the second key value;
[0075] The lookup unit 14 is used to search for the target data corresponding to the first key value in the database if the target associated key value contains the first key value, and then return the target data to the user.
[0076] Optionally, the query unit 13 includes: a first determining subunit 131, a second determining subunit 132, and an execution subunit 133.
[0077] The first determining subunit 131 is used to determine any key value in the second key value as the third key value, and to determine whether there is an associated key value containing the third key value in the associated data;
[0078] The second determining subunit 132 is used to determine the associated key value as the target associated key value if it exists.
[0079] Execution subunit 133 is used to filter out the third key value from the second key value if it does not exist, and return to the execution of the step of determining that any key value in the second key value is the third key value and determining whether there is an associated key value containing the third key value in the associated data, until a preset condition is met; the preset condition is that an associated key value containing the third key value is determined in the associated data, or the number of key values in the second key value is 0.
[0080] Optionally, the query unit 13 further includes a third determining subunit 134 and an updating subunit 135.
[0081] The third determining subunit 134 is used to determine the fourth key value in the target associated key value other than the third key value if the target associated key value does not contain the first key value, and to determine the associated key value containing the fourth key value in the associated data.
[0082] Update subunit 135 to update the associated key value containing the fourth key value to the target associated key value.
[0083] Optionally, the query unit 13 further includes: a fourth determining subunit 136, a fifth determining subunit 137, and a generating subunit 138.
[0084] The fourth determining subunit 136 is used to determine multiple key values corresponding to the same data in the database;
[0085] The fifth determining subunit 137 is used to determine the first key value corresponding to the data among multiple key values;
[0086] The generation subunit 138 is used to establish the association key value between the first key value corresponding to the data and other key values corresponding to the data, and generate associated data.
[0087] Optionally, the query unit 13 further includes a sixth determining subunit 139.
[0088] The sixth determining subunit 139 is used to obtain the length of each key value among multiple key values corresponding to the same data, and determine the key value with the smallest length as the first key value corresponding to the data.
[0089] Optionally, the generation subunit 138 is specifically used for:
[0090] Get the first length of the first key value corresponding to the data, and the second length of the other key values corresponding to the data;
[0091] If there exists any second length that is less than the first length, then the key value corresponding to the smallest second length is determined to be the fifth key value;
[0092] Construct a related key-value pair between the fifth key-value pair and the first key-value pair, and construct a related key-value pair between the fifth key-value pair and the sixth key-value pair to generate related data. The sixth key-value pair is the key-value pair of the data that is not the fifth key-value pair and the first key-value pair.
[0093] Optionally, the receiving unit 11 further includes a search subunit 111.
[0094] The lookup subunit 111 is used to search for the target data corresponding to the first key value in the database if the input key value contains the first key value, and then return the target data to the user.
[0095] Please see Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 7 As shown, the electronic device 500 includes a processor 501 and a memory 502. The processor 501 and the memory 502 are electrically connected.
[0096] The processor 501 is the control center of the electronic device 500 and may include one or more processing cores. The processor 501 connects to various parts of the electronic device 500 using various interfaces and lines. It executes various functions and processes data of the electronic device 500 by running or calling computer programs stored in the memory 502 and by calling data stored in the memory 502, thereby providing overall control of the electronic device 500. Optionally, the processor 501 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 501 may integrate one or more of the following: CPU, Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user page, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 501 and may be implemented separately using a communication chip.
[0097] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the computer programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, computer programs required for at least one function, etc.; the data storage area may store data created based on the use of the electronic device 500, etc.
[0098] Furthermore, memory 502 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory 502 may also include a memory controller to provide processor 501 with access to memory 502.
[0099] In this embodiment, the processor 501 in the electronic device 500 loads the instructions corresponding to the processes of one or more computer programs into the memory 502 according to the following steps, and the processor 501 runs the computer programs stored in the memory 502 to realize various functions, as follows:
[0100] Receive a data request instruction sent by a user and obtain the input key value in the data request instruction;
[0101] If the input key value does not contain the first key value, then the key value in the input key value is determined to be the second key value, wherein the first key value is the key value that directly corresponds to the target data;
[0102] Query the target associated key value based on the second key value;
[0103] If the target associated key value contains the first key value, then the target data corresponding to the first key value is searched in the database, and the target data is returned to the user.
[0104] Optionally, the second key value includes at least one, and the processor 501 specifically executes the following when querying the target associated key value based on the second key value:
[0105] In the second key value, determine any key value as the third key value, and in the associated data, determine whether there is an associated key value containing the third key value;
[0106] If it exists, then the associated key value is determined to be the target associated key value;
[0107] If it does not exist, the third key value is filtered out from the second key value, and the process returns to the step of determining any key value in the second key value as the third key value, and determining whether there is an associated key value containing the third key value in the associated data, until a preset condition is met; the preset condition is that an associated key value containing the third key value is determined in the associated data, or the number of key values in the second key value is 0.
[0108] Optionally, after executing the query for the target associated key value based on the second key value, the processor 501 further executes:
[0109] If the target associated key value does not contain the first key value, then the key value other than the third key value in the target associated key value is determined to be the fourth key value, and an associated key value containing the fourth key value is determined in the associated data;
[0110] Update the associated key value containing the fourth key value to the target associated key value.
[0111] Optionally, processor 501 also performs:
[0112] Identify multiple key values corresponding to the same data in the database;
[0113] Determine the first key value corresponding to the data from the plurality of key values;
[0114] Establish association key values between the first key value corresponding to the data and other key values corresponding to the data, and generate the associated data.
[0115] Optionally, when the processor 501 determines the first key value corresponding to the data among the plurality of key values, it specifically performs the following:
[0116] Obtain the length of each key value among multiple key values corresponding to the same data, and determine the key value with the smallest length as the first key value corresponding to the data.
[0117] Optionally, when the processor 501 executes the process of establishing association key values between the first key value corresponding to the data and other key values corresponding to the data, and generating the associated data, it specifically performs the following:
[0118] Obtain the first length of the first key value corresponding to the data, and the second length of the other key values corresponding to the data;
[0119] If any of the second lengths is less than the first length, then the key value corresponding to the smallest second length is determined to be the fifth key value;
[0120] Construct an association key between the fifth key and the first key, and construct an association key between the fifth key and the sixth key to generate the associated data. The sixth key is the key other than the fifth key and the first key among the key values corresponding to the data.
[0121] Optionally, after executing the input key value in the data fetch request instruction, processor 501 also executes:
[0122] If the input key value contains the first key value, then the target data corresponding to the first key value is searched in the database and the target data is returned to the user.
[0123] It should be understood that the apparatus provided in this application embodiment is used to execute the above-described data search method, and therefore can achieve the same effect as the above-described implementation method.
[0124] When using integrated units, the device may include a processing module and a storage module. When applied to an electronic device, the processing module can be used to control and manage the operation of the electronic device. The storage module can be used to support the execution of relevant program code by the electronic device.
[0125] The processing module may be a processor or a controller, which can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc., and the storage module may be a memory.
[0126] In addition, the device provided in this application embodiment may specifically be a chip, component or module. The chip may include a connected processor and a memory. The memory is used to store instructions. When the processor calls and executes the instructions, the chip can execute a data lookup method provided in the above embodiment.
[0127] This application also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, the computer executes the aforementioned method steps to implement the data retrieval method provided in the above embodiments.
[0128] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement a data search method provided in the above embodiment.
[0129] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0130] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0131] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0132] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data retrieval method, characterized in that, The method includes: Receive a data request instruction sent by a user and obtain the input key value in the data request instruction; If the input key value does not contain the first key value, then the key value in the input key value is determined to be the second key value, wherein the first key value is the key value that directly corresponds to the target data; Query the target associated key value based on the second key value; If the target associated key value contains the first key value, then the target data corresponding to the first key value is searched in the database, and the target data is returned to the user.
2. The method according to claim 1, characterized in that, The second key value includes at least one key value, and the step of querying the target associated key value based on the second key value includes: In the second key value, determine any key value as the third key value, and in the associated data, determine whether there is an associated key value containing the third key value; If it exists, then the associated key value is determined to be the target associated key value; If it does not exist, the third key value is filtered out from the second key value, and the process returns to the step of determining any key value in the second key value as the third key value, and determining whether there is an associated key value containing the third key value in the associated data, until a preset condition is met; the preset condition is that an associated key value containing the third key value is determined in the associated data, or the number of key values in the second key value is 0.
3. The method according to claim 2, characterized in that, After querying the target associated key value based on the second key value, the method further includes: If the target associated key value does not contain the first key value, then the key value other than the third key value in the target associated key value is determined to be the fourth key value, and an associated key value containing the fourth key value is determined in the associated data; Update the associated key value containing the fourth key value to the target associated key value.
4. The method according to claim 1, characterized in that, The method is preceded by: Identify multiple key values corresponding to the same data in the database; Determine the first key value corresponding to the data from the plurality of key values; Establish association key values between the first key value corresponding to the data and other key values corresponding to the data, and generate the associated data.
5. The method according to claim 4, characterized in that, Determining the first key value corresponding to the data among the plurality of key values includes: Obtain the length of each key value among multiple key values corresponding to the same data, and determine the key value with the smallest length as the first key value corresponding to the data.
6. The method according to claim 4, characterized in that, The step of establishing association key values between the first key value corresponding to the data and other key values corresponding to the data, and generating the associated data, includes: Obtain the first length of the first key value corresponding to the data, and the second length of the other key values corresponding to the data; If any of the second lengths is less than the first length, then the key value corresponding to the smallest second length is determined to be the fifth key value; Construct an association key between the fifth key and the first key, and construct an association key between the fifth key and the sixth key to generate the associated data. The sixth key is the key other than the fifth key and the first key among the key values corresponding to the data.
7. The method according to claim 1, characterized in that, After obtaining the input key value in the data request instruction, the method further includes: If the input key value contains a first key value, then the target data corresponding to the first key value is searched in the database, and the target data is returned to the user.
8. A data retrieval device, characterized in that, The device includes: The receiving unit is used to receive a data request instruction sent by the user and obtain the input key value in the data request instruction; The acquisition unit is configured to determine that the key value in the input key value is the second key value if the input key value does not contain the first key value, wherein the first key value is the key value directly corresponding to the target data; The query unit is used to query the target associated key value based on the second key value; The search unit is configured to, if the target associated key value contains a first key value, search for the target data corresponding to the first key value in the database and return the target data to the user.
9. An electronic device, characterized in that, The electronic device includes: Memory, used to store executable program code; A control component for calling and running the executable program code from the memory, causing the electronic device to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program code that, when executed, implements the method as described in any one of claims 1 to 7.