CN102880628B - Hash data storage method and device - Google Patents

Hash data storage method and device Download PDF

Info

Publication number
CN102880628B
CN102880628B CN201210199209.6A CN201210199209A CN102880628B CN 102880628 B CN102880628 B CN 102880628B CN 201210199209 A CN201210199209 A CN 201210199209A CN 102880628 B CN102880628 B CN 102880628B
Authority
CN
China
Prior art keywords
data
stored
memory location
hash
memory
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.)
Active
Application number
CN201210199209.6A
Other languages
Chinese (zh)
Other versions
CN102880628A (en
Inventor
陈佳泳
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.)
Ruijie Networks Co Ltd
Original Assignee
Fujian Star Net Communication 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 Fujian Star Net Communication Co Ltd filed Critical Fujian Star Net Communication Co Ltd
Priority to CN201210199209.6A priority Critical patent/CN102880628B/en
Publication of CN102880628A publication Critical patent/CN102880628A/en
Application granted granted Critical
Publication of CN102880628B publication Critical patent/CN102880628B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Storage Device Security (AREA)

Abstract

The invention provides a hash data storage method and a hash data storage device. The method comprises the following steps of: respectively hashing data to be stored by using at least two hash algorithms, and acquiring at least two hash values of the data to be stored, wherein each hash value corresponds to each hash algorithm; when a certain storage position of the data to be stored is idle, storing the data to be stored in an idle storage position; and when all storage positions of the data to be stored are not idle, iteratively and recursively storing the data to be stored according to the storage conditions of other storage positions of all first stored data in each storage position of the data to be stored. The invention also provides the hash data storage device. By the invention, hash collisions can be effectively reduced, and the using efficiency of resources is improved.

Description

Hash data storage method and device
Technical field
The present invention relates to the communication technology, particularly relate to a kind of hash data storage method and device.
Background technology
Hash (Hash) algorithm is also referred to as hash algorithm usually, by hash algorithm, the Input transformation of random length is become the output of regular length, and this output is hashed value.This conversion is a kind of compressing mapping, and namely the space of hashed value is usually much smaller than the space of input, and different inputs may hash to identical output, therefore uniquely can not determine input value by hashed value.Hash algorithm may be used for multiple operation, as processes such as the destination address couplings in authentication, the communications field.One set of keyword is mapped on a limited address section according to the hash function of setting and conflict processing method, and using the memory location that resemble as be recorded in table of key word in address section, this table is called Hash table or hash, and memory location is wherein called Hash Round Robin data partition or hash address.Hash table, as a kind of linear data structure, is compared with queue with form, and seek rate is very fast.
Various hash algorithm is there is in prior art, can optimization data seek rate; But hash algorithm of the prior art exists hash-collision usually, effectively cannot reduce hash-collision, thus affect the service efficiency of resource.
Summary of the invention
The invention provides a kind of hash data storage method and device, effectively reduce hash-collision, improve the service efficiency of resource.
First aspect of the present invention is to provide a kind of hash data storage method, comprising:
Adopt at least two kinds of hash algorithms to carry out Hash process to data to be stored respectively, obtain at least two cryptographic hash of described data to be stored, each cryptographic hash is corresponding with each hash algorithm respectively;
When there is idle memory location in each memory location of described data to be stored, described data to be stored are stored in an idle memory location; Wherein, each memory location of described data to be stored is the memory location of at least two cryptographic hash difference correspondences of described data to be stored;
When each memory location of described data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored, recurrence stores processor is carried out to described data to be stored; Wherein, described first other memory locations having stored data are described first stored memory location corresponding to other cryptographic hash of data.
Another aspect of the present invention is to provide a kind of hash memory storage, comprising:
Hash processing module, for adopting at least two kinds of hash algorithms to carry out Hash process to data to be stored respectively, obtain at least two cryptographic hash of described data to be stored, each cryptographic hash is corresponding with each hash algorithm respectively;
Described data to be stored, for when there is idle memory location in each memory location of described data to be stored, are stored in an idle memory location by the first memory module; Wherein, each memory location of described data to be stored is the memory location of at least two cryptographic hash difference correspondences of described data to be stored;
Second memory module, for when each memory location of described data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored, recurrence stores processor is carried out to described data to be stored; Wherein, described first other memory locations having stored data are described first stored memory location corresponding to other cryptographic hash of data.
Technique effect of the present invention is: carry out Hash process to data to be stored respectively by adopting at least two kinds of hash algorithms, obtain at least two cryptographic hash of data to be stored, when there is idle memory location in each memory location of data to be stored, data to be stored are stored in an idle memory location, when each memory location of data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of data to be stored, iterative recursive stores processor is carried out to data to be stored; The present invention utilizes multiple hash algorithm to generate multiple memory locations of data to be stored, thus effectively can reduce hash-collision, improves the service efficiency of resource.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of hash data storage method embodiment one of the present invention;
Fig. 2 is the process flow diagram of hash data storage method embodiment two of the present invention;
Fig. 3 is the data storage procedure schematic diagram one in hash data storage method embodiment two of the present invention;
Fig. 4 is the data storage procedure schematic diagram two in hash data storage method embodiment two of the present invention;
Fig. 5 is the data storage procedure schematic diagram three in hash data storage method embodiment two of the present invention;
Fig. 6 is the structural representation of hash memory storage embodiment one of the present invention;
Fig. 7 is the structural representation of hash memory storage embodiment two of the present invention.
Embodiment
Fig. 1 is the process flow diagram of hash data storage method embodiment one of the present invention, as shown in Figure 1, present embodiments provides a kind of hash data storage method, can specifically comprise the steps:
Step 101, adopts at least two kinds of hash algorithms to carry out Hash process to data to be stored respectively, obtains at least two cryptographic hash of described data to be stored.
The present embodiment, in order to effectively reduce hash-collision, utilizes multiple hash algorithm to store data.This step carries out Hash process to data to be stored respectively for adopting at least two kinds of hash algorithms, at least two kinds of hash algorithms herein specifically can adopt existing various hash algorithm, by at least two kinds of hash algorithms, Hash process is carried out to data to be stored, obtain at least two cryptographic hash of data to be stored respectively, each cryptographic hash is herein corresponding with each hash algorithm respectively.Namely a cryptographic hash of data to be stored is calculated by a hash algorithm; at least two cryptographic hash of data to be stored are calculated by least two hash algorithms; the Hash processing procedure of concrete each hash algorithm can adopt the existing Hash mechanism of this hash algorithm, repeats no longer one by one herein.For existing each hash algorithm, may specifically be applicable in different application scenarioss by different hash algorithm, each hash algorithm may have good hash effect in certain application scenarios, but its hash effect in other application scenarioss is then poor, therefore, the advantage of the comprehensive multiple hash algorithm of the present embodiment obtains cryptographic hash corresponding to each hash algorithm respectively.
Described data to be stored, when there is idle memory location in each memory location of described data to be stored, are stored in an idle memory location by step 102.
Owing to having been got multiple cryptographic hash of these data to be stored by above-mentioned steps, each cryptographic hash is a corresponding memory location in storage space, and therefore data to be stored exist multiple memory locations that can store in storage space.Different hash algorithm is adopted to carry out to data to be stored the different cryptographic hash that Hash process obtains, may be identical with the cryptographic hash storing data that other have been stored in storage space, if two of two data cryptographic hash are identical, then there is hash-collision when storing in the two.In order to avoid this hash-collision, in the present embodiment, when storing each data to be stored, all need to carry out hash-collision judgement to each memory location of these data to be stored, each memory location of data to be stored is herein the memory location of at least two cryptographic hash difference correspondences of described data to be stored.In the present embodiment, multiple memory location is included in a storage space, the each cryptographic hash obtained by Hash process and these memory locations have corresponding relation, corresponding relation is specifically as follows the corresponding relation of the sequence number of cryptographic hash and memory location, the two can be identical, namely cryptographic hash represents the sequence number of memory location, and such as, cryptographic hash is 2 second memory location corresponding in storage space.
When there is the memory location of one or more free time in each memory location of data to be stored, can by an idle memory location stored therein for these data to be stored.In the present embodiment, when certain memory location in storage space does not store data, then show that this memory location is idle; When certain position in storage space stores data, then show that this memory location is not idle.When storing data to be stored, because each data to be stored all comprise at least two memory locations, then can judge that whether these memory locations are idle successively, when certain memory location is idle, just directly these data to be stored can be stored in this memory location, other memory locations can with judging.If data to be stored are first data needing to be stored in storage space, then, before these data to be stored store, each memory location in this storage space is all idle, can by any one memory location stored therein for these data to be stored.If data to be stored are not first data needing to be stored in storage space, then, before these data to be stored store, the memory location first judging other data in current memory space is needed whether to clash with its memory location.
Step 103, when each memory location of described data to be stored is all not idle, carries out recurrence stores processor according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored to described data to be stored.
When each memory location of described data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored, recurrence stores processor is carried out to described data to be stored.After above-mentioned judgement is carried out to each memory location of data to be stored, when each memory location of these data to be stored is all not idle, namely all occupied by other data in each memory location, now then according to each first storage condition having stored other memory locations of data in each memory location of these data to be stored, recurrence stores processor is carried out to these data to be stored.
Recurrence stores processor herein can be specially with the data of data to be stored for the 1st level in Recursion procedure, each memory location of data to be stored is obtained by Hash process, if each memory location of data to be stored is all not idle, then get the current storage in each memory location first stores data; This first has stored the data that data are the 2nd level in Recursion procedure, obtain again and stored data to first and carry out each memory location that Hash process obtains, if first to have stored each memory location of data all not idle, then get the current storage in each memory location second stores data; Second to have stored data be the data of the 3rd layer in Recursion procedure for this, if second to have stored each memory location of data all not idle yet, then can store data using second and store data as above-mentioned first, continue the data obtaining next level, and search each memory location of the data of next level; The like, search judgement to the memory location of the data of level each in Recursion procedure, data the most to be stored are stored in storage space.In the present embodiment, in order to improve data storage efficiency, can limit overall recurrence number of times, as arranged recurrence frequency threshold value, if above-mentioned recurrence number of times reaches default recurrence frequency threshold value, then that no longer carries out next level searches judgement, directly these data to be stored is carried out discard processing.Recurrence can not certainly be limited now, then when having there is not idle memory location in storage space, then no matter find which level, all cannot move data, then these data to be stored are carried out discard processing.Wherein, first other memory locations having stored data are first stored memory location corresponding to other cryptographic hash of data, herein first has stored the data that data specifically refer to store in the memory location of data to be stored, it just in order to store data distinguish with follow-up second, does not have special implication.In the present embodiment, the data that store be stored in storage space also adopt said process to store, and namely each data that stored also need to adopt at least two hash algorithms to carry out Hash process before storing, obtain at least two cryptographic hash.Particularly, this step is the storage condition of other memory locations having stored data according to first, store this data to be stored, first other memory locations having stored data are, first has stored other memory locations in each memory location of data except its current memory location, and storage condition specifically refers to that these memory locations are idle or are not idle situation.
Particularly, above-mentioned steps 103 in the present embodiment specifically can comprise each step following: when each memory location of described data to be stored is all not idle, to judge in each memory location of described data to be stored each first has stored in other memory locations of data whether there is idle memory location successively; If one or more first has stored in other memory locations of data the memory location that there is the free time in each memory location of described data to be stored, then one first is stored Data Migration has stored the free time of data memory location to described first, described data to be stored have been stored in the former memory location that described first has stored data; If in each memory location of described data to be stored each first to have stored other memory locations of data all not idle, then store each second storage condition having stored other memory locations of data in other memory locations of data according to described each first and recurrence stores processor has been carried out to described data to be stored.
More specifically, above-mentioned in the present embodiment to have stored in other memory locations of data each second storage condition having stored other memory locations of data according to described each first and specifically can comprise the steps: to judge successively that described each first to have stored in other memory locations of data each second and stored in other memory locations of data whether there is idle memory location to the step that described data to be stored carry out recurrence stores processor; Store in other memory locations of data there is idle memory location if described each first to have stored in each memory location of data one or more second, then one second is stored Data Migration has stored the free time of data memory location to described second, stored described second data corresponding first stored Data Migration has stored data former memory location to described second, described data to be stored are stored in the former memory location that described first has stored data.
Further, if above-mentioned in the present embodiment to have stored in other memory locations of data each second storage condition having stored other memory locations of data according to described each first and can also comprise the steps: that described each first to have stored in other memory locations of data each second to have stored other memory locations of data all not idle to the step that described data to be stored carry out recurrence stores processor, then store data using described second and store data as first, recurrence performs and describedly to have stored in other memory locations of data according to described each first each second storage condition having stored other memory locations of data to carry out recurrence stores processor step to described data to be stored, till above-mentioned recurrence number of times reaches default recurrence frequency threshold value.
Further, the hash data storage method that the present embodiment provides is after above-mentioned steps 103, can also comprise the steps: that the multiple hash algorithms used when adopting data to store are treated data query respectively and carried out Hash process, obtain multiple cryptographic hash of described data to be checked, each cryptographic hash is corresponding with each hash algorithm respectively; Memory location in the storage space that each cryptographic hash of described data to be checked is corresponding inquires about described data to be stored respectively.
Present embodiments provide a kind of hash data storage method, respectively Hash process is carried out to data to be stored by adopting at least two kinds of hash algorithms, obtain at least two cryptographic hash of data to be stored, when there is idle memory location in each memory location of data to be stored, data to be stored are stored in an idle memory location, when each memory location of data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of data to be stored, recurrence stores processor is carried out to data to be stored; The present embodiment utilizes multiple hash algorithm to generate multiple memory locations of data to be stored, thus effectively can reduce hash-collision, improves the service efficiency of resource.
Fig. 2 is the process flow diagram of hash data storage method embodiment two of the present invention, as shown in Figure 2, present embodiments provides a kind of hash data storage method, can specifically comprise the steps:
Step 201, adopts at least two kinds of hash algorithms to carry out Hash process to data to be stored respectively, obtains at least two cryptographic hash of described data to be stored.
This step carries out Hash process to data to be stored respectively for adopting at least two kinds of hash algorithms, and obtain at least two cryptographic hash of data to be stored respectively, each cryptographic hash is herein corresponding with each hash algorithm respectively.For existing each hash algorithm, may specifically be applicable in different application scenarioss by different hash algorithm, each hash algorithm may have good hash effect in certain application scenarios, but its hash effect in other application scenarioss is then poor, therefore, the advantage of the comprehensive multiple hash algorithm of the present embodiment obtains cryptographic hash corresponding to each hash algorithm respectively.Suppose that employing two kinds of hash algorithms A, B carry out Hash process to data to be stored, this sentences data to be stored be IP address is that example is described, key assignments (key) using IP address as hash algorithm, employing A algorithm, B algorithm carry out Hash process to IP address respectively, corresponding cryptographic hash can be obtained, thus carry out storing and searching according to cryptographic hash.Suppose to have respectively the IP address that two different: P and Q needs to be stored in storage space; It is x1 that IP address P obtains cryptographic hash after the Hash process of A algorithm, and after the Hash process of B algorithm, obtain cryptographic hash is x2, and namely the cryptographic hash of IP address P is expressed as (x1, x2); It is y1 that IP address Q obtains cryptographic hash after the Hash process of A algorithm, and after the Hash process of B algorithm, obtain cryptographic hash is y2, and namely the cryptographic hash of IP address Q is expressed as (y1, y2).
Step 202, judges whether there is idle memory location in each memory location of data to be stored, if so, then performs step 203, otherwise performs step 204.
After getting each cryptographic hash of data to be stored, because cryptographic hash in the present embodiment is corresponding with the memory location in storage space, then can carry out stores processor according to the cryptographic hash of data to be stored to these data to be stored.Before the storage carrying out data to be stored, first judge in each memory location of data to be stored, whether to there is idle memory location, idle memory location is the current position not storing data in storage space, if there is the memory location of one or more free time in each storage space of these data to be stored, then perform step 203, otherwise perform step 204.Specifically can carry out searching judgement according to the order of the cryptographic hash of data to be stored, judge whether each memory location is idle successively.The memory location of data to be stored is herein memory location corresponding to the cryptographic hash of data to be stored, be illustrated in figure 3 the data storage procedure schematic diagram one in hash data storage method embodiment two of the present invention, figure interior joint P (x, y) represent that two cryptographic hash that data P obtains after the calculating of hash algorithm are respectively x and y, these two cryptographic hash x and y are that the memory location of x and y is corresponding respectively with sequence number.In the present embodiment, the corresponding relation of cryptographic hash and memory location can show as, cryptographic hash can represent the sequence number of the memory location that these data can store in storage space, cryptographic hash as data A in Fig. 3 is 1 and 5, then this data A can be stored in sequence number is in the storage space of 1 or 5.
Data to be stored are stored in an idle memory location, and return step 201 by step 203.
Through searching judgement, if there is the memory location of one or more free time in each memory location of data to be stored, then by an idle memory location stored therein for these data to be stored, and terminate the Stored Procedure of these data to be stored, and return step 201, stores processor is carried out to next one data to be stored.As shown in Figure 3, suppose that data to be stored are C, the cryptographic hash being got data C to be stored by above-mentioned steps 201 is (1,3), four memory locations being 1,2,4,5 in sequence number in current memory space store data A (1,5), data B(2,7), data D(4,9), data E(5,12), carry out searching judgement with the order of the cryptographic hash of data C to be stored, find that the memory location of cryptographic hash " 1 " correspondence of data C to be stored is occupied by data A, then this time search and store unsuccessfully; Search the memory location that cryptographic hash " 3 " is corresponding again, find that the memory location of cryptographic hash " 3 " correspondence is in idle condition, then data C to be stored directly can be stored in the memory location that sequence number is 3, this is searched and stores successfully, and return step 201, stores processor is carried out to next one data to be stored.
Step 204, to judge in each memory location of data to be stored each first has stored in other memory locations of data whether there is idle memory location, if so, then performs step 205, otherwise performs step 206 successively.
Through searching judgement, if each memory location of data to be stored is all not idle, namely each memory location that each cryptographic hash of data to be stored is corresponding is all occupied by other data, then to judge in each memory location of data to be stored each first has stored in other memory locations of data whether there is idle memory location successively, if, then perform step 205, otherwise perform step 206.Wherein, first other memory locations having stored data are first stored memory location corresponding to other cryptographic hash of data, herein first has stored the data that data specifically refer to store in the memory location of data to be stored, it just in order to store data distinguish with follow-up second, does not have special implication.Fig. 4 is the data storage procedure schematic diagram two in hash data storage method embodiment two of the present invention, as shown in Figure 4, after having stored data C, store data F to be stored, the cryptographic hash getting data F to be stored through the calculating of above-mentioned steps 201 is (3,4), according to said process, judgement is searched in first corresponding to cryptographic hash " 3 " memory location, finds this memory location by data C (1,3) occupy, this is searched and stores unsuccessfully; Continue the memory location corresponding to cryptographic hash " 4 " and search judgement, find that this memory location is occupied by data D (4,6), this searches storage also failure.Now, judge data F(3 to be stored successively, 4) each memory location in each first store data, i.e. C (1,3) whether other memory locations and D (4,6), exist idle memory location, if existed, then perform step 205, otherwise perform step 206.
Step 205, has stored Data Migration has stored the free time of data memory location to described first by one first, described data to be stored are stored in the former memory location that described first has stored data, and return step 201.
If one or more first has stored in other memory locations of data the memory location that there is the free time in each memory location of data to be stored, then one of them first is stored Data Migration to have stored the free time of data memory location to first, data to be stored are stored in the former memory location that first has stored data, and return step 201, stores processor is carried out to next one data to be stored.In the present embodiment, judgement is searched in other memory locations that can store data to each first in order, when find wherein some first stored one of them other memory locations of data idle time, just this first can have been stored data to move to this free time memory location from former memory location, and without the need to first having stored other memory locations of data and judgement is searched in other first other memory locations having stored data to this again.Continue with reference to above-mentioned Fig. 4, first carry out searching judgement to other memory locations of data C (1,3), find sequence number be 3 memory location occupied by self, then cannot carry out data mobile; To data D (4,6) other memory locations carry out searching judgement, discovery sequence number is the memory location of 6 is the free time, then by data D(4, and 6) be advanced to from its former memory location the memory location that sequence number is 6, then just can by data F(3 to be stored, 4) be stored into the former memory location of data D (4,6), this is searched and stores successfully, and return step 201, stores processor is carried out to next one data to be stored.
Step 206, judges that each first to have stored in other memory locations of data each second and stored in other memory locations of data whether there is idle memory location successively, if so, then performs step 207, otherwise perform step 208.
Through above-mentioned to each first stored other memory locations of data search judgement, if in each memory location of these data to be stored each first to have stored other memory locations of data all not idle, namely each first other memory locations having stored data are also occupied by other data, then continuation trial mobile first has stored second in the memory location of data and has stored data, namely judge that each first to have stored in other memory locations of data each second and stored in other memory locations of data whether there is idle memory location successively, if, then perform step 207, otherwise perform step 208.Wherein, second other memory locations having stored data are second stored memory location corresponding to other cryptographic hash of data, herein second has stored data specifically refers to that above-mentioned first has stored the data stored in the memory location of data, it just in order to store data distinguish with above-mentioned first, does not have special implication.Fig. 5 is the data storage procedure schematic diagram three in hash data storage method embodiment two of the present invention, as shown in Figure 5, when after the storage completing data C and data F, store data G to be stored, the cryptographic hash getting data G to be stored through the calculating of above-mentioned steps 201 is (4,2), according to said process, judgement is searched in first corresponding to cryptographic hash " 4 " memory location, finds this memory location by data F (3,4) occupy, this is searched and stores unsuccessfully; Continue the memory location corresponding to cryptographic hash " 2 " and search judgement, find that this memory location is occupied by data B (2,7), this searches storage also failure.Now, judge data G(4 to be stored successively, 2) each memory location in each first store data, i.e. F (3,4) and B (2,7), other memory locations whether there is idle memory location; Other memory locations first having stored data F (3,4) to first carry out searching judgement, find sequence number be 4 memory location occupied by himself, this is searched and stores unsuccessfully; Other memory locations having stored data B (2,7) to first again carry out searching judgement, find sequence number be 7 memory location occupied by data H (8,7), this is searched and stores unsuccessfully.Now then recurrence is attempted removing first and has been stored second in the memory location of data and store data, namely judge that each first has stored data F (3 successively, 4) and B (2, 7) in other memory locations, each second has stored in other memory locations of data whether there is idle memory location, wherein, first has stored data F (3, 4) in each memory location second has stored data for himself, first has stored data B (2, 7) in each memory location second has stored data also comprises H(8, 7), second is then only needed now to store data H(8, 7) whether there is idle memory location in other memory locations, judge if, then perform step 207, otherwise perform step 208.
Step 207, one second is stored Data Migration has stored the free time of data memory location to second, stored second data corresponding first stored Data Migration has stored data former memory location to second, data to be stored are stored in the former memory location that first has stored data, and return step 201.
Store in other memory locations of data there is idle memory location if one or more first to have stored in other memory locations of data one or more second, then one second is stored Data Migration has stored the free time of data memory location to second, stored second data corresponding first stored Data Migration has stored data former memory location to second, data to be stored are stored in the former memory location that first has stored data, and return step 201, continue to carry out stores processor to next one data to be stored.Continue with reference to above-mentioned Fig. 5, data G(4 to be stored, 2) in memory location first has stored data F (3, 4) do not comprise second in other memory locations and store data, data G(4 to be stored, 2) in memory location first has stored data B (2, 7) in other memory locations second to have stored data be H(8, 7), by searching judgement, second stores data H(8, 7) there is idle memory location in other memory locations, namely sequence number is the memory location of 8, now then first this second is stored data H(8, 7) memory location of this free time is moved to, namely sequence number is the memory location of 8, then second data H(8 will be stored corresponding to this, 7) first has stored data B (2, 7) move to second and store data H(8, 7) former memory location, namely sequence number is the memory location of 7, again by data G(4 to be stored, 2) be stored into first and stored data B (2, 7) former memory location, namely sequence number is the memory location of 2, this is searched and stores successfully, and return step 201, stores processor is carried out to next one data to be stored.
Step 208, abandons described data to be stored, and returns step 201.
The present embodiment is described the solution of the present invention to carry out twice recursive lookup and to move, even each first to have stored in each memory location of data each second, and to have stored other memory locations of data all not idle, show that current memory space may be full or close full, simultaneously in order to avoid causing the performance of searching storage to reduce often because of recursive lookup, then no longer continuation mobile second has stored the storage data in each memory location of data, directly can abandon these data to be stored.
Further, after completing the storage to each data to be stored by each step above-mentioned, the present embodiment can also be included in the step of searching data to be checked in the storage space having stored data.Particularly, when carrying out data query, first adopt the multiple hash algorithms used when data store in above-mentioned steps 201 to treat data query respectively and carry out Hash process, obtain multiple cryptographic hash of data to be checked, each cryptographic hash is corresponding with each hash algorithm respectively.Then the memory location in the direct storage space corresponding in each cryptographic hash of these data to be checked inquires about data to be stored respectively, if inquire data to be stored in each memory location, then shows data query success, otherwise data query failure.In above-mentioned data storage procedure, for each data to be stored, it may be stored in memory location corresponding to its cryptographic hash, therefore only need search in the memory location of its correspondence in subsequent query process, without the need to searching other positions, therefore data search speed can be improved.
Present embodiments provide a kind of hash data storage method, respectively Hash process is carried out to data to be stored by adopting at least two kinds of hash algorithms, obtain at least two cryptographic hash of data to be stored, when there is idle memory location in each memory location of data to be stored, data to be stored are stored in an idle memory location, when each memory location of data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of data to be stored, recurrence stores processor is carried out to data to be stored; The present embodiment utilizes multiple hash algorithm to generate multiple memory locations of data to be stored, when its memory location occurs conflicting with the memory location storing data, the conflict of appearance is overcome by iterative search and data mobile, thus effectively can reduce hash-collision, improve the service efficiency of resource.
One of ordinary skill in the art will appreciate that: all or part of step realizing above-mentioned each embodiment of the method can have been come by the hardware that programmed instruction is relevant.Aforesaid program can be stored in a computer read/write memory medium.This program, when performing, performs the step comprising above-mentioned each embodiment of the method; And aforesaid storage medium comprises: ROM, RAM, magnetic disc or CD etc. various can be program code stored medium.
Fig. 6 is the structural representation of hash memory storage embodiment one of the present invention, as shown in Figure 6, present embodiments provides a kind of hash memory storage, specifically can perform each step in said method embodiment one, repeat no more herein.The hash memory storage that the present embodiment provides specifically can comprise the first Hash processing module 601, first memory module 602 and the second memory module 603.Wherein, the first Hash processing module 601 carries out Hash process to data to be stored respectively for adopting at least two kinds of hash algorithms, and obtain at least two cryptographic hash of described data to be stored, each cryptographic hash is corresponding with each hash algorithm respectively.Described data to be stored, for when there is idle memory location in each memory location of described data to be stored, are stored in an idle memory location by the first memory module 602; Wherein, each memory location of described data to be stored is the memory location of at least two cryptographic hash difference correspondences of described data to be stored.Second memory module 603, for when each memory location of described data to be stored is all not idle, carries out stores processor according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored to described data to be stored; Wherein, described first other memory locations having stored data are described first stored memory location corresponding to other cryptographic hash of data.
Fig. 7 is the structural representation of hash memory storage embodiment two of the present invention, as shown in Figure 7, present embodiments provides a kind of hash memory storage, specifically can perform each step in said method embodiment two, repeat no more herein.The hash memory storage that the present embodiment provides is on the basis shown in above-mentioned Fig. 6, and the second memory module 603 specifically can comprise judging unit 613, first storage unit 623 and the second storage unit 633.Wherein, judging unit 613, for when each memory location of described data to be stored is all not idle, to judge in each memory location of described data to be stored each first has stored in other memory locations of data whether there is idle memory location successively.If the first storage unit 623 is one or more first stored in other memory locations of data and there is idle memory location in each memory location of described data to be stored for the judged result of judging unit 613, then one first is stored Data Migration has stored the free time of data memory location to described first, described data to be stored have been stored in the former memory location that described first has stored data.If the second storage unit 633 is that in each memory location of described data to be stored each first to have stored other memory locations of data all not idle for the judged result of judging unit 613, then stores each second storage condition having stored other memory locations of data in each memory location of data according to described each first and stores processor has been carried out to described data to be stored.
Particularly, the second storage unit 633 in the present embodiment specifically can comprise judgment sub-unit 6331 and the first storing sub-units 6332.Wherein, judgment sub-unit 6331 is for judging that described each first to have stored in each memory location of data each second and stored in other memory locations of data whether there is idle memory location successively.If the first storing sub-units 6332 is described each first to have stored in each memory location of data one or more second and stored in other memory locations of data and there is idle memory location for the judged result of described judgment sub-unit, then one second is stored Data Migration has stored the free time of data memory location to described second, stored described second data corresponding first stored Data Migration has stored data former memory location to described second, described data to be stored are stored in the former memory location that described first has stored data.
Further, the second storage unit 633 in the present embodiment can also comprise the second storing sub-units 6333.If the second storing sub-units 6333 is described each first to have stored in each memory location of data each second to have stored other memory locations of data all not idle for the judged result of described judgment sub-unit, then store data using described second and store data as first, recurrence performs and describedly to have stored in other memory locations of data each second storage condition having stored other memory locations of data to carry out recurrence stores processor step to described data to be stored, till above-mentioned recurrence number of times reaches default recurrence frequency threshold value according to described each first.
Further, the hash memory storage that the present embodiment provides can also comprise the second Hash processing module 604 and enquiry module 605.Wherein, second Hash processing module 604 for described according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored recurrence stores processor is carried out to described data to be stored after, the multiple hash algorithms adopting described first Hash processing module to use are treated data query respectively and are carried out Hash process, obtain multiple cryptographic hash of described data to be checked, each cryptographic hash is corresponding with each hash algorithm respectively.Enquiry module 605 inquires about described data to be stored respectively for the memory location in the storage space that each cryptographic hash of described data to be checked is corresponding.
Present embodiments provide a kind of hash memory storage, respectively Hash process is carried out to data to be stored by adopting at least two kinds of hash algorithms, obtain at least two cryptographic hash of data to be stored, when there is idle memory location in each memory location of data to be stored, data to be stored are stored in an idle memory location, when each memory location of data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of data to be stored, stores processor is carried out to data to be stored; The present embodiment utilizes multiple hash algorithm to generate multiple memory locations of data to be stored, when its memory location occurs conflicting with the memory location storing data, the conflict of appearance is overcome by iterative search and data mobile, thus effectively can reduce hash-collision, improve the service efficiency of resource.
Last it is noted that above each embodiment is only in order to illustrate technical scheme of the present invention, be not intended to limit; Although with reference to foregoing embodiments to invention has been detailed description, those of ordinary skill in the art is to be understood that: it still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein some or all of technical characteristic; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the scope of various embodiments of the present invention technical scheme.

Claims (8)

1. a hash data storage method, is characterized in that, comprising:
Adopt at least two kinds of hash algorithms to carry out Hash process to data to be stored respectively, obtain at least two cryptographic hash of described data to be stored, each cryptographic hash is corresponding with each hash algorithm respectively;
When there is idle memory location in each memory location of described data to be stored, described data to be stored are stored in an idle memory location; Wherein, each memory location of described data to be stored is the memory location of at least two cryptographic hash difference correspondences of described data to be stored;
When each memory location of described data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored, recurrence stores processor is carried out to described data to be stored; Wherein, described first other memory locations having stored data are described first stored memory location corresponding to other cryptographic hash of data;
Describedly according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored, recurrence stores processor is carried out to described data to be stored and comprises:
To judge in each memory location of described data to be stored each first has stored in other memory locations of data whether there is idle memory location successively;
If one or more first has stored in other memory locations of data the memory location that there is the free time in each memory location of described data to be stored, then one first is stored Data Migration has stored the free time of data memory location to described first, described data to be stored have been stored in the former memory location that described first has stored data;
If in each memory location of described data to be stored each first to have stored other memory locations of data all not idle, then store each second storage condition having stored other memory locations of data in other memory locations of data according to described each first and recurrence stores processor has been carried out to described data to be stored.
2. method according to claim 1, is characterized in that, has describedly stored each second storage condition having stored other memory locations of data in other memory locations of data according to described each first and carries out recurrence stores processor to described data to be stored and comprise:
Judge that described each first to have stored in other memory locations of data each second and stored in other memory locations of data whether there is idle memory location successively;
Store in other memory locations of data there is idle memory location if described each first to have stored in each memory location of data one or more second, then one second is stored Data Migration has stored the free time of data memory location to described second, stored described second data corresponding first stored Data Migration has stored data former memory location to described second, described data to be stored are stored in the former memory location that described first has stored data.
3. method according to claim 2, it is characterized in that, describedly stored each second storage condition having stored other memory locations of data in other memory locations of data according to described each first and recurrence stores processor is carried out to described data to be stored also comprise:
If described each first to have stored in other memory locations of data each second, to have stored other memory locations of data all not idle, then store data using described second and store data as first, recurrence performs and describedly to have stored in other memory locations of data each second storage condition having stored other memory locations of data to carry out recurrence stores processor step to described data to be stored, until above-mentioned recurrence number of times reaches default recurrence frequency threshold value according to described each first.
4. the method according to any one of claim 1-3, it is characterized in that, described according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored recurrence stores processor is carried out to described data to be stored after, also comprise:
The multiple hash algorithms used when adopting data to store are treated data query respectively and are carried out Hash process, and obtain multiple cryptographic hash of described data to be checked, each cryptographic hash is corresponding with each hash algorithm respectively;
Memory location in the storage space that each cryptographic hash of described data to be checked is corresponding inquires about described data to be stored respectively.
5. a hash memory storage, is characterized in that, comprising:
First Hash processing module, for adopting at least two kinds of hash algorithms to carry out Hash process to data to be stored respectively, obtain at least two cryptographic hash of described data to be stored, each cryptographic hash is corresponding with each hash algorithm respectively;
Described data to be stored, for when there is idle memory location in each memory location of described data to be stored, are stored in an idle memory location by the first memory module; Wherein, each memory location of described data to be stored is the memory location of at least two cryptographic hash difference correspondences of described data to be stored;
Second memory module, for when each memory location of described data to be stored is all not idle, according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored, recurrence stores processor is carried out to described data to be stored; Wherein, described first other memory locations having stored data are described first stored memory location corresponding to other cryptographic hash of data;
Described second memory module comprises:
Judging unit, for when each memory location of described data to be stored is all not idle, to judge in each memory location of described data to be stored each first has stored in other memory locations of data whether there is idle memory location successively;
First storage unit, if the judged result for described judging unit is one or more first stored in other memory locations of data and there is idle memory location in each memory location of described data to be stored, then one first is stored Data Migration has stored the free time of data memory location to described first, described data to be stored have been stored in the former memory location that described first has stored data;
Second storage unit, if the judged result for described judging unit is that in each memory location of described data to be stored each first to have stored other memory locations of data all not idle, then stores each second storage condition having stored other memory locations of data in other memory locations of data according to described each first and stores processor has been carried out to described data to be stored.
6. device according to claim 5, is characterized in that, described second storage unit comprises:
Judgment sub-unit, for judging that described each first to have stored in other memory locations of data each second and stored in other memory locations of data whether there is idle memory location successively;
First storing sub-units, if the judged result for described judgment sub-unit is described each first to have stored in each memory location of data one or more second and stored in other memory locations of data and there is idle memory location, then one second is stored Data Migration has stored the free time of data memory location to described second, stored described second data corresponding first stored Data Migration has stored data former memory location to described second, described data to be stored are stored in the former memory location that described first has stored data.
7. device according to claim 6, is characterized in that, described second storage unit also comprises:
Second storing sub-units, if the judged result for described judgment sub-unit is described each first to have stored in other memory locations of data each second to have stored other memory locations of data all not idle, then store data using described second and store data as first, recurrence performs and describedly to have stored in other memory locations of data each second storage condition having stored other memory locations of data to carry out recurrence stores processor step to described data to be stored, until above-mentioned recurrence number of times reaches default recurrence frequency threshold value according to described each first.
8. the device according to any one of claim 5-7, is characterized in that, also comprises:
Second Hash processing module, for described according to each first storage condition having stored other memory locations of data in each memory location of described data to be stored recurrence stores processor is carried out to described data to be stored after, the multiple hash algorithms adopting described first Hash processing module to use are treated data query respectively and are carried out Hash process, obtain multiple cryptographic hash of described data to be checked, each cryptographic hash is corresponding with each hash algorithm respectively;
Enquiry module, inquires about described data to be stored respectively for the memory location in the storage space that each cryptographic hash of described data to be checked is corresponding.
CN201210199209.6A 2012-06-15 2012-06-15 Hash data storage method and device Active CN102880628B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210199209.6A CN102880628B (en) 2012-06-15 2012-06-15 Hash data storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210199209.6A CN102880628B (en) 2012-06-15 2012-06-15 Hash data storage method and device

Publications (2)

Publication Number Publication Date
CN102880628A CN102880628A (en) 2013-01-16
CN102880628B true CN102880628B (en) 2015-02-25

Family

ID=47481954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210199209.6A Active CN102880628B (en) 2012-06-15 2012-06-15 Hash data storage method and device

Country Status (1)

Country Link
CN (1) CN102880628B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6025149B2 (en) 2013-11-06 2016-11-16 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation System and method for managing data
CN104298899A (en) * 2014-08-29 2015-01-21 苏州蓝恩信息科技有限公司 Method for manually signing electronic data based on file summary information
CN105760413B (en) * 2015-12-07 2018-10-23 重庆川仪自动化股份有限公司 Management method based on the RFID data of Hash table in MES system
CN106202548B (en) * 2016-07-25 2018-09-04 网易(杭州)网络有限公司 Date storage method, lookup method and device
CN106528670A (en) * 2016-10-31 2017-03-22 盛科网络(苏州)有限公司 Method for reducing Hash search conflicts
CN108874803B (en) * 2017-05-09 2023-05-12 腾讯科技(深圳)有限公司 Data storage method, device and storage medium
CN108985057B (en) * 2018-06-27 2022-07-22 平安科技(深圳)有限公司 Webshell detection method and related equipment
CN110750508A (en) * 2019-09-27 2020-02-04 苏州浪潮智能科技有限公司 Data storage method and device
CN111158590B (en) * 2019-12-17 2021-07-06 苏州浪潮智能科技有限公司 Method and equipment for solving hash collision
US11636224B2 (en) 2019-12-19 2023-04-25 Micro Focus Llc Generating hash values for input strings
CN111143288A (en) * 2019-12-22 2020-05-12 北京浪潮数据技术有限公司 Data storage method, system and related device
US11789636B2 (en) 2021-09-13 2023-10-17 International Business Machines Corporation Ensuring sufficient space is available on target volumes before performing a point-in-time copy job

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101043695A (en) * 2006-03-23 2007-09-26 上海宇梦通信科技有限公司 Method for storing and maintaining user equipment information in mobile communication system
CN101122885A (en) * 2007-09-11 2008-02-13 腾讯科技(深圳)有限公司 Data cache processing method, system and data cache device
CN101996217A (en) * 2009-08-24 2011-03-30 华为技术有限公司 Method for storing data and memory device thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101043695A (en) * 2006-03-23 2007-09-26 上海宇梦通信科技有限公司 Method for storing and maintaining user equipment information in mobile communication system
CN101122885A (en) * 2007-09-11 2008-02-13 腾讯科技(深圳)有限公司 Data cache processing method, system and data cache device
CN101996217A (en) * 2009-08-24 2011-03-30 华为技术有限公司 Method for storing data and memory device thereof

Also Published As

Publication number Publication date
CN102880628A (en) 2013-01-16

Similar Documents

Publication Publication Date Title
CN102880628B (en) Hash data storage method and device
CN108846133B (en) Block chain storage structure based on B-M tree, B-M tree establishment algorithm and search algorithm
EP3432157B1 (en) Data table joining mode processing method and apparatus
CN101594319B (en) Entry lookup method and entry lookup device
US20110016142A1 (en) Method and apparatus for creating pattern matching state machine and identifying pattern
US9294390B2 (en) Hash table storage and search methods and devices
WO2019160128A1 (en) Method for validating transaction in blockchain network and node for configuring same network
CN111083179B (en) Internet of things cloud platform, and equipment interaction method and device based on same
US8812492B2 (en) Automatic and dynamic design of cache groups
CN102420771B (en) Method for increasing concurrent transmission control protocol (TCP) connection speed in high-speed network environment
CN109145053B (en) Data processing method and device, client and server
CN106341280A (en) Service processing method and device
CN102187642B (en) Method and device for adding, searching for and deleting key in hash table
JP6951846B2 (en) Computer system and task allocation method
CN112148738A (en) Hash collision processing method and system
CN102427420B (en) Virtual network mapping method and device based on graph pattern matching
CN112165505B (en) Decentralized data processing method, electronic device and storage medium
CN106878185B (en) Message IP address matching circuit and method
KR102620584B1 (en) Apparatus for guaranteeing integrity of state database in blockchain-based environment and method thereof
CN102724106B (en) Learning method for MAC addresses, network side equipment, and system
CN112380004B (en) Memory management method, memory management device, computer readable storage medium and electronic equipment
CN109062694B (en) Method for migrating application program to cloud platform
CN110555158A (en) mutually exclusive data processing method and system, and computer readable storage medium
US11063869B2 (en) ARP table management system
CN110059109B (en) Device, method and storage medium for data query

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP01 Change in the name or title of a patent holder
CP01 Change in the name or title of a patent holder

Address after: Cangshan District of Fuzhou City, Fujian province 350002 Jinshan Road No. 618 Garden State Industrial Park 19 floor

Patentee after: RUIJIE NETWORKS Co.,Ltd.

Address before: Cangshan District of Fuzhou City, Fujian province 350002 Jinshan Road No. 618 Garden State Industrial Park 19 floor

Patentee before: Beijing Star-Net Ruijie Networks Co.,Ltd.