Correlation query method and apparatus
By storing the hash value of the join query in memory, the problem of low cache hit rate in the existing technology is solved, the number of external storage queries is reduced, and the performance of join queries in scenarios such as e-commerce platforms is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2026-03-17
AI Technical Summary
In scenarios such as e-commerce platforms, the data volume of dimension tables is large and is mostly stored offline. The cache hit rate of existing join query methods is low, resulting in frequent queries to external storage and affecting overall performance.
By pre-storing the hash values of the related fields of the data table to be queried in memory, and using a hash algorithm to calculate the hash value of the related field to be queried, if the value is not found in memory, the related query is directly judged to have failed, thus reducing the number of queries to external storage.
It improves the overall performance of join queries, reduces the number of queries to external storage, and enhances robustness and stability.
Smart Images

Figure CN116795835B_ABST
Abstract
Description
Technical Field
[0001] The embodiments disclosed herein relate to the field of computer technology, and more specifically to a method and apparatus for related querying. Background Technology
[0002] When a query involves multiple tables with related fields, a join query is typically required. For example, in real-time computing scenarios based on the Flink framework, many vertical business lines often need to perform join queries using fact tables and dimension tables.
[0003] In existing technologies, methods such as preloading dimension tables, hot-join storage, broadcast dimension tables, and Temporal TableFunction Join are commonly used to implement join storage. However, in some scenarios, such as e-commerce platforms, the data volume of dimension tables (such as product tables) is usually very large, and they are mostly stored offline. The cache hit rate of the above-mentioned existing join query methods is low, and in most cases, queries need to be performed directly from external storage (such as HBase). This puts a significant strain on external storage such as HBase, thereby affecting the overall performance of join queries. Summary of the Invention
[0004] Embodiments of this disclosure present a method and apparatus for related querying.
[0005] In a first aspect, embodiments of this disclosure provide a method for related querying, the method comprising: obtaining the related field value to be queried; determining the hash value corresponding to the related field value as a target hash value using a preset hash algorithm; determining whether the target hash value exists in a target memory unit, wherein the target memory unit is used to store the hash values corresponding to each related field value in the data table to be queried based on the hash algorithm; and generating a related query result indicating that the related query has failed in response to determining that the target hash value does not exist in the target memory unit.
[0006] Secondly, embodiments of this disclosure provide an association query apparatus, comprising: an acquisition unit configured to acquire the values of the associated fields to be queried; a first determination unit configured to determine, using a preset hash algorithm, the hash value corresponding to the associated field value as a target hash value; a second determination unit configured to determine whether the target hash value exists in a target memory unit, wherein the target memory unit is used to store the hash values corresponding to each associated field value in the data table to be queried based on the hash algorithm; and a generation unit configured to generate an association query result indicating that the association query has failed in response to determining that the target hash value does not exist in the target memory unit.
[0007] Thirdly, embodiments of this disclosure provide an electronic device comprising: one or more processors; a storage device for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the method described in any implementation of the first aspect.
[0008] Fourthly, embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon that, when executed by a processor, implements the method as described in any implementation of the first aspect.
[0009] The associated storage method and apparatus provided in the embodiments of this disclosure pre-store the hash values corresponding to each associated field value in the data table to be queried based on a preset hash algorithm in a memory unit. When performing an associated query, the hash value corresponding to the associated field value to be queried based on the hash algorithm is calculated first, and then the hash value is used to query the memory unit. If the hash value is not found in the memory unit, the associated query can be directly determined to have failed, thereby reducing the number of queries to external storage and thus helping to improve the overall performance of associated queries. Attached Figure Description
[0010] Other features, objects, and advantages of this disclosure will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0011] Figure 1 This is an exemplary system architecture diagram to which one embodiment of this disclosure can be applied;
[0012] Figure 2 This is a flowchart of an embodiment of the association query method according to this disclosure;
[0013] Figure 3 This is a flowchart of yet another embodiment of the association query method according to this disclosure;
[0014] Figure 4 This is a schematic design framework diagram of the association query method according to this embodiment;
[0015] Figure 5 This is a schematic diagram of the structure of an embodiment of the association query device according to the present disclosure;
[0016] Figure 6 This is a schematic diagram of the structure of an electronic device suitable for implementing embodiments of the present disclosure. Detailed Implementation
[0017] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the relevant parts are shown in the accompanying drawings.
[0018] It should be noted that the collection, updating, analysis, use, transmission, and storage of user personal information involved in the technical solution of this invention all comply with relevant laws and regulations, are used for legitimate and reasonable purposes, and are not shared, disclosed, or sold outside of these legitimate uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken to selectively block the use or access to personal information data to prevent unauthorized access to such personal information data, ensure that personnel authorized to access personal information data comply with relevant laws and regulations, and ensure the security of user personal information. Furthermore, once this user personal information data is no longer needed, the risk should be minimized by restricting or even prohibiting data collection and / or deleting the data.
[0019] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0020] Figure 1 An exemplary architecture 100 is shown, to which embodiments of the association query method or association query apparatus of this disclosure may be applied.
[0021] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0022] Terminal devices 101, 102, and 103 interact with server 105 via network 104 to receive or send messages, etc. Various client applications can be installed on terminal devices 101, 102, and 103, such as browser applications, e-commerce applications, search applications, instant messaging tools, and news feed applications.
[0023] Terminal devices 101, 102, and 103 can be either hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices, including but not limited to smartphones, tablets, e-book readers, laptops, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices. They can be implemented as multiple software programs or software modules (e.g., multiple software programs or software modules used to provide distributed services) or as a single software program or software module. No specific limitations are imposed here.
[0024] Server 105 can be a server providing various services, such as a backend server providing data query services to terminal devices 101, 102, and 103. Server 105 can obtain the related field values to be queried from terminal devices 101, 102, and 103, and then use a preset hash algorithm to determine the hash value corresponding to the related field value as the target hash value; determine whether the target hash value exists in the target memory unit, wherein the target memory unit is used to store the hash values corresponding to each related field value in the data table to be queried based on the hash algorithm; in response to determining that the target hash value does not exist in the target memory unit, generate a related query result to indicate that the related query has failed.
[0025] It should be noted that the related field values to be queried can also be stored locally on server 105. Server 105 can directly extract and process the related field values stored locally. In this case, terminal devices 101, 102, 103 and network 104 may not exist.
[0026] It should be noted that the association query method provided in the embodiments of this disclosure is generally executed by server 105, and correspondingly, the association query device is generally set in server 105.
[0027] It should also be noted that data query applications can be installed on terminal devices 101, 102, and 103, and these devices can perform related queries based on these applications. In this case, the related query method can also be executed by terminal devices 101, 102, and 103, and correspondingly, the related query device can also be set in terminal devices 101, 102, and 103. In this case, the exemplary system architecture 100 may not include server 105 and network 104.
[0028] It should be noted that server 105 can be either hardware or software. When server 105 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When server 105 is software, it can be implemented as multiple software programs or software modules (e.g., multiple software programs or software modules used to provide distributed services), or as a single software program or software module. No specific limitations are made here.
[0029] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0030] Continue to refer to Figure 2 The diagram illustrates a flow 200 of an embodiment of the association query method according to this disclosure. The association query method includes the following steps:
[0031] Step 201: Obtain the values of the associated fields to be queried.
[0032] In this embodiment, the value of the related field to be queried can refer to the field value of the related field to be queried. Here, the related field refers to the related field of multiple tables involved in the related query. For example, the order table includes fields such as order identifier and product identifier. The product table includes fields such as product identifier and product attribute. In this case, the product identifier is the related field for the related query between the order table and the product table.
[0033] The executing entity of the related query method (e.g.) Figure 1 The server(s) shown can obtain the values of the related fields in a join query from the local machine or other data sources. For example, the values of the related fields can be parsed from the data table from which the join query is performed.
[0034] Step 202: Use a preset hash algorithm to determine the hash value corresponding to the associated field value as the target hash value.
[0035] In this embodiment, a preset hash algorithm can be used to calculate the hash value corresponding to the associated field value, and this hash value can be determined as the target hash value. The specific hash algorithm used can be preset by relevant technical personnel.
[0036] Step 203: Determine whether the target hash value exists in the target memory unit.
[0037] In this embodiment, it can be first determined whether the target hash value exists in the target memory unit. The target memory unit can refer to a memory unit used to store the hash values corresponding to the values of each related field in the data table to be queried, based on the aforementioned hash algorithm.
[0038] The data table to be queried can be flexibly configured according to the actual application scenario. For example, the data table can be a product table, an order table, etc. The data table can record the correspondence between the related fields and other fields. These other fields can be flexibly configured according to the actual application scenario. For example, in a product table, other fields can include various attribute fields of the product (such as price, origin, inventory, etc.). That is, the data table consists of data rows containing multiple related data values.
[0039] For each related field value in the data table, the corresponding hash value can be pre-calculated using the same hash algorithm described above, then stored in a specified memory unit, and these specified memory units are determined as the target memory units.
[0040] Step 204: In response to determining that the target hash value does not exist in the target memory unit, generate a join query result to indicate that the join query failed.
[0041] In this embodiment, if the target hash value is not found in the target memory unit, it means that there is no data row corresponding to the above-mentioned associated field value in the data table, so an associated query result can be generated to indicate that the associated query has failed.
[0042] The method provided in the above embodiments of this disclosure utilizes a preset hash algorithm to store in memory the hash values corresponding to each related field value in the data table to be queried. Thus, after obtaining the related field value to be queried, the hash value corresponding to the related field value can be calculated first, and then the existence of the hash value can be checked in memory. If it does not exist, the related query can be directly judged as failed, thereby reducing the number of related queries to external storage.
[0043] Further reference Figure 3 This illustrates a flow 300 of another embodiment of the correlation query method. Flow 300 of this correlation query method includes the following steps:
[0044] Step 301: Obtain the values of the associated fields to be queried.
[0045] Step 302: Use a preset hash algorithm to determine the hash value corresponding to the associated field value as the target hash value.
[0046] Step 303: Determine whether the target hash value exists in the target memory unit.
[0047] Step 304: In response to determining that the target hash value does not exist in the target memory unit, generate a join query result to indicate that the join query failed.
[0048] Step 305: In response to determining that the target hash value exists in the target memory unit, determine whether there is a data row in the data table where the associated field value is located in the cache.
[0049] In this embodiment, if the target hash value is found in the target memory unit, it indicates that there may be a related field value to be queried in the data table. At this time, it is possible to further query in the cache whether the related field value to be queried exists in the data row content of the data table.
[0050] It should be noted that a hash algorithm can be an algorithm in which a hash value uniquely corresponds to a single associated field value, or an algorithm in which a hash value corresponds to one or more associated field values.
[0051] Step 306: In response to determining that a data row exists in the cache, retrieve the data row from the cache as the result of the related query.
[0052] In this embodiment, if the data row containing the value of the related field to be queried is found in the cache, the data row can be directly obtained from the cache as the result of the related query.
[0053] Step 307: In response to determining that the data row does not exist in the cache, query the data row in the external storage to obtain the associated query result.
[0054] In this step, the aforementioned data tables can be stored on external storage. External storage can refer to databases such as Redis and HBase. Generally, external storage can store the contents of the data tables in a key-value format.
[0055] If the row containing the value of the related field to be joined in the query is not found in the cache, a further query can be performed in the external storage to determine if the row exists there. If the row is found in the external storage, its content can be used as the join query result. If the row is not found in the external storage, a join query result indicating that the join query failed can be generated.
[0056] By setting up a cache to first look up relevant data rows in the cache, the efficiency of join queries can be improved, and the number of queries to external storage can be further reduced.
[0057] In addition, if the data row is found in the external storage, the content of the data row can be written into the cache at the same time as the result of the related query. At the same time, each time a new data row is written into the cache, expired data such as data rows that have not been found for a long time can be cleared from the cache to improve the cache hit rate of subsequent related queries and further reduce the number of queries to the external storage.
[0058] In some optional implementations of this embodiment, the above method can also update the target memory unit through the following steps:
[0059] Step 1: In response to the determination that the preset update time has been reached, retrieve the updated data rows from the data table.
[0060] In this step, the update time can be preset by relevant technical personnel according to actual application needs. For example, updates can be performed periodically at specified times.
[0061] When the update time arrives, the updated data rows in the aforementioned data table can be retrieved first. The updated data rows refer to data rows newly generated since the last update time.
[0062] Step 2: Use a hash algorithm to determine the hash value corresponding to each associated field value in the updated data row.
[0063] In this step, for each associated field value in the updated data row, the same hash algorithm described above can be used to calculate the hash value corresponding to that associated field value.
[0064] Step 3: Allocate new memory units and store the hash value corresponding to the updated data row in the newly allocated memory units.
[0065] In this step, a new memory unit can be allocated first, and then the hash values corresponding to each associated field value in the updated data row can be stored in the newly allocated memory unit. The newly allocated memory unit is the update to the target memory unit mentioned above.
[0066] By allocating new memory units to store the hash value corresponding to the updated data row during each update, the impact of the update on online real-time relational queries and other applications can be avoided, thereby helping to improve the stability of online applications.
[0067] See also Figure 4 , Figure 4 This is a schematic design framework diagram of the association query method according to this embodiment. Figure 4 In this example, a real-time join query task based on the Flink framework is used. After receiving the input data stream, the join field values are parsed first, and then a join query is performed to obtain the join query results as the output stream. The computation operators can be used to implement various computations required for the join query process.
[0068] The dynamic relational generator provides services such as mapping, storage, judgment, and updating. Mapping is used to generate hash values corresponding to the values of the related fields using a hash algorithm. Storage is used to store the hash values in memory. Judgment is used to determine whether the hash value corresponding to the value of the related field to be queried can be found in memory. Updating is used to update the memory units.
[0069] The persistence checker provides services such as construction, storage, check, and expiration. Construction is used to implement data querying functions in the cache and external storage (such as HBase in the diagram). Storage is used to implement data storage in the cache and external storage. Checking is used to determine whether the data row in the data table contains the value of the related field to be queried. Expiration is used to check the expiration of data in the cache.
[0070] The existing join query methods typically perform a direct search in the cache. If the cache misses, a join query is performed in external storage. However, for large tables, these methods suffer from low cache hit rates, leading to frequent external storage queries, which inevitably impact overall performance.
[0071] The method provided in the above embodiments of this disclosure designs a dynamic joiner and a persistent checker to calculate the corresponding hash value after obtaining the value of the join field to be queried. Then, the dynamic joiner first checks if the hash value exists in memory. If it does not exist, the join query can be directly determined to have failed to avoid subsequent query operations, thereby reducing the number of accesses to external storage and improving the robustness, stability, and fault tolerance of real-time join queries in massive data scenarios. Simultaneously, if the hash value is found in memory, the persistent checker can sequentially search for the corresponding data row in the cache and external storage to achieve the join query.
[0072] Further reference Figure 5 As an implementation of the methods shown in the above figures, this disclosure provides an embodiment of an association query device, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0073] like Figure 5As shown, the association query device 500 provided in this embodiment includes an acquisition unit 501, a first determination unit 502, a second determination unit 503, and a generation unit 504. The acquisition unit 501 is configured to acquire the values of the associated fields to be queried; the first determination unit 502 is configured to determine the hash value corresponding to the associated field value as the target hash value using a preset hash algorithm; the second determination unit 503 is configured to determine whether the target hash value exists in the target memory unit, wherein the target memory unit is used to store the hash values corresponding to each associated field value in the data table to be queried based on the hash algorithm; and the generation unit 504 is configured to generate an association query result indicating that the association query has failed in response to the determination that the target hash value does not exist in the target memory unit.
[0074] In this embodiment, the specific processing of the acquisition unit 501, the first determination unit 502, the second determination unit 503, and the generation unit 504 in the association query device 500, and the resulting technical effects, can be referred to respectively. Figure 2 The relevant descriptions of steps 201, 202, 203 and 204 in the corresponding embodiments will not be repeated here.
[0075] In some optional implementations of this embodiment, the above-mentioned association query device 500 further includes: a third determining unit (not shown in the figure) is configured to determine whether there is a data row in the data table where the associated field value is located in the cache in response to determining that a target hash value exists in the target memory unit; and the above-mentioned generating unit 504 is further configured to query the data row in the external storage to obtain the association query result in response to determining that there is no data row in the cache, wherein the external storage is used to store the data table.
[0076] In some optional implementations of this embodiment, the generation unit 503 is further configured to: in response to determining that a data row exists in the cache, query the data row from the cache as the associated query result.
[0077] In some optional implementations of this embodiment, the above-mentioned association query device 500 further includes: a writing unit (not shown in the figure) configured to write the data row into a cache in response to determining that a data row has been found in the external storage.
[0078] In some optional implementations of this embodiment, the association query device 500 further includes: an update unit (not shown in the figure) configured to, in response to determining that a preset update time has been reached, obtain an updated data row in the data table; use a hash algorithm to determine the hash value corresponding to each associated field value in the updated data row; request a new memory unit, and store the hash value corresponding to the updated data row in the newly requested memory unit.
[0079] The apparatus provided in the above embodiments of this disclosure obtains the related field value to be queried by an acquisition unit; a first determining unit determines the hash value corresponding to the related field value as the target hash value using a preset hash algorithm; a second determining unit determines whether the target hash value exists in a target memory unit, wherein the target memory unit is used to store the hash values corresponding to each related field value in the data table to be queried based on the hash algorithm; and a generating unit is configured to generate a related query result indicating that the related query has failed in response to determining that the target hash value does not exist in the target memory unit. By first checking whether the hash value exists in memory, if it does not exist, the related query can be directly determined to have failed, thereby reducing the number of related queries to external storage.
[0080] The following is for reference. Figure 6 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 1 The structural diagram of the server (600) in the middle. Figure 6 The server shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0081] like Figure 6 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0082] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 6 Each box shown can represent a device or multiple devices as needed.
[0083] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0084] It should be noted that the computer-readable medium described in the embodiments of this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the embodiments of this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0085] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: obtain the value of the related field to be queried; determine the hash value corresponding to the related field value as the target hash value using a preset hash algorithm; determine whether the target hash value exists in the target memory unit, wherein the target memory unit is used to store the hash values corresponding to each related field value in the data table to be queried based on the hash algorithm; and, in response to determining that the target hash value does not exist in the target memory unit, generate a related query result indicating that the related query has failed.
[0086] Computer program code for performing the operations of embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0088] The units described in the embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including an acquisition unit, a first determination unit, a second determination unit, and a generation unit. The names of these units do not necessarily limit the specific unit; for example, the acquisition unit may also be described as "a unit that acquires the values of the associated fields to be queried."
[0089] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A method for association query, comprising: obtaining an association field value to be queried, the association field value being a field value of an association field of a plurality of data tables to be queried; determining a hash value corresponding to the association field value as a target hash value by using a preset hash algorithm; determining whether the target hash value exists in a target memory unit, wherein the target memory unit is configured to store hash values corresponding to respective association field values in the data tables based on the hash algorithm; generating an association query result indicating a failure of the association query in response to a determination that the target hash value does not exist in the target memory unit; obtaining an updated data row in the data tables in response to a determination that a preset update time is reached; determining hash values corresponding to respective association field values in the updated data row by using the hash algorithm; applying for a new memory unit, and storing the hash values corresponding to the updated data row in the new memory unit.
2. The method of claim 1, wherein, The method further comprises: determining whether a data row in which the association field value is located in the data tables exists in a cache in response to a determination that the target hash value exists in the target memory unit; and querying the data row in an external storage to obtain an association query result in response to a determination that the data row does not exist in the cache, wherein the external storage is configured to store the data tables.
3. The method of claim 2, wherein, The method further comprises: querying the data row from the cache as an association query result in response to a determination that the data row exists in the cache.
4. The method of claim 2, wherein, The method further comprises: writing the data row into the cache in response to a determination that the data row is queried in the external storage. 5.An apparatus for association query, comprising: an obtaining unit configured to obtain an association field value to be queried, the association field value being a field value of an association field of a plurality of data tables to be queried; a first determining unit configured to determine a hash value corresponding to the association field value as a target hash value by using a preset hash algorithm; a second determining unit configured to determine whether the target hash value exists in a target memory unit, wherein the target memory unit is configured to store hash values corresponding to respective association field values in the data tables based on the hash algorithm; a generating unit configured to generate an association query result indicating a failure of the association query in response to a determination that the target hash value does not exist in the target memory unit; an updating unit configured to obtain an updated data row in the data tables in response to a determination that a preset update time is reached, determine hash values corresponding to respective association field values in the updated data row by using the hash algorithm, apply for a new memory unit, and store the hash values corresponding to the updated data row in the new memory unit.
6. The apparatus of claim 5, wherein, The apparatus further comprises: a third determining unit configured to determine whether a data row in which the association field value is located in the data tables exists in a cache in response to a determination that the target hash value exists in the target memory unit; and a querying unit configured to query the data row in an external storage to obtain an association query result in response to a determination that the data row does not exist in the cache, wherein the external storage is configured to store the data tables. The generating unit is further configured to, in response to determining that the data row does not exist in the cache, query the data row in an external storage to obtain an associated query result, wherein the external storage is configured to store the data table.
7. The apparatus of claim 6, wherein, The generating unit is further configured to: in response to determining that the data row exists in the cache, query the data row from the cache as the associated query result.
8. The apparatus of claim 6, wherein, The apparatus further includes: a writing unit configured to, in response to determining that the data row is queried in the external storage, write the data row into the cache. 9.An electronic device, comprising: one or more processors; a memory device having one or more programs stored thereon; when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-4.
10. A computer readable medium having stored thereon a computer program, wherein, The program is executed by the processor to implement the method according to any one of claims 1-4. The program is executed by the processor to implement the method according to any one of claims 1-4.
Citation Information
Patent Citations
Data output method and device
CN102929943A
Data retrieval method, device and equipment and machine readable storage medium
CN114647658A