A kind of method and system saving data
Technical field
The present invention relates to data processing and technical field of memory more particularly to a kind of method and system for saving data.
Background technique
With the development of internet technology, the data for storing and applying in internet are increasingly longer, for example, UGC class application
The mainstream of current internet is increasingly becomed, microblogging, social networks, blog are all that UGC class is mainly applied.These applications are often gathered around
There are mass users, stores the UGC data of magnanimity.In such applications, for certain special users, certain class data may be non-
Chang Duo, it grows very much, for example in microblogging application, the bean vermicelli list (listening to the other users list of the user) of any active ues can be non-
Often long, the number of fans of some any active ues is even more than 1 hundred million.
The storage scheme of existing data is to store in the database mostly, and every table safeguards one group of long data, such as will
Someone bean vermicelli information establishes a table, and table name is distinguished with the Key of user.When the external world reads these data, backstage is needed to deposit
Storage services type according to different requests, is ranked up data different field (such as according to time sequence, by place sequence, by word
Female size sequence etc.), the data that extraneous request is read are searched, result is returned again to;Calculation amount therein is bigger, to request
Have biggish time delay.
More complete scheme can build multiple hot standby databases, and a master writes a little, multiple standby read points, realization pair
The shunting of request.This mode is when reading data, it is also desirable to storing data is ranked up, equally exist it is computationally intensive and
Be delayed larger problem, therefore extraneous slower to the access speed of data.
Summary of the invention
The present invention provides a kind of date storage methods, can be improved the access speed of data.
The present invention also provides a kind of data-storage systems, can be improved the access speed of data.
The technical scheme of the present invention is realized as follows:
A kind of date storage method, comprising:
Multiple backup points are set for a data, each backup point carries out this part of data according to respective ordering rule
It sorts and saves;Wherein, at least one backup point is full backup point, saves the full content of this part of data;Other backup points
For incremental backup point, the partial content of this part of data is saved.
In the above method, when access layer receives the newly-increased request for this part of data, modification request or removal request,
The newly-increased request, modification request or removal request are sent to each backup point;Each backup point is according to respective row
Sequence rule, increases, modifies or deletes this part of data.
It wherein, will be newly-increased according to the keyword (Key) of newly-increased data when full backup point increases this part of data newly
Data are added to suitable position and save, or update original data;
When the incremental backup point increases this part of data newly, it is standby to judge whether the Key of newly-increased data belongs to the part
The range of the Key of part point stored data, if it is, the suitable position of newly-increased data is searched according to the Key of newly-increased data, it will
Newly-increased data are added to suitable position and save, or update original data.
When each backup point is modified or deleted to this part of data, according to respective ordering rule and modification or deletion
The data are modified or are deleted by the data that the Key of data finds request modification or deletes;
For incremental backup point, if the data volume deleted is more than preset threshold value, from the full backup
Point extracts new data and preservation.
In the above method, when access layer receives the read requests for this part of data, according to the read requests
The read requests are forwarded to corresponding backup point by ordering rule;The corresponding backup point is by the data feedback of reading to connecing
Enter layer.
A kind of data-storage system, system include access layer and multiple backup points;Wherein,
For a data, each backup point is ranked up and protects to this part of data according to respective ordering rule
It deposits;Wherein, at least one backup point is full backup point, saves the full content of this part of data;Other backup points are that part is standby
Part point, saves the partial content of this part of data.
The access layer is used for, will when receiving the newly-increased request for a data, modification request or removal request
The newly-increased request, modification request or removal request are sent to each backup point for saving this part of data;
Each backup point increases, modifies or deletes this part of data according to respective ordering rule.
Wherein, when full backup point increases this part of data newly, newly-increased data are added according to the Key of newly-increased data
It to suitable position and saves, or updates original data;
When the incremental backup point increases this part of data newly, it is standby to judge whether the Key of newly-increased data belongs to the part
The range of the Key of part point stored data, if it is, the suitable position of newly-increased data is searched according to the Key of newly-increased data, it will
Newly-increased data are added to suitable position and save, or update original data.
When each backup point is modified or deleted to this part of data, according to respective ordering rule and modification or deletion
The data are modified or are deleted by the data that the Key of data finds request modification or deletes;
For incremental backup point, if the data volume deleted is more than preset threshold value, from the full backup
Point extracts new data and preservation.
Access layer is also used to, when receiving the read requests for a data, according to the sequence of the read requests
The read requests are forwarded to corresponding backup point by rule;
The corresponding backup point is by the data feedback of reading to access layer
As it can be seen that date storage method proposed by the present invention and system, same part data are stored in multiple backup points, each
Backup point is ranked up data according to respective ordering rule, and this avoid the sequence calculating when reading data, realizes
The quick access of the same multiple dimensions of part data, improves the flexibility and responding ability of the long data storage service of magnanimity.
Detailed description of the invention
Fig. 1 is data storage system architecture schematic diagram proposed by the present invention;
Fig. 2 is that the message of the embodiment of the present invention one flows to schematic diagram;
Fig. 3 is that the message of the embodiment of the present invention two flows to schematic diagram.
Specific embodiment
The present invention proposes a kind of date storage method and system, if Fig. 1 is data storage system architecture proposed by the present invention
Schematic diagram, system proposed by the present invention are divided into upper layer and lower layer, accumulation layer and access layer.For same part data, set in accumulation layer
Multiple backup points are set, each backup point is ranked up and saves to this part of data according to respective ordering rule;Wherein, at least one
A backup point is full backup point, saves the full content of this part of data;Other backup points are incremental backup point, save the number
According to partial content.
The read and write access of extraneous all pairs of accumulation layers is both needed to be forwarded to accumulation layer by access layer, and access layer perceives accumulation layer
Backup point number and each backup point ordering rule.The ordering rule of each backup point is different.Each backup point storage
Data be not necessarily required to full dose, can be a part of data therein, but at least one backup data be full dose.
For example, temporally sorting from the near to the distant in backup point 1 for same part data, 1000 datas are stored;In backup point 2
It sorts by user's name, stores full dose data;It sorts in backup point 3 by user integral, stores 10,000 datas.Except full dose is standby
Other than part point, the maximum amount of data of other backup points storage is determined by the object of its service.It is needed when the later period extends new sequence
When asking, the corresponding configuration of access layer only need to be changed, and in addition build a set of new backup point.
In the manner described above after storing data, for extraneous different types of request, the present invention uses different processing
Mode.Below referring to attached drawing, lifts specific embodiment and be discussed in detail.
Embodiment one:
In the present embodiment, handle from extraneous newly-increased request, modification request or removal request.If Fig. 2 is this
The message of inventive embodiments one flows to schematic diagram.Access layer receives the newly-increased request for a data, modification request or deletes
When except request, the newly-increased request, modification request or removal request are sent to each backup point of this part of message;Each backup
After point receives request, according to respective ordering rule, this part of data are increased, modified or deleted.
Wherein, for newly-increased request, the newly-increased data of request are added to by each backup point according to respective ordering rule
Suitable position simultaneously saves, or updates original data.In full backup point, suitable position is inserted data into according to its Key
It sets.On incremental backup point, if the Key of newly-increased data belongs to the range of the Key of the incremental backup point stored data, press
Newly-increased data are added to suitable position and saved by the suitable position that newly-increased data are searched according to the Key of newly-increased data, or
Update original data;If the sequence Key of newly-increased data is more than the maximum or minimum k ey of existing sorting data, it is not necessarily to
Insertion is (if original data are compared according to permutation with positive order (from small to large) with maximum key and the key of newly-increased data;If
Data originally are then compared with the key of minimum k ey and newly-increased data according to reversing (from big to small)).
It is requested for modification, each backup point finds request according to the Key of respective ordering rule and the data of modification and repairs
The data changed modify to the data.
For removal request, each backup point finds request according to the Key of respective ordering rule and the data of deletion and deletes
The data removed delete the data.On incremental backup point, if deleting data volume is more than that preset threshold value (is such as more than
50%) it, then needs to pull new data and preservation from full backup point, fills the incremental backup point.
It,, can be with so using general binary chop since data volume is less for incremental backup point when searching data
It realizes and quickly searches.It, can be using the mechanism for allocating data segment in advance since data volume is huger for full backup point.
For example, splitting data into N number of section as segmentation basis using user id.Using id%N as segment number.Again by user's in each section
Id sorts.When queried, segment number is determined first with user id%N, then do binary chop in section again, find user.
Embodiment two:
In the present embodiment, handle from extraneous read requests.Access layer receives a variety of external read requests, this
A little read passes through access layer, is uniformly converted to the order that data are read from accumulation layer.These external read requests are according to accumulation layer
The various ordering rules that are capable of providing determine.Access layer is by these external read requests and corresponding accumulation layer backup point pair
It answers, therefore access layer is capable of determining that the ordering rule of read requests, and read requests are sent to the standby of identical ordering rule
Part point;After the backup point receives request, access layer is fed data back to, requestor is returned data to by access layer.
Message if Fig. 3 is the embodiment of the present invention two flows to schematic diagram.When access layer receives the reading for a data
When taking request, which is forwarded to by corresponding backup point according to the ordering rule of read requests;Corresponding backup point will
The data feedback of reading is to access layer.
The present invention also proposes a kind of data-storage system, including access layer and multiple backup points;Wherein,
For a data, each backup point is ranked up and protects to this part of data according to respective ordering rule
It deposits;Wherein, at least one backup point is full backup point, saves the full content of this part of data;Other backup points are that part is standby
Part point, saves the partial content of this part of data.
Above-mentioned access layer is used for, will when receiving the newly-increased request for a data, modification request or removal request
The newly-increased request, modification request or removal request are sent to each backup point for saving this part of data;
Each backup point increases, modifies or deletes this part of data according to respective ordering rule.
Wherein, when full backup point increases this part of data newly, number that will be newly-increased according to the keyword Key of newly-increased data
According to being added to suitable position and save, or update original data;
When the incremental backup point increases this part of data newly, it is standby to judge whether the Key of newly-increased data belongs to the part
The range of the Key of part point stored data, if it is, the suitable position of newly-increased data is searched according to the Key of newly-increased data, it will
Newly-increased data are added to suitable position and save, or update original data.
When each backup point is modified or deleted to this part of data, according to respective ordering rule and modification or deletion
The data are modified or are deleted by the data that the Key of data finds request modification or deletes;
For incremental backup point, if the data volume deleted is more than preset threshold value, from the full backup
Point extracts new data and preservation.
Above-mentioned access layer is also used to, when receiving the read requests for a data, according to the read requests
The read requests are forwarded to corresponding backup point by ordering rule;
The corresponding backup point is by the data feedback of reading to access layer.
To sum up, the present invention saves same part data in multiple backup points by the way of space for time,
Each backup point is ranked up data according to respective ordering rule, and the mistake of data is write due to having advanceed to the pressure of sequence
Cheng Zhong, therefore the reading performance of system is largely improved, improve the response speed of system.Also, the present invention proposes
System can with fast construction rise a set of new sorting data, to meet the needs of extraneous.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the present invention.