WO2008119269A1 - Method and engine device for storing and looking up information - Google Patents

Method and engine device for storing and looking up information Download PDF

Info

Publication number
WO2008119269A1
WO2008119269A1 PCT/CN2008/070143 CN2008070143W WO2008119269A1 WO 2008119269 A1 WO2008119269 A1 WO 2008119269A1 CN 2008070143 W CN2008070143 W CN 2008070143W WO 2008119269 A1 WO2008119269 A1 WO 2008119269A1
Authority
WO
WIPO (PCT)
Prior art keywords
information
keyword
hash value
storage unit
memory
Prior art date
Application number
PCT/CN2008/070143
Other languages
French (fr)
Chinese (zh)
Inventor
Rui Hu
Shijun Shen
Meng Li
Zhenhua Xu
Original Assignee
Huawei Technologies Co., Ltd.
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co., Ltd. filed Critical Huawei Technologies Co., Ltd.
Publication of WO2008119269A1 publication Critical patent/WO2008119269A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/35Switches specially adapted for specific applications
    • H04L49/351Switches specially adapted for specific applications for local area network [LAN], e.g. Ethernet switches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9014Indexing; Data structures therefor; Storage structures hash tables
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing

Definitions

  • the present invention relates to the field of communications and database storage, and in particular, to a method for storing information, searching, and an engine device. Background technique
  • the hash-based search method mainly maps a long-length key (keyword) to a shorter-length space according to a certain mapping relationship (hash function), for example, using a hash function to 32bit.
  • the (bit) IP (Internet Protocol) address is mapped to the 20-bit address space (1M).
  • This method has a wide range of applications in fixed length lookups.
  • the hash value of the key value is obtained to obtain the corresponding hash address, and the corresponding subsidiary information can be obtained.
  • the two pieces of information may need to be stored in an address, which creates a collision.
  • the information corresponding to the key value forms a conflicting entry, which brings great difficulty to information storage and searching.
  • FIG. 1 it is a schematic diagram of a linked list storage method in the prior art.
  • the method uses a linked list storage method to store conflicting entries in a hashed list.
  • the received keyword to be searched is hashed to obtain a hash value for finding the hash table.
  • a pointer to the linked list with the conflicting entry is obtained, and then the pointer is used to access the hashed list, and then the hashed list needs to be traversed to find the required information.
  • FIG. 1 it is a schematic diagram of a linked list storage method in the prior art.
  • the method uses a linked list storage method to store conflicting entries in a hashed list.
  • the received keyword to be searched is hashed to obtain a hash value for finding the hash table.
  • From the hash table a pointer to the linked list with the conflicting entry is obtained, and then the pointer is used to access the hashed list, and then the hashed list needs to be traversed to find the required information.
  • the hash table entry 0 The pointer points to a hash list, the length of the hash list is 1, indicating a conflict-free entry; and the table entry X pointer of the hash table points to a hash list, the length of the hash list is 3, indicating that There are 3 conflicting entries in the entry X.
  • the search information requires multiple memory accesses, and high-speed search cannot be realized.
  • Fig. 2 it is a schematic diagram of the multi-hash function method used in the prior art.
  • the method uses multiple hash functions to hash the keywords to be searched, and then reads the information into the corresponding multiple hash tables for searching.
  • the first hash value is calculated using the first hash function to obtain the first hash value, if the position of the hash table corresponding to the first hash value (which may be referred to as the first hash table) is not
  • the table item that is, when there is no conflict, the corresponding information is stored in the position, and no other hash function is used for calculation; if there is a conflict in the position, the second hash function is used to recalculate the keyword.
  • the second hash value is used.
  • the corresponding information is stored in the location, and the information storage ends; Otherwise, you need to continue to use other hash functions for calculations until there is no conflict.
  • the information search multiple hash functions are used to calculate the keywords, and at the same time, the corresponding information is obtained, and after comparing with the keywords to be searched, the corresponding information is found.
  • the less the hash table needs to be stored the less the table entry information needs to be stored. For example, the second hash table needs to store less entry information than the first hash table needs to store.
  • each hash table can be reduced step by step.
  • This method uses multiple hash functions to offset the randomness of the information distribution, which can effectively reduce the probability of collisions.
  • high memory bandwidth is required, which brings great difficulties to hardware design.
  • FIG. 3 it is a schematic diagram of a CAM-based search in the prior art, and a logic controller can Is a logic device or dedicated CPU (Central Processing Unit) provides the CAM with the keyword to be searched.
  • the CAM searches through the hardware in parallel according to the keyword, outputs the memory address of the corresponding information, and then according to the address
  • the attached external information is returned to the logic controller in the corresponding external memory. This allows the required information to be obtained with only one memory read operation.
  • CAM-based methods are used in a large number of existing communication devices, especially routers.
  • large-capacity CAM chips cannot be fabricated, and a large amount of data information, such as 32b i t information larger than 1M, cannot currently be stored.
  • the cost and power consumption of the CAM chip are greatly increased as the capacity increases.
  • an embodiment of the present invention provides a method for storing information, including: receiving information to be stored, where a keyword of the information to be stored is m bits (m is a natural number); using the first hash function to The keyword to be stored is hashed to obtain first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, And 1 ⁇ 111);
  • the other (m ⁇ n ) bit information in the first mapping information is used as the first compression keyword, together with the to-be-stored
  • the attached information of the information is stored together in a storage unit corresponding to the first hash value in the first memory.
  • the embodiment of the invention further provides an engine device, including:
  • a logic controller configured to receive information to be stored, where the keyword of the information to be stored is m bits (m is a natural number), and the keyword of the information to be stored is hashed by using a first hash function to obtain a first a mapping information, the first mapping information is m bits, and n bits in the first mapping information Information as the first hash value (n is a natural number, and 1 ⁇ 111);
  • a first memory when the storage unit corresponding to the first hash value is idle, used to use other (m - n ) bit information in the first mapping information as the first compression keyword, together with the waiting
  • the attached information storing the information is stored together in the storage unit corresponding to the first hash value.
  • an embodiment of the present invention provides a method for searching for information, including:
  • the keyword is m bits (m is a natural number);
  • Searching the first memory according to the first hash value acquiring keyword information in a storage unit corresponding to the first hash value, and comparing the keyword information with the keyword to determine the When the storage unit corresponding to the first hash value corresponds to the keyword, the information in the storage unit corresponding to the first hash value is acquired.
  • the embodiment of the invention further provides another method for searching for information, including:
  • the keyword is m bits (m is a natural number);
  • the first hash information is obtained by hashing the key row by using a first hash function, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value. (n is a natural number, and n is less than m),
  • an embodiment of the present invention provides an engine apparatus, including:
  • a first memory for storing information
  • a logic controller configured to receive a keyword to be searched, the keyword is m bits (m is a natural number), and the first hash function is used to perform hash operation on the keyword to be searched to obtain first mapping information.
  • the first mapping information is m bits, and the n-bit information in the first mapping information is used as a first hash value (n is a natural number, and n is less than m); searching according to the first hash value.
  • a memory the keyword information in the storage unit corresponding to the first hash value is obtained, and the keyword information is compared with the keyword to determine the storage corresponding to the first hash value And when the unit corresponds to the keyword, acquiring information in the storage unit corresponding to the first hash value.
  • Another embodiment of the present invention provides an engine device, including:
  • a content address storage for storing information
  • a first memory for storing information
  • a logic controller configured to receive a keyword to be searched, the keyword is m bits (m is a natural number), and the content address memory is searched according to the keyword, and the keyword is hashed by using a first hash function Computing, the first mapping information is obtained, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m); Obtaining information in the storage unit corresponding to the keyword when the storage unit corresponding to the keyword is found in the content address memory; when the keyword is not found in the content address memory And searching for the first memory according to the first hash value, acquiring keyword information in the storage unit corresponding to the first hash value, using the keyword information and the keyword And comparing, when determining that the storage unit corresponding to the first hash value corresponds to the keyword, acquiring information in the storage unit corresponding to the first hash value.
  • the solution provided by the embodiment of the present invention does not store the complete keyword, but uses a keyword compression scheme, that is, the keyword is hashed, compressed into fewer bits, and then stored, so that the same bit width memory can be stored.
  • the number of entries increases, which improves space utilization, reduces memory capacity requirements, and saves costs; it also reduces the probability of collisions.
  • the engine device can store more information, that is, increase the capacity of the engine device.
  • the solution provided by the embodiment of the present invention can simplify the process of information searching and information storage, and is convenient for quick searching and information maintenance.
  • the solution of the embodiment of the content address memory can solve the conflict problem caused by the hash operation, and the keyword compression scheme can reduce the capacity requirement of the content address memory and save costs.
  • FIG. 1 is a schematic diagram of a linked list storage method in the prior art
  • FIG. 2 is a schematic diagram of a multi-hash function method in the prior art
  • FIG. 3 is a schematic diagram of a CAM-based search in the prior art
  • FIG. 4 is a schematic structural view of an engine device in an embodiment of the present invention.
  • FIG. 5 is a flow chart of information storage by an engine device in an embodiment of the present invention.
  • Figure 6 is a flow chart showing the information search by the engine device in one embodiment of the present invention. detailed description
  • An embodiment of the present invention provides an engine apparatus, including a logic controller and a first memory, where the logic controller is configured to receive information to be stored, where the key of the information to be stored is m bits (m is a natural number),
  • the first hash information is hashed by using the first hash function to obtain the first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value ( n is a natural number, and n is smaller than m); when the storage unit in the first memory corresponding to the first hash value is idle, the other (m - n ) bit information in the first mapping information is used as the first compression keyword
  • the auxiliary information along with the information to be stored is stored in the storage unit corresponding to the first hash value.
  • the logic controller when performing information search, receives the keyword to be searched, the keyword is m bits (m is a natural number), and hashes the keyword to be searched by using the first hash function.
  • the first memory obtains keyword information in a storage unit corresponding to the first hash value, and compares the keyword information with the keyword to be searched to determine a storage unit corresponding to the first hash value and the to-be-searched When the keyword is corresponding, the information in the storage unit corresponding to the first hash value is obtained.
  • the keyword information is compared with the keyword to be searched to determine whether the storage unit corresponding to the first hash value corresponds to the keyword to be searched, and there are multiple implementation manners, for example:
  • the other (m - n ) bit information in the mapping information is used as the first compression keyword; comparing the keyword information with the first compression keyword, when the two are the same, determining the storage unit and the corresponding to the first hash value
  • the keywords that are found correspond.
  • the keyword information is combined with the first hash value to obtain a complete keyword, and compared with the keyword to be searched. When the two are the same, the storage unit corresponding to the first hash value is determined to be searched. The corresponding keyword.
  • the above logic controller may include: a first hash unit and a logic unit.
  • the first hash unit performs a hash operation on the keyword of the information to be stored, to obtain the first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first
  • the logical unit receives the first hash value, determines whether the storage unit in the first memory corresponding to the first hash value is idle or occupied, and notifies the first when the storage unit corresponding to the first hash value is idle.
  • the memory stores the first compressed keyword and the attached information of the information to be stored, wherein the first compressed keyword is other (m - n ) bit information in the first mapping information.
  • the engine device may further include: a second memory, correspondingly, the logic controller further includes a second hash unit, when the storage unit in the first memory corresponding to the first hash value is occupied
  • the second hash unit performs a hash operation on the keyword to be stored, to obtain second mapping information, where the second mapping information is m bits, and the t-bit information in the second mapping information is used as the second hash value (t Is a natural number, and t is less than m);
  • the logic unit receives the second hash value, and determines whether the memory cell in the second memory corresponding to the second hash value is idle or occupied, when the memory cell corresponding to the second hash value When idle, the second memory is notified to store the second compressed keyword and the attached information to be stored.
  • Generic information wherein the second keyword is other (m - t) bit information in the second mapping information.
  • the engine apparatus further includes a content address memory for storing a key of the information to be stored and to be stored when a storage unit in the first memory corresponding to the first hash value is occupied
  • the attached information of the information is stored in a free storage unit in the content address memory.
  • the logic controller when performing information search, receives the keyword to be searched, the keyword is m bits (m is a natural number), and the content address memory is searched according to the keyword; meanwhile, the first hash function is used to pair the keyword Performing a hash operation to obtain first mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is smaller than m).
  • the storage unit corresponding to the keyword When the storage unit corresponding to the keyword is found in the content address storage, acquiring information in the storage unit corresponding to the keyword; when the storage unit corresponding to the keyword is not found in the content address storage, according to the first
  • the hash value is searched for the first memory, and the keyword information in the storage unit corresponding to the first hash value is obtained, and the keyword information is compared with the keyword to be searched to determine the storage unit corresponding to the first hash value.
  • information in the storage unit corresponding to the first hash value is obtained.
  • using the keyword information to compare with the keyword to be searched determining whether the storage unit corresponding to the first hash value corresponds to the keyword to be searched, there are multiple implementation manners, where No longer.
  • the engine device includes a content address memory, and further includes a second memory.
  • the logic controller further includes a second hash unit.
  • the second hash unit performs a hash operation on the keyword of the information to be stored to obtain second mapping information, where the second mapping information is m bits, the t-bit information in the second mapping information is taken as the second hash value (t is a natural number, and t is less than m); the logic unit receives the second hash value, and determines the second corresponding to the second hash value
  • the storage unit in the memory is idle or occupied.
  • the second memory When the storage unit corresponding to the second hash value is idle, the second memory is notified to store the second compressed keyword and the auxiliary information of the information to be stored, where the second compressed keyword is Other (m - t ) bit information in the second mapping information; and when the memory cell in the second memory corresponding to the second hash value is occupied, the content address memory will be the key of the information to be stored.
  • the words and the attached information of the information to be stored are stored in an idle storage unit.
  • the first memory and the second memory are not limited to the on-chip memory or the off-chip memory.
  • FIG. 4 is a schematic structural diagram of an engine apparatus in an embodiment of the present invention, which comprises a logic controller 120, a CAM unit 123, and an off-chip memory 134.
  • the logic controller 120 is composed of a logic unit 122, a plurality of hash units 121a and 121b, and an on-chip memory 131.
  • the CAM unit 123 includes a CAM chip 133 and a CAM memory 132.
  • the logic controller 120 can be implemented by using an ASIC (Application Specific Integrated IC) or an FPGA (Field Programmable Gatec Array);
  • the external memory 134 can be implemented using a DRAM (Dynamic Random Accs s Memory); the CAM memory 132 can be an SRAM (Sta tic Random Acces s Memory).
  • the information lookup includes the following process:
  • the logic controller 120 receives the key (key) to be searched and distributes it to each hash unit and logic unit through the data bus 111;
  • the logic unit After receiving the keyword to be searched, the logic unit sends the keyword to the CAM unit 123 for searching through the data bus 115. If the CAM unit 123 finds the information corresponding to the keyword, the CAM memory 132 returns the information to the logic unit 122. At this time, the logic unit 122 no longer uses the calculation result of each hash unit to access the corresponding memory; if the CAM unit 123 does not find the required information, the B' J logic unit 122 respectively according to the calculation result of each hash unit.
  • the corresponding keyword and the auxiliary information are read on the memory corresponding to each hash unit, and the information is returned to the logical unit 122 through the data bus 117, and the logical unit 122 compares the keyword in the information with the keyword to be searched, if If the keyword of the information is found to be the same as the keyword to be searched, the auxiliary information is obtained from the memory corresponding to the same keyword as the keyword to be searched and returned to the logical unit.
  • the keyword to be found It is 32 bits
  • the affiliate information is 20 bits
  • the database to be checked contains 1M entry.
  • the data bus 1 11 is 32 bits
  • 112a is 20 bits
  • 114 is 20 bits
  • 112b has a number of bits less than 112a
  • 1 12b can be set to 15 bits.
  • the hash table corresponding to the hash unit 121a is stored in the off-chip memory 134, the memory space of the off-chip memory is 1M, and the data bit width is 128 bits. Since the hash unit uses the hash function to map the keyword information of 32b it to the address space (1M) of 20b it, that is, the hash unit 121a hashes the 32-bit keyword information to obtain a 32-bit.
  • the mapping information, the 20-bit information in the 32-bit mapping information is used as the first hash value, and the other 12-bit information is stored as the compression key in the off-chip memory 134. This process is called a keyword. compression.
  • the keyword information in the off-chip memory 134 can be used to obtain complete keyword information.
  • the logic unit 122 retrieves the 32-bit information, it is only necessary to combine the hash function used to obtain the complete keyword, as compared with the key to be searched, as shown in Table 1.
  • one storage unit can store four entries, as shown in Table 2.
  • Table 2 Table storage structure in a storage unit with a bit width of 128 bits
  • a storage unit can store 4 conflicting entries, so that even if 4 conflicts occur, all the entries can be obtained in one read, and a fast search can be realized. Since the probability of occurrence of more than 4 collisions in a storage space is relatively small, the remaining unstorable rushes The number of items is relatively small, which is much less likely to be compared with the way of storing 4M entries using 4M 32-bit storage. In addition, by keyword compression, the size of information to be stored in an entry is reduced. The 1M entry can be stored using 128M space, and all key information is stored. The same storage mode requires 512M of storage space. , space utilization is much higher.
  • the above expression simply uses a hash function that uses a storage unit to store entries. Because the distribution of information is random, and a hash function is a fixed format, there may be a large number of conflicts in some information distribution situations. If these conflicting entries are stored in the CAM unit, the space of the CAM unit is required. Large, the cost will be 4 ⁇ high. To this end, the multi-hash function method can be used to offset the effects of randomness of information distribution. In order not to increase the number of off-chip memories, it is considered that the number of conflicting entries of the off-chip memory has been relatively small, so the on-chip memory 1 31 in the logic controller 120 is used to store the hash table corresponding to the hash unit 121 b. .
  • 32 ⁇ 32-bit on-chip memory 1 31 can be used to store a hash table, which is available for existing logic devices.
  • the hash function used by the hash unit 121 b is selected as far as possible from the hash function used by the hash unit 121 a to reduce the probability of collision occurring. This can effectively reduce the probability of collisions and effectively utilize the memory space.
  • one off-chip memory and one on-chip memory shown in FIG. 4 are only an example. In the logic controller 120, there may be only one memory, not limited to on-chip or off-chip, or multiple memories. When there are multiple memories, there are multiple hash tables.
  • on-chip memory In some cases, a large amount of on-chip memory is required to implement storage of all conflicting entries, and on-chip memory resources are very limited. Therefore, for example, in the case where the number of conflicting entries is small, a CAM with a smaller capacity can be used. The unit stores the remaining conflicting entries. This effectively reduces the need for on-chip memory and resolves the problems that conflicts pose to lookups.
  • IK X 32-bit CAM chip 1 33 and 1K ⁇ 20-bit CAM memory 1 32 can be used to store keywords and ancillary information, respectively.
  • a method for information storage is provided, the process is as follows: receiving information to be stored, the keyword of the information to be stored is m bits (m is a natural number); using the first hash function to store information The keyword is hashed to get the first map Information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m);
  • the other (m ⁇ n ) bit information in the first mapping information is stored as the first compression key together with the auxiliary information of the information to be stored.
  • Within the first memory is in a memory location corresponding to the first hash value.
  • the keyword of the information to be stored is hashed by using the second hash function, to obtain the second mapping information,
  • the second mapping information is m bits, and the t bit information in the second mapping information is used as the second hash value (t is a natural number, and t is less than m);
  • the second compressed keyword and the auxiliary information of the information to be stored are stored in a storage unit corresponding to the second hash value in the second memory, where the second compressed keyword is the other of the second mapping information ( m - t ) bit information.
  • the second hash function is used to hash the keyword to be stored, to obtain the second mapping information, and the second mapping information is m bits,
  • the t-bit information in the second mapping information is used as the second hash value (t is a natural number, and t is less than m);
  • the second compressed keyword is And the auxiliary information of the information to be stored is stored in a storage unit corresponding to the second hash value in the second memory, where the second compressed keyword is other (m ⁇ t ) bit information in the second mapping information;
  • the stored item is less than 1M item
  • step 51 1 the logic controller 120 receives the store instruction and the information to be stored, and then transmits it to the hash unit 121a through the data bus;
  • step 512 the hash unit 121a performs an operation using the first hash function to obtain a first hash value and sends it to the logic unit 122 via the data bus 112a;
  • step 51 3 the logic unit 122 correspondingly searches for the storage unit in the off-chip memory 134 according to the first hash value, and finds the storage unit corresponding to the first hash value, and takes Table 2 as an example, which is 4 tables. A total of 128 items;
  • step 514 it is determined whether the storage unit corresponding to the first hash value has a free space (collision table entry ⁇ 4). If there is free space, then in step 515, the logic unit 122 is based on the first hash of the hash unit 121a. The function compresses the keyword;
  • step 516 the logic unit 122 puts the compressed keyword and the auxiliary information into the free space in the storage unit corresponding to the first hash value, stores it in the off-chip memory 134, and then proceeds to step 523 to wait for other instructions. .
  • step 514 if there is no free space (collision table entry > 4), then step 517 is entered, that is, the hash unit 121 b receives the storage instruction and the corresponding information, and the second hash value is calculated by the second hash function and sent.
  • the logic unit 122 searches the on-chip memory 1 31 for the memory location (32 bits) corresponding to the second hash value according to the second hash value.
  • step 519 it is determined whether the storage unit has valid entry information. If not, that is, idle, then in step 520, the logic unit 122 compresses the keyword according to the second hash function of the hash unit 121b. In step 521, the logic unit 122 places the compressed keyword and the attached information into the storage unit, and then proceeds to step 523 to wait for other instructions. In step 519, if a conflict occurs, the logic unit stores the keyword information and the affiliate information in the CAM unit 123. At this point, the information storage process ends, and the flow proceeds to step 523 to wait for other instructions.
  • an embodiment of the present invention also provides a method for information searching, and the process is as follows: Receiving the keyword to be searched, the keyword is m bits (m is a natural number);
  • the first hash information is hashed by using the first hash function to obtain first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m);
  • Searching the first memory according to the first hash value acquiring keyword information in the storage unit corresponding to the first hash value, comparing the keyword information with the keyword to be searched, and determining, corresponding to the first hash value, When the storage unit corresponds to the keyword to be searched, the information in the storage unit corresponding to the first hash value is obtained.
  • the keyword information is compared with the keyword to be searched to determine whether the storage unit corresponding to the first hash value corresponds to the keyword to be searched.
  • the process of information lookup is slightly different, including:
  • the keyword to be searched is m bits (m is a natural number);
  • the first hash information is hashed by using the first hash function to obtain the first mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number) And n is less than m); when the storage unit corresponding to the keyword to be searched is found in the content address memory, the information in the storage unit corresponding to the keyword is obtained; when the search is not found in the content address memory Searching for the first storage unit according to the first hash value, obtaining keyword information in the storage unit corresponding to the first hash value, and comparing the keyword to be searched using the keyword information, When it is determined that the storage unit corresponding to the first hash value corresponds to the keyword to be searched, the information in the storage unit corresponding to the first hash value is obtained.
  • FIG. 6 it is a flowchart of the information search by the engine device in one embodiment of the present invention. Referring to the structural diagram of the engine device in FIG. 4, the information search process is as follows:
  • step 611 the logic controller 120 receives the lookup instruction and the to-be-checked key and transmits them to the hash unit 121a, the hash unit 121b, and the CAM unit 123 via the data buses 111 and 115.
  • step 612 after the CAM unit 123 receives the to-be-checked keyword, the CAM chip 133 performs a parallel search according to the keyword.
  • the address is output to the CAM memory 132, and the CAM memory 132 returns the auxiliary information; If the chip 133 does not find the matching information, it does not return any value to the logical unit; in steps 613 and 614, the two hash units perform a hash calculation outputting a hash value according to the to-be-checked keyword, and the hash value passes through the data bus 112a and 112b is output to the logic unit 122;
  • the logic unit 122 collects the CAM search result and the operation result of the two hash units, wherein the CAM unit 123 searches for the result, that is, the return value has the highest priority. If the CAM unit 123 has a return value, the value is used as the return value. Ancillary information. If the CAM unit 123 has no return value, the hash unit is used to calculate the result to the corresponding memory to obtain the keyword information and the attached information. Each hash unit is a parallel lookup, and all hash calculations and memory accesses are done in parallel, with no priority.
  • step 616 the logic unit 122 determines whether the CAM unit 123 has a return value. If so, indicating that the CAM unit finds the information to be checked, then in step 617, the CAM search result is used as the returned affiliate information. At this point, proceed to step 624, waiting for other instructions to arrive;
  • step 616 if the CAM unit 123 has no return value, indicating that the CAM unit has not found the information to be checked, then in step 618, the result of the hash operation is used to obtain the keyword information and the attached information in the corresponding memory.
  • step 619 logic unit 122 compresses the keywords based on the hash functions of all of the hash units.
  • step 620 logic unit 122 compares the computed compression key with the key information retrieved from each memory. In step 621, it is determined whether or not they are consistent. If they match, in step 622, the attached information stored in the storage unit in which the keyword matching the compressed keyword is stored is returned. At this point, the process proceeds to step 624, waiting for other commands to arrive.
  • step 621 if it is inconsistent, it indicates that the keyword information to be searched for does not exist, then the "no match" information is returned in step 623, and then proceeds to step 624, waiting for other instructions to arrive, and the entire search process ends.
  • Corresponding software in the embodiments of the present invention may be stored in a computer readable storage medium.
  • the solution in the embodiment of the present invention has been subjected to multiple simulation tests in a computer, and the verification operation is reliable and feasible.
  • the solution provided by the embodiment of the present invention does not store the complete keyword, but uses a keyword compression scheme, that is, the keyword is hashed, compressed into fewer bits, and then stored, so that the same bit width memory can be stored.
  • the number of entries increases, which improves space utilization, reduces memory capacity requirements, and saves costs; it also reduces the probability of collisions.
  • the engine device can store more information, that is, increase the capacity of the engine device.
  • the solution provided by the embodiment of the present invention can simplify the process of information searching and information storage, and is convenient for quick searching and information maintenance.
  • the solution of the embodiment of the content address memory can solve the conflict problem caused by the hash operation, and the keyword compression scheme can reduce the capacity requirement of the content address memory and save costs.

Abstract

A method for storing information is disclosed, including: receive information to be stored, which has a key consisting of m bits (where m is a natural number); a first hash function is used to perform hash operation of the key of the information to be stored, so as to result in a first mapped information consisting of m bits, then n bits of information in the first mapped information is used as a first hash value (where n is a natural number, and n<m); when a storage unit of a first storage corresponding to the first hash value is free, the other (m-n) bits of information in the first mapped information is used as a first compressed key, and store the first compressed key and additional information of the information to be stored in the corresponding storage unit. A method for looking up information and an engine device are also disclosed.

Description

信息存储、 查找的方法及引擎装置 技术领域  Information storage, search method and engine device
本发明涉及通信领域和数据库存储领域, 尤其涉及一种信息存储、 查找 的方法及引擎装置。 背景技术  The present invention relates to the field of communications and database storage, and in particular, to a method for storing information, searching, and an engine device. Background technique
现在, 越来越多的系统需要在大量的数据信息中快速查找所需要的信息, 例如, 在数据通信领域, 需要查找各种转发表的核心路由器就属于这样的系 统。 使用硬件实现查找是最常用的选择。  Nowadays, more and more systems need to quickly find the required information in a large amount of data information. For example, in the field of data communication, the core routers that need to find various forwarding tables belong to such a system. Using hardware to implement lookups is the most common choice.
目前, 对于定长信息的查找一般有两种实现方式: 基于哈希的方法和基 于 CAM (Content Address Memory, 内容地址存储器) 的方法。  Currently, there are generally two implementations for finding fixed-length information: a hash-based method and a CAM (Content Address Memory)-based method.
基于哈希的查找方法主要是将某一长度较长的 key (关键字)按照某种映 射关系 (哈希函数), 映射到较短长度的空间上进行存储, 例如, 使用哈希函 数将 32bit (位)的 IP ( Internet Protocol, 因特网协议)地址映射到 20bit 的地址空间(1M)。这种方法在定长查找中有广泛的应用。 当添加某一信息时, 对该信息的 key进行哈希运算, 即 f (key)=h, 其中, f ()是特定的哈希函数, key是需要存储信息的关键字, h则是信息存储的哈希地址, 该地址对应存储 空间的第 h个存储单元, 把该 key值以及该 key值对应的附属信息都存入该 地址。 这样在查找时, 对 key值进行哈希(hash)运算获取相应的 hash地址 就可以取得对应的附属信息。 但是, 当两个 key值进行 hash运算后得到同样 哈希值时, 即 f (keyl ) =f (key2), 两条信息可能需要存入一个地址, 这就 产生了冲突(collision), 这两个 key值对应的信息就形成冲突表项, 给信 息存储和查找带来了很大困难。  The hash-based search method mainly maps a long-length key (keyword) to a shorter-length space according to a certain mapping relationship (hash function), for example, using a hash function to 32bit. The (bit) IP (Internet Protocol) address is mapped to the 20-bit address space (1M). This method has a wide range of applications in fixed length lookups. When a certain information is added, the key of the information is hashed, that is, f (key)=h, where f () is a specific hash function, key is a keyword that needs to store information, and h is information. The stored hash address corresponding to the hth storage unit of the storage space, and the key value and the attached information corresponding to the key value are stored in the address. In this way, when searching, the hash value of the key value is obtained to obtain the corresponding hash address, and the corresponding subsidiary information can be obtained. However, when the two key values are hashed and the same hash value is obtained, that is, f (keyl ) = f (key2), the two pieces of information may need to be stored in an address, which creates a collision. The information corresponding to the key value forms a conflicting entry, which brings great difficulty to information storage and searching.
为了解决上述冲突问题, 现在有几种方法: 例如, 链表存储法、 多哈希 函数法, 以及基于 CAM的方法。 如图 1 所示, 是现有技术中釆用链表存储法的示意图。 该方法釆用链表 存储法将冲突表项存入哈希链表中。 当查找信息时, 将接收到的要查找的关 键字进行哈希运算得到哈希值, 用于查找哈希表。 从哈希表得到指向存有冲 突表项的链表的指针, 再使用该指针访问哈希链表, 然后需要遍历哈希链表 来查找需要的信息, 例如, 图 1中, 哈希表的表项 0指针指向 1个哈希链表, 该哈希链表的长度为 1 ,说明无冲突表项; 而哈希表的表项 X指针指向 1个哈 希链表, 该哈希链表的长度为 3 , 说明该表项 X处有 3个冲突表项。 釆用链表 存储法, 在恶劣情况下, 如图中的表项 X , 查找信息需要艮多次存储器访问, 无法实现高速查找。 In order to solve the above conflict problem, there are several methods: for example, the linked list storage method, the multi-hash function method, and the CAM-based method. As shown in FIG. 1, it is a schematic diagram of a linked list storage method in the prior art. The method uses a linked list storage method to store conflicting entries in a hashed list. When the information is found, the received keyword to be searched is hashed to obtain a hash value for finding the hash table. From the hash table, a pointer to the linked list with the conflicting entry is obtained, and then the pointer is used to access the hashed list, and then the hashed list needs to be traversed to find the required information. For example, in FIG. 1, the hash table entry 0 The pointer points to a hash list, the length of the hash list is 1, indicating a conflict-free entry; and the table entry X pointer of the hash table points to a hash list, the length of the hash list is 3, indicating that There are 3 conflicting entries in the entry X. In the case of a bad case, in the case of the table item X in the figure, the search information requires multiple memory accesses, and high-speed search cannot be realized.
如图 2 所示, 是现有技术中釆用多哈希函数法的示意图。 在信息存储过 程中, 该方法釆用多个哈希函数对要查找的关键字进行哈希运算后, 到对应 的多个哈希表中读取信息进行查找。 当进行信息存储时, 使用第一个哈希函 数对关键字进行计算得到第一哈希值, 如果第一哈希值对应的哈希表(可以 称为第一哈希表) 中的位置没有表项, 即无冲突时, 则将相应信息存入该位 置, 不必再用其它的哈希函数进行计算; 如果该位置存在冲突时, 则使用第 二个哈希函数对关键字进行再计算得到第二哈希值, 同样的, 如果第二哈希 值对应的哈希表(可以称为第二哈希表) 中的位置无冲突时, 则将相应信息 存入该位置, 信息存储结束; 否则, 需要继续使用其它哈希函数进行计算, 直到无冲突时。 而在信息查找时, 使用多个哈希函数对关键字进行计算, 同 时获取对应信息, 和待查找的关键字进行比较后, 找到相应的信息。 另外, 顺序越在后边的哈希表需要存储的表项信息越少, 例如, 第二哈希表需要存 储的表项信息少于第一哈希表需要存储的表项信息。 所以, 为了提高存储空 间的利用率, 各个哈希表可以逐级减小。 这种方法使用多个哈希函数来抵消 信息分布的随机性, 能够有效减少冲突发生的概率。 但是, 需要高的存储器 带宽, 这给硬件设计带来的很大困难。  As shown in Fig. 2, it is a schematic diagram of the multi-hash function method used in the prior art. In the information storage process, the method uses multiple hash functions to hash the keywords to be searched, and then reads the information into the corresponding multiple hash tables for searching. When the information is stored, the first hash value is calculated using the first hash function to obtain the first hash value, if the position of the hash table corresponding to the first hash value (which may be referred to as the first hash table) is not The table item, that is, when there is no conflict, the corresponding information is stored in the position, and no other hash function is used for calculation; if there is a conflict in the position, the second hash function is used to recalculate the keyword. The second hash value. Similarly, if there is no conflict in the position in the hash table corresponding to the second hash value (which may be referred to as the second hash table), the corresponding information is stored in the location, and the information storage ends; Otherwise, you need to continue to use other hash functions for calculations until there is no conflict. In the information search, multiple hash functions are used to calculate the keywords, and at the same time, the corresponding information is obtained, and after comparing with the keywords to be searched, the corresponding information is found. In addition, the less the hash table needs to be stored, the less the table entry information needs to be stored. For example, the second hash table needs to store less entry information than the first hash table needs to store. Therefore, in order to improve the utilization of storage space, each hash table can be reduced step by step. This method uses multiple hash functions to offset the randomness of the information distribution, which can effectively reduce the probability of collisions. However, high memory bandwidth is required, which brings great difficulties to hardware design.
如图 3所示, 是现有技术中基于 CAM的查找示意图, 逻辑控制器, 可以 是逻辑器件或专用 CPU ( Cent ra l Proce s s ing Uni t , 中央处理单元) 向 CAM 提供要查找的关键字, CAM根据关键字通过硬件并行查找,输出对应信息的存 储器地址, 然后根据该地址从对应的外部存储器中返回附属信息到逻辑控制 器中。 这样只用一次存储器读取操作即可获得需要的信息。 As shown in FIG. 3, it is a schematic diagram of a CAM-based search in the prior art, and a logic controller can Is a logic device or dedicated CPU (Central Processing Unit) provides the CAM with the keyword to be searched. The CAM searches through the hardware in parallel according to the keyword, outputs the memory address of the corresponding information, and then according to the address The attached external information is returned to the logic controller in the corresponding external memory. This allows the required information to be obtained with only one memory read operation.
正是因为 CAM查找的快速性, 基于 CAM的方法在现有的通讯设备中, 尤 其是路由器中被大量应用。 但是由于工艺的约束, 不能够制作大容量的 CAM 芯片, 对于大量的数据信息, 例如大于 1M的 32b i t信息, 目前不能够存储。 另外, CAM芯片的成本和功耗随着容量的增加而大幅提高。  Because of the rapidity of CAM lookups, CAM-based methods are used in a large number of existing communication devices, especially routers. However, due to process constraints, large-capacity CAM chips cannot be fabricated, and a large amount of data information, such as 32b i t information larger than 1M, cannot currently be stored. In addition, the cost and power consumption of the CAM chip are greatly increased as the capacity increases.
从上面描述的多种现有技术方案可以看出, 目前迫切需要一种性能较好 的信息存储和信息查找方案, 来实现大型数据库信息的存储, 以及信息的快 速查找。 发明内容  As can be seen from the various prior art solutions described above, there is an urgent need for a better performance information storage and information search scheme to realize storage of large database information and rapid search of information. Summary of the invention
基于上述分析, 本发明实施例提供了一种信息存储的方法, 包括: 接收待存储信息, 所述待存储信息的关键字为 m位( m是自然数); 利用第一哈希函数对所述待存储信息的关键字进行哈希运算, 得到第一 映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位信息作 为第一哈希值(n是自然数, 且1 <111 );  Based on the foregoing analysis, an embodiment of the present invention provides a method for storing information, including: receiving information to be stored, where a keyword of the information to be stored is m bits (m is a natural number); using the first hash function to The keyword to be stored is hashed to obtain first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, And 1 <111);
当与所述第一哈希值对应的第一存储器中的存储单元空闲时, 将所述第 一映射信息中的其他(m - n )位信息作为第一压缩关键字, 连同所述待存储 信息的附属信息一起存储在所述第一存储器中与所述第一哈希值对应的存储 单元内。  When the storage unit in the first memory corresponding to the first hash value is idle, the other (m − n ) bit information in the first mapping information is used as the first compression keyword, together with the to-be-stored The attached information of the information is stored together in a storage unit corresponding to the first hash value in the first memory.
本发明实施例还提供了一种引擎装置, 包括:  The embodiment of the invention further provides an engine device, including:
逻辑控制器, 用于接收待存储信息, 所述待存储信息的关键字为 m位( m 是自然数), 利用第一哈希函数对所述待存储信息的关键字进行哈希运算, 得 到第一映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位 信息作为第一哈希值(n是自然数, 且1 <111 ); a logic controller, configured to receive information to be stored, where the keyword of the information to be stored is m bits (m is a natural number), and the keyword of the information to be stored is hashed by using a first hash function to obtain a first a mapping information, the first mapping information is m bits, and n bits in the first mapping information Information as the first hash value (n is a natural number, and 1 <111);
第一存储器, 当与所述第一哈希值对应的存储单元空闲时, 用于将所述 第一映射信息中的其他(m - n )位信息作为第一压缩关键字, 连同所述待存 储信息的附属信息一起存储在所述与所述第一哈希值对应的存储单元内。  a first memory, when the storage unit corresponding to the first hash value is idle, used to use other (m - n ) bit information in the first mapping information as the first compression keyword, together with the waiting The attached information storing the information is stored together in the storage unit corresponding to the first hash value.
同时, 本发明实施例提供了一种信息查找的方法, 包括:  In the meantime, an embodiment of the present invention provides a method for searching for information, including:
接收待查找的关键字, 所述关键字为 m位( m是自然数);  Receiving a keyword to be searched, the keyword is m bits (m is a natural number);
利用第一哈希函数对所述关键字进行哈希运算, 得到第一映射信息, 所 述第一映射信息为 m位, 将所述第一映射信息中的 n位信息作为第一哈希值 ( n是自然数, 且 n小于 m );  And performing the hash operation on the keyword by using the first hash function to obtain the first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value. (n is a natural number, and n is less than m);
根据所述第一哈希值查找第一存储器, 获取与所述第一哈希值对应的存 储单元内的关键字信息, 利用所述关键字信息与所述关键字进行比较, 确定 所述与所述第一哈希值对应的存储单元与所述关键字对应时, 获取所述与所 述第一哈希值对应的存储单元内的信息。  Searching the first memory according to the first hash value, acquiring keyword information in a storage unit corresponding to the first hash value, and comparing the keyword information with the keyword to determine the When the storage unit corresponding to the first hash value corresponds to the keyword, the information in the storage unit corresponding to the first hash value is acquired.
本发明实施例还提供了另一种信息查找的方法, 包括:  The embodiment of the invention further provides another method for searching for information, including:
接收待查找的关键字, 所述关键字为 m位( m是自然数);  Receiving a keyword to be searched, the keyword is m bits (m is a natural number);
根据所述关键字查找内容地址存储器;  Finding a content address memory according to the keyword;
利用第一哈希函数对所述关键字行哈希运算, 得到第一映射信息, 所述 第一映射信息为 m位, 将所述第一映射信息中的 n位信息作为第一哈希值(n 是自然数, 且 n小于 m ),  The first hash information is obtained by hashing the key row by using a first hash function, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value. (n is a natural number, and n is less than m),
当在所述内容地址存储器中查找到与所述关键字对应的存储单元时, 获 取所述关键字对应的存储单元内的信息;  When the storage unit corresponding to the keyword is found in the content address storage, the information in the storage unit corresponding to the keyword is obtained;
当在所述内容地址存储器中未查找到与所述关键字对应的存储单元时, 根据所述第一哈希值查找第一存储器, 获取与所述第一哈希值对应的存储单 元内的关键字信息, 利用所述关键字信息与所述关键字进行比较, 确定所述 与所述第一哈希值对应的存储单元与所述关键字对应时, 获取所述与所述第 一哈希值对应的存储单元内的信息。 相应地, 本发明实施例提供了一种引擎装置, 包括: When the storage unit corresponding to the keyword is not found in the content address storage, searching for the first memory according to the first hash value, acquiring a storage unit corresponding to the first hash value Keyword information, using the keyword information to compare with the keyword, and determining that the storage unit corresponding to the first hash value corresponds to the keyword, acquiring the first The information in the storage unit corresponding to the hash value. Correspondingly, an embodiment of the present invention provides an engine apparatus, including:
第一存储器, 用于存储信息;  a first memory for storing information;
逻辑控制器,用于接收待查找的关键字,所述关键字为 m位( m是自然数), 利用第一哈希函数对所述待查找的关键字进行哈希运算, 得到第一映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位信息作为第一哈希 值(n是自然数, 且 n小于 m ); 根据所述第一哈希值查找第一存储器, 获取 与所述第一哈希值对应的存储单元内的关键字信息, 利用所述关键字信息与 所述关键字进行比较, 确定所述与所述第一哈希值对应的存储单元与所述关 键字对应时, 获取所述与所述第一哈希值对应的存储单元内的信息。  a logic controller, configured to receive a keyword to be searched, the keyword is m bits (m is a natural number), and the first hash function is used to perform hash operation on the keyword to be searched to obtain first mapping information. The first mapping information is m bits, and the n-bit information in the first mapping information is used as a first hash value (n is a natural number, and n is less than m); searching according to the first hash value. a memory, the keyword information in the storage unit corresponding to the first hash value is obtained, and the keyword information is compared with the keyword to determine the storage corresponding to the first hash value And when the unit corresponds to the keyword, acquiring information in the storage unit corresponding to the first hash value.
本发明实施例还提供了另一种引擎装置, 包括:  Another embodiment of the present invention provides an engine device, including:
内容地址存储器, 用于存储信息;  a content address storage for storing information;
第一存储器, 用于存储信息;  a first memory for storing information;
逻辑控制器,用于接收待查找的关键字,所述关键字为 m位( m是自然数), 根据所述关键字查找内容地址存储器, 利用第一哈希函数对所述关键字进行 哈希运算, 得到第一映射信息, 所述第一映射信息为 m位, 将所述第一映射 信息中的 n位信息作为第一哈希值(n是自然数, 且 n小于 m ); 当在所述内 容地址存储器中查找到与所述关键字对应的存储单元时, 获取所述与所述关 键字对应的存储单元内的信息; 当在所述内容地址存储器中未查找到与所述 关键字对应的存储单元时, 根据所述第一哈希值查找第一存储器, 获取与所 述第一哈希值对应的存储单元内的关键字信息, 利用所述关键字信息与所述 关键字进行比较, 确定所述第一哈希值对应的存储单元与所述关键字对应时, 获取所述与所述第一哈希值对应的存储单元内的信息。  a logic controller, configured to receive a keyword to be searched, the keyword is m bits (m is a natural number), and the content address memory is searched according to the keyword, and the keyword is hashed by using a first hash function Computing, the first mapping information is obtained, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m); Obtaining information in the storage unit corresponding to the keyword when the storage unit corresponding to the keyword is found in the content address memory; when the keyword is not found in the content address memory And searching for the first memory according to the first hash value, acquiring keyword information in the storage unit corresponding to the first hash value, using the keyword information and the keyword And comparing, when determining that the storage unit corresponding to the first hash value corresponds to the keyword, acquiring information in the storage unit corresponding to the first hash value.
本发明实施例提供的方案, 不存储完整的关键字, 而是通过关键字压缩 方案, 即将关键字进行哈希运算, 压缩为更少的位数再进行存储, 使得相同 位宽的存储器可存储的表项数增加, 提高了空间利用率, 降低了对存储器的 容量需求, 从而节约成本; 也可以减少冲突发生的概率。 从反面来说, 在相 同的硬件配置情况下, 釆用本发明方案, 引擎装置可以存储更多的信息, 即 增加了引擎装置的容量。 另外, 本发明实施例提供的方案可以简化信息查找 和信息存储的过程, 便于快速查找以及信息维护。 本发明使用内容地址存储 器的实施例中的方案, 可以解决哈希运算带来的冲突问题, 并且, 通过关键 字压缩方案, 可以降低对内容地址存储器的容量需求, 节约成本。 附图说明 The solution provided by the embodiment of the present invention does not store the complete keyword, but uses a keyword compression scheme, that is, the keyword is hashed, compressed into fewer bits, and then stored, so that the same bit width memory can be stored. The number of entries increases, which improves space utilization, reduces memory capacity requirements, and saves costs; it also reduces the probability of collisions. On the reverse side, in the phase With the same hardware configuration, with the solution of the present invention, the engine device can store more information, that is, increase the capacity of the engine device. In addition, the solution provided by the embodiment of the present invention can simplify the process of information searching and information storage, and is convenient for quick searching and information maintenance. The solution of the embodiment of the content address memory can solve the conflict problem caused by the hash operation, and the keyword compression scheme can reduce the capacity requirement of the content address memory and save costs. DRAWINGS
图 1是现有技术中链表存储法的示意图;  1 is a schematic diagram of a linked list storage method in the prior art;
图 2是现有技术中多哈希函数法的示意图;  2 is a schematic diagram of a multi-hash function method in the prior art;
图 3是现有技术中基于 CAM的查找示意图;  3 is a schematic diagram of a CAM-based search in the prior art;
图 4是本发明的一个实施例中引擎装置的结构示意图;  4 is a schematic structural view of an engine device in an embodiment of the present invention;
图 5是本发明的一个实施例中引擎装置进行信息存储的流程图;  5 is a flow chart of information storage by an engine device in an embodiment of the present invention;
图 6是是本发明一个实施例中引擎装置进行信息查找的流程图。 具体实施方式  Figure 6 is a flow chart showing the information search by the engine device in one embodiment of the present invention. detailed description
下面结合附图及具体实施例对本发明进行详细说明。  The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
本发明的一个实施例中提供了一种引擎装置, 包括逻辑控制器和第一存 储器, 其中, 逻辑控制器用于接收待存储信息, 该待存储信息的关键字为 m 位( m是自然数), 利用第一哈希函数对该待存储信息的关键字进行哈希运算, 得到第一映射信息, 第一映射信息为 m位, 将第一映射信息中的 n位信息作 为第一哈希值( n是自然数, 且 n小于 m ); 当与第一哈希值对应的第一存储 器中的存储单元空闲时, 将第一映射信息中的其他(m - n )位信息作为第一 压缩关键字, 连同待存储信息的附属信息存储在该与第一哈希值对应的存储 单元内。  An embodiment of the present invention provides an engine apparatus, including a logic controller and a first memory, where the logic controller is configured to receive information to be stored, where the key of the information to be stored is m bits (m is a natural number), The first hash information is hashed by using the first hash function to obtain the first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value ( n is a natural number, and n is smaller than m); when the storage unit in the first memory corresponding to the first hash value is idle, the other (m - n ) bit information in the first mapping information is used as the first compression keyword The auxiliary information along with the information to be stored is stored in the storage unit corresponding to the first hash value.
在这个实施例中, 当进行信息查找时, 逻辑控制器接收待查找的关键字, 关键字为 m位(m是自然数), 利用第一哈希函数对待查找的关键字进行哈希 运算, 得到第一映射信息, 第一映射信息为 m位, 将第一映射信息中的 n位 信息作为第一哈希值(n是自然数, 且 n小于 m ); 根据第一哈希值查找第一 存储器, 获取与第一哈希值对应的存储单元内的关键字信息, 利用该关键字 信息与待查找的关键字进行比较, 确定与第一哈希值对应的存储单元与待查 找的关键字对应时, 获取与第一哈希值对应的存储单元内的信息。 在上述过 程中, 利用该关键字信息与待查找的关键字进行比较, 确定与第一哈希值对 应的存储单元与待查找的关键字是否对应, 有多种实现方式, 例如: 将第一 映射信息中的其他(m - n )位信息作为第一压缩关键字; 比较该关键字信息 与第一压缩关键字, 当二者相同时, 确定与第一哈希值对应的存储单元与待 查找的关键字对应。 又例如: 将该关键字信息与第一哈希值结合得到完整的 关键字, 与待查找的关键字进行比较, 当二者相同时, 确定与第一哈希值对 应的存储单元与待查找的关键字对应。 In this embodiment, when performing information search, the logic controller receives the keyword to be searched, the keyword is m bits (m is a natural number), and hashes the keyword to be searched by using the first hash function. Computing, obtaining first mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m); searching according to the first hash value The first memory obtains keyword information in a storage unit corresponding to the first hash value, and compares the keyword information with the keyword to be searched to determine a storage unit corresponding to the first hash value and the to-be-searched When the keyword is corresponding, the information in the storage unit corresponding to the first hash value is obtained. In the above process, the keyword information is compared with the keyword to be searched to determine whether the storage unit corresponding to the first hash value corresponds to the keyword to be searched, and there are multiple implementation manners, for example: The other (m - n ) bit information in the mapping information is used as the first compression keyword; comparing the keyword information with the first compression keyword, when the two are the same, determining the storage unit and the corresponding to the first hash value The keywords that are found correspond. For another example, the keyword information is combined with the first hash value to obtain a complete keyword, and compared with the keyword to be searched. When the two are the same, the storage unit corresponding to the first hash value is determined to be searched. The corresponding keyword.
上述逻辑控制器可以包括: 第一哈希单元和逻辑单元。 进行信息存储时, 第一哈希单元将待存储信息的关键字进行哈希运算, 得到第一映射信息, 第 一映射信息为 m位, 将第一映射信息中的 n位信息作为第一哈希值; 逻辑单 元接收第一哈希值, 判断与第一哈希值对应的第一存储器中的存储单元空闲 还是被占用, 当与第一哈希值对应的存储单元空闲时, 通知第一存储器存储 第一压缩关键字和待存储信息的附属信息, 其中, 第一压缩关键字是第一映 射信息中的其他(m - n )位信息。  The above logic controller may include: a first hash unit and a logic unit. When the information is stored, the first hash unit performs a hash operation on the keyword of the information to be stored, to obtain the first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first The logical unit receives the first hash value, determines whether the storage unit in the first memory corresponding to the first hash value is idle or occupied, and notifies the first when the storage unit corresponding to the first hash value is idle. The memory stores the first compressed keyword and the attached information of the information to be stored, wherein the first compressed keyword is other (m - n ) bit information in the first mapping information.
在另一个实施例中, 引擎装置还可以包括: 第二存储器, 对应地, 逻辑 控制器还包括第二哈希单元, 当与第一哈希值对应的第一存储器中的存储单 元被占用时, 第二哈希单元将待存储信息的关键字进行哈希运算, 得到第二 映射信息, 第二映射信息为 m位, 将第二映射信息中的 t位信息作为第二哈 希值(t是自然数, 且 t小于 m ); 逻辑单元接收第二哈希值, 判断与第二哈 希值对应的第二存储器中的存储单元空闲还是被占用, 当与第二哈希值对应 的存储单元空闲时, 通知第二存储器存储第二压缩关键字和待存储信息的附 属信息, 其中, 第二关键字是第二映射信息中的其他(m - t )位信息。 In another embodiment, the engine device may further include: a second memory, correspondingly, the logic controller further includes a second hash unit, when the storage unit in the first memory corresponding to the first hash value is occupied The second hash unit performs a hash operation on the keyword to be stored, to obtain second mapping information, where the second mapping information is m bits, and the t-bit information in the second mapping information is used as the second hash value (t Is a natural number, and t is less than m); the logic unit receives the second hash value, and determines whether the memory cell in the second memory corresponding to the second hash value is idle or occupied, when the memory cell corresponding to the second hash value When idle, the second memory is notified to store the second compressed keyword and the attached information to be stored. Generic information, wherein the second keyword is other (m - t) bit information in the second mapping information.
在又一个实施例中, 引擎装置还包括内容地址存储器, 当与第一哈希值 对应的第一存储器中的存储单元被占用时, 内容地址存储器用于将待存储信 息的关键字和待存储信息的附属信息存储在内容地址存储器中空闲的存储单 元内。 该实施例中, 进行信息查找时, 逻辑控制器接收待查找的关键字, 关 键字为 m位(m是自然数), 根据关键字查找内容地址存储器; 同时, 利用第 一哈希函数对关键字进行哈希运算, 得到第一映射信息, 第一映射信息为 m 位,将第一映射信息中的 n位信息作为第一哈希值( n是自然数,且 n小于 m )。 当在内容地址存储器中查找到与关键字对应的存储单元时, 获取与关键字对 应的存储单元内的信息; 当在内容地址存储器中未查找到与关键字对应的存 储单元时, 根据第一哈希值查找第一存储器, 获取与第一哈希值对应的存储 单元内的关键字信息, 利用该关键字信息与待查找的关键字进行比较, 确定 与第一哈希值对应的存储单元与待查找的关键字对应时, 获取与第一哈希值 对应的存储单元内的信息。 同样的, 如上文所述, 利用该关键字信息与待查 找的关键字进行比较, 确定与第一哈希值对应的存储单元与待查找的关键字 是否对应, 有多种实现方式, 此处不再赘述。  In still another embodiment, the engine apparatus further includes a content address memory for storing a key of the information to be stored and to be stored when a storage unit in the first memory corresponding to the first hash value is occupied The attached information of the information is stored in a free storage unit in the content address memory. In this embodiment, when performing information search, the logic controller receives the keyword to be searched, the keyword is m bits (m is a natural number), and the content address memory is searched according to the keyword; meanwhile, the first hash function is used to pair the keyword Performing a hash operation to obtain first mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is smaller than m). When the storage unit corresponding to the keyword is found in the content address storage, acquiring information in the storage unit corresponding to the keyword; when the storage unit corresponding to the keyword is not found in the content address storage, according to the first The hash value is searched for the first memory, and the keyword information in the storage unit corresponding to the first hash value is obtained, and the keyword information is compared with the keyword to be searched to determine the storage unit corresponding to the first hash value. When corresponding to the keyword to be searched, information in the storage unit corresponding to the first hash value is obtained. Similarly, as described above, using the keyword information to compare with the keyword to be searched, determining whether the storage unit corresponding to the first hash value corresponds to the keyword to be searched, there are multiple implementation manners, where No longer.
当然, 也可以将上述两个实施例中的方案进行结合, 即引擎装置包括内 容地址存储器, 还包括第二存储器, 对应地, 逻辑控制器还包括第二哈希单 元。 这样, 当与第一哈希值对应的第一存储器中的存储单元被占用时, 第二 哈希单元将待存储信息的关键字进行哈希运算, 得到第二映射信息, 第二映 射信息为 m位, 将第二映射信息中的 t位信息作为第二哈希值(t是自然数, 且 t小于 m ) ; 逻辑单元接收第二哈希值, 判断与第二哈希值对应的第二存储器 中的存储单元空闲还是被占用, 当与第二哈希值对应的存储单元空闲时, 通 知第二存储器存储第二压缩关键字和待存储信息的附属信息, 其中, 第二压 缩关键字是第二映射信息中的其他(m - t )位信息; 而当与第二哈希值对应 的第二存储器中的存储单元被占用时, 内容地址存储器将待存储信息的关键 字和待存储信息的附属信息存储在空闲的存储单元中。 其中, 第一存储器和 第二存储器并不限定于片上存储器或者片外存储器。 Of course, the solution in the above two embodiments may also be combined, that is, the engine device includes a content address memory, and further includes a second memory. Correspondingly, the logic controller further includes a second hash unit. In this way, when the storage unit in the first memory corresponding to the first hash value is occupied, the second hash unit performs a hash operation on the keyword of the information to be stored to obtain second mapping information, where the second mapping information is m bits, the t-bit information in the second mapping information is taken as the second hash value (t is a natural number, and t is less than m); the logic unit receives the second hash value, and determines the second corresponding to the second hash value The storage unit in the memory is idle or occupied. When the storage unit corresponding to the second hash value is idle, the second memory is notified to store the second compressed keyword and the auxiliary information of the information to be stored, where the second compressed keyword is Other (m - t ) bit information in the second mapping information; and when the memory cell in the second memory corresponding to the second hash value is occupied, the content address memory will be the key of the information to be stored The words and the attached information of the information to be stored are stored in an idle storage unit. The first memory and the second memory are not limited to the on-chip memory or the off-chip memory.
下面结合图 4来举例进行更详细的说明。 当然, 图 4仅仅是一个具体的例 子, 并不用于限制本发明。 如图 4所示, 是本发明的一个实施例中引擎装置的 结构示意图,该引擎装置包括逻辑控制器 120、 CAM单元 123以及片外存储器 134 组成。  A more detailed description will be given below by way of example with reference to FIG. Of course, Figure 4 is only a specific example and is not intended to limit the invention. As shown in FIG. 4, it is a schematic structural diagram of an engine apparatus in an embodiment of the present invention, which comprises a logic controller 120, a CAM unit 123, and an off-chip memory 134.
其中, 逻辑控制器 120由逻辑单元 122、 多个 hash单元 121a和 121b、 片上 存储器 131组成。 CAM单元 123包括 CAM芯片 133和 CAM存储器 132。 举例来说, 逻 辑控制器 120可以使用 ASIC ( Appl ica t ion Spec if ic Integra ted Ci rcui t , 专用集成电路)或者 FPGA ( Fie ld Programmable Ga te Array, 现场可编程還 辑门阵列) 实现; 片外存储器 134可以使用 DRAM ( Dynamic Random Acces s Memory,动态随机存储器)实现; CAM存储器 132则可以是 SRAM ( S ta t ic Random Acces s Memory, 静态存储器) 。  The logic controller 120 is composed of a logic unit 122, a plurality of hash units 121a and 121b, and an on-chip memory 131. The CAM unit 123 includes a CAM chip 133 and a CAM memory 132. For example, the logic controller 120 can be implemented by using an ASIC (Application Specific Integrated IC) or an FPGA (Field Programmable Gatec Array); The external memory 134 can be implemented using a DRAM (Dynamic Random Accs s Memory); the CAM memory 132 can be an SRAM (Sta tic Random Acces s Memory).
在图 4所示的引擎装置中, 信息查找包括下述过程:  In the engine device shown in Figure 4, the information lookup includes the following process:
逻辑控制器 120接收到待查找的关键字 (key ) , 通过数据总线 111分发给 各哈希单元、 逻辑单元;  The logic controller 120 receives the key (key) to be searched and distributes it to each hash unit and logic unit through the data bus 111;
逻辑单元接收到待查找的关键字后通过数据总线 115将该关键字发送给 CAM单元 123查找, 如果 CAM单元 123查找到该关键字对应的信息, 则 CAM存储器 132将该信息返回给逻辑单元 122 , 此时, 逻辑单元 122不再使用各个哈希单元 的计算结果来访问对应的存储器; 如果 CAM单元 123没有找到需要的信息, 贝' J 逻辑单元 122根据各哈希单元的计算结果, 分别到各哈希单元对应的存储器上 读取对应的关键字和附属信息, 这些信息通过数据总线 117返回给逻辑单元 122 , 逻辑单元 122将这些信息中的关键字和待查找的关键字对比, 如果在这 些信息的关键字中找到与待查找的关键字相同的, 则从与待查找的关键字相 同的关键字所对应的存储器中获取附属信息并返回给逻辑单元。  After receiving the keyword to be searched, the logic unit sends the keyword to the CAM unit 123 for searching through the data bus 115. If the CAM unit 123 finds the information corresponding to the keyword, the CAM memory 132 returns the information to the logic unit 122. At this time, the logic unit 122 no longer uses the calculation result of each hash unit to access the corresponding memory; if the CAM unit 123 does not find the required information, the B' J logic unit 122 respectively according to the calculation result of each hash unit The corresponding keyword and the auxiliary information are read on the memory corresponding to each hash unit, and the information is returned to the logical unit 122 through the data bus 117, and the logical unit 122 compares the keyword in the information with the keyword to be searched, if If the keyword of the information is found to be the same as the keyword to be searched, the auxiliary information is obtained from the memory corresponding to the same keyword as the keyword to be searched and returned to the logical unit.
举一个很具体的例子来描述引擎装置的工作过程: 假设要查找的关键字 为 32位, 附属信息为 20位,待查的数据库包含 1M入口。则数据总线 1 11为 32位, 112a为 20位, 114为 20位; 112b的位数一般少于 112a , 可以设定 1 12b为 15位。 Give a very concrete example to describe the working process of the engine device: Suppose the keyword to be found It is 32 bits, the affiliate information is 20 bits, and the database to be checked contains 1M entry. Then, the data bus 1 11 is 32 bits, 112a is 20 bits, 114 is 20 bits; 112b has a number of bits less than 112a, and 1 12b can be set to 15 bits.
哈希单元 121a对应的哈希表存储在片外存储器 1 34上, 片外存储器的存储 空间为 1M, 数据位宽为 128位。 由于哈希单元使用哈希函数将 32b i t的关键字 信息映射到 20b i t的地址空间 (1M ) , 也就是说哈希单元 121a对 32位的关键字 信息进行哈希运算, 得出一个 32位的映射信息, 将该 32位映射信息中的 20位 信息作为第一哈希值, 而将另 12位信息, 作为压缩关键字, 存储在片外存储 器 1 34中, 这一过程称为关键字压缩。 这样, 片外存储器 1 34中的关键字信息, 连同第一哈希值就可以得到完整的关键字信息。 例如附属信息是 20位, 加上 存储这 20位附属信息, 那么, 一个表项在存储器中片外存储器 1 34中存储只需 要存储 12+20=32位的信息, 总共需要 32位位宽。 当逻辑单元 122取回这 32位信 息时, 只需要结合所用的哈希函数就可以获得完整的关键字, 与待查找的关 键字对比, 如表 1所示。  The hash table corresponding to the hash unit 121a is stored in the off-chip memory 134, the memory space of the off-chip memory is 1M, and the data bit width is 128 bits. Since the hash unit uses the hash function to map the keyword information of 32b it to the address space (1M) of 20b it, that is, the hash unit 121a hashes the 32-bit keyword information to obtain a 32-bit. The mapping information, the 20-bit information in the 32-bit mapping information is used as the first hash value, and the other 12-bit information is stored as the compression key in the off-chip memory 134. This process is called a keyword. compression. Thus, the keyword information in the off-chip memory 134, together with the first hash value, can be used to obtain complete keyword information. For example, the auxiliary information is 20 bits, and the 20-bit auxiliary information is stored. Then, an entry stored in the off-chip memory 134 in the memory only needs to store 12+20=32 bits of information, and a total of 32 bits is required. When the logic unit 122 retrieves the 32-bit information, it is only necessary to combine the hash function used to obtain the complete keyword, as compared with the key to be searched, as shown in Table 1.
表 1 经过关键字压缩后的表项存储形式  Table 1 Table entry storage form after keyword compression
1 12 13 32  1 12 13 32
压缩关键字 附属信息  Compressed keyword
这样, 对于位宽为 128位的片外存储器 1 34 , —个存储单元可以存储 4个表 项信息, 如表 2所示。 Thus, for an off-chip memory 1 34 having a bit width of 128 bits, one storage unit can store four entries, as shown in Table 2.
表 2 位宽为 128位的存储单元内的表项存储结构  Table 2 Table storage structure in a storage unit with a bit width of 128 bits
1 32 33 64 65 96 97 128
Figure imgf000012_0001
1 32 33 64 65 96 97 128
Figure imgf000012_0001
这样做的好处是一个存储单元可以存储 4个冲突表项, 这样, 即便发生 4 次冲突, 也可以实现一次读取获得所有的表项信息, 可以实现快速查找。 由 于某一个存储空间发生大于 4次冲突的概率比较小, 所以剩余的无法存储的冲 突表项就比较小, 这和使用 4M的 32位存储空间来存储 1M表项信息的存储方式 相比, 冲突概率要小很多。 另外, 通过关键字压缩, 一个表项的需存储信息 的大小被缩小了, 1M表项使用 128M的空间就可以存储, 与存储所有关键字信 息, 同样的存储方式下需要 512M的存储空间相比, 空间利用率要高很多。 The advantage of this is that a storage unit can store 4 conflicting entries, so that even if 4 conflicts occur, all the entries can be obtained in one read, and a fast search can be realized. Since the probability of occurrence of more than 4 collisions in a storage space is relatively small, the remaining unstorable rushes The number of items is relatively small, which is much less likely to be compared with the way of storing 4M entries using 4M 32-bit storage. In addition, by keyword compression, the size of information to be stored in an entry is reduced. The 1M entry can be stored using 128M space, and all key information is stored. The same storage mode requires 512M of storage space. , space utilization is much higher.
上面的表述只是使用了一个哈希函数, 使用一个存储单元来存储表项。 因为信息的分布是随机的, 而一个哈希函数却是固定格式, 在某些信息分布 情况下可能会有大量的冲突, 如果这些冲突表项都存入 CAM单元中, 需要 CAM 单元的空间较大, 成本会 4艮高。 为此, 可以釆用多哈希函数法来抵消信息分 布随机性的影响。 为了不增加片外存储器的个数, 考虑到片外存储器的冲突 表项个数已经比较少了, 所以使用逻辑控制器 120中的片上存储器 1 31来存储 哈希单元 121 b对应的哈希表。举例来说,可以使用 32Κ χ 32位的片上存储器 1 31 来存储一个哈希表, 对于现有的逻辑器件来说都具备这样的片上存储器。 优 选的, 哈希单元 121 b釆用的哈希函数选取要与哈希单元 121 a釆用的哈希函数 尽量不相关, 以降低冲突发生的概率。 这样可以有效降低了冲突发生的概率, 又有效利用存储器空间。 当然, 图 4所示的 1个片外存储器和 1个片上存储器只 是一个示例, 逻辑控制器 120中, 可以只有 1个存储器, 不限于片上还是片外, 也可以有多个存储器。 当有多个存储器时, 则对应多个哈希表。  The above expression simply uses a hash function that uses a storage unit to store entries. Because the distribution of information is random, and a hash function is a fixed format, there may be a large number of conflicts in some information distribution situations. If these conflicting entries are stored in the CAM unit, the space of the CAM unit is required. Large, the cost will be 4 艮 high. To this end, the multi-hash function method can be used to offset the effects of randomness of information distribution. In order not to increase the number of off-chip memories, it is considered that the number of conflicting entries of the off-chip memory has been relatively small, so the on-chip memory 1 31 in the logic controller 120 is used to store the hash table corresponding to the hash unit 121 b. . For example, 32 Κ 32-bit on-chip memory 1 31 can be used to store a hash table, which is available for existing logic devices. Preferably, the hash function used by the hash unit 121 b is selected as far as possible from the hash function used by the hash unit 121 a to reduce the probability of collision occurring. This can effectively reduce the probability of collisions and effectively utilize the memory space. Of course, one off-chip memory and one on-chip memory shown in FIG. 4 are only an example. In the logic controller 120, there may be only one memory, not limited to on-chip or off-chip, or multiple memories. When there are multiple memories, there are multiple hash tables.
在有些情况下, 需要大量的片上存储器来实现所有冲突表项的存储, 而 片上存储器资源十分有限, 所以, 例如, 在冲突表项的个数不多的情况下, 可以使用容量较小的 CAM单元存储剩余的冲突表项。 这样既有效减少了片上存 储器的需求, 又可以解决冲突给查找带来的问题。 如图 4所示的引擎装置中, 可以使用 IK X 32位的 CAM芯片 1 33和 1K χ 20位的 CAM存储器 1 32来分别存储关键 字和附属信息。  In some cases, a large amount of on-chip memory is required to implement storage of all conflicting entries, and on-chip memory resources are very limited. Therefore, for example, in the case where the number of conflicting entries is small, a CAM with a smaller capacity can be used. The unit stores the remaining conflicting entries. This effectively reduces the need for on-chip memory and resolves the problems that conflicts pose to lookups. In the engine unit shown in Fig. 4, IK X 32-bit CAM chip 1 33 and 1K χ 20-bit CAM memory 1 32 can be used to store keywords and ancillary information, respectively.
另外, 本发明的实施例中提供了一种信息存储的方法, 过程如下: 接收待存储信息, 该待存储信息的关键字为 m位( m是自然数); 利用第一哈希函数对待存储信息的关键字进行哈希运算, 得到第一映射 信息, 第一映射信息为 m位, 将第一映射信息中的 n位信息作为第一哈希值 ( n是自然数, 且 n小于 m ); In addition, in the embodiment of the present invention, a method for information storage is provided, the process is as follows: receiving information to be stored, the keyword of the information to be stored is m bits (m is a natural number); using the first hash function to store information The keyword is hashed to get the first map Information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m);
当与第一哈希值对应的第一存储器中的存储单元空闲时, 将第一映射信 息中的其他(m - n )位信息作为第一压缩关键字, 连同待存储信息的附属信 息一起存储在第一存储器中与第一哈希值对应的存储单元内。  When the storage unit in the first memory corresponding to the first hash value is idle, the other (m − n ) bit information in the first mapping information is stored as the first compression key together with the auxiliary information of the information to be stored. Within the first memory is in a memory location corresponding to the first hash value.
在另一个实施例中, 当第一存储器中与第一哈希值对应的存储单元被占 用时, 利用第二哈希函数对待存储信息的关键字进行哈希运算, 得到第二映 射信息, 第二映射信息为 m位, 将第二映射信息中的 t位信息作为第二哈希 值( t是自然数, 且 t小于 m ); 当与第二哈希值对应的第二存储器中的存储 单元空闲时, 将第二压缩关键字和待存储信息的附属信息存储在第二存储器 中与第二哈希值对应的存储单元内, 其中, 第二压缩关键字是第二映射信息 中的其他(m - t )位信息。  In another embodiment, when the storage unit corresponding to the first hash value in the first memory is occupied, the keyword of the information to be stored is hashed by using the second hash function, to obtain the second mapping information, The second mapping information is m bits, and the t bit information in the second mapping information is used as the second hash value (t is a natural number, and t is less than m); when the storage unit in the second memory corresponding to the second hash value When idle, the second compressed keyword and the auxiliary information of the information to be stored are stored in a storage unit corresponding to the second hash value in the second memory, where the second compressed keyword is the other of the second mapping information ( m - t ) bit information.
在又一个实施例中, 当第一存储器中与第一哈希值对应的存储单元被占 用时, 查找内容地址存储器中是否存在空闲的存储单元; 当存在空闲的存储 单元时, 将待存储信息的关键字和附属信息存储在该空闲的存储单元内。 储器中与第一哈希值对应的存储单元被占用时, 利用第二哈希函数对待存储 信息的关键字进行哈希运算, 得到第二映射信息, 第二映射信息为 m位, 将 第二映射信息中的 t位信息作为第二哈希值( t是自然数, 且 t小于 m ); 当 与第二哈希值对应的第二存储器中的存储单元空闲时, 将第二压缩关键字和 待存储信息的附属信息存储在第二存储器中与第二哈希值对应的存储单元 内, 其中, 第二压缩关键字是第二映射信息中的其他(m - t )位信息; 而当 与第二哈希值对应的第二存储器中的存储单元被占用时, 查找内容地址存储 器中是否存在空闲的存储单元; 当存在空闲的存储单元时, 将待存储信息中 关键字和附属信息存储在该空闲的存储单元内。  In still another embodiment, when a storage unit corresponding to the first hash value in the first memory is occupied, whether there is an idle storage unit in the content address memory; when there is an idle storage unit, the information to be stored The keywords and affiliate information are stored in the free storage unit. When the storage unit corresponding to the first hash value in the storage is occupied, the second hash function is used to hash the keyword to be stored, to obtain the second mapping information, and the second mapping information is m bits, The t-bit information in the second mapping information is used as the second hash value (t is a natural number, and t is less than m); when the storage unit in the second memory corresponding to the second hash value is idle, the second compressed keyword is And the auxiliary information of the information to be stored is stored in a storage unit corresponding to the second hash value in the second memory, where the second compressed keyword is other (m − t ) bit information in the second mapping information; When the storage unit in the second memory corresponding to the second hash value is occupied, whether there is an idle storage unit in the content address memory; when there is an idle storage unit, storing the keyword and the auxiliary information in the information to be stored In the free storage unit.
下面举一个具体的例子来描述信息存储的过程。 如图 5所示, 是本发明的 一个实施例中引擎装置进行信息存储的流程图, 结合图 4所示的引擎装置的结 构示意图, 信息存储的过程如下: The following is a concrete example to describe the process of information storage. As shown in FIG. 5, it is the present invention. In one embodiment, the flow chart of the information storage by the engine device is combined with the structural diagram of the engine device shown in FIG. 4, and the information storage process is as follows:
首先从步骤 510开始, 此时存储的表项小于 1M项;  First, starting from step 510, the stored item is less than 1M item;
在步骤 51 1中, 逻辑控制器 120接收存储指令和待存储的信息, 然后通过 数据总线发送给哈希单元 121a ;  In step 51 1 , the logic controller 120 receives the store instruction and the information to be stored, and then transmits it to the hash unit 121a through the data bus;
在步骤 512中, 哈希单元 121 a使用第一哈希函数进行运算获得第一哈希值 并通过数据总线 112a发送给逻辑单元 122;  In step 512, the hash unit 121a performs an operation using the first hash function to obtain a first hash value and sends it to the logic unit 122 via the data bus 112a;
在步骤 51 3中, 逻辑单元 122根据第一哈希值对应地查找到片外存储器 1 34 中的存储单元, 找到第一哈希值对应的存储单元, 以表 2为例, 是 4个表项共 128位;  In step 51 3, the logic unit 122 correspondingly searches for the storage unit in the off-chip memory 134 according to the first hash value, and finds the storage unit corresponding to the first hash value, and takes Table 2 as an example, which is 4 tables. A total of 128 items;
在步骤 514中, 判断第一哈希值对应的存储单元是否有空闲空间 (冲突表 项 <4 ) , 如果有空闲空间, 则在步骤 515中, 逻辑单元 122根据哈希单元 121a 的第一哈希函数对关键字进行压缩;  In step 514, it is determined whether the storage unit corresponding to the first hash value has a free space (collision table entry <4). If there is free space, then in step 515, the logic unit 122 is based on the first hash of the hash unit 121a. The function compresses the keyword;
在步骤 516中, 逻辑单元 122将压缩后的关键字和附属信息放入第一哈希 值对应的存储单元中的空闲空间, 存入片外存储器 1 34中, 然后进入步骤 523 , 等待其它指令。 在步骤 514中, 如果没有空闲空间 (冲突表项〉 4 ) , 则进入步 骤 517 , 即哈希单元 121 b接收存储指令和相应信息, 通过第二哈希函数计算得 到第二哈希值并发送给逻辑单元 122。 在步骤 518中, 逻辑单元 122根据第二哈 希值到片上存储器 1 31中查找第二哈希值对应的存储单元( 32位)。在步骤 519 中, 判断该存储单元是否存有有效的表项信息, 如果没有, 即空闲, 则在步 骤 520中, 逻辑单元 122根据哈希单元 121b的第二哈希函数对关键字进行压缩。 在步骤 521中, 逻辑单元 122将压缩后的关键字和附属信息放入该存储单元中, 然后进入步骤 523 , 等待其它指令。 在步骤 519中, 如果有冲突发生, 则逻辑 单元将关键字信息和附属信息存入 CAM单元 123中。 至此, 信息存储流程结束, 流程进入步骤 523 , 等待其它指令。  In step 516, the logic unit 122 puts the compressed keyword and the auxiliary information into the free space in the storage unit corresponding to the first hash value, stores it in the off-chip memory 134, and then proceeds to step 523 to wait for other instructions. . In step 514, if there is no free space (collision table entry > 4), then step 517 is entered, that is, the hash unit 121 b receives the storage instruction and the corresponding information, and the second hash value is calculated by the second hash function and sent. To the logic unit 122. In step 518, the logic unit 122 searches the on-chip memory 1 31 for the memory location (32 bits) corresponding to the second hash value according to the second hash value. In step 519, it is determined whether the storage unit has valid entry information. If not, that is, idle, then in step 520, the logic unit 122 compresses the keyword according to the second hash function of the hash unit 121b. In step 521, the logic unit 122 places the compressed keyword and the attached information into the storage unit, and then proceeds to step 523 to wait for other instructions. In step 519, if a conflict occurs, the logic unit stores the keyword information and the affiliate information in the CAM unit 123. At this point, the information storage process ends, and the flow proceeds to step 523 to wait for other instructions.
同时, 本发明的一个实施例中还提供了一种信息查找的方法, 过程如下: 接收待查找的关键字, 关键字为 m位(m是自然数); In the meantime, an embodiment of the present invention also provides a method for information searching, and the process is as follows: Receiving the keyword to be searched, the keyword is m bits (m is a natural number);
利用第一哈希函数对关键字进行哈希运算, 得到第一映射信息, 第一映 射信息为 m位, 将第一映射信息中的 n位信息作为第一哈希值(n是自然数, 且 n小于 m );  The first hash information is hashed by using the first hash function to obtain first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m);
根据第一哈希值查找第一存储器, 获取与第一哈希值对应的存储单元内 的关键字信息, 利用关键字信息与待查找的关键字进行比较, 确定与第一哈 希值对应的存储单元与待查找的关键字对应时, 获取与第一哈希值对应的存 储单元内的信息。  Searching the first memory according to the first hash value, acquiring keyword information in the storage unit corresponding to the first hash value, comparing the keyword information with the keyword to be searched, and determining, corresponding to the first hash value, When the storage unit corresponds to the keyword to be searched, the information in the storage unit corresponding to the first hash value is obtained.
如上文所述, 利用关键字信息与待查找的关键字进行比较, 确定与第一 哈希值对应的存储单元与待查找的关键字是否对应, 存在多种方案, 此处不 再赘述。  As described above, the keyword information is compared with the keyword to be searched to determine whether the storage unit corresponding to the first hash value corresponds to the keyword to be searched. There are various solutions, and details are not described herein.
在另一个实施例中, 信息查找的过程略有不同, 包括:  In another embodiment, the process of information lookup is slightly different, including:
接收待查找的关键字, 待查找的关键字为 m位( m是自然数);  Receiving the keyword to be searched, the keyword to be searched is m bits (m is a natural number);
根据待查找的关键字查找内容地址存储器;  Find the content address memory according to the keyword to be searched;
利用第一哈希函数对待查找的关键字进行哈希运算, 得到第一映射信息 , 第一映射信息为 m位, 将第一映射信息中的 n位信息作为第一哈希值( n是自 然数, 且 n小于 m ); 当在内容地址存储器中查找到与待查找的关键字对应的 存储单元时, 获取关键字对应的存储单元中的信息; 当在内容地址存储器中 未查找到与待查找的关键字对应的存储单元时, 根据第一哈希值查找第一存 储器, 获取与第一哈希值对应的存储单元内的关键字信息, 利用关键字信息 与待查找的关键字进行比较, 确定与第一哈希值对应的存储单元与待查找的 关键字对应时, 获取与第一哈希值对应的存储单元内的信息。  The first hash information is hashed by using the first hash function to obtain the first mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number) And n is less than m); when the storage unit corresponding to the keyword to be searched is found in the content address memory, the information in the storage unit corresponding to the keyword is obtained; when the search is not found in the content address memory Searching for the first storage unit according to the first hash value, obtaining keyword information in the storage unit corresponding to the first hash value, and comparing the keyword to be searched using the keyword information, When it is determined that the storage unit corresponding to the first hash value corresponds to the keyword to be searched, the information in the storage unit corresponding to the first hash value is obtained.
下面举一个具体的例子来说明信息查找的具体过程。 如图 6 所示, 是本 发明一个实施例中引擎装置进行信息查找的流程图, 结合图 4 中引擎装置的 结构示意图, 信息查找的过程如下:  The following is a specific example to illustrate the specific process of information search. As shown in FIG. 6, it is a flowchart of the information search by the engine device in one embodiment of the present invention. Referring to the structural diagram of the engine device in FIG. 4, the information search process is as follows:
首先从步骤 610开始, 此时引擎装置处于等待指令阶段; 在步骤 611中, 逻辑控制器 120接收查找指令和待查关键字, 并通过数据 总线 111和 115发送到哈希单元 121a、 哈希单元 121b和 CAM单元 123。 在步骤 612 中, CAM单元 123接收到待查关键字后, CAM芯片 133根据该关键字进行并行查 找, 如果找到相符信息, 则输出地址到 CAM存储器 132上, CAM存储器 132返回 附属信息; 如果 CAM芯片 133没有找到相符信息, 则不向逻辑单元返回任何值; 在步骤 613和 614中, 两哈希单元根据待查关键字进行哈希计算输出哈希 值, 该哈希值通过数据总线 112a和 112b输出到逻辑单元 122; First, starting from step 610, at which time the engine device is in the waiting command phase; In step 611, the logic controller 120 receives the lookup instruction and the to-be-checked key and transmits them to the hash unit 121a, the hash unit 121b, and the CAM unit 123 via the data buses 111 and 115. In step 612, after the CAM unit 123 receives the to-be-checked keyword, the CAM chip 133 performs a parallel search according to the keyword. If the matching information is found, the address is output to the CAM memory 132, and the CAM memory 132 returns the auxiliary information; If the chip 133 does not find the matching information, it does not return any value to the logical unit; in steps 613 and 614, the two hash units perform a hash calculation outputting a hash value according to the to-be-checked keyword, and the hash value passes through the data bus 112a and 112b is output to the logic unit 122;
在步骤 615中, 逻辑单元 122收集 CAM查找结果和两哈希单元的运算结果, 其中, CAM单元 123查找结果, 即返回值的优先级最高, 如果 CAM单元 123有返 回值, 则使用该值作为附属信息。 如果 CAM单元 123无返回值, 则使用哈希单 元计算结果到相应存储器获取关键字信息和附属信息。 各个哈希单元为并行 查找, 所有哈希计算和存储器访问都是并行完成的, 无优先级之分。  In step 615, the logic unit 122 collects the CAM search result and the operation result of the two hash units, wherein the CAM unit 123 searches for the result, that is, the return value has the highest priority. If the CAM unit 123 has a return value, the value is used as the return value. Ancillary information. If the CAM unit 123 has no return value, the hash unit is used to calculate the result to the corresponding memory to obtain the keyword information and the attached information. Each hash unit is a parallel lookup, and all hash calculations and memory accesses are done in parallel, with no priority.
在步骤 616中, 逻辑单元 122判断 CAM单元 123是否有返回值, 如果有, 说 明 CAM单元找到待查信息, 则在步骤 617中, 使用 CAM查找结果作为返回的附属 信息。 此时进入步骤 624, 等待其它指令到来;  In step 616, the logic unit 122 determines whether the CAM unit 123 has a return value. If so, indicating that the CAM unit finds the information to be checked, then in step 617, the CAM search result is used as the returned affiliate information. At this point, proceed to step 624, waiting for other instructions to arrive;
在步骤 616中, 如果 CAM单元 123没有返回值, 说明 CAM单元未找到待查信 息, 则在步骤 618中, 使用哈希运算的结果到相应的存储器获取关键字信息和 附属信息。 同时, 在步骤 619中, 逻辑单元 122根据所有的哈希单元的哈希函 数来压缩关键字。 在步骤 620中, 逻辑单元 122将计算所得的压缩关键字与从 各个存储器中取回的关键字信息进行比较。 在步骤 621中, 判断是否一致。 如 果一致, 则在步骤 622中, 返回与压缩关键字一致的关键字所在的存储单元内 存储的附属信息。 此时进入步骤 624, 等待其它指令到来。  In step 616, if the CAM unit 123 has no return value, indicating that the CAM unit has not found the information to be checked, then in step 618, the result of the hash operation is used to obtain the keyword information and the attached information in the corresponding memory. At the same time, in step 619, logic unit 122 compresses the keywords based on the hash functions of all of the hash units. In step 620, logic unit 122 compares the computed compression key with the key information retrieved from each memory. In step 621, it is determined whether or not they are consistent. If they match, in step 622, the attached information stored in the storage unit in which the keyword matching the compressed keyword is stored is returned. At this point, the process proceeds to step 624, waiting for other commands to arrive.
在步骤 621中, 如果不一致, 则说明要查找的关键字信息不存在, 则在步 骤 623中返回 "无相符" 信息, 然后进入步骤 624, 等待其它指令到来, 整个 查找过程到此结束。  In step 621, if it is inconsistent, it indicates that the keyword information to be searched for does not exist, then the "no match" information is returned in step 623, and then proceeds to step 624, waiting for other instructions to arrive, and the entire search process ends.
本发明实施例中对应的软件可以存储在一个计算机可读取存储介质中。 本发明实施例中的方案已经在计算机中进行了多次仿真试验, 经验证运行可 靠可行。 本发明实施例提供的方案, 不存储完整的关键字, 而是通过关键字 压缩方案, 即将关键字进行哈希运算, 压缩为更少的位数再进行存储, 使得 相同位宽的存储器可存储的表项数增加, 提高了空间利用率, 降低了对存储 器的容量需求, 从而节约成本; 也可以减少冲突发生的概率。 从反面来说, 在相同的硬件配置情况下, 釆用本发明方案, 引擎装置可以存储更多的信息, 即增加了引擎装置的容量。 另外, 本发明实施例提供的方案可以简化信息查 找和信息存储的过程, 便于快速查找以及信息维护。 本发明使用内容地址存 储器的实施例中的方案, 可以解决哈希运算带来的冲突问题, 并且, 通过关 键字压缩方案, 可以降低对内容地址存储器的容量需求, 节约成本。 Corresponding software in the embodiments of the present invention may be stored in a computer readable storage medium. The solution in the embodiment of the present invention has been subjected to multiple simulation tests in a computer, and the verification operation is reliable and feasible. The solution provided by the embodiment of the present invention does not store the complete keyword, but uses a keyword compression scheme, that is, the keyword is hashed, compressed into fewer bits, and then stored, so that the same bit width memory can be stored. The number of entries increases, which improves space utilization, reduces memory capacity requirements, and saves costs; it also reduces the probability of collisions. On the contrary, in the case of the same hardware configuration, the engine device can store more information, that is, increase the capacity of the engine device. In addition, the solution provided by the embodiment of the present invention can simplify the process of information searching and information storage, and is convenient for quick searching and information maintenance. The solution of the embodiment of the content address memory can solve the conflict problem caused by the hash operation, and the keyword compression scheme can reduce the capacity requirement of the content address memory and save costs.
以上所述, 仅为本发明较佳的具体实施方式, 但本发明的保护范围并不 局限于此, 任何熟悉该技术的人在本发明所揭露的技术范围内, 可轻易想到 的变化或替换, 都应涵盖在本发明的保护范围之内。  The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope of the present invention. All should be covered by the scope of the present invention.

Claims

权利 要求 书 Claim
1、 一种信息存储的方法, 其特征在于, 包括: A method for storing information, characterized in that it comprises:
接收待存储信息, 所述待存储信息的关键字为 m位(m是自然数); 利用第一哈希函数对所述待存储信息的关键字进行哈希运算, 得到第一 映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位信息作 为第一哈希值(n是自然数, 且1 <111 );  Receiving information to be stored, the keyword of the information to be stored is m bits (m is a natural number); performing a hash operation on the keyword of the information to be stored by using a first hash function, to obtain first mapping information, The first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and 1 <111);
当与所述第一哈希值对应的第一存储器中的存储单元空闲时, 将所述第 一映射信息中的其他(m - n )位信息作为第一压缩关键字, 连同所述待存储 信息的附属信息一起存储在所述第一存储器中与所述第一哈希值对应的存储 单元内。  When the storage unit in the first memory corresponding to the first hash value is idle, the other (m − n ) bit information in the first mapping information is used as the first compression keyword, together with the to-be-stored The attached information of the information is stored together in a storage unit corresponding to the first hash value in the first memory.
2、 如权利要求 1所述的方法, 其特征在于, 还包括:  2. The method of claim 1, further comprising:
当所述与所述第一哈希值对应的第一存储器中的存储单元被占用时, 利 用第二哈希函数对所述待存储信息的关键字进行哈希运算, 得到第二映射信 息, 所述第二映射信息为 m位, 将所述第二映射信息中的 t位信息作为第二 哈希值(t是自然数, 且 Km );  When the storage unit in the first memory corresponding to the first hash value is occupied, the keyword of the information to be stored is hashed by using a second hash function to obtain second mapping information. The second mapping information is m bits, and the t-bit information in the second mapping information is used as a second hash value (t is a natural number, and Km);
当与所述第二哈希值对应的第二存储器中的存储单元空闲时, 将所述第 二映射信息中的其他(m - t )位信息作为第二压缩关键字, 连同所述待存储 信息的附属信息一起存储在所述第二存储器中与所述第二哈希值对应的存储 单元内。  When the storage unit in the second memory corresponding to the second hash value is idle, the other (m − t ) bit information in the second mapping information is used as the second compression keyword, together with the to-be-stored The attached information of the information is stored together in a storage unit corresponding to the second hash value in the second memory.
3、 如权利要求 1所述的方法, 其特征在于, 还包括:  3. The method of claim 1, further comprising:
当所述与所述第一哈希值对应的第一存储器中的存储单元被占用时, 查 找内容地址存储器中是否有空闲的存储单元;  When the storage unit in the first memory corresponding to the first hash value is occupied, it is found whether there is a free storage unit in the content address memory;
当所述内容地址存储器中有空闲的存储单元时, 将所述待存储信息的关 键字和附属信息存储在所述空闲的存储单元内。  When there is an empty storage unit in the content address memory, the keyword and the auxiliary information of the information to be stored are stored in the free storage unit.
4、 如权利要求 2所述的方法, 其特征在于, 还包括: 当所述与所述第二哈希值对应的第二存储器中的存储单元被占用时, 查 找内容地址存储器中是否有空闲的存储单元; 4. The method of claim 2, further comprising: When the storage unit in the second memory corresponding to the second hash value is occupied, whether there is a free storage unit in the content address memory;
当所述内容地址存储器中有空闲的存储单元时, 将所述待存储信息的关 键字和附属信息存储在所述空闲的存储单元内。  When there is an empty storage unit in the content address memory, the keyword and the auxiliary information of the information to be stored are stored in the free storage unit.
5、 一种引擎装置, 其特征在于, 包括:  5. An engine device, comprising:
逻辑控制器, 用于接收待存储信息, 所述待存储信息的关键字为 m位( m 是自然数), 利用第一哈希函数对所述待存储信息的关键字进行哈希运算, 得 到第一映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位 信息作为第一哈希值(n是自然数, 且1 <111 );  a logic controller, configured to receive information to be stored, where the keyword of the information to be stored is m bits (m is a natural number), and the keyword of the information to be stored is hashed by using a first hash function to obtain a first a mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as a first hash value (n is a natural number, and 1 <111);
第一存储器, 当与所述第一哈希值对应的存储单元空闲时, 用于将所述 第一映射信息中的其他(m - n )位信息作为第一压缩关键字, 连同所述待存 储信息的附属信息一起存储在所述与所述第一哈希值对应的存储单元内。  a first memory, when the storage unit corresponding to the first hash value is idle, used to use other (m - n ) bit information in the first mapping information as the first compression keyword, together with the waiting The attached information storing the information is stored together in the storage unit corresponding to the first hash value.
6、 如权利要求 5所述的引擎装置, 其特征在于, 所述逻辑控制器包括: 第一哈希单元, 用于对所述待存储信息的关键字进行哈希运算, 得到所 述第一映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位 信息作为所述第一哈希值;  The engine apparatus according to claim 5, wherein the logic controller comprises: a first hashing unit, configured to perform a hash operation on a keyword of the information to be stored, to obtain the first Mapping information, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value;
逻辑单元, 用于接收所述第一哈希值, 判断所述与所述第一哈希值对应 的存储单元空闲还是被占用, 当所述与所述第一哈希值对应的存储单元空闲 时 , 通知所述第一存储器存储所述第一压缩关键字和所述待存储信息的附属 信息。  a logic unit, configured to receive the first hash value, determine whether the storage unit corresponding to the first hash value is idle or occupied, when the storage unit corresponding to the first hash value is idle And notifying the first memory to store the first compressed keyword and the auxiliary information of the information to be stored.
7、 如权利要求 6所述的引擎装置, 其特征在于, 还包括第二存储器; 所 述逻辑控制器还包括第二哈希单元, 当所述与所述第一哈希值对应的存储单 元被占用时, 所述第二哈希单元用于对所述待存储信息的关键字进行哈希运 算, 得到第二映射信息, 所述第二映射信息为 m位, 将所述第二映射信息中 的 t位信息作为第二哈希值(t是自然数, 且 t小于 m );  7. The engine apparatus according to claim 6, further comprising a second memory; the logic controller further comprising a second hash unit, wherein the storage unit corresponding to the first hash value When being occupied, the second hashing unit is configured to perform a hash operation on the keyword of the information to be stored, to obtain second mapping information, where the second mapping information is m bits, and the second mapping information is used. The t-bit information in the second hash value (t is a natural number, and t is less than m);
所述逻辑单元接收所述第二哈希值, 判断所述与所述第二哈希值对应的 第二存储器中的存储单元空闲还是被占用, 当所述与所述第二哈希值对应的 存储单元空闲时, 通知所述第二存储器存储第二压缩关键字和所述待存储信 息的附属信息, 所述第二关键字为所述第二映射信息中的其他(m - t )位信 息。 The logic unit receives the second hash value, and determines the corresponding to the second hash value. The storage unit in the second memory is idle or occupied, and when the storage unit corresponding to the second hash value is idle, notifying the second memory to store the second compression keyword and the attachment of the information to be stored Information, the second keyword is other (m - t) bit information in the second mapping information.
8、如权利要求 5所述的引擎装置, 其特征在于,还包括内容地址存储器, 当所述与所述第一哈希值对应的第一存储器中的存储单元被占用时, 所述内 容地址存储器用于将所述待存储信息的关键字和所述待存储信息的附属信息 存储在所述内容地址存储器中空闲的存储单元内。  8. The engine apparatus according to claim 5, further comprising a content address memory, said content address when said storage unit in said first memory corresponding to said first hash value is occupied The memory is configured to store the keyword of the information to be stored and the auxiliary information of the information to be stored in a storage unit that is free in the content address memory.
9、如权利要求 7所述的引擎装置, 其特征在于,还包括内容地址存储器, 当所述与所述第二哈希值对应的第二存储器中的存储单元被占用时, 所述内 容地址存储器用于将所述待存储信息的关键字和所述待存储信息的附属信息 存储在所述内容地址存储器中空闲的存储单元内。  9. The engine apparatus according to claim 7, further comprising a content address memory, said content address when said storage unit in said second memory corresponding to said second hash value is occupied The memory is configured to store the keyword of the information to be stored and the auxiliary information of the information to be stored in a storage unit that is free in the content address memory.
10、 一种信息查找的方法, 其特征在于, 包括:  10. A method for searching for information, characterized in that it comprises:
接收待查找的关键字, 所述关键字为 m位( m是自然数);  Receiving a keyword to be searched, the keyword is m bits (m is a natural number);
利用第一哈希函数对所述关键字进行哈希运算, 得到第一映射信息, 所 述第一映射信息为 m位, 将所述第一映射信息中的 n位信息作为第一哈希值 ( n是自然数, 且 n小于 m );  And performing the hash operation on the keyword by using the first hash function to obtain the first mapping information, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value. (n is a natural number, and n is less than m);
根据所述第一哈希值查找第一存储器, 获取与所述第一哈希值对应的存 储单元内的关键字信息, 利用所述关键字信息与所述关键字进行比较, 确定 所述与所述第一哈希值对应的存储单元与所述关键字对应时, 获取所述与所 述第一哈希值对应的存储单元内的信息。  Searching the first memory according to the first hash value, acquiring keyword information in a storage unit corresponding to the first hash value, and comparing the keyword information with the keyword to determine the When the storage unit corresponding to the first hash value corresponds to the keyword, the information in the storage unit corresponding to the first hash value is acquired.
11、 如权利要求 10所述的方法, 其特征在于, 所述利用所述关键字信息 与所述关键字进行比较, 包括:  The method according to claim 10, wherein the comparing the keyword information with the keyword comprises:
将所述第一映射信息中的其他(m - n )位信息作为第一压缩关键字; 比较所述关键字信息与所述第一压缩关键字, 当二者相同时, 确定所述 与所述第一哈希值对应的存储单元与所述关键字对应。 Determining the other (m - n ) bit information in the first mapping information as a first compression keyword; comparing the keyword information with the first compression keyword, and when the two are the same, determining the location The storage unit corresponding to the first hash value corresponds to the keyword.
12、 如权利要求 10所述的方法, 其特征在于, 所述利用所述关键字信息 与所述关键字进行比较, 包括: The method according to claim 10, wherein the comparing the keyword information with the keyword comprises:
将所述关键字信息与所述第一哈希值结合得到完整的关键字, 与所述关 键字进行比较, 当二者相同时, 确定所述与所述第一哈希值对应的存储单元 与所述关键字对应。  Combining the keyword information with the first hash value to obtain a complete keyword, comparing with the keyword, and when the two are the same, determining the storage unit corresponding to the first hash value Corresponding to the keyword.
1 3、 一种信息查找的方法, 其特征在于, 包括:  1 3, a method for information searching, characterized in that:
接收待查找的关键字, 所述关键字为 m位( m是自然数);  Receiving a keyword to be searched, the keyword is m bits (m is a natural number);
根据所述关键字查找内容地址存储器;  Finding a content address memory according to the keyword;
利用第一哈希函数对所述关键字行哈希运算, 得到第一映射信息, 所述 第一映射信息为 m位, 将所述第一映射信息中的 n位信息作为第一哈希值(n 是自然数, 且 n小于 m ),  The first hash information is obtained by hashing the key row by using a first hash function, where the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value. (n is a natural number, and n is less than m),
当在所述内容地址存储器中查找到与所述关键字对应的存储单元时, 获 取所述关键字对应的存储单元内的信息;  When the storage unit corresponding to the keyword is found in the content address storage, the information in the storage unit corresponding to the keyword is obtained;
当在所述内容地址存储器中未查找到与所述关键字对应的存储单元时, 根据所述第一哈希值查找第一存储器, 获取与所述第一哈希值对应的存储单 元内的关键字信息, 利用所述关键字信息与所述关键字进行比较, 确定所述 与所述第一哈希值对应的存储单元与所述关键字对应时, 获取所述与所述第 一哈希值对应的存储单元内的信息。  When the storage unit corresponding to the keyword is not found in the content address storage, searching for the first memory according to the first hash value, acquiring a storage unit corresponding to the first hash value Keyword information, using the keyword information to compare with the keyword, and determining that the storage unit corresponding to the first hash value corresponds to the keyword, acquiring the first The information in the storage unit corresponding to the hash value.
14、 如权利要求 1 3所述的方法, 其特征在于, 所述利用所述关键字信息 与所述关键字进行比较, 包括:  The method according to claim 13, wherein the comparing the keyword information with the keyword comprises:
将所述第一映射信息中的其他(m - n )位信息作为第一压缩关键字; 比较所述关键字信息与所述第一压缩关键字, 当二者相同时, 确定所述 与所述第一哈希值对应的存储单元与所述关键字对应。  Determining the other (m - n ) bit information in the first mapping information as a first compression keyword; comparing the keyword information with the first compression keyword, and when the two are the same, determining the location The storage unit corresponding to the first hash value corresponds to the keyword.
15、 如权利要求 1 3所述的方法, 其特征在于, 所述利用所述关键字信息 与所述关键字进行比较, 包括:  The method according to claim 13, wherein the comparing the keyword information with the keyword comprises:
将所述关键字信息与所述第一哈希值结合得到完整的关键字, 与所述关 键字进行比较, 当二者相同时, 确定所述与所述第一哈希值对应的存储单元 与所述关键字对应。 Combining the keyword information with the first hash value to obtain a complete keyword, The keys are compared, and when the two are the same, it is determined that the storage unit corresponding to the first hash value corresponds to the keyword.
16、 一种引擎装置, 其特征在于, 包括:  16. An engine apparatus, comprising:
第一存储器, 用于存储信息;  a first memory for storing information;
逻辑控制器,用于接收待查找的关键字,所述关键字为 m位( m是自然数), 利用第一哈希函数对所述待查找的关键字进行哈希运算, 得到第一映射信息, 所述第一映射信息为 m位, 将所述第一映射信息中的 n位信息作为第一哈希 值(n是自然数, 且 n小于 m ); 根据所述第一哈希值查找第一存储器, 获取 与所述第一哈希值对应的存储单元内的关键字信息, 利用所述关键字信息与 所述关键字进行比较, 确定所述与所述第一哈希值对应的存储单元与所述关 键字对应时, 获取所述与所述第一哈希值对应的存储单元内的信息。  a logic controller, configured to receive a keyword to be searched, the keyword is m bits (m is a natural number), and the first hash function is used to perform hash operation on the keyword to be searched to obtain first mapping information. The first mapping information is m bits, and the n-bit information in the first mapping information is used as a first hash value (n is a natural number, and n is less than m); searching according to the first hash value. a memory, the keyword information in the storage unit corresponding to the first hash value is obtained, and the keyword information is compared with the keyword to determine the storage corresponding to the first hash value And when the unit corresponds to the keyword, acquiring information in the storage unit corresponding to the first hash value.
17、 一种引擎装置, 其特征在于, 包括:  17. An engine apparatus, comprising:
内容地址存储器, 用于存储信息;  a content address storage for storing information;
第一存储器, 用于存储信息;  a first memory for storing information;
逻辑控制器,用于接收待查找的关键字,所述关键字为 m位( m是自然数), 根据所述关键字查找内容地址存储器, 利用第一哈希函数对所述关键字进行 哈希运算, 得到第一映射信息, 所述第一映射信息为 m位, 将所述第一映射 信息中的 n位信息作为第一哈希值(n是自然数, 且 n小于 m ); 当在所述内 容地址存储器中查找到与所述关键字对应的存储单元时, 获取所述与所述关 键字对应的存储单元内的信息; 当在所述内容地址存储器中未查找到与所述 关键字对应的存储单元时, 根据所述第一哈希值查找第一存储器, 获取与所 述第一哈希值对应的存储单元内的关键字信息, 利用所述关键字信息与所述 关键字进行比较, 确定所述第一哈希值对应的存储单元与所述关键字对应时, 获取所述与所述第一哈希值对应的存储单元内的信息。  a logic controller, configured to receive a keyword to be searched, the keyword is m bits (m is a natural number), and the content address memory is searched according to the keyword, and the keyword is hashed by using a first hash function Computing, the first mapping information is obtained, the first mapping information is m bits, and the n-bit information in the first mapping information is used as the first hash value (n is a natural number, and n is less than m); Obtaining information in the storage unit corresponding to the keyword when the storage unit corresponding to the keyword is found in the content address memory; when the keyword is not found in the content address memory And searching for the first memory according to the first hash value, acquiring keyword information in the storage unit corresponding to the first hash value, using the keyword information and the keyword And comparing, when determining that the storage unit corresponding to the first hash value corresponds to the keyword, acquiring information in the storage unit corresponding to the first hash value.
PCT/CN2008/070143 2007-04-02 2008-01-18 Method and engine device for storing and looking up information WO2008119269A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CNB2007100739263A CN100470550C (en) 2007-04-02 2007-04-02 Information storing method, information search method and engine device
CN200710073926.3 2007-04-02

Publications (1)

Publication Number Publication Date
WO2008119269A1 true WO2008119269A1 (en) 2008-10-09

Family

ID=38730967

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2008/070143 WO2008119269A1 (en) 2007-04-02 2008-01-18 Method and engine device for storing and looking up information

Country Status (2)

Country Link
CN (1) CN100470550C (en)
WO (1) WO2008119269A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269784A (en) * 2020-10-28 2021-01-26 中科驭数(北京)科技有限公司 Hash table structure based on hardware realization and inserting, inquiring and deleting method
US20210073410A1 (en) * 2018-05-15 2021-03-11 Microsoft Technology Licensing, Llc Secure dataset management
CN112699416A (en) * 2021-01-04 2021-04-23 烽火通信科技股份有限公司 File storage method, file verification method and electronic equipment
CN113592920A (en) * 2021-07-28 2021-11-02 南京物间科技有限公司 Rapid stereo matching method based on Census and Hash chain table
CN113726660A (en) * 2021-08-27 2021-11-30 西安微电子技术研究所 Route finder and method based on perfect hash algorithm
CN114785396A (en) * 2022-03-09 2022-07-22 西安电子科技大学 Method, system and terminal for configuring, searching mapping and managing flow of logical port
US11636047B2 (en) 2021-08-31 2023-04-25 Micron Technology, Inc. Hash operations in memory for data sharing

Families Citing this family (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100470550C (en) * 2007-04-02 2009-03-18 华为技术有限公司 Information storing method, information search method and engine device
CN101140592A (en) * 2007-09-30 2008-03-12 华为技术有限公司 Keywords storing and researching method and apparatus
CN101604337B (en) * 2009-07-13 2011-08-24 中兴通讯股份有限公司 Apparatus and method for hash table storage, searching
CN101692651B (en) * 2009-09-27 2014-12-31 中兴通讯股份有限公司 Method and device for Hash lookup table
CN101826107B (en) * 2010-04-02 2015-08-05 华为技术有限公司 Hash data processing method and device
CN102754394B (en) * 2010-08-19 2015-07-22 华为技术有限公司 Method for hash table storage, method for hash table lookup, and devices thereof
CN102187642B (en) * 2011-04-14 2015-01-07 华为技术有限公司 Method and device for adding, searching for and deleting key in hash table
WO2012106916A1 (en) * 2011-07-22 2012-08-16 华为技术有限公司 Method and apparatus for processing hash calculations
CN102629234B (en) * 2012-01-18 2015-01-21 物联微电子(常熟)有限公司 Fast retrieval method for data of built-in Flash of single chip microcomputer
CN103064948B (en) * 2012-12-27 2015-08-19 中国航空工业集团公司第六三一研究所 Based on content addressed method and the corresponding memory circuitry of Hash chain
CN104182393A (en) * 2013-05-21 2014-12-03 中兴通讯股份有限公司 Processing method and processing device for keyword mapping based on hash table
CN103309950A (en) * 2013-05-22 2013-09-18 苏州雄立科技有限公司 Searching method for key value
CN103399920B (en) * 2013-08-02 2017-04-26 苏州雄立科技有限公司 Key value searching method, key value searching device and chip
CN104301228A (en) * 2014-09-12 2015-01-21 中国电子科技集团公司第三十二研究所 Method and system for realizing searching module in network processor
CN106033420A (en) * 2015-03-11 2016-10-19 杭州华三通信技术有限公司 A Hash table processing method and device
CN106933749B (en) * 2015-12-31 2020-10-13 北京国睿中数科技股份有限公司 Address random method and device applied to cache verification system
CN106708438A (en) * 2016-12-16 2017-05-24 盛科网络(苏州)有限公司 Method and device for lowering Hash conflict probability
CN108111421B (en) * 2017-11-28 2021-02-09 苏州浪潮智能科技有限公司 Message distribution method and device based on multiple Hash
CN108172260B (en) * 2017-12-30 2020-06-26 盛科网络(苏州)有限公司 Method and device for verifying Hash module in ASIC chip
CN108632046B (en) * 2018-05-14 2021-05-04 深圳市合众万邦科技有限公司 Grading card, reading and writing device, medical care management system and method
CN109245879A (en) * 2018-09-06 2019-01-18 杭州光芯科技有限公司 A kind of double hash algorithms of storage and lookup IP address mapping relations
CN111107068B (en) * 2019-12-09 2021-03-09 江苏云涌电子科技股份有限公司 Efficient rule matching method for FPGA and terminal
CN113297219A (en) * 2021-05-21 2021-08-24 山东云海国创云计算装备产业创新中心有限公司 Method, device and equipment for storing field and storage medium
CN113204556A (en) * 2021-05-21 2021-08-03 山东英信计算机技术有限公司 Storage method, system, terminal and storage medium based on low-order hash label
CN113395615B (en) * 2021-06-10 2022-05-06 烽火通信科技股份有限公司 Message processing method and device, electronic equipment and readable storage medium
CN114936087B (en) * 2021-09-29 2023-06-02 华为技术有限公司 Method, device, system and related equipment for embedded vector prefetching
CN114726920A (en) * 2022-06-07 2022-07-08 恒生电子股份有限公司 TCP data processing method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5920900A (en) * 1996-12-30 1999-07-06 Cabletron Systems, Inc. Hash-based translation method and apparatus with multiple level collision resolution
US6247014B1 (en) * 1998-07-01 2001-06-12 Nortel Networks Limited Method and apparatus for performing hash lookups using valid bit tables with pointers
US7116664B2 (en) * 2002-05-13 2006-10-03 International Business Machines Corporation Lookups by collisionless direct tables and CAMs
CN1912870A (en) * 2006-09-05 2007-02-14 四川南山之桥微电子有限公司 Look-up method of hash table
CN101034412A (en) * 2007-04-02 2007-09-12 华为技术有限公司 Information storing method, information search method and engine device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5920900A (en) * 1996-12-30 1999-07-06 Cabletron Systems, Inc. Hash-based translation method and apparatus with multiple level collision resolution
US6247014B1 (en) * 1998-07-01 2001-06-12 Nortel Networks Limited Method and apparatus for performing hash lookups using valid bit tables with pointers
US7116664B2 (en) * 2002-05-13 2006-10-03 International Business Machines Corporation Lookups by collisionless direct tables and CAMs
CN1912870A (en) * 2006-09-05 2007-02-14 四川南山之桥微电子有限公司 Look-up method of hash table
CN101034412A (en) * 2007-04-02 2007-09-12 华为技术有限公司 Information storing method, information search method and engine device

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210073410A1 (en) * 2018-05-15 2021-03-11 Microsoft Technology Licensing, Llc Secure dataset management
CN112269784A (en) * 2020-10-28 2021-01-26 中科驭数(北京)科技有限公司 Hash table structure based on hardware realization and inserting, inquiring and deleting method
CN112699416A (en) * 2021-01-04 2021-04-23 烽火通信科技股份有限公司 File storage method, file verification method and electronic equipment
CN113592920A (en) * 2021-07-28 2021-11-02 南京物间科技有限公司 Rapid stereo matching method based on Census and Hash chain table
CN113726660A (en) * 2021-08-27 2021-11-30 西安微电子技术研究所 Route finder and method based on perfect hash algorithm
US11636047B2 (en) 2021-08-31 2023-04-25 Micron Technology, Inc. Hash operations in memory for data sharing
CN114785396A (en) * 2022-03-09 2022-07-22 西安电子科技大学 Method, system and terminal for configuring, searching mapping and managing flow of logical port
CN114785396B (en) * 2022-03-09 2024-04-12 西安电子科技大学 Logic port configuration, lookup mapping and traffic management method, system and terminal

Also Published As

Publication number Publication date
CN101034412A (en) 2007-09-12
CN100470550C (en) 2009-03-18

Similar Documents

Publication Publication Date Title
WO2008119269A1 (en) Method and engine device for storing and looking up information
US11102120B2 (en) Storing keys with variable sizes in a multi-bank database
US8484439B1 (en) Scalable hash tables
US7668890B2 (en) Prefix search circuitry and method
WO2008037201A1 (en) Method and apparatus for solving hash collision
US7167471B2 (en) Network processor with single interface supporting tree search engine and CAM
US6522632B1 (en) Apparatus and method for efficient prefix search
US7930516B1 (en) Linked list traversal with reduced memory accesses
CN111382327B (en) Character string matching device and method
US20060248095A1 (en) Efficient RAM lookups by means of compressed keys
Bando et al. FlashTrie: beyond 100-Gb/s IP route lookup using hash-based prefix-compressed trie
US20020138648A1 (en) Hash compensation architecture and method for network address lookup
WO2019042372A1 (en) Message forwarding
US20140358886A1 (en) Internal search engines architecture
WO2012013023A2 (en) Hash search method for reducing hash conflicts
US20170078200A1 (en) Multi-table hash-based lookups for packet processing
WO2014201902A1 (en) Tcam-based table query processing method and apparatus
US11782895B2 (en) Cuckoo hashing including accessing hash tables using affinity table
WO2016206490A1 (en) Device and method of enhancing item access bandwidth and atomic operation
US8503442B2 (en) Transmission information transfer apparatus and method thereof
CN112818185A (en) Method for searching longest prefix matching hardware system based on SRAM
US6343289B1 (en) Efficient search and organization of a forwarding database or the like
WO2021008552A1 (en) Data reading method and apparatus, and computer-readable storage medium
WO2023130953A1 (en) Data search method and apparatus, and network device
US8001524B1 (en) Instruction extension for linked list lookup

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 08700800

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 08700800

Country of ref document: EP

Kind code of ref document: A1