Summary of the invention
Purpose of the present invention is exactly to overcome the shortcoming that need utilize network configuration and instrument to carry out for cross-platform data base querying at present, a kind of otherness between can shielding platform is proposed, reduce user inquiring and handle complexity, and the platform database querying method of Network Transmission bottleneck problem can solve the big data quantity query requests time.
Core concept of the present invention is: define a kind of unified file structure, be used to store user's querying condition and Query Result, the server end database processing unit is inquired about in database according to the querying condition that defines in the file structure, and Query Result is stored in the unified file structure.
Technical scheme of the present invention is as follows: a kind of platform database querying method comprises the following steps:
(1) inquiry file of structure consolidation form, described inquiry file comprises information Control district and information data district, and the information Control district is used to store user's querying condition and user's self information, and the information data district is used for the return results of storing queries;
(2) user's input inquiry information in inquiry file;
(3) user sends to database processing unit with query requests in the mode of file;
(4) database processing unit is the sub-processing unit of each query requests allocation database, and the sub-processing unit of described database connects for the database that can Gong call;
(5) the sub-processing unit of database is according to the inquiry file constructs database SQL query statement that distributes;
(6) carry out data base querying;
(7) database word processing cell processing Query Result and return the Query Result file to the user.
The content in described information Control district comprises: whether be conjunctive query, and inquiry table name, inquiry list of fields, querying condition, the filename of generation, user totem information.The content in described information data district comprises: data head, in order to the field number and the record number of record queries; Data type is described, in order to record field type and field length; Data recording, the particular content that obtains in order to record queries.
Above-mentioned steps (5) specifically comprises the following steps:
(1) the sub-processing unit of database calls file structure according to the user totem information in the query requests, obtain file structure and the given filename of information Control district user, and under given catalogue, open this file with read-write mode, if this document exists, then cover, if there is no, then generate a new file;
(2) the sub-processing unit of database is judged the correctness of user input query information in the query requests, if user's fill message is incomplete, then returns failure information to the user, otherwise carries out next step;
(3) Query Information filled in according to the user of the sub-processing unit of database constructs the database SQL query statement;
(4) whether the sub-processing unit checking of database query statement is correct, if incorrect, then returns failure information to the user, otherwise carries out next step inquiry.
Data base querying is meant and once imports query statement into database, obtains Query Result one by one.Handle Query Result and be meant that the sub-processing unit of database writes the information data district of Query Result file with Query Result in the mode of network bytes preface, after inquiry was finished, the sub-processing unit of database was closed the Query Result file.
Described method also comprises provides a series of file access interfaces, and described access interface is to encapsulate one deck on the access interface of file system itself, makes the user need not to be concerned about the structure and the source of file when file is carried out access.Described access interface comprises that document creation, File Open, file write, file reads, closing of a file, document alignment, file movement, file pointer current location and file delete.
The present invention compares with existing platform database querying method, considered move the influence that inquiry brought of user especially with respect to database platform, and the bottleneck of the inquiry of big data quantity on Network Transmission, original method in this case, general all need to reconfigure and being connected of database, perhaps adjust the user to querying condition to reduce the data volume of Query Result.The present invention utilizes the difference between the transmission shielding different platform of file and the Network Transmission bottleneck of big data quantity inquiry, and utilizes unified file structure to reduce user's complexity.Adopt the method: the animal migration that 1, has effectively improved the user; 2, can solve the network transfer speeds problem of big data quantity inquiry; 3, reduced user's processing complexity; 4, the user need not to be concerned about the configuring condition to database, has improved the compatibility of operating between the platform; 5, reduce the frequent input of user, improved access speed the data library inquiry to data library inquiry condition.
Embodiment
The present invention is described in further detail below in conjunction with drawings and Examples.
Fig. 1 is the main flow chart of querying method of the present invention.As shown in Figure 1, the querying method that proposes of the present invention comprise the following steps: 1, the inquiry file of structure consolidation form.Described inquiry file comprises information Control district and information data district, and the information Control district is used to store user's querying condition and user's self information, and the information data district is used for the return results of storing queries.The structure of inquiry file will be further described in the explanation of Fig. 2.2, user's input inquiry information in inquiry file.File structure is presented to the user with original template, and the user fills in original template according to the query demand of oneself, and the information that the user fills in is recorded in the information Control district of file structure.3, the user sends to database processing unit with query requests in the mode of file.When the user confirmed filling in of oneself, the file structure that fills just was sent to database processing unit and keeps, and in system's operational process, the user can revise Query Information at any time, and the Query Information of modification can be recorded at once, and is retained in the later use.4, database processing unit is the sub-processing unit of each query requests allocation database, and the sub-processing unit of described database connects for the database that can Gong call.The user can send to query requests the server database processing unit and inquire about, database processing unit is dispatched query requests, connect for each request distributes the database that can Gong call, this independent database connects can be called the sub-processing unit of database.Database processing unit is dispatched query requests, distributes according to the idle degree of each sub-processing unit, finds non-loaded database processing subelement, and this database processing subelement is distributed in this request.5, the sub-processing unit of database is according to the inquiry file constructs database SQL query statement that distributes.Inquiry for database is mainly finished by certain SQL query statement, and the detailed description in this step will be carried out in Fig. 3.6, carry out data base querying, once import query statement into database, obtain Query Result one by one.7, database word processing cell processing Query Result and return the Query Result file to the user.The sub-processing unit of database writes the information data district of Query Result file with Query Result in the mode of network bytes preface, and after inquiry was finished, the sub-processing unit of database was closed the Query Result file.The user can be synchronous to the request of data library inquiry, also can be asynchronous, and this depends on whether the user is concerned about at once to return results.
Fig. 2 is the structural representation of inquiry file.As shown in Figure 2, the present invention has defined a kind of unified file structure, and this document structure can adapt to various users' query demand.The user can define Query Information according to the demand of oneself, and the SQL statement that is used for the back is obtained the written document foundation of foundation and Query Result.The inquiry file of unified structure comprises information Control district and information data district, and the information Control district is used to store user's querying condition and user's self information, and the information data district is used for the return results of storing queries.The definition different system in information Control district can have different definition, but essential information is identical: the Query Information definitional part in information Control district can define query object, querying condition etc.; The user profile definitional part in information Control district can define user's identification information, as:
Whether be conjunctive query
The inquiry table name
Inquiry list of fields (defaulting to whole fields in the table)
Querying condition (defaulting to whole records)
The filename that generates
User totem information
The information data district of file structure generally can consist of the following components:
The data head in information data district part is in order to the field number of record queries and record number etc.;
The data type in information data district is described part in order to record field type and field length etc.;
The concrete outcome that the data recording portion in information data district obtains in order to record queries;
Certainly, different systems can have different definition in information Control district and the information data district.
Fig. 3 is the detail flowchart of " sub-processing unit structure query SQL statement " step among Fig. 1.As shown in Figure 3, specifically comprise the following steps: 1, the sub-processing unit of database calls file structure according to the user totem information in the query requests, obtain file structure and the given filename of information Control district user, and under given catalogue, open this file with read-write mode, if this document exists, then cover, if there is no, then generate a new file; 2, the sub-processing unit of database is judged the correctness of user input query information in the query requests, if user's fill message is incomplete, then returns failure information to the user, otherwise carries out next step; 3, the Query Information filled in according to the user of the sub-processing unit of database constructs the database SQL query statement; 4, whether the sub-processing unit checking of database query statement is correct, if incorrect, then returns failure information to the user, otherwise carries out next step inquiry.The user sends query requests to database processing unit, the sub-processing unit of database is analyzed this request, and judge that the user inserts the correctness of information (such as verifying whether table name is inserted), if fill message is incomplete, then return failure to the user, otherwise the sub-processing unit of database is after the query requests of receiving the database processing unit distribution, at first search in the information Control district, obtain relevant Query Information, and according to the SQL statement of the Query Information formation that obtains in order to inquiry, and the correctness of simple inspect statement (such as in the checking statement whether table name etc. being arranged) is if checking correctly, is then carried out next step inquiry, otherwise, return error number to the user.In a single day the sub-processing unit of database has verified the correctness of query statement, just imports query statement into database, carries out corresponding query manipulation in database.Query statement once imports database into, Query Result obtains one by one, in order to shield the difference between the different platform, sub-processing unit carries out preliminary analysis to Query Result, Query Result is write the information data district of file in the mode of network bytes preface, after inquiry is finished, the sub-processing unit close file of database, and prepare to return to the user.
The user is to the access of Query Result file for convenience, this method provides a series of file access interface, these access interfaces have utilized the access interface of file system itself, on original interface, encapsulated one deck, encapsulated layer provides to the analysis of Query Information and to the judgment processing of different platform in the network, makes the user need not to be concerned about the source and the structure of file when file is carried out access.These access interfaces comprise that document creation, File Open, file write, file reads, closing of a file, document alignment, file movement, file pointer current location and file delete.To being simply described as follows of these access interfaces:
Document creation
Judge whether file exists,, need then to judge whether to cover, if then cover original file if exist;
If file does not exist, directly create;
File Open
The judgement file is opened in which way, opens file as requested;
File writes
Judgement be to Query Information write or to the writing of Query Result, according to the different request that writes written documents;
File reads
Judgement be to Query Information read or to the reading of Query Result, the database processing subelement calls the reading of Query Information, the user calls reading Query Result;
Closing of a file
With the closing of a file of opening;
Document alignment
The pointer of file is navigated to certain position;
File movement
File is moved to another place from a place, can be moving between the identical platform, also can be moving between the different platform;
The file pointer current location
The position that the backspace file pointer is current;
File delete
File from deletion somewhere, if there is not authority, then returned failure and tells the lack of competence deletion, if authority is arranged, then directly deletion.
In a preferred embodiment of the present invention---in the telecom network management system (customer end/server mode), adopt method of the present invention to realize the data library inquiry, main implementation step is as follows:
1. querying condition definition
According to the unified file structure that provides in the said method, information Control district and information data district are defined respectively, information Control district segment template organization definition is as follows:
Information Control district head
Whether be conjunctive query (can be default, default to single table inquiry)
The filename that generates
User totem information
Information Control district content
The inquiry table name
Inquiry list of fields (can be default, default to whole fields)
Querying condition (can be default, default to whole records)
Information data district segment template organization definition is as follows:
Data head: the field number of record queries and record number etc.
Data type is described: record field type and field length, total length are the field number
Data recording: the particular content that record queries obtains
Client is filled in according to the query demand of oneself and is initially touched plate, and when client was confirmed filling in of oneself, the file structure that fills just was sent to database processing unit and keeps.In system's operational process, client can be revised Query Information at any time by interface, and the Query Information of modification can be recorded at once, and is retained in the later use.
2. query requests is handled
Client sends to the server database processing unit with query requests and inquires about, database processing unit is dispatched query requests, find non-loaded database processing subelement, and this request distributed to this database processing subelement, when the sub-processing unit of database is received query requests, call file structure according to user totem information, obtain the given filename of document structure information control zone user, and under the given catalogue of server, open this file with read-write mode, if this document exists, then cover, if there is no, then generate a new file.
The sub-processing unit that has distributed is implemented concrete query requests, and will inquire about the result be stored in the information data district of file, after one query finished fully, sub-processing unit returned to client with file.Client can be synchronous to the request of data library inquiry, also can be asynchronous, and this depends on whether it is concerned about at once to return results.
We provide a series of api functions to carry out the operation of database.In order under database linking number condition of limited, to make the database manipulation as much as possible can concurrent operations, at first Query Result is put into result cache for the operation of simple queries, take out each result when fetching data again one by one.
3. query statement obtains
The sub-processing unit of database is after the query requests of receiving the database processing unit distribution, then at first search in the information Control district, obtain relevant Query Information, and according to the SQL statement of the Query Information formation that obtains in order to inquiry, and the correctness of simple inspect statement (such as in the checking statement whether table name etc. being arranged) is if checking is correct, then carry out next step inquiry, otherwise, error number returned to client.
4. inquire about
In a single day the sub-processing unit of database has verified the correctness of query statement, just imports query statement into database, carries out corresponding query manipulation in database.
Query statement once imports database into, Query Result obtains one by one, in order to shield the difference between the different platform, sub-processing unit carries out preliminary analysis to Query Result, Query Result is write the information data district of file in the mode of network bytes preface, after inquiry is finished, the sub-processing unit close file of database, and prepare to return to client.
Querying method proposed by the invention is applicable to any customer end/server mode.The method that adopts the present invention to propose makes under limited database linking number, can finish each module for access of database, has shielded each line module to access of database; It also provides the monitoring function to database simultaneously, and solved and moved the influence that inquiry is brought, and the bottleneck problem of the inquiry of big data quantity on Network Transmission, and reduced the complexity that the user carries out query processing.