+

WO2012159480A1 - Table entry adding, deleting and searching method of hash table and hash table storage device - Google Patents

Table entry adding, deleting and searching method of hash table and hash table storage device Download PDF

Info

Publication number
WO2012159480A1
WO2012159480A1 PCT/CN2012/072473 CN2012072473W WO2012159480A1 WO 2012159480 A1 WO2012159480 A1 WO 2012159480A1 CN 2012072473 W CN2012072473 W CN 2012072473W WO 2012159480 A1 WO2012159480 A1 WO 2012159480A1
Authority
WO
WIPO (PCT)
Prior art keywords
hash
entry
sub
bitmap
stored
Prior art date
Application number
PCT/CN2012/072473
Other languages
French (fr)
Chinese (zh)
Inventor
李彧
张炜
孙远航
崔玉姣
郑永梅
Original Assignee
中兴通讯股份有限公司
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
Priority claimed from CN201110138340.7A external-priority patent/CN102194002B/en
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012159480A1 publication Critical patent/WO2012159480A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method for adding, deleting, searching, and hashing a table of a hash table. Background technique
  • hash lookup is to use the hash function to find the key value of the input.
  • (Key) performs the abbreviated operation, and then uses the calculated hash value to be addressed in the hash index table. After finding the matching item, the hash index (Hash Index) stored in the corresponding item is read, and finally the hash index is used. The direct address mapping table is addressed to get the desired lookup results.
  • the hash algorithm is a common fast search algorithm. Its basic idea is to use the keyword k of each element in the linear table as an independent variable. Through a certain functional relationship H(k), the corresponding function value is calculated, and this value is interpreted as a unit of continuous storage space, and the element is stored in this unit.
  • the hash algorithm establishes a certain correspondence between the storage location of the element and its keyword. When searching, there is no need to compare, and a hash map can find the required element.
  • collision collision
  • the key is how to deal with them after a conflict to achieve the desired search purpose.
  • a hash function using the CRC (Cyclic Redundancy Checking) class is suitable.
  • CRC Cyclic Redundancy Checking
  • Different hash functions under the same bit width can be achieved by selecting different CRC polynomials.
  • Multidimensional hash tables, conflict chains, Double Hashing, etc. can be used to select the appropriate table storage structure to resolve conflicts.
  • the simulation results show that using these methods, under the premise of ensuring that no entries remain, that is, all the entries can be stored, the number of times the hash value is calculated is opposite to the required storage table space, that is, if you want To drop all the entries with a small enough storage space, you need to do a sufficient number of hashes. This will result in multiple accesses to the same table.
  • the invention provides a method for adding, deleting, searching and hashing a table entry of a hash table, which can realize storage of all entries without a table entry with a minimum search time cost and a high table space utilization rate. At the same time, it only needs to be accessed once to accurately find the required items. At the same time, it is also convenient to implement the interface between hardware and memory, which can achieve better balance in table space size, search efficiency and hardware implementation.
  • a method for adding a table entry of a hash table including:
  • each hash sub-table corresponds to a bitmap
  • each bitmap corresponds to a hash function
  • Determining a current target hash sub-table calculating a hash value of the key value of the table to be stored by using a hash function corresponding to the bitmap corresponding to the current target hash sub-table, and determining, according to the hash value, a current target hash sub-table Whether the storage location is a vacancy, if yes, the information of the to-be-stored entry is stored in the vacancy, otherwise, the current target hash sub-table is updated until a vacancy is found to store the information of the to-be-stored entry.
  • the bitmap includes a conflict bit and a valid bit, and is determined according to the hash value. Whether the storage location corresponding to the previous target hash sub-table is a vacancy, if yes, the information of the to-be-stored entry is stored in the vacancy, otherwise, the current target hash sub-table is updated until a vacancy is found to store the to-be-stored entry.
  • the steps of the information including:
  • searching for a bitmap corresponding to the current target hash sub-table determining whether the valid bit of the bitmap is valid, and whether the conflict bit of the bitmap is invalid; if the valid bit If it is valid, and the conflict bit is invalid, it is determined that the storage location corresponding to the current target hash sub-table is a vacancy, and the information of the to-be-stored entry is stored in the vacancy; otherwise, the current target hash is updated.
  • the step of searching for the bitmap corresponding to the current target hash sub-table by using the hash value as an index, and the method includes:
  • the method further includes: invalidating the valid position of the bitmap, and storing the key value of the to-be-stored entry into the bitmap.
  • the step of updating the current target hash sub-table until finding a space to store the information of the to-be-stored item includes:
  • the hash sub-table updates the current target hash sub-table to the next hash sub-table until the vacancy is found to store the information of the to-be-stored entry.
  • the step of updating the current target hash sub-table until finding a space to store the information of the to-be-stored item includes:
  • the method further includes:
  • the conflict bit information of the bitmap and the information of the hash sub-table are synchronously updated.
  • the hash function corresponding to the hash sub-table is a cyclic redundancy code check function. Further, different cyclic redundancy code check polynomials are used between the hash functions corresponding to the plurality of hash sub-tables.
  • a hash table entry deletion method the hash table includes a plurality of hash sub-tables, each hash sub-table corresponds to a bitmap, each bitmap corresponds to a hash function, and each of the bits
  • the figure includes a plurality of entries, and the method includes:
  • the hash function corresponding to each bitmap calculates the hash value of the item to be deleted in parallel; according to the calculated hash value, it searches in parallel in its corresponding bitmap;
  • the search results of each bitmap are sequentially compared.
  • the entry in the hash sub-table corresponding to the address of the bitmap is taken out;
  • the key value of the fetched entry is compared with the key value to be searched. If they are the same, the entry is deleted from the hash subtable.
  • the method further includes;
  • the conflict position of the corresponding bitmap is invalid, and the valid position is valid.
  • the method further includes:
  • a hash table search method the hash table includes a plurality of hash sub-tables, each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function, and the hash table search method Includes:
  • the hash value obtained according to the calculation is searched in parallel in the corresponding bitmap
  • the search results of each bitmap are sequentially compared.
  • the entry in the hash sub-table corresponding to the address of the bitmap is taken out;
  • the key value of the extracted entry is compared with the key value of the entry to be searched. If the key value of the retrieved entry matches the key of the to-be-find entry, the information of the entry is used as a final check. Table results.
  • the method further includes: if the key value of the extracted entry does not match the key value of the to-be-find entry, returning a message that the search fails.
  • step of searching in parallel according to the calculated hash value in the corresponding bitmap includes:
  • the intercepted hash value is used as an index and is searched in parallel in its corresponding bitmap.
  • the hash function corresponding to the bitmap is the same as the hash function corresponding to the hash sub-table when the table entry is stored.
  • a hash table storage device includes a main control logic module, and a control line and a data line connected to the main control logic module, wherein the main control logic module controls the addition and/or deletion of the control line completion entry And the control data line completion entry search, where the control line includes: an entry split module, a target hash sub-determination module, and an entry storage module, where
  • the table splitting module is configured to split the hash table into multiple hash subtables and multiple bitmaps, and each hash subtable corresponds to a bitmap and a hash function;
  • the target hash sub-table determining module is connected to the table splitting module, and is configured to determine a hash sub-table from the plurality of hash sub-tables obtained by splitting the table splitting module as a current target. Hash subtable; and after receiving the update instruction issued by the entry storage module, set to update the current target hash subtable to its next hash subtable;
  • the entry storage module is configured to be connected to the target hash sub-table determining module, and configured to calculate a hash value of the key value of the to-be-stored entry by using a hash function corresponding to the current target hash sub-table. And determining, according to the hash value, whether the storage location corresponding to the current target hash sub-table is a vacancy, and if yes, storing information of the entry to be stored in the vacancy, otherwise sending an update instruction to the target hash sub-determination module, The storage of the to-be-stored entry is not found until the slot is found.
  • bitmap includes a conflicting bit and a valid bit
  • entry storage module includes a calculation submodule, a lookup submodule, and an entry add submodule, where
  • the calculation sub-module is connected to the target hash sub-table determination module, and is configured to calculate a hash value of the key value of the to-be-stored entry by using a hash function corresponding to the current target hash sub-table;
  • the search submodule is connected to the calculation submodule and configured to determine the target hash
  • the sub-table determines whether the number of bits of the hash value calculated by the module is greater than or equal to the capacity of the current target hash sub-table, and if so, intercepts the hash value, and uses the intercepted hash value as an index to find the corresponding bit. And determining whether the valid bit of the bitmap is valid, and whether the conflict bit of the bitmap is invalid, and if yes, determining that the storage location in the target hash sub-table is a vacancy; otherwise, proceeding to the target
  • the hash sub-table determines that the module sends an update instruction until a space is found;
  • the entry-add sub-module is further configured to invalidate the valid position of the bitmap. And storing the key value of the item to be stored in the bitmap.
  • the searching sub-module determines that the valid bit of the bitmap is invalid, it is further configured to determine whether the conflict bit of the bitmap is invalid, and if yes, the entry adding submodule is set to be The bitmap corresponding to the stored table entry in the hash sub-table, and the key value of the extracted entry and the key value of the current to-be-stored entry are stored in the bitmap;
  • the entry adding submodule of the entry storage module is configured to store the current key value of the to-be-stored entry into the bitmap.
  • the hash table includes a plurality of hash sub-tables, each of the hash sub-tables corresponds to a bitmap and a hash function, and the data line includes a parallel computing module, a parallel search module, and a comparison module, where
  • the parallel computing module is configured to calculate a hash value of the key value of the to-be-find table item in parallel by using a hash function corresponding to each hash sub-table;
  • a parallel search module connected to the parallel computing module, configured to search in parallel according to the calculated hash values in their respective bitmaps;
  • the comparison module is set to compare and compare the lookup results of the respective bitmaps to determine a match.
  • the address of the hash table in which the entry is located, the information of the entry stored in the address is taken out, and compared with the key value to be searched, to determine whether the extracted entry matches the entry to be searched, such as matching. Then the information of the entry is used as the final lookup result.
  • the method for adding an entry of a hash table by splitting the hash table into multiple hash sub-tables, and each hash sub-table corresponds to a bitmap and a hash function, and then utilizing The hash function calculates a hash value of the key value of the table to be stored, and the hash value is used to determine the space for storing the entry to be stored, that is, since each hash sub-table is obtained by splitting the hash table.
  • the storage address of the matching entry has been determined in the bitmap, so that all the entries are stored with a minimum update time cost and a high table space utilization, and no entry remains.
  • the hash table searching method calculates the hash value of the key of the table to be searched in parallel, and searches according to the hash value to the corresponding bitmap, and compares the search results.
  • the conflicting bit is invalid for the first time, the entry in the hash sub-table corresponding to the address of the bitmap is taken out; compared with the lookup table entry, if it matches, the entry is the table to be searched.
  • each hash sub-table is obtained by splitting the hash table, and the storage address of the matching table item has been determined in the bitmap, so that only one visit to the hash sub-table can accurately find the need
  • the table entry also facilitates the implementation of the interface between hardware and memory, and achieves a better balance in table space size, search efficiency, and hardware implementation.
  • FIG. 1 is a schematic structural diagram of an embodiment of a hash table storage device of the present invention.
  • FIG. 2 is a schematic structural diagram of an embodiment of an entry storage module according to the present invention.
  • FIG. 3 is a schematic structural diagram of a specific embodiment of a hash table storage device of the present invention
  • FIG. 4 is a flowchart of an embodiment of a method for adding a hash table of the present invention
  • FIG. 5 is a hash of the present invention
  • step S409b of the method for adding a table entry of the hash table of the present invention Cheng Tu
  • FIG. 7 is a flowchart of an embodiment of a method for deleting an entry of a hash table according to the present invention
  • FIG. 8 is a flowchart of an embodiment of a method for searching a hash table according to the present invention
  • FIG. 9 is a logical structural diagram of an embodiment of a hash table of the present invention.
  • FIG. 10 is a flowchart of a specific embodiment of an entry of a hash table of the present invention
  • FIG. 11 is a schematic diagram of a logical structure of an embodiment of a lookup hash table according to the present invention. detailed description
  • FIG. 1 is a structural block diagram of an embodiment of a hash table storage device according to an embodiment of the present invention.
  • the hash table storage device of this embodiment includes a main control logic module 100, and a control line and a data line connected to the main control logic module 100, wherein the main control logic module 100 controls the addition and/or deletion of the control line completion entry.
  • the control data line completes the entry search, wherein the control line includes: an entry split module 101, a target hash sub-determination module 102, and an entry storage module 103, wherein the entry split module 101 and the target hash sub-determination module 102 and the entry storage module 103, wherein the table entry splitting module 101 is configured to split the hash table into multiple hash sub-tables and multiple bitmaps, and each hash sub-table corresponds to one bitmap and one
  • the hash function table 102 is connected to the table splitting module 101, and is used as the current target in the first hash sub-table of the plurality of hash sub-tables obtained by splitting the table splitting module 101.
  • Hash subtable and after receiving the update instruction issued by the entry storage module 103, is used to update the current target hash subtable to its next hash subtable; the entry storage module 103, And the target hash sub-table determination module 102 is configured to calculate a hash value of the key value of the table to be stored by using a hash function corresponding to the current target hash sub-table, and determine a current target hash sub-table according to the hash value. If the corresponding storage location is a vacancy, if yes, the information of the entry to be stored is stored in the vacancy, otherwise the update instruction is sent to the target hash sub-determination module 102 until the vacant storage of the entry to be stored is found.
  • FIG. 2 is a schematic structural diagram of an embodiment of an entry storage module according to an embodiment of the present invention.
  • the bitmap in this embodiment includes a collision bit and a valid bit.
  • the entry storage module includes a calculation submodule 200, a lookup submodule 201, and an entry addition submodule 203, wherein the calculation submodule 200 is connected to the target hash subform determination module for utilizing the current target hash subtable.
  • the corresponding hash function calculates a hash value of the key value of the entry to be stored; the search submodule 201 is connected to the calculation submodule 200, and is used for determining the number of bits of the hash value calculated by the target hash subtable determination module.
  • the search sub-module 201 is connected to be used to store the information of the entry to be stored when the search sub-module 201 finds a vacancy in the current target hash sub-table.
  • Bit, and invalidate the valid position of the bitmap store the key value of the table item to be stored in the bitmap, and when the search sub-module 201 determines that the valid bit of the bitmap is invalid, Determining whether the conflict bit of the bitmap is invalid. If yes, the entry adding submodule is used to take out the stored table entry in the hash sub-table, and extract the key value of the entry and the current table to be stored. The key value of the item is stored in the bitmap; when the search sub-module 201 determines that the conflict bit of the bitmap is valid, the entry adding sub-module 202 is configured to store the key value of the current to-be-stored entry to the bitmap. in.
  • Each bitmap in this embodiment includes a bit conflict bit and a valid bit, and a plurality of conflict key value storage slots.
  • the effective position of the bitmap is 0, that is, it is valid, and when it is set to 1, it means invalid; if the conflict position of the bitmap is 0, it means invalid, and setting it to 1 means valid.
  • the data line of the hash table storage device in this embodiment includes a parallel computing module 301, a parallel searching module 302, and a comparison module 303, wherein the parallel computing module 301 is configured to utilize each hash sub-table corresponding to a hash function, the hash value of the key value of the table to be searched is calculated in parallel; the parallel search module 302 is connected to the parallel computing module 301, and is configured to search for the hash values in parallel according to the calculated hash values in their respective corresponding bitmaps.
  • Comparison module 303 for using each bitmap The result of the look-up table is compared and judged, the address of the hash sub-table in which the matching entry is located is determined, the information of the entry stored in the address is taken out, and compared with the key value to be searched to determine whether the entry matches, such as If the match is made, the information of the entry is used as the final lookup result.
  • the bitmap corresponding to the hash sub-table in the lookup table when the bitmap corresponding to the hash sub-table in the lookup table is stored and the table entry is stored, the bitmap depth corresponding to the hash sub-table is the same; and the hash function corresponding to the hash sub-table and the storage table entry, the hash sub- The hash function corresponding to the table is the same.
  • the corresponding bitmap when the entry is looked up, the corresponding bitmap contains only one bit of the conflict bit.
  • the hash table storage device of the present embodiment splits the hash table into a plurality of hash sub-tables by using the table splitting module, and then the target hash sub-table determining module determines a target hash sub-table from which the entry is
  • the storage module calculates a hash value corresponding to the key value of the table to be stored by using a hash function corresponding to the target hash sub-table, and searches for a space in the target hash table according to the hash value, thereby storing the to-be-stored entry into the In the vacancy, when no vacancy is found, the key value of the entry to be stored is stored in the corresponding bitmap, and the target hash sub-table is updated until a vacancy is found to store the to-be-stored entry, thereby updating with a minimum
  • the time cost and the higher table space utilization realize that all the table entries are stored, and no table entries are left behind; on the other hand, the device uses the parallel computing module to calculate the hash value corresponding to the key value
  • the entry matches the entry to be searched, the entry is the entry to be searched, and then it is returned as the final search result, so that each hash subtable passes through the hash.
  • the table is split, and the storage address of the matching entry is determined in the bitmap, so that only one hash subtable can be accessed to accurately find the required entry, and the interface between the hardware and the memory is also facilitated. Implementation, can achieve a better balance in table space size, search efficiency and hardware implementation.
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • FIG. 3 is a schematic structural diagram of an embodiment of a hash table storage device according to an embodiment of the present invention.
  • the hash table storage search system of the present embodiment includes a main control logic module 505, a plurality of calculation modules 502a to 502n, a plurality of search modules 503a to 503n, an entry addition module 504, a statistics module 505, and an entry split module 506.
  • the internal connection of the hash table storage device of this embodiment is divided into a data line and a control line.
  • the main control logic module 501 is coupled to the plurality of calculation modules 502a-502n, the data decision module 509; and the plurality of calculation modules 502a ⁇ 502n are coupled to the plurality of lookup modules 503a-503n, respectively; the plurality of lookup modules 503a-503n are respectively coupled to the plurality of bitmap modules 507a-507n, and the plurality of bitmap modules 507a-507n are coupled to the plurality of entry storage modules 508a-508n;
  • the main control logic module 501 is coupled to the entry adding module 504, the statistics module 505, the table splitting module 506, and the exception handling module 510, and the entry adding module 504, the statistics module 505, the table splitting module 506, and the exception handling.
  • Modules 510 are each coupled to a plurality of lookup modules 503a-503n, respectively.
  • the main control logic module 501 is a control component of the hash table storage device, and is mainly used for controlling algorithm startup, termination, task scheduling, data distribution on the data path, and result collection and the like on the control line and the data line.
  • the master logic module 501 in this embodiment may be implemented by hardware logic, such as an ASIC (Application Specific Integrated Circuit) or an FPGA (Field Programmable Logic Gate Array) or other chip that can implement a logic function.
  • the main control logic module 501 in this embodiment may also be implemented by software running on a CPU (Central Processing).
  • the modules on the control line include an entry adding module 504, and a statistics module 505.
  • the entry splitting module 506 and the exception handling module 550 can all be implemented by software.
  • the plurality of calculation modules 502a to 502n are coupled to the main control logic module 501 and the plurality of search modules 503a to 503n.
  • the main control logic module 501 simultaneously sends the key values to be searched to the plurality of calculation modules.
  • 502a ⁇ 502 ⁇ the plurality of calculation modules 502 are configured to perform a hash operation on the assigned key values at the same time to obtain an index different from other calculation modules.
  • Each computing module 502 in this embodiment includes a hash function different from other computing modules 502, and the hash function in this embodiment can be implemented by various known methods, such as an exclusive OR array or a CRC-like CRC. Functions, or through complex mathematical operations, and so on.
  • the selection criterion of the hash function is to reduce the index number conflicts obtained by hash function operations of different key values as much as possible.
  • a plurality of lookup modules 503a through 503n are coupled to the plurality of compute modules 502a through 502n and the plurality of bitmap modules 507a through 507n, respectively, and a statistics module 505, an entry split module 506, and an exception handling module 510.
  • Each of the search modules 503 in the present embodiment is independently coupled to a bitmap module 507, and accesses and modifies the data in the bitmap module 507 and the storage module 508 corresponding to the bitmap through the address bus and data bus of the bitmap module 507.
  • each lookup module 503 receives the different index generated by the compute module 502 and converts it to the address of the bitmap module 507, thereby reading the address corresponding to the data in the memory module 508.
  • the searching module 503 transmits the received index value calculated by the plurality of calculating modules 502a to 502n and the data values obtained by the plurality of bitmap modules 507a to 507n to the data decision module 509 and Finding a key value comparison to determine whether a match is made; on the control line, the plurality of search modules 503a to 503n receive the read/write instructions issued by the statistics module 505, the table item splitting module 506, and the exception handling module 509, and convert the plurality of bitmap modules 507a into The address of ⁇ 507n operates on the stored data in the plurality of bitmap modules 507a to 507n, and further operates the data stored in the plurality of storage modules 508a to 508n.
  • the search module 503 in this embodiment simultaneously implements the functions of the control line and the data line.
  • the corresponding search module can also be set for the control line and the data line respectively.
  • the plurality of bitmap modules 507a to 507n are respectively coupled to the plurality of search modules 503a to 503n, and each of the bitmap modules 507 has an independent address access bus and an independent data bus. For each module, the address bus and the data bus can be complexed. Use, but multiple storage modules 508 Without multiplexing, the plurality of bitmap modules 507a to 507n are respectively coupled to the plurality of search modules 503a to 503n through the independent address access bus and the independent data bus, and the plurality of search modules 503a to 503n access the plurality of addresses by transmitting addresses.
  • the bitmap modules 507a to 507n correspond to data (conflict bits, valid bits and key values) stored at the transmitted address, and the plurality of bitmap modules 507a to 507n further correspond to one of the storage modules 508a to 508n, and each of the storage modules 508 A hash sub-table is stored, and each sub-table is obtained by splitting the hash table by the table item splitting module 506, and the storage address of the matching entry is determined in the bitmap module 507, and only the storage module 508a is accessed once. ⁇ 508n, so the memory modules 508a ⁇ 508n share a set of address access bus and data bus.
  • a plurality of bitmap modules 507a through 507n are coupled to the plurality of lookup modules 503a through 503n, respectively.
  • Each of the bitmap modules has a separate address access bus and a separate data bus.
  • the address bus and the data bus can be multiplexed, but multiple entries are not multiplexed between the storage modules.
  • the plurality of bitmap modules 507a to 507n are respectively coupled to the plurality of search modules 503a to 503n through the independent address access bus and the independent data bus, and the plurality of search modules 503a to 503n can access the plurality of bitmap modules 507a by sending addresses.
  • 507 ⁇ corresponds to the data (conflict bit, valid bit and key value) stored at the transmitted address.
  • the plurality of bitmap modules 507a to 507n respectively correspond to one entry storage module 508a to 508n, and each entry storage module stores a hash sub-table, wherein each sub-table is obtained by splitting the hash table, because The storage address of the matching entry has been determined in the bitmap, and only the entry storage modules 508a-508n are accessed once, so the entry storage modules 508a-508n share a set of address access bus and data bus.
  • the plurality of bitmap modules 507 and storage modules 508 in this embodiment may be implemented by various data storage technologies currently in existence. Since the bitmap module 507 requires parallel access and takes up less storage space, it can be implemented with on-chip SRAM.
  • the storage module 508 for example, in an application scenario requiring less delay, n independent high-speed SRAM chips can be used as the storage.
  • the high-speed SRAM chip may be various commonly used SRAM chips such as ZBT SRAM, QDR SRAM, QDRII SRAM, QDRII+ SRAM; in the case where a large-capacity entry space is required, n independent high-speed lines may be used.
  • the DRAM chip is used as the storage modules 508a-508n.
  • the high-speed DRAM chip may be various commonly used SDRAM chips such as SDRAM, DDR SDRAM, DDRII SDRAM, DDRIII SDRAM, etc. In the case where data needs to be saved by power-down, n can be used.
  • the independent FLASH chip is used as the storage modules 508a to 508n, and the FLASH chip may be NAND FLASH, NOR FLASH, NV RAM or other commonly used memory chips; in the case of massive data, the storage modules 508a to 508n may also be It can be realized by a plurality of independent hard disks, a plurality of independent disk storage arrays, or a mass data storage technology such as an optical disk drive, and a plurality of bitmap modules 507a to 507n and a storage module can be arbitrarily selected without departing from the scope of the present embodiment.
  • the data decision module 509 is coupled to the plurality of search modules 503a-503n and the plurality of storage modules 508a-508n to complete the decision operation of the search result.
  • the plurality of lookups 503a to 503n after obtaining the search results of the plurality of bitmap modules 507a to 507n, transfer the result to the data decision module 509, and the data decision module compares the search results of the bitmap modules 507a to 507n in the order of a ⁇ n to find out
  • the bitmap module 507 with the first conflict bit is 0, and the found bitmap address is transmitted to the plurality of storage modules 508a to 508n, and the data acquired from the storage module 508 is transmitted to the data decision module 509, and transmitted according to the main control logic module 501.
  • the data decision module 509 When the lookup is correct, the data decision module 509 returns the index value in the correct set of data to the master logic module 501, representing The result of this hash search; in the case of a search failure, the data decision module 509 will return to the master logic module 501 an invalid index value or an interrupt signal, informing the master logic module 501 that the current search failed.
  • Each hash subtable corresponds to a bitmap and a hash function, and the storage size of N hash subtables and N bitmaps can be selected as needed. For example, the 32-th power of 2, in the hash sub-table generation process, the table item splitting module 506 sequentially selects one of the M items, and sets the target hash sub-table and the bitmap as the first hash sub-table and the bitmap.
  • the entry is passed to the entry addition module 504.
  • the entry adding module 104 calculates the index value K of the entry according to the hash function corresponding to the first hash sub-table, and attempts to store the entry in the hash sub-table corresponding to the hash function.
  • the position of the index value K at the same time, the conflicting position 0 in the corresponding index value K position in the bitmap corresponding to the hash sub-table, the valid position 1, and the original 43 ⁇ 4 value is stored in the position.
  • the table splitting module 506 splits multiple hash sub-tables, it is possible to encounter a hash conflict, that is, two different key values are calculated to obtain the same hash sub-table.
  • the same index value if the bitmap conflict bit of the location is 0, the valid bit is 1, indicating that the location has been placed in an entry, and the data of the entry storage module corresponding to the index value needs to be taken out, and The conflicting bit value 1 in the bitmap corresponding to the index value, the current key value and the key value corresponding to the fetched entry are placed in the bitma; if the bitmap conflict bit of the location is 1, indicating that the location has collided more than once, The current key value is placed in the bitmap.
  • the failure message is returned to the table item splitting module 106, and the table item splitting module 506 determines whether the current target hash sub-table is the last hash sub-table, and if not, the item is The target sub-table is set to the next sub-table, and is passed to the entry adding module 504 to repeat the above process; If it is already the last hash sub-table, a failure message is returned to the main control logic module 501, and the exception processing module 509 is called by the main control logic module 501 to complete the update of the hash table.
  • the entry adding module 504 in this embodiment is on the control line, the contents of the bitmap module 507 and the storage module 508 can be read or modified by the plurality of lookup modules 503a to 503n.
  • the exception handling module 510 and the statistics module 505 are coupled to the plurality of lookup modules 503 and the master control logic module 501, respectively, to perform tasks such as system monitoring and error recovery. If each query fails, the statistics module 505 will count it into the lookup failure record.
  • the exception processing module 510 is configured to respond to the hash table refresh request sent by the master logic module 501, and clear the plurality of Bitmap modules 507a to 507n and the plurality of storage modules 508a to 508n through the plurality of search modules 503a to 503n. Reassign operation.
  • the hash table storage device of this embodiment will be divided into two parts, a data line and a control line, for detailed description.
  • the data line is composed of a main control logic module 501, a plurality of calculation modules 502a to 502n, a plurality of search modules 503a to 503n, a plurality of Bitmap modules 507a to 507n, a plurality of storage modules 508a to 508n, and a data decision module 509.
  • the data line is used to complete the search operation, and the control line is composed of the main control logic module 501, the item addition module 504, the statistics module 505, the table item splitting module 506, and the exception handling module 510.
  • the entry adding module 504 is coupled to the plurality of searching modules 503 for adding the conflicting state information and the entry data to the plurality of bitmap modules 507a to 507n and the plurality of storage modules 508a to 508n, wherein the control line is used to complete the entry addition and Delete operation.
  • the hash function corresponding to the hash sub-table obtained after the splitting may be a CRC function or other functions, and the CRC function is used as the hash sub-table corresponding to the embodiment.
  • the hash function is used, different CRC polynomials can be used between the hash functions corresponding to several hash subtables.
  • the embodiment further provides a method for adding a strong entry of a hash table.
  • FIG. 4 it is a schematic flowchart of an embodiment of a method for adding an entry of a hash table according to the embodiment.
  • the method for adding an entry of the hash table in this embodiment includes:
  • the hash table is split into multiple hash sub-tables, and each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function.
  • the key influencing factor of the split in this embodiment is the size of the storage space of each sub-table.
  • the storage space of the multiple hash sub-tables in this embodiment may be selected according to requirements. For example, the size of each small table space may be set to be the same, or the size of the storage space may be decreased.
  • the split mode is not limited to the above two modes. .
  • S403 The first hash sub-table is used as the current target hash sub-table.
  • S405 The key value of the storage entry is taken, and the hash value corresponding to the current target hash sub-table is used to calculate the hash value.
  • step S407. Determine, according to the calculated hash value, whether the storage location corresponding to the current target hash sub-table is a vacancy. If yes, go to step S409a. Otherwise, go to step S409b.
  • the information of the entry to be stored is stored in the slot, and step S4011 is performed.
  • the information of the entry in this embodiment includes information such as a table key value and a table lookup result.
  • Step S407 in this embodiment includes:
  • step S501 determining whether the capacity of the current target hash sub-table is less than the calculated hash value, and if so, Then, step S503a is performed, otherwise step S503b is performed.
  • step S503a according to the bit number corresponding to the capacity of the hash sub-table, intercepting the same bit number of the calculated hash value from the high bit, obtaining the intercepted hash value, and using the intercepted hash value as The index is executed in step S505.
  • step S503b directly using the calculated hash value as an index, and executing step S505.
  • step S505. Find a null bit in the target hash sub-table according to the index, that is, determine whether the valid bit of the bitmap is 0, and the conflict bit of the bitmap is 0. If yes, the storage location corresponding to the target hash sub-table is a vacancy. Then, step S409a is performed; otherwise, step S409b is performed.
  • step S409b in this embodiment includes:
  • step S601. Determine whether the conflict bit of the bitmap is 0, and whether the valid bit is 1. If yes, step S603a is performed. If the conflict bit of the bitmap is 1, step S603b is performed.
  • step S603a the bitmap corresponding to the stored table in the hash sub-table is taken out, and the conflict position of the bitmap is set to 1, and step S605 is performed.
  • S603b The key value of the current to-be-stored entry is stored in the bitmap, and step S607 is performed.
  • S605 The key value of the fetched entry and the key value of the current to-be-stored entry are stored in the bitmap.
  • S607. Determine whether the current target hash sub-table is the last hash sub-table. If yes, go to step S609a, otherwise go to step S609b.
  • the hash function corresponding to the hash sub-table is a cyclic redundancy code check function, and the hash functions corresponding to the multiple hash sub-tables adopt different cyclic redundancy. Code check polynomial.
  • the method for adding an entry of the hash table in this embodiment by splitting the hash table into multiple hash sub-tables, and each hash sub-table corresponds to a bitmap and a hash function, and then using the hash
  • the function calculates a hash value of the key value of the table to be stored, and the hash value determines the storage of the entry to be stored. Vacancies. Since each hash sub-table is obtained by splitting the hash table, and the storage address of the matching entry is determined in the bitmap, the implementation is achieved with a small update time cost and a high table space utilization rate. All entries are stored, and no entries are left behind.
  • the embodiment further provides a method for deleting an entry of a hash table.
  • the hash table in this embodiment includes a plurality of hash sub-tables, each of which corresponds to a bitmap, each bitmap corresponding to a hash function, and each of the bitmaps includes a plurality of entries.
  • the entry deletion method of the hash table storage device in this embodiment includes:
  • the hash function corresponding to each bitmap calculates the hash value of the item to be deleted in parallel.
  • S703. Search according to the calculated hash values in parallel in their respective bitmaps.
  • step S707. Compare the key value of the extracted item with the key value to be searched. If they are the same, perform step S709.
  • step S7013 Compare all the stored key values in all the bitmaps before the bitmap in which the deleted entry is located. If the key value stored in a bitmap is greater than two, step S7015a is performed, if some If the key value stored in the bitmap is equal to two, step S7015b is performed.
  • S7015b deletes the key value that needs to be deleted, and finds the location where another key value is stored.
  • S7017 The entry corresponding to another key value is taken out and stored in the hash sub-table corresponding to the bitmap.
  • the embodiment further provides a hash table search method.
  • the hash table searched in the method is composed of a plurality of hash sub-tables, and the storage space size of the plurality of hash sub-tables can be selected according to requirements.
  • Each bitmap has a separate address control line that can be accessed at the same time, all the hashes
  • the table shares a set of address control lines, and each table entry looks up only once for the hash subtable.
  • Each hash subtable corresponds to a hash function, and the hash function corresponding to each hash subtable is the same as the hash function corresponding to the hash subtable when the table entry is stored.
  • FIG. 8 is a flowchart of an implementation principle of the hash table searching method according to the embodiment.
  • the hash table search method in this embodiment mainly includes the following steps:
  • the hash values corresponding to the key values of the table to be searched are calculated in parallel by using multiple hash functions corresponding to the plurality of hash sub-tables.
  • step S807 the key value of the extracted entry is compared with the key value of the entry to be searched. If the key value of the retrieved entry matches the key of the to-be-find entry, step S809a is performed, otherwise, execution is performed. Step S809b.
  • Step S805 in this embodiment includes: intercepting the hash value according to the calculated hash sub-table corresponding to the hash value; using the intercepted hash value as an index, in the corresponding bitmap and the hash sub- Look in parallel in the table.
  • the hash table searching method in this embodiment by performing a hash value of the key value of the table to be searched in parallel, and searching according to the hash value to the corresponding bitmap, and comparing the search results, when the first time When the conflicting bit is invalid, the entry in the hash sub-table corresponding to the address of the bitmap is taken out; compared with the lookup table entry, if the match is matched, the entry is the entry to be searched, because Each hash subtable is obtained by splitting the hash table, and the storage address of the matching entry is determined in the bitmap, so that only one hash subtable can be accessed to accurately find the required entry. , also facilitates the implementation of the interface between the hardware and the memory, can be in the table space A good balance between size, search efficiency, and hardware implementation.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • each hash sub-table corresponds to a bitmap and a hash function, wherein input key values are input to the local through the input interface.
  • the hash value of the input key value is calculated by the hash table storage device, and the hash value is used as an index to search for a space in the bitmap and the hash sub-table, and is filled in; wherein bitmap0 ⁇ 9 is 10
  • bitmap0 ⁇ 9 is 10
  • the state table with the depth of m is stored.
  • the hash sub-tables 0 ⁇ 9 are 10 memories of the same size and storing the depth m.
  • the hash table storage device in this embodiment is used to complete all operations on input key values according to user requests, including addition, lookup, monitoring, exception handling, and the like.
  • the main control logic module 501 selects a hash function, and uses the hash function to calculate a corresponding hash value through the hash calculation logic, and adds an entry.
  • the logic module 504 completes the work of adding an entry
  • the lookup logic module 503 completes the lookup of the specified hash key.
  • the hash table storage device of this embodiment further includes a delete entry logic module, and a monitor logic module, which are not shown in the drawings.
  • the delete entry logic module completes the work of deleting the entry; the monitoring logic module monitors the space occupation in the hash sub-table during the process of adding and deleting the entry, and feeds this information back to the main control logic module 501.
  • the exception processing logic 510 is required to perform processing to maximize the addition of all the entries. In the table.
  • FIG. 10 is a flowchart of a specific embodiment of a method for adding an entry of a hash table according to the embodiment, the method includes the following steps:
  • S1001 Calculate a 16-bit hash value of a key value of the to-be-stored entry by using a hash function corresponding to the i-th hash sub-table, that is, a CRC16 function.
  • step S1003 Determine whether the table capacity of the i-th hash sub-table is less than the calculated hash value, and if yes, execute step S1005a, otherwise perform step S1005b.
  • step S1005a the calculated 16-bit hash value is intercepted from the high-order bit, and the intercepted hash value is used as an index, and step S1007 is performed.
  • step S1011 if the conflict bit of the bitmap is 0, and the valid bit is 1, that is, the address has stored one entry, step S1012 is performed; if the conflict bit of the bitmap is 1, step S1013 is performed.
  • step S1013 The stored entry is taken out, and the current key value and the extracted entry key value are stored in the bitmap, and the conflict position is 1, and step S1017 is performed.
  • FIG. 11 is a logical structural diagram of an embodiment of a lookup table entry in the embodiment.
  • the hash function 0 to 9 is first calculated in parallel.
  • the hash value, each hash function here must be the same as the hash function used to store the table entry; then the calculated hash value is used as the index value to search in parallel in the corresponding bitmap table to determine the matching table.
  • the address of the item, the address is transferred to the hash sub-table memory fetch entry, and each hash sub-table memory still has a port for CPU access; finally, the fetched entry is compared with the key value to be searched to determine the match. , all the information of the item as the final
  • the result of the lookup table is returned to the user, and the process of checking the table ends.
  • Embodiment 3 is a diagrammatic representation of Embodiment 3
  • the figure is a logical structure diagram of an embodiment of a hash table in the embodiment.
  • the input key value is input to the hash sub-table of the embodiment through an input interface, and the input is input through a hash table controller.
  • the key value calculates its hash value, and the hash value is used as an index to find the empty space in the hash sub-table and fill in; wherein the hash sub-table 0-9 is 10 memories, representing 10 hash sub-tables, and bitmap0 ⁇ 9 is 10 A state table, but the first four of the ten memories in this embodiment have a memory depth of m, and the last six have a memory depth of m/2.
  • the logical structure of the hash table controller in this embodiment, the storage of the hash table, the search process, and the logical structure of the lookup table are exactly the same as those in the second embodiment.
  • the space utilization rate of the third embodiment is higher. It is to be understood that the specific embodiments of the invention are limited only by the description. It is to be understood by those skilled in the art that the present invention may be practiced without departing from the spirit and scope of the invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Storage Device Security (AREA)

Abstract

Disclosed is a table entry adding method of a hash table, which comprises: splitting a hash table into multiple hash sub-tables, each hash sub-table being corresponding to a bitmap and a hash function; using the hash function to calculate a hash value of a key of a table entry to be stored; and determining an unoccupied position for storing the table entry to be stored according to the hash value. Also disclosed are a table entry deleting and searching method of a hash table and a hash table storage device. According to the present invention, with a rather small search time and high table space utilization rate, all table entries are stored and no table entry is left; the required table entry can be found accurately by accessing the memory once; and meanwhile, an interface between the hardware and the memory can be easily realized, so that the table space size, search efficiency and hardware implementation can be well balanced.

Description

哈希表的表项添加、 删除、 查找方法及哈希表存储装置 技术领域  Hash table entry addition, deletion, search method, and hash table storage device
本发明涉及通信技术领域, 尤其涉及一种哈希表的表项添加、 删除、 查找方法及哈希表存储装置。 背景技术  The present invention relates to the field of communications technologies, and in particular, to a method for adding, deleting, searching, and hashing a table of a hash table. Background technique
在通信领域中, 存在着多种的匹配算法, 例如, 对于精确匹配的查找, 可以采用哈希算法。 哈希查找的过程就是用哈希函数对输入的查找键值 In the field of communication, there are various matching algorithms. For example, for an exact matching search, a hash algorithm can be employed. The process of hash lookup is to use the hash function to find the key value of the input.
( Key )进行缩位运算, 再用计算得到的哈希值在哈希索引表中寻址, 找到 匹配项后读出对应项中存放的哈希索引 (Hash Index ), 最后用哈希索引在 直接地址映射表寻址, 得到所需的查找结果。 (Key) performs the abbreviated operation, and then uses the calculated hash value to be addressed in the hash index table. After finding the matching item, the hash index (Hash Index) stored in the corresponding item is read, and finally the hash index is used. The direct address mapping table is addressed to get the desired lookup results.
哈希算法是一种常见的快速查找算法, 它的基本思想是以线性表中每 个元素的关键字 k为自变量。 通过一定的函数关系 H(k), 计算出对应的函 数值来, 并把这个值解释为一块连续存储空间的单元, 将该元素存储到这 个单元中。 哈希算法将元素的存储位置和它的关键字之间建立一个确定的 对应关系, 查找时, 不需要比较, 一次哈希映射就可以查找所需元素。  The hash algorithm is a common fast search algorithm. Its basic idea is to use the keyword k of each element in the linear table as an independent variable. Through a certain functional relationship H(k), the corresponding function value is calculated, and this value is interpreted as a unit of continuous storage space, and the element is stored in this unit. The hash algorithm establishes a certain correspondence between the storage location of the element and its keyword. When searching, there is no need to compare, and a hash map can find the required element.
在哈希函数中,对不同的关键字可能得到同一哈希地址,即 keyl≠key2, 而 H(keyl)=H(key2), 这种情况叫沖突( Collision )。 一般来说, 遇到沖突是 很正常的事情, 关键在于遇到沖突后怎么处理, 以达到要求的查找目的。 处理沖突主要有以下两种方法: 一是选择和改进比较好的哈希函数; 二是 选择比较合适的表项存储结构。  In the hash function, the same hash address may be obtained for different keywords, namely keyl≠key2, and H(keyl)=H(key2), which is called collision (Collision). In general, it is normal to encounter conflicts. The key is how to deal with them after a conflict to achieve the desired search purpose. There are two main methods to deal with conflicts: one is to select and improve the better hash function; the other is to choose the appropriate table item storage structure.
目前, 对于路由查找这类的应用, 采用 CRC ( Cyclic Redundancy Checking, 循环冗余码校验)类的哈希函数是比较适合的。 通过选取不同的 CRC多项式, 可以实现同一个位宽下的不同哈希函数。 在选择合适的表存储结构解决沖突问题方面, 可以采用多维哈希表、 沖突链、 Double Hashing等。 仿真实验结果表明, 使用这些方法, 在保证无 表项遗留即所有表项都能存入的前提条件下, 计算哈希值的次数跟需要的 存储表空间存在对立的关系, 也就是说如果想要以足够小的存储空间放下 所有的表项, 则需要进行足够多次数的哈希运算。 这样就会造成对同一块 表的多次访问, 由于表只有一张, 所以查找只能顺序进行, 这会严重影响 查表的速度; 另一方面, 如果想要以足够少的计算次数找到存储空位, 那 么就要保证存储空间足够的大, 空间利用率就会大大的降低。 如果采用多 张哈希表并行查找, 则需要占用多个存储器接口, 不利于硬件上的实现。 发明内容 Currently, for applications such as route lookup, a hash function using the CRC (Cyclic Redundancy Checking) class is suitable. Different hash functions under the same bit width can be achieved by selecting different CRC polynomials. Multidimensional hash tables, conflict chains, Double Hashing, etc. can be used to select the appropriate table storage structure to resolve conflicts. The simulation results show that using these methods, under the premise of ensuring that no entries remain, that is, all the entries can be stored, the number of times the hash value is calculated is opposite to the required storage table space, that is, if you want To drop all the entries with a small enough storage space, you need to do a sufficient number of hashes. This will result in multiple accesses to the same table. Since there is only one table, the search can only be performed sequentially, which will seriously affect the speed of the table lookup. On the other hand, if you want to find the storage with a small enough number of calculations Vacancies, then ensure that the storage space is large enough, the space utilization will be greatly reduced. If multiple hash tables are used for parallel search, multiple memory interfaces are required, which is not conducive to hardware implementation. Summary of the invention
本发明提供一种哈希表的表项添加、 删除、 查找方法及哈希表存储装 置, 能够以极小的查找时间代价以及较高的表空间利用率实现全部表项存 储而无表项遗留; 同时只需访问一次就能够准确的查找到需要的表项; 同 时也便于硬件与存储器之间接口的实现, 能够在表空间大小, 查找效率以 及硬件实现方面获得比较好的均衡。  The invention provides a method for adding, deleting, searching and hashing a table entry of a hash table, which can realize storage of all entries without a table entry with a minimum search time cost and a high table space utilization rate. At the same time, it only needs to be accessed once to accurately find the required items. At the same time, it is also convenient to implement the interface between hardware and memory, which can achieve better balance in table space size, search efficiency and hardware implementation.
为解决上述技术问题, 本发明实施例采用的技术方案如下:  To solve the above technical problem, the technical solution adopted by the embodiment of the present invention is as follows:
一种哈希表的表项添加方法,包括:  A method for adding a table entry of a hash table, including:
将哈希表拆分为多张哈希子表, 每一张哈希子表对应一张位图, 每一 张位图对应一个哈希函数;  Splitting the hash table into multiple hash sub-tables, each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function;
确定当前目标哈希子表, 利用当前目标哈希子表所对应的位图相应的 哈希函数计算待存储表项的键值的哈希值, 根据所述哈希值确定当前目标 哈希子表所对应的存储位置是否为空位, 如是, 将所述待存储表项的信息 存入该空位中, 否则, 更新当前目标哈希子表直至找到空位存储所述待存 储表项的信息。  Determining a current target hash sub-table, calculating a hash value of the key value of the table to be stored by using a hash function corresponding to the bitmap corresponding to the current target hash sub-table, and determining, according to the hash value, a current target hash sub-table Whether the storage location is a vacancy, if yes, the information of the to-be-stored entry is stored in the vacancy, otherwise, the current target hash sub-table is updated until a vacancy is found to store the information of the to-be-stored entry.
进一步地, 所述位图包含了沖突位和有效位, 根据所述哈希值确定当 前目标哈希子表所对应的存储位置是否为空位, 如是, 将所述待存储表项 的信息存入该空位中, 否则, 更新当前目标哈希子表直至找到空位存储所 述待存储表项的信息的步驟, 包括: Further, the bitmap includes a conflict bit and a valid bit, and is determined according to the hash value. Whether the storage location corresponding to the previous target hash sub-table is a vacancy, if yes, the information of the to-be-stored entry is stored in the vacancy, otherwise, the current target hash sub-table is updated until a vacancy is found to store the to-be-stored entry. The steps of the information, including:
以所述哈希值作为索引, 查找所述当前目标哈希子表对应的位图; 判断所述位图的有效位是否有效, 且所述位图的沖突位是否为无效; 如果所述有效位为有效, 且所述沖突位为无效, 则确定所述当前目标 哈希子表所对应的存储位置为空位, 则将所述待存储表项的信息存入该空 位; 否则, 更新当前目标哈希子表直至找到空位存储所述待存储表项的信 更进一步地, 所述以所述哈希值作为索引, 查找所述当前目标哈希子 表对应的位图的步驟, 包括:  Using the hash value as an index, searching for a bitmap corresponding to the current target hash sub-table; determining whether the valid bit of the bitmap is valid, and whether the conflict bit of the bitmap is invalid; if the valid bit If it is valid, and the conflict bit is invalid, it is determined that the storage location corresponding to the current target hash sub-table is a vacancy, and the information of the to-be-stored entry is stored in the vacancy; otherwise, the current target hash is updated. And the step of searching for the bitmap corresponding to the current target hash sub-table by using the hash value as an index, and the method includes:
判断当前目标哈希子表的容量是否小于计算得到的所述哈希值的位 数;  Determining whether the capacity of the current target hash sub-table is less than the calculated number of bits of the hash value;
如果所述当前目标哈希子表的容量小于计算得到的所述哈希值的位 数, 则截取所述哈希值, 并将截取后的哈希值作为索引, 查找所述当前目 标哈希子表对应的位图。  If the capacity of the current target hash sub-table is less than the calculated number of bits of the hash value, intercept the hash value, and use the intercepted hash value as an index to find the current target hash sub-table The corresponding bitmap.
更进一步地, 将所述待存储表项的信息存入空位后, 还包括: 将所述位图的有效位置为无效, 并将所述待存储表项的键值存储到该 位图中。  Further, after the information of the to-be-stored entry is stored in the vacancy, the method further includes: invalidating the valid position of the bitmap, and storing the key value of the to-be-stored entry into the bitmap.
更进一步地, 更新当前目标哈希子表直至找到空位存储所述待存储表 项的信息的步驟, 包括:  Further, the step of updating the current target hash sub-table until finding a space to store the information of the to-be-stored item includes:
当所述位图的沖突位为无效, 有效位为无效, 则将该位图对应的哈希 子表中已存的表项取出, 将该沖突位置为有效, 并将取出表项的键值与当 前的待存储表项的键值存入该位图中;  When the conflict bit of the bitmap is invalid and the valid bit is invalid, the existing entry in the hash sub-table corresponding to the bitmap is taken out, the conflict position is valid, and the key value of the entry is taken out. The key value of the current table to be stored is stored in the bitmap;
判断当前的目标哈希子表是否为最后一张哈希子表, 如果不是最后一 张哈希子表, 则将当前目标哈希子表更新为下一张哈希子表, 直至查找到 空位存储所述待存储表项的信息。 Determine whether the current target hash subtable is the last hash subtable, if not the last one The hash sub-table updates the current target hash sub-table to the next hash sub-table until the vacancy is found to store the information of the to-be-stored entry.
更进一步地, 更新当前目标哈希子表直至找到空位存储所述待存储表 项的信息的步驟, 包括:  Further, the step of updating the current target hash sub-table until finding a space to store the information of the to-be-stored item includes:
当该位图的沖突位为有效, 则当前的待存储表项的键值直接存入到该 位图中;  When the conflict bit of the bitmap is valid, the key value of the current to-be-stored entry is directly stored in the bitmap;
判断当前目标哈希子表是否为最后一张哈希子表, 如果不是最后一张 哈希子表, 则将当前目标哈希子表更新为下一张哈希子表, 直至找到空位 存储所述待存储表项的信息。  Determining whether the current target hash sub-table is the last hash sub-table, if not the last hash sub-table, updating the current target hash sub-table to the next hash sub-table until the empty space is found to store the to-be-stored entry Information.
更进一步地, 所述方法还包括:  Further, the method further includes:
当所述待存储表项存储完成后, 同步更新位图的沖突位信息和哈希子 表的信息。  After the storage of the to-be-stored entry is completed, the conflict bit information of the bitmap and the information of the hash sub-table are synchronously updated.
更进一步地, 所述哈希子表对应的哈希函数为循环冗余码校验函数。 更进一步地, 所述多张哈希子表对应的哈希函数之间采用不同的循环 冗余码校验多项式。  Further, the hash function corresponding to the hash sub-table is a cyclic redundancy code check function. Further, different cyclic redundancy code check polynomials are used between the hash functions corresponding to the plurality of hash sub-tables.
一种哈希表的表项删除方法, 哈希表包括多张哈希子表, 每一张哈希 子表对应一张位图, 每一张位图对应一个哈希函数, 且每张所述位图包括 多个条目, 则所述方法包括:  A hash table entry deletion method, the hash table includes a plurality of hash sub-tables, each hash sub-table corresponds to a bitmap, each bitmap corresponds to a hash function, and each of the bits The figure includes a plurality of entries, and the method includes:
每张位图所对应的哈希函数并行计算需要删除的条目的哈希值; 根据计算得到的哈希值, 在其各自对应的位图中并行查找;  The hash function corresponding to each bitmap calculates the hash value of the item to be deleted in parallel; according to the calculated hash value, it searches in parallel in its corresponding bitmap;
将每一张位图的查找结果顺序进行比较, 当第一次出现沖突位为无效 时, 将该位图的地址对应的哈希子表中的表项取出;  The search results of each bitmap are sequentially compared. When the first occurrence of the conflict bit is invalid, the entry in the hash sub-table corresponding to the address of the bitmap is taken out;
将取出的表项的键值与需要查找的键值进行比较, 如果相同, 则将所 述表项从所述哈希子表中删除。  The key value of the fetched entry is compared with the key value to be searched. If they are the same, the entry is deleted from the hash subtable.
进一步地, 删除表项后还包括; 将对应的位图的沖突位置为无效, 有效位置为有效。 Further, after deleting the entry, the method further includes; The conflict position of the corresponding bitmap is invalid, and the valid position is valid.
进一步地, 所述方法还包括:  Further, the method further includes:
将删除的表项所在的位图之前的所有位图中的所存储的所有键值进行 比较;  Compare all stored key values in all bitmaps before the bitmap in which the deleted entry is located;
如果某个位图中所存储的键值大于两个, 则直接将需要删除的键值删 掉; 或者,  If the key value stored in a bitmap is greater than two, delete the key value that needs to be deleted directly; or,
如果某个位图中所存储的键值等于两个, 则将需要删除的键值删掉, 并查找到另一个键值所存储的位置, 将其取出, 存入该位图所对应的哈希 子表中。  If the key value stored in a bitmap is equal to two, delete the key value that needs to be deleted, and find the location where another key value is stored, take it out, and store it in the corresponding bitmap. In the table.
一种哈希表的查找方法, 所述哈希表包括多张哈希子表, 每张哈希子 表对应一张位图, 每张位图对应一个哈希函数, 则所述哈希表查找方法包 括:  A hash table search method, the hash table includes a plurality of hash sub-tables, each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function, and the hash table search method Includes:
利用每张哈希子表对应的哈希函数并行计算待查找表项的键值的哈希 值;  Using the hash function corresponding to each hash sub-table to calculate the hash value of the key value of the item to be searched in parallel;
根据计算得到的所述哈希值在对应的位图中并行查找;  The hash value obtained according to the calculation is searched in parallel in the corresponding bitmap;
将每一张位图的查找结果顺序进行比较, 当第一次出现沖突位为无效 时, 取出该位图的地址对应的哈希子表中的表项;  The search results of each bitmap are sequentially compared. When the first occurrence of the conflict bit is invalid, the entry in the hash sub-table corresponding to the address of the bitmap is taken out;
将取出的表项的键值与待查找表项的键值进行比较, 如果取出的表项 的键值与所述待查找表项的键值相匹配, 则将该表项的信息作为最终查表 结果。  The key value of the extracted entry is compared with the key value of the entry to be searched. If the key value of the retrieved entry matches the key of the to-be-find entry, the information of the entry is used as a final check. Table results.
进一步地, 所述方法还包括: 如果取出的表项的键值与所述待查找表 项的键值不相匹配, 则返回查找失败的消息。  Further, the method further includes: if the key value of the extracted entry does not match the key value of the to-be-find entry, returning a message that the search fails.
更进一步地, 根据计算得到的所述哈希值在对应的位图中并行查找的 步驟, 包括:  Further, the step of searching in parallel according to the calculated hash value in the corresponding bitmap includes:
根据计算得到的所述哈希值对应的哈希子表的容量, 对所述哈希值进 行截取; Calculating the capacity of the hash sub-table corresponding to the hash value, and calculating the hash value Line interception
将截取后的哈希值作为索引, 在其对应的位图中并行查找。  The intercepted hash value is used as an index and is searched in parallel in its corresponding bitmap.
更进一步地, 所述位图对应的哈希函数与存储表项时所述哈希子表对 应的哈希函数相同。  Further, the hash function corresponding to the bitmap is the same as the hash function corresponding to the hash sub-table when the table entry is stored.
一种哈希表存储装置, 包括主控逻辑模块, 以及与所述主控逻辑模块 相连的控制线路和数据线路, 其中, 主控逻辑模块控制所述控制线路完成 表项的添加和 /或删除, 以及控制数据线路完成表项查找, 所述控制线路包 括: 表项拆分模块, 目标哈希子表确定模块和表项存储模块, 其中,  A hash table storage device includes a main control logic module, and a control line and a data line connected to the main control logic module, wherein the main control logic module controls the addition and/or deletion of the control line completion entry And the control data line completion entry search, where the control line includes: an entry split module, a target hash sub-determination module, and an entry storage module, where
所述表项拆分模块, 设置为将哈希表拆分为多张哈希子表和多张位图, 且每张哈希子表对应一张位图和一个哈希函数;  The table splitting module is configured to split the hash table into multiple hash subtables and multiple bitmaps, and each hash subtable corresponds to a bitmap and a hash function;
所述目标哈希子表确定模块, 与所述表项拆分模块相连, 设置为从所 述表项拆分模块拆分得到的多张哈希子表中的确定一张哈希子表作为当前 的目标哈希子表; 并当接收到所述表项存储模块发出的更新指令后, 设置 为将当前的目标哈希子表更新为其下一张哈希子表;  The target hash sub-table determining module is connected to the table splitting module, and is configured to determine a hash sub-table from the plurality of hash sub-tables obtained by splitting the table splitting module as a current target. Hash subtable; and after receiving the update instruction issued by the entry storage module, set to update the current target hash subtable to its next hash subtable;
所述表项存储模块, 与所述目标哈希子表确定模块相连, 设置为利用 所述当前目标哈希子表所对应的哈希函数, 计算所述待存储表项的键值的 哈希值, 并根据所述哈希值确定当前目标哈希子表所对应的存储位置是否 为空位, 如是, 将待存储表项的信息存入该空位, 否则向所述目标哈希子 表确定模块发送更新指令, 直至查找到空位存储所述待存储表项的。  The entry storage module is configured to be connected to the target hash sub-table determining module, and configured to calculate a hash value of the key value of the to-be-stored entry by using a hash function corresponding to the current target hash sub-table. And determining, according to the hash value, whether the storage location corresponding to the current target hash sub-table is a vacancy, and if yes, storing information of the entry to be stored in the vacancy, otherwise sending an update instruction to the target hash sub-determination module, The storage of the to-be-stored entry is not found until the slot is found.
进一步地, 所述位图包含沖突位和有效位, 所述表项存储模块包括计 算子模块、 查找子模块、 表项添加子模块, 其中,  Further, the bitmap includes a conflicting bit and a valid bit, and the entry storage module includes a calculation submodule, a lookup submodule, and an entry add submodule, where
所述计算子模块, 与所述目标哈希子表确定模块相连, 设置为利用所 述当前目标哈希子表所对应的哈希函数, 计算所述待存储表项的键值的哈 希值;  The calculation sub-module is connected to the target hash sub-table determination module, and is configured to calculate a hash value of the key value of the to-be-stored entry by using a hash function corresponding to the current target hash sub-table;
所述查找子模块, 与所述计算子模块相连, 设置为判断所述目标哈希 子表确定模块计算的哈希值的位数是否大于等于所述当前目标哈希子表的 容量, 如是, 则截取所述哈希值, 并将截取后的哈希值作为索引, 查找相 应的位图, 并判断所述位图的有效位是否有效, 且所述位图的沖突位是否 为无效, 如是, 则判定所述目标哈希子表中的存储位置为空位, 否则, 则 向所述目标哈希子表确定模块发送更新指令, 直至查找到空位; The search submodule is connected to the calculation submodule and configured to determine the target hash The sub-table determines whether the number of bits of the hash value calculated by the module is greater than or equal to the capacity of the current target hash sub-table, and if so, intercepts the hash value, and uses the intercepted hash value as an index to find the corresponding bit. And determining whether the valid bit of the bitmap is valid, and whether the conflict bit of the bitmap is invalid, and if yes, determining that the storage location in the target hash sub-table is a vacancy; otherwise, proceeding to the target The hash sub-table determines that the module sends an update instruction until a space is found;
所述表项添加子模块, 与所述查找子模块相连, 设置为当所述查找子 模块在所述当前目标哈希子表中查找到空位时, 将所述待存储表项的信息 存入所述空位中。  Adding a sub-module of the entry to the lookup sub-module, and setting, when the search sub-module finds a vacancy in the current target hash sub-table, storing the information of the to-be-stored entry into the Said in the vacancy.
进一步地, 当所述表项添加子模块, 将所述待存储表项的信息存入所 述空位中后, 所述表项添加子模块还设置为将所述位图的有效位置为无效, 并将所述待存储表项的键值存储到所述位图中。  Further, after the sub-module is added to the entry, the information about the to-be-stored entry is stored in the slot, and the entry-add sub-module is further configured to invalidate the valid position of the bitmap. And storing the key value of the item to be stored in the bitmap.
进一步地, 当所述查找子模块判断出所述位图的有效位为无效时, 还 设置为判断所述位图的沖突位是否为无效, 如是, 则所述表项添加子模块 设置为将所述位图对应哈希子表中已存储的表项取出, 并将取出的表项的 键值与所述当前待存储表项的键值存入到所述位图中; 当所述查找子模块 判断出所述位图的沖突位为有效时, 则所述表项存储模块的表项添加子模 块设置为将当前的所述待存储表项的键值存储到所述位图中。  Further, when the searching sub-module determines that the valid bit of the bitmap is invalid, it is further configured to determine whether the conflict bit of the bitmap is invalid, and if yes, the entry adding submodule is set to be The bitmap corresponding to the stored table entry in the hash sub-table, and the key value of the extracted entry and the key value of the current to-be-stored entry are stored in the bitmap; When the module determines that the conflict bit of the bitmap is valid, the entry adding submodule of the entry storage module is configured to store the current key value of the to-be-stored entry into the bitmap.
进一步地, 所述哈希表包括多张哈希子表, 每张哈希子表对应一张位 图和一个哈希函数, 所述数据线路包括并行计算模块, 并行查找模块以及 比较模块, 其中,  Further, the hash table includes a plurality of hash sub-tables, each of the hash sub-tables corresponds to a bitmap and a hash function, and the data line includes a parallel computing module, a parallel search module, and a comparison module, where
并行计算模块, 设置为利用每张哈希子表对应的哈希函数, 并行计算 待查找表项的键值的哈希值;  The parallel computing module is configured to calculate a hash value of the key value of the to-be-find table item in parallel by using a hash function corresponding to each hash sub-table;
并行查找模块, 与所述并行计算模块相连, 设置为根据计算得到的哈 希值在其各自对应的位图中并行地查找;  a parallel search module, connected to the parallel computing module, configured to search in parallel according to the calculated hash values in their respective bitmaps;
比较模块, 设置为将各个位图的查表结果进行比较判断, 确定出匹配 的表项所在的哈希子表的地址, 将该地址存储的表项的信息取出, 并与需 要查找的键值进行比较, 判断取出的表项是否与待查找的表项相匹配, 如 匹配, 则将该表项的信息作为最终查表结果。 The comparison module is set to compare and compare the lookup results of the respective bitmaps to determine a match. The address of the hash table in which the entry is located, the information of the entry stored in the address is taken out, and compared with the key value to be searched, to determine whether the extracted entry matches the entry to be searched, such as matching. Then the information of the entry is used as the final lookup result.
本发明实施例所述的哈希表的表项添加方法, 通过将哈希表拆分为多 张哈希子表, 且每一张哈希子表对应一张位图和一个哈希函数, 再利用该 哈希函数计算待存储表项的键值的哈希值, 由该哈希值来确定存储待存储 表项的空位, 即由于每张哈希子表都是通过对哈希表进行拆分得到, 且在 位图中已经确定了匹配表项的存储地址, 从而以极小的更新时间代价以及 较高的表空间利用率实现全部表项存储, 而无表项遗留。  The method for adding an entry of a hash table according to the embodiment of the present invention, by splitting the hash table into multiple hash sub-tables, and each hash sub-table corresponds to a bitmap and a hash function, and then utilizing The hash function calculates a hash value of the key value of the table to be stored, and the hash value is used to determine the space for storing the entry to be stored, that is, since each hash sub-table is obtained by splitting the hash table. The storage address of the matching entry has been determined in the bitmap, so that all the entries are stored with a minimum update time cost and a high table space utilization, and no entry remains.
本发明实施例所述的哈希表查找方法, 通过并行计算待查找表项键值 的哈希值, 并根据该哈希值到对应位图中进行查找, 并将查找的结果进行 对比, 当第一次出现沖突位为无效时, 取出该位图的地址对应的哈希子表 中的表项; 将其与带查找表项进行对比, 如果相匹配, 则该表项即为待查 找的表项, 由于每张哈希子表都是通过对哈希表进行拆分得到, 且在位图 中已经确定了匹配表项的存储地址, 从而只需访问一次哈希子表就能够准 确的查找到需要的表项, 同时也便于硬件与存储器之间接口的实现, 能够 在表空间大小, 查找效率以及硬件实现方面获得比较好的均衡。 附图说明  The hash table searching method according to the embodiment of the present invention calculates the hash value of the key of the table to be searched in parallel, and searches according to the hash value to the corresponding bitmap, and compares the search results. When the conflicting bit is invalid for the first time, the entry in the hash sub-table corresponding to the address of the bitmap is taken out; compared with the lookup table entry, if it matches, the entry is the table to be searched. Item, because each hash sub-table is obtained by splitting the hash table, and the storage address of the matching table item has been determined in the bitmap, so that only one visit to the hash sub-table can accurately find the need The table entry also facilitates the implementation of the interface between hardware and memory, and achieves a better balance in table space size, search efficiency, and hardware implementation. DRAWINGS
图 1为本发明的哈希表存储装置的一实施例的结构示意图;  1 is a schematic structural diagram of an embodiment of a hash table storage device of the present invention;
图 2为本发明的表项存储模块的一实施例的结构示意图;  2 is a schematic structural diagram of an embodiment of an entry storage module according to the present invention;
图 3为本发明的哈希表存储装置的一具体实施例的结构示意图; 图 4为本发明的哈希表的表项添加方法的一实施例的流程图; 图 5为本发明的哈希表的表项添加方法的步驟 S407的一实施例的流程 图;  3 is a schematic structural diagram of a specific embodiment of a hash table storage device of the present invention; FIG. 4 is a flowchart of an embodiment of a method for adding a hash table of the present invention; FIG. 5 is a hash of the present invention; A flowchart of an embodiment of step S407 of the table entry adding method of the table;
图 6为本发明的哈希表的表项添加方法的步驟 S409b的一实施例的流 程图; 6 is a flow of an embodiment of step S409b of the method for adding a table entry of the hash table of the present invention; Cheng Tu
图 7为本发明的哈希表的表项删除方法的一实施例的流程图; 图 8为本发明的哈希表查找方法的一实施例的流程图;  7 is a flowchart of an embodiment of a method for deleting an entry of a hash table according to the present invention; FIG. 8 is a flowchart of an embodiment of a method for searching a hash table according to the present invention;
图 9为本发明的哈希表的一实施例的逻辑结构图;  9 is a logical structural diagram of an embodiment of a hash table of the present invention;
图 10为本发明的哈希表的表项添加的一具体实施例的流程图; 图 11为本发明的查找哈希表的一实施例的逻辑结构示意图。 具体实施方式  FIG. 10 is a flowchart of a specific embodiment of an entry of a hash table of the present invention; FIG. 11 is a schematic diagram of a logical structure of an embodiment of a lookup hash table according to the present invention. detailed description
下面通过具体实施方式结合附图对本发明作进一步详细说明。  The present invention will be further described in detail below with reference to the accompanying drawings.
请参考图 1 , 为本实施方式的哈希表存储装置的一实施例的结构框图。 本实施方式的哈希表存储装置包括主控逻辑模块 100,以及与主控逻辑模块 100相连的控制线路和数据线路, 其中, 主控逻辑模块 100控制控制线路完 成表项的添加和 /或删除,控制数据线路完成表项查找, 其中控制线路包括: 表项拆分模块 101 , 目标哈希子表确定模块 102和表项存储模块 103,其中, 表项拆分模块 101 , 目标哈希子表确定模块 102和表项存储模块 103,其中, 表项拆分模块 101 , 用于将哈希表拆分为多张哈希子表和多张位图,且每张 哈希子表对应一张位图和一个哈希函数; 目标哈希子表确定模块 102与表 项拆分模块 101相连, 用于将表项拆分模块 101拆分得到的多张哈希子表 中的第一张哈希子表作为当前的目标哈希子表, 并当接收到表项存储模块 103发出的更新指令后,用于将当前的目标哈希子表更新为其下一张哈希子 表; 表项存储模块 103, 与目标哈希子表确定模块 102相连, 用于利用当前 目标哈希子表所对应的哈希函数, 计算待存储表项的键值的哈希值, 并根 据该哈希值确定当前目标哈希子表所对应的存储位置是否为空位, 如是, 将待存储表项的信息存入该空位, 否则向目标哈希子表确定模块 102发送 更新指令, 直至查找到空位存储待存储表项。  Please refer to FIG. 1 , which is a structural block diagram of an embodiment of a hash table storage device according to an embodiment of the present invention. The hash table storage device of this embodiment includes a main control logic module 100, and a control line and a data line connected to the main control logic module 100, wherein the main control logic module 100 controls the addition and/or deletion of the control line completion entry. The control data line completes the entry search, wherein the control line includes: an entry split module 101, a target hash sub-determination module 102, and an entry storage module 103, wherein the entry split module 101 and the target hash sub-determination module 102 and the entry storage module 103, wherein the table entry splitting module 101 is configured to split the hash table into multiple hash sub-tables and multiple bitmaps, and each hash sub-table corresponds to one bitmap and one The hash function table 102 is connected to the table splitting module 101, and is used as the current target in the first hash sub-table of the plurality of hash sub-tables obtained by splitting the table splitting module 101. Hash subtable, and after receiving the update instruction issued by the entry storage module 103, is used to update the current target hash subtable to its next hash subtable; the entry storage module 103, And the target hash sub-table determination module 102 is configured to calculate a hash value of the key value of the table to be stored by using a hash function corresponding to the current target hash sub-table, and determine a current target hash sub-table according to the hash value. If the corresponding storage location is a vacancy, if yes, the information of the entry to be stored is stored in the vacancy, otherwise the update instruction is sent to the target hash sub-determination module 102 until the vacant storage of the entry to be stored is found.
请参考图 2, 为本实施方式的表项存储模块的一实施例的结构示意图。 本实施方式中的位图包含沖突位和有效位。 本实施方式中表项存储模块包 括计算子模块 200、 查找子模块 201、 表项添加子模块 203 , 其中, 计算子 模块 200, 与目标哈希子表确定模块相连, 用于利用当前目标哈希子表所对 应的哈希函数, 计算待存储表项的键值的哈希值; 查找子模块 201 , 与计算 子模块 200相连, 用于判断该目标哈希子表确定模块计算的哈希值的位数 是否大于等于当前目标哈希子表的容量, 如是, 则截取该哈希值, 并将截 取后的哈希值作为索引, 查找相应的位图, 并判断查找到的位图的有效位 是否有效, 且沖突位是否为无效, 如是, 则判定该目标哈希子表中的存储 位置为空位, 否则, 则向目标哈希子表确定模块发送更新指令, 直至查找 到空位; 表项添加子模块 202, 与查找子模块 201相连, 用于当查找子模块 201 在当前目标哈希子表中查找到空位时, 将待存储表项的信息存入空位 中, 并将该位图的有效位置为无效, 将待存储表项的键值存储到该位图中, 而当查找子模块 201 判断出该位图的有效位为无效时, 还用于判断该位图 的沖突位是否为无效, 如是, 则表项添加子模块用于将位图对应哈希子表 中已存储的表项取出, 并将取出的表项的键值与当前待存储表项的键值存 入到位图中; 当查找子模块 201 判断出位图的沖突位为有效时, 则表项添 加子模块 202用于将当前的待存储表项的键值存储到该位图中。 Please refer to FIG. 2 , which is a schematic structural diagram of an embodiment of an entry storage module according to an embodiment of the present invention. The bitmap in this embodiment includes a collision bit and a valid bit. In the embodiment, the entry storage module includes a calculation submodule 200, a lookup submodule 201, and an entry addition submodule 203, wherein the calculation submodule 200 is connected to the target hash subform determination module for utilizing the current target hash subtable. The corresponding hash function calculates a hash value of the key value of the entry to be stored; the search submodule 201 is connected to the calculation submodule 200, and is used for determining the number of bits of the hash value calculated by the target hash subtable determination module. Whether it is greater than or equal to the capacity of the current target hash subtable, if yes, intercept the hash value, and use the intercepted hash value as an index to find the corresponding bitmap, and determine whether the valid bit of the found bitmap is valid. And if the conflict bit is invalid, if yes, it is determined that the storage location in the target hash sub-table is a vacancy; otherwise, the update instruction is sent to the target hash sub-table determination module until the vacancy is found; the entry adds the sub-module 202, The search sub-module 201 is connected to be used to store the information of the entry to be stored when the search sub-module 201 finds a vacancy in the current target hash sub-table. Bit, and invalidate the valid position of the bitmap, store the key value of the table item to be stored in the bitmap, and when the search sub-module 201 determines that the valid bit of the bitmap is invalid, Determining whether the conflict bit of the bitmap is invalid. If yes, the entry adding submodule is used to take out the stored table entry in the hash sub-table, and extract the key value of the entry and the current table to be stored. The key value of the item is stored in the bitmap; when the search sub-module 201 determines that the conflict bit of the bitmap is valid, the entry adding sub-module 202 is configured to store the key value of the current to-be-stored entry to the bitmap. in.
本实施方式中的每张位图包含了一位沖突位和一位有效位, 多个沖突 键值存储槽位。本实施方式中的位图的有效位置为 0, 即表示有效, 置为 1 , 即表示无效; 位图的沖突位置为 0则表示无效, 置为 1则表示有效。  Each bitmap in this embodiment includes a bit conflict bit and a valid bit, and a plurality of conflict key value storage slots. In this embodiment, the effective position of the bitmap is 0, that is, it is valid, and when it is set to 1, it means invalid; if the conflict position of the bitmap is 0, it means invalid, and setting it to 1 means valid.
请参考图 1 ,本实施方式中的哈希表存储装置的数据线路包括并行计算 模块 301 , 并行查找模块 302以及比较模块 303 , 其中, 并行计算模块 301 , 用于利用每张哈希子表对应的哈希函数, 并行计算待查找表项的键值的哈 希值; 并行查找模块 302, 与并行计算模块 301相连, 用于根据计算得到的 哈希值在其各自对应的位图中并行地查找; 比较模块 303 , 用于将各个位图 的查表结果进行比较判断, 确定出匹配的表项所在的哈希子表的地址, 将 该地址存储的表项的信息取出, 并与需要查找的键值进行比较, 确定表项 是否匹配, 如匹配, 则将该表项的信息作为最终查表结果。 Referring to FIG. 1, the data line of the hash table storage device in this embodiment includes a parallel computing module 301, a parallel searching module 302, and a comparison module 303, wherein the parallel computing module 301 is configured to utilize each hash sub-table corresponding to a hash function, the hash value of the key value of the table to be searched is calculated in parallel; the parallel search module 302 is connected to the parallel computing module 301, and is configured to search for the hash values in parallel according to the calculated hash values in their respective corresponding bitmaps. Comparison module 303 for using each bitmap The result of the look-up table is compared and judged, the address of the hash sub-table in which the matching entry is located is determined, the information of the entry stored in the address is taken out, and compared with the key value to be searched to determine whether the entry matches, such as If the match is made, the information of the entry is used as the final lookup result.
本实施方式中查找表项时的哈希子表对应的位图与存储表项时, 哈希 子表对应的位图深度相同; 且哈希子表对应的哈希函数与存储表项时, 该 哈希子表对应的哈希函数相同。 本实施方式中查找表项时, 对应的位图只 包含一位的沖突位。  In the present embodiment, when the bitmap corresponding to the hash sub-table in the lookup table is stored and the table entry is stored, the bitmap depth corresponding to the hash sub-table is the same; and the hash function corresponding to the hash sub-table and the storage table entry, the hash sub- The hash function corresponding to the table is the same. In the present embodiment, when the entry is looked up, the corresponding bitmap contains only one bit of the conflict bit.
本实施方式的哈希表存储装置通过表项拆分模块将哈希表拆分为多张 哈希子表, 再由目标哈希子表确定模块从其中确定一张目标哈希子表, 并 由表项存储模块利用目标哈希子表对应的哈希函数计算待存储表项的键值 对应的哈希值, 并根据该哈希值才目标哈希子表中查找空位, 从而将待存 储表项存入该空位中, 当没有查找到空位时, 则将待存储表项的键值存储 在对应的位图中, 并更新目标哈希子表直至找到空位来存储该待存储表项, 从而以极小的更新时间代价以及较高的表空间利用率实现全部表项存储, 而无表项遗留; 另一方面本装置通过并行计算模块来并行计算待查找表项 的键值对应的哈希值, 再由并行查找模块根据该哈希值在各自对应的位图 中查找, 最后由比较模块来比较查找结果, 并匹配表项所在的哈希子表地 址中取出对应的表项, 如果该表项与待查找的表项相匹配, 则该表项即为 待查找的表项, 则将其作为最终的查找结果返回, 从而由于每张哈希子表 都是通过对哈希表进行拆分得到, 且在位图中已经确定了匹配表项的存储 地址, 从而只需访问一次哈希子表就能够准确的查找到需要的表项, 同时 也便于硬件与存储器之间接口的实现, 能够在表空间大小, 查找效率以及 硬件实现方面获得比较好的均衡。  The hash table storage device of the present embodiment splits the hash table into a plurality of hash sub-tables by using the table splitting module, and then the target hash sub-table determining module determines a target hash sub-table from which the entry is The storage module calculates a hash value corresponding to the key value of the table to be stored by using a hash function corresponding to the target hash sub-table, and searches for a space in the target hash table according to the hash value, thereby storing the to-be-stored entry into the In the vacancy, when no vacancy is found, the key value of the entry to be stored is stored in the corresponding bitmap, and the target hash sub-table is updated until a vacancy is found to store the to-be-stored entry, thereby updating with a minimum The time cost and the higher table space utilization realize that all the table entries are stored, and no table entries are left behind; on the other hand, the device uses the parallel computing module to calculate the hash value corresponding to the key value of the table to be searched in parallel, and then by parallel The search module searches for the corresponding bitmap according to the hash value, and finally compares the search result by the comparison module, and extracts the corresponding corresponding address in the hash sub-table address where the entry is located. If the entry matches the entry to be searched, the entry is the entry to be searched, and then it is returned as the final search result, so that each hash subtable passes through the hash. The table is split, and the storage address of the matching entry is determined in the bitmap, so that only one hash subtable can be accessed to accurately find the required entry, and the interface between the hardware and the memory is also facilitated. Implementation, can achieve a better balance in table space size, search efficiency and hardware implementation.
实施例一:  Embodiment 1:
请参考图 3 , 为本实施方式的哈希表存储装置的一实施例的结构示意 图。 本实施方式的哈希表存储查找系统包括主控逻辑模块 505 , 多个计算模 块 502a ~ 502η, 多个查找模块 503a ~ 503η, 表项添加模块 504, 统计模块 505 , 表项拆分模块 506, 多个 bitmap模块 507a ~ 507η, 多个表项存储模块 508a ~ 508η, 数据判决模块 509和异常处理模块 550。 本实施方式的哈希表 存储装置的内部连接分为数据线路和控制线路, 在数据线路上, 主控逻辑 模块 501耦合至多个计算模块 502a ~ 502η, 数据判决模块 509; 多个计算 模块 502a ~ 502η 分别耦合至多个查找模块 503a ~ 503η; 多个查找模块 503a - 503η分别耦合至多个 bitmap模块 507a ~ 507η, 多个 bitmap模块 507a ~ 507η耦合至多个表项存储模块 508a ~ 508η; 在控制线路上, 主控逻 辑模块 501耦合至表项添加模块 504, 统计模块 505 , 表项拆分模块 506和 异常处理模块 510,且表项添加模块 504, 统计模块 505 ,表项拆分模块 506 和异常处理模块 510均分别耦合至多个查找模块 503a~503n。 Please refer to FIG. 3 , which is a schematic structural diagram of an embodiment of a hash table storage device according to an embodiment of the present invention. Figure. The hash table storage search system of the present embodiment includes a main control logic module 505, a plurality of calculation modules 502a to 502n, a plurality of search modules 503a to 503n, an entry addition module 504, a statistics module 505, and an entry split module 506. A plurality of bitmap modules 507a to 507n, a plurality of entry storage modules 508a to 508n, a data decision module 509, and an exception processing module 550. The internal connection of the hash table storage device of this embodiment is divided into a data line and a control line. On the data line, the main control logic module 501 is coupled to the plurality of calculation modules 502a-502n, the data decision module 509; and the plurality of calculation modules 502a~ 502n are coupled to the plurality of lookup modules 503a-503n, respectively; the plurality of lookup modules 503a-503n are respectively coupled to the plurality of bitmap modules 507a-507n, and the plurality of bitmap modules 507a-507n are coupled to the plurality of entry storage modules 508a-508n; The main control logic module 501 is coupled to the entry adding module 504, the statistics module 505, the table splitting module 506, and the exception handling module 510, and the entry adding module 504, the statistics module 505, the table splitting module 506, and the exception handling. Modules 510 are each coupled to a plurality of lookup modules 503a-503n, respectively.
其中, 主控逻辑模块 501 , 是哈希表存储装置的控制部件, 主要用于控 制控制线路和数据线路上的算法启动, 终止, 任务调度以及数据路径上的 数据分发, 结果收集等操作。  The main control logic module 501 is a control component of the hash table storage device, and is mainly used for controlling algorithm startup, termination, task scheduling, data distribution on the data path, and result collection and the like on the control line and the data line.
本实施方式中的主控逻辑模块 501可以由硬件逻辑实现, 如 ASIC (专 用集成电路 )或者是 FPGA (现场可编程逻辑门阵列 )或者是其他可以实现 逻辑函数功能的芯片。 当然本实施方式中的主控逻辑模块 501 也可以通过 运行在 CPU (中央处理)上的软件来实现, 在这种实现方式下, 控制线路 上的模块, 包括表项添加模块 504, 统计模块 505 , 表项拆分模块 506和异 常处理模块 550, 且均可以通过软件来实现。  The master logic module 501 in this embodiment may be implemented by hardware logic, such as an ASIC (Application Specific Integrated Circuit) or an FPGA (Field Programmable Logic Gate Array) or other chip that can implement a logic function. Of course, the main control logic module 501 in this embodiment may also be implemented by software running on a CPU (Central Processing). In this implementation manner, the modules on the control line include an entry adding module 504, and a statistics module 505. The entry splitting module 506 and the exception handling module 550 can all be implemented by software.
多个计算模块 502a ~ 502η耦接至主控逻辑模块 501 和多个查找模块 503a ~ 503η, 在表项查找过程中, 当主控逻辑模块 501 将待查找的键值同 时发送给多个计算模块 502a ~ 502η时, 该多个计算模块 502用于对所分配 到的键值同时进行一次哈希运算, 获得与其他计算模块不同的索引。 本实施方式中的每个计算模块 502中包含一个与其他计算模块 502不 同的哈希函数, 且本实施方式中的哈希函数可以采用各种已知的方法实现, 如异或阵列或者类 CRC函数, 或者经过复杂的数学运算等等。 哈希函数的 选取准则是要尽可能的减少不同的键值经过哈希函数运算后获得的索引号 沖突。 The plurality of calculation modules 502a to 502n are coupled to the main control logic module 501 and the plurality of search modules 503a to 503n. In the table item search process, the main control logic module 501 simultaneously sends the key values to be searched to the plurality of calculation modules. 502a ~ 502η, the plurality of calculation modules 502 are configured to perform a hash operation on the assigned key values at the same time to obtain an index different from other calculation modules. Each computing module 502 in this embodiment includes a hash function different from other computing modules 502, and the hash function in this embodiment can be implemented by various known methods, such as an exclusive OR array or a CRC-like CRC. Functions, or through complex mathematical operations, and so on. The selection criterion of the hash function is to reduce the index number conflicts obtained by hash function operations of different key values as much as possible.
多个查找模块 503a ~ 503η分别耦合至多个计算模块 502a ~ 502η和多个 bitmap模块 507a ~ 507η, 以及统计模块 505 , 表项拆分模块 506和异常处 理模块 510。 本实施方式中的每个查找模块 503独立的耦合于一个 bitmap 模块 507, 通过 bitmap模块 507的地址总线和数据总线对 bitmap模块 507 以及该 bitmap所对应的存储模块 508中的数据进行访问和修改。 在数据线 路上, 每个查找模块 503接收计算模块 502生成的不同的索引, 并将其转 换成 bitmap模块 507的地址, 从而读取该地址对应于存储模块 508中的数 据。 在获取到对应于该地址的数据后, 查找模块 503将接收的多个计算模 块 502a ~ 502η计算得到的索引值和多个 bitmap模块 507a ~ 507η获取的数 据值, 一起传送给数据判决模块 509与查找键值比较, 确定是否匹配; 在 控制线路上, 多个查找模块 503a ~ 503η接收统计模块 505 , 表项拆分模块 506和异常处理模块 509发出的读写指令, 转换成多个 bitmap模块 507a ~ 507η的地址, 对多个 bitmap模块 507a ~ 507η中的存储数据进行操作, 进 而对多个存储模块 508a ~ 508η中存储的数据进行操作。  A plurality of lookup modules 503a through 503n are coupled to the plurality of compute modules 502a through 502n and the plurality of bitmap modules 507a through 507n, respectively, and a statistics module 505, an entry split module 506, and an exception handling module 510. Each of the search modules 503 in the present embodiment is independently coupled to a bitmap module 507, and accesses and modifies the data in the bitmap module 507 and the storage module 508 corresponding to the bitmap through the address bus and data bus of the bitmap module 507. On the data line, each lookup module 503 receives the different index generated by the compute module 502 and converts it to the address of the bitmap module 507, thereby reading the address corresponding to the data in the memory module 508. After obtaining the data corresponding to the address, the searching module 503 transmits the received index value calculated by the plurality of calculating modules 502a to 502n and the data values obtained by the plurality of bitmap modules 507a to 507n to the data decision module 509 and Finding a key value comparison to determine whether a match is made; on the control line, the plurality of search modules 503a to 503n receive the read/write instructions issued by the statistics module 505, the table item splitting module 506, and the exception handling module 509, and convert the plurality of bitmap modules 507a into The address of ~507n operates on the stored data in the plurality of bitmap modules 507a to 507n, and further operates the data stored in the plurality of storage modules 508a to 508n.
本实施方式中的查找模块 503 同时实现控制线路和数据线路的功能, 当然也可以分别针对控制线路和数据线路设置相应的查找模块。 本实施方 式中可以存在索引值的扩充, 加减偏移量或者截取等运算。  The search module 503 in this embodiment simultaneously implements the functions of the control line and the data line. Of course, the corresponding search module can also be set for the control line and the data line respectively. In this embodiment, there may be an expansion of the index value, an addition or subtraction of an offset or an interception operation.
多个 bitmap模块 507a ~ 507η分别耦合于多个查找模块 503a ~ 503η, 且每个 bitmap模块 507具有独立的地址访问总线和独立的数据总线, 对每 一个模块而言, 地址总线和数据总线可以复用, 但是多个存储模块 508之 间不复用,多个 bitmap模块 507a ~ 507η通过上述的独立的地址访问总线和 独立的数据总线分别耦合于多个查找模块 503a ~ 503η , 多个查找模块 503a ~ 503η通过发送地址来访问多个 bitmap模块 507a ~ 507η中对应于所 发送地址处存储的数据(沖突位, 有效位和键值), 且该多个 bitmap模块 507a ~ 507η还分别对应一个存储模块 508a ~ 508η, 每个存储模块 508存储 一张哈希子表, 每张子表都是通过表项拆分模块 506对哈希表进行拆分得 到, 且在 bitmap模块 507中已经确定了匹配表项的存储地址, 只需访问一 次存储模块 508a ~ 508η,所以存储模块 508a ~ 508η共享一组地址访问总线 和数据总线。 The plurality of bitmap modules 507a to 507n are respectively coupled to the plurality of search modules 503a to 503n, and each of the bitmap modules 507 has an independent address access bus and an independent data bus. For each module, the address bus and the data bus can be complexed. Use, but multiple storage modules 508 Without multiplexing, the plurality of bitmap modules 507a to 507n are respectively coupled to the plurality of search modules 503a to 503n through the independent address access bus and the independent data bus, and the plurality of search modules 503a to 503n access the plurality of addresses by transmitting addresses. The bitmap modules 507a to 507n correspond to data (conflict bits, valid bits and key values) stored at the transmitted address, and the plurality of bitmap modules 507a to 507n further correspond to one of the storage modules 508a to 508n, and each of the storage modules 508 A hash sub-table is stored, and each sub-table is obtained by splitting the hash table by the table item splitting module 506, and the storage address of the matching entry is determined in the bitmap module 507, and only the storage module 508a is accessed once. ~ 508n, so the memory modules 508a ~ 508n share a set of address access bus and data bus.
多个 bitmap模块 507a ~ 507η 分别耦合于所述多个查找模块 503a ~ 503n。 其中每个 bitmap模块具有独立的地址访问总线和独立的数据总线, 其中对每一个模块而言, 地址总线和数据总线可以复用, 但是多个表项存 储模块之间不复用。多个 bitmap模块 507a ~ 507η通过上述的独立的地址访 问总线和独立的数据总线分别耦合于多个查找模块 503a ~ 503η, 多个查找 模块 503a ~ 503η可以通过发送地址来访问多个 bitmap模块 507a ~ 507η中 对应于所发送地址处存储的数据 (沖突位, 有效位和键值)。 多个 bitmap 模块 507a ~ 507η分别对应一个表项存储模块 508a ~ 508η,每个表项存储模 块存储一张哈希子表, 其中每张子表都是通过对所述哈希表进行拆分得到 , 因为在 bitmap中已经确定了匹配表项的存储地址, 只需访问一次表项存储 模块 508a ~ 508η,所以表项存储模块 508a ~ 508η共享一组地址访问总线和 数据总线。  A plurality of bitmap modules 507a through 507n are coupled to the plurality of lookup modules 503a through 503n, respectively. Each of the bitmap modules has a separate address access bus and a separate data bus. For each module, the address bus and the data bus can be multiplexed, but multiple entries are not multiplexed between the storage modules. The plurality of bitmap modules 507a to 507n are respectively coupled to the plurality of search modules 503a to 503n through the independent address access bus and the independent data bus, and the plurality of search modules 503a to 503n can access the plurality of bitmap modules 507a by sending addresses. 507η corresponds to the data (conflict bit, valid bit and key value) stored at the transmitted address. The plurality of bitmap modules 507a to 507n respectively correspond to one entry storage module 508a to 508n, and each entry storage module stores a hash sub-table, wherein each sub-table is obtained by splitting the hash table, because The storage address of the matching entry has been determined in the bitmap, and only the entry storage modules 508a-508n are accessed once, so the entry storage modules 508a-508n share a set of address access bus and data bus.
本实施方式中的多个 bitmap模块 507和存储模块 508可以通过当前存 在的各种数据存储技术来实现。 由于 bitmap模块 507需要并行访问且占用 的存储空间比较小, 可以用片内 SRAM实现。 而对于存储模块 508, 如在 需要少延时的应用场景下, 可以用 n个独立的高速 SRAM芯片来作为存储 模块 508a ~ 508n,所述的高速 SRAM芯片可以是 ZBT SRAM, QDR SRAM, QDRII SRAM, QDRII+ SRAM等各种常用的 SRAM芯片;在需要大容量表 项空间的情况下, 可以用 n 个独立的高速 DRAM 芯片来作为存储模块 508a ~ 508η,所述的高速 DRAM芯片可以是 SDRAM, DDR SDRAM, DDRII SDRAM, DDRIII SDRAM等各种常用的 SDRAM芯片; 在需要掉电保存数 据的情况下, 可以用 n个独立的 FLASH芯片来作为存储模块 508a ~ 508η, 所述的 FLASH芯片可以是 NAND FLASH, NOR FLASH, NV RAM或者 其他各种常用的存储芯片; 在海量数据的情况下, 存储模块 508a ~ 508η还 可以用多个独立的硬盘, 多个独立的磁盘存储阵列, 或者是光盘驱动器等 海量数据存储技术来实现, 也可在不脱离本实施方式的范围下任意选取多 个 bitmap模块 507a ~ 507η和存储模块 508a ~ 508η的实现介质。 The plurality of bitmap modules 507 and storage modules 508 in this embodiment may be implemented by various data storage technologies currently in existence. Since the bitmap module 507 requires parallel access and takes up less storage space, it can be implemented with on-chip SRAM. For the storage module 508, for example, in an application scenario requiring less delay, n independent high-speed SRAM chips can be used as the storage. Modules 508a to 508n, the high-speed SRAM chip may be various commonly used SRAM chips such as ZBT SRAM, QDR SRAM, QDRII SRAM, QDRII+ SRAM; in the case where a large-capacity entry space is required, n independent high-speed lines may be used. The DRAM chip is used as the storage modules 508a-508n. The high-speed DRAM chip may be various commonly used SDRAM chips such as SDRAM, DDR SDRAM, DDRII SDRAM, DDRIII SDRAM, etc. In the case where data needs to be saved by power-down, n can be used. The independent FLASH chip is used as the storage modules 508a to 508n, and the FLASH chip may be NAND FLASH, NOR FLASH, NV RAM or other commonly used memory chips; in the case of massive data, the storage modules 508a to 508n may also be It can be realized by a plurality of independent hard disks, a plurality of independent disk storage arrays, or a mass data storage technology such as an optical disk drive, and a plurality of bitmap modules 507a to 507n and a storage module can be arbitrarily selected without departing from the scope of the present embodiment. Implementation medium of 508a ~ 508η.
数据判决模块 509, 耦合至多个查找模块 503a ~ 503η和多个存储模块 508a ~ 508η, 完成查找结果的判决操作。 多个查找 503a ~ 503η, 在获取了 多个 bitmap模块 507a ~ 507η查找结果后,将结果传送至数据判决模块 509, 数据判决模块按 a~n顺序比较 bitmap模块 507a ~ 507η的查找结果,找出最 先沖突位为 0的 bitmap模块 507, 将找到的 bitmap地址传送给多个存储模 块 508a ~ 508n, 从存储模块 508 中获取到的数据再传送给数据判决模块 509, 根据主控逻辑模块 501传送过来的原始键值, 比较该数据是否是匹配 的表项, 由于多个查找模块 503a ~ 503n 获取的多个查找结果来自于多个 bitmap模块 507a ~ 507η中存储的沖突位, 而沖突位只有当其不与其他表项 沖突时才会置 0, 若有一次沖突就将其置 1 , 所以最先出现的沖突位为 0的 地址对应的表项存储模块中存储的数据是唯一的, 因此, 这当中不存在重 复的表项, 只有一个查找存储模块 508 的结果是可能的正确结果, 或者返 回的结果均与键值不符, 本次哈希查找失败。 在查找正确的情况下, 数据 判决模块 509将正确的一组数据中的索引值返回给主控逻辑模块 501 ,代表 本次哈希查找的结果; 在查找失败的情况下, 数据判决模块 509将返回给 主控逻辑模块 501 —个无效索引值或者一个中断信号, 通知主控逻辑模块 501本次查找失败。 The data decision module 509 is coupled to the plurality of search modules 503a-503n and the plurality of storage modules 508a-508n to complete the decision operation of the search result. The plurality of lookups 503a to 503n, after obtaining the search results of the plurality of bitmap modules 507a to 507n, transfer the result to the data decision module 509, and the data decision module compares the search results of the bitmap modules 507a to 507n in the order of a~n to find out The bitmap module 507 with the first conflict bit is 0, and the found bitmap address is transmitted to the plurality of storage modules 508a to 508n, and the data acquired from the storage module 508 is transmitted to the data decision module 509, and transmitted according to the main control logic module 501. The original key value from the comparison, whether the data is a matching entry, because the plurality of search results obtained by the plurality of search modules 503a to 503n are from conflict bits stored in the plurality of bitmap modules 507a to 507n, and the conflict bits are only It will be set to 0 when it does not conflict with other entries. If there is a conflict, it will be set to 1. Therefore, the data stored in the storage module corresponding to the address with the first occurrence of the conflicting bit is 0. Therefore, There is no duplicate entry in this, only one result of finding the storage module 508 is a possible correct result, or the returned result is inconsistent with the key value, and the hash search is lost. defeat. When the lookup is correct, the data decision module 509 returns the index value in the correct set of data to the master logic module 501, representing The result of this hash search; in the case of a search failure, the data decision module 509 will return to the master logic module 501 an invalid index value or an interrupt signal, informing the master logic module 501 that the current search failed.
表项拆分模块 506和表项添加模块 504协同工作, 用于将哈希表拆分 为 N ( N〉=l ) 张哈希子表并存入到多个存储模块 508中。 每张哈希子表对 应一张 bitmap和一个哈希函数, 其中 N张哈希子表和 N张 bitmap的存储 空间大小可以根据需要进行选择。 如 2的 32次方), 哈希子表生成过程中, 表项拆分模块 506依次选取 M个 条目中的一个, 将其目标哈希子表和 bitmap 设定为第一张哈希子表和 bitmap, 并将该条目传送给表项添加模块 504。 表项添加模块 104根据第一 张哈希子表对应的哈希函数, 计算得出该条目的索引值 K, 并尝试将该条 目存入所取的哈希函数对应的哈希子表中的对应于索引值 K的位置, 同时 将与该哈希子表对应的 bitmap中对应的索引值 K位置中的沖突位置 0, 有 效位置 1, 将原始 4¾值存入该位置中。  The table item splitting module 506 and the table item adding module 504 work together to split the hash table into N (N>=l) hash subtables and store them in a plurality of storage modules 508. Each hash subtable corresponds to a bitmap and a hash function, and the storage size of N hash subtables and N bitmaps can be selected as needed. For example, the 32-th power of 2, in the hash sub-table generation process, the table item splitting module 506 sequentially selects one of the M items, and sets the target hash sub-table and the bitmap as the first hash sub-table and the bitmap. The entry is passed to the entry addition module 504. The entry adding module 104 calculates the index value K of the entry according to the hash function corresponding to the first hash sub-table, and attempts to store the entry in the hash sub-table corresponding to the hash function. The position of the index value K, at the same time, the conflicting position 0 in the corresponding index value K position in the bitmap corresponding to the hash sub-table, the valid position 1, and the original 43⁄4 value is stored in the position.
本实施方式中, 在表项拆分模块 506对多个哈希子表进行拆分的时候, 有可能遇到哈希沖突的情况, 即两个不同的键值经过计算得到同一张哈希 子表的同一个索引值。 在这种情况下, 如果该位置的 bitmap沖突位为 0, 有效位为 1 ,说明该位置已放入一条表项, 需要将已存入该索引值对应的表 项存储模块的数据取出, 并将该索引值对应的 bitmap中的沖突位值 1 , 当 前键值与取出表项对应的键值都放在 bitma 中; 如果该位置的 bitmap沖突 位为 1 , 说明该位置已经沖突超过一次, 将当前键值放入 bitmap中。 当出 现上述两种沖突情况时,返回失败消息给表项拆分模块 106,表项拆分模块 506再判断当前的目标哈希子表是否为最后一张哈希子表,若不是则将该条 目的目标子表设置为下一张子表,传递给表项添加模块 504,重复上述过程; 若已经是最后一张哈希子表, 则返回失败消息给主控逻辑模块 501 , 通过主 控逻辑模块 501调用异常处理模块 509来完成哈希表的更新。 In this embodiment, when the table splitting module 506 splits multiple hash sub-tables, it is possible to encounter a hash conflict, that is, two different key values are calculated to obtain the same hash sub-table. The same index value. In this case, if the bitmap conflict bit of the location is 0, the valid bit is 1, indicating that the location has been placed in an entry, and the data of the entry storage module corresponding to the index value needs to be taken out, and The conflicting bit value 1 in the bitmap corresponding to the index value, the current key value and the key value corresponding to the fetched entry are placed in the bitma; if the bitmap conflict bit of the location is 1, indicating that the location has collided more than once, The current key value is placed in the bitmap. When the above two conflict situations occur, the failure message is returned to the table item splitting module 106, and the table item splitting module 506 determines whether the current target hash sub-table is the last hash sub-table, and if not, the item is The target sub-table is set to the next sub-table, and is passed to the entry adding module 504 to repeat the above process; If it is already the last hash sub-table, a failure message is returned to the main control logic module 501, and the exception processing module 509 is called by the main control logic module 501 to complete the update of the hash table.
虽然本实施方式中的表项添加模块 504处于控制线路上, 但是可以通 过多个查找模块 503a ~ 503η读取或修改 bitmap模块 507和存储模块 508中 的内容。  Although the entry adding module 504 in this embodiment is on the control line, the contents of the bitmap module 507 and the storage module 508 can be read or modified by the plurality of lookup modules 503a to 503n.
异常处理模块 510和统计模块 505分别耦合至多个查找模块 503和主 控逻辑模块 501 , 完成系统监控和错误恢复等任务。 如每次查询失败, 统计 模块 505均会将其计入到查找失败记录。 异常处理模块 510则用于响应主 控逻辑模块 501发出的哈希表刷新请求, 并通过多个查找模块 503a ~ 503η 对多个 Bitmap模块 507a ~ 507η和多个存储模块 508a ~ 508η进行清零和重 新赋值操作。  The exception handling module 510 and the statistics module 505 are coupled to the plurality of lookup modules 503 and the master control logic module 501, respectively, to perform tasks such as system monitoring and error recovery. If each query fails, the statistics module 505 will count it into the lookup failure record. The exception processing module 510 is configured to respond to the hash table refresh request sent by the master logic module 501, and clear the plurality of Bitmap modules 507a to 507n and the plurality of storage modules 508a to 508n through the plurality of search modules 503a to 503n. Reassign operation.
下面将本实施例的哈希表存储装置拆分成数据线路和控制线路两个部 分来进行详细的说明。  The hash table storage device of this embodiment will be divided into two parts, a data line and a control line, for detailed description.
其中, 数据线路由主控逻辑模块 501 , 多个计算模块 502a ~ 502η, 多 个查找模块 503a ~ 503η, 多个 Bitmap模块 507a ~ 507η, 多个存储模块 508a ~ 508η以及数据判决模块 509构成, 该数据线路用来完成查找操作, 控制线路由主控逻辑模块 501 , 表项添加模块 504, 统计模块 505 , 表 项拆分模块 506和异常处理模块 510构成。 表项添加模块 504耦合至多个 查找模块 503 , 用于将沖突状态信息和表项数据添加进多个 bitmap模块 507a ~ 507η和多个存储模块 508a ~ 508η, 该控制线路用来完成表项添加和 删除操作。  The data line is composed of a main control logic module 501, a plurality of calculation modules 502a to 502n, a plurality of search modules 503a to 503n, a plurality of Bitmap modules 507a to 507n, a plurality of storage modules 508a to 508n, and a data decision module 509. The data line is used to complete the search operation, and the control line is composed of the main control logic module 501, the item addition module 504, the statistics module 505, the table item splitting module 506, and the exception handling module 510. The entry adding module 504 is coupled to the plurality of searching modules 503 for adding the conflicting state information and the entry data to the plurality of bitmap modules 507a to 507n and the plurality of storage modules 508a to 508n, wherein the control line is used to complete the entry addition and Delete operation.
本实施例的哈希表存储装置中, 拆分后得到的哈希子表对应的 Ν个哈 希函数可以是 CRC函数也可以是其他函数, 当采用 CRC函数做为本实施 例中哈希子表对应的哈希函数时, 若干张哈希子表对应的哈希函数之间可 以采用不同的 CRC多项式。 基于上述的哈希表存储装置, 本实施方式还提供一种哈希表的表项添 力口方法。 In the hash table storage device of this embodiment, the hash function corresponding to the hash sub-table obtained after the splitting may be a CRC function or other functions, and the CRC function is used as the hash sub-table corresponding to the embodiment. When the hash function is used, different CRC polynomials can be used between the hash functions corresponding to several hash subtables. Based on the hash table storage device described above, the embodiment further provides a method for adding a strong entry of a hash table.
请参考图 4,为本实施方式的哈希表的表项添加方法的一实施例的流程 示意图。 本实施方式哈希表的表项添加方法包括:  Referring to FIG. 4, it is a schematic flowchart of an embodiment of a method for adding an entry of a hash table according to the embodiment. The method for adding an entry of the hash table in this embodiment includes:
S401 , 哈希表拆分为多张哈希子表, 每一张哈希子表对应一张位图, 每一张位图对应一个哈希函数。  S401, the hash table is split into multiple hash sub-tables, and each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function.
本实施方式中拆分的关键影响因素是每张子表的存储空间大小选择。 本实施方式中的多张哈希子表的存储空间可以根据需要搭配选择, 比如可 以设置每张小表空间大小一致, 也可以采用存储空间大小递减的方式, 但 是, 拆分方式不局限于上述两种方式。  The key influencing factor of the split in this embodiment is the size of the storage space of each sub-table. The storage space of the multiple hash sub-tables in this embodiment may be selected according to requirements. For example, the size of each small table space may be set to be the same, or the size of the storage space may be decreased. However, the split mode is not limited to the above two modes. .
S403 , 将第一张哈希子表作为当前的目标哈希子表。  S403: The first hash sub-table is used as the current target hash sub-table.
S405 , 取待存储表项的键值, 利用当前目标哈希子表对应的哈希函数 计算其哈希值。  S405: The key value of the storage entry is taken, and the hash value corresponding to the current target hash sub-table is used to calculate the hash value.
S407 , 根据计算得到的哈希值, 确定当前目标哈希子表所对应的存储 位置是否为空位, 如是, 则执行步驟 S409a, 否则, 执行步驟 S409b。  S407. Determine, according to the calculated hash value, whether the storage location corresponding to the current target hash sub-table is a vacancy. If yes, go to step S409a. Otherwise, go to step S409b.
S409a, 将待存储表项的信息进存入该空位中, 并执行步驟 S4011。 本实施方式中的表项的信息包括查表键值、 查表结果等信息。  S409a: The information of the entry to be stored is stored in the slot, and step S4011 is performed. The information of the entry in this embodiment includes information such as a table key value and a table lookup result.
S409b , 更新当前目标哈希子表并执行步驟 S405。  S409b, updating the current target hash sub-table and performing step S405.
S4011 , 将该位图中的有效位置为无效, 并将待存储表项的键值存储到 该位图中。  S4011, invalidating the valid position in the bitmap, and storing the key value of the item to be stored into the bitmap.
S4013 , 待存储表项存储完成后, 同步更新位图的沖突位信息和哈希子 表的信息。  S4013: After the storage of the to-be-stored entry is completed, the conflict bit information of the bitmap and the information of the hash sub-table are synchronously updated.
请参考图 5 , 为本实施方式的步驟 S407的一实施例的流程图。 本实施 方式中的步驟 S407包括:  Please refer to FIG. 5, which is a flowchart of an embodiment of step S407 of the present embodiment. Step S407 in this embodiment includes:
S501 , 判断当前目标哈希子表的容量是否小于计算的哈希值, 如是, 则执行步驟 S503a, 否则执行步驟 S503b。 S501, determining whether the capacity of the current target hash sub-table is less than the calculated hash value, and if so, Then, step S503a is performed, otherwise step S503b is performed.
S503a, 根据哈希子表的容量对应的比特位数, 从高比特位开始截取计 算得到的哈希值的相同比特位数, 得到截取后的哈希值, 并将该截取后的 哈希值作为索引, 执行步驟 S505。  S503a, according to the bit number corresponding to the capacity of the hash sub-table, intercepting the same bit number of the calculated hash value from the high bit, obtaining the intercepted hash value, and using the intercepted hash value as The index is executed in step S505.
S503b, 直接以计算得到的哈希值作为索引, 执行步驟 S505。  S503b, directly using the calculated hash value as an index, and executing step S505.
S505 , 根据索引在目标哈希子表中查找空位, 即判断该位图的有效位 是否为 0, 且该位图的沖突位为 0, 如是, 即该目标哈希子表对应的存储位 置为空位, 则执行步驟 S409a; 否则执行步驟 S409b。  S505. Find a null bit in the target hash sub-table according to the index, that is, determine whether the valid bit of the bitmap is 0, and the conflict bit of the bitmap is 0. If yes, the storage location corresponding to the target hash sub-table is a vacancy. Then, step S409a is performed; otherwise, step S409b is performed.
请参考图 6, 本实施方式中的步驟 S409b包括:  Referring to FIG. 6, step S409b in this embodiment includes:
S601 , 判断该位图的沖突位是否为 0, 有效位是否为 1 , 如是, 则执行 步驟 S603a, 如果该位图的沖突位为 1 , 则执行步驟 S603b。  S601. Determine whether the conflict bit of the bitmap is 0, and whether the valid bit is 1. If yes, step S603a is performed. If the conflict bit of the bitmap is 1, step S603b is performed.
S603a, 将该位图对应哈希子表中已存储的表项取出, 并将该位图的沖 突位置为 1 , 并执行步驟 S605。  S603a, the bitmap corresponding to the stored table in the hash sub-table is taken out, and the conflict position of the bitmap is set to 1, and step S605 is performed.
S603b, 将当前的待存储表项的键值存储到该位图中, 执行步驟 S607。 S605 , 将取出表项的键值与当前待存储表项的键值存入到该位图中。 S607 , 判断当前目标哈希子表是否为最后一张哈希子表, 如是, 执行 步驟 S609a, 否则执行步驟 S609b。  S603b: The key value of the current to-be-stored entry is stored in the bitmap, and step S607 is performed. S605: The key value of the fetched entry and the key value of the current to-be-stored entry are stored in the bitmap. S607. Determine whether the current target hash sub-table is the last hash sub-table. If yes, go to step S609a, otherwise go to step S609b.
S609a, 返回存储失败消息, 结束操作。  S609a, returns a storage failure message, and ends the operation.
S609b, 将目标哈希子表更新为下一张哈希子表, 并执行步驟 S405。 本实施方式的哈希表的表项添加方法中, 哈希子表对应的哈希函数为 循环冗余码校验函数, 且多张哈希子表对应的哈希函数之间采用不同的循 环冗余码校验多项式。  S609b, updating the target hash sub-table to the next hash sub-table, and executing step S405. In the method for adding a hash table of the present embodiment, the hash function corresponding to the hash sub-table is a cyclic redundancy code check function, and the hash functions corresponding to the multiple hash sub-tables adopt different cyclic redundancy. Code check polynomial.
本实施方式的哈希表的表项添加方法, 通过将哈希表拆分为多张哈希 子表, 且每一张哈希子表对应一张位图和一个哈希函数, 再利用该哈希函 数计算待存储表项的键值的哈希值, 由该哈希值来确定存储待存储表项的 空位。 由于每张哈希子表都是通过对哈希表进行拆分得到, 且在位图中已 经确定了匹配表项的存储地址, 从而以极小的更新时间代价以及较高的表 空间利用率实现全部表项存储, 而无表项遗留。 The method for adding an entry of the hash table in this embodiment, by splitting the hash table into multiple hash sub-tables, and each hash sub-table corresponds to a bitmap and a hash function, and then using the hash The function calculates a hash value of the key value of the table to be stored, and the hash value determines the storage of the entry to be stored. Vacancies. Since each hash sub-table is obtained by splitting the hash table, and the storage address of the matching entry is determined in the bitmap, the implementation is achieved with a small update time cost and a high table space utilization rate. All entries are stored, and no entries are left behind.
本实施方式还提供一种哈希表的表项删除方法。 本实施方式中的哈希 表包括多张哈希子表, 每一张哈希子表对应一张位图, 每一张位图对应一 个哈希函数, 且每张所述位图包括多个条目。 请参考图 7, 本实施方式的哈 希表存储装置的表项删除方法, 包括:  The embodiment further provides a method for deleting an entry of a hash table. The hash table in this embodiment includes a plurality of hash sub-tables, each of which corresponds to a bitmap, each bitmap corresponding to a hash function, and each of the bitmaps includes a plurality of entries. Referring to FIG. 7, the entry deletion method of the hash table storage device in this embodiment includes:
S701 ,每张位图所对应的哈希函数并行计算需要删除的条目的哈希值。 S703 , 根据计算得到的哈希值, 在其各自对应的位图中并行查找。 S705 , 将每一张位图的查找结果顺序进行比较, 当第一次出现沖突位 为无效时, 将该位图的地址对应的哈希子表中的表项取出。  S701. The hash function corresponding to each bitmap calculates the hash value of the item to be deleted in parallel. S703. Search according to the calculated hash values in parallel in their respective bitmaps. S705: sequentially compare the search results of each bitmap, and when the first occurrence of the conflict bit is invalid, extract the entry in the hash sub-table corresponding to the address of the bitmap.
S707 , 将取出的表项的键值与需要查找的键值进行比较, 如果相同, 则执行步驟 S709。  S707. Compare the key value of the extracted item with the key value to be searched. If they are the same, perform step S709.
S709, 将该表项从哈希子表中删除。  S709, the entry is deleted from the hash subtable.
S7011 , 将对应的位图的沖突位置为 0, 有效位置为 0。  S7011, the conflict position of the corresponding bitmap is 0, and the valid position is 0.
S7013 , 将删除的表项所在的位图之前的所有位图中的所存储的所有键 值进行比较, 如果某个位图中所存储的键值大于两个, 则执行步驟 S7015a, 如果某个位图中所存储的键值等于两个, 则执行步驟 S7015b。  S7013: Compare all the stored key values in all the bitmaps before the bitmap in which the deleted entry is located. If the key value stored in a bitmap is greater than two, step S7015a is performed, if some If the key value stored in the bitmap is equal to two, step S7015b is performed.
S7015a, 直接将需要删除的键值删掉, 结束。  S7015a, directly delete the key value to be deleted, and end.
S7015b, 将需要删除的键值删掉, 并查找到另一个键值所存储的位置。 S7017 , 将另一个键值对应的表项取出, 存入该位图所对应的哈希子表 中。  S7015b, deletes the key value that needs to be deleted, and finds the location where another key value is stored. S7017: The entry corresponding to another key value is taken out and stored in the hash sub-table corresponding to the bitmap.
本实施方式还提供一种哈希表查找方法, 本方法中查找的哈希表由若 干张哈希子表组成, 若干张哈希子表的存储空间大小可以根据需要搭配选 择。 每张 bitmap具有独立的地址控制线, 可以同时被访问, 所有的哈希子 表共享一组地址控制线, 每一条表项查找只访问一次哈希子表。 每张哈希 子表对应一个哈希函数, 每张哈希子表对应的哈希函数与存储表项时该哈 希子表对应的哈希函数相同。 The embodiment further provides a hash table search method. The hash table searched in the method is composed of a plurality of hash sub-tables, and the storage space size of the plurality of hash sub-tables can be selected according to requirements. Each bitmap has a separate address control line that can be accessed at the same time, all the hashes The table shares a set of address control lines, and each table entry looks up only once for the hash subtable. Each hash subtable corresponds to a hash function, and the hash function corresponding to each hash subtable is the same as the hash function corresponding to the hash subtable when the table entry is stored.
请参阅图 8 , 该图为本实施方式的哈希表查找方法的实现原理流程图。 本实施方式的哈希表查找方法主要包括以下步驟:  Please refer to FIG. 8 , which is a flowchart of an implementation principle of the hash table searching method according to the embodiment. The hash table search method in this embodiment mainly includes the following steps:
S801 , 利用多个哈希子表对应的多个哈希函数并行计算待查找表项的 键值对应的哈希值。  S801. The hash values corresponding to the key values of the table to be searched are calculated in parallel by using multiple hash functions corresponding to the plurality of hash sub-tables.
S803 , 根据计算得到的哈希值在对应的位图中并行查找。  S803, searching according to the calculated hash value in parallel in the corresponding bitmap.
S805 , 将每一张位图的查找结果顺序进行比较, 当第一次出现沖突位 为 0时, 取出该沖突位所对应位图的地址对应的哈希子表中的表项。  S805, comparing the search results of each bitmap, and when the conflict bit is 0 for the first time, extracting the entry in the hash sub-table corresponding to the address of the bitmap corresponding to the conflict bit.
S807 , 将取出的表项的键值与待查找表项的键值进行比较, 如果取出 的表项的键值与所述待查找表项的键值相匹配, 则执行步驟 S809a, 否则, 执行步驟 S809b。  S807, the key value of the extracted entry is compared with the key value of the entry to be searched. If the key value of the retrieved entry matches the key of the to-be-find entry, step S809a is performed, otherwise, execution is performed. Step S809b.
S809a, 将该表项的信息作为最终查表结果。  S809a, the information of the entry is used as the final lookup result.
S809b , 返回查找失败的消息。  S809b, returns a message that failed to find.
本实施方式中步驟 S805包括: 根据计算得到的哈希值对应的哈希子表 的容量, 对该哈希值进行截取; 将截取后的哈希值作为索引, 在其对应的 位图以及哈希子表中并行查找。  Step S805 in this embodiment includes: intercepting the hash value according to the calculated hash sub-table corresponding to the hash value; using the intercepted hash value as an index, in the corresponding bitmap and the hash sub- Look in parallel in the table.
本实施方式的哈希表查找方法, 通过并行计算待查找表项键值的哈希 值, 并根据该哈希值到对应位图中进行查找, 并将查找的结果进行对比, 当第一次出现沖突位为无效时, 取出该位图的地址对应的哈希子表中的表 项; 将其与带查找表项进行对比, 如果相匹配, 则该表项即为待查找的表 项, 由于每张哈希子表都是通过对哈希表进行拆分得到, 且在位图中已经 确定了匹配表项的存储地址, 从而只需访问一次哈希子表就能够准确的查 找到需要的表项, 同时也便于硬件与存储器之间接口的实现, 能够在表空 间大小, 查找效率以及硬件实现方面获得比较好的均衡。 The hash table searching method in this embodiment, by performing a hash value of the key value of the table to be searched in parallel, and searching according to the hash value to the corresponding bitmap, and comparing the search results, when the first time When the conflicting bit is invalid, the entry in the hash sub-table corresponding to the address of the bitmap is taken out; compared with the lookup table entry, if the match is matched, the entry is the entry to be searched, because Each hash subtable is obtained by splitting the hash table, and the storage address of the matching entry is determined in the bitmap, so that only one hash subtable can be accessed to accurately find the required entry. , also facilitates the implementation of the interface between the hardware and the memory, can be in the table space A good balance between size, search efficiency, and hardware implementation.
实施例二:  Embodiment 2:
请参阅图 9, 该图为本实施方式的哈希表的一实施例的逻辑结构图,每 个哈希子表对应于一张 bitmap和一个哈希函数, 其中输入键值通过输入接 口输入到本实施方式的哈希子表中, 通过哈希表存储装置计算输入键值的 哈希值, 以该哈希值作为索引在 bitmap和哈希子表中查找空位并填入; 其 中 bitmap0~9是 10个大小相同的, 存储深度为 m的状态表, 哈希子表 0~9 是 10个大小相同的, 存储深度为 m的存储器。  Referring to FIG. 9, which is a logical structure diagram of an embodiment of a hash table according to an embodiment, each hash sub-table corresponds to a bitmap and a hash function, wherein input key values are input to the local through the input interface. In the hash sub-table of the embodiment, the hash value of the input key value is calculated by the hash table storage device, and the hash value is used as an index to search for a space in the bitmap and the hash sub-table, and is filled in; wherein bitmap0~9 is 10 For the same size, the state table with the depth of m is stored. The hash sub-tables 0~9 are 10 memories of the same size and storing the depth m.
本实施例中的哈希表存储装置用于根据用户请求完成对输入键值的全 部操作, 包括添加、 查找、 监控、 异常处理等。 请参考图 3 , 当哈希键值输 入主控逻辑模块 501 , 由主控逻辑模块 501选择哈希函数, 并利用该哈希函 数通过哈希计算逻辑计算得到对应的哈希值, 添加表项逻辑模块 504完成 添加表项的工作, 查找逻辑模块 503 完成对指定哈希键值的查找工作。 本 实施例的哈希表存储装置还包括删除表项逻辑模块, 和监控逻辑模块, 均 未在附图中画出。 其中删除表项逻辑模块完成删除表项的工作; 监控逻辑 模块监控在添加和删除表项的过程中哈希子表中的空间占用情况, 并将此 信息反馈给主控逻辑模块 501。  The hash table storage device in this embodiment is used to complete all operations on input key values according to user requests, including addition, lookup, monitoring, exception handling, and the like. Referring to FIG. 3, when the hash key is input to the main control logic module 501, the main control logic module 501 selects a hash function, and uses the hash function to calculate a corresponding hash value through the hash calculation logic, and adds an entry. The logic module 504 completes the work of adding an entry, and the lookup logic module 503 completes the lookup of the specified hash key. The hash table storage device of this embodiment further includes a delete entry logic module, and a monitor logic module, which are not shown in the drawings. The delete entry logic module completes the work of deleting the entry; the monitoring logic module monitors the space occupation in the hash sub-table during the process of adding and deleting the entry, and feeds this information back to the main control logic module 501.
本实施例中, 如果遍历了所有哈希子表都无法将某一表项添加进哈希 表的异常处理情况时, 需要异常处理逻辑 510来进行处理, 以最大程度实 现所有表项的添加入哈希表中。  In this embodiment, if all the hash subtables cannot be added to the exception processing of the hash table, the exception processing logic 510 is required to perform processing to maximize the addition of all the entries. In the table.
请参阅图 10, 该图为本实施方式的一种哈希表的表项添加方法的一具 体实施例的流程图, 包括以下步驟:  Referring to FIG. 10, which is a flowchart of a specific embodiment of a method for adding an entry of a hash table according to the embodiment, the method includes the following steps:
S1001 , 利用第 i张哈希子表对应的哈希函数, 即 CRC16函数, 计算待 存储表项的键值的 16 bit哈希值。  S1001: Calculate a 16-bit hash value of a key value of the to-be-stored entry by using a hash function corresponding to the i-th hash sub-table, that is, a CRC16 function.
本实施例中 i的初始值是 0, 取值范围是 0-9。 S1003 , 判断第 i张哈希子表的表容量是否小于计算的哈希值, 如是, 则执行步驟 S1005a, 否则执行步驟 S1005b。 In this embodiment, the initial value of i is 0, and the value ranges from 0 to 9. S1003: Determine whether the table capacity of the i-th hash sub-table is less than the calculated hash value, and if yes, execute step S1005a, otherwise perform step S1005b.
S1005a, 对计算得到的 16 bit哈希值从高比特位开始进行截取, 并以 截取后的哈希值作为索引, 执行步驟 S1007。  S1005a, the calculated 16-bit hash value is intercepted from the high-order bit, and the intercepted hash value is used as an index, and step S1007 is performed.
S1005b, 以计算得到的哈希值作为索引。  S1005b, using the calculated hash value as an index.
S1007、 根据索引值在第 i张哈希子表中查找是否有空位, 即判断对应 的 bitmap中沖突位为 0, 有效位为 0, 若是执行步驟 S 1009, 否则, 执行步 驟 S1011。  S1007: Find, according to the index value, whether there is a space in the i-th hash sub-table, that is, determine that the conflict bit in the corresponding bitmap is 0, and the valid bit is 0. If yes, execute step S1009; otherwise, execute step S1011.
S1009, 将待存储表项所对应的所有信息放入查找到的空位中, 将其对 应的 bitmap中沖突位置 0, 有效位置 1。  S1009: Put all the information corresponding to the table to be stored into the found space, and set a conflict position 0 and a valid position 1 in the corresponding bitmap.
至此, 本条表项计算、 存储过程结束, 开始存储下条表项。  At this point, the calculation of this entry and the end of the stored procedure begin to store the next entry.
S1011 , 如果该位图的沖突位为 0, 且有效位为 1 , 即该地址已存储一 条表项, 则执行步驟 S1012; 如果该位图的沖突位为 1 , 则执行步驟 S1013。  S1011, if the conflict bit of the bitmap is 0, and the valid bit is 1, that is, the address has stored one entry, step S1012 is performed; if the conflict bit of the bitmap is 1, step S1013 is performed.
S1013 , 将该存储的表项取出, 将当前键值与取出的表项键值存入到 bitmap中, 且沖突位置 1 , 执行步驟 S1017。  S1013: The stored entry is taken out, and the current key value and the extracted entry key value are stored in the bitmap, and the conflict position is 1, and step S1017 is performed.
S1013 , 将当前键值存入对应的 bitmap中。  S1013: Store the current key value in the corresponding bitmap.
S1015, i = i + l , 返回步驟 S1001 , 即开始在下一张表中查找空位, 直 到找到空位存储该条表项为止。  S1015, i = i + l , returns to step S1001, and starts to find the gap in the next table until the slot is found to store the entry.
请参阅图 11 , 该图为本实施方式中的一种查找表项的一种实施例的逻 辑结构图, 对于一个需要查找的哈希键值, 首先经过哈希函数 0~9并行计 算出哈希值, 这里的每个哈希函数必须与存储表项时所用的哈希函数相同; 然后利用计算得到的哈希值作为索引值分别在各自对应的 bitmap表中并行 地查找, 确定出匹配表项的地址, 将该地址传送给哈希子表存储器取出表 项, 各个哈希子表存储器还留有一个端口用作 CPU访问; 最后, 将取出的 表项与需要查找的键值比较, 确定匹配后, 将该项所有的信息作为最终的 查表结果返回给用户, 至此查表过程结束。 Please refer to FIG. 11 , which is a logical structural diagram of an embodiment of a lookup table entry in the embodiment. For a hash key value to be searched, the hash function 0 to 9 is first calculated in parallel. The hash value, each hash function here must be the same as the hash function used to store the table entry; then the calculated hash value is used as the index value to search in parallel in the corresponding bitmap table to determine the matching table. The address of the item, the address is transferred to the hash sub-table memory fetch entry, and each hash sub-table memory still has a port for CPU access; finally, the fetched entry is compared with the key value to be searched to determine the match. , all the information of the item as the final The result of the lookup table is returned to the user, and the process of checking the table ends.
由于在查找时是对所有 10张 bitmap表进行并行查找,那么只需要一个 查找周期和一个周期读取哈希子表存储器就能实现全部命中, 这样就实现 了在保证无表项遗留的前提条件下, 以比较小的片内表空间容量和一个存 储器接口, 实现快速的哈希查找。  Since all 10 bitmap tables are searched in parallel during the search, only one search cycle and one cycle read the hash sub-table memory can achieve all hits, thus realizing the premise of guaranteeing the absence of the entry. Faster hash lookup with a smaller on-chip table space capacity and a memory interface.
实施例三:  Embodiment 3:
请参阅图 9, 该图为本实施方式中的哈希表的一实施例逻辑结构图, 其 中输入键值通过输入接口输入到本实施例的哈希子表中, 通过哈希表控制 器对输入键值计算其哈希值, 以该哈希值作为索引在哈希子表中查找空位 并填入;其中哈希子表 0-9是 10个存储器,代表 10张哈希子表, bitmap0~9 是 10个状态表, 但本实施例中的 10个存储器中的前 4个的存储深度为 m, 而后 6个的存储深度为 m/2。  Referring to FIG. 9, the figure is a logical structure diagram of an embodiment of a hash table in the embodiment. The input key value is input to the hash sub-table of the embodiment through an input interface, and the input is input through a hash table controller. The key value calculates its hash value, and the hash value is used as an index to find the empty space in the hash sub-table and fill in; wherein the hash sub-table 0-9 is 10 memories, representing 10 hash sub-tables, and bitmap0~9 is 10 A state table, but the first four of the ten memories in this embodiment have a memory depth of m, and the last six have a memory depth of m/2.
本实施例中哈希表控制器的逻辑结构, 哈希表的存储、 查找流程, 以 及查找表项的逻辑结构与实施例二中完全一致。  The logical structure of the hash table controller in this embodiment, the storage of the hash table, the search process, and the logical structure of the lookup table are exactly the same as those in the second embodiment.
与实施例二相比, 实施例三的空间利用率更高。 能认定本发明的具体实施只局限于这些说明。 对于本发明所属技术领域的 普通技术人员来说, 在不脱离本发明构思的前提下, 还可以做出若干简单 推演或替换, 都应当视为属于本发明的保护范围。  Compared with the second embodiment, the space utilization rate of the third embodiment is higher. It is to be understood that the specific embodiments of the invention are limited only by the description. It is to be understood by those skilled in the art that the present invention may be practiced without departing from the spirit and scope of the invention.

Claims

权利要求书 Claim
1、 一种哈希表的表项添加方法, 其中, 该方法包括:  A method for adding an entry of a hash table, where the method includes:
将哈希表拆分为多张哈希子表, 每一张哈希子表对应一张位图, 每一 张位图对应一个哈希函数;  Splitting the hash table into multiple hash sub-tables, each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function;
确定当前目标哈希子表, 利用当前目标哈希子表所对应的位图相应的 哈希函数计算待存储表项的键值的哈希值, 根据所述哈希值确定当前目标 哈希子表所对应的存储位置是否为空位, 如是, 将所述待存储表项的信息 存入该空位中, 否则, 更新当前目标哈希子表直至找到空位存储所述待存 储表项的信息。  Determining a current target hash sub-table, calculating a hash value of the key value of the table to be stored by using a hash function corresponding to the bitmap corresponding to the current target hash sub-table, and determining, according to the hash value, a current target hash sub-table Whether the storage location is a vacancy, if yes, the information of the to-be-stored entry is stored in the vacancy, otherwise, the current target hash sub-table is updated until a vacancy is found to store the information of the to-be-stored entry.
2、如权利要求 1所述的方法, 其中, 所述位图包含了沖突位和有效位, 根据所述哈希值确定当前目标哈希子表所对应的存储位置是否为空位, 如 是, 将所述待存储表项的信息存入该空位中, 否则, 更新当前目标哈希子 表直至找到空位存储所述待存储表项的信息, 包括:  The method of claim 1, wherein the bitmap includes a conflict bit and a valid bit, and determining, according to the hash value, whether a storage location corresponding to the current target hash sub-table is a vacancy, and if so, The information about the storage entry is stored in the slot. Otherwise, the current target hash sub-table is updated until the slot is found to store the information of the to-be-stored entry, including:
以所述哈希值作为索引, 查找所述当前目标哈希子表对应的位图; 判断所述位图的有效位是否有效, 且所述位图的沖突位是否为无效; 所述有效位为有效, 且所述沖突位为无效, 则确定所述当前目标哈希 子表所对应的存储位置为空位, 则将所述待存储表项的信息存入该空位; 否则, 更新当前目标哈希子表直至找到空位存储所述待存储表项的信息。  Using the hash value as an index, searching for a bitmap corresponding to the current target hash sub-table; determining whether the valid bit of the bitmap is valid, and whether the conflict bit of the bitmap is invalid; the valid bit is If the conflicting bit is invalid, and determining that the storage location corresponding to the current target hash sub-table is a vacancy, the information of the to-be-stored entry is stored in the vacancy; otherwise, the current target hash sub-table is updated. The information of the item to be stored is stored until the vacancy is found.
3、 如权利要求 2所述的方法, 其中, 所述以所述哈希值作为索引, 查 找所述当前目标哈希子表对应的位图为:  3. The method according to claim 2, wherein the using the hash value as an index, searching for a bitmap corresponding to the current target hash sub-table is:
判断当前目标哈希子表的容量是否小于计算得到的所述哈希值的位 数;  Determining whether the capacity of the current target hash sub-table is less than the calculated number of bits of the hash value;
如果所述当前目标哈希子表的容量小于计算得到的所述哈希值的位 数, 则截取所述哈希值, 并将截取后的哈希值作为索引, 查找所述当前目 标哈希子表对应的位图。 If the capacity of the current target hash sub-table is less than the calculated number of bits of the hash value, intercept the hash value, and use the intercepted hash value as an index to find the current target hash sub-table The corresponding bitmap.
4、 如权利要求 2所述的方法, 其中, 将所述待存储表项的信息存入空 位后, 该方法还包括: The method of claim 2, wherein after the information of the item to be stored is stored in a space, the method further includes:
将所述位图的有效位置为无效, 并将所述待存储表项的键值存储到该 位图中。  The valid position of the bitmap is invalid, and the key value of the table to be stored is stored in the bitmap.
5、 如权利要求 2所述的方法, 其中, 所述更新当前目标哈希子表直至 找到空位存储所述待存储表项的信息为:  5. The method according to claim 2, wherein the updating the current target hash sub-table until the location of the vacant space to store the to-be-stored entry is:
当所述位图的沖突位为无效、 有效位为无效, 则将该位图对应的哈希 子表中已存的表项取出, 将该沖突位置为有效, 并将取出表项的键值与当 前的待存储表项的键值存入该位图中;  When the conflict bit of the bitmap is invalid and the valid bit is invalid, the existing entry in the hash sub-table corresponding to the bitmap is taken out, the conflict position is valid, and the key value of the entry is taken out. The key value of the current table to be stored is stored in the bitmap;
判断当前的目标哈希子表是否为最后一张哈希子表, 如果不是最后一 张哈希子表, 则将当前目标哈希子表更新为下一张哈希子表, 直至查找到 空位存储所述待存储表项的信息。  Determining whether the current target hash sub-table is the last hash sub-table, if not the last hash sub-table, updating the current target hash sub-table to the next hash sub-table until the vacancy is found to store the to-be-stored The information of the entry.
6、 如权利要求 2所述的方法, 其中, 所述更新当前目标哈希子表直至 找到空位存储所述待存储表项的信息为:  The method of claim 2, wherein the updating the current target hash sub-table until the location of the vacant space to store the to-be-stored entry is:
当该位图的沖突位为有效, 则当前的待存储表项的键值直接存入到该 位图中;  When the conflict bit of the bitmap is valid, the key value of the current to-be-stored entry is directly stored in the bitmap;
判断当前目标哈希子表是否为最后一张哈希子表, 如果不是最后一张 哈希子表, 则将当前目标哈希子表更新为下一张哈希子表, 直至找到空位 存储所述待存储表项的信息。  Determining whether the current target hash sub-table is the last hash sub-table, if not the last hash sub-table, updating the current target hash sub-table to the next hash sub-table until the empty space is found to store the to-be-stored entry Information.
7、 如权利要求 1至 6任意一项所述的方法, 其中, 该方法还包括: 当所述待存储表项存储完成后, 同步更新位图的沖突位信息和哈希子 表的信息。  The method according to any one of claims 1 to 6, wherein the method further comprises: synchronously updating the conflict bit information of the bitmap and the information of the hash sub-table after the storage of the to-be-stored entry is completed.
8、 如权利要求 1至 6任意一项所述的方法, 其中, 所述哈希子表对应 的哈希函数为循环冗余码校验函数。  The method according to any one of claims 1 to 6, wherein the hash function corresponding to the hash sub-table is a cyclic redundancy code check function.
9、 如权利要求 1至 6任意一项所述的方法, 其中, 所述多张哈希子表 对应的哈希函数之间采用不同的循环冗余码校验多项式。 The method according to any one of claims 1 to 6, wherein the plurality of hash sub-tables Different cyclic redundancy code check polynomials are used between the corresponding hash functions.
10、 一种哈希表的表项删除方法, 其中, 哈希表包括多张哈希子表, 每一张哈希子表对应一张位图, 每一张位图对应一个哈希函数, 且每张所 述位图包括多个条目, 该方法包括:  10, a hash table entry deletion method, wherein the hash table includes multiple hash sub-tables, each hash sub-table corresponds to a bitmap, each bitmap corresponds to a hash function, and each The bitmap includes a plurality of entries, and the method includes:
每张位图所对应的哈希函数并行计算需要删除的条目的哈希值; 根据计算得到的哈希值, 在其各自对应的位图中并行查找;  The hash function corresponding to each bitmap calculates the hash value of the item to be deleted in parallel; according to the calculated hash value, it searches in parallel in its corresponding bitmap;
将每一张位图的查找结果顺序进行比较, 当第一次出现沖突位为无效 时, 将该位图的地址对应的哈希子表中的表项取出;  The search results of each bitmap are sequentially compared. When the first occurrence of the conflict bit is invalid, the entry in the hash sub-table corresponding to the address of the bitmap is taken out;
将取出的表项的键值与需要查找的键值进行比较, 如果相同, 则将所 述表项从所述哈希子表中删除。  The key value of the fetched entry is compared with the key value to be searched. If they are the same, the entry is deleted from the hash subtable.
11、 如权利要求 10所述的方法, 其中, 所述删除表项之后, 该方法还 包括;  The method according to claim 10, wherein after the deleting the entry, the method further includes:
将对应的位图的沖突位置为无效, 有效位置为有效。  The conflict position of the corresponding bitmap is invalid, and the valid position is valid.
12、 如权利要求 10所述的方法, 其中, 该方法还包括:  12. The method of claim 10, wherein the method further comprises:
将删除的表项所在的位图之前的所有位图中所存储的所有键值进行比 较;  Compare all key values stored in all bitmaps before the bitmap in which the deleted entry is located;
如果某个位图中所存储的键值大于两个, 则直接将需要删除的键值删 掉; 或者,  If the key value stored in a bitmap is greater than two, delete the key value that needs to be deleted directly; or,
如果某个位图中所存储的键值等于两个, 则将需要删除的键值删掉, 并查找到另一个键值所存储的位置, 将其取出, 存入该位图所对应的哈希 子表中。  If the key value stored in a bitmap is equal to two, delete the key value that needs to be deleted, and find the location where another key value is stored, take it out, and store it in the corresponding bitmap. In the table.
13、 一种哈希表的查找方法, 其中, 所述哈希表包括多张哈希子表, 每张哈希子表对应一张位图, 每张位图对应一个哈希函数, 该方法包括: 利用每张哈希子表对应的哈希函数并行计算待查找表项的键值的哈希 值; 根据计算得到的所述哈希值在对应的位图中并行查找; A hash table search method, wherein the hash table includes a plurality of hash sub-tables, each hash sub-table corresponds to a bitmap, and each bitmap corresponds to a hash function, and the method includes: Using the hash function corresponding to each hash sub-table to calculate the hash value of the key value of the table to be searched in parallel; The hash value obtained according to the calculation is searched in parallel in the corresponding bitmap;
将每一张位图的查找结果顺序进行比较, 当第一次出现沖突位为无效 时, 取出该位图的地址对应的哈希子表中的表项;  The search results of each bitmap are sequentially compared. When the first occurrence of the conflict bit is invalid, the entry in the hash sub-table corresponding to the address of the bitmap is taken out;
将取出的表项的键值与待查找表项的键值进行比较, 如果取出的表项 的键值与所述待查找表项的键值相匹配, 则将该表项的信息作为最终查表 结果。  The key value of the extracted entry is compared with the key value of the entry to be searched. If the key value of the retrieved entry matches the key of the to-be-find entry, the information of the entry is used as a final check. Table results.
14、 如权要求 13所述的方法, 其中, 该方法还包括: 取出的表项的键 值与所述待查找表项的键值不相匹配, 则返回查找失败的消息。  The method of claim 13, wherein the method further comprises: if the key value of the retrieved entry does not match the key of the to-be-find entry, returning a message that the search fails.
15、 如权利要求 13或者 14所述的方法, 其中, 所述根据计算得到的 所述哈希值在对应的位图中并行查找为:  The method according to claim 13 or 14, wherein the calculated hash value is found in parallel in the corresponding bitmap as:
根据计算得到的所述哈希值对应的哈希子表的容量, 对所述哈希值进 行截取;  Obtaining the hash value according to the calculated capacity of the hash sub-table corresponding to the hash value;
将截取后的哈希值作为索引, 在其对应的位图中并行查找。  The intercepted hash value is used as an index and is searched in parallel in its corresponding bitmap.
16、 如权利要求 15所述的方法, 其中, 所述位图对应的哈希函数与存 储表项时所述哈希子表对应的哈希函数相同。  The method according to claim 15, wherein the hash function corresponding to the bitmap is the same as the hash function corresponding to the hash sub-table when the table entry is stored.
17、 一种哈希表存储装置, 包括主控逻辑模块, 以及与所述主控逻辑 模块相连的控制线路和数据线路, 其中, 主控逻辑模块控制所述控制线路 完成表项的添加和 /或删除, 以及控制数据线路完成表项查找, 其中, 所述 控制线路包括: 表项拆分模块, 目标哈希子表确定模块和表项存储模块, 其中,  17. A hash table storage device, comprising a main control logic module, and a control line and a data line connected to the main control logic module, wherein the main control logic module controls the addition of the control line completion entry and/or Or deleting, and controlling the data line completion entry search, where the control line includes: an entry split module, a target hash sub-determination module, and an entry storage module, where
所述表项拆分模块, 设置为将哈希表拆分为多张哈希子表和多张位图, 且每张哈希子表对应一张位图和一个哈希函数;  The table splitting module is configured to split the hash table into multiple hash subtables and multiple bitmaps, and each hash subtable corresponds to a bitmap and a hash function;
所述目标哈希子表确定模块, 与所述表项拆分模块相连, 设置为从所 述表项拆分模块拆分得到的多张哈希子表中的确定一张哈希子表作为当前 的目标哈希子表; 并当接收到所述表项存储模块发出的更新指令后, 设置 为将当前的目标哈希子表更新为其下一张哈希子表; The target hash sub-table determining module is connected to the table splitting module, and is configured to determine a hash sub-table from the plurality of hash sub-tables obtained by splitting the table splitting module as a current target. Hash subtable; and after receiving the update instruction issued by the entry storage module, setting To update the current target hash subtable to its next hash subtable;
所述表项存储模块, 与所述目标哈希子表确定模块相连, 设置为利用 所述当前目标哈希子表所对应的哈希函数, 计算所述待存储表项的键值的 哈希值, 并根据所述哈希值确定当前目标哈希子表所对应的存储位置是否 为空位, 如是, 将待存储表项的信息存入该空位, 否则向所述目标哈希子 表确定模块发送更新指令, 直至查找到空位存储所述待存储表项的。  The entry storage module is configured to be connected to the target hash sub-table determining module, and configured to calculate a hash value of the key value of the to-be-stored entry by using a hash function corresponding to the current target hash sub-table. And determining, according to the hash value, whether the storage location corresponding to the current target hash sub-table is a vacancy, and if yes, storing information of the entry to be stored in the vacancy, otherwise sending an update instruction to the target hash sub-determination module, The storage of the to-be-stored entry is not found until the slot is found.
18、如权利要求 17所述的装置, 其中, 所述位图包含沖突位和有效位, 所述表项存储模块包括计算子模块、 查找子模块、 表项添加子模块, 其中, 所述计算子模块, 与所述目标哈希子表确定模块相连, 设置为利用所 述当前目标哈希子表所对应的哈希函数, 计算所述待存储表项的键值的哈 希值;  The device of claim 17, wherein the bitmap includes a conflicting bit and a valid bit, the entry storage module includes a computing submodule, a searching submodule, and an entry adding submodule, wherein the calculating a sub-module, connected to the target hash sub-table determining module, configured to calculate a hash value of the key value of the to-be-stored entry by using a hash function corresponding to the current target hash sub-table;
所述查找子模块, 与所述计算子模块相连, 设置为判断所述目标哈希 子表确定模块计算的哈希值的位数是否大于等于所述当前目标哈希子表的 容量, 如是, 则截取所述哈希值, 并将截取后的哈希值作为索引, 查找相 应的位图, 并判断所述位图的有效位是否有效, 且所述位图的沖突位是否 为无效, 如是, 则判定所述目标哈希子表中的存储位置为空位, 否则, 则 向所述目标哈希子表确定模块发送更新指令, 直至查找到空位;  The search sub-module is connected to the calculation sub-module, and is configured to determine whether the number of bits of the hash value calculated by the target hash sub-table determination module is greater than or equal to the capacity of the current target hash sub-table, and if so, intercept The hash value, and taking the intercepted hash value as an index, searching for a corresponding bitmap, and determining whether the valid bit of the bitmap is valid, and whether the conflict bit of the bitmap is invalid, if yes, Determining that the storage location in the target hash sub-table is a vacancy; otherwise, sending an update instruction to the target hash sub-table determination module until a vacancy is found;
所述表项添加子模块, 与所述查找子模块相连, 设置为当所述查找子 模块在所述当前目标哈希子表中查找到空位时, 将所述待存储表项的信息 存入所述空位中。  Adding a sub-module of the entry to the lookup sub-module, and setting, when the search sub-module finds a vacancy in the current target hash sub-table, storing the information of the to-be-stored entry into the Said in the vacancy.
19、 如权利要求 18所述的装置, 其中, 当所述表项添加子模块将所述 待存储表项的信息存入所述空位中后, 所述表项添加子模块还设置为将所 述位图的有效位置为无效, 并将所述待存储表项的键值存储到所述位图中。  The device according to claim 18, wherein, after the entry adding sub-module stores the information of the to-be-stored entry into the slot, the entry adding sub-module is further configured to be The valid position of the bitmap is invalid, and the key value of the table to be stored is stored in the bitmap.
20、 如权利要求 18所述的装置, 其中, 当所述查找子模块判断出所述 位图的有效位为无效时, 还设置为判断所述位图的沖突位是否为无效, 如 是, 则所述表项添加子模块设置为将所述位图对应哈希子表中已存储的表 项取出, 并将取出的表项的键值与所述当前待存储表项的键值存入到所述 位图中; 当所述查找子模块判断出所述位图的沖突位为有效时, 则所述表 项存储模块的表项添加子模块设置为将当前的所述待存储表项的键值存储 到所述位图中。 The device according to claim 18, wherein, when the finding sub-module determines that the valid bit of the bitmap is invalid, it is further configured to determine whether the conflict bit of the bitmap is invalid, such as If yes, the entry adding submodule is configured to take out the stored table entry in the hash sub-table, and store the key value of the extracted entry and the key value of the current to-be-stored entry. Entering into the bitmap; when the lookup sub-module determines that the conflict bit of the bitmap is valid, the entry add sub-module of the entry storage module is set to be the current to-be-stored table The key value of the item is stored in the bitmap.
21、如权利要求 17所述的装置,其中, 所述哈希表包括多张哈希子表, 每张哈希子表对应一张位图和一个哈希函数, 所述数据线路包括并行计算 模块, 并行查找模块以及比较模块, 其中,  The apparatus of claim 17, wherein the hash table comprises a plurality of hash sub-tables, each hash sub-table corresponds to a bitmap and a hash function, and the data line comprises a parallel computing module. a parallel search module and a comparison module, wherein
并行计算模块, 设置为利用每张哈希子表对应的哈希函数, 并行计算 待查找表项的键值的哈希值;  The parallel computing module is configured to calculate a hash value of the key value of the to-be-find table item in parallel by using a hash function corresponding to each hash sub-table;
并行查找模块, 与所述并行计算模块相连, 设置为根据计算得到的哈 希值在其各自对应的位图中并行地查找;  a parallel search module, connected to the parallel computing module, configured to search in parallel according to the calculated hash values in their respective bitmaps;
比较模块, 设置为将各个位图的查表结果进行比较判断, 确定出匹配 的表项所在的哈希子表的地址, 将该地址存储的表项的信息取出, 并与需 要查找的键值进行比较, 判断取出的表项是否与待查找的表项相匹配, 如 匹配, 则将该表项的信息作为最终查表结果。  The comparison module is configured to compare and compare the lookup results of the respective bitmaps, determine the address of the hash sub-table in which the matching entry is located, take out the information of the entry stored in the address, and perform the key value that needs to be searched. The comparison determines whether the extracted entry matches the entry to be searched. If the entry is matched, the information of the entry is used as the final lookup result.
PCT/CN2012/072473 2011-05-25 2012-03-16 Table entry adding, deleting and searching method of hash table and hash table storage device WO2012159480A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110138340.7 2011-05-25
CN201110138340.7A CN102194002B (en) 2011-05-25 The list item interpolation of Hash table, deletion, lookup method and Hash table storage device

Publications (1)

Publication Number Publication Date
WO2012159480A1 true WO2012159480A1 (en) 2012-11-29

Family

ID=44602071

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/072473 WO2012159480A1 (en) 2011-05-25 2012-03-16 Table entry adding, deleting and searching method of hash table and hash table storage device

Country Status (1)

Country Link
WO (1) WO2012159480A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104162278A (en) * 2014-06-17 2014-11-26 廖明忠 Air suspension and programmable motion method and system and toy flight vehicle

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060117036A1 (en) * 2004-11-30 2006-06-01 Thierry Cruanes Method and apparatus to support bitmap filtering in a parallel system
CN101604337A (en) * 2009-07-13 2009-12-16 中兴通讯股份有限公司 Device and method for storing and searching hash table items
CN102194002A (en) * 2011-05-25 2011-09-21 中兴通讯股份有限公司 Table entry adding, deleting and searching method of hash table and hash table storage device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060117036A1 (en) * 2004-11-30 2006-06-01 Thierry Cruanes Method and apparatus to support bitmap filtering in a parallel system
CN101604337A (en) * 2009-07-13 2009-12-16 中兴通讯股份有限公司 Device and method for storing and searching hash table items
CN102194002A (en) * 2011-05-25 2011-09-21 中兴通讯股份有限公司 Table entry adding, deleting and searching method of hash table and hash table storage device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104162278A (en) * 2014-06-17 2014-11-26 廖明忠 Air suspension and programmable motion method and system and toy flight vehicle
CN104162278B (en) * 2014-06-17 2016-08-17 廖明忠 A kind of air suspension and the method for programmable movements, system and toy aircraft

Also Published As

Publication number Publication date
CN102194002A (en) 2011-09-21

Similar Documents

Publication Publication Date Title
CN101604337B (en) Device and method for storing and searching hash table items
US8635402B2 (en) Storage system and storage access method and program
US9021189B2 (en) System and method for performing efficient processing of data stored in a storage node
CN103345472B (en) Deduplication File System Based on Finite Binary Tree Bloom Filter and Its Construction Method
US9871727B2 (en) Routing lookup method and device and method for constructing B-tree structure
CN103581331B (en) The online moving method of virtual machine and system
WO2018205151A1 (en) Data updating method and storage device
US11449270B2 (en) Address translation method and system for KV storage device
CN114625762A (en) Metadata acquisition method, network device and system
WO2012013023A2 (en) Hash search method for reducing hash conflicts
CN115237954A (en) Method, PIM device and system for cuckoo hash query based on PIM device
WO2023093091A1 (en) Data storage system, smart network card, and computing node
WO2015032214A1 (en) High-speed routing lookup method and device simultaneously supporting ipv4 and ipv6
CN119166566A (en) Storage controller and electronic system
CN101211346A (en) Method for optimizing memorizer performance
CN113127717A (en) Key retrieval method and system
WO2012159480A1 (en) Table entry adding, deleting and searching method of hash table and hash table storage device
CN118519827A (en) Data backup, recovery and query method and device for distributed database
WO2021208403A1 (en) Data flow table and processing method and apparatus therefor, and storage medium
US20230113460A1 (en) Systems and Methods for Key-based Indexing in Storage Devices
CN102194002B (en) The list item interpolation of Hash table, deletion, lookup method and Hash table storage device
US10503409B2 (en) Low-latency lightweight distributed storage system
CN115309745A (en) A key-value pair storage method, device, device and medium
CN116301636B (en) Method for managing data structure and hardware accelerator based on hash algorithm
CN119003306B (en) Hardware implementation method for optimizing KV storage performance based on configurable logic

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: 12789449

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: 12789449

Country of ref document: EP

Kind code of ref document: A1

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载