Hash processing method, device, equipment and computer-readable storage medium
By installing a variety of computing units in the hash computing device and selecting the target computing unit according to the computing instructions, the problem of poor flexibility of existing hash hardware is solved and efficient hash computing adapted to different application scenarios is achieved.
Patent Information
- Application Number
- CN202311764357.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-12-20
AI Technical Summary
Existing hash computing hardware fails when application scenarios change, has poor flexibility, and is difficult to meet different application needs.
A hash processing method and device are provided. By installing at least two types of computing units in the hash computing device, and selecting matching target computing units for hash processing according to the computing instructions, flexible adaptation to different application scenarios is achieved.
The flexibility and performance of hash operations are improved, and appropriate computing units can be selected for calculation according to different application requirements to meet the computing needs of various scenarios.
Smart Images

Figure CN117807082B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a hash processing method, device, equipment and computer-readable storage medium. Background Art
[0002] Key-Value database is a typical non-relational database. The database is implemented as a hash table, and a key requirement of the hash table is hash operation.
[0003] In the prior art, dedicated hardware is generally used to implement hash operations. The main approach is to customize or optimize the hash algorithm according to the specific application scenario, and then design it into dedicated hardware to achieve the purpose of large-bandwidth, high-speed hash operations.
[0004] However, once the application scenario or application requirements change significantly, the dedicated hardware will lose its effectiveness. Therefore, the current dedicated hardware designed for specific scenarios has the problem of poor flexibility. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a hash processing method, device, equipment and computer-readable storage medium.
[0006] In a first aspect, an embodiment of the present disclosure provides a hash processing method, including:
[0007] Obtaining an operation instruction and input data; based on the operation instruction, selecting a target operation unit that matches the operation instruction from the at least two operation units; and performing hash processing on the input data based on the target operation unit to obtain a target hash value.
[0008] In a second aspect, an embodiment of the present disclosure provides a hash operation device, including:
[0009] An acquisition module, used for acquiring operation instructions and input data;
[0010] A selection module, configured to select, based on the operation instruction, a target operation unit that matches the operation instruction from the at least two operation units;
[0011] A processing module is used to perform hash processing on the input data based on the target operation unit to obtain a target hash value.
[0012] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0013] Memory;
[0014] Processor; and
[0015] Computer programs;
[0016] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.
[0018] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the method described in the first aspect is implemented.
[0019] The hash processing method, device, equipment and computer-readable storage medium provided by the embodiments of the present disclosure are applicable to a hash operation device. By installing at least two operation units in the hash operation device, after obtaining the operation instruction and input data, based on the operation instruction, a target operation unit matching the operation instruction is selected from at least two operation units, and the input data is hashed based on the target operation unit to obtain a target hash value. The hash operation device can select a corresponding operation unit for calculation according to different operation requirements, thereby meeting the operation requirements of different application scenarios while taking into account the performance of hash calculation, and has high application flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0022] Figure 1 A flow chart of a hash processing method provided by an embodiment of the present disclosure;
[0023] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0024] Figure 3 A flowchart of a method for calculating a hash value provided by another embodiment of the present disclosure;
[0025] Figure 4A schematic diagram of another application scenario provided for an embodiment of the present disclosure;
[0026] Figure 5 A schematic diagram of the structure of a hash operation device provided in an embodiment of the present disclosure;
[0027] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0029] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0030] Figure 1 A flow chart of a hash processing method provided for an embodiment of the present disclosure. The hash processing method is applicable to a hash operation device, in which at least two types of operation units are mounted, and different types of operation units in the hash operation device may have different operation capabilities or operation functions. For example, in some embodiments, the operation units mounted in the embodiment of the present disclosure may include: at least two of an addition operation unit, a subtraction operation unit, a shift operation unit, and at least one custom operation unit. Among them, the addition operation unit can be used to perform addition operations, the subtraction operation unit can be used to perform subtraction operations, the shift operation unit can be used to perform shift operations, and the custom operation unit can be used to perform custom operations. It should be noted that the number of any type of operation unit mounted on the hash operation device referred to in the embodiment of the present disclosure can be one or more, and the embodiment of the present disclosure does not limit it.
[0031] See also Figure 1 The hash processing method provided in the embodiment of the present disclosure can be executed by the above-mentioned hash operation device, and the hash operation device can be configured in an electronic device, such as a server or a terminal.
[0032] like Figure 1 As shown, the hash processing method provided by the embodiment of the present disclosure may include the following steps:
[0033] S101, obtaining operation instructions and input data.
[0034] Specifically, the operation instruction referred to in the embodiment of the present disclosure is used to indicate the operation performed on the input data, as well as the execution order of each operation, etc. The language and format used by the operation instruction can be set as needed. For example, in a feasible implementation, the operation instruction referred to in the embodiment of the present disclosure can be exemplarily represented by a 32-bit binary number.
[0035] Specifically, Figure 2 A schematic diagram of an application scenario provided for an embodiment of the present disclosure.
[0036] Specifically, Figure 2 The preset cache 21 refers to a cache area in an electronic device for storing operation instructions, such as a random access memory (RAM), etc. The hash operation device 22 is provided with at least two operation units for controlling the corresponding operation units to perform operations according to the operation instructions.
[0037] Optionally, the operation instructions referred to in the embodiment of the present disclosure can be obtained from the preset cache 21, for example, they can be read from the cache 21 through a preset request message or a data transmission protocol. In the embodiment of the present disclosure, the operation instructions in the preset cache 21 can be downloaded from a preset instruction editing platform, and the user can edit and set the hash operation through the instruction editing platform to generate operation instructions that meet the operation requirements of specific application scenarios. After obtaining the operation instructions edited by the user, the instruction editing platform can send the cloud instructions to the cache 21 for storage through a preset message, or notify the cache 21 of the operation instruction update, so that the cache 21 downloads the operation instructions from the instruction editing platform.
[0038] like Figure 2 As shown, the operation instructions are in the preset cache 21 and can be stored as an array in an array table in the cache 21 .
[0039] Specifically, the instruction editing platform can generate multiple operation instructions according to the application scenario or application requirements of the hash operation, and select key value test data corresponding to the application scenario or application requirements. Based on the test data and multiple operation instructions, simulate the hash operation to obtain the operation results corresponding to the multiple operation instructions. According to the operation results, the discreteness of the multiple operation instructions is calculated. According to the discreteness, the operation instruction is selected and downloaded to the cache 21.
[0040] Optionally, selecting the operation instruction according to the discreteness may be selecting the operation instruction with the largest discreteness among the operation instructions, or may be setting a discreteness threshold and randomly selecting an operation instruction from the operation instructions with a discreteness greater than the discreteness threshold.
[0041] The hash operation device obtains input data, which can be a set of binary data of any length.
[0042] The input data in the embodiments of the present disclosure refers to the input data associated with the acquired operation instruction, that is, the operation object of the acquired operation instruction, or the operation object specified by the operation instruction. For example, in an exemplary implementation, the input data referred to in the embodiments of the present disclosure can be understood as a key value that has been converted into binary in a key-value database. The key value can be a set of strings of arbitrary length. In a key-value database, the role of the key value is the address of the data stored in the database, and the key value can be automatically generated by the database or specified by the user.
[0043] In the embodiment of the present disclosure, the input data can be obtained from a preset data interface.
[0044] S102: Based on the operation instruction, select a target operation unit that matches the operation instruction from at least two types of operation units.
[0045] In one embodiment, the operation unit carried by the hash operation device may include: at least two of an addition operation unit, a subtraction operation unit, a shift operation unit, and at least one custom operation unit. It is understandable that the number of any one operation unit carried by the hash operation device referred to in the embodiment of the present disclosure may be one or more, and the embodiment of the present disclosure does not limit this.
[0046] The addition unit refers to an operation circuit that can perform addition operation on input data.
[0047] A subtraction unit refers to an operation circuit that can perform subtraction operations on input data.
[0048] The shift operation unit refers to an operation circuit structure that can perform shift operations on input data, wherein the shift operation includes left shift and right shift. Left shift refers to shifting all the digits of the input data to the left by the corresponding number of bits, moving the high bits out (discarding), and filling the low-order vacant bits with 0. Right shift refers to shifting all the digits of the input data to the right by the corresponding number of bits, moving the low bits out (discarding), and filling the high-order vacant bits with the sign bit, that is, filling positive numbers with 0 and negative numbers with 1.
[0049] A custom arithmetic unit refers to a logic operation circuit that is customized according to computing requirements.
[0050] Specifically, in the embodiment of the present disclosure, according to the operation processing or operation unit specified in the operation instruction, a corresponding operation unit is searched for in at least two operation units as the target operation unit.
[0051] S103 . Perform hash processing on the input data based on the target operation unit to obtain a target hash value.
[0052] Specifically, each target operation unit will perform arithmetic operations or logical operations on the input data as indicated by the target operation unit. When processing the input data, some processing only requires processing the input data, for example, when performing non-processing in a logical operation, only the input data needs to be processed; some processing requires the input data and the preset initial data to be processed together, for example, when performing a subtraction operation, the input data is used as the minuend, and the preset initial data is used as the subtrahend for operation. The preset initial data can be set as needed, for example, in one example it can be a 16-byte binary data, for example (for the convenience of display, the initial data is displayed in hexadecimal form) 0123456789ABCDEFFEDCBA9876 543210, etc. After the target operation unit completes the processing, the hash operation device outputs the processing result of the input data, that is, the target hash value.
[0053] The disclosed embodiment is applicable to a hash operation device, which is equipped with at least two operation units. After obtaining the operation instruction and input data, based on the operation instruction, a target operation unit matching the operation instruction is selected from at least two operation units, and the input data is hashed based on the target operation unit to obtain a target hash value. The hash operation device can select a corresponding operation unit for calculation according to different operation requirements, thereby meeting the operation requirements of different application scenarios while taking into account the performance of hash calculation, and has high application flexibility.
[0054] For example, in some embodiments, the user wishes to store the data to be stored in the user table of the database offload engine (Database Offload Engine, referred to as DOE). At this time, a key value needs to be set first, which can be automatically generated by DOE or specified by the user. After converting the key value into binary data, the input data is obtained. The user sets the corresponding operation logic through the instruction editing platform, and the instruction editing platform automatically generates operation instructions according to the operation logic, and sends them to the preset cache. The hash operation device obtains the operation instruction from the preset cache, and controls the opening or closing of multiple operation units carried by itself according to the operation unit involved in the operation logic carried in the operation instruction. For example, when the operation logic involves addition and shift operations, the addition operation unit and the shift operation unit are controlled to be turned on, and other operation units are turned off. The input data is processed by the addition operation unit and the shift operation unit to obtain the corresponding target hash value. The quotient of the target hash value divided by the number of entries in the user table is confirmed as the address of the data to be stored in the user table. According to the address, the data to be stored is stored. The number of table entries of the user table refers to the result of multiplying the number of columns of the user table by the number of rows. Generally speaking, the user table in DOE has only one column, so the number of rows of the user table can be used as the number of table entries.
[0055] Figure 3 This is a flow chart of a method for calculating a hash value provided by another embodiment of the present disclosure. The method for calculating a hash value is also applicable to the hash operation device referred to in the above embodiment.
[0056] like Figure 3 As shown, in some embodiments of the present disclosure, the method for calculating the hash value may include the following steps:
[0057] S301, dividing input data into multiple data blocks.
[0058] S302, processing the data blocks in sequence based on the target operation unit.
[0059] S303: Using the processing result of the target operation unit on the previous data block as the input of the target operation unit for processing the next data block, until the processing of multiple data blocks is completed to obtain the target hash value.
[0060] For example, in one implementation of the present disclosure, the input data can be exemplarily divided into multiple data blocks of a preset length. The preset length can be greater than the length of the input data or less than the length of the input data. For ease of understanding, the present embodiment is exemplarily understood as the preset length being less than the length of the input data.
[0061] Optionally, before processing a data block based on the target operation unit, determine whether the data block is the first data block to be processed of the input data corresponding to the data block. If the data block is the first data block to be processed of the input data corresponding to the data block, use the preset initial data and the data block to process it based on the target operation unit. If the data block is not the first data block to be processed of the input data corresponding to the data block, use the processing result of the previous data block and process it together with the data block.
[0062] After processing the data block based on the target operation unit, determine whether the data block is the last data block processed of the input data corresponding to the data block. If the data block is the last data block processed of the input data corresponding to the data block, determine the processing result of the data block as the target hash value. If the data block is not the last data block processed of the input data corresponding to the data block, process the processing result of the data block together with the next data block.
[0063] The disclosed embodiment divides the input data into multiple data blocks, processes the data blocks in sequence based on the target operation unit, and uses the processing result of the target operation unit on the previous data block as the input of the target operation unit for processing the next data block, until the processing of multiple data blocks is completed, and a target hash value is obtained, thereby realizing continuous iterative operations on the input data, thereby increasing the complexity of the hash operation, improving the randomness effect of the hash operation, and enhancing the avalanche effect of the hash operation.
[0064] For example, Figure 4 A schematic diagram of another application scenario provided for an embodiment of the present disclosure.
[0065] like Figure 4 As shown, the hash operation device 41 includes a plurality of operation units and a selection unit.
[0066] The hash operation device 41 obtains the operation instruction and the input data, divides the input data into n (n is a positive integer) data blocks of a preset length, and generates a hash function in the operation unit ( Figure 4 The addition unit, the shift unit and the custom unit are shown in the example, but in practice they are not limited to Figure 4 The target operation unit is confirmed among the operation units shown in the figure, and the input switch of the corresponding target operation unit is opened through the selection unit 411. After the target operation unit completes the processing, if there are still data blocks to be processed, the selection unit 412 selects to return the processing result of the data block to the selection unit 411, and performs iterative operation with the next data block. If there are no data blocks to be processed, the selection unit 412 outputs the processing result of the target operation unit as the target hash value.
[0067] Figure 5 The schematic diagram of the structure of the hash operation device provided in the embodiment of the present disclosure. The hash operation device can be understood as the terminal device in the above embodiment, or the hash operation device can also be understood as a component or assembly in the above terminal device. The hash operation device provided in the embodiment of the present disclosure can execute the processing flow provided in the hash processing method embodiment, such as Figure 5 As shown, the hash operation device 500 includes:
[0068] An acquisition module 510 is used to acquire operation instructions and input data;
[0069] A selection module 520, configured to select a target operation unit matching the operation instruction from at least two types of operation units based on the operation instruction;
[0070] The processing module 530 is used to perform hash processing on the input data based on the target operation unit to obtain a target hash value.
[0071] Optionally, the acquisition module 510 includes a first acquisition unit;
[0072] The first acquisition unit is used to acquire operation instructions from a preset cache, where the operation instructions in the cache are downloaded from a preset instruction editing platform.
[0073] Optionally, the processing module 530 includes a segmentation unit, a first processing unit, and a second processing unit;
[0074] The segmentation unit is used to segment the input data into multiple data blocks;
[0075] The first processing unit is used to process the data blocks in sequence based on the target operation unit, and use the processing result of the target operation unit on the previous data block as the input of the target operation unit to process the next data block, until the target hash value is obtained after completing the processing of multiple data blocks.
[0076] Figure 5 The hash operation device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0077] Figure 6 The electronic device provided by the embodiment of the present disclosure may be a terminal as described in the above embodiment. The electronic device provided by the embodiment of the present disclosure may execute the processing flow provided by the kernel upgrade method embodiment, such as Figure 6 As shown, the electronic device 60 includes: a memory 61, a processor 62, a computer program and a communication interface 63; wherein the computer program is stored in the memory 61 and is configured so that the processor 62 executes the hash processing method as described above.
[0078] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the hash processing method described in the above embodiment.
[0079] In addition, an embodiment of the present disclosure also provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the hash processing method described above is implemented.
[0080] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0081] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A hash processing method, characterized in that: The method is applicable to a hash operation device, wherein the device is equipped with at least two operation units, and the method comprises: Obtain operation instructions and input data; Based on the operation instruction, selecting a target operation unit that matches the operation instruction from the at least two operation units; Performing hash processing on the input data based on the target computing unit to obtain a target hash value; The acquisition operation instruction comprises: Obtain operation instructions from a preset cache, wherein the operation instructions in the cache are downloaded from a preset instruction editing platform, wherein before downloading the operation instructions from the preset instruction editing platform, the steps include: the instruction editing platform generates multiple operation instructions according to application scenarios or application requirements of hash operations, and selects test data corresponding to the application scenarios or application requirements; performs simulated hash operations based on the test data and the multiple operation instructions to obtain operation results corresponding to the multiple operation instructions; calculates the discreteness of the multiple operation instructions according to the operation results corresponding to the multiple operation instructions; and selects the operation instruction from the multiple operation instructions according to the discreteness.
2. The method according to claim 1, characterized in that The performing hash processing on the input data based on the target computing unit to obtain a target hash value includes: Splitting the input data into a plurality of data blocks; Processing the data blocks in sequence based on the target computing unit; The processing result of the target operation unit on the previous data block is used as the input of the target operation unit for processing the next data block, until the processing of the multiple data blocks is completed, and the target hash value is obtained.
3. The method according to any one of claims 1 to 2, characterized in that: The hash operation device is equipped with at least two types of operation units as follows: An addition unit, a subtraction unit, a shift unit, and at least one custom unit.
4. A hash operation device, characterized in that: The device is equipped with at least two types of computing units, and the device includes: An acquisition module, used for acquiring operation instructions and input data; A selection module, configured to select, based on the operation instruction, a target operation unit that matches the operation instruction from the at least two operation units; A processing module, configured to perform hash processing on the input data based on the target operation unit to obtain a target hash value; The acquisition module includes a first acquisition unit; The first acquisition unit is used to obtain operation instructions from a preset cache, and the operation instructions in the cache are downloaded from a preset instruction editing platform, wherein before downloading the operation instructions from the preset instruction editing platform, it includes: the instruction editing platform generates multiple operation instructions according to the application scenario or application requirement of the hash operation, and selects test data corresponding to the application scenario or application requirement; simulates hash operation based on the test data and the multiple operation instructions to obtain operation results corresponding to the multiple operation instructions; calculates the discreteness of the multiple operation instructions according to the operation results corresponding to the multiple operation instructions; and selects the operation instruction from the multiple operation instructions according to the discreteness.
5. The device according to claim 4, characterized in that The processing module includes a segmentation unit and a first processing unit; The segmentation unit is used to segment the input data into multiple data blocks; The first processing unit is used to process the data blocks in sequence based on the target operation unit; and use the processing result of the target operation unit on the previous data block as the input of the target operation unit for processing the next data block, until the processing of the multiple data blocks is completed to obtain the target hash value.
6. The device according to any one of claims 4-5, characterized in that The hash operation device is equipped with at least two types of operation units as follows: An addition unit, a subtraction unit, a shift unit, and at least one custom unit.
7. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 3.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Hash value calculation apparatus and method thereof
CN101753291A
Hash function Key value screening method based on Intel 82599 quintillion network card
CN106375237A
Data distribution method and apparatus
CN106997361A
Arithmetic device, arithmetic execution device, and arithmetic execution method
CN108364061A
An arithmetic device and related products
CN109284823A
