Data query method, system and device and electronic equipment
By storing multiple table entries information in the CAM table into RAM and reading and comparing the query data one after another, the problems of data compression and waste of hardware resources in hash lookup tables and CAM table queries are solved, and the problem of data compression and hardware resource waste in hash lookup tables and CAM table queries is achieved quickly and efficiently Data query.
Patent Information
- Application Number
- CN202310609484.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-26
- Publication Date
- 2024-11-26
AI Technical Summary
In the existing data query methods, the hash lookup table and CAM table query has problems such as data compression and waste of hardware resources, resulting in long query time and high cost.
Store multiple table entry information in the CAM table into RAM, and read the table entry information to be matched from each storage address of the RAM in turn, and compare it with the data to be queryed to avoid one-time enumeration matching and reduce querying cost and does not compress data when stored in RAM.
It realizes faster data queries, reduces query costs and time, and avoids the extension of query time due to data compression.
Smart Images

Figure CN119025722A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing, and in particular to a data query method, system, device and electronic equipment. Background Art
[0002] At present, for most information exchange systems, data control and processing require data query operations. Currently, the data query speeds that are relatively fast mainly include the following two types: one is based on hash table query, and the other is based on CAM (content addressable memory, referred to as content addressable memory) table query.
[0003] However, in the process of converting the input keyword into a hash value based on hash table query, the bit width of the data will be reduced, that is, the data is compressed, and hash conflict problems will inevitably occur, resulting in a longer data query time. Based on CAM table query, the implementation method in the relevant technology is to read all the table item information in the CAM table at one time. Since each matching register can only store one table item information, all the read table item information needs to be stored in a matching register consistent with the number of table item information for enumeration matching; however, when there are many table item information to be matched in the CAM table and the bit width of the table item information is large, data query based on the CAM table will cause the register and hardware resources to increase exponentially, resulting in higher query costs. Summary of the invention
[0004] The present disclosure aims to solve one of the technical problems in the above-mentioned technologies at least to some extent.
[0005] To this end, the present disclosure proposes a data query method, system, device and electronic device, which can store multiple table item information in a CAM table into a RAM (Random Access Memory), and read the table item information to be matched from each storage address of the RAM in turn, so as to compare each table item information traversed and read into any storage address of the RAM with the data to be queried, and can store only the table item information read each time into a matching register matching the number of the table item information read this time for comparison with the data to be queried, thereby eliminating the need to store all the table item information in a matching register consistent with the number of all the table item information at one time for enumeration matching, thereby reducing the query cost, and at the same time, when storing the table item information, the RAM does not need to compress the table item information, thereby avoiding the problem of long data query time caused by data compression.
[0006] The first aspect of the present disclosure proposes a data query method, which is characterized by comprising: receiving a query request sent by a client, wherein the query request includes data to be queried; in response to the query request, starting from the first storage address, traversing and reading multiple table item information to be matched in each storage address of the RAM in sequence; comparing each of the table item information traversed and read in any storage address of the RAM with the data to be queried, and obtaining a target value of a flag bit corresponding to each of the table item information in any of the storage addresses, wherein the target value of the flag bit is used to indicate whether each of the table item information matches the data to be queried; arbitrating the target value corresponding to each of the table item information in any of the storage addresses to obtain target matching information, and generating a query result based on the target matching information, and sending the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM.
[0007] The second aspect of the present disclosure proposes a data query system, including: a RAM, used to store table item information to be matched, wherein the table item information to be matched is multiple table item information in a CAM table; a read controller, used to respond to receiving a query request, starting from the first storage address, and sequentially traverse and read multiple table item information to be matched in each storage address of the RAM; a comparator, used to compare each of the table item information in any of the storage addresses currently read with the data to be queried, and output a target value of a flag bit corresponding to each of the table item information in any of the storage addresses, wherein the target value of the flag bit is used to indicate whether the corresponding table item information in any of the storage addresses matches the data to be queried; an arbitrator, used to arbitrate the target value corresponding to each of the table item information in any of the storage addresses to obtain target matching information, and generate a query result based on the target matching information, and send the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM.
[0008] The third aspect of the present disclosure proposes a data query device, including: a receiving module, used to receive a query request sent by a client, wherein the query request includes data to be queried; a reading module, used to respond to the query request, starting from the first storage address, and sequentially traverse and read multiple table item information to be matched in each storage address of the RAM; a comparison module, used to compare each of the table item information traversed and read in any storage address of the RAM with the data to be queried, and obtain a target value of a flag bit corresponding to each of the table item information in any of the storage addresses, wherein the target value of the flag bit is used to indicate whether each of the table item information matches the data to be queried; an arbitration module, used to arbitrate the target value corresponding to each of the table item information in any of the storage addresses to obtain target matching information, and generate a query result based on the target matching information, and send the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM.
[0009] The fourth aspect embodiment of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data query method described in the first aspect embodiment of the present disclosure.
[0010] The fifth aspect of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the data query method described in the first aspect of the present disclosure is implemented.
[0011] The sixth aspect embodiment of the present disclosure proposes a computer program product, including computer instructions, on which a computer program is stored. When the computer instructions are executed by a processor, the data query method described in the first aspect embodiment of the present disclosure is implemented.
[0012] The data query method of the disclosed embodiment receives a query request sent by a client, wherein the query request includes data to be queried; in response to the query request, starting from a first storage address, traverses and reads a plurality of table item information to be matched in each storage address of a RAM in sequence; compares each of the table item information traversed and read in any storage address of the RAM with the data to be queried, and obtains a target value of a flag bit corresponding to each of the table item information in any storage address, wherein the target value of the flag bit is used to indicate whether each of the table item information matches the data to be queried; performs arbitration processing on the target value corresponding to each of the table item information in any storage address to obtain target matching information, generates a query result based on the target matching information, and sends the query result to the client, wherein the target matching information is used to indicate whether the R Whether there is table entry information matching the data to be queried in the AM, multiple table entry information in the CAM table is stored in the RAM, and the table entry information to be matched is read from each storage address of the RAM in turn, so as to compare each table entry information traversed and read in any storage address of the RAM with the data to be queried, so that only the table entry information read each time is stored in the matching register matching the number of the table entry information read this time for comparison with the data to be queried, thereby eliminating the need to store all the table entry information in the matching register consistent with the number of all the table entry information at one time for enumeration matching, thereby reducing the query cost, and at the same time, when storing the table entry information, the RAM does not need to compress the table entry information, and can also avoid the problem of long data query time caused by data compression.
[0013] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description or learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The above and / or additional aspects and advantages of the present disclosure will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0015] Figure 1 A flowchart of a data query method provided according to an embodiment of the present disclosure;
[0016] Figure 2 A flowchart of a data query method provided according to an embodiment of the present disclosure;
[0017] Figure 3 A flowchart of a data query method provided according to an embodiment of the present disclosure;
[0018] Figure 4 A schematic diagram of the structure of a data query system provided according to an embodiment of the present disclosure;
[0019] Figure 5A schematic diagram of a RAM storing information of each entry of a CAM table according to an embodiment of the present disclosure;
[0020] Figure 6 A schematic diagram of the structure of a data query system provided according to an embodiment of the present disclosure;
[0021] Figure 7 A schematic diagram of the structure of a data query device provided according to an embodiment of the present disclosure;
[0022] Figure 8 The present invention is a structural block diagram of an electronic device provided according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] Embodiments of the present disclosure are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0024] The present disclosure provides a data query method, system, device and electronic device.
[0025] Figure 1 The present invention is a flowchart of a data query method provided according to an embodiment of the present disclosure.
[0026] like Figure 1 As shown, the data query method may include the following steps:
[0027] Step 101: Receive a query request sent by a client.
[0028] The query request includes the data to be queried.
[0029] Step 102 , in response to the query request, starting from the first storage address, traverse and read the multiple table entry information to be matched in each storage address of the RAM in sequence.
[0030] In order to reduce the hardware cost of the data query system, as a possible implementation method of the embodiment of the present disclosure, multiple table item information in the CAM table can be stored in the RAM as table item information to be matched, and in response to the received query request, a read controller is used to start from the first storage address and sequentially traverse and read multiple table item information to be matched in each storage address of the RAM. It should be noted that different storage addresses in the RAM can store different table item information to be matched, and each storage address may include at least one table item information to be matched.
[0031] Step 103 , compare each entry information in any storage address of the RAM read through the traversal with the data to be queried, and obtain the target value of the flag bit corresponding to each entry information in any storage address.
[0032] The target value is used to indicate whether the information of each table item matches the data to be queried.
[0033] In the disclosed embodiment, a comparator can be used to compare the multiple table entry information in any storage address traversed and read to the RAM with the data to be queried, and obtain the target value of the flag bit corresponding to each table entry information in any storage address output by the comparator. For example, when the target value is the first target value (e.g., 1), it indicates that the corresponding table entry information in any storage address matches the data to be queried; when the target value is the second target value (e.g., 0), it indicates that the corresponding table entry information in any storage address does not match the data to be queried.
[0034] In order to improve the accuracy of matching the table entry information to be matched in each storage address with the data to be queried, as an example, when the read controller traverses multiple table entry information in any storage address of the RAM read, the read controller can send the multiple table entry information in any storage address of the RAM traversed and read to the matching register, so that the matching register can store the multiple table entry information in any storage address of the RAM traversed and read, wherein it should be noted that, in order to reduce the query cost, the number of matching registers matches the number of multiple table entry information in any storage address.
[0035] Furthermore, the comparator can read multiple entry information in any storage address from the matching register, compare each entry information in any storage address with the data to be queried, and output the target value of the flag bit corresponding to each entry information in any storage address.
[0036] Step 104 , arbitrate the target value corresponding to each entry information in any storage address to obtain target matching information, generate a query result based on the target matching information, and send the query result to the client.
[0037] The target matching information is used to indicate whether there is table entry information matching the data to be queried in the RAM.
[0038] In order to improve the accuracy of the query result, as an example, an arbitrator may be used to arbitrate the target value corresponding to each entry information in any storage address to obtain target matching information, thereby generating a query result based on the target matching information. The target matching information may include: a matching flag, a matching state, and a matching address.
[0039] Among them, the matching flag is used to indicate whether there is table entry information matching the data to be queried in the RAM; the matching status is used to indicate the number of table entry information matching the data to be queried in the RAM (such as single address matching, multiple address matching), and the matching address is used to indicate the address information of the table entry information with the highest access priority matching the data to be queried in the CAM.
[0040] The data query method of the disclosed embodiment receives a query request sent by a client, wherein the query request includes data to be queried; in response to the query request, starting from the first storage address, traverses and reads multiple table item information to be matched in each storage address of the RAM in sequence; compares each table item information in any storage address traversed and read with the data to be queried, and obtains a target value of a flag bit corresponding to each table item information in any storage address, wherein the target value is used to indicate whether each table item information matches the data to be queried; arbitrates the target value corresponding to each table item information in any storage address to obtain target matching information, and generates a query result based on the target matching information, and sends the query result to the client, wherein the target matching information is used to indicate whether each table item information matches the data to be queried. Whether there is table item information matching the data to be queried, thereby, multiple table item information in the CAM table is stored in the RAM, and the table item information to be matched is read from each storage address of the RAM in turn, so as to compare each table item information traversed and read in any storage address of the RAM with the data to be queried, and it can be realized that only the table item information read each time is stored in the matching register matching the number of the table item information read this time for comparison with the data to be queried, so that there is no need to store all the table item information in the matching register consistent with the number of all the table item information at one time for enumeration matching, thereby reducing the query cost. At the same time, when storing the table item information, the RAM does not need to compress the table item information, and the problem of long data query time caused by data compression can also be avoided.
[0041] In order to clearly explain how the target value corresponding to each entry information in any storage address is arbitrated in the above embodiment to obtain target matching information, the present disclosure proposes another data query method.
[0042] Figure 2 The present invention is a flowchart of a data query method provided according to an embodiment of the present disclosure.
[0043] like Figure 2 As shown, the data query method may include the following steps:
[0044] Step 201: receiving a query request sent by a client.
[0045] The query request includes the data to be queried.
[0046] Step 202 , in response to the query request, starting from the first storage address, traverse and read the multiple table entry information to be matched in each storage address of the RAM in sequence.
[0047] Step 203 , compare each entry information in any storage address of the RAM read through the traversal with the data to be queried, and obtain the target value of the flag bit corresponding to each entry information in any storage address.
[0048] The target value of the flag bit is used to indicate whether the information of each table item matches the data to be queried.
[0049] Step 204 , arbitrate the target values corresponding to the table entry information of the first storage address read through the traversal to generate initial matching information.
[0050] As a possible implementation form of the embodiment of the present disclosure, the initial matching information includes a matching flag, a matching state and a matching address, and it is determined whether the target value corresponding to each table item information of the first storage address indicates whether there is table item information matching the data to be queried in the multiple table item information of the first storage address; when the target value corresponding to each table item information of the first storage address indicates that there is at least one table item information matching the data to be queried in the multiple table item information of the first storage address, the matching flag is determined to be a first value; from the multiple table item information of the first storage address, the first address information of at least one table item information matching the data to be queried in the CAM table and the access priority of at least one first address information are obtained, the highest access priority among the access priorities of the at least one first address information is determined, and the first address information in the CAM table corresponding to the highest access priority is used as the matching address; when the number of table item information matching the data to be queried in each table item information of the first storage address is equal to 1, the matching state is determined to be a single matching state; when the number of table item information matching the data to be queried in each table item information of the first storage address is greater than 1, the matching state is determined to be a multiple matching state.
[0051] That is, the initial matching information includes a matching flag, a matching state and a matching address. As an example, when the target value (e.g., the target value is the first target value, such as 1) corresponding to each table item information of the first storage address traversed and read indicates that there is table item information matching the data to be queried in each table item information of the first storage address, the matching flag is determined to be the first value (e.g., 1), and the arbitrator can obtain the first address information of at least one table item information matching the data to be queried in the CAM table and the access priority of at least one first address information, and determine the highest access priority among the access priorities of the at least one first address information, and use the first address information in the CAM table corresponding to the highest access priority as the matching address; at the same time, the arbitrator can also determine the matching state based on the number of table item information matching the data to be queried in each table item information of the first storage address, for example, when the number of table item information matching the data to be queried in each table item information of the first storage address is one, the matching state is a single-address match; for another example, when the number of table item information matching the data to be queried in each table item information of the first storage address is multiple, the matching state is a multiple-address match.
[0052] In addition, when the target value corresponding to each entry information of the first storage address indicates that there is no entry information matching the data to be queried in the multiple entry information of the first storage address, the matching flag is determined to be the second value, and the matching state and the matching address are determined to be null values.
[0053] 205 , determining whether there is a non-first storage address other than the first storage address among the storage addresses of the RAM.
[0054] In order to further determine whether there is a non-first storage address other than the first storage address among the RAM storage addresses, in the embodiment of the present disclosure, it can be determined whether there is a non-first storage address other than the first storage address among the RAM storage addresses.
[0055] Step 206, when there is at least one non-first storage address in each storage address of the RAM, based on the target value corresponding to each table entry information of the non-first storage address traversed and read, determine whether there is at least one table entry information matching the data to be queried in each table entry information of the non-first storage address traversed and read.
[0056] Furthermore, after generating the initial matching information, it can be determined whether there is at least one non-first storage address among the RAM storage addresses. When there is at least one non-first storage address among the RAM storage addresses, an arbitrator can be used to determine whether there is at least one table entry information matching the data to be queried among the table entry information of the non-first storage addresses traversed and read based on the target value corresponding to each table entry information of the non-first storage addresses traversed and read.
[0057] Step 207, when there is at least one table entry information matching the data to be queried in each table entry information of the non-first storage address traversed and read, arbitration processing is performed on the target value corresponding to at least one table entry information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once.
[0058] In an embodiment of the present disclosure, when the target value corresponding to each table entry information of the non-first storage address traversed and read indicates that the corresponding table entry information matches the data to be queried, an arbitrator can be used to arbitrate the target value corresponding to at least one table entry information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once, wherein any update process may include: obtaining the second address information of at least one table entry information matching the data to be queried in the non-first storage address traversed and read and the access priority of at least one second address information in the CAM table; when the access priority of any second address information is higher than the access priority in the matching information obtained in the previous update, the arbitrator updates the matching information obtained in the previous update based on any second address information.
[0059] Step 208: Use the matching information obtained by the last update as the target matching information.
[0060] Then, the matching information obtained by the last update is used as the target matching information.
[0061] For example, after the initial matching information is generated, there is at least one non-first storage address in each storage address of the RAM, and when the table item information of the second storage address in the RAM is continuously traversed and read, the arbitrator can judge whether there is at least one table item information matching the data to be queried in each table item information of the second storage address according to the target value corresponding to each table item information of the second storage address that is continuously traversed and read. When the target value corresponding to each table item information of the second storage address indicates that the corresponding table item information matches the data to be queried, the arbitrator can be used to perform arbitration processing on the target value corresponding to at least one table item information matching the data to be queried in the second storage address that is continuously traversed and read, so as to The initial matching information is updated; and so on, until the table entry information of the last storage address is traversed and read, the arbitrator can determine whether there is at least one table entry information matching the data to be queried in the table entry information of the last storage address according to the target value corresponding to the table entry information of the last storage address. When the target value corresponding to the table entry information of the last storage address indicates that the corresponding table entry information matches the data to be queried, the arbitrator can be used to arbitrate the target value corresponding to at least one table entry information matching the data to be queried in the last storage address, so as to update the matching information obtained in the previous update, and obtain the target matching information obtained in the last update.
[0062] It should be noted that, when there is no non-first storage address in the RAM storage addresses, the initial matching information is used as the target matching information.
[0063] In addition, when there is no entry information matching the data to be queried in the table entry information of the non-first storage address that is traversed and read, the initial matching information is used as the target matching information.
[0064] In summary, initial matching information is generated by arbitrating the target values corresponding to the table item information of the first storage address traversed and read; judging whether there is a non-first storage address other than the first storage address in each storage address of the RAM; when there is at least one non-first storage address in each storage address of the RAM, judging whether there is at least one table item information matching the data to be queried in each table item information of the non-first storage address traversed and read according to the target values corresponding to the table item information of the non-first storage address traversed and read; when there is at least one table item information matching the data to be queried in each table item information of the non-first storage address traversed and read, arbitrating the target value corresponding to at least one table item information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once; taking the matching information obtained by the last update as the target matching information, thereby arbitrating the target values corresponding to the table item information in each storage address, and accurately obtaining the target matching information.
[0065] In order to clearly explain how to generate query results based on target matching information and send the query results to the client in the above embodiment, the present disclosure proposes another data query method.
[0066] Figure 3 The present invention is a flowchart of a data query method provided according to an embodiment of the present disclosure.
[0067] like Figure 3 As shown, the data query method may include the following steps:
[0068] Step 301: Receive a query request sent by a client.
[0069] The query request includes the data to be queried.
[0070] Step 302 , in response to the query request, starting from the first storage address, traverse and read the multiple table entry information to be matched in each storage address of the RAM in sequence.
[0071] Step 303 , compare each entry information in any storage address of the RAM read through the traversal with the data to be queried, and obtain the target value of the flag bit corresponding to each entry information in any storage address.
[0072] The target value of the flag bit is used to indicate whether each of the table entry information matches the data to be queried.
[0073] Step 304: arbitrate the target value corresponding to each entry information in any storage address to obtain target matching information.
[0074] The target matching information is used to indicate whether there is table entry information matching the data to be queried in the RAM.
[0075] Step 305: When the matching flag in the target matching information is the first value, the matching address and matching status in the target matching information are used as the query result.
[0076] Step 306: Send the query result to the client.
[0077] As a possible implementation method of an embodiment of the present disclosure, when the matching flag in the target matching information is a first value, the matching address and matching status in the target matching information are used as the query result, wherein the first value is used to indicate that there is table entry information in the RAM that matches the data to be queried.
[0078] As a possible implementation method of an embodiment of the present disclosure, when the matching flag in the target matching information is a second value, a prompt message is generated, wherein the second value is used to indicate that there is no table entry information matching the data to be queried in the RAM; the prompt message is used as the query result; wherein the prompt message is used to prompt that there is no table entry information matching the data to be queried in the RAM; and the query result is sent to the client.
[0079] That is to say, after traversing and reading all storage addresses in the RAM, when there is no table entry information matching the data to be queried in the multiple table entry information of all storage addresses, that is, when the matching flag is the second value, a prompt message can be generated, and the prompt message is used as the query result, and the arbitrator sends the query result to the client, wherein the prompt message is used to prompt that there is no table entry information matching the data to be queried in the RAM.
[0080] In summary, when the matching flag in the target matching information is the first value, the matching address and matching status in the target matching information are used as the query result; the query result is sent to the client, so that the client can effectively obtain the query result, and through the query result, the address and number of table item information matching the data to be queried can be accurately obtained.
[0081] In order to implement the above embodiments, the present disclosure also proposes a data query system.
[0082] Figure 4 The present invention is a schematic diagram of the structure of a data query system provided according to an embodiment of the present disclosure.
[0083] like Figure 4 As shown, the data query system includes: a RAM 410 , a read controller 420 , a matching register 430 , a comparator 440 and an arbiter 450 .
[0084] The RAM 410 is used to store table entry information to be matched, wherein the table entry information to be matched is a plurality of table entry information in the CAM table;
[0085] The read controller 420 is used to, in response to receiving the query request, start from the first storage address and sequentially traverse and read multiple table entry information to be matched in each storage address of the RAM;
[0086] A comparator 430 is used to compare each entry information in any storage address currently traversed and read with the data to be queried, and output a target value of a flag bit corresponding to each entry information in any storage address, wherein the target value of the flag bit is used to indicate whether the corresponding entry information in any storage address matches the data to be queried;
[0087] The arbitrator 440 is used to arbitrate the target value corresponding to each table item information in any storage address to obtain target matching information, and generate a query result based on the target matching information, and send the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM. In order to reduce the hardware cost of the data query system, as a possible implementation of the embodiment of the present disclosure, multiple table item information in the CAM table can be stored in the RAM 410 as the table item information to be matched.
[0088] It should be noted that the storage capacity of the RAM can be determined in advance according to the number of table entry information in the CAM table, and each storage address of the RAM can store at least one table entry information.
[0089] For example, Figure 5 As shown, the depth of RAM is m, and each storage address can store n table entry information. It should be noted that in actual applications, developers can adjust m and n according to actual needs. For example, if there are high requirements for data query latency but low requirements for hardware resource usage, then the value of n can be reduced and the value of m can be increased. Correspondingly, if the latency limit for data query is low but the hardware resource overhead is required to be as low as possible, then the value of m can be reduced and the value of n can be increased.
[0090] In order to control the cycle of data query and improve the throughput of information exchange, as a possible implementation of the embodiment of the present disclosure, a read controller may be used to respond to receiving a query request, starting from the first storage address, and sequentially traverse and read multiple table entry information to be matched in each storage address of RAM 410. Each storage address includes at least one table entry information to be matched.
[0091] In order to improve the accuracy of matching the to-be-matched table entry information in each storage address with the to-be-queried data, as an example, the data query system further includes: a matching register.
[0092] Among them, when the read controller 420 traverses multiple table entry information in any storage address of the RAM read, the read controller 420 can send the multiple table entry information in any storage address of the RAM traversed and read to the matching register, so that the matching register can store the multiple table entry information in any storage address of the RAM traversed and read. It should be noted that in order to reduce the query cost, the number of matching registers matches the number of multiple table entry information in any storage address.
[0093] Furthermore, the comparator 430 can read multiple table entry information in any storage address from the matching register, compare each table entry information in any storage address with the data to be queried, and output a target value of a flag bit corresponding to each table entry information in any storage address, wherein the target value is used to indicate whether the corresponding table entry information in any storage address matches the data to be queried.
[0094] In addition, it should be noted that, in order to reduce the data query cost, the number of comparators 440 matches the number of entry information in any storage address.
[0095] In order to improve the accuracy of the query result, as an example, the arbitrator 450 may be used to arbitrate the target value corresponding to each entry information in any storage address to obtain target matching information, thereby generating a query result based on the target matching information. The target matching information may include: a matching flag, a matching state, and a matching address.
[0096] Among them, the matching flag is used to indicate whether there is table entry information matching the data to be queried in the RAM; the matching status is used to indicate the number of table entry information matching the data to be queried in the RAM (such as single address matching, multiple address matching), and the matching address is used to indicate the address information of the table entry information with the highest access priority that matches the data to be queried in the CAM.
[0097] In summary, the table item information to be matched is stored in the RAM, wherein the table item information to be matched is multiple table item information in the CAM table. The read controller responds to the query request received, starts from the first storage address, and sequentially traverses and reads multiple table item information to be matched in each storage address of the RAM. The comparator compares each table item information in any storage address currently read with the data to be queried, and outputs the target value of the flag bit corresponding to each table item information in any storage address. The arbitrator arbitrates the target value corresponding to each table item information in any storage address to obtain the target matching information, and generates a query result based on the target matching information, and sends the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM, thereby, the CAM table Multiple table item information in the RAM is stored in the RAM, and a read controller is used to read the table item information to be matched from each storage address of the RAM in turn, and store it in a matching register that matches the number of table item information in each storage address, so that the comparator reads the table item information to be matched corresponding to each storage address from the matching register to match it with the data to be queried. It can be achieved that only the table item information read each time is stored in the matching register that matches the number of table item information read this time for comparison with the data to be queried, and there is no need to store all the table items in the matching register that is consistent with the number of all the table item information at one time for enumeration matching, thereby reducing the query cost. At the same time, when storing the table item information, the RAM does not need to compress the table item information, and the problem of long data query time caused by data compression can also be avoided.
[0098] As a possible implementation method of the embodiment of the present disclosure, when the arbitrator 440 is used to arbitrate the target value corresponding to each table entry information in any storage address to obtain the target matching information, the arbitrator 440 can arbitrate the target value corresponding to each table entry information of the first storage address traversed and read to generate initial matching information.
[0099] Furthermore, when there is at least one non-first storage address located after the first storage address in each storage address of RAM 410, the arbiter 440 is used to determine whether there is at least one table entry information matching the data to be queried in each table entry information of the non-first storage address traversed and read according to the target value corresponding to each table entry information of the non-first storage address traversed and read.
[0100] Furthermore, when there is at least one entry information matching the data to be queried in each entry information of the non-first storage address traversed and read, the arbitrator 440 is used to arbitrate the target value corresponding to at least one entry information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once.
[0101] As another example, when the target value corresponding to each entry information of the first storage address traversed and read (e.g., the target value is the first target value) indicates that there is no entry information matching the data to be queried in the entry information of the first storage address, the match flag is determined to be the second value (e.g., 0), and the match status and the match address are null values.
[0102] Furthermore, after generating the initial matching information, it can be determined whether there is at least one non-first storage address in each storage address of the RAM. When there is at least one non-first storage address in each storage address of the RAM, an arbitrator can be used to determine whether there is at least one table item information matching the data to be queried in each table item information of the non-first storage address traversed and read according to the target value corresponding to each table item information of the non-first storage address traversed and read. When the target value corresponding to each table item information of the non-first storage address traversed and read indicates that the corresponding table item information matches the data to be queried, an arbitrator can be used to arbitrate the target value corresponding to at least one table item information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once; and use the matching information obtained from the last update as the target matching information.
[0103] Among them, any update process may include: obtaining the second address information of at least one table entry information matching the data to be queried in the CAM table in a non-first storage address that is traversed and read, and the access priority of at least one second address information; when the access priority of any second address information is higher than the access priority in the matching information obtained in the previous update, the arbitrator updates the matching information obtained in the previous update based on any second address information.
[0104] As a possible implementation of the embodiment of the present disclosure, the initial matching information may include a matching flag, a matching state, and a matching address. When the matching information obtained in the previous update is updated to obtain the matching information obtained in this update, the matching flag, matching state, and matching address in the matching information obtained in the previous update may be updated. The value of the matching flag is used to indicate whether there is table entry information matching the data to be queried in the RAM, and the matching state is used to indicate the number of table entry information matching the data to be queried in the RAM.
[0105] It should be noted that, when there is no non-first storage address in the RAM storage addresses, the initial matching information is used as the target matching information.
[0106] In addition, when there is no entry information matching the to-be-queried data in each entry information of the non-first storage address that is traversed and read, the initial matching information is used as the target matching information.
[0107] As a possible implementation method of an embodiment of the present disclosure, when the matching flag in the target matching information is a first value, the matching address and matching status in the target matching information are used as the query result, wherein the first value is used to indicate that there is table entry information in the RAM that matches the data to be queried.
[0108] As a possible implementation method of an embodiment of the present disclosure, when the matching flag in the target matching information is a second value, a prompt message is generated, wherein the second value is used to indicate that there is no table entry information matching the data to be queried in the RAM; the prompt message is used as the query result; wherein the prompt message is used to prompt that there is no table entry information matching the data to be queried in the RAM; and the query result is sent to the client.
[0109] In addition, it should be noted that after traversing and reading all storage addresses in the RAM, when there is no table entry information matching the data to be queried in the multiple table entry information of all storage addresses, that is, when the matching flag is the second value, a prompt message can be generated, and the prompt message is used as the query result, and the arbitrator sends the query result to the client, wherein the prompt message is used to prompt that there is no table entry information matching the data to be queried in the RAM.
[0110] In order to explain the above embodiment more clearly, an example is now given for illustration.
[0111] For example, Figure 6 As shown, Figure 6 The present invention is a schematic diagram of the structure of a data query system provided according to an embodiment of the present disclosure.
[0112] Taking the CAM table with 8 entries as an example, each RAM storage address stores 2 matching word information, occupying a total of 4 storage addresses. Therefore, the table lookup cycle can be fixed to 4, and the data query process can be specifically as follows:
[0113] 1. In response to the received query request, traverse and read from the first storage address;
[0114] 2. Read the matching word 1 and matching word 2 in the first storage address in the RAM (each table entry information), and store the read matching word 1 into the matching register 1, and store the read matching word 2 into the matching register 2;
[0115] 3. Use a comparator to compare the data to be queried (input data) with the matching word 1 in the matching register 1 and the matching word 2 in the matching register 2. If the contents are consistent, the target value of the output flag is the first target value (1). Otherwise, the target value of the output flag is the second target value (e.g., 0).
[0116] 4. The arbitrator arbitrates the target values corresponding to the matching word 1 and the matching word 2 in the first storage address output by the comparator to obtain the initial matching information;
[0117] 5. If the RAM traversal is completed, the initial matching information is used as the target matching information, and the query result is output according to the target matching information; otherwise, the traversal continues to read the next storage address, and steps 2, 3, and 4 are repeated to update the initial matching information at least once; and the matching information obtained by the last update is used as the target matching information, and the query result is output according to the target matching information.
[0118] Among them, the target matching information includes: a matching flag, a matching status and a matching address. The matching flag can indicate whether there is table entry information matching the data to be queried in the RAM. The matching status can indicate the number of table entry information matching the data to be queried in each table entry information of each storage address of the RAM. The matching address is the address information of the table entry information with the highest access priority that matches the data to be queried in the CAM.
[0119] The data query system of the disclosed embodiment stores table item information to be matched through RAM, wherein the table item information to be matched is multiple table item information in the CAM table, and responds to the query request received through the read controller, starting from the first storage address, sequentially traverses and reads multiple table item information to be matched in each storage address of the RAM, and the comparator compares each table item information in any storage address currently traversed with the data to be queried, and outputs the target value of the flag bit corresponding to each table item information in any storage address, and arbitrates the target value corresponding to each table item information in any storage address through the arbitrator to obtain the target matching information, and generates the query result based on the target matching information, and sends the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM, thereby, Multiple table item information in the CAM table is stored in the RAM, and a read controller is used to read the table item information to be matched from each storage address of the RAM in turn, and store it in a matching register that matches the number of table item information in each storage address, so that the comparator reads the table item information to be matched corresponding to each storage address from the matching register to match it with the data to be queried. It can be achieved that only the table item information read each time is stored in the matching register that matches the number of table item information read this time for comparison with the data to be queried, and there is no need to store all the table item information at one time in the matching register that is consistent with the number of all the table item information for enumeration matching, thereby reducing the query cost. At the same time, when storing the table item information, the RAM does not need to compress the table item information, and the problem of long data query time caused by data compression can also be avoided.
[0120] In order to implement the above embodiment, the present disclosure proposes a data query device.
[0121] Figure 7 The present invention is a schematic diagram of the structure of a data query device provided according to an embodiment of the present disclosure.
[0122] like Figure 7 As shown, the data query device 700 includes: a receiving module 710 , a reading module 720 , a comparing module 730 and an arbitration module 740 .
[0123] Among them, the receiving module 710 is used to receive a query request sent by the client, wherein the query request includes the data to be queried; the reading module 720 is used to respond to the query request, starting from the first storage address, and sequentially traverse and read multiple table item information to be matched in each storage address of the RAM; the comparison module 730 is used to compare each table item information in any storage address of the RAM traversed and read with the data to be queried, and obtain the target value of the flag bit corresponding to each table item information in any storage address, wherein the target value is used to indicate whether each table item information matches the data to be queried; the arbitration module 740 is used to arbitrate the target value corresponding to each table item information in any storage address to obtain the target matching information, and generate the query result based on the target matching information, and send the query result to the client, wherein the target matching information is used to indicate whether there is table item information matching the data to be queried in the RAM.
[0124] As a possible implementation method of the embodiment of the present disclosure, the arbitration module 740 is used to arbitrate the target values corresponding to each table item information of the first storage address traversed and read to generate initial matching information; determine whether there is a non-first storage address other than the first storage address in each storage address of the RAM; when there is at least one non-first storage address in each storage address of the RAM, determine whether there is at least one table item information matching the data to be queried in each table item information of the non-first storage address traversed and read according to the target value corresponding to each table item information of the non-first storage address traversed and read; when there is at least one table item information matching the data to be queried in each table item information of the non-first storage address traversed and read, arbitrate the target value corresponding to at least one table item information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once; and use the matching information obtained by the last update as the target matching information.
[0125] As a possible implementation of the embodiment of the present disclosure, the initial matching information includes a matching flag, a matching state and a matching address, and the arbitration module 740 is specifically used to: determine whether the target value corresponding to each table item information of the first storage address indicates whether there is table item information matching the data to be queried in the multiple table item information of the first storage address; when the target value corresponding to each table item information of the first storage address indicates that there is at least one table item information matching the data to be queried in the multiple table item information of the first storage address, determine the matching flag to be the first value; obtain the first address information of at least one table item information matching the data to be queried in the CAM table and the access priority of at least one first address information from the multiple table item information of the first storage address, determine the highest access priority among the access priorities of the at least one first address information, and use the first address information in the CAM table corresponding to the highest access priority as the matching address; when the number of table item information matching the data to be queried in each table item information of the first storage address is equal to 1, determine that the matching state is a single matching state; when the number of table item information matching the data to be queried in each table item information of the first storage address is greater than 1, determine that the matching state is a multiple matching state.
[0126] As a possible implementation method of the embodiment of the present disclosure, the arbitration module 740 is specifically used to: when the target value corresponding to each table entry information of the first storage address indicates that there is no table entry information matching the data to be queried in the multiple table entry information of the first storage address, determine that the matching flag is the second value, and determine that the matching status and the matching address are null values.
[0127] As a possible implementation method of an embodiment of the present disclosure, any one of at least one updates to the initial matching information includes: obtaining the second address information in the CAM table of at least one table entry information that matches the data to be queried among multiple table entry information of non-first storage addresses that are traversed and read, and the access priority of at least one second address information; when the access priority of any second address information is higher than the access priority in the matching information obtained in the previous update, based on any second address information, updating the matching information obtained in the previous update to obtain the matching information obtained in this update.
[0128] As a possible implementation method of the embodiment of the present disclosure, the arbitration module 740 is specifically used to: when there is no non-first storage address in the storage addresses of the RAM, use the initial matching information as the target matching information; or, when there is no table entry information matching the data to be queried in the multiple table entry information of the non-first storage address traversed and read, use the initial matching information as the target matching information.
[0129] As a possible implementation method of the embodiment of the present disclosure, the arbitration module 740 is specifically used to: when the matching flag in the target matching information is a first value, use the matching address and matching status in the target matching information as the query result, wherein the first value is used to indicate that there is table entry information in the RAM that matches the data to be queried; and send the query result to the client.
[0130] As a possible implementation method of the embodiment of the present disclosure, the arbitration module 740 is specifically used to: generate prompt information when the matching flag in the target matching information is a second value, wherein the second value is used to indicate that there is no table entry information matching the data to be queried in the RAM; use the prompt information as the query result; wherein the prompt information is used to prompt that there is no table entry information matching the data to be queried in the RAM; and send the query result to the client.
[0131] The data query device of the disclosed embodiment receives a query request sent by a client, wherein the query request includes data to be queried; in response to the query request, starting from the first storage address, traverses and reads multiple table item information to be matched in each storage address of the RAM in sequence; compares each table item information in any storage address traversed and read with the data to be queried, and obtains a target value of a flag bit corresponding to each table item information in any storage address, wherein the target value is used to indicate whether each table item information matches the data to be queried; arbitrates the target value corresponding to each table item information in any storage address to obtain target matching information, generates a query result based on the target matching information, and sends the query result to the client, wherein the target matching information is used to indicate whether each table item information matches the data to be queried. Whether there is table item information matching the data to be queried, thereby, multiple table item information in the CAM table is stored in the RAM, and the table item information to be matched is read from each storage address of the RAM in turn, so as to compare each table item information traversed and read in any storage address of the RAM with the data to be queried, and it can be realized that only the table item information read each time is stored in the matching register matching the number of the table item information read this time for comparison with the data to be queried, so that there is no need to store all the table items at one time in the matching register consistent with the number of all the table item information for enumeration matching, thereby reducing the query cost. At the same time, when storing the table item information, the RAM does not need to compress the table item information, and can also avoid the problem of long data query time caused by data compression.
[0132] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and will not be repeated here.
[0133] In order to implement the above embodiments, the present disclosure also proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data query method described in the above embodiments is implemented.
[0134] In order to implement the above embodiments, the present disclosure further proposes a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the data query method described in the above embodiments is implemented.
[0135] In order to implement the above embodiments, the present disclosure further proposes a computer program product, on which a computer program is stored. When the computer program is executed by a processor, the data query method described in the above embodiments is implemented.
[0136] Figure 8 The present invention is a structural block diagram of an electronic device provided according to an embodiment of the present disclosure. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0137] like Figure 8 As shown, the electronic device 800 includes a processor 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the memory 806 to the random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processor 801, ROM 802 and RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0138] The following components are connected to the I / O interface 805: a memory 806 including a hard disk, etc.; and a communication part 807 including a network interface card such as a LAN (Local Area Network) card, a modem, etc., and the communication part 807 performs communication processing via a network such as the Internet; a drive 808 is also connected to the I / O interface 805 as needed.
[0139] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 807. When the computer program is executed by the processor 801, the above-mentioned functions defined in the method of the present disclosure are executed.
[0140] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory 806 including instructions, and the instructions can be executed by the processor 801 of the electronic device 800 to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0141] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0142] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0143] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present disclosure belong.
[0144] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0145] It should be understood that the various parts of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0146] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0147] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0148] The storage medium mentioned above may be a read-only memory, a disk or an optical disk, etc. Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations of the present disclosure. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present disclosure.
Claims
1. A data query method, characterized in that: include: Receiving a query request sent by a client, wherein the query request includes data to be queried; In response to the query request, starting from the first storage address, traverse and read the multiple table entry information to be matched in each storage address of the RAM in sequence; Compare each of the table entry information in any storage address of the RAM read through the traversal with the data to be queried, and obtain a target value of a flag bit corresponding to each of the table entry information in any of the storage addresses, wherein the target value of the flag bit is used to indicate whether each of the table entry information matches the data to be queried; The target value corresponding to each of the table entry information in any of the storage addresses is arbitrated to obtain target matching information, and a query result is generated based on the target matching information, and the query result is sent to the client, wherein the target matching information is used to indicate whether there is table entry information in the RAM that matches the data to be queried.
2. The data query method according to claim 1, characterized in that: The arbitrating the target value corresponding to each entry information in any of the storage addresses to obtain target matching information includes: Perform arbitration processing on the target value corresponding to each entry information of the first storage address read through the traversal to generate initial matching information; Determine whether there is a non-first storage address other than the first storage address among the storage addresses of the RAM; When there is at least one non-first storage address among the storage addresses of the RAM, judging whether there is at least one table item information matching the data to be queried among the table item information of the non-first storage addresses traversed and read according to the target value corresponding to each table item information of the non-first storage addresses traversed and read; In the case where there is at least one entry information matching the data to be queried in each entry information of the non-first storage address traversed and read, arbitration processing is performed on the target value corresponding to at least one entry information matching the data to be queried in the non-first storage address traversed and read, so as to update the initial matching information at least once; The matching information obtained by the last update is used as the target matching information.
3. The data query method according to claim 2, characterized in that: The initial matching information includes a matching flag, a matching state and a matching address. The target value corresponding to each entry information of the first storage address read through the traversal is arbitrated to generate the initial matching information, including: Determine whether a target value corresponding to each entry information of the first storage address indicates whether there is entry information matching the data to be queried in multiple entry information of the first storage address; When the target value corresponding to each entry information of the first storage address indicates that there is at least one entry information matching the data to be queried among the multiple entry information of the first storage address, determining that the matching flag is a first value; From multiple table entry information of the first storage address, obtain first address information of at least one table entry information matching the data to be queried in the CAM table and an access priority of at least one first address information, determine the highest access priority among the access priorities of the at least one first address information, and use the first address information in the CAM table corresponding to the highest access priority as the matching address; When the number of table entry information matching the to-be-queried data in each table entry information of the first storage address is equal to 1, determining that the matching state is a single matching state; When the number of table entry information matching the to-be-queried data in each table entry information of the first storage address is greater than 1, it is determined that the matching state is a multiple matching state.
4. The data query method according to claim 3, characterized in that: After determining whether the target value corresponding to each entry information of the first storage address indicates whether there is entry information matching the data to be queried in multiple entry information of the first storage address, the method further includes: When the target value corresponding to each entry information of the first storage address indicates that there is no entry information matching the data to be queried in the multiple entry information of the first storage address, the matching flag is determined to be a second value, and the matching status and the matching address are determined to be null values.
5. The method according to claim 2, characterized in that: Any of the at least one updates to the initial matching information includes: Obtaining second address information in the CAM table and access priority of at least one second address information of at least one table entry information matching the data to be queried among the plurality of table entry information of the non-first storage address traversed and read; When the access priority of any second address information is higher than the access priority of the matching information obtained in the previous update, the matching information obtained in the previous update is updated based on the any second address information.
6. The data query method according to claim 2, characterized in that: After determining whether there is at least one non-first storage address other than the first storage address in each storage address of the RAM, the method further includes: In the case that there is no non-first storage address in the storage addresses of the RAM, using the initial matching information as the target matching information; or, In the case that there is no entry information matching the to-be-queried data in the plurality of entry information of the non-first storage address that is traversed and read, the initial matching information is used as the target matching information.
7. The data query method according to any one of claims 1 to 6, characterized in that: The generating a query result based on the target matching information and sending the query result to the client includes: When the matching flag in the target matching information is a first value, the matching address and the matching state in the target matching information are used as the query result, wherein the first value is used to indicate that there is table entry information matching the data to be queried in the RAM; The query result is sent to the client.
8. The data query method according to any one of claims 1 to 6, characterized in that: The generating a query result based on the target matching information and sending the query result to the client includes: When the matching flag in the target matching information is a second value, generating prompt information, wherein the second value is used to indicate that there is no table entry information matching the data to be queried in the RAM; The prompt information is used as the query result; wherein the prompt information is used to prompt that there is no table entry information matching the data to be queried in the RAM; The query result is sent to the client.
9. A data query system, characterized in that: include: A random access memory RAM, used for storing table entry information to be matched, wherein the table entry information to be matched is a plurality of table entry information in a content addressable memory CAM table; A read controller, configured to respond to a query request and, starting from a first storage address, sequentially traverse and read multiple table entry information to be matched in each storage address of the RAM; A comparator, used to compare each of the table entry information in any of the storage addresses read through the traversal with the data to be queried, and output a target value of a flag bit corresponding to each of the table entry information in any of the storage addresses, wherein the target value of the flag bit is used to indicate whether the corresponding table entry information in any of the storage addresses matches the data to be queried; An arbitrator is used to arbitrate the target value corresponding to each of the table entry information in any of the storage addresses to obtain target matching information, and generate a query result based on the target matching information, and send the query result to the client, wherein the target matching information is used to indicate whether there is table entry information in the RAM that matches the data to be queried.
10. A data query device, characterized in that: include: A receiving module, used to receive a query request sent by a client, wherein the query request includes data to be queried; A reading module, used for responding to the query request, starting from the first storage address, and sequentially traversing and reading a plurality of table entry information to be matched in each storage address of the RAM; A comparison module, used for comparing each of the table entry information in any of the storage addresses read through the traversal with the data to be queried, and obtaining a target value of a flag bit corresponding to each of the table entry information in any of the storage addresses, wherein the target value of the flag bit is used to indicate whether each of the table entry information matches the data to be queried; An arbitration module is used to arbitrate the target value corresponding to each of the table entry information in any of the storage addresses to obtain target matching information, and generate a query result based on the target matching information, and send the query result to the client, wherein the target matching information is used to indicate whether there is table entry information in the RAM that matches the data to be queried.
11. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data query method described in claims 1-8.
12. A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data query method according to claims 1-8.
Citation Information
Patent Citations
Method and device for managing list item of content addressable memory CAM
CN101620623A
Data query method and device, electronic equipment and computer readable storage medium
CN114741328A
CAM table processing method and equipment
CN115048375A
