CN105117471A - Read-write operation method and device - Google Patents

Read-write operation method and device Download PDF

Info

Publication number
CN105117471A
CN105117471A CN201510549565.XA CN201510549565A CN105117471A CN 105117471 A CN105117471 A CN 105117471A CN 201510549565 A CN201510549565 A CN 201510549565A CN 105117471 A CN105117471 A CN 105117471A
Authority
CN
China
Prior art keywords
read
key word
rbtree
write requests
write
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.)
Pending
Application number
CN201510549565.XA
Other languages
Chinese (zh)
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.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software 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 Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201510549565.XA priority Critical patent/CN105117471A/en
Publication of CN105117471A publication Critical patent/CN105117471A/en
Pending legal-status Critical Current

Links

Classifications

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

Abstract

The invention provides a read-write operation method, which comprises the following steps: acquiring a read-write request, wherein the read-write request comprises keywords; determining a hash address of the keyword in a hash index according to the keyword, wherein the hash address is used for indicating a red-black tree; determining the red and black tree according to the hash address, and searching the keyword in the red and black tree; and performing read-write operation on the red-black tree according to the search result and the read-write request. The embodiment of the invention also discloses a read-write operation device. The invention can improve the speed of the read-write storage system and reduce the average time complexity of the read-write storage system.

Description

A kind of read-write operation method and device
Technical field
The present invention relates to Computer Applied Technology field, particularly relate to a kind of read-write operation method and device.
Background technology
Along with the arrival of large data age, how quick obtaining information from the data message of magnanimity, how building efficient, stable storage system is all problem demanding prompt solution.The data structure that current storage system universal key-value (Key-Value) is right builds, and wherein, key also claims key word.Key-Value inquiry velocity is fast, support height is concurrent, store data amount large, is applicable to very much being inquired about by Key.The combination of hash index (HashTable) and chained list is storage key-be worth right a kind of common data structure, if the key of storage of linked list-be worth right quantity is N, the table of hash index long (i.e. mould) is M, and reading and writing a key-be worth right average time complexity is O (N/M).When the right quantity of key-be worth reach 1,000,000 ranks even ten million rank time cause the rising of the average time complexity reading and writing storage system, the bottleneck of restriction reading and writing data can be become, thus known, be the bottleneck of the application of storage system to the read-write operation of hash index and chained list.Therefore, ensure when storage system scale constantly increases that the efficient work of storage system is a good problem to study.
Summary of the invention
The invention provides a kind of read-write operation method and device, the speed of read-write storage system can be improved, reduce the average time complexity of read-write storage system.
First aspect present invention provides a kind of read-write operation method, comprising:
Obtain read-write requests, described read-write requests comprises key word;
Determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree;
Determine described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word;
According to lookup result and described read-write requests, read-write operation is carried out to described RBTree.
In conjunction with the implementation of first aspect present invention, in the first possible implementation of first aspect present invention, described read-write requests is used for the first value corresponding to key word described in acquisition request, then describedly according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, comprising:
When finding described key word in described RBTree, obtain the first value corresponding to described key word according to described read-write requests from described RBTree.
In conjunction with the implementation of first aspect present invention, in the implementation that the second of first aspect present invention is possible, described read-write requests also comprises the first value corresponding to described key word, described read-write requests is for asking to insert described key word and the first value corresponding to described key word, then describedly according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, comprising:
When not finding described key word in described RBTree, in described RBTree, insert described key word and the first value corresponding to described key word according to described read-write requests.
In conjunction with the implementation of first aspect present invention, in the third possible implementation of first aspect present invention, described read-write requests is for asking to delete described key word and the first value corresponding to described key word, then describedly according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, comprising:
When finding described key word in described RBTree, in described RBTree, delete described key word and the first value corresponding to described key word according to described read-write requests.
In conjunction with the implementation of first aspect present invention, in the 4th kind of possible implementation of first aspect present invention, described read-write requests also comprises the second value for replacing, described read-write requests is for the first value corresponding to the described key word of asking to replace described RBTree and prestoring, then describedly according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, comprising:
When finding described key word in described RBTree, according to described read-write requests, the first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value is replaced.
Second aspect present invention provides a kind of read-write operation device, comprising:
Acquisition module, for obtaining read-write requests, described read-write requests comprises key word;
Determination module, the Hash Round Robin data partition of described key word in hash index determined in the key word for obtaining according to described acquisition module, and described Hash Round Robin data partition is used to indicate RBTree;
Search module, the Hash Round Robin data partition for determining according to described determination module determines described RBTree, in described RBTree, search described key word;
Read-write operation module, carries out read-write operation for the lookup result and described read-write requests searching module described in basis to described RBTree.
In conjunction with the implementation of second aspect present invention, in the first possible implementation of second aspect present invention, described read-write requests is used for the first value corresponding to key word described in acquisition request, then described read-write operation module, specifically for:
When described search module in described RBTree, find described key word time, obtain the first value corresponding to described key word according to described read-write requests from described RBTree.
In conjunction with the implementation of second aspect present invention, in the implementation that the second of second aspect present invention is possible, described read-write requests also comprises the first value corresponding to described key word, described read-write requests is for asking to insert described key word and the first value corresponding to described key word, then described read-write operation module, specifically for:
When described search module in described RBTree, do not find described key word time, in described RBTree, insert described key word and the first value corresponding to described key word according to described read-write requests.
In conjunction with the implementation of second aspect present invention, in the third possible implementation of second aspect present invention, described read-write requests for asking to delete described key word and the first value corresponding to described key word, then described read-write operation module, specifically for:
When described search module in described RBTree, find described key word time, in described RBTree, delete described key word and the first value corresponding to described key word according to described read-write requests.
In conjunction with the implementation of second aspect present invention, in the 4th kind of possible implementation of second aspect present invention, described read-write requests also comprises the second value for replacing, described read-write requests is for the first value corresponding to the described key word of asking to replace described RBTree and prestoring, then described read-write operation module, specifically for:
When described search module in described RBTree, find described key word time, according to described read-write requests, the first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value is replaced.
Adopt the present invention, obtain read-write requests, described read-write requests comprises key word, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme of the embodiment of the present invention, below the accompanying drawing used required in describing embodiment is briefly described, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the schematic flow sheet of an embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 2 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 3 is the determination RBTree schematic diagram of another embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 4 is the structural representation of the RBTree 2 of another embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 5 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 6 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 7 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention;
Fig. 8 is the structural representation of a kind of read-write operation device of the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Adopt the embodiment of the present invention, the speed of read-write storage system can be improved, reduce the average time complexity of read-write storage system.
Refer to Fig. 1, Fig. 1 is the schematic flow sheet of an embodiment of a kind of read-write operation method of the embodiment of the present invention.The embodiment of the present invention realizes by central processing unit (CPU, CentralProcessingUnit).The hash index that the embodiment of the present invention relates to is the data structure directly conducted interviews according to Key-Value, that is, it visits the record stored in chained list, to accelerate the speed of searching by key word (Key) is mapped to a position in table.Under the combination of hash index and chained list, if the key of storage of linked list-be worth right quantity is N, the table long (i.e. mould) of hash index is M, and reading and writing a key-be worth right average time complexity is O (N/M).
RBTree is a kind of self-equilibrating binary search tree, and each node is with color attribute, and its color is red or black.Following 5 character are had: node is red or black to any effective RBTree; Root node is black; Each leaf node (empty node) is black; Two child nodes of each red node are black; Comprise the black node of identical number to all paths of its descendants's node from arbitrary node.Therefore, RBTree makes any operation all above-mentioned 5 kinds of character of demand fulfillment, the balance of guarantee RBTree thus.If the key-be worth right quantity that RBTree stores is P, so only reading and writing a key-be worth right average time complexity RBTree is O (logP).
As shown in Figure 1, an embodiment of a kind of read-write operation method of the embodiment of the present invention can comprise the following steps.
S100, obtain read-write requests, described read-write requests comprises key word.
In specific implementation, processor can obtain read-write requests, and read-write requests comprises key word, then whether processor exists value corresponding to key word within the storage system by key word.
S101, determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree.
In specific implementation, processor is according to key word determination Hash Round Robin data partition, concrete, key word first can be obtained cryptographic hash corresponding to key word (cryptographic hash now calculated is integer) as Hash operation by processor, obtain long (i.e. mould) M of table of hash index again, and cryptographic hash corresponding for key word is done modular arithmetic (by the computing of cryptographic hash divided by M remainder number) to M, the result obtained is key word Hash Round Robin data partition corresponding in hash index.Wherein, Hash Round Robin data partition uniquely points to corresponding RBTree, and this RBTree is the RBTree of the value that unique possibility storage key and key word are corresponding.
S102, determines described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word.
In specific implementation, processor, after knowing the Hash Round Robin data partition that key word is corresponding in hash index, determines corresponding RBTree according to Hash Round Robin data partition, and in the RBTree determined search key.Such as, when to calculate Hash Round Robin data partition be i to processor, then according to instruction search key in i-th RBTree of Hash Round Robin data partition.
S103, carries out read-write operation according to lookup result and described read-write requests to described RBTree.
In specific implementation, processor carries out read-write operation according to lookup result and read-write requests to i-th RBTree.Wherein, read-write operation can be included in i-th RBTree and obtain or value corresponding to amendment key word, insertion or delete key word and value corresponding to key word.It should be noted that the 5 kind character of processor the equal demand fulfillment RBTree of any read-write operation of i-th RBTree, ensure the balance of RBTree thus.
Adopt the embodiment of the present invention, obtain read-write requests, described read-write requests comprises key word, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
Refer to Fig. 2, Fig. 2 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention.The embodiment of the present invention realizes by CPU.The value that the present embodiment obtains key word corresponding with processor from RBTree is illustrated.
As shown in Figure 2, another embodiment of a kind of read-write operation method of the embodiment of the present invention can comprise the following steps.
S200, obtain read-write requests, described read-write requests comprises key word.
In specific implementation, processor can obtain read-write requests, and read-write requests comprises key word, and described read-write requests can be used for the first value corresponding to key word described in acquisition request.
S201, determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree.
In specific implementation, as shown in Figure 3, mould due to hash index is M, learn thus hash index comprise M Hash Round Robin data partition [0-(M-1)), the RBTree that each Hash Round Robin data partition instruction is corresponding, such as, when Hash Round Robin data partition is 0 in Fig. 3, correspond to RBTree 0, when Hash Round Robin data partition is M-1, correspond to RBTree M-1.
As the enforceable mode of one, before processor gets read-write requests, the mould that processor first can set hash index is M, and creates the RBTree of hash index and correspondence according to the size of M.RBTree comprises at least one node, each node storage key and value corresponding to key word.Because the Hash Round Robin data partition obtained after carrying out Hash operation to key word and do modular arithmetic to M can exist the phenomenon of repetition, therefore a RBTree can comprise at least one node.Such as, the mould that processor can preset hash index is M=10, and after a key word carries out Hash operation, its cryptographic hash is 12, then the Hash Round Robin data partition obtained after its cryptographic hash being done modular arithmetic to M is mod (12,10)=2; After b key word carries out Hash operation, its cryptographic hash is 22, the Hash Round Robin data partition obtained after then its cryptographic hash being done modular arithmetic to M is mod (22,10)=2, find out that the Hash Round Robin data partition of a key word and b key word is 2 thus, corresponding to RBTree 2, therefore there are at least two nodes in RBTree 2, wherein there are two nodes and store a key word and value corresponding to corresponding value, b key word and the b key word of a key word respectively.
S202, determines described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word.
In specific implementation, the read-write requests got for processor comprises b key word, and processor determining that the Hash Round Robin data partition of b key word is after 2, correspondingly to be searched RBTree 2.
In specific implementation, be illustrated in figure 4 the structural representation of RBTree 2, using white node as redness in Fig. 4, using black node as black.The mark of each node can be key word itself, and key word can be character or character string, Fig. 4 then with b key word for character is illustrated, therefore processor can be searched RBTree according to inorder traversal and whether store b key word in RBTree.
S203, when finding described key word in described RBTree, obtains the first value corresponding to described key word according to described read-write requests from described RBTree.
In specific implementation, when the judged result of step S203 is for being, such as b key word is 15, then processor is from root node 13, and because 15 to 13 is large, therefore processor continues to search at the right subtree of root node, and the node 17 of right subtree compares.Because 15 to 17 is little, therefore processor continues to search at the left subtree of node 17, and the node 15 of left subtree compares, and when comparative result is identical, then obtains the first value corresponding to the interior b key word stored of node 15 according to read-write requests.
S204, when not finding described key word in described RBTree, then obtains the first value corresponding to key word from disk.
In specific implementation, when the judged result of step S203 is no, such as b key word is 12, then processor is from root node 13, and because 12 to 13 is little, therefore processor continues to search at the left subtree of root node, and the node 8 of left subtree compares.Because 12 to 8 is large, therefore processor continues to search at the right subtree of node 8, and the node 11 of right subtree compares.Because 12 to 11 is large, therefore processor continues to search at the right subtree of node 11, but the right subtree of node 11 is without value (NIL), so processor is searched unsuccessfully.Last processor separately can obtain the first value corresponding to b key word from disk.
It can thus be appreciated that under the combination of hash index and RBTree, reading and writing a key-be worth right average time complexity is O (log (N/M)).Form for testing the right time complexity of the query key learnt-be worth under the combination of hash index and chained list and under the combination of hash index and RBTree as shown in table 1, find out from the comparative result of form, along with the increase of data volume, under the combination of hash index and RBTree, form the average time complexity of average time complexity far below data structure new under the combination of hash index and chained list of new data structure.
Data volume Hash index+chained list Hash index+RBTree
Inquiry Inquiry
10,000 1s 0.37s
100,000 33s 0.5s
200,000 242s 1s
500,000 1000s+ 4.5s
As the enforceable mode of one, processor can destroy RBTree and hash index in time, releasing memory space after above-mentioned flow process terminates, and improves entire system performance.
Adopt the embodiment of the present invention, obtain read-write requests, described read-write requests comprises key word, described read-write requests is used for the first value corresponding to key word described in acquisition request, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
Refer to Fig. 5, Fig. 5 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention.The embodiment of the present invention realizes by CPU.The present embodiment in RBTree, inserts described key word with processor and the first value corresponding to described key word is illustrated.
As shown in Figure 5, another embodiment of a kind of read-write operation method of the embodiment of the present invention can comprise the following steps.
S500, obtain read-write requests, described read-write requests comprises key word.
In specific implementation, processor can obtain read-write requests, and read-write requests comprises key word and the first value corresponding to described key word, then described read-write requests can be used for asking inserting described key word and the first value corresponding to described key word.
S501, determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree.
S502, determines described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word.
In specific implementation, the detailed description of the step S501 to step S502 of the embodiment of the present invention can see the step S201 of embodiment Fig. 2 to step S202, and the present embodiment then repeats no more.
S503, when not finding described key word in described RBTree, inserts described key word and the first value corresponding to described key word according to described read-write requests in described RBTree.
In specific implementation, when processor does not find key word in RBTree, then obtain key word and the first value corresponding to key word by read-write requests, and key word and the first value corresponding to key word are inserted RBTree when meeting 5 character of RBTree.
It can thus be appreciated that under the combination of hash index and RBTree, reading and writing a key-be worth right average time complexity is O (log (N/M)).Form for testing the right time complexity of the insert key learnt-be worth under the combination of hash index and chained list and under the combination of hash index and RBTree as shown in table 1, find out from the comparative result of form, along with the increase of data volume, under the combination of hash index and RBTree, form the average time complexity of average time complexity far below data structure new under the combination of hash index and chained list of new data structure.
Data volume Hash index+chained list Hash index+RBTree
Insert Insert
10,000 0.5s 0.35s
100,000 31s 1s
200,000 263s 1s
500,000 1000s+ 2.6s
As the enforceable mode of one, processor can destroy RBTree and hash index in time, releasing memory space after above-mentioned flow process terminates, and improves entire system performance.
S504, when finding described key word in described RBTree, then replaces the 3rd corresponding with the described key word that described RBTree prestores for described first value value.
In specific implementation, when processor finds key word in RBTree, the 3rd value that the key word that acquisition RBTree prestores is corresponding, then the first value and the 3rd value are replaced, the value corresponding with this key word that RBTree is finally preserved is the first value.
Adopt the embodiment of the present invention, obtain read-write requests, described read-write requests comprises key word, described read-write requests is for asking to insert described key word and the first value corresponding to described key word, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
Refer to Fig. 6, Fig. 6 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention.The embodiment of the present invention realizes by CPU.The present embodiment in described RBTree, deletes described key word with processor and the first value corresponding to described key word is illustrated.
As shown in Figure 6, another embodiment of a kind of read-write operation method of the embodiment of the present invention can comprise the following steps.
S600, obtain read-write requests, described read-write requests comprises key word.
In specific implementation, processor can obtain read-write requests, and read-write requests comprises key word, and described read-write requests can be used for asking to delete described key word and the first value corresponding to described key word.
S601, determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree.
S602, determines described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word.
In specific implementation, the detailed description of the step S601 to step S602 of the embodiment of the present invention can see the step S201 of embodiment Fig. 2 to step S202, and the present embodiment then repeats no more.
S603, when finding described key word in described RBTree, deletes described key word and the first value corresponding to described key word according to described read-write requests in described RBTree.
In specific implementation, when processor finds key word in RBTree, then the key word that is stored in RBTree and the first value corresponding to key word are deleted.
S604, terminates.
In specific implementation, when not finding described key word in described RBTree, then flow process terminates.
As the enforceable mode of one, processor can destroy RBTree and hash index in time, releasing memory space after above-mentioned flow process terminates, and improves entire system performance.
Adopt the embodiment of the present invention, obtain read-write requests, described read-write requests comprises key word, described read-write requests is for asking to delete described key word and the first value corresponding to described key word, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
Refer to Fig. 7, Fig. 7 is the schematic flow sheet of another embodiment of a kind of read-write operation method of the embodiment of the present invention.The embodiment of the present invention realizes by CPU.The first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value replacement is illustrated with processor by the present embodiment.
As shown in Figure 7, another embodiment of a kind of read-write operation method of the embodiment of the present invention can comprise the following steps.
S700, obtain read-write requests, described read-write requests comprises key word.
In specific implementation, processor can obtain read-write requests, and read-write requests comprises key word and the second value for replacing, then described read-write requests is for the first value corresponding to the described key word of asking to replace described RBTree and prestoring.
S701, determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree.
S702, determines described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word.
In specific implementation, the detailed description of the step S701 to step S702 of the embodiment of the present invention can see the step S201 of embodiment Fig. 2 to step S202, and the present embodiment then repeats no more.
S703, when finding described key word in described RBTree, replaces the first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value according to described read-write requests.
In specific implementation, when processor finds key word in RBTree, then find the first value that key word that RBTree prestores is corresponding, and the second value and first to be worth according to read-write requests and to replace, the value making the key word that stores in RBTree corresponding is the second value.
S704, when not finding described key word in described RBTree, inserts described key word and described second value according to described read-write requests in described RBTree.
In specific implementation, when processor does not find key word in RBTree, then key word and the second value are inserted RBTree when meeting 5 character of RBTree.
As the enforceable mode of one, processor can destroy RBTree and hash index in time, releasing memory space after above-mentioned flow process terminates, and improves entire system performance.
Adopt the embodiment of the present invention, obtain read-write requests, described read-write requests comprises key word, described read-write requests is for the first value corresponding to the described key word of asking to replace described RBTree and prestoring, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
Refer to Fig. 8, Fig. 8 is the structural representation of a kind of read-write operation device of the embodiment of the present invention.Read-write operation device as shown in Figure 8 comprises acquisition module 800, determination module 801, searches module 802 and read-write operation module 803.
Acquisition module 800, for obtaining read-write requests, described read-write requests comprises key word;
Determination module 801, determine the Hash Round Robin data partition of described key word in hash index for the key word obtained according to described acquisition module 800, described Hash Round Robin data partition is used to indicate RBTree;
Search module 802, determine described RBTree for the Hash Round Robin data partition determined according to described determination module 801, in described RBTree, search described key word;
Read-write operation module 803, carries out read-write operation for the lookup result and described read-write requests searching module 802 described in basis to described RBTree.
In specific implementation, processor can obtain read-write requests, and read-write requests comprises key word, then whether processor exists value corresponding to key word within the storage system by key word.
In specific implementation, processor is according to key word determination Hash Round Robin data partition, concrete, key word first can be obtained cryptographic hash corresponding to key word (cryptographic hash now calculated is integer) as Hash operation by processor, obtain long (i.e. mould) M of table of hash index again, and cryptographic hash corresponding for key word is done modular arithmetic (by the computing of cryptographic hash divided by M remainder number) to M, the result obtained is key word Hash Round Robin data partition corresponding in hash index.Wherein, Hash Round Robin data partition uniquely points to corresponding RBTree, and this RBTree is the RBTree of the value that unique possibility storage key and key word are corresponding.
In specific implementation, processor, after knowing the Hash Round Robin data partition that key word is corresponding in hash index, determines corresponding RBTree according to Hash Round Robin data partition, and in the RBTree determined search key.Such as, when to calculate Hash Round Robin data partition be i to processor, then according to instruction search key in i-th RBTree of Hash Round Robin data partition.
In specific implementation, processor carries out read-write operation according to lookup result and read-write requests to i-th RBTree.Wherein, read-write operation can be included in i-th RBTree and obtain or value corresponding to amendment key word, insertion or delete key word and value corresponding to key word.It should be noted that the 5 kind character of processor the equal demand fulfillment RBTree of any read-write operation of i-th RBTree, ensure the balance of RBTree thus.
As the enforceable mode of one, described read-write requests is used for the first value corresponding to key word described in acquisition request, then described read-write operation module 803, specifically for:
When described search module 802 in described RBTree, find described key word time, obtain the first value corresponding to described key word according to described read-write requests from described RBTree.
As the enforceable mode of one, described read-write requests also comprises the first value corresponding to described key word, described read-write requests for asking to insert described key word and the first value corresponding to described key word, then described read-write operation module 803, specifically for:
When described search module 802 in described RBTree, do not find described key word time, in described RBTree, insert described key word and the first value corresponding to described key word according to described read-write requests.
As the enforceable mode of one, described read-write requests for asking to delete described key word and the first value corresponding to described key word, then described read-write operation module 803, specifically for:
When described search module 802 in described RBTree, find described key word time, in described RBTree, delete described key word and the first value corresponding to described key word according to described read-write requests.
As the enforceable mode of one, described read-write requests also comprises the second value for replacing, described read-write requests for the first value corresponding to the described key word of asking to replace described RBTree and prestoring, then described read-write operation module 803, specifically for:
When described search module 802 in described RBTree, find described key word time, according to described read-write requests, the first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value is replaced.
Adopt the embodiment of the present invention, obtain read-write requests, described read-write requests comprises key word, the Hash Round Robin data partition of described key word in hash index is determined according to described key word, described Hash Round Robin data partition is used to indicate RBTree, described RBTree is determined according to described Hash Round Robin data partition, described key word is searched in described RBTree, according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, hash index and RBTree can be carried out combining and form new storage organization, accelerate the speed of search key, reduce the average time complexity of read-write storage system, and then improve the speed of read-write storage system, promote the performance of storage system.
In the description of this instructions, specific features, structure, material or feature that the description of reference term " embodiment ", " some embodiments ", " example ", " concrete example " or " some examples " etc. means to describe in conjunction with this embodiment or example are contained at least one embodiment of the present invention or example.In this manual, to the schematic representation of above-mentioned term not must for be identical embodiment or example.And the specific features of description, structure, material or feature can combine in one or more embodiment in office or example in an appropriate manner.In addition, when not conflicting, the feature of the different embodiment described in this instructions or example and different embodiment or example can carry out combining and combining by those skilled in the art.
In addition, term " first ", " second " only for describing object, and can not be interpreted as instruction or hint relative importance or imply the quantity indicating indicated technical characteristic.Thus, be limited with " first ", the feature of " second " can express or impliedly comprise at least one this feature.In describing the invention, the implication of " multiple " is at least two, such as two, three etc., unless otherwise expressly limited specifically.
Describe and can be understood in process flow diagram or in this any process otherwise described or method, represent and comprise one or more for realizing the module of the code of the executable instruction of the step of specific logical function or process, fragment or part, and the scope of the preferred embodiment of the present invention comprises other realization, wherein can not according to order that is shown or that discuss, comprise according to involved function by the mode while of basic or by contrary order, carry out n-back test, this should understand by embodiments of the invention person of ordinary skill in the field.
In flow charts represent or in this logic otherwise described and/or step, such as, the sequencing list of the executable instruction for realizing logic function can be considered to, may be embodied in any computer-readable medium, for instruction execution system, device or equipment (as computer based system, comprise the system of processor or other can from instruction execution system, device or equipment instruction fetch and perform the system of instruction) use, or to use in conjunction with these instruction execution systems, device or equipment.With regard to this instructions, " computer-readable medium " can be anyly can to comprise, store, communicate, propagate or transmission procedure for instruction execution system, device or equipment or the device that uses in conjunction with these instruction execution systems, device or equipment.The example more specifically (non-exhaustive list) of computer-readable medium comprises following: the electrical connection section (electronic installation) with one or more wiring, portable computer diskette box (magnetic device), random access memory (RAM), ROM (read-only memory) (ROM), erasablely edit ROM (read-only memory) (EPROM or flash memory), fiber device, and portable optic disk ROM (read-only memory) (CDROM).In addition, computer-readable medium can be even paper or other suitable media that can print described program thereon, because can such as by carrying out optical scanning to paper or other media, then carry out editing, decipher or carry out process with other suitable methods if desired and electronically obtain described program, be then stored in computer memory.
Should be appreciated that each several part of the present invention can realize with hardware, software, firmware or their combination.In the above-described embodiment, multiple step or method can with to store in memory and the software performed by suitable instruction execution system or firmware realize.Such as, if realized with hardware, the same in another embodiment, can realize by any one in following technology well known in the art or their combination: the discrete logic with the logic gates for realizing logic function to data-signal, there is the special IC of suitable combinational logic gate circuit, programmable gate array (PGA), field programmable gate array (FPGA) etc.
Those skilled in the art are appreciated that realizing all or part of step that above-described embodiment method carries is that the hardware that can carry out instruction relevant by program completes, described program can be stored in a kind of computer-readable recording medium, this program perform time, step comprising embodiment of the method one or a combination set of.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing module, also can be that the independent physics of unit exists, also can be integrated in a module by two or more unit.Above-mentioned integrated module both can adopt the form of hardware to realize, and the form of software function module also can be adopted to realize.If described integrated module using the form of software function module realize and as independently production marketing or use time, also can be stored in a computer read/write memory medium.
The above-mentioned storage medium mentioned can be ROM (read-only memory), disk or CD etc.Although illustrate and describe embodiments of the invention above, be understandable that, above-described embodiment is exemplary, can not be interpreted as limitation of the present invention, and those of ordinary skill in the art can change above-described embodiment within the scope of the invention, revises, replace and modification.

Claims (10)

1. a read-write operation method, is characterized in that, comprising:
Obtain read-write requests, described read-write requests comprises key word;
Determine the Hash Round Robin data partition of described key word in hash index according to described key word, described Hash Round Robin data partition is used to indicate RBTree;
Determine described RBTree according to described Hash Round Robin data partition, in described RBTree, search described key word;
According to lookup result and described read-write requests, read-write operation is carried out to described RBTree.
2. method according to claim 1, is characterized in that, described read-write requests is used for the first value corresponding to key word described in acquisition request, then describedly carry out read-write operation according to lookup result and described read-write requests to described RBTree, comprising:
When finding described key word in described RBTree, obtain the first value corresponding to described key word according to described read-write requests from described RBTree.
3. method according to claim 1, it is characterized in that, described read-write requests also comprises the first value corresponding to described key word, described read-write requests is for asking to insert described key word and the first value corresponding to described key word, then describedly according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, comprising:
When not finding described key word in described RBTree, in described RBTree, insert described key word and the first value corresponding to described key word according to described read-write requests.
4. method according to claim 1, it is characterized in that, described read-write requests for asking to delete described key word and the first value corresponding to described key word, then describedly carries out read-write operation according to lookup result and described read-write requests to described RBTree, comprising:
When finding described key word in described RBTree, in described RBTree, delete described key word and the first value corresponding to described key word according to described read-write requests.
5. method according to claim 1, it is characterized in that, described read-write requests also comprises the second value for replacing, described read-write requests is for the first value corresponding to the described key word of asking to replace described RBTree and prestoring, then describedly according to lookup result and described read-write requests, read-write operation is carried out to described RBTree, comprising:
When finding described key word in described RBTree, according to described read-write requests, the first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value is replaced.
6. a read-write operation device, is characterized in that, comprising:
Acquisition module, for obtaining read-write requests, described read-write requests comprises key word;
Determination module, the Hash Round Robin data partition of described key word in hash index determined in the key word for obtaining according to described acquisition module, and described Hash Round Robin data partition is used to indicate RBTree;
Search module, the Hash Round Robin data partition for determining according to described determination module determines described RBTree, in described RBTree, search described key word;
Read-write operation module, carries out read-write operation for the lookup result and described read-write requests searching module described in basis to described RBTree.
7. read-write operation device according to claim 6, is characterized in that, described read-write requests is used for the first value corresponding to key word described in acquisition request, then described read-write operation module, specifically for:
When described search module in described RBTree, find described key word time, obtain the first value corresponding to described key word according to described read-write requests from described RBTree.
8. read-write operation device according to claim 6, it is characterized in that, described read-write requests also comprises the first value corresponding to described key word, and described read-write requests is for asking to insert described key word and the first value corresponding to described key word, then described read-write operation module, specifically for:
When described search module in described RBTree, do not find described key word time, in described RBTree, insert described key word and the first value corresponding to described key word according to described read-write requests.
9. read-write operation device according to claim 6, is characterized in that, described read-write requests for asking to delete described key word and the first value corresponding to described key word, then described read-write operation module, specifically for:
When described search module in described RBTree, find described key word time, in described RBTree, delete described key word and the first value corresponding to described key word according to described read-write requests.
10. read-write operation device according to claim 6, it is characterized in that, described read-write requests also comprises the second value for replacing, and described read-write requests is for the first value corresponding to the described key word of asking to replace described RBTree and prestoring, then described read-write operation module, specifically for:
When described search module in described RBTree, find described key word time, according to described read-write requests, the first corresponding with the described key word that described RBTree prestores for described the second value being used for replacing value is replaced.
CN201510549565.XA 2015-08-31 2015-08-31 Read-write operation method and device Pending CN105117471A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510549565.XA CN105117471A (en) 2015-08-31 2015-08-31 Read-write operation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510549565.XA CN105117471A (en) 2015-08-31 2015-08-31 Read-write operation method and device

Publications (1)

Publication Number Publication Date
CN105117471A true CN105117471A (en) 2015-12-02

Family

ID=54665461

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510549565.XA Pending CN105117471A (en) 2015-08-31 2015-08-31 Read-write operation method and device

Country Status (1)

Country Link
CN (1) CN105117471A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107145502A (en) * 2017-03-20 2017-09-08 中山大学 A kind of method of mass picture storage and search
CN109885576A (en) * 2019-03-06 2019-06-14 珠海金山网络游戏科技有限公司 A kind of Hash table creation method and system calculate equipment and storage medium
CN111984649A (en) * 2020-08-20 2020-11-24 北京金山云网络技术有限公司 Data index searching method and device and related equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130268770A1 (en) * 2012-04-06 2013-10-10 Tad Hunt Cryptographic hash database
CN103856462A (en) * 2012-12-05 2014-06-11 深圳市快播科技有限公司 Method and system for managing sessions

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130268770A1 (en) * 2012-04-06 2013-10-10 Tad Hunt Cryptographic hash database
CN103856462A (en) * 2012-12-05 2014-06-11 深圳市快播科技有限公司 Method and system for managing sessions

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
所思 所学 我写 我得: "Java类集框架之HashMap(JDK1.8源码剖析", 《红黑联盟HTTPS://WWW.2CTO.COM/KF/201505/401433.HTML》 *
滕少华等: "一种带红黑树的哈希表在物流信息系统中的应用研究", 《江西师范大学学报》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107145502A (en) * 2017-03-20 2017-09-08 中山大学 A kind of method of mass picture storage and search
CN109885576A (en) * 2019-03-06 2019-06-14 珠海金山网络游戏科技有限公司 A kind of Hash table creation method and system calculate equipment and storage medium
CN111984649A (en) * 2020-08-20 2020-11-24 北京金山云网络技术有限公司 Data index searching method and device and related equipment

Similar Documents

Publication Publication Date Title
US7523288B2 (en) Dynamic fragment mapping
US9411840B2 (en) Scalable data structures
US7743013B2 (en) Data partitioning via bucketing bloom filters
CN101719141B (en) File processing method and system based on directory object
US10140351B2 (en) Method and apparatus for processing database data in distributed database system
TWI544334B (en) Data storage device and operating method thereof
US10248680B2 (en) Index management
CN101192237A (en) Method and system for inquiring multiple information
CN105630803B (en) The method and apparatus that Document image analysis establishes index
CN104794177A (en) Data storing method and device
CN107085570A (en) Data processing method, application server and router
CN107807989B (en) Small file processing method and device
JP2013196565A (en) Database processing method, and database processor
CN105117471A (en) Read-write operation method and device
US20110258483A1 (en) Data Layout for Recovery and Durability
CN104268192A (en) Webpage information extracting method, device and terminal
CN111078689B (en) Data processing method and system of discontinuous pre-ordering traversal tree algorithm
CN109976669A (en) A kind of edge storage method, device and storage medium
CN114579561A (en) Data processing method and device, and storage medium
CN105117489A (en) Database management method and device and electronic equipment
CN104573112A (en) Page query method and data processing node for OLTP cluster database
CN105389394A (en) Data request processing method and device based on a plurality of database clusters
CN111984649A (en) Data index searching method and device and related equipment
WO2012001455A1 (en) Hyper-lattice model for optimized sequencing of online analytical processing (olap) operations on data warehouses
CN114840487A (en) Metadata management method and device for distributed file system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20151202