The content of the invention
To solve above-mentioned technical problem present in prior art, the present invention proposes a kind of method that big data effectively stores
And device.
The method that a kind of big data proposed by the present invention effectively stores, including:
Step S100, treat data storage and pre-processed;The data to be stored are packaged into object data, it is described right
The attribute information of object data is added with image data, the attribute information includes the data type of object data;
Step S200, object data is received, the data type of object data is determined according to the attribute information of object data;
Step S300, object data is stored into different memory cell according to the data type of object data.
Wherein, the data type of the object data described in step S100 include structural data, semi-structured data and
Unstructured data;Different memory cell described in step S300 include HDFS distributed file systems unit, HBase numbers
According to library unit and relation data library unit;Wherein, HDFS distributed file systems unit is used to store unstructured data,
HBase Database Unit is used to store semi-structured data, and relational database is used for structured data.
Wherein, the object data being packaged in step S100 has unified data operating interface, and the data manipulation connects
Mouth receives the operation to object data;
Different memory cell has respective data manipulation resolution unit respectively, and the data for receiving object data are grasped
Make the data manipulation of interface transmission, and the data manipulation is parsed, the data manipulation that data operating interface is sent turns
It is changed to the operation that this memory cell can perform.
Wherein, using the incidence relation between tree conservation object data, on the one hand, each node of tree
The link for pointing to an object data is saved, i.e., tree, which does not have, stores actual object data, the section of tree
Point and object data are one-to-one relations, and on the other hand, the relation between tree father and son's node illustrates number of objects
Corresponding relation between.
The method that big data proposed by the present invention effectively stores, further comprises:
Step S400, the object data in each memory cell is synchronized, the number of objects for synchronously referring to client
According to synchronous between the object data of server end.
The method that big data proposed by the present invention effectively stores, further comprises:
Include real-time synchronization mark in the attribute information of object data, when client synchronizes, detect net first
Network environment, if message transmission rate is more than first threshold, real-time synchronization is carried out, if message transmission rate is not more than first
The real-time synchronization mark of threshold value, then detection object data, if real-time synchronization is masked as "Yes", real-time synchronization is carried out, if
Real-time synchronization is masked as "No", then is temporarily carried out again when waiting message transmission rate to be more than specified threshold without real-time synchronization
Simultaneously operating.
The method that big data proposed by the present invention effectively stores, further comprises:
In the case of non real-time synchronous, two kinds of synchronization process modes are included when synchronizing, one kind is fully synchronized
Mode, that is, do not have to consider whether single object data needs synchronization, whole object datas are synchronized, another kind is that increment is same
Step mode, i.e., it is only synchronous to need synchronous object data, that is, the object data changed;In simultaneously operating, pass through synchronous side
Formula judges that the method for synchronization judges to include to determine to use increment synchronization mode or fully synchronized mode:It is all right to judge
The earliest lock in time of image data, when the difference of earliest lock in time and current time is more than Second Threshold, then using all same
Step mode.
The invention also provides the device that a kind of big data effectively stores, including:
Pretreatment module, pre-processed for treating data storage;The data to be stored are packaged into object data,
The attribute information of object data is added with the object data, the attribute information includes the data type of object data;
Receiving module, object data is received, the data type of object data is determined according to the attribute information of object data;
Memory module, object data is stored into different memory cell according to the data type of object data.
The method and apparatus that a kind of big data proposed by the present invention effectively stores, distinguish by using different memory cell
The data of different types of data are stored, so as to play the storage advantage of different memory cell.By way of object data
The data of different types of data are packaged, and unified data operating interface is provided, it is possible to achieve to different memory cell
In data unified operation.By the object data in tree tissue difference memory cell, can conveniently operate discrete
Object data.
Embodiment
Below in conjunction with the accompanying drawing of the present invention, technical scheme is clearly and completely described.Here will be detailed
Carefully exemplary embodiment is illustrated, its example is illustrated in the accompanying drawings.In the following description when referring to the accompanying drawings, unless otherwise table
Show, the same numbers in different accompanying drawings represent same or analogous key element.Embodiment party described in following exemplary embodiment
Formula does not represent all embodiments consistent with the present invention.On the contrary, they are only detailed with institute in such as appended claims
The example of the consistent apparatus and method of some aspects stating, of the invention.
Referring to Fig. 1, method that a kind of big data proposed by the present invention effectively stores, including:
Step S100, treat data storage and pre-processed;The data to be stored are packaged into object data, it is described right
The attribute information of object data is added with image data, the attribute information includes the data type of object data;
Data to be stored can be various types of data, structural data, semi-structured data, unstructured data.
Treating the pretreatment of data storage includes analyzing and determining the data type of data to be stored.Data to be stored are packaged into object
Data, and the data type of data to be stored is added in the attribute information of object data, that is, pass through the attribute of object data
Information is that can determine that the data type of object data.
Step S200, object data is received, the data type of object data is determined according to the attribute information of object data;
The data type of the object data included according to the attribute information of object data, it may be determined that the number of object data
It is structural data, semi-structured data or unstructured data according to type.
Step S300, object data is stored into different memory cell according to the data type of object data.
Further, the different memory cell described in step S300 include HDFS distributed file systems unit,
HBase Database Unit and relation data library unit;Wherein, HDFS distributed file systems unit is used to store unstructured number
According to HBase Database Unit is used to store semi-structured data, and relational database is used for structured data.
Further, the object data being packaged in step S100 has unified data operating interface, the data behaviour
Make operation of the interface to object data.Different memory cell has respective data manipulation resolution unit respectively, is used for
The data manipulation that the data operating interface of object data is sent is received, and the data manipulation is parsed, by data manipulation
The data manipulation that interface is sent is converted to the operation that this memory cell can perform.
Due to the architectural difference of different data types, the data of different types of data have in storage and inquiry operation
Different requirement, if all using single storage and querying method, the single storage to the data of different types of data
With querying method when favourable to a kind of operation of the data of data type, the operation to the data of another data type may
It is unfavorable.The method that a kind of big data proposed by the present invention effectively stores, to the data of different types of data, it can provide effectively
Storage and querying method.
The method that a kind of big data provided by the invention effectively stores, further comprises:Using tree conservation object
Incidence relation between data, on the one hand, each node of tree saves the link for pointing to an object data, that is, sets
Type structure, which does not have, stores actual object data, and node and the object data of tree are one-to-one relations, another
Aspect, the relation between tree father and son's node illustrate the corresponding relation between object data.Different memory cell are deposited
Storage is discrete data object, and tree is then associated these object datas, and the convenient application to data is grasped
Make.
The method that a kind of big data provided by the invention effectively stores, further comprises:
Step S400, the object data in each memory cell is synchronized.
In substantial amounts of the Internet, applications, server end safeguards a big data set, and each client is safeguarded greatly respectively
The a subset of data set, thus need to carry out the synchronization of data at client and server end.Respectively depositing in step S300
Storage unit is located at server end, and client and server end can safeguard to the object data in memory cell, such as
Increase, delete, modification, pass through the operation of log recording data.Client and server all must be capable of identify out that last time is same
After step (may be successful, it is also possible to failure), the data item to change, i.e. which data be modified, which number have been increased newly
According to this and delete which data.Here the concept of synchronous anchor is introduced, synchronous anchor is exactly server end with being protected during client synchronization
The timestamp deposited, it has indicated whether last synchronization is completed.
Before client initiates synchronization request for the first time, it will be this one synchronous anchor of subsynchronous generation, recorded in daily record,
And carry and client is sent in synchronization request.Received server-side by the anchor to recorded one and user-association after message
, using client id as the Hash table of key assignments in cached, while handle synchronization request, return to corresponding data.Return to number
According to when will carry the anchor value.After client receives server end return value, anchor value is compared with the anchor value in daily record, more
New local data base, and corresponding change daily record is labeled as having confirmed that.Before synchronization request next time, next anchor is generated
Value, and carry new anchor value respectively in synchronization request and (identified respectively with next and last) with upper one anchor value having confirmed that.
For received server-side to after new synchronization request, the last anchors in first confirmation request are identical with the anchor identification in server buffer
(i.e. client identifies transmission anchor information using last and is used as the feedback to server end), mark is last to be synchronously identified, so
Synchronizing information is handled according to previous step afterwards, old value is covered with new anchor value after having handled, so as to complete newly once
Synchronization.When server end finds the anchor value difference in last marks and current cache, refusal performs new synchronization request, and
Return to notice client.Equally, client only completes a synchronization request, and obtains just sending down after service end confirms
Synchronization request, so as to ensure synchronous timing.
In data syn-chronization, it is related to the real-time of data syn-chronization.In the Internet, applications environment, especially mobile Internet
Using, network environment varies, than if any wifi network and no wifi network, message transmission rate may differ by a lot,
And the expense spent in network transmission is also different.In order to meet the requirement of real-time of data syn-chronization, while it is further contemplated that with
The real network ambient conditions at family.
The present invention further includes real-time synchronization mark in the attribute information of object data, is synchronized in client
When, network environment is detected first, if message transmission rate is more than specified threshold, real-time synchronization is carried out, if data transfer
Speed is not more than specified threshold, then the real-time synchronization mark of detection object data, if real-time synchronization is masked as "Yes", carries out
Real-time synchronization, if real-time synchronization is masked as "No", temporarily without real-time synchronization, waits message transmission rate to be more than and specify
Operation is synchronized during threshold value again.
In data syn-chronization, it is also necessary to consider synchronous data volume.When network environment is poor, if synchronous data volume
It is more, then it can cause the increase of client device hydraulic performance decline and user's cost of use.In the case of non real-time synchronous, entering
Row may have multiple object datas to need synchronization when synchronous, at this moment there is two kinds of synchronization process modes, and one kind is fully synchronized mode,
Do not have to consider whether single object data needs synchronization, whole object datas are synchronized, another kind is increment synchronization side
Formula, i.e., it is only synchronous to need synchronous object data, that is, the object data changed.Obviously, the data transfer of increment synchronization mode
Amount is smaller, can save network bandwidth.But the premise of increment synchronization mode is to need which object data needs judged one by one
Synchronize, it is this to judge that spent overhead be very high when the object data changed is more, it is overall and
Speech, this cost may be higher than fully synchronized mode sometimes.
The present invention determines to use increment synchronization mode or fully synchronized in simultaneously operating by method of synchronization judgement
Mode, the method for synchronization judge to include:The earliest lock in time of all object datas is judged, when earliest lock in time and currently
The difference of time is more than specified threshold, then using fully synchronized mode.Earliest lock in time is talked about earlier, shows that the long period does not have
Synchronize operation, it is believed that need the object data that synchronizes more, at this moment directly take fully synchronized mode.By
In the earliest lock in time for only needing to judge object data, whether need to update without comparison other data one by one, so as to
Substantially reduce amount of calculation.
In addition, different Method of Data Organization, the influence for synchronization is also very big.Line number is entered to the father node of tree
It is corresponding to need to be updated all downstream sites belonging to the father node and their descendant node during according to renewal,
The downstream site includes the child node of the father node and the downstream site of child node.If the father node includes down
Level node is a lot, and the amount updated accordingly can be very big.In order to reduce this associated renewal as far as possible, the present invention is to tree
Node carry out Version Control, determine by the node of Version Control in tree, and by as root by Version Control
And it is not to be formed a updating block by all downstream sites of Version Control and their descendant node.
By the quantity for suitably determining the node by Version Control so that do not have it is expected that the data often to be updated are in those
Have or the updating block of only a small amount of downstream site among.It is single being formed renewal in a manner of the node by Version Control
Member, enable to the data of updating block to be arranged as required, can prevent the renewal of some node from sending out by this way
Transform into and updated for avalanche type.
Referring to Fig. 2, the invention also provides the device that a kind of big data effectively stores, including:
Pretreatment module, pre-processed for treating data storage;The data to be stored are packaged into object data,
The attribute information of object data is added with the object data, the attribute information includes the data type of object data;
Receiving module, object data is received, the data type of object data is determined according to the attribute information of object data;
Memory module, object data is stored into different memory cell according to the data type of object data.
The method and apparatus that a kind of big data proposed by the present invention effectively stores, distinguish by using different memory cell
The data of different types of data are stored, so as to play the storage advantage of different memory cell.By way of object data
The data of different types of data are packaged, and unified data operating interface is provided, it is possible to achieve to different memory cell
In data unified operation.By the object data in tree tissue difference memory cell, can conveniently operate discrete
Object data.
Those skilled in the art will readily occur to the present invention its after considering specification and putting into practice invention disclosed herein
Its embodiment.The application be intended to the present invention any modification, purposes or adaptations, these modifications, purposes or
Person's adaptations follow the general principle of the present invention and including undocumented common knowledges in the art of the invention
Or conventional techniques.
It should be appreciated that the invention is not limited in the precision architecture for being described above and being shown in the drawings, and
And various modifications and changes can be being carried out without departing from the scope.The scope of the present invention is only limited by appended claim.