Summary of the invention
The application's technical matters to be solved is to provide data processing in a kind of non-relational database and method and the device of inquiry, in order to improve the systematicness of non-relational data storage, improves the stability of operation; The data volume that expansion is supported, the cost of reduction operation maintenance.
In order to address the above problem, the application discloses the data processing method in a kind of non-relational database, described non-relational database comprises the distributed system of at least two units, described unit comprises at least two data minute storehouse, a described data minute storehouse comprises some data forms, a described data minute storehouse has data minute storehouse sign, and described data form has data form sign;
Described method comprises:
Generate the user ID of data to be stored, described data to be stored are the data that store into first in described distributed system;
Described data to be stored are write in the data form in a certain data minute storehouse, and divide storehouse sign and data form sign corresponding to described data form according to data corresponding to described data minute storehouse, generate target memory address;
Record the mapping relations of described user ID and target memory address.
Preferably, described data to be stored comprise user's characteristic information; The step of the user ID of described generation data to be stored comprises:
Extract user's characteristic information in described data to be stored;
Record the mapping of described user's characteristic information and preset storage sequence number, and described corresponding stored sequence number is designated as to user ID.
Preferably, in the described data form that data to be stored is write to a certain data minute storehouse, and divide storehouse sign and data form sign corresponding to described data form according to data corresponding to described data minute storehouse, the step that generates target memory address comprises:
Select not reach in a data minute storehouse data form of the preset number of users upper limit, generate target data form;
Described data to be stored are write to described target data form;
Divide the identifier combination in storehouse to generate target memory address the sign of described target data form and corresponding data.
Preferably, the described step that records the mapping relations of described user ID and target memory address comprises:
Set up and select described user ID to shine upon the key-value pair of described target memory address;
Record described key-value pair in map listing.
Preferably, described method also comprises:
Obtain user ID in data to be added; Described data to be added are to store in the corresponding target memory address of the built user ID of described distributed system, are the supplementary datas of built user ID;
According to described user ID inquiry, obtain target memory address;
Described data to be added are write to described target memory address.
Preferably, described method also comprises:
According to user ID, target memory address is obtained in inquiry, the corresponding data minute storehouse of pointing to and target data form, extracts the user data in described target memory address from target memory address.
Preferably, described data to be added comprise user's characteristic information; The described step of obtaining user ID in data to be added comprises:
Extract the user's characteristic information in described data to be added;
According to described user's characteristic information mapping, obtain corresponding stored sequence number, described corresponding stored sequence number is user ID.
Preferably, if a legacy data minute library storage load reaches the upper limit, increase the unit of described distributed system, and in described unit, set up new data minute storehouse.
Preferably, the data to be stored of the same user ID of described correspondence or data to be added are stored among a data form.
The embodiment of the present application also discloses the data processing equipment in a kind of non-relational database, described non-relational database comprises the distributed system of at least two units, described unit comprises at least two data minute storehouse, a described data minute storehouse comprises some data forms, a described data minute storehouse has data minute storehouse sign, and described data form has data form sign;
Described device comprises:
User ID generation module, for generating the user ID of data to be stored, described data to be stored are the data that store into first in described distributed system;
Target storing address generating module, for described data to be stored being write to the data form in a certain data minute storehouse, and divide storehouse sign and data form sign corresponding to described data form according to data corresponding to described data minute storehouse, generate target memory address;
Mapping relations logging modle, for recording the mapping relations of described user ID and target memory address.
Preferably, described data to be stored comprise user's characteristic information; Described user ID generation module comprises:
User's characteristic information extracts submodule, for extracting described data user's characteristic information to be stored;
User ID generates submodule, for recording the mapping of described user's characteristic information and preset storage sequence number, and described corresponding stored sequence number is designated as to user ID.
Preferably, described target storing address generating module comprises:
Target data form generates submodule, for selecting a data minute storehouse not reach the data form of the preset number of users upper limit, generate target data form;
Data to be stored write submodule, described data to be stored are write to described target data form;
Identifier combination submodule, divide the identifier combination in storehouse to generate target memory address the sign of described target data form and corresponding data.
Preferably, described mapping relations logging modle comprises:
Key-value pair is set up submodule, for setting up, is selected described user ID to shine upon the key-value pair of described target memory address;
Key-value pair record sub module, record described key-value pair in map listing.
Preferably, described device also comprises:
User ID acquisition module, for obtaining data user ID to be added; Described data to be added are to store in the corresponding target memory address of the built user ID of described distributed system, are the supplementary datas of built user ID;
Target memory address acquisition module, for according to described user ID inquiry obtain target memory address;
Target memory address writing module, for described data to be added are write to described target memory address.
Preferably, described device also comprises:
According to user ID, target memory address is obtained in inquiry, the corresponding data minute storehouse of pointing to and target data form, extracts the user data in described target memory address from target memory address.
Preferably, described data to be added comprise user's characteristic information; Described user ID acquisition module comprises:
User's characteristic information extracts submodule, for extracting the user's characteristic information of described data to be added;
Storage sequence number obtains submodule, according to described user's characteristic information mapping, obtains corresponding stored sequence number, and described corresponding stored sequence number is user ID.
Preferably, if a legacy data minute library storage load reaches the upper limit, increase the unit of described distributed system, and in described unit, set up new data minute storehouse.
Preferably, the data to be stored of the same user ID of described correspondence or data to be added are stored among a data form.
The embodiment of the present application also discloses the data enquire method in a kind of non-relational database, described non-relational database comprises the distributed system of at least two units, described unit comprises at least two data minute storehouse, a described data minute storehouse comprises some data forms, a described data minute storehouse has data minute storehouse sign, and described data form has data form sign;
Described method comprises:
The inquiry request that receives user data, described inquiry request comprises user ID;
According to described user ID inquiry, obtain target memory address, described target memory address is generated by the sign of target data form and the identifier combination in corresponding data minute storehouse;
The corresponding data minute storehouse of pointing to from described target memory address and target data form, extract user data;
Return to described user data.
The embodiment of the present application also discloses the data query device in a kind of non-relational database, described non-relational database comprises the distributed system of at least two units, described unit comprises at least two data minute storehouse, a described data minute storehouse comprises some data forms, a described data minute storehouse has data minute storehouse sign, and described data form has data form sign;
Described device comprises:
User ID acquisition module, for receiving the inquiry request of user data, described inquiry request comprises user ID;
Target memory address enquiry module, according to described user ID, target memory address is obtained in inquiry, and described target memory address is generated by the sign of target data form and the identifier combination in corresponding data minute storehouse;
Store data acquisition module, for corresponding data minute storehouse and the target data form pointing to from described target memory address, extract user data;
Storage data return to module, for returning to described user data.
Compared with prior art, the application has the following advantages:
The application stores by a kind of non-relational database the data that application scenarios has a large amount of user data to analyze, adopt data minute storehouse and tables of data to carry out orderly store and management user data simultaneously, and set up the map listing of user ID and target memory address, effectively improve the systematicness of non-relational data storage, make to search and extract data more fast accurately, improve the stability of operation; The data volume that expansion is supported, the cost of reduction operation maintenance.
Embodiment
For the application's above-mentioned purpose, feature and advantage can be become apparent more, below in conjunction with the drawings and specific embodiments, the application is described in further detail.
Relevant database: be the database being based upon on relational model basis, carry out the data in process database by means of the mathematical concepts such as algebra of sets and method.Various entities in real world and the various contacts between entity all represent with relational model.Normal data query language SQL is exactly a kind of language based on relational database, and this language is carried out the retrieval of data in relational database and operation.
Non-relational database: store with key-value pair, its structure is fixing, and each tuple can have different field, and each tuple can increase some oneself key-value pair as required, so just fixing structure can be confined to, the expense in some times and space can be reduced.
The application's application scenarios has a large amount of user data to need to analyze, and the user data of the application's application scenarios magnanimity is opening relationships model one by one, so relevant database can not adapt to the needs of the application's Users'Data Analysis.In the process of the application's Users'Data Analysis, need to carry out from a plurality of dimensions, each dimension has again a lot of k/v key-value pairs, stores these key assignments and adopts non-relational database the most suitable.But various commercial scheme costs are higher in the market, and the non-relational database scheme of increasing income can not meet the requirement of performance and capacity aspect.
The non-relational database technology of increasing income of current popular, has cassandra and HanderSocket.
Cassandra is used local file system storage data, but the data volume of supporting is limited, and has the inconsistent fatal problem of read-write.Although support cluster expansion, system is extremely unstable, and O&M machine cost is too high.
HanderSocket is that pure k/v key-value pair is realized, the replacement scheme that application scenarios is MemoryCache.Memory requirement that cannot satisfying magnanimity user profile.
So the scheme of existing relevant database and non-relational database scheme all cannot be overlapped in the application scenarios of using the application.
The application stores by a kind of non-relational database the data that application scenarios has a large amount of user data to analyze, adopt data minute storehouse and tables of data to carry out orderly store and management user data simultaneously, and set up the map listing of user ID and target memory address, effectively improve the systematicness of non-relational data storage, make to search and extract data more fast accurately, improve the stability of operation; The data volume that expansion is supported, the cost of reduction operation maintenance.
Described in the application, non-relational database comprises the distributed system of at least two units, described unit comprises at least two data minute storehouse, a described data minute storehouse comprises some data forms, and a described data minute storehouse has data minute storehouse sign, and described data form has data form sign.
With reference to Fig. 1, show the process flow diagram of the data processing method embodiment 1 in a kind of non-relational database of the application, specifically can comprise:
Step 101, generate the user ID of data to be stored, described data to be stored are the data that store into first in described distributed system;
In a preferred embodiment of the present application, described data to be stored are to store first the data in described distributed system into, need newly-built user ID.
In a preferred embodiment of the present application, described data to be stored can comprise user's characteristic information; Describedstep 101 specifically can comprise following sub-step:
Sub-step S11, extract user's characteristic information in described data to be stored;
In specific implementation, user's characteristic information can be user's network ID, the register account number of user in system, or the information of user's relevant proof of identification etc.; So long as can distinguish user and other users' information, can become user's characteristic information.
Sub-step S12, record the mapping of described user's characteristic information and preset storage sequence number, and described corresponding stored sequence number is designated as to user ID.
In specific implementation, preset storage sequence number can directly adopt the serial number of storage, and data to be stored during as the data of the 10021st storage, can be set as its storage sequence number: 001021.
In specific implementation, can also set up map listing, user's characteristic information and preset storage sequence number are recorded in map listing, form mapping relations.
Step 102, described data to be stored are write in the data form in a certain data minute storehouse, and divide storehouse sign and data form sign corresponding to described data form according to data corresponding to described data minute storehouse, generate target memory address;
In a preferred embodiment of the present application, describedstep 102 specifically can comprise following sub-step:
Sub-step S21, select not reach in a data minute storehouse data form of the preset number of users upper limit, generate target data form;
In specific implementation, the table quantity in single storehouse too much can be difficult to management, so may be limited in 1000.Can dynamically increase the object that data minute storehouse can reach dilatation according to the demand of oneself like this.
Sub-step S22, described data to be stored are write to described target data form;
Sub-step S23, divide the identifier combination in storehouse to generate target memory address the sign of described target data form and corresponding data.
In specific implementation, described target memory address is equivalent to an exclusive sign, can divide storehouse sign and data form sign to generate according to available data, certain data form sign and its corresponding data minute storehouse sign can be connected to the target memory address that generates this data form.As shown in Figure 5.In Fig. 5, first four can be number information in the sign of data minute storehouse, and latter three can be number information in data form sign.
Step 103, record the mapping relations of described user ID and target memory address;
In specific implementation, can set up the map listing of user ID and target memory address.
In a preferred embodiment of the present application, describedstep 103 specifically can comprise following sub-step:
Sub-step S31, foundation select described user ID to shine upon the key-value pair of described target memory address;
Sub-step S32, record described key-value pair in map listing.
Step 104, according to user ID inquiry, obtain target memory address, the corresponding data minute storehouse of pointing to from target memory address and target data form, extract the user data in described target memory address.
In specific implementation, when extracting certain user's data, can find according to respective user sign the target memory address of all data storages of respective user.Then call the data that preset interface extracts the needs in described target memory address.
With reference to Fig. 2, show the process flow diagram of the data processing method embodiment 2 in a kind of non-relational database of the application, specifically can comprise:
Step 201, obtain user ID in data to be added;
In a kind of preferred embodiment of the application, described data to be added need to store in the corresponding target memory address of the built user ID of described distributed system, are the supplementary datas of built user ID.
In concrete practice, data to be added do not need newly-built user ID.But find a corresponding target memory address of the user ID having existed, data to be added are write wherein.
In a preferred embodiment of the present application, described data to be added comprise user's characteristic information; Describedstep 201 specifically can comprise following sub-step:
Sub-step S41, extract the user's characteristic information in described data to be added;
Sub-step S42, according to described user's characteristic information, corresponding stored sequence number is obtained in mapping, and described corresponding stored sequence number is user ID.
Step 202, according to described user ID, target memory address is obtained in inquiry;
Step 203, described data to be added are write to described target memory address;
Step 204, according to user ID inquiry, obtain target memory address, the corresponding data minute storehouse of pointing to from target memory address and target data form, extract the user data in described target memory address.
In a preferred embodiment of the present application, if a legacy data minute library storage load reaches the upper limit, increase the unit of described distributed system, and in described unit, set up new data minute storehouse.
In specific implementation, the table quantity in single storehouse too much can be difficult to management, so may be limited in 1000.Can dynamically increase storehouse according to the demand of oneself like this can dilatation.
In a preferred embodiment of the present application, described same storage of subscriber data is among a data form.
In specific implementation, due to a user's whole data model, all data messages of a user, all in a table, have been avoided the query script in multilist or many storehouses, and therefore efficiency and the stability of inquiry also can obtain larger lifting.
It should be noted that, for embodiment of the method, for simple description, therefore it is all expressed as to a series of combination of actions, but those skilled in the art should know, the application is not subject to the restriction of described sequence of movement, because according to the application, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in instructions all belongs to preferred embodiment, and related action might not be that the application is necessary.
In order to facilitate those skilled in the art to understand better the application, below in conjunction with table 1, by a complete example, illustrate further the application:
Table 1: shown in be a user's model information:
| ID | Nick | Age | Sex |
| 10000 | Lionbule | 30 | man |
Table 1
A1, extraction user ID: 10000; Wherein other data informations of user also comprise: Data{nick:Lionbule; Age:30; Sex:man}.
A2, storage user model information time, first call memory interface: api save (long id, Map < String, Object > data), query aim memory address.If user ID: the mapping address of 10000 correspondences does not exist, applies for new target memory address A, Data{nick:Lionbule; Age:30; Sex:man} is converted to the line item of database table at new target memory address A by key, then store new target memory address A in mapping table.If user ID: the mapping address of 10000 correspondences exists, extracts corresponding target memory address B.Data{nick:Lionbule; Age:30; Sex:man} is converted to the line item of database table at target memory address B by key.
B1, now a user's newly-added information need to be stored in this user's target memory address, know this user ID: 10000, first call query interface: api query (long id), according to user ID: mapping target memory address corresponding to 10000 inquiry.
B2, pass through user ID: 10000 inquire corresponding mapping address exists, and extracts corresponding target memory address C.
B3, by the newly-increased information D ata{nick:Lionbule of user; Age:30; Sex:man} stores in target memory address C.
C1, now need to obtain user ID: 10001 information.First call query interface: api query (long id), according to user ID: mapping target memory address corresponding to 10001 inquiry.
C2, inquiry, without result, are found user ID: the mapping address of 10001 correspondences does not exist, throw exception information exit query script.Result is returned to client.
The structured flowchart that shows the data processing equipment embodiment 1 in a kind of non-relational database of the application with reference to Fig. 3, specifically can comprise:
User ID generation module 301, for generating the user ID of data to be stored;
In a preferred embodiment of the present application, described data to be stored are to store first the data in described distributed system into, need newly-built user ID.
In a preferred embodiment of the present application, described data to be stored comprise user's characteristic information; Described user ID generation module 301 specifically can comprise following submodule:
User's characteristic information extracts submodule, for extracting described data user's characteristic information to be stored;
User ID generates submodule, for recording the mapping of described user's characteristic information and preset storage sequence number, and described corresponding stored sequence number is denoted as to user ID.
Target storing address generating module 302, for described data to be stored being write to the data form in a certain data minute storehouse, and divide storehouse sign and data form sign corresponding to described data form according to data corresponding to described data minute storehouse, generate target memory address;
In a preferred embodiment of the present application, described target storing address generating module 302 specifically can comprise following submodule:
Target data form generates submodule, for selecting a data minute storehouse not reach the data form of the preset number of users upper limit, generate target data form;
Data to be stored write submodule, for described data to be stored are write to described target data form;
Identifier combination submodule, for the sign of described target data form and corresponding data being divided the identifier combination in storehouse generate target memory address.
Mapping relations logging modle 303, for recording the mapping relations of described user ID and target memory address;
In a preferred embodiment of the present application, described mapping relations logging modle 303 specifically can comprise following submodule:
Key-value pair is set up submodule, for setting up, is selected described user ID to shine upon the key-value pair of described target memory address;
Key-value pair record sub module, for recording described key-value pair at map listing.
User data extraction module 304, for obtaining target memory address according to user ID inquiry, call preset interface and extract the user data in described target memory address.
With reference to Fig. 4, show the structured flowchart of the data processing equipment embodiment 2 in a kind of non-relational database of the application, specifically can comprise:
UserID acquisition module 401, for obtaining data user ID to be added;
In a preferred embodiment of the present application, described data to be added need to store in the corresponding target memory address of the built user ID of described distributed system, are the supplementary datas of built user ID.
In a preferred embodiment of the present application, described data to be added comprise user's characteristic information; Described userID acquisition module 401 specifically can comprise following sub-step:
User's characteristic information extracts submodule, for extracting the user's characteristic information of described data to be added;
Storage sequence number obtain submodule, for according to described user's characteristic information mapping obtain corresponding stored sequence number, described corresponding stored sequence number is user ID.
Target memoryaddress acquisition module 402, for according to described user ID inquiry obtain target memory address;
Data writing module 403 to be added, for described data to be added are write to described target memory address.
Userdata extraction module 404, for obtain target memory address according to user ID inquiry, the corresponding data minute storehouse of pointing to from target memory address and target data form, extract the user data in described target memory address.
In a preferred embodiment of the present application, if a legacy data minute library storage load reaches the upper limit, increase the unit of described distributed system, and in described unit, set up new data minute storehouse.
In a preferred embodiment of the present application, described same storage of subscriber data is among a data form.
With reference to Fig. 6, show the flow chart of steps of the data enquire method embodiment in a kind of non-relational database of the application, specifically can comprise the steps:
The inquiry request ofstep 601, reception user data, described inquiry request comprises user ID;
Step 602, according to described user ID, target memory address is obtained in inquiry, and described target memory address is generated by the sign of target data form and the identifier combination in corresponding data minute storehouse;
Step 603, the corresponding data minute storehouse of pointing to from described target memory address and target data form, extract user data;
Step 604, return to described user data.
In order to facilitate those skilled in the art to understand better the application, below in conjunction with table 1, by a complete example, illustrate further the embodiment of the present application:
D1, now need to obtain user ID: 10000 information.First call query interface: api query (long id), according to user ID: mapping target memory address corresponding to 10000 inquiry.
If D2 user ID: the target memory address of 10000 correspondences exists, user's data information Data{nick:Lionbule; Age:30; Sex:man} returns to client.
With reference to Fig. 7, show the structured flowchart of the data query device embodiment in a kind of non-relational database of the application, specifically can comprise:
UserID acquisition module 701, for receiving the inquiry request of user data, described inquiry request comprises user ID;
Target memoryaddress enquiry module 702, for according to described user ID inquiry obtain target memory address, described target memory address is generated by the sign of target data form and the identifier combination in corresponding data minute storehouse;
Storedata acquisition module 703, for corresponding data minute storehouse and the target data form pointing to from described target memory address, extract user data;
Storage data return tomodule 704, for returning to described user data.
Because described device embodiment is substantially corresponding to preceding method embodiment, therefore not detailed part in the description of the present embodiment can, referring to the related description in previous embodiment, just not repeat at this.
Those skilled in the art should understand, the application's embodiment can be provided as method, system or computer program.Therefore, the application can adopt complete hardware implementation example, implement software example or in conjunction with the form of the embodiment of software and hardware aspect completely.And the application can adopt the form that wherein includes the upper computer program of implementing of computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) of computer usable program code one or more.
The application is with reference to describing according to process flow diagram and/or the block scheme of the method for the embodiment of the present application, equipment (system) and computer program.Should understand can be in computer program instructions realization flow figure and/or block scheme each flow process and/or the flow process in square frame and process flow diagram and/or block scheme and/or the combination of square frame.Can provide these computer program instructions to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, the instruction of carrying out by the processor of computing machine or other programmable data processing device is produced for realizing the device in the function of flow process of process flow diagram or a plurality of flow process and/or square frame of block scheme or a plurality of square frame appointments.
These computer program instructions also can be stored in energy vectoring computer or the computer-readable memory of other programmable data processing device with ad hoc fashion work, the instruction that makes to be stored in this computer-readable memory produces the manufacture that comprises command device, and this command device is realized the function of appointment in flow process of process flow diagram or a plurality of flow process and/or square frame of block scheme or a plurality of square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make to carry out sequence of operations step to produce computer implemented processing on computing machine or other programmable devices, thereby the instruction of carrying out is provided for realizing the step of the function of appointment in flow process of process flow diagram or a plurality of flow process and/or square frame of block scheme or a plurality of square frame on computing machine or other programmable devices.
Although described the application's preferred embodiment, once those skilled in the art obtain the basic creative concept of cicada, can make other change and modification to these embodiment.So claims are intended to all changes and the modification that are interpreted as comprising preferred embodiment and fall into the application's scope.
Data processing method in a kind of non-relational database above the application being provided and the data processing equipment in a kind of non-relational database are described in detail, applied specific case herein the application's principle and embodiment are set forth, the explanation of above embodiment is just for helping to understand the application's method and core concept thereof; Meanwhile, for one of ordinary skill in the art, the thought according to the application, all will change in specific embodiments and applications, and in sum, this description should not be construed as the restriction to the application.