CN104111992A - Method and system for merging agency results of distributed database - Google Patents

Method and system for merging agency results of distributed database Download PDF

Info

Publication number
CN104111992A
CN104111992A CN201410315793.6A CN201410315793A CN104111992A CN 104111992 A CN104111992 A CN 104111992A CN 201410315793 A CN201410315793 A CN 201410315793A CN 104111992 A CN104111992 A CN 104111992A
Authority
CN
China
Prior art keywords
result set
packet
function
field
row
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.)
Granted
Application number
CN201410315793.6A
Other languages
Chinese (zh)
Other versions
CN104111992B (en
Inventor
李静
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Si Tech Information Technology Co Ltd
Original Assignee
Beijing Si Tech Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Si Tech Information Technology Co Ltd filed Critical Beijing Si Tech Information Technology Co Ltd
Priority to CN201410315793.6A priority Critical patent/CN104111992B/en
Publication of CN104111992A publication Critical patent/CN104111992A/en
Application granted granted Critical
Publication of CN104111992B publication Critical patent/CN104111992B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The invention relates to a method and system for merging agency results of a distributed database. The system comprises an SQL analyzing module, a data package analyzing module, a logical processing module, a data package assembling module and a feedback module. The SQL analyzing module is used for analyzing SQL statements to obtain functions included in the SQL statements, the data package analyzing module is used for analyzing a data package and extracting row data information and line field data information, the logical processing module is used for extracting the data information of fields, where the corresponding functions are located, in each row, carrying out logical processing and carrying out corresponding processing according to the different functions to obtain the results, the data package assembling module is used for re-packaging the processed results to form a data package meeting requirements of an MYSQL protocol and sending the data package to the feedback module, and the feedback module is used for sending the data package to a client terminal. The method and system have the economical efficiency, and the performance and the safety performance can be further improved.

Description

A kind of proxy results of distributed data base merges method and system
Technical field
The proxy results that the present invention relates to a kind of distributed data base merges method and system.
Background technology
Existing distributed data base agency sends each pending SQL request to client, through the routing rule of acting on behalf of, obtains destination node, then SQL information is sent to MYSQL server process, and result is returned to client.If route results is a plurality of physical nodes, agency can do Query Result simple merging and return to client so.If there is no some functions such as sum, max in SQL, the simple merging of Query Result satisfies the demands so.If there are these functions, Query Result just need to be done further processing rather than simply merge so, as sum function, the cumulative client that returns to that just need to try again to the sum value in Query Result, client just can obtain correct result and not need application to do secondary treating again like this.Based on this principle, agency need to just comprise the execution result of the SQL of some functions and do corresponding logical process, then returns to client, to realizing distributed data base agency's result set, merges processing.
The shortcoming of processing based on existing system:
While having sum function in SQL, the result of returning is the simple merging of individual node sum value.
While having count function in SQL, the result of returning is the simple merging of individual node count value.
While having max function in SQL, the result of returning is the simple merging of individual node max value.
While having min function in SQL, the result of returning is the simple merging of individual node max value.
While having avg function in SQL, the result of returning is the simple merging of individual node avg value.
While having order by function in SQL, the result of returning is the simple merging of individual node order by value.
While having group by function in SQL, the result of returning is the simple merging of individual node order by value.
While having distinct function in SQL, the result of returning is the simple merging of the distinct value of individual node.
In internet, many key areas such as telecommunications, development along with business event, the I/T environment of enterprise is also constantly developing, individual data storehouse has been difficult to the storage of satisfying magnanimity database and the access of high concurrent data, the appearance of distributed data base becomes inevitable, distributed data base can effectively solve mass data storage and concurrent problem, by the horizontal cutting of data and the vertical cutting of tables of data, effectively alleviated mass data storage, pass through load balancing, high available, polls etc. have been alleviated high concurrent problem, but distributed data base just simply merges when treating the SQL execution result of function, what thereby client obtained is the result that has ambiguity.
Summary of the invention
Technical matters to be solved by this invention is to provide a kind of for different functions, adopts the proxy results merging method of the distributed data base of different disposal and merging method.
The technical scheme that the present invention solves the problems of the technologies described above is as follows: a kind of proxy results merging method of distributed data base, specifically comprises the following steps:
Step 1: resolve the first SQL statement and obtain the function that it comprises;
Step 2: judge that described function belongs to first kind function or Equations of The Second Kind function, if first kind function, execution step 8; Otherwise, execution step 3;
Step 3: judge whether described function is distinct function, if so, execution step 5; Otherwise, execution step 4;
Step 4: the first SQL statement is carried out to pre-service and obtain the second SQL statement, the second SQL statement is replaced to the first SQL statement;
Step 5: send the first SQL statement or the second SQL statement to MYSQL service end;
Step 6: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set;
Step 7: set operates to packet according to described function, obtains new result set;
Step 8: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
The invention has the beneficial effects as follows: the present invention has economy: be supported under the condition that does not increase hardware input, improve system concurrency processing power; Make full use of the computational resource of idleness of equipment period, improve resource utilization ratio; Utilize the storage space of load balancing database on low-end server to carry out data processing; The present invention can also improving performance and security: configurable mode mobile computing, Mobile data carry out cloud computing, and performance and the efficiency of parallel computation is provided; Ensure consistance, integrality, the availability of data, improve the isolated form of data, for high concurrent system lays the foundation.
On the basis of technique scheme, the present invention can also do following improvement.
Further, described first kind function comprises sum function, count function, max function and min function; Described Equations of The Second Kind function comprises avg function, order by function, group by function and distinct function.
Further, described step 4 specifically comprises the following steps:
Step 4.1: judge whether the first SQL statement comprises avg function, if so, execution step 4.2; Otherwise execution step 4.3;
Step 4.2: the avga () in the first SQL statement is changed into sum (), and count () and avga (), obtain the second SQL statement, execution step 5;
Step 4.3: judge whether the first SQL statement comprises order by function, if so, execution step 4.4; Otherwise, execution step 4.6;
Step 4.4: whether judgement inquiry field comprises order by sort field; If so, execution step 4.6; Otherwise, execution step 4.5;
Step 4.5: the sort field in the first SQL statement is added in inquiry field and forms the second SQL statement, execution step 5;
Step 4.6: judge whether the first SQL statement comprises group by function; If so, execution step 4.5; Otherwise, execution step 5.
Further, described step 7 specifically comprises the following steps:
Step 7.1: judge whether described function is sum function or count function; If so, execution step 7.2; Otherwise, execution step 7.3;
Step 7.2: the result set of multinode is added up and forms new result set, execution step 8;
Step 7.3: judge whether described function is max function; If so, execution step 7.4; Otherwise, execution step 7.5;
Step 7.4: the result set of multinode is carried out to maximizing and obtain new result set, execution step 8;
Step 7.5: judge whether described function is min function; If so, execution step 7.6; Otherwise execution step 7.7;
Step 7.6: the result set of multinode is minimized and obtained new result set, execution step 8;
Step 7.7: judge whether described function is avg function; If so, execution step 7.8; Otherwise, execution step 7.9;
Step 7.8: the result set of all nodes is unified to average obtains new result set, performs step 8;
Step 7.9: judge whether described function is order by function, if so, execution step 7.10; Otherwise, execution step 7.11;
Step 7.10: the result set of multinode is resequenced and obtained new result set, execution step 8;
Step 7.11: judge whether described function is group by function, if so, execution step 7.12; Otherwise, execution step 7.13;
Step 7.12: the result set of multinode is re-assemblied and obtains new result set, execution step 8;
Step 7.13: the distinct value to individual node simply merges, and obtains new result set, execution step 8.
Further, described step 7.2 comprises the following steps:
Step 7.2.1: obtain the column data bag of row field from result set, find sum () field or count () field in column data bag, and obtain the sequence number of this field;
Step 7.2.2: obtain the row packet of row field from result set, be expert in packet, obtain the result of sum () function or the count () function of every a line, and add up and obtain accumulated value;
Step 7.2.3: accumulated value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number, execution step 8.
Further, described step 7.4 specifically comprises the following steps:
Step 7.4.1: obtain the column data bag of row field from result set, find max () field in column data bag, and obtain the sequence number of this field;
Step 7.4.2: from result set, obtain the row packet of row field, in the packet of being expert at, search the result of the max () function of every a line, and its maximal value of big or small acquisition;
Step 7.4.3: maximal value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
Further, described step 7.6 specifically comprises the following steps:
Step 7.6.1: obtain the column data bag of row field from result set, find min () field in column data bag, and obtain the sequence number of this field;
Step 7.6.2: from result set, obtain the row packet of row field, in the packet of being expert at, search the result of the min () function of every a line, and its minimum value of big or small acquisition;
Step 7.6.3: minimum value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
Further, described step 7.8 specifically comprises the following steps:
Step 7.8.1: obtain the column data bag of row field from result set, find avg (), sum () and count () field in column data bag, and obtain the sequence number of this field;
Step 7.8.2: obtain the row packet of row field from result set, obtain the result of sum function and the count function of every a line in the packet of being expert at, and add up and obtain total sum value and count value respectively;
Step 7.8.3:sum value obtains mean value divided by count value, and is assembled into row packet;
Step 7.8.4: the capable packet of Delete superfluous and unnecessary column data bag form new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number, execution step 8.
Further, described step 7.10 specifically comprises the following steps:
Step 7.10.1: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising sort field;
Step 7.10.2: obtain row packet from result set, obtain the value of the sort field of every a line from row packet, and the value of sort field is remained in result set;
Step 7.10.3: judge in described the second SQL statement whether comprise desc, if so, execution step 7.10.4; Otherwise, execution step 7.10.5;
Step 7.10.4: the value in result set is carried out to descending sort and obtain new result set, concentrating in new structure the information change represent packet number is the information of correct sequence number, execution step 8;
Step 7.10.5: the value in result set is carried out to ascending order is arranged and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
Further, described step 7.12 specifically comprises the following steps:
Step 7.12.1: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising grop by field in column data bag;
Step 7.12.2: obtain the row packet of row field from result set, and obtain the value of the sort field of every a line, the value of sort field is deposited in result set;
Step 7.12.3: the value in result set is carried out to ascending order arrangement, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
Further, described step 7.13 specifically comprises the following steps:
Step 7.13.1: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising distinct field in column data bag;
Step 7.13.2: obtain the row packet of row field from result set, and obtain the value of the sort field of every a line, the value of sort field is deposited in result set;
Step 7.13.3: the value in result set is screened to the data that reject to repeat, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
Technical matters to be solved by this invention is to provide a kind of for different functions, adopts the proxy results combination system of the distributed data base of different disposal and merging method.
The technical scheme that the present invention solves the problems of the technologies described above is as follows: a kind of proxy results combination system of distributed data base, comprising: resolve SQL module, resolution data bag module, logic processing module, packet assembling module and feedback module;
Described parsing SQL module obtains for resolving SQL statement the function that it comprises;
Described resolution data bag module is used for analyzing packet, extracts row data, the information such as row field data;
Described logic processing module is for extracting the data message of respective function place field of every row, and carries out logical process, carries out corresponding processing obtain result according to different functions; As: respective value addition, maximizing, minimize, average or sequence etc.;
Described packet assembling module is for the result Reseal after processing being become to meet the packet of MYSQL agreement, and by described Packet Generation to feedback module;
Described feedback module is for arriving client by Packet Generation.
Accompanying drawing explanation
Fig. 1 is the proxy results combination system structured flowchart of a kind of distributed data base of the present invention;
Fig. 2 is that the proxy results of a kind of distributed data base of the present invention merges method flow diagram;
Fig. 3 is sum function processing flow chart of the present invention;
Fig. 4 is count function processing flow chart of the present invention;
Fig. 5 is max function processing flow chart of the present invention;
Fig. 6 is min function processing flow chart of the present invention;
Fig. 7 is avg function processing flow chart of the present invention;
Fig. 8 is order by function processing flow chart of the present invention;
Fig. 9 is group by function processing flow chart of the present invention;
Figure 10 is distinct function processing flow chart of the present invention.
In accompanying drawing, the list of parts of each label representative is as follows:
1, resolve SQL module, 2, resolution data bag module, 3, logic processing module, 4, packet assembling module, 5, feedback module.
Embodiment
Below in conjunction with accompanying drawing, principle of the present invention and feature are described, example, only for explaining the present invention, is not intended to limit scope of the present invention.
As shown in Figure 1, the proxy results combination system for a kind of distributed data base of the present invention, comprising: resolve SQL module 1, resolution data bag module 2, logic processing module 3, packet assembling module 4 and feedback module 5;
Described parsing SQL module 1 obtains for resolving statement the function that it comprises;
Described resolution data bag module 2, for analyzing packet, is extracted row data, the information such as row field data;
Described logic processing module 3 is for extracting the data message of the respective function place field of every row, and carries out logical process, carries out corresponding processing obtain result according to different functions; As: respective value addition, maximizing, minimize, average or sequence etc.;
Described packet assembling module 4 is for the result Reseal after processing being become to meet the packet of MYSQL agreement, and by described Packet Generation to feedback module 5;
Described feedback module 5 is for arriving client by Packet Generation.
As shown in Figure 2, the proxy results merging method for a kind of distributed data base of the present invention, specifically comprises the following steps:
Step 1: resolve the first SQL statement and obtain the function that it comprises;
Step 2: judge that described function belongs to first kind function or Equations of The Second Kind function, if first kind function, execution step 8; Otherwise, execution step 3;
Step 3: judge whether described function is distinct function, if so, execution step 5; Otherwise, execution step 4;
Step 4: the first SQL statement is carried out to pre-service and obtain the second SQL statement, the second SQL statement is replaced to the first SQL statement;
Step 5: send the first SQL statement or the second SQL statement to MYSQL service end;
Step 6: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set;
Step 7: set operates to packet according to described function, obtains new result set;
Step 8: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
Described first kind function comprises sum function, count function, max function and min function; Described Equations of The Second Kind function comprises avg function, order by function, group by function and distinct function.
As shown in Figure 3, be sum function processing flow chart of the present invention;
Step 3.1: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 3.2: judge whether described function is sum function; If so, execution step 3.3; Otherwise, execution step 3.6;
Step 3.3: obtain the column data bag of row field from result set, find sum () field in column data bag, and obtain the sequence number of this field;
Step 3.4: obtain the row packet of row field from result set, be expert in packet, obtain the result of the sum () function of every a line, and add up and obtain accumulated value;
Step 3.5: accumulated value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number;
Step 3.6: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in Figure 4, be count function processing flow chart of the present invention;
Step 4.1: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 4.2: judge whether described function is count function; If so, execution step 4.3; Otherwise, execution step 4.6;
Step 4.3: obtain the column data bag of row field from result set, find count () field in column data bag, and obtain the sequence number of this field;
Step 4.4: obtain the row packet of row field from result set, be expert in packet, obtain the result of the count () function of every a line, and add up and obtain accumulated value;
Step 4.5: accumulated value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number;
Step 4.6: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in Figure 5, be max function processing flow chart of the present invention;
Step 5.1: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 5.2: judge whether described function is max function; If so, execution step 5.3; Otherwise, execution step 5.6;
Step 5.3: obtain the column data bag of row field from result set, find max () field in column data bag, and obtain the sequence number of this field;
Step 5.4: from result set, obtain the row packet of row field, in the packet of being expert at, search the result of the max () function of every a line, and its maximal value of big or small acquisition;
Step 5.5: maximal value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number;
Step 5.6: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in Figure 6, be min function processing flow chart of the present invention;
Step 6.1: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 6.2: judge whether described function is min function; If so, execution step 6.3; Otherwise, execution step 6.6;
Step 6.3: obtain the column data bag of row field from result set, find min () field in column data bag, and obtain the sequence number of this field;
Step 6.4: from result set, obtain the row packet of row field, in the packet of being expert at, search the result of the min () function of every a line, and its minimum value of big or small acquisition;
Step 6.5: minimum value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number;
Step 6.6: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in Figure 7, be avg function processing flow chart of the present invention;
Step 7.1: judge whether the first SQL statement comprises avg function, if so, execution step 7.2; Otherwise execution step 7.3;
Step 7.2: the avga () in the first SQL statement is changed into sum (), and count () and avga (), obtain the second SQL statement;
Step 7.3: send the second SQL statement to MYSQL service end;
Step 7.4: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 7.5: obtain the column data bag of row field from result set, find avg (), sum () and count () field in column data bag, and obtain the sequence number of this field;
Step 7.6: obtain the row packet of row field from result set, obtain the result of sum function and the count function of every a line in the packet of being expert at, and add up and obtain total sum value and count value respectively;
Step 7.7:sum value obtains mean value divided by count value, and is assembled into row packet;
Step 7.8: the capable packet of Delete superfluous and unnecessary column data bag form new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number;
Step 7.9: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in Figure 8, be order by function processing flow chart of the present invention;
Step 8.1: judge whether the first SQL statement comprises order by function, if so, execution step 8.2; Otherwise, execution step 8.4;
Step 8.2: whether judgement inquiry field comprises order by sort field; If so, execution step 8.3; Otherwise, execution step 8.4;
Step 8.3: the sort field in the first SQL statement is added in inquiry field and forms the second SQL statement;
Step 8.4: send the second SQL statement to MYSQL service end;
Step 8.5: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 8.6: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising sort field;
Step 8.7: obtain row packet from result set, obtain the value of the sort field of every a line from row packet, and the value of sort field is remained in result set;
Step 8.8: judge in described the second SQL statement whether comprise desc, if so, execution step 8.9; Otherwise, execution step 8.10;
Step 8.9: the value in result set is carried out to descending sort and obtain new result set, concentrating in new structure the information change represent packet number is the information of correct sequence number, execution step 8.11;
Step 8.10: the value in result set is carried out to ascending order is arranged and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number;
Step 8.11: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in Figure 9, be group by function processing flow chart of the present invention;
Step 9.1: judge whether the first SQL statement comprises group by function; If so, execution step 9.2; Otherwise, execution step 9.3;
Step 9.2: the sort field in the first SQL statement is added in inquiry field and forms the second SQL statement;
Step 9.3: send the second SQL statement to MYSQL service end;
Step 9.4: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, the merging of being convenient to subsequent result collection arranges;
Step 9.5: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising grop by field in column data bag;
Step 9.6: obtain the row packet of row field from result set, and obtain the value of the sort field of every a line, the value of sort field is deposited in result set;
Step 9.7: the value in result set is carried out to ascending order arrangement, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number;
Step 9.8: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
As shown in figure 10, be distinct function processing flow chart of the present invention;
Step 10.1: send the first SQL statement to MYSQL service end;
Step 10.2: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set, packet set comprises row field bag and the row packet of feedback result, and the merging of being convenient to subsequent result collection arranges;
Step 10.3: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising distinct field in column data bag;
Step 10.4: obtain the row packet of row field from result set, and obtain the value of the sort field of every a line, the value of sort field is deposited in result set;
Step 10.5: the value in result set is screened to the data that reject to repeat, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number;
Step 10.6: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (12)

1. the proxy results merging method of a distributed data base, is characterized in that, specifically comprises the following steps:
Step 1: resolve the first SQL statement and obtain the function that it comprises;
Step 2: judge that described function belongs to first kind function or Equations of The Second Kind function, if first kind function, execution step 8; Otherwise, execution step 3;
Step 3: judge whether described function is distinct function, if so, execution step 5; Otherwise, execution step 4;
Step 4: the first SQL statement is carried out to pre-service and obtain the second SQL statement, the second SQL statement is replaced to the first SQL statement;
Step 5: send the first SQL statement or the second SQL statement to MYSQL service end;
Step 6: obtain the result set that MYSQL service end is returned, according to the protocol format of MYSQL packet, convert result set to packet set;
Step 7: set operates to packet according to described function, obtains new result set;
Step 8: new result set is carried out to packet encapsulation and obtain new packet, new Packet Generation is arrived to client.
2. the proxy results merging method of a kind of distributed data base according to claim 1, is characterized in that, described first kind function comprises sum function, count function, max function and min function; Described Equations of The Second Kind function comprises avg function, order by function, group by function and distinct function.
3. the proxy results merging method of a kind of distributed data base according to claim 1, is characterized in that, described step 4 specifically comprises the following steps:
Step 4.1: judge whether the first SQL statement comprises avg function, if so, execution step 4.2; Otherwise execution step 4.3;
Step 4.2: the avga () in the first SQL statement is changed into sum (), and count () and avga (), form the second SQL statement, execution step 5;
Step 4.3: judge whether the first SQL statement comprises order by function, if so, execution step 4.4; Otherwise, execution step 4.6;
Step 4.4: whether judgement inquiry field comprises order by sort field; If so, execution step 4.6; Otherwise, execution step 4.5;
Step 4.5: the sort field in the first SQL statement is added in inquiry field and forms the second SQL statement, execution step 5;
Step 4.6: judge whether the first SQL statement comprises group by function; If so, execution step 4.5; Otherwise, execution step 5.
4. according to the proxy results merging method of a kind of distributed data base described in claim 1-3 any one, it is characterized in that, described step 7 specifically comprises the following steps:
Step 7.1: judge whether described function is sum function or count function; If so, execution step 7.2; Otherwise, execution step 7.3;
Step 7.2: the result set of multinode is added up and forms new result set, execution step 8;
Step 7.3: judge whether described function is max function; If so, execution step 7.4; Otherwise, execution step 7.5;
Step 7.4: the result set of multinode is carried out to maximizing and obtain new result set, execution step 8;
Step 7.5: judge whether described function is min function; If so, execution step 7.6; Otherwise execution step 7.7;
Step 7.6: the result set of multinode is minimized and obtained new result set, execution step 8;
Step 7.7: judge whether described function is avg function; If so, execution step 5.8; Otherwise, execution step 7.9;
Step 7.8: the result set of all nodes is unified to average obtains new result set, performs step 8;
Step 7.9: judge whether described function is order by function, if so, execution step 7.10; Otherwise, execution step 7.11;
Step 7.10: the result set of multinode is resequenced and obtained new result set, execution step 8;
Step 7.11: judge whether described function is group by function, if so, execution step 7.12; Otherwise, execution step 7.13;
Step 7.12: the result set of multinode is re-assemblied and obtains new result set, execution step 8;
Step 7.13: the distinct value to individual node simply merges, and obtains new result set, execution step 8.
5. the proxy results merging method of a kind of distributed data base according to claim 4, is characterized in that, described step 7.2 comprises the following steps:
Step 7.2.1: obtain the column data bag of row field from result set, find sum () field or count () field in column data bag, and obtain the sequence number of this field;
Step 7.2.2: obtain the row packet of row field from result set, be expert in packet, obtain the result of sum () function or the count () function of every a line, and add up and obtain accumulated value;
Step 7.2.3: accumulated value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number, execution step 8.
6. the proxy results merging method of a kind of distributed data base according to claim 4, is characterized in that, described step 7.4 specifically comprises the following steps:
Step 7.4.1: obtain the column data bag of row field from result set, find max () field in column data bag, and obtain the sequence number of this field;
Step 7.4.2: from result set, obtain the row packet of row field, in the packet of being expert at, search the result of the max () function of every a line, and its maximal value of big or small acquisition;
Step 7.4.3: maximal value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
7. the proxy results merging method of a kind of distributed data base according to claim 4, is characterized in that, described step 7.6 specifically comprises the following steps:
Step 7.6.1: obtain the column data bag of row field from result set, find min () field in column data bag, and obtain the sequence number of this field;
Step 7.6.2: from result set, obtain the row packet of row field, in the packet of being expert at, search the result of the min () function of every a line, and its minimum value of big or small acquisition;
Step 7.6.3: minimum value is put in the first row packet, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
8. the proxy results merging method of a kind of distributed data base according to claim 4, is characterized in that, described step 7.8 specifically comprises the following steps:
Step 7.8.1: obtain the column data bag of row field from result set, find avg (), sum () and count () field in column data bag, and obtain the sequence number of this field;
Step 7.8.2: obtain the row packet of row field from result set, obtain the result of sum function and the count function of every a line in the packet of being expert at, and add up and obtain total sum value and count value respectively;
Step 7.8.3:sum value obtains mean value divided by count value, and is assembled into row packet;
Step 7.8.4: the capable packet of Delete superfluous and unnecessary column data bag form new result set, and by the information change that represents packet number in new result set, be the information of correct sequence number, execution step 8.
9. the proxy results merging method of a kind of distributed data base according to claim 4, is characterized in that, described step 7.10 specifically comprises the following steps:
Step 7.10.1: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising sort field;
Step 7.10.2: obtain row packet from result set, obtain the value of the sort field of every a line from row packet, and the value of sort field is remained in result set;
Step 7.10.3: judge in described the second SQL statement whether comprise desc, if so, execution step 7.10.4; Otherwise, execution step 7.10.5;
Step 7.10.4: the value in result set is carried out to descending sort and obtain new result set, concentrating in new structure the information change represent packet number is the information of correct sequence number, execution step 8;
Step 7.10.5: the value in result set is carried out to ascending order is arranged and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
10. the proxy results merging method of a kind of distributed data base according to claim 4, is characterized in that, described step 7.12 specifically comprises the following steps:
Step 7.12.1: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising grop by field in column data bag;
Step 7.12.2: obtain the row packet of row field from result set, and obtain the value of the sort field of every a line, the value of sort field is deposited in result set;
Step 7.12.3: the value in result set is carried out to ascending order arrangement, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
The proxy results merging method of 11. a kind of distributed data bases according to claim 4, is characterized in that, described step 7.13 specifically comprises the following steps:
Step 7.13.1: obtain the column data bag of row field from result set, search the sequence number of the row field that obtains comprising distinct field in column data bag;
Step 7.13.2: obtain the row packet of row field from result set, and obtain the value of the sort field of every a line, the value of sort field is deposited in result set;
Step 7.13.3: the value in result set is screened to the data that reject to repeat, and the capable packet of Delete superfluous forms new result set, and the information change that represents packet number in new result set is the information of correct sequence number, execution step 8.
The proxy results combination system of 12. 1 kinds of distributed data bases, is characterized in that, comprising: resolve SQL module, resolution data bag module, logic processing module, packet assembling module and feedback module;
Described parsing SQL module obtains for resolving SQL statement the function that it comprises;
Described resolution data bag module is used for analyzing packet, extracts row data, row field data information;
Described logic processing module is for extracting the data message of respective function place field of every row, and carries out logical process, carries out corresponding processing obtain result according to different functions;
Described packet assembling module is for the result Reseal after processing being become to meet the packet of MYSQL agreement, and by described Packet Generation to feedback module;
Described feedback module is for arriving client by Packet Generation.
CN201410315793.6A 2014-07-03 2014-07-03 Method and system for merging agency results of distributed database Active CN104111992B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410315793.6A CN104111992B (en) 2014-07-03 2014-07-03 Method and system for merging agency results of distributed database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410315793.6A CN104111992B (en) 2014-07-03 2014-07-03 Method and system for merging agency results of distributed database

Publications (2)

Publication Number Publication Date
CN104111992A true CN104111992A (en) 2014-10-22
CN104111992B CN104111992B (en) 2017-05-17

Family

ID=51708783

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410315793.6A Active CN104111992B (en) 2014-07-03 2014-07-03 Method and system for merging agency results of distributed database

Country Status (1)

Country Link
CN (1) CN104111992B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040088717A1 (en) * 2002-07-12 2004-05-06 Jun Chen System and method for connectivity to structured query language database
US20060106895A1 (en) * 2004-11-12 2006-05-18 Microsoft Corporation Method and subsystem for performing metadata cleanup for replication topologies
CN103488778A (en) * 2013-09-27 2014-01-01 华为技术有限公司 Data searching method and device
CN103729428A (en) * 2013-12-25 2014-04-16 中国科学院计算技术研究所 Big data classification method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040088717A1 (en) * 2002-07-12 2004-05-06 Jun Chen System and method for connectivity to structured query language database
US20060106895A1 (en) * 2004-11-12 2006-05-18 Microsoft Corporation Method and subsystem for performing metadata cleanup for replication topologies
CN103488778A (en) * 2013-09-27 2014-01-01 华为技术有限公司 Data searching method and device
CN103729428A (en) * 2013-12-25 2014-04-16 中国科学院计算技术研究所 Big data classification method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
娄希安: "海量数据存储与查询策略的优化研究", 《中国优秀硕士学位论文全文数据库》 *

Also Published As

Publication number Publication date
CN104111992B (en) 2017-05-17

Similar Documents

Publication Publication Date Title
CN109240821B (en) Distributed cross-domain collaborative computing and service system and method based on edge computing
CN105335479B (en) A kind of text data statistics implementation method based on SQL
CN104021194A (en) Mixed type processing system and method oriented to industry big data diversity application
CN107895046B (en) Heterogeneous data integration platform
CN104572727A (en) Data querying method and device
CN101345694A (en) Method for fast searching, positioning and matching access control list
CN103179052A (en) Virtual resource allocation method and system based on proximity centrality
CN106850258A (en) A kind of Log Administration System, method and device
CN108959445A (en) Distributed information log processing method and processing device
CN111078765A (en) View base system based on Hadoop system architecture and construction method thereof
Ge et al. Adaptive analytic service for real-time internet of things applications
CN104933136A (en) Dynamic car-pooling method and system based on automatic number plate recognition data
Xu The analytics and applications on supporting big data framework in wireless surveillance networks
CN107346270A (en) Method and system based on the sets cardinal calculated in real time
CN103412883A (en) Semantic intelligent information publishing and subscribing method based on P2P technology
CN107870982A (en) Data processing method, system and computer-readable recording medium
CN102724290B (en) Method, device and system for getting target customer group
CN102882979A (en) System and method for collecting, gathering and distributing data on basis of cloud computing system
CN113900810A (en) Distributed graph processing method, system and storage medium
CN104125146B (en) A kind of method for processing business and device
CN108471355A (en) A kind of Internet of Things Information Interoperability method based on extra large cloud computing framework
CN103647666A (en) Method and apparatus for counting call detail record (CDR) messages and outputting results in real time
CN104111992A (en) Method and system for merging agency results of distributed database
CN215298210U (en) Multistage edge computing system of electric power thing networking
Zhao et al. An integrated processing platform for traffic sensor data and its applications in intelligent transportation systems

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