CN104462124B - Data storing platform method for organizing and data storing platform based on linear Hash table - Google Patents
Data storing platform method for organizing and data storing platform based on linear Hash table Download PDFInfo
- Publication number
- CN104462124B CN104462124B CN201310430856.8A CN201310430856A CN104462124B CN 104462124 B CN104462124 B CN 104462124B CN 201310430856 A CN201310430856 A CN 201310430856A CN 104462124 B CN104462124 B CN 104462124B
- Authority
- CN
- China
- Prior art keywords
- hash table
- node
- address number
- value
- hash
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 43
- 238000013500 data storage Methods 0.000 claims abstract description 46
- 230000008520 organization Effects 0.000 claims abstract description 31
- 238000012545 processing Methods 0.000 claims description 16
- 238000013507 mapping Methods 0.000 abstract description 11
- 230000008901 benefit Effects 0.000 abstract description 6
- 230000006870 function Effects 0.000 description 24
- 238000010586 diagram Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 5
- 230000005012 migration Effects 0.000 description 3
- 238000013508 migration Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2255—Hash tables
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/214—Database migration support
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种基于线性哈希表的数据存储平台组织方法和数据存储平台,涉及云计算领域。本发明扩展了哈希表的结构和地址映射模式,在有新的节点加入集群时,保持键值和地址间原有的映射不变,只是扩展地址的有效位数和哈希表长度,将新产生的地址赋予新节点,并在保持系统运行的同时逐渐迁移数据;同理,在有节点离开集群时,保持键值和地址间原有的映射不变,只是收缩地址的有效位数和哈希表长度,并在保持系统运行的同时逐渐迁移数据。这种组织方法,既保留了通过哈希表组织云集群的实时性高的优点,又使集群易于维护和扩展。本发明适用于所有云存储平台,特别是对实时性要求较高、运行在内存数据库上的计费或流量控制等业务平台。
The invention discloses a data storage platform organization method and a data storage platform based on a linear hash table, and relates to the field of cloud computing. The present invention expands the structure of the hash table and the address mapping mode. When a new node joins the cluster, the original mapping between the key value and the address remains unchanged, and only the effective number of bits of the address and the length of the hash table are extended. The newly generated address is given to the new node, and the data is gradually migrated while keeping the system running; similarly, when a node leaves the cluster, the original mapping between the key value and the address remains unchanged, only the effective number of bits and Hash table length, and gradually migrate data while keeping the system running. This organization method not only retains the high real-time advantages of organizing cloud clusters through hash tables, but also makes the clusters easy to maintain and expand. The present invention is applicable to all cloud storage platforms, especially service platforms such as billing or flow control that have high real-time requirements and run on memory databases.
Description
技术领域technical field
本发明涉及云计算领域,特别涉及一种基于线性哈希表的数据存储平台组织方法和数据存储平台。The invention relates to the field of cloud computing, in particular to a data storage platform organization method and a data storage platform based on a linear hash table.
背景技术Background technique
随着大数据时代的来临,云模式是数据存储平台的发展趋势。云存储的组织方法是指根据键值决定哪些数据存储在哪个节点的方法,可以分为树状组织法和哈希表组织法两种。其中,哈希表组织法适合单记录查询和修改,优点是结构简单、访问速度快,缺点是集群不易维护,增加和删除节点都需要停止集群运行并重新组织数据。With the advent of the big data era, the cloud model is the development trend of data storage platforms. The organization method of cloud storage refers to the method of determining which data is stored in which node according to the key value, which can be divided into tree organization method and hash table organization method. Among them, the hash table organization method is suitable for single-record query and modification. The advantage is that the structure is simple and the access speed is fast. The disadvantage is that the cluster is not easy to maintain. Adding and deleting nodes requires stopping the cluster operation and reorganizing the data.
通过哈希表组织云存储平台的方法如下:The method of organizing the cloud storage platform through the hash table is as follows:
1)为简化模型起见,我们认为数据具有唯一的键值k,云存储平台有N个节点,编号为0~N-1,节点之间对等。1) For the sake of simplifying the model, we consider that the data has a unique key value k, and the cloud storage platform has N nodes, numbered from 0 to N-1, and the nodes are equal.
2)云存储平台维护一张哈希表,长度为N,表的每一列指向一个节点,并维护一个哈希函数H,H(k)的结果取值范围在0~N-1之间。哈希本身是一种成熟的技术,现有的哈希函数能够做到,无论k的分布如何,H(k)的分布基本均匀。2) The cloud storage platform maintains a hash table with a length of N. Each column of the table points to a node, and maintains a hash function H. The result of H(k) ranges from 0 to N-1. Hash itself is a mature technology, and the existing hash function can do it. Regardless of the distribution of k, the distribution of H(k) is basically uniform.
3)当有新的数据(键值k1)载入云存储平台时,云存储平台计算H(k1),假设H(k1)=n,则在哈希表上查找到n号节点,并将该数据存入n号节点;3) When new data (key value k1) is loaded into the cloud storage platform, the cloud storage platform calculates H(k1), assuming H(k1)=n, then finds node n on the hash table, and The data is stored in node n;
4)当用户向云存储平台请求访问键值为k1的数据时,云存储平台同样根据H(k1)=n查找哈希表,将这个请求转发给n号节点。4) When a user requests access to data with a key value of k1 from the cloud storage platform, the cloud storage platform also looks up the hash table according to H(k1)=n, and forwards the request to node n.
图1为现有的哈希表组织原理示意图。如图1所示,如果有新的节点加入集群,则系统需要扩展哈希表,使其长度达到N+1,新节点的地址编号为N;更换哈希函数,新的哈希函数H’(k)的取值范围为0~N;根据新的哈希函数迁移数据,对于任一k,H’(k)即是k所代表的数据的存储节点。数据迁移过程涉及到整个集群几乎所有的节点,为此不得不停止集群服务。FIG. 1 is a schematic diagram of an existing hash table organization principle. As shown in Figure 1, if a new node joins the cluster, the system needs to expand the hash table so that its length reaches N+1, and the address number of the new node is N; replace the hash function with a new hash function H' (k) ranges from 0 to N; migrate data according to the new hash function, for any k, H'(k) is the storage node of the data represented by k. The data migration process involves almost all nodes in the entire cluster, so the cluster service has to be stopped.
节点离开集群的流程与上述加入集群相似,也需要更换哈希函数,数据迁移过程也涉及到整个集群几乎所有的节点。The process for a node to leave the cluster is similar to that of joining the cluster above, and the hash function also needs to be replaced. The data migration process also involves almost all nodes in the entire cluster.
有上述分析可见,现有的哈希表组织法集群不易维护,增加和删除节点都需要停止集群运行并重新组织数据,不适用于实时性要求较高的数据存储平台。From the above analysis, it can be seen that the existing hash table organization method cluster is not easy to maintain. Adding and deleting nodes requires stopping the cluster operation and reorganizing data, which is not suitable for data storage platforms with high real-time requirements.
发明内容Contents of the invention
本发明实施例所要解决的一个技术问题是:解决现有的哈希表组织法存在的集群不易维护,增加和删除节点都需要停止集群运行并重新组织数据的问题。A technical problem to be solved by the embodiments of the present invention is to solve the problem that the cluster existing in the existing hash table organization method is not easy to maintain, and adding and deleting nodes requires stopping the cluster operation and reorganizing data.
根据本发明实施例的一个方面,提出一种基于线性哈希表的数据存储平台组织方法,包括:对于节点数量为N的一个集群,如果有新节点加入该集群,将哈希表长度扩展为N+1,新节点的地址编号记为N;将哈希表分裂指针指向的节点上的部分数据迁移到地址编号为N的新节点上;哈希表分裂指针后移一位,指向下一个节点;更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整。According to an aspect of the embodiments of the present invention, a method for organizing a data storage platform based on a linear hash table is proposed, including: for a cluster with N nodes, if a new node joins the cluster, the length of the hash table is extended to N+1, the address number of the new node is recorded as N; part of the data on the node pointed to by the hash table split pointer is migrated to the new node with the address number N; the hash table split pointer is shifted one bit to point to the next Node; update the value of the hash table bit counter Among them, d represents the value of the hash table bit counter, Indicates rounding up.
根据本发明实施例的再一个方面,提出一种基于线性哈希表的数据存储平台组织方法,包括:对于节点数量为N+1的一个集群,如果哈希表最末端的地址编号为N的节点离开该集群,哈希表分裂指针前移一位,指向上一个节点;更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整;将地址编号为N的节点上的所有数据迁移到哈希表分裂指针指向的节点;将哈希表长度缩小为N。According to another aspect of the embodiment of the present invention, a method for organizing a data storage platform based on a linear hash table is proposed, including: for a cluster with N+1 nodes, if the address number at the end of the hash table is N When the node leaves the cluster, the split pointer of the hash table moves forward one bit to point to the previous node; the value of the bit counter of the hash table is updated Among them, d represents the value of the hash table bit counter, Indicates rounding up; migrate all data on the node whose address number is N to the node pointed to by the split pointer of the hash table; reduce the length of the hash table to N.
前述的数据存储平台组织方法还包括:用户请求访问键值为k的数据时,根据H(k)=n计算k的哈希值,H表示哈希函数,n表示计算出的哈希值;获取哈希表位数计数器的值d;截取n的后d位得到n’;截取n的后d-1位得到n”;比较哈希表分裂指针与地址编号n”的位置,如果地址编号为n”的节点在哈希表分裂指针之后,将请求定位到地址编号为n”的节点,如果地址编号为n”的节点在哈希表分裂指针之前,将请求定位到地址编号为n’的节点。The aforementioned data storage platform organization method also includes: when a user requests access to data with a key value of k, calculate the hash value of k according to H(k)=n, where H represents a hash function, and n represents the calculated hash value; Obtain the value d of the hash table digit counter; intercept the last d digits of n to obtain n'; intercept the last d-1 digits of n to obtain n"; compare the position of the hash table split pointer with the address number n", if the address number After the hash table splits the pointer, the node with n” locates the request to the node with the address number n”, if the node with the address number n” locates the request to the address number n’ before the hash table splits the pointer of nodes.
其中,哈希函数的取值范围大于集群中节点的地址编号的范围。Wherein, the value range of the hash function is larger than the range of the address numbers of the nodes in the cluster.
根据本发明实施例的又一个方面,提出一种数据存储平台,包括:节点加入处理单元或/和节点离开处理单元;节点加入处理单元对于节点数量为N的一个集群,如果有新节点加入该集群,将哈希表长度扩展为N+1,新节点的地址编号记为N;将哈希表分裂指针指向的节点上的部分数据迁移到地址编号为N的新节点上;哈希表分裂指针后移一位,指向下一个节点;更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整;节点离开处理单元对于节点数量为N+1的一个集群,如果哈希表最末端的地址编号为N的节点离开该集群,哈希表分裂指针前移一位,指向上一个节点;更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整;将地址编号为N的节点上的所有数据迁移到哈希表分裂指针指向的节点;将哈希表长度缩小为N。According to still another aspect of the embodiments of the present invention, a data storage platform is proposed, including: a node joins a processing unit or/and a node leaves a processing unit; a node joins a processing unit for a cluster whose number of nodes is N, if a new node joins the Cluster, expand the length of the hash table to N+1, record the address number of the new node as N; migrate some data on the node pointed to by the split pointer of the hash table to the new node with the address number N; split the hash table Move the pointer back one bit to point to the next node; update the value of the bit counter in the hash table Among them, d represents the value of the hash table bit counter, Represents rounding up; the node leaves the processing unit. For a cluster with the number of nodes N+1, if the node whose address number is N at the end of the hash table leaves the cluster, the split pointer of the hash table moves forward one bit, pointing to the previous Node; update the value of the hash table bit counter Among them, d represents the value of the hash table bit counter, Indicates rounding up; migrate all data on the node whose address number is N to the node pointed to by the split pointer of the hash table; reduce the length of the hash table to N.
数据存储平台还包括:数据访问处理单元,用于用户请求访问键值为k的数据时,根据H(k)=n计算k的哈希值,H表示哈希函数,n表示计算出的哈希值;获取哈希表位数计数器的值d;截取n的后d位得到n’;截取n的后d-1位得到n”;比较哈希表分裂指针与地址编号n”的位置,如果地址编号为n”的节点在哈希表分裂指针之后,将请求定位到地址编号为n”的节点,如果地址编号为n”的节点在哈希表分裂指针之前,将请求定位到地址编号为n’的节点。The data storage platform also includes: a data access processing unit, which is used to calculate the hash value of k according to H(k)=n when a user requests to access data with a key value of k, H represents a hash function, and n represents the calculated hash value Hash value; obtain the value d of the hash table digit counter; intercept the last d digits of n to obtain n'; intercept the last d-1 digits of n to obtain n"; compare the position of the hash table split pointer with the address number n", If the node with the address number n" is after the hash table split pointer, locate the request to the node with the address number n", if the node with the address number n" is before the hash table split pointer, locate the request to the address number is the node of n'.
其中,数据存储平台例如可以是云存储平台,或者是其他实时性要求较高、运行在内存数据库上的计费或流量控制等业务平台。Wherein, the data storage platform may be, for example, a cloud storage platform, or other service platforms such as billing or traffic control that have high real-time requirements and run on an in-memory database.
本发明扩展了哈希表的结构和地址映射模式,在有新的节点加入集群时,保持键值和地址间原有的映射不变,只是扩展地址的有效位数和哈希表长度,将新产生的地址赋予新节点,并在保持系统运行的同时逐渐迁移数据;同理,在有节点离开集群时,保持键值和地址间原有的映射不变,只是收缩地址的有效位数和哈希表长度,并在保持系统运行的同时逐渐迁移数据。这种组织方法,既保留了通过哈希表组织云集群的实时性高的优点,又使集群易于维护和扩展。本发明适用于所有云存储平台,特别是对实时性要求较高、运行在内存数据库上的计费或流量控制等业务平台。The present invention expands the structure of the hash table and the address mapping mode. When a new node joins the cluster, the original mapping between the key value and the address remains unchanged, and only the effective number of bits of the address and the length of the hash table are extended. The newly generated address is given to the new node, and the data is gradually migrated while keeping the system running; similarly, when a node leaves the cluster, the original mapping between the key value and the address remains unchanged, only the effective number of bits and Hash table length, and gradually migrate data while keeping the system running. This organization method not only retains the high real-time advantages of organizing cloud clusters through hash tables, but also makes the clusters easy to maintain and expand. The present invention is applicable to all cloud storage platforms, especially service platforms such as billing or flow control that have high real-time requirements and run on memory databases.
通过以下参照附图对本发明的示例性实施例的详细描述,本发明的其它特征及其优点将会变得清楚。Other features of the present invention and advantages thereof will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the accompanying drawings.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained according to these drawings without any creative effort.
图1为现有的哈希表组织原理示意图。FIG. 1 is a schematic diagram of an existing hash table organization principle.
图2为本发明有节点加入集群时的数据存储平台组织方法的流程示意图。FIG. 2 is a schematic flowchart of the method for organizing a data storage platform in the present invention when nodes join a cluster.
图3为本发明的哈希表组织原理示意图。Fig. 3 is a schematic diagram of the organization principle of the hash table of the present invention.
图4为本发明的数据访问流程示意图。FIG. 4 is a schematic diagram of a data access flow in the present invention.
图5为本发明有节点加入集群时数据存储平台组织过程示意图。FIG. 5 is a schematic diagram of the organization process of the data storage platform when nodes join the cluster in the present invention.
图6为本发明有节点离开集群时的数据存储平台组织方法的流程示意图。FIG. 6 is a schematic flowchart of the method for organizing a data storage platform when a node leaves the cluster according to the present invention.
图7为本发明数据存储平台一个实施例的结构示意图。Fig. 7 is a schematic structural diagram of an embodiment of the data storage platform of the present invention.
图8为本发明数据存储平台再一个实施例的结构示意图。Fig. 8 is a schematic structural diagram of another embodiment of the data storage platform of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。以下对至少一个示例性实施例的描述实际上仅仅是说明性的,决不作为对本发明及其应用或使用的任何限制。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. The following description of at least one exemplary embodiment is merely illustrative in nature and in no way taken as limiting the invention, its application or uses. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
除非另外具体说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本发明的范围。The relative arrangements of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
为了解决现有的哈希表组织法存在的集群不易维护,增加和删除节点都需要停止集群运行并重新组织数据的问题,本发明提出一种基于线性哈希表的数据存储平台组织方案,在增加和删除节点时无需更换哈希函数,可以在保持系统运行的同时逐渐迁移数据,集群易于维护和扩展。下面详细说明本发明的方案。In order to solve the problem that the existing hash table organization method is not easy to maintain the cluster, adding and deleting nodes need to stop the cluster operation and reorganize the data, the present invention proposes a data storage platform organization scheme based on a linear hash table. There is no need to change the hash function when adding and deleting nodes, and the data can be gradually migrated while keeping the system running. The cluster is easy to maintain and expand. The solution of the present invention will be described in detail below.
为简化模型起见,我们认为数据具有唯一的键值k,数据存储平台有N个节点,地址编号为0~N-1。数据存储平台维护一张哈希表,长度为N,表的每一列指向一个节点,并维护一个哈希函数H,H(k)的结果取值范围在0~N-1之间。哈希本身是一种成熟的技术,现有的哈希函数能够做到,无论k的分布如何,H(k)的分布基本均匀。下面分别介绍有节点加入和离开集群时的数据存储平台组织方法。To simplify the model, we consider that the data has a unique key value k, the data storage platform has N nodes, and the addresses are numbered from 0 to N-1. The data storage platform maintains a hash table with a length of N, each column of the table points to a node, and maintains a hash function H, and the result of H(k) ranges from 0 to N-1. Hash itself is a mature technology, and the existing hash function can do it. Regardless of the distribution of k, the distribution of H(k) is basically uniform. The following describes the organization methods of the data storage platform when nodes join and leave the cluster.
图2为本发明有节点加入集群时的数据存储平台组织方法的流程示意图。FIG. 2 is a schematic flowchart of the method for organizing a data storage platform in the present invention when nodes join a cluster.
如图2所示,本实施例在有节点加入集群时的数据存储平台组织方法包括以下步骤:As shown in Figure 2, the data storage platform organization method of this embodiment when a node joins the cluster includes the following steps:
S201,对于节点数量为N的一个集群,各个节点的地址编号为0~N-1,如果有新节点加入该集群,将哈希表长度扩展为N+1,新节点的地址编号记为N。S201, for a cluster with N nodes, the address number of each node is 0-N-1, if a new node joins the cluster, the length of the hash table is extended to N+1, and the address number of the new node is recorded as N .
S202,增加用来记录数据迁移情况的哈希表分裂指针,将哈希表分裂指针指向的节点上的部分数据迁移到地址编号为N的新节点上。S202. Add a hash table split pointer used to record the data migration situation, and migrate part of the data on the node pointed to by the hash table split pointer to a new node whose address number is N.
图3示出本发明的哈希表组织原理示意图。如图3所示,本发明只需迁移一个节点上的数据,可以将大约一半的数据迁移到新节点。FIG. 3 shows a schematic diagram of the organization principle of the hash table in the present invention. As shown in Figure 3, the present invention only needs to migrate the data on one node, and can migrate about half of the data to the new node.
S203,哈希表分裂指针后移一位,指向下一个节点。S203, the hash table split pointer is moved backward by one bit to point to the next node.
S204,增加用来记录集群总体规模的哈希表位数计数器,更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整。S204, increase the hash table digit counter used to record the overall size of the cluster, and update the value of the hash table digit counter Among them, d represents the value of the hash table bit counter, Indicates rounding up.
基于图2所示的数据存储平台组织方法,当用户请求访问键值为k的数据时,如图4所示,该方法还包括以下步骤:Based on the data storage platform organization method shown in Figure 2, when a user requests access to data with a key value of k, as shown in Figure 4, the method further includes the following steps:
S401,根据H(k)=n计算k的哈希值。S401. Calculate the hash value of k according to H(k)=n.
其中,H表示哈希函数,k表示欲访问数据的键值,n表示计算出的哈希值。在本发明中,无需更换哈希函数,哈希函数的取值范围可以表示为0~2m-1,哈希函数的取值范围(或者说m)足够大,可以确保无论集群如何扩展,节点地址编号都不会超出这范围,即哈希函数的取值范围大于集群中节点的地址编号的范围。截取哈希函数的后若干位为哈希输出,截取位数视情况而定,下面具体说明。Among them, H represents the hash function, k represents the key value of the data to be accessed, and n represents the calculated hash value. In the present invention, there is no need to replace the hash function, the value range of the hash function can be expressed as 0 to 2 m -1, and the value range (or m) of the hash function is large enough to ensure that no matter how the cluster expands, The node address numbers will not exceed this range, that is, the value range of the hash function is greater than the range of the address numbers of the nodes in the cluster. The last few bits of the hash function are intercepted as the hash output, and the number of intercepted bits depends on the situation, which is explained in detail below.
S402,获取哈希表位数计数器的值d。S402. Obtain the value d of the digit counter of the hash table.
S403,截取n的后d位得到n’。S403, intercepting the last d bits of n to obtain n'.
S404,截取n的后d-1位得到n”。S404, intercepting the last d-1 digits of n to obtain n".
S405,比较哈希表分裂指针与地址编号n”的位置;S405, compare the location of the hash table split pointer and the address number n";
S405a,如果地址编号为n”的节点在哈希表分裂指针之后,将请求定位到地址编号为n”的节点;S405a, if the node with the address number n" locates the request to the node with the address number n" after the hash table split pointer;
S405b,如果地址编号为n”的节点在哈希表分裂指针之前,将请求定位到地址编号为n’的节点。S405b, if the node with the address number n" is before the hash table split pointer, locate the request to the node with the address number n'.
为了使本发明的方案更加清楚,下面列举一个有节点加入集群时哈希表组织方法以及用户访问数据的示例。本领域技术人员可以理解,在这里示出和讨论的所有示例中,任何具体值应被解释为仅仅是示例性的,而不是作为限制。因此,示例性实施例的其它示例可以具有不同的值。In order to make the solution of the present invention more clear, an example of a hash table organization method and a user accessing data when a node joins the cluster is listed below. It will be appreciated by those skilled in the art that in all examples shown and discussed herein, any specific values should be construed as exemplary only and not as limiting. Therefore, other examples of the exemplary embodiment may have different values.
图5为本发明有节点加入集群时的数据存储平台组织过程示意图。FIG. 5 is a schematic diagram of the organization process of the data storage platform when nodes join the cluster in the present invention.
假设集群有4个节点,各节点的地址编号依次为00、01、10、11,哈希表分裂指针初始位置指向地址编号为00的节点,此时哈希表位数计数器的值d为2。Assuming that the cluster has 4 nodes, the address numbers of each node are 00, 01, 10, and 11 in sequence, and the initial position of the hash table split pointer points to the node with address number 00. At this time, the value d of the hash table digit counter is 2 .
如有新节点加入集群,扩展哈希表长度到5,记录该新节点的编号为3位二进制的100,由于哈希表分裂指针初始位置指向地址编号为00的节点,因此,将节点00上相应的数据迁移到节点100,节点00上的数据大概有一半迁移到节点100,剩下的仍在00上,哈希表分裂指针后移,指向节点01,此时哈希表位数计数器的值d为3。由于哈希函数输出长度边长,节点00的地址编号变为000。If a new node joins the cluster, extend the length of the hash table to 5, and record the number of the new node as 3-digit binary 100. Since the initial position of the split pointer of the hash table points to the node with address number 00, the node 00 The corresponding data is migrated to node 100. About half of the data on node 00 is migrated to node 100, and the rest is still on node 00. The hash table split pointer moves backwards to point to node 01. At this time, the number of digits in the hash table counter The value d is 3. Since the output length of the hash function is long, the address number of node 00 becomes 000.
如再有新节点加入集群,则该新节点序号为101,由于此时哈希表分裂指针指向节点01,因此,将节点01上的相应数据迁移到节点101,节点01上的数据大概有一半迁移到节点101,哈希表分裂指针后移,指向节点10,此时哈希表位数计数器的值d仍为3。同理,节点01的地址编号变为001。If a new node joins the cluster, the serial number of the new node is 101. Since the hash table split pointer points to node 01 at this time, the corresponding data on node 01 is migrated to node 101, and the data on node 01 is about half Migrating to node 101, the split pointer of the hash table moves backwards to point to node 10, and the value d of the bit counter of the hash table is still 3 at this time. Similarly, the address number of node 01 becomes 001.
如再有新节点加入集群,以此类推,直到节点11分裂完毕,然后哈希表分裂指针回位到000,此时所有节点都已经过一轮分裂,所有节点地址编号都是3位。If a new node joins the cluster again, and so on, until node 11 is split, then the hash table split pointer returns to 000. At this time, all nodes have gone through a round of split, and all node address numbers are 3 digits.
在用户请求访问键值为k的数据时,系统先求H(k)=n,再取位数计数器的值d,截取n的后d位得到n’,n’的后d-1位称为n”;再看分裂指针,如n”在分裂指针之后,则直接将该数据请求定位到n”节点,如n’’在分裂指针之前,则将请求定位到n’节点。When the user requests to access data with key value k, the system first calculates H(k)=n, then takes the value d of the digit counter, intercepts the last d digits of n to obtain n', and the last d-1 digits of n' are called is n”; look at the split pointer, if n” is after the split pointer, then directly locate the data request to the n” node, if n’’ is before the split pointer, then locate the request to the n’ node.
图6为本发明有节点离开集群时的数据存储平台组织方法的流程示意图。FIG. 6 is a schematic flowchart of the method for organizing a data storage platform when a node leaves the cluster according to the present invention.
如图6所示,本实施例在有节点离开集群时的数据存储平台组织方法包括以下步骤:As shown in Figure 6, the data storage platform organization method of this embodiment when a node leaves the cluster includes the following steps:
S601,对于节点数量为N+1的一个集群,如果哈希表最末端的地址编号为N的节点离开该集群,哈希表分裂指针前移一位,指向上一个节点;S601, for a cluster with the number of nodes being N+1, if the node whose address number is N at the end of the hash table leaves the cluster, the split pointer of the hash table is moved forward by one bit to point to the previous node;
S602,更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整;S602, update the value of the bit counter of the hash table Among them, d represents the value of the hash table bit counter, Indicates rounding up;
S603,将地址编号为N的节点上的所有数据迁移到哈希表分裂指针指向的节点;S603, migrating all the data on the node whose address number is N to the node pointed to by the split pointer of the hash table;
S604,将哈希表长度缩小为N。S604. Reduce the length of the hash table to N.
基于图6所示的数据存储平台组织方法,用户请求访问键值为k的数据的处理处理可以参考图4所示实施例,这里仅简单概述。用户请求访问键值为k的数据时,根据H(k)=n计算k的哈希值,H表示哈希函数,n表示计算出的哈希值;获取哈希表位数计数器的值d;截取n的后d位得到n’;截取n的后d-1位得到n”;比较哈希表分裂指针与地址编号n”的位置,如果地址编号为n”的节点在哈希表分裂指针之后,将请求定位到地址编号为n”的节点,如果地址编号为n”的节点在哈希表分裂指针之前,将请求定位到地址编号为n’的节点。Based on the data storage platform organization method shown in FIG. 6 , the processing of the user's request to access data with a key value of k may refer to the embodiment shown in FIG. 4 , which is only briefly outlined here. When a user requests to access data with a key value of k, calculate the hash value of k according to H(k)=n, where H represents the hash function and n represents the calculated hash value; obtain the value d of the digit counter of the hash table ; Intercept the last d bits of n to get n'; intercept the last d-1 bits of n to get n"; compare the hash table split pointer with the position of address number n", if the node with address number n" is split in the hash table After the pointer, locate the request to the node with the address number n", if the node with the address number n" is before the hash table split pointer, locate the request to the node with the address number n'.
由此可见,本发明提出的数据存储平台组织方案,扩展了哈希表的结构和地址映射模式,在有新的节点加入集群时,保持键值和地址间原有的映射不变,只是扩展地址的有效位数和哈希表长度,将新产生的地址赋予新节点,并在保持系统运行的同时逐渐迁移数据;同理,在有节点离开集群时,保持键值和地址间原有的映射不变,只是收缩地址的有效位数和哈希表长度,并在保持系统运行的同时逐渐迁移数据。这种组织方法,既保留了通过哈希表组织云集群的实时性高的优点,又使集群易于维护和扩展。本发明的数据存储平台适用于所有云存储平台,特别是对实时性要求较高、运行在内存数据库上的计费或流量控制等业务平台。It can be seen that the data storage platform organization scheme proposed by the present invention expands the structure of the hash table and the address mapping mode. The effective number of bits of the address and the length of the hash table, assign the newly generated address to the new node, and gradually migrate the data while keeping the system running; similarly, when a node leaves the cluster, keep the original key value and address The mapping is unchanged, only the effective number of bits of the address and the length of the hash table are shrunk, and the data is gradually migrated while keeping the system running. This organization method not only retains the high real-time advantages of organizing cloud clusters through hash tables, but also makes the clusters easy to maintain and expand. The data storage platform of the present invention is applicable to all cloud storage platforms, especially service platforms such as billing or flow control that have high real-time requirements and run on memory databases.
基于前述数据组织方法,本发明还提出一种相应的数据存储平台。图7为本发明数据存储平台一个实施例的结构示意图。如图7所示,本实施例的数据存储平台包括:节点加入处理单元701或/和节点离开处理单元702。Based on the foregoing data organization method, the present invention also proposes a corresponding data storage platform. Fig. 7 is a schematic structural diagram of an embodiment of the data storage platform of the present invention. As shown in FIG. 7 , the data storage platform of this embodiment includes: a node joining processing unit 701 or/and a node leaving processing unit 702 .
节点加入处理单元701对于节点数量为N的一个集群,如果有新节点加入该集群,将哈希表长度扩展为N+1,新节点的地址编号记为N;将哈希表分裂指针指向的节点上的部分数据迁移到地址编号为N的新节点上;哈希表分裂指针后移一位,指向下一个节点;更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整。The node joining processing unit 701 is a cluster whose number of nodes is N, if a new node joins the cluster, the length of the hash table is expanded to N+1, and the address number of the new node is recorded as N; Part of the data on the node is migrated to the new node with the address number N; the split pointer of the hash table is shifted by one bit to point to the next node; the value of the bit counter of the hash table is updated Among them, d represents the value of the hash table bit counter, Indicates rounding up.
节点离开处理单元702对于节点数量为N+1的一个集群,如果哈希表最末端的地址编号为N的节点离开该集群,哈希表分裂指针前移一位,指向上一个节点;更新哈希表位数计数器的值其中,d表示哈希表位数计数器的值,表示向上取整;将地址编号为N的节点上的所有数据迁移到哈希表分裂指针指向的节点;将哈希表长度缩小为N。Node leaving processing unit 702 For a cluster with the number of nodes being N+1, if the node whose address number is N at the end of the hash table leaves the cluster, the split pointer of the hash table moves forward by one bit, pointing to the previous node; update the hash table The value of the Greek table bit counter Among them, d represents the value of the hash table bit counter, Indicates rounding up; migrate all data on the node whose address number is N to the node pointed to by the split pointer of the hash table; reduce the length of the hash table to N.
图8为本发明数据存储平台再一个实施例的结构示意图。如图8所示,本实施例的数据存储平台还包括:Fig. 8 is a schematic structural diagram of another embodiment of the data storage platform of the present invention. As shown in Figure 8, the data storage platform of this embodiment also includes:
数据访问处理单元803,用于用户请求访问键值为k的数据时,根据H(k)=n计算k的哈希值,H表示哈希函数,n表示计算出的哈希值;获取哈希表位数计数器的值d;截取n的后d位得到n’;截取n的后d-1位得到n”;比较哈希表分裂指针与地址编号n”的位置,如果地址编号为n”的节点在哈希表分裂指针之后,将请求定位到地址编号为n”的节点,如果地址编号为n”的节点在哈希表分裂指针之前,将请求定位到地址编号为n’的节点。The data access processing unit 803 is used to calculate the hash value of k according to H(k)=n when the user requests to access the data whose key value is k, H represents the hash function, and n represents the calculated hash value; The value d of the table digit counter; intercept the last d digits of n to obtain n'; intercept the last d-1 digits of n to obtain n"; compare the position of the hash table split pointer with the address number n", if the address number is n After the hash table splits the pointer, the node with the address of "n" locates the request to the node with the address number n". .
其中,哈希函数的取值范围可以表示为0~2m-1,哈希函数的取值范围(或者说m)足够大,可以确保无论集群如何扩展,节点地址编号都不会超出这范围,即哈希函数的取值范围大于集群中节点的地址编号的范围。Among them, the value range of the hash function can be expressed as 0 to 2 m -1, and the value range (or m) of the hash function is large enough to ensure that no matter how the cluster expands, the node address number will not exceed this range , that is, the value range of the hash function is greater than the range of the address numbers of the nodes in the cluster.
前述数据存储平台例如可以是云存储平台,或者是其他实时性要求较高、运行在内存数据库上的计费或流量控制等业务平台。The aforementioned data storage platform may be, for example, a cloud storage platform, or other service platforms that require high real-time performance and run on an in-memory database such as accounting or traffic control.
本发明提出的数据存储平台,扩展了哈希表的结构和地址映射模式,在有新的节点加入集群时,保持键值和地址间原有的映射不变,只是扩展地址的有效位数和哈希表长度,将新产生的地址赋予新节点,并在保持系统运行的同时逐渐迁移数据;同理,在有节点离开集群时,保持键值和地址间原有的映射不变,只是收缩地址的有效位数和哈希表长度,并在保持系统运行的同时逐渐迁移数据。这种组织方法,既保留了通过哈希表组织云集群的实时性高的优点,又使集群易于维护和扩展。本发明的数据存储平台适用于所有云存储平台,特别是对实时性要求较高、运行在内存数据库上的计费或流量控制等业务平台。The data storage platform proposed by the present invention expands the structure of the hash table and the address mapping mode. When a new node joins the cluster, the original mapping between the key value and the address remains unchanged, and only the effective digits and The length of the hash table, assign the newly generated address to the new node, and gradually migrate the data while keeping the system running; similarly, when a node leaves the cluster, keep the original mapping between the key value and the address unchanged, just shrink The effective number of bits of the address and the length of the hash table, and gradually migrate the data while keeping the system running. This organization method not only retains the high real-time advantages of organizing cloud clusters through hash tables, but also makes the clusters easy to maintain and expand. The data storage platform of the present invention is applicable to all cloud storage platforms, especially service platforms such as billing or flow control that have high real-time requirements and run on memory databases.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, and can also be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, and the like.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection of the present invention. within range.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310430856.8A CN104462124B (en) | 2013-09-22 | 2013-09-22 | Data storing platform method for organizing and data storing platform based on linear Hash table |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310430856.8A CN104462124B (en) | 2013-09-22 | 2013-09-22 | Data storing platform method for organizing and data storing platform based on linear Hash table |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104462124A CN104462124A (en) | 2015-03-25 |
CN104462124B true CN104462124B (en) | 2018-04-06 |
Family
ID=52908182
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310430856.8A Active CN104462124B (en) | 2013-09-22 | 2013-09-22 | Data storing platform method for organizing and data storing platform based on linear Hash table |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104462124B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106909557B (en) * | 2015-12-23 | 2020-06-16 | 中国电信股份有限公司 | Memory cluster storage method and device and memory cluster reading method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101676855A (en) * | 2008-09-11 | 2010-03-24 | 美国日本电气实验室公司 | Scalable secondary storage systems and methods |
CN102457428A (en) * | 2010-10-27 | 2012-05-16 | 中兴通讯股份有限公司 | Load balancing realization method and device for DHT (distributed Hash table) network |
CN102521304A (en) * | 2011-11-30 | 2012-06-27 | 北京人大金仓信息技术股份有限公司 | Hash based clustered table storage method |
CN103150394A (en) * | 2013-03-25 | 2013-06-12 | 中国人民解放军国防科学技术大学 | Distributed file system metadata management method facing to high-performance calculation |
CN103229151A (en) * | 2012-12-27 | 2013-07-31 | 华为技术有限公司 | Partition extension method and device |
-
2013
- 2013-09-22 CN CN201310430856.8A patent/CN104462124B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101676855A (en) * | 2008-09-11 | 2010-03-24 | 美国日本电气实验室公司 | Scalable secondary storage systems and methods |
CN102457428A (en) * | 2010-10-27 | 2012-05-16 | 中兴通讯股份有限公司 | Load balancing realization method and device for DHT (distributed Hash table) network |
CN102521304A (en) * | 2011-11-30 | 2012-06-27 | 北京人大金仓信息技术股份有限公司 | Hash based clustered table storage method |
CN103229151A (en) * | 2012-12-27 | 2013-07-31 | 华为技术有限公司 | Partition extension method and device |
CN103150394A (en) * | 2013-03-25 | 2013-06-12 | 中国人民解放军国防科学技术大学 | Distributed file system metadata management method facing to high-performance calculation |
Also Published As
Publication number | Publication date |
---|---|
CN104462124A (en) | 2015-03-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10013317B1 (en) | Restoring a volume in a storage system | |
CN107423368B (en) | Spatio-temporal data indexing method in non-relational database | |
CN102567495B (en) | Mass information storage system and implementation method | |
CN103020315B (en) | A kind of mass small documents storage means based on master-salve distributed file system | |
US10140351B2 (en) | Method and apparatus for processing database data in distributed database system | |
US20130262758A1 (en) | Systems and Methods for Tracking Block Ownership | |
CN103838770A (en) | Logic data partition method and system | |
CN104077423A (en) | Consistent hash based structural data storage, inquiry and migration method | |
US10789228B2 (en) | Data presence/absence determination apparatus and computer-readable storage medium storing program for determination of data presence/absence | |
CN103294785B (en) | A kind of packet-based metadata server cluster management method | |
CN109933312B (en) | A method to effectively reduce the I/O consumption of containerized relational databases | |
CN104111924A (en) | Database system | |
CN103150122A (en) | Method and device for managing disk cache space | |
CN103049574B (en) | Realize key assignments file system and the method for file dynamic copies | |
CN110109873A (en) | A kind of file management method for message queue | |
WO2016070341A1 (en) | Data processing method and apparatus | |
CN108628969A (en) | Spatial keyword indexing method and platform and storage medium | |
CN104462124B (en) | Data storing platform method for organizing and data storing platform based on linear Hash table | |
EP4462278A1 (en) | Method, apparatus, device, and storage medium for data processing of graph database | |
WO2019174558A1 (en) | Data indexing method and device | |
CN103780692A (en) | Data access method and system for key value storage | |
CN106293537B (en) | A lightweight approach to autonomous block management for data-intensive file systems | |
US12182201B2 (en) | Graph data storage method, system and electronic device | |
CN104978327A (en) | Data query method, management control node and target data node | |
CN114969110A (en) | Query method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
EE01 | Entry into force of recordation of patent licensing contract |
Application publication date: 20150325 Assignee: Tianyiyun Technology Co.,Ltd. Assignor: CHINA TELECOM Corp.,Ltd. Contract record no.: X2024990000687 Denomination of invention: Organizational method and data storage platform based on linear hash table for data storage platform Granted publication date: 20180406 License type: Common License Record date: 20241220 |
|
EE01 | Entry into force of recordation of patent licensing contract |