WO2016141887A1 - Hash table processing - Google Patents

Hash table processing Download PDF

Info

Publication number
WO2016141887A1
WO2016141887A1 PCT/CN2016/076114 CN2016076114W WO2016141887A1 WO 2016141887 A1 WO2016141887 A1 WO 2016141887A1 CN 2016076114 W CN2016076114 W CN 2016076114W WO 2016141887 A1 WO2016141887 A1 WO 2016141887A1
Authority
WO
WIPO (PCT)
Prior art keywords
signature
hash
entry
key
matched
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2016/076114
Other languages
French (fr)
Inventor
Changzhong Ge
Kai Ren
Jianming Song
Yunfeng Zhao
Shaoliang AN
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou H3C Technologies Co Ltd
Original Assignee
Hangzhou H3C Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou H3C Technologies Co Ltd filed Critical Hangzhou H3C Technologies Co Ltd
Publication of WO2016141887A1 publication Critical patent/WO2016141887A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • Hash table is a data structure with higher search performance. Hash table may be accessed with a key value. That is, map a key value to a position of a hash table to access entries, so as to accelerate search speed.
  • FIG. 1 is a schematic diagram illustrating an application structure of a hash table, in accordance with an example of the present disclosure.
  • FIG. 2 is a flowchart illustrating a method for processing a hash table, in accordance with an example of the present disclosure.
  • FIG. 3a is a schematic diagram illustrating structure of a first memory 23 in a hash table processing device, in accordance with an example of the present disclosure.
  • FIG. 3b is a schematic diagram illustrating structure of a logic chip 22 in a hash table processing device, in accordance with an example of the present disclosure.
  • FIG. 4 is a schematic diagram illustrating an application structure of a hash table, in accordance with another example of the present disclosure.
  • FIG. 5a and FIG. 5b are respectively a flowchart illustrating a method for processing a hash table, in accordance with an example of the present disclosure.
  • FIG. 6a is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
  • FIG. 6b is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
  • FIG. 6c is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
  • FIG. 6d is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
  • FIG. 7 is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
  • a hash table may be applied to a structure, which may include a central processing unit (CPU) 21, a logic chip 22, a first memory 23 and a second memory 24.
  • the CPU 21 may be a single core processor or a multi-core processor.
  • the logic chip 22 may be a programmable logic device, such as Field-Programmable Gate Array (FPGA) .
  • the first memory 23 and the second memory 24 may be storage mediums, such as double date rate (DDR) synchronous dynamic random access memory (SDRAM) .
  • DDR double date rate
  • SDRAM synchronous dynamic random access memory
  • the CPU 21 may be connected with the logic chip 22.
  • the first memory 23 may be connected with CPU 21.
  • the second memory 24 may be connected with the logic chip 22.
  • the logic chip 22 and connected second memory 24 may be taken as hardware layer.
  • the CPU 21 and connected first memory 23 may be taken as machine readable instruction layer.
  • the CPU 21 may execute operations, such as add, delete and search, to the hash table 20 in the first memory 23. After executing the add or delete operation to the hash table 20 in the first memory 23, the CPU 21 may copy the hash table 20 to the second memory 24, such that the hash table 20 may be used in the hardware layer.
  • the logic chip 22 in the hardware layer may execute a search operation to the hash table 20 stored in the second memory 24.
  • IP address length may change from 32 bits of IPv4 to 128 bits. Subsequently, length of Key 221 of a corresponding IP address may also be increased. For a hash table taking flow table as an example, length of a five tuple may be changed from 104 bits of IPv4 to 296 bits of IPv6. Correspondingly, when representing an IP address, the length of Key 221 may be increased significantly. Subsequently, the length of Signature&result 201 may also be increased. Thus, number of Signature&result 201 stored in the second memory 24 with limited storage capacity may be reduced significantly, and usage of a large-size hash table 20 in the hardware layer may be limited.
  • the hash table 20 may include a hash area 20a and a conflict zone 20b.
  • the hash area 20a and conflict zone 20b may respectively possess a hash bucket 200a and a hash bucket 200b.
  • Either of hash bucket 200a and hash bucket 200b may at least include a hash entry.
  • a Signature may be obtained, based on Key and a preset calculation method, such as MD5 (Message Digest Algorithm 5) , CRC (Cyclical Redundancy Check) and SHA-1 (Secure Hash Algorithm) .
  • the Key in each hash entry may be replaced with a Signature, length thereof may be less than that of Key. In some examples, length of Signature may be uniform for Key with a different length.
  • a hash entry may be represented with Signature&result 201 in the example illustrated with FIG. 1.
  • number of Signature&result 201 e.g., number of hash entry
  • hash bucket 200a or 200b it does not mean that there is one Signature&result 201 (e.g., number of hash entry) in hash bucket 200a or 200b.
  • the conflict zone 20b may be formed by a linked list in the example illustrated with FIG. 1.
  • the hash bucket 200a or 200b may still include a pointer 202.
  • the pointer 202 in the hash bucket 200a of the hash area 20a may point to the hash bucket 200b in the conflict zone 20b.
  • the pointer 202 of the hash bucket 200b in the conflict zone 20b may point to a hash bucket (not shown in FIG. 1) of a next level in the conflict zone 20b. Subsequently, the pointer 202 may enable the hash bucket 200a and at least one hash bucket 200b to constitute a hash bucket linked list.
  • Hash_idx 222 (hash address or hash index) may be calculated based on Key 221. And then, corresponding hash buckets 200a and 200b may be indexed in the hash table 20, by using the calculated Hash_idx 222. In some examples, Key 221 may be converted into Signature 223. A Signature&result 201 may be matched with the same Signature value in the indexed hash bucket 200a and the hash bucket 200b, based on Signature 223.
  • a result of the matched Signature&result 201 may be replaced with another result corresponding to Key 221, so as to implement the add operation.
  • a new Signature&result 201 may be inserted into an idle position of a hash bucket 200a or 200b.
  • the new Signature&result 201 may carry the Signature 223 and a result corresponding to Key 221, so as to implement the add operation.
  • Hash_idx 222 may be calculated based on Key 221. And then, corresponding hash buckets 200a and 200b may be indexed in the hash table 20, by using the calculated Hash_idx 222. In some examples, Key 221 may be converted into Signature 223. A Signature&result 201 may be matched with the same Signature value in the indexed hash buckets 200a and 200b, based on Signature 223.
  • the matched Signature&result 201 may be set to be invalid, so as to implement the delete operation.
  • Hash_idx 222 may be calculated based on Key 221. And then, a corresponding hash bucket 200a or 200b may be indexed in the hash table 20, by using the calculated Hash_idx 222. In some examples, Key 221 may be converted into Signature 223. And a Signature&result 201 may be matched with the same Signature value in the indexed hash buckets 200a and 200b, based on Signature 223.
  • Hash_idx 222 When there is a matched Signature&result 201 in a hash bucket 200a or 200b pointed to by Hash_idx 222, read the result of the matched Signature&result 201, so as to implement the search operation.
  • length of Signature 223 may be consistent for Key 221 with a different length. That is, in the example illustrated with FIG. 1, Key 221 with a different length may be converted into Signature 223 with a uniform length.
  • the process for converting Key 221 into Signature 223 may be taken as a length reducing process, and a length normalization process.
  • length of Signature 223 may be taken as the normalized length.
  • length of Signature 223 of each hash table 20 stored in the second memory 24 may be uniform.
  • the logic chip 22 in hardware layer may not implement complicated programming, so as to adapt to a different length of Key 221.
  • the normalized length of Signature 223 may be achieved with the following modes in the example illustrated with FIG. 1.
  • the normalized length of Signature 223 may be limited by utilizing a preset target value of conflict probability.
  • N may represent the target value of conflict probability.
  • N may represent number of Signature&result 201 in hash table 20.
  • I may represent value range of Hash_idx 222.
  • S may represent value range of Signature 223.
  • the probability demonstrating that the conflict occurs may be
  • N 2 20
  • I 2 20
  • P (N) 0.0000000000005684341615028642778715783961.
  • Hash_idx 222 and Signature 223 For example, during the process of executing an add, delete, or search operation to hash table 20, when at least two Keys 221 with different Key values correspond to the same Hash_idx 222 and Signature 223, it may be considered that foregoing false hit probability occurs.
  • N may represent number of Signature&result 201 in hash table 20.
  • I may represent value range of Hash_idx 222.
  • S may represent value range of Signature 223.
  • MTBF meantime between failure
  • a preset target value of conflict probability For example, when calculating that the normalized length S1 of Signature 223 is 32 bits, based on foregoing first limitation mode, utilize the preset target value of false hit probability to limit the normalized length of Signature 223.
  • the normalized length of Signature 223 may be the maximum value of S1 and S2, that is, 33 bits. It should be noted that, S1 and S2 may also be other values.
  • a method for processing a hash table may include the following blocks.
  • Hash_idx based on Key.
  • the Key may be obtained from a packet, and may be used for triggering an add operation, a delete operation or a search operation.
  • the hash bucket searched out in block S312 may include multiple hash buckets in the hash bucket chained list.
  • block S314 utilize the Signature to match an entry (e.g., Signature&result) in the indexed hash bucket.
  • an entry e.g., Signature&result
  • the hash bucket indexed in block S312 includes multiple hash buckets in the hash bucket chained list, match an entry of the multiple hash buckets in block S314.
  • the add operation, or delete operation may be executed by CPU 21.
  • the search operation may be executed by logic chip 22.
  • the operation executed in block S315 may be the add operation, or the delete operation.
  • the operation executed in block S315 may be the search operation.
  • the foregoing mode may adapt to an application setting, where CPU 21 may maintain the hash table, and copy the hash table to logic chip 22.
  • CPU 21 may also execute the search operation.
  • logic chip 22 may also execute the add operation, or delete operation.
  • the normalized length of Signature may be set, based on the preset target value of conflict probability and the preset target value of false hit probability, as well as foregoing mode.
  • a device for processing a hash table may include an address calculator 411, an address indexer 412, a Signature calculator 413, a Signature matcher 414 and an operation executer 415.
  • the address calculator 411 is to calculate Hash_idx based on Key.
  • the Key may be obtained from a packet, and may be used for triggering an add operation, a delete operation or a search operation.
  • the address indexer 412 may utilize the calculated Hash_idx to index a corresponding hash bucket in the hash table.
  • the hash bucket searched out by the address indexer 412 may include multiple hash buckets in the hash bucket chained list.
  • the Signature calculator 413 may calculate a Signature with normalized length based on foregoing Key, in which the normalized length is less than length of the Key.
  • the Signature matcher 414 may match an entry (e.g., Signature&result) in the indexed hash bucket, based on the Signature.
  • the Signature matcher 414 may match an entry in the multiple hash buckets.
  • the operation executer 415 may execute a corresponding operation, based on a matched result.
  • the operation executer 415 may execute the add operation to the matched entry; otherwise, the operation executer 415 may insert a new entry (e.g., Signature&result) into an idle position of the hash bucket, so as to execute the add operation.
  • a new entry e.g., Signature&result
  • the operation executer 415 may execute the delete operation to the matched entry; otherwise, the operation executer 415 may confirm that the delete operation is failed.
  • the operation executer 415 may execute the search operation to the matched entry; otherwise, the operation executer 415 may confirm that the search operation is failed.
  • foregoing processing device may be modularized as in FIG. 3a and stored in the first memory 23 as in FIG. 1, and then be called and run by CPU 21 in FIG. 1.
  • the processing device respectively illustrated with FIG. 3a and FIG. 3b may further include a Signature length limiter (not shown in the Figures) .
  • the Signature length limiter may set the normalized length of Signature, based on the preset target value of conflict probability, the preset target value of false hit probability, and foregoing two modes.
  • a hash table may be applied in a structure, which may include a CPU 51, a logic chip 52, a first memory 53 and a second memory 54.
  • the CPU 51, the logic chip 52, the first memory 53 and the second memory 54 may be respectively the same as the CPU 21, the logic chip 22, the first memory 23 and the second memory 24 in the example illustrated with FIG. 1.
  • the hash table 50 may be copied to the second memory 54 in hardware layer from the first memory 53 similarly.
  • the hash buckets 500a and 500b in hash table 50 may further include a Signature calculation method selecting field (e.g., sel field) 503.
  • a Signature calculation method selecting field e.g., sel field
  • the first memory 53 may further store the hash table 10.
  • the hash table 10 may include a hash area 10a and a conflict zone 10b.
  • the hash area 10a and conflict zone 10b may respectively possess a hash bucket 100a and a hash bucket 100b.
  • the hash bucket 100a or 100b may include at least one hash entry.
  • Each hash entry may include an original Key used for calculating the Signature, the calculated Signature and a corresponding result. Thus, represent the hash entry in the hash table 10 with Key&Signature&result 101.
  • hash bucket 100a or 100b may further include a pointer 102.
  • the pointer 102 may enable the hash bucket 100a and at least one hash bucket 100b to constitute a hash bucket chained list.
  • the calculation method selecting field (e.g., sel field) 103 in the hash table 10 may indicate a selected method, which is to calculate the Signature based on the Key. Based on the calculation method indicated by sel field 103 in the hash table 10, calculate the Signature based on the Key, and obtain a corresponding result. And then, issue the calculated Signature and result to the second memory 54 to form the hash table 50.
  • the CPU 51 may maintain Key value and Signature value in the hash table 10 of the first memory 53. However, the Key value in the hash table 10 may not be issued to the second memory 54.
  • deletion and search operation executed to the hash table 50, compared with the example shown in FIG. 1, select a corresponding Signature calculating method with sel field 503 of the indexed hash buckets 500a and 500b in the example illustrated with FIG. 4. And then, utilize the selected Signature calculating method to convert Key 521 into Signature 523.
  • the add operation executed to the hash table 50 in the example illustrated with FIG. 4, when there is a matched Signature&result 501 in a hash bucket 500a or 500b pointed to by Hash_idx 522, before executing the add operation to the matched Signature&result 501, firstly utilize the hash table 10 to check whether the matching belongs to conflict. That is, utilize Key value of Key&Signature&result 101 in the hash table 10 to check, whether Signature conflict may occur in the hash buckets 500a and 500b pointed to by Hash_idx 522, which may be resulted from the add operation to be executed.
  • update sel field 503 in all the hash buckets 500a and 500b which may be pointed to by Hash_idx 522.
  • the processing mode when there is no matched Signature&result 501 about add operation, and the processing mode about deletion and search operations may be respectively the same as that in the example illustrated with FIG. 1.
  • the add method of the hash table may be applied to CPU 51 in FIG. 4.
  • the processing method when executing the add operation, may include the following blocks.
  • index a corresponding hash bucket in a hash table based on the calculated Hash_idx.
  • the hash bucket searched out in block S612 may include multiple hash buckets in the hash bucket chained list.
  • Block S613 select a corresponding Signature calculating method, based on the Signature calculation method selecting field in the indexed hash bucket.
  • the Signature calculation method selecting field of each hash bucket in the hash bucket chained list may correspond to a Signature calculation method, which may have the same type ID.
  • block S614 calculate a Signature with the normalized length, based on the Key (same as the Key in block S611) and the selected Signature calculating method.
  • the normalized length is less than length of the Key.
  • block S615 match an entry (e.g., Signature&result) in the indexed hash bucket, based on the Signature.
  • the hash bucket indexed in block S612 includes multiple hash buckets in the hash bucket chained list, match an entry in the multiple hash buckets in block S615.
  • the processing method may be applied to CPU 51 of FIG. 4.
  • the processing method may be applied to logic chip 52 of FIG. 4.
  • the foregoing processing method may include the following blocks.
  • index a corresponding hash bucket by using the calculated Hash_idx.
  • the hash bucket searched out in block S622 may include multiple hash buckets in the hash bucket chained list.
  • Block S623 select a corresponding Signature calculating method, based on a Signature calculation method selecting field in the indexed hash bucket.
  • the Signature calculation method selecting field of each hash bucket in the hash bucket chained list may correspond to a Signature calculating method, which may have the same type ID.
  • block S625 match an entry (e.g., Signature&result) in the indexed hash bucket based on Signature.
  • the hash bucket indexed in block S622 includes multiple hash buckets in the hash bucket chained list, match an entry of the multiple hash buckets in block S625.
  • the CPU 51 may delete the corresponding entry in the hash table 50. Specifically, the CPU 51 may firstly determine whether Signature value of one entry in the hash table 50 is the same as the Signature value to be deleted. If they are different, reserve the entry. If they are the same, delete the entry.
  • FIG. 6a illustrates structure of a device for processing a hash table, which may be applied to the add operation.
  • the device may include modules, which are respectively the same as the address calculator 411, the address indexer 412, the Signature calculator 413, the Signature matcher 414 and the operation executer 415 shown in FIG. 3a.
  • the device may further include a Signature calculation method selector 711, a conflict checker 712, an add enabler 713, a conflict processor 714 and a field maintainer 715.
  • the Signature calculation method selector 711 may select a corresponding Signature calculating method for the Signature calculator 413, based on sel field in the hash bucket indexed by the first address module 412, so as to facilitate the Signature calculator 413 to calculate the Signature, before the Signature calculator 413 calculates Signature with the normalized length based on foregoing Key.
  • the conflict checker 712 may check whether Signature conflict exists for the calculated Signature in the hash bucket pointed to by Hash_idx, before the operation executer 415 executes the add operation to the entry (e.g., Signature&result) matched by the Signature matcher 414.
  • the add enabler 713 may enable the operation executer 415 to execute the add operation to the matched entry, when the conflict checker 712 determines that there is no Signature conflict.
  • the conflict processor 714 may enable the Signature calculator 413 to update the calculated Signature, and Signature value of each entry (e.g., Signature&result) in the hash bucket pointed to by Hash_idx, by changing the Signature calculating method, and may re-trigger the Signature matcher 414 to match an entry.
  • the Signature calculator 413 may update the calculated Signature, and Signature value of each entry (e.g., Signature&result) in the hash bucket pointed to by Hash_idx, by changing the Signature calculating method, and may re-trigger the Signature matcher 414 to match an entry.
  • the field maintainer 715 may update the sel field in a corresponding hash bucket, when changing the Signature calculating method.
  • foregoing device When the add operation is executed by the CPU 51 in the structure shown in FIG. 4, foregoing device may be modularized as shown in FIG. 6a, may be stored in the first memory 53 as shown in FIG. 4, and may be called and run by the CPU 51 in FIG. 4.
  • foregoing device When the add operation is executed by logic chip 52 in the structure illustrated with FIG. 4, foregoing device may be modularized as shown in FIG. 6b, and may be integrated into the logic chip 52 shown in FIG. 4.
  • FIG. 6b illustrates structure of a device for processing a hash table, which may be applied to the delete operation.
  • the device may include modules, which are respectively the same as the address calculator 411, the address indexer 412, the Signature calculator 413, the Signature matcher 414 and the operation executer 415 in FIG. 3a.
  • the device may further include a Signature calculation method selector 711 as shown in FIG. 6a.
  • foregoing device may be modularized as in FIG. 6c, may be stored in the first memory 53 as in FIG. 4, and may be called and run by the CPU 51 in FIG. 4.
  • foregoing device When the delete operation, or the search operation is executed by the logic chip 52 in the structure shown in FIG. 4, foregoing device may be modularized as in FIG. 6d, and may be integrated into the logic chip 52 as in FIG. 4.
  • the device may include foregoing Signature length limiter (not shown in the figure) similarly.
  • a system or device configured with machine readable storage medium may be provided.
  • Such storage medium may store machine readable instruction program codes, which may implement foregoing method, or functions of foregoing device.
  • a processor of the system or device may read, and execute the program codes in the storage medium.
  • the program codes read from the storage medium may implement foregoing method, or functions of foregoing device.
  • the program codes and storage medium storing the program codes may constitute one part of technical solution of foregoing method, or foregoing device.
  • the storage medium example providing program codes may include the first memory shown in FIG. 3a, which may further include a floppy disk, a hard disk, a magneto-optical disk, a compact disk (CD) (such as CD-read-only memory (CD-ROM) , CD-Recordable (CD-R) , CD-rewritable (CD-RW) , digital versatile disc (DVD) -ROM, DVD-random access memory (RAM) , DVD-RW, DVD+RW) , a magnetic tape, a nonvolatile memory card and ROM.
  • CD compact disk
  • CD-ROM compact disk
  • CD-R compact disk
  • CD-RW compact disc
  • DVD digital versatile disc
  • RAM random access memory
  • DVD+RW digital versatile disc
  • the program codes may be downloaded from a server computer through a communication network.
  • program codes being executed by a computer
  • at least part of the operations performed by the program codes may be implemented by an operation system running in a computer following instructions based on the program codes, which may realize a technical scheme of any of the above examples.
  • the program codes read from a storage medium may be written in storage in an extension board inserted in the computer, or in storage in an extension unit connected to the computer.
  • a CPU in the extension board or the extension unit may execute at least part of the operations, according to the instructions based on the program codes, so as to realize above method, or functions of above device.
  • a device for processing a hash table may include a memory 801 (e.g., foregoing memory) , and a processor 802 in connection with the memory 801 through an internal bus 800.
  • the program codes may be read from a storage medium, or downloaded from a communication network, and then may be stored into the memory 801. Subsequently, the processor 802 may read the program codes from the memory 801, and then run the program codes, so as to implement foregoing method or functions of foregoing device.
  • one device for processing a hash table may include a memory 801 and a processor 802.
  • the memory 801 may store program codes.
  • the processor 802 may be in connection with the memory 801 through an internal bus 800, and may read the program codes.
  • the instructions of program codes may be understood as instruction codes of each functional module in foregoing example, such as the address calculator 411, the address indexer 412, the Signature calculator 413, the Signature matcher 414, and the operation executer 415 in the memory 801 shown in FIG. 7.
  • the other modules are not shown.
  • the processor 802 may read instructions to execute the following operations.
  • P (N) may represent the target value of conflict probability.
  • N may represent entry number in the hash table.
  • I may represent value range of the hash address.
  • S may represent value range of the Signature.
  • the processor 802 may read instructions to execute the following operations.
  • MTBF may represent the target value of false hit probability.
  • N may represent entry number in the hash table.
  • I may represent value range of the hash address.
  • S may represent value range of the Signature.
  • Rate may represent the speed accessing the hash table.
  • the processor 802 may read instructions to execute the following operations.
  • the add operation When the corresponding operation is the add operation, if there is a matched entry, execute the add operation to the matched entry; otherwise, insert a new entry with Signature into an idle position of the hash bucket, so as to execute the add operation.
  • the processor 802 may read instructions to execute the following operations.
  • the method may further include the following blocks. Before calculating the Signature with normalized length based on the Key, select a corresponding Signature calculating method for calculating the Signature, based on the Signature calculation method selecting field in the indexed hash bucket.
  • the Key may be replaced with the Signature, and then be inserted to the hash table in foregoing examples. Since length of the Signature is less than that of the Key, when using the hash table in the hardware layer, storage space in the hardware layer occupied by the hash bucket of the hash table may be reduced, so as to implement a hash table with a greater capability without increasing storage space of hardware layer.
  • Signature respectively corresponding to a Key with a different length may possess a uniform normalized length.
  • a uniform processing mechanism may be applicable for different hash tables in the hardware layer.
  • usage of hash table in the hardware layer may be implemented easily.
  • the normalized length of Signature may be limited by the target value of conflict probability, or the target value of false hit probability, so as to meet requirements for conflict probability or false hit probability.
  • Signature conflict within the same hash bucket may be avoided in foregoing examples, by adjusting the Signature calculating method.

Landscapes

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

Abstract

A hash address is calculated based on a key. A corresponding hash bucket is indexed in a hash table, based on the calculated hash address. A signature with a normalized length is calculated based on the key. The normalized length is less than a length of the key. An entry in the indexed hash bucket is matched, based on the signature. A corresponding operation is executed, based on a matched result.

Description

HASH TABLE PROCESSING Background
Hash table is a data structure with higher search performance. Hash table may be accessed with a key value. That is, map a key value to a position of a hash table to access entries, so as to accelerate search speed.
Brief Descriptions of the Drawings
FIG. 1 is a schematic diagram illustrating an application structure of a hash table, in accordance with an example of the present disclosure.
FIG. 2 is a flowchart illustrating a method for processing a hash table, in accordance with an example of the present disclosure.
FIG. 3a is a schematic diagram illustrating structure of a first memory 23 in a hash table processing device, in accordance with an example of the present disclosure.
FIG. 3b is a schematic diagram illustrating structure of a logic chip 22 in a hash table processing device, in accordance with an example of the present disclosure.
FIG. 4 is a schematic diagram illustrating an application structure of a hash table, in accordance with another example of the present disclosure.
FIG. 5a and FIG. 5b are respectively a flowchart illustrating a method for processing a hash table, in accordance with an example of the present disclosure.
FIG. 6a is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
FIG. 6b is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
FIG. 6c is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
FIG. 6d is a schematic diagram illustrating structure of a hash table processing device, in accordance with an example of the present disclosure.
FIG. 7 is a schematic diagram illustrating structure of a hash table  processing device, in accordance with an example of the present disclosure.
Detailed Descriptions
With reference to FIG. 1, in an example, a hash table may be applied to a structure, which may include a central processing unit (CPU) 21, a logic chip 22, a first memory 23 and a second memory 24. The CPU 21 may be a single core processor or a multi-core processor. The logic chip 22 may be a programmable logic device, such as Field-Programmable Gate Array (FPGA) . The first memory 23 and the second memory 24 may be storage mediums, such as double date rate (DDR) synchronous dynamic random access memory (SDRAM) .
The CPU 21 may be connected with the logic chip 22. The first memory 23 may be connected with CPU 21. The second memory 24 may be connected with the logic chip 22. In some examples, the logic chip 22 and connected second memory 24 may be taken as hardware layer. The CPU 21 and connected first memory 23 may be taken as machine readable instruction layer.
In the example illustrated with FIG. 1, the CPU 21 may execute operations, such as add, delete and search, to the hash table 20 in the first memory 23. After executing the add or delete operation to the hash table 20 in the first memory 23, the CPU 21 may copy the hash table 20 to the second memory 24, such that the hash table 20 may be used in the hardware layer. Correspondingly, the logic chip 22 in the hardware layer may execute a search operation to the hash table 20 stored in the second memory 24.
In accordance with conventions of IPv6, IP address length may change from 32 bits of IPv4 to 128 bits. Subsequently, length of Key 221 of a corresponding IP address may also be increased. For a hash table taking flow table as an example, length of a five tuple may be changed from 104 bits of IPv4 to 296 bits of IPv6. Correspondingly, when representing an IP address, the length of Key 221 may be increased significantly. Subsequently, the length of Signature&result 201 may also be increased. Thus, number of Signature&result 201 stored in the second memory 24 with limited storage capacity may be reduced significantly, and usage of a large-size hash table 20 in the hardware layer may be limited.
With reference to FIG. 1, the hash table 20 may include a hash area 20a and a conflict zone 20b. The hash area 20a and conflict zone 20b may respectively possess a hash bucket 200a and a hash bucket 200b. Either of hash bucket 200a and hash bucket 200b may at least include a hash entry. A Signature may be obtained, based on Key and a preset calculation method, such as MD5 (Message Digest Algorithm 5) , CRC (Cyclical Redundancy Check) and SHA-1 (Secure Hash Algorithm) . The Key in each hash entry may be replaced with a Signature, length thereof may be less than that of Key. In some examples, length of Signature may be uniform for Key with a different length. Thus, a hash entry may be represented with Signature&result 201 in the example illustrated with FIG. 1. In FIG. 1, although number of Signature&result 201 (e.g., number of hash entry) in either hash bucket 200a or hash bucket 200b is one, it does not mean that there is one Signature&result 201 (e.g., number of hash entry) in  hash bucket  200a or 200b. It should be understood that, there may be one or more Signature&result 201 (e.g., number of hash entry) in  hash bucket  200a or 200b.
In some examples, the conflict zone 20b may be formed by a linked list in the example illustrated with FIG. 1. Thus, the  hash bucket  200a or 200b may still include a pointer 202. Correspondingly, the pointer 202 in the hash bucket 200a of the hash area 20a may point to the hash bucket 200b in the conflict zone 20b. In some examples, the pointer 202 of the hash bucket 200b in the conflict zone 20b may point to a hash bucket (not shown in FIG. 1) of a next level in the conflict zone 20b. Subsequently, the pointer 202 may enable the hash bucket 200a and at least one hash bucket 200b to constitute a hash bucket linked list.
(1.1) For the add operation to the hash table 20, Hash_idx 222 (hash address or hash index) may be calculated based on Key 221. And then, corresponding  hash buckets  200a and 200b may be indexed in the hash table 20, by using the calculated Hash_idx 222. In some examples, Key 221 may be converted into Signature 223. A Signature&result 201 may be matched with the same Signature value in the indexed hash bucket 200a and the hash bucket 200b, based on Signature 223.
When there is a matched Signature&result 201 in the  hash bucket  200a or 200b pointed to by Hash_idx 222, a result of the matched Signature&result 201 may be replaced with another result corresponding to Key  221, so as to implement the add operation.
When there is no matched Signature&result 201 in all the  hash buckets  200a and 200b pointed to by Hash_idx 222, a new Signature&result 201 may be inserted into an idle position of a  hash bucket  200a or 200b. The new Signature&result 201 may carry the Signature 223 and a result corresponding to Key 221, so as to implement the add operation.
(1.2) For the delete operation to the hash table 20, Hash_idx 222 may be calculated based on Key 221. And then, corresponding  hash buckets  200a and 200b may be indexed in the hash table 20, by using the calculated Hash_idx 222. In some examples, Key 221 may be converted into Signature 223. A Signature&result 201 may be matched with the same Signature value in the indexed  hash buckets  200a and 200b, based on Signature 223.
When there is a matched Signature&result 201 in a  hash bucket  200a or 200b pointed to by Hash_idx 222, the matched Signature&result 201 may be set to be invalid, so as to implement the delete operation.
When there is no matched Signature&result 201 in all the  hash buckets  200a and 200b pointed to by Hash_idx 222, the delete operation may be terminated.
(1.3) For the search operation to the hash table 20, Hash_idx 222 may be calculated based on Key 221. And then, a  corresponding hash bucket  200a or 200b may be indexed in the hash table 20, by using the calculated Hash_idx 222. In some examples, Key 221 may be converted into Signature 223. And a Signature&result 201 may be matched with the same Signature value in the indexed  hash buckets  200a and 200b, based on Signature 223.
When there is a matched Signature&result 201 in a  hash bucket  200a or 200b pointed to by Hash_idx 222, read the result of the matched Signature&result 201, so as to implement the search operation.
When there is no matched Signature&result 201 in all the  hash buckets  200a and 200b pointed to by Hash_idx 222, the search operation may be not successfully completed.
As described herein, it can be seen that since Key of each hash entry has been replaced with Signature, in which length of the Signature is less than that of Key. In the example illustrated with FIG. 1, add, delete and search  operations to hash table 20 may be executed, by replacing Key 221 with Signature 223 of a less length. Thus, length of Signature&result 201 in hash table 20 may be avoided to be increased, accompanying with increasing length of Key 221. Subsequently, storage space occupied by hash table 20 may be avoided to be increased, accompanying with increasing length of Key 221. Thus, storage loads of second memory 24 in hardware layer may be avoided to be increased.
In some examples, as illustrated with FIG. 1, length of Signature 223 may be consistent for Key 221 with a different length. That is, in the example illustrated with FIG. 1, Key 221 with a different length may be converted into Signature 223 with a uniform length. Thus, the process for converting Key 221 into Signature 223 may be taken as a length reducing process, and a length normalization process. Correspondingly, length of Signature 223 may be taken as the normalized length.
At this time, even if there may be multiple hash tables 20 in the example illustrated with FIG. 1, length of Signature 223 of each hash table 20 stored in the second memory 24 may be uniform. Thus, the logic chip 22 in hardware layer may not implement complicated programming, so as to adapt to a different length of Key 221.
In addition, there may be a risk for increasing conflict probability when executing an add operation, and there may be a risk for increasing false hit probability, when replacing Key 221 with Signature 223 of a smaller length. Thus, the normalized length of Signature 223 may be achieved with the following modes in the example illustrated with FIG. 1.
The normalized length of Signature 223 may be limited by utilizing a preset target value of conflict probability.
For example, during the process of adding an entry to hash table 20, when respective Signature 223 of at least two Keys 221 corresponding to the same Hash_idx 222 is the same, it may be considered that foregoing conflict occurs; when respective Signature 223 of at least two Keys 221 corresponding to the same Hash_idx 222 is different, it may be considered that foregoing conflict does not occur.
Correspondingly, probability
Figure PCTCN2016076114-appb-000001
demonstrating that no conflict  occurs may be represented with
Figure PCTCN2016076114-appb-000002
P (N) may represent the target value of conflict probability. N may represent number of Signature&result 201 in hash table 20. I may represent value range of Hash_idx 222. S may represent value range of Signature 223.
The foregoing probability
Figure PCTCN2016076114-appb-000003
demonstrating that no conflict occurs may be reduced gradually, accompanying with increasing number of Signature&result 201 in hash table 20.
When N=1, there may be one Signature&result 201 in hash table 20. 
Figure PCTCN2016076114-appb-000004
That is, the probability demonstrating that no conflict occurs may be 100%.
When N=2, there may be two Signature&result 201 in hash table 20. 
Figure PCTCN2016076114-appb-000005
When N=3, there may be three Signature&result 201 in hash table 20. 
Figure PCTCN2016076114-appb-000006
Subsequently,
Figure PCTCN2016076114-appb-000007
may be represented as follows,
Figure PCTCN2016076114-appb-000008
Correspondingly, the probability demonstrating that the conflict occurs may be
Figure PCTCN2016076114-appb-000009
Suppose N=220, I=220, S=264 (that is, the normalized length of Signature 223 may be 64 bits) , after extracting 40 significant bits, P (N) =0.0000000000005684341615028642778715783961.
In another example, suppose N=220, I=220, S=2128 (that is, the normalized length of Signature 223 may be 128 bits) , after extracting 40 significant bits, P (N) =0.0000000000000000000000000000000308148776.
Thus, it can be seen that there may be limitation relationship between the normalized length of Signature 223 and P (N) . Thus, preset P (N) . And, take the preset P (N) as the target value of conflict probability, so as to limit the  normalized length of Signature 223.
Alternatively, use a preset target value of false hit probability to limit the normalized length of Signature 223.
For example, during the process of executing an add, delete, or search operation to hash table 20, when at least two Keys 221 with different Key values correspond to the same Hash_idx 222 and Signature 223, it may be considered that foregoing false hit probability occurs.
During one add (when there is a matched Signature&result 201) , one delete or one search, the maximum false hit probability which may occur is
Figure PCTCN2016076114-appb-000010
N may represent number of Signature&result 201 in hash table 20. I may represent value range of Hash_idx 222. S may represent value range of Signature 223.
In some examples, when hash table 20 has been accessed with a given rate, meantime between failure (MTBF) between occurrences of false hit probability may be represented with
Figure PCTCN2016076114-appb-000011
In some examples, MTBF may be measured in years.
Suppose S=N, S=264 (that is, the normalized length of Signature 223 may be 64 bits) , when rate is 150 Mpps, MTBF may be 3899 years.
Thus, it can be seen that there may be limitation relationship between normalized length of Signature 223 and MTBF. Thus, preset MTBF. Take the preset MTBF as the target value of false hit probability, so as to limit the normalized length of Signature 223.
In an example, firstly utilize a preset target value of conflict probability to limit the normalized length of Signature 223. For example, when calculating that the normalized length S1 of Signature 223 is 32 bits, based on foregoing first limitation mode, utilize the preset target value of false hit probability to limit the normalized length of Signature 223. For example, when calculating that the normalized length S2 of Signature 223 is 33 bits, based on foregoing second limitation mode, since the calculated normalized length of Signature 223 may meet the preset target value of conflict probability and the preset target value of false hit probability, the normalized length of Signature 223 may be the maximum value of S1 and S2, that is, 33 bits. It should be noted that, S1 and S2 may also be  other values.
Based on foregoing principle of the example illustrated with FIG. 1, a method for processing a hash table and a corresponding device are respectively provided, which will be respectively described in detail in the following.
With reference to FIG. 2, a method for processing a hash table may include the following blocks.
In block S311, calculate Hash_idx based on Key. The Key may be obtained from a packet, and may be used for triggering an add operation, a delete operation or a search operation.
In block S312, utilize the calculated Hash_idx to index a corresponding hash bucket in the hash table. When a hash area and a conflict zone form a hash bucket chained list corresponding to the Hash_idx, the hash bucket searched out in block S312 may include multiple hash buckets in the hash bucket chained list.
In block S313, calculate a Signature with normalized length based on the Key (same as the Key in block S311) , in which the normalized length is less than that of the Key.
In block S314, utilize the Signature to match an entry (e.g., Signature&result) in the indexed hash bucket. When the hash bucket indexed in block S312 includes multiple hash buckets in the hash bucket chained list, match an entry of the multiple hash buckets in block S314.
In block S315, execute a corresponding operation based on a matched result, and then terminate the process.
When the corresponding operation executed in block S315 is the add operation, and the matched result shows that there is a matched entry (e.g., Signature&result) , execute the add operation to the entry matched in block S315. When the matched result shows that there is no matched entry (e.g., Signature&result) , insert a new entry (e.g., Signature&result) with the Signature into an idle position of the hash bucket in block S315, so as to execute the add operation.
When the corresponding operation executed in block S315 is the delete operation, and the matched result shows that there is a matched entry (e.g., Signature&result) , execute the delete operation to the entry matched in block  S315; otherwise, the delete operation in block S315 may be failed.
When the corresponding operation executed in block S315 is the search operation, and the matched result shows that there is a matched entry (e.g., Signature&result) , execute the search operation to the entry (e.g., Signature&result) matched in block S315; otherwise, the search operation in block S315 may be failed.
In the structure illustrated with FIG. 1, the add operation, or delete operation may be executed by CPU 21. In the structure illustrated with FIG. 1, the search operation may be executed by logic chip 22. Correspondingly, when running above-mentioned processing method in CPU 21 of FIG. 1, the operation executed in block S315 may be the add operation, or the delete operation. However, when above-mentioned processing method is executed by a logic array constituted with logic chip 22 in FIG. 1, the operation executed in block S315 may be the search operation.
The foregoing mode may adapt to an application setting, where CPU 21 may maintain the hash table, and copy the hash table to logic chip 22. In a debugging scene, CPU 21 may also execute the search operation. In some examples, in an application scene where logic chip 22 may maintain the hash table, logic chip 22 may also execute the add operation, or delete operation.
In some examples, in the processing method illustrated with FIG. 2, the normalized length of Signature may be set, based on the preset target value of conflict probability and the preset target value of false hit probability, as well as foregoing mode.
Referring now to FIG. 3a and FIG. 3b, a device for processing a hash table may include an address calculator 411, an address indexer 412, a Signature calculator 413, a Signature matcher 414 and an operation executer 415.
The address calculator 411 is to calculate Hash_idx based on Key. The Key may be obtained from a packet, and may be used for triggering an add operation, a delete operation or a search operation.
The address indexer 412 may utilize the calculated Hash_idx to index a corresponding hash bucket in the hash table. When a hash area and a conflict zone form a hash bucket chained list corresponding to the Hash_idx, the hash bucket searched out by the address indexer 412 may include multiple hash  buckets in the hash bucket chained list.
The Signature calculator 413 may calculate a Signature with normalized length based on foregoing Key, in which the normalized length is less than length of the Key.
The Signature matcher 414 may match an entry (e.g., Signature&result) in the indexed hash bucket, based on the Signature. When the hash bucket indexed by the address indexer 412 includes multiple hash buckets in the hash bucket chained list, the Signature matcher 414 may match an entry in the multiple hash buckets.
The operation executer 415 may execute a corresponding operation, based on a matched result.
When the corresponding operation executed by the operation executer 415 is the add operation, and the matched result shows that there is a matched entry (e.g., Signature&result) , the operation executer 415 may execute the add operation to the matched entry; otherwise, the operation executer 415 may insert a new entry (e.g., Signature&result) into an idle position of the hash bucket, so as to execute the add operation.
When the corresponding operation executed by the operation executer 415 is the delete operation, and the matched result shows that there is a matched entry (e.g., Signature&result) , the operation executer 415 may execute the delete operation to the matched entry; otherwise, the operation executer 415 may confirm that the delete operation is failed.
When the corresponding operation executed by the operation executer 415 is the search operation, and the matched result shows that there is a matched entry (e.g., Signature&result) , the operation executer 415 may execute the search operation to the matched entry; otherwise, the operation executer 415 may confirm that the search operation is failed.
When the add operation, delete operation or search operation is executed by CPU 21 in the structure shown in FIG. 1, foregoing processing device may be modularized as in FIG. 3a and stored in the first memory 23 as in FIG. 1, and then be called and run by CPU 21 in FIG. 1.
When the add operation, delete operation or search operation is executed by logic chip 22 in the structure shown in FIG. 1, foregoing processing  device may be modularized as in FIG. 3b, and may be integrated into logic chip 22 as shown in FIG. 1.
In some examples, the processing device respectively illustrated with FIG. 3a and FIG. 3b may further include a Signature length limiter (not shown in the Figures) . The Signature length limiter may set the normalized length of Signature, based on the preset target value of conflict probability, the preset target value of false hit probability, and foregoing two modes.
With reference to FIG. 4, in another example, a hash table may be applied in a structure, which may include a CPU 51, a logic chip 52, a first memory 53 and a second memory 54.
In the example illustrated with FIG. 4, the CPU 51, the logic chip 52, the first memory 53 and the second memory 54 may be respectively the same as the CPU 21, the logic chip 22, the first memory 23 and the second memory 24 in the example illustrated with FIG. 1. In some examples, as illustrated with FIG. 4, the hash table 50 may be copied to the second memory 54 in hardware layer from the first memory 53 similarly.
Compared with the hash table 20 in the example illustrated with FIG. 1, in addition to Signature&result 501 and pointer 502 (which may be respectively the same as Signature&result 201 and pointer 202 in the example illustrated in FIG. 1) in the example illustrated with FIG. 4, the  hash buckets  500a and 500b in hash table 50 may further include a Signature calculation method selecting field (e.g., sel field) 503.
In some examples, in addition to storing the hash table 50, the first memory 53 may further store the hash table 10. The hash table 10 may include a hash area 10a and a conflict zone 10b. The hash area 10a and conflict zone 10b may respectively possess a hash bucket 100a and a hash bucket 100b. The  hash bucket  100a or 100b may include at least one hash entry. Each hash entry may include an original Key used for calculating the Signature, the calculated Signature and a corresponding result. Thus, represent the hash entry in the hash table 10 with Key&Signature&result 101. Although there may be one Key&Signature&result 101 (e.g., number of hash entry) in  hash bucket  100a or 100b, it does not mean that there may be one Key&Signature&result 101 (e.g., number of hash entry) in  hash bucket  100a or 100b. Instead, it may be understood  as follows. There may be one or more Key&Signature&result 101 (e.g., number of hash entry) in  hash bucket  100a or 100b. Although conflict zone 10b in the hash table 10 is formed with chain address method,  hash bucket  100a or 100b may further include a pointer 102. The pointer 102 may enable the hash bucket 100a and at least one hash bucket 100b to constitute a hash bucket chained list.
The calculation method selecting field (e.g., sel field) 103 in the hash table 10 may indicate a selected method, which is to calculate the Signature based on the Key. Based on the calculation method indicated by sel field 103 in the hash table 10, calculate the Signature based on the Key, and obtain a corresponding result. And then, issue the calculated Signature and result to the second memory 54 to form the hash table 50.
The CPU 51 may maintain Key value and Signature value in the hash table 10 of the first memory 53. However, the Key value in the hash table 10 may not be issued to the second memory 54.
For the add, deletion and search operation executed to the hash table 50, compared with the example shown in FIG. 1, select a corresponding Signature calculating method with sel field 503 of the indexed  hash buckets  500a and 500b in the example illustrated with FIG. 4. And then, utilize the selected Signature calculating method to convert Key 521 into Signature 523.
In some examples, for the add operation executed to the hash table 50, in the example illustrated with FIG. 4, when there is a matched Signature&result 501 in a  hash bucket  500a or 500b pointed to by Hash_idx 522, before executing the add operation to the matched Signature&result 501, firstly utilize the hash table 10 to check whether the matching belongs to conflict. That is, utilize Key value of Key&Signature&result 101 in the hash table 10 to check, whether Signature conflict may occur in the  hash buckets  500a and 500b pointed to by Hash_idx 522, which may be resulted from the add operation to be executed.
When there is no Signature conflict, replace a result of the matched Signature&result 501 with another result corresponding to Key 521, so as to execute the add operation. In some examples, record the type of the used Signature calculating method in sel field 503, when calculating the Signature 523.
When there is a Signature conflict, update currently selected Signature calculating method. Update Signature 523, and all the Signature values  in  hash buckets  500a and 500b pointed to by Hash_idx 522 in hash table 50, by using the changed Signature calculating method. And then, re-match the Signature&result 501 in the  hash buckets  500a and 500b, which may be pointed to by Hash_idx 522, by using the updated Signature 523. In some examples, update sel field 503 in all the  hash buckets  500a and 500b, which may be pointed to by Hash_idx 522.
Update all the Signature values in  hash buckets  500a and 500b, by using Key value in Key&Signature&result 101 of the maintained hash table 10.
In the example illustrated with FIG. 4, the processing mode when there is no matched Signature&result 501 about add operation, and the processing mode about deletion and search operations may be respectively the same as that in the example illustrated with FIG. 1.
Based on foregoing contents, it can be seen that in the example illustrated with FIG. 4, in addition to reducing conflict probability and false hit probability with foregoing mode for limiting the normalized length, further reduce the probability for conflict occurrence when executing the add operation, by changing the Signature calculating method.
Based on foregoing principle, a method for processing a hash table and a corresponding device are respectively provided by the example illustrated with FIG. 4, which will be described in detail as follows.
With reference to FIG. 5a, for the add operation, the add method of the hash table may be applied to CPU 51 in FIG. 4. In some examples, when executing the add operation, the processing method may include the following blocks.
In block S611, calculate Hash_idx based on Key.
In block S612, index a corresponding hash bucket in a hash table, based on the calculated Hash_idx. When hash area and conflict zone form a hash bucket chained list corresponding to Hash_idx, the hash bucket searched out in block S612 may include multiple hash buckets in the hash bucket chained list.
In block S613, select a corresponding Signature calculating method, based on the Signature calculation method selecting field in the indexed hash bucket. When multiple hash buckets in the hash bucket chained list are indexed in block S612, the Signature calculation method selecting field of each hash bucket in the hash bucket chained list may correspond to a Signature calculation method,  which may have the same type ID.
In block S614, calculate a Signature with the normalized length, based on the Key (same as the Key in block S611) and the selected Signature calculating method. The normalized length is less than length of the Key.
In block S615, match an entry (e.g., Signature&result) in the indexed hash bucket, based on the Signature. When the hash bucket indexed in block S612 includes multiple hash buckets in the hash bucket chained list, match an entry in the multiple hash buckets in block S615.
In block S616, when there is a matched entry (e.g., Signature&result) , check whether Signature conflict for the calculated Signature exists in the hash bucket, which may be pointed to by Hash_idx. The foregoing check may be implemented, by using a hash table where Key value is a matched element.
In block S617, when there is no Signature conflict, enable to execute the add operation to the matched entry (e.g., Signature&result) . That is, execute the add operation to the matched entry, and then terminate the process.
In block S618, when there is the Signature conflict, update the calculated Signature, and the Signature value of each entry (e.g., Signature&result) in the hash bucket pointed to by Hash_idx, by changing the Signature calculating method, and return to block S615 to re-match an entry.
In block S619, when changing the Signature calculating method, update the Signature calculation method selecting field in the corresponding hash bucket.
In block S620, when there is no matched entry (e.g., Signature&result) , insert a new entry (e.g., Key&Signature&result) into an idle position of the hash bucket, so as to execute the add operation, and then terminate the process.
With reference to FIG. 5b, for the delete operation, the processing method may be applied to CPU 51 of FIG. 4. For the search operation, the processing method may be applied to logic chip 52 of FIG. 4. In some examples, for the delete operation or search operation, the foregoing processing method may include the following blocks.
In block S621, calculate Hash_idx based on Key.
In block S622, index a corresponding hash bucket by using the calculated Hash_idx. When a hash area and a conflict zone form a hash bucket  chained list corresponding to Hash_idx, the hash bucket searched out in block S622 may include multiple hash buckets in the hash bucket chained list.
In block S623, select a corresponding Signature calculating method, based on a Signature calculation method selecting field in the indexed hash bucket. When multiple hash buckets in the hash bucket chained list are indexed in block S622, the Signature calculation method selecting field of each hash bucket in the hash bucket chained list may correspond to a Signature calculating method, which may have the same type ID.
In block S624, calculate Signature with the normalized length, based on the Key (same as the Key in block S621) and selected Signature calculating method. The normalized length may be less than length of the Key.
In block S625, match an entry (e.g., Signature&result) in the indexed hash bucket based on Signature. When the hash bucket indexed in block S622 includes multiple hash buckets in the hash bucket chained list, match an entry of the multiple hash buckets in block S625.
In block S626, when there is a matched entry (e.g., Signature&result) , execute the deletion or search operation to the matched entry, and then terminate the process; otherwise, the search operation or delete operation may be failed, and the process may be terminated.
Specific delete operation will be described in detail in the following. Firstly determine whether Signature value of one entry in the hash table 10 is the same as the Signature value to be deleted. If they are different, determine that the entry will not be deleted. If they are the same, further determine whether Key value in the hash entry Key&Signature&result is the same as the Key value corresponding to the Signature value to be deleted. When determining that the key value in the hash entry Key&Signature&result is different from the key value corresponding to the Signature value to be deleted, confirm that the entry may not be deleted. When determining that the key value in the hash entry Key&Signature&result is the same as the key value corresponding to the Signature value to be deleted, delete the entry in the hash table 10. And the CPU 51 may delete the corresponding entry in the hash table 50. Specifically, the CPU 51 may firstly determine whether Signature value of one entry in the hash table 50 is the same as the Signature value to be deleted. If they are different, reserve the  entry. If they are the same, delete the entry.
In some examples, in the processing method respectively illustrated with FIG. 5a and FIG. 5b, set the normalized length of Signature, based on the preset target value of conflict probability and the preset target value of false hit probability as mentioned above.
FIG. 6a illustrates structure of a device for processing a hash table, which may be applied to the add operation. The device may include modules, which are respectively the same as the address calculator 411, the address indexer 412, the Signature calculator 413, the Signature matcher 414 and the operation executer 415 shown in FIG. 3a. In some examples, the device may further include a Signature calculation method selector 711, a conflict checker 712, an add enabler 713, a conflict processor 714 and a field maintainer 715.
The Signature calculation method selector 711 may select a corresponding Signature calculating method for the Signature calculator 413, based on sel field in the hash bucket indexed by the first address module 412, so as to facilitate the Signature calculator 413 to calculate the Signature, before the Signature calculator 413 calculates Signature with the normalized length based on foregoing Key.
The conflict checker 712 may check whether Signature conflict exists for the calculated Signature in the hash bucket pointed to by Hash_idx, before the operation executer 415 executes the add operation to the entry (e.g., Signature&result) matched by the Signature matcher 414.
The add enabler 713 may enable the operation executer 415 to execute the add operation to the matched entry, when the conflict checker 712 determines that there is no Signature conflict.
The conflict processor 714 may enable the Signature calculator 413 to update the calculated Signature, and Signature value of each entry (e.g., Signature&result) in the hash bucket pointed to by Hash_idx, by changing the Signature calculating method, and may re-trigger the Signature matcher 414 to match an entry.
The field maintainer 715 may update the sel field in a corresponding hash bucket, when changing the Signature calculating method.
When the add operation is executed by the CPU 51 in the structure  shown in FIG. 4, foregoing device may be modularized as shown in FIG. 6a, may be stored in the first memory 53 as shown in FIG. 4, and may be called and run by the CPU 51 in FIG. 4.
When the add operation is executed by logic chip 52 in the structure illustrated with FIG. 4, foregoing device may be modularized as shown in FIG. 6b, and may be integrated into the logic chip 52 shown in FIG. 4.
FIG. 6b illustrates structure of a device for processing a hash table, which may be applied to the delete operation. The device may include modules, which are respectively the same as the address calculator 411, the address indexer 412, the Signature calculator 413, the Signature matcher 414 and the operation executer 415 in FIG. 3a. The device may further include a Signature calculation method selector 711 as shown in FIG. 6a.
When the delete operation, or the search operation is executed by the CPU 51 in the structure illustrated with FIG. 4, foregoing device may be modularized as in FIG. 6c, may be stored in the first memory 53 as in FIG. 4, and may be called and run by the CPU 51 in FIG. 4.
When the delete operation, or the search operation is executed by the logic chip 52 in the structure shown in FIG. 4, foregoing device may be modularized as in FIG. 6d, and may be integrated into the logic chip 52 as in FIG. 4.
In some examples, as respectively illustrated with FIG. 6a-FIG. 6d, the device may include foregoing Signature length limiter (not shown in the figure) similarly.
Based on understanding of foregoing examples, the technical solution of foregoing examples may be demonstrated with hardware form, or machine readable instruction product form.
Specifically, when foregoing technical solution is demonstrated with machine readable instruction product, a system or device configured with machine readable storage medium may be provided. Such storage medium may store machine readable instruction program codes, which may implement foregoing method, or functions of foregoing device. In some examples, a processor of the system or device may read, and execute the program codes in the storage medium.
In this case, the program codes read from the storage medium may  implement foregoing method, or functions of foregoing device. Thus, the program codes and storage medium storing the program codes may constitute one part of technical solution of foregoing method, or foregoing device.
The storage medium example providing program codes may include the first memory shown in FIG. 3a, which may further include a floppy disk, a hard disk, a magneto-optical disk, a compact disk (CD) (such as CD-read-only memory (CD-ROM) , CD-Recordable (CD-R) , CD-rewritable (CD-RW) , digital versatile disc (DVD) -ROM, DVD-random access memory (RAM) , DVD-RW, DVD+RW) , a magnetic tape, a nonvolatile memory card and ROM. The program codes may be downloaded from a server computer through a communication network.
It should be noted that, alternatively to the program codes being executed by a computer, at least part of the operations performed by the program codes may be implemented by an operation system running in a computer following instructions based on the program codes, which may realize a technical scheme of any of the above examples.
In addition, the program codes read from a storage medium may be written in storage in an extension board inserted in the computer, or in storage in an extension unit connected to the computer. In this example, a CPU in the extension board or the extension unit may execute at least part of the operations, according to the instructions based on the program codes, so as to realize above method, or functions of above device.
For example, with reference to FIG. 7, a device for processing a hash table may include a memory 801 (e.g., foregoing memory) , and a processor 802 in connection with the memory 801 through an internal bus 800. In some examples, the program codes may be read from a storage medium, or downloaded from a communication network, and then may be stored into the memory 801. Subsequently, the processor 802 may read the program codes from the memory 801, and then run the program codes, so as to implement foregoing method or functions of foregoing device. Thus, it can be considered that one device for processing a hash table may include a memory 801 and a processor 802. The memory 801 may store program codes. The processor 802 may be in connection with the memory 801 through an internal bus 800, and may read the program codes.
When running instructions of the program codes by the processor 802, the following operations may be executed.
Calculate a hash address based on Key.
Index a corresponding hash bucket, based on the calculated hash address.
Calculate a Signature with normalized length based on the Key, in which the normalized length may be less than length of the Key.
Match an entry in the indexed hash bucket, based on the calculated Signature.
Execute a corresponding operation based on a matched result.
The instructions of program codes may be understood as instruction codes of each functional module in foregoing example, such as the address calculator 411, the address indexer 412, the Signature calculator 413, the Signature matcher 414, and the operation executer 415 in the memory 801 shown in FIG. 7. The other modules are not shown.
In an example, furthermore, the processor 802 may read instructions to execute the following operations.
Set the normalized length based on a preset target value of conflict probability, such that the normalized length may meet the following condition:
Figure PCTCN2016076114-appb-000012
P (N) may represent the target value of conflict probability. N may represent entry number in the hash table. I may represent value range of the hash address. S may represent value range of the Signature.
In an example, furthermore, the processor 802 may read instructions to execute the following operations.
Set the normalized length based on a preset target value of false hit probability, such that the normalized length may meet the following condition:
Figure PCTCN2016076114-appb-000013
MTBF may represent the target value of false hit probability. N may represent entry number in the hash table. I may represent value range of the hash  address. S may represent value range of the Signature. Rate may represent the speed accessing the hash table.
In an example, furthermore, the processor 802 may read instructions to execute the following operations.
When the corresponding operation is the add operation, if there is a matched entry, execute the add operation to the matched entry; otherwise, insert a new entry with Signature into an idle position of the hash bucket, so as to execute the add operation.
Before calculating the Signature with normalized length based on the Key, select a corresponding Signature calculating method for calculating the Signature, based on the Signature calculation method selecting field in the indexed hash bucket.
Before executing the add operation to the matched entry, check whether Signature conflict exists for the calculated Signature in the hash bucket, which may be pointed to by the hash address.
When there is no Signature conflict, enable to execute the add operation to the matched entry.
When there is Signature conflict, update the calculated Signature, and update Signature of each entry in the hash bucket pointed to by the hash address, by changing the Signature calculating method. And re-trigger to match an entry.
When changing the Signature calculating method, update the Signature calculation method selecting field in the corresponding hash bucket.
In an example, furthermore, the processor 802 may read instructions to execute the following operations.
When the corresponding operation is the search operation or delete operation, the method may further include the following blocks. Before calculating the Signature with normalized length based on the Key, select a corresponding Signature calculating method for calculating the Signature, based on the Signature calculation method selecting field in the indexed hash bucket.
Based on foregoing contents, it can be seen that the Key may be replaced with the Signature, and then be inserted to the hash table in foregoing examples. Since length of the Signature is less than that of the Key, when using the hash table in the hardware layer, storage space in the hardware layer  occupied by the hash bucket of the hash table may be reduced, so as to implement a hash table with a greater capability without increasing storage space of hardware layer. In some examples, Signature respectively corresponding to a Key with a different length may possess a uniform normalized length. Thus, when using a hash table in the hardware layer, a uniform processing mechanism may be applicable for different hash tables in the hardware layer. Thus, usage of hash table in the hardware layer may be implemented easily.
In some examples, in foregoing examples, the normalized length of Signature may be limited by the target value of conflict probability, or the target value of false hit probability, so as to meet requirements for conflict probability or false hit probability. In some examples, Signature conflict within the same hash bucket may be avoided in foregoing examples, by adjusting the Signature calculating method.

Claims (15)

  1. A method for processing a hash table, comprising:
    calculating a hash address based on a key;
    indexing a corresponding hash bucket in the hash table, based on the calculated hash address;
    calculating a signature with a normalized length based on the key, wherein the normalized length is less than a length of the key;
    matching an entry in the indexed hash bucket, based on the signature; and,
    executing a corresponding operation based on the matched result.
  2. The method according to claim 1, further comprising:
    setting the normalized length based on a preset target value of conflict probability.
  3. The method according to claim 1, further comprising:
    setting the normalized length based on a preset target value of false hit probability.
  4. The method according to claim 1, wherein the hash table further comprises a signature calculation method selecting field, and the method further comprises:
    prior to calculating the signature with the normalized length based on the key, selecting a corresponding signature calculating method for calculating the signature, based on the signature calculation method selecting field in the indexed hash bucket.
  5. The method according to claim 4, further comprising:
    when the corresponding operation is an add operation, if there is a matched entry, executing the add operation to the matched entry; if there is no matched entry, inserting a new entry with the signature into an idle position of the hash bucket to execute the add operation;
    before executing the add operation to the matched entry, checking whether there is a signature conflict for the calculated signature in the hash bucket, which is pointed to by the hash address;
    when there is no signature conflict, enabling to execute the add operation to the matched entry;
    when there is the signature conflict, updating the calculated signature, and updating the signature of each entry in the hash bucket pointed to by the hash address, by changing the signature calculating method, re-triggering to match the entry; and,
    when changing the signature calculating method, updating the signature calculation method selecting field in the corresponding hash bucket.
  6. The method according to claim 1, further comprising:
    when the corresponding operation is an add operation, if there is a matched entry, executing the add operation to the matched entry; if there is no matched entry, inserting a new entry with the signature into an idle position of the hash bucket to execute the add operation.
  7. A device for processing a hash table, at least comprising a processor and a memory, wherein
    the memory is to store computer instructions executable by the processor, when being executed by the processor, the computer instructions indicate to:
    calculate a hash address based on a key;
    index a corresponding hash bucket in the hash table, based on the calculated hash address;
    calculate a signature with a normalized length based on the key, wherein the normalized length is less than a length of the key;
    match an entry in the hash bucket based on the signature; and,
    execute a corresponding operation based on a matched result.
  8. The device according to claim 7, wherein when being executed by the processor, the computer instructions further indicate to:
    set the normalized length based on a preset target value of conflict probability.
  9. The device according to claim 7, wherein when being executed by the processor, the computer instructions further indicate to:
    set the normalized length based on a preset target value of false hit probability.
  10. The device according to claim 7, wherein the hash table further comprises a signature calculation method selecting field, when being executed by the processor, the computer instructions further indicate to:
    select a corresponding signature calculating method for calculating the signature, based on a signature calculation method selecting field in the indexed hash bucket, before calculating the signature with the normalized length based on the key.
  11. The device according to claim 10, wherein when being executed by the processor, the computer instructions further indicate to:
    when the corresponding operation is an add operation, if there is a matched entry, execute the add operation to the matched entry; if there is no matched entry, insert a new entry with the signature into an idle position of the hash bucket, so as to execute the add operation;
    check whether a signature conflict exists for the calculated signature in the hash bucket, which is pointed to by the hash address, before executing the add operation to the matched entry;
    when there is no signature conflict, enable to execute the add operation to the matched entry;
    when there is the signature conflict, update the calculated signature, and update the signature of each entry in the hash bucket pointed to by the hash address, by changing the signature calculating method, and re-trigger to match the entry;
    when changing the signature calculating method, update the signature calculation method selecting field in the corresponding hash bucket.
  12. The device according to claim 7, wherein when being executed by the processor, the computer instructions further indicate to:
    when the corresponding operation is an add operation, if there is a matched entry, execute the add operation to the matched entry; if there is no matched entry, insert a new entry with the signature into an idle position of the hash bucket to execute the add operation.
  13. A computer readable storage medium for processing a hash table, wherein the computer readable storage medium stores instruction codes, which indicate to:
    calculate a hash address based on a key;
    index a corresponding hash bucket in the hash table, based on the calculated hash address;
    calculate a signature with a normalized length based on the key, wherein the normalized length is less than a length of the key;
    match an entry in the indexed hash bucket, based on the signature; and,
    execute a corresponding operation based on a matched result.
  14. The computer readable storage medium according to claim 13, wherein the hash table further comprises a signature calculation method selecting field, and the instruction codes further indicate to:
    before calculating the signature with the normalized length based on the key, select a corresponding signature calculating method for calculating the signature, based on the signature calculation method selecting field in the indexed hash bucket.
  15. The computer readable storage medium according to claim 13, wherein the instruction codes further indicate to:
    when the corresponding operation is an add operation, if there is a matched entry, execute the add operation to the matched entry; if there is no matched entry, insert a new entry with the signature into an idle position of the hash bucket, so as to execute the add operation.
PCT/CN2016/076114 2015-03-11 2016-03-11 Hash table processing Ceased WO2016141887A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510105315.7A CN106033420A (en) 2015-03-11 2015-03-11 A Hash table processing method and device
CN201510105315.7 2015-03-11

Publications (1)

Publication Number Publication Date
WO2016141887A1 true WO2016141887A1 (en) 2016-09-15

Family

ID=56878928

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/076114 Ceased WO2016141887A1 (en) 2015-03-11 2016-03-11 Hash table processing

Country Status (2)

Country Link
CN (1) CN106033420A (en)
WO (1) WO2016141887A1 (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10496543B2 (en) * 2016-03-31 2019-12-03 Samsung Electronics Co., Ltd. Virtual bucket multiple hash tables for efficient memory in-line deduplication application
CN106411654A (en) * 2016-10-27 2017-02-15 任子行网络技术股份有限公司 Method and device for processing network traffic analysis
US11010300B2 (en) * 2017-05-04 2021-05-18 Hewlett Packard Enterprise Development Lp Optimized record lookups
CN107515901B (en) * 2017-07-24 2020-12-04 中国科学院信息工程研究所 A chain log storage structure and its hash index structure, data operation method, server and medium
CN109947762A (en) * 2017-08-16 2019-06-28 深圳市中兴微电子技术有限公司 Hash table management method and device, and computer-readable storage medium
CN108052582A (en) * 2017-12-08 2018-05-18 锐捷网络股份有限公司 A kind of method and apparatus for accessing database
CN110413215B (en) * 2018-04-28 2023-11-07 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for obtaining access rights
CN109977116B (en) * 2019-03-14 2023-04-21 超越科技股份有限公司 FPGA-DDR-based hash connection operator acceleration method and system
CN111177476B (en) * 2019-12-05 2023-08-18 北京百度网讯科技有限公司 Data query method, device, electronic device and readable storage medium
CN111309772A (en) * 2020-03-23 2020-06-19 优刻得科技股份有限公司 Data operation management method and hardware processing module
CN112988754B (en) * 2021-04-08 2023-07-14 中煤科工集团重庆研究院有限公司 A Fast Query Method Oriented to Data Integration
CN120234329B (en) * 2025-05-29 2025-09-16 神州灵云(北京)科技有限公司 Business object deserialization index alignment method, computer device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080033942A1 (en) * 2006-08-01 2008-02-07 Jung-Hong Kao Substring search algorithm optimized for hardware acceleration
CN101345694A (en) * 2007-07-11 2009-01-14 上海未来宽带技术及应用工程研究中心有限公司 Method for fast searching, positioning and matching access control list
CN102546299A (en) * 2012-01-09 2012-07-04 北京锐安科技有限公司 Method for detecting deep packet under large flow
US20120330965A1 (en) * 2010-01-26 2012-12-27 Huawei Technologies Co., Ltd. Method and apparatus for storing and searching for keyword

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100410949C (en) * 2006-09-20 2008-08-13 华为技术有限公司 Database system and method for managing database data
CN100470550C (en) * 2007-04-02 2009-03-18 华为技术有限公司 A method for storing information, a method for searching for information, and an engine device
CN101651628A (en) * 2009-09-17 2010-02-17 杭州华三通信技术有限公司 Implementation method of three-state content addressable memory and device
CN102591792B (en) * 2012-01-13 2015-04-29 从兴技术有限公司 Storage method for memory data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080033942A1 (en) * 2006-08-01 2008-02-07 Jung-Hong Kao Substring search algorithm optimized for hardware acceleration
CN101345694A (en) * 2007-07-11 2009-01-14 上海未来宽带技术及应用工程研究中心有限公司 Method for fast searching, positioning and matching access control list
US20120330965A1 (en) * 2010-01-26 2012-12-27 Huawei Technologies Co., Ltd. Method and apparatus for storing and searching for keyword
CN102546299A (en) * 2012-01-09 2012-07-04 北京锐安科技有限公司 Method for detecting deep packet under large flow

Also Published As

Publication number Publication date
CN106033420A (en) 2016-10-19

Similar Documents

Publication Publication Date Title
EP3561674B1 (en) Method and apparatus for verifying block data in a blockchain
CN102467408B (en) Method and device for accessing data of virtual machine
US20180113767A1 (en) Systems and methods for data backup using data binning and deduplication
WO2020143317A1 (en) Fragmented file verification method and terminal device
CN109033360B (en) Data query method, device, server and storage medium
CN107704202B (en) A method and device for fast reading and writing of data
US10983909B2 (en) Trading off cache space and write amplification for Bε-trees
CN105468642A (en) Data storage method and apparatus
US10515228B2 (en) Commit and rollback of data streams provided by partially trusted entities
US20210073410A1 (en) Secure dataset management
US10503605B2 (en) Method of detecting source change for file level incremental backup
KR102646619B1 (en) Method and system providing file system for an electronic device comprising a composite memory device
US10664460B2 (en) Index B-tree maintenance for linear sequential insertion
CN106033420A (en) A Hash table processing method and device
CN102890675A (en) Method and device for storing and finding data
US20170083537A1 (en) Mapping logical identifiers using multiple identifier spaces
CN109460406A (en) Data processing method and device
Tao et al. LHF: A new archive based approach to accelerate massive small files access performance in HDFS
CN110019468A (en) A kind of Database Systems and data bank access method
CN107423321B (en) Method and device suitable for cloud storage of large-batch small files
EP4621593A1 (en) Data storage methods and apparatuses for graph database
US10146791B2 (en) Open file rebalance
US12253974B2 (en) Metadata processing method and apparatus, and a computer-readable storage medium
US11354270B2 (en) Searching for a hash string stored in an indexed array
US11914587B2 (en) Systems and methods for key-based indexing in storage devices

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

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

Country of ref document: EP

Kind code of ref document: A1