CN106844380A - A kind of database operation method, information processing method and related device - Google Patents
A kind of database operation method, information processing method and related device Download PDFInfo
- Publication number
- CN106844380A CN106844380A CN201510886241.5A CN201510886241A CN106844380A CN 106844380 A CN106844380 A CN 106844380A CN 201510886241 A CN201510886241 A CN 201510886241A CN 106844380 A CN106844380 A CN 106844380A
- Authority
- CN
- China
- Prior art keywords
- database
- data
- sql
- operating instruction
- language
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
- G06F16/2448—Query languages for particular applications; for extensibility, e.g. user defined types
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
- G06F16/2445—Data retrieval commands; View definitions
Abstract
This application provides a kind of database operation method, information processing method and related device.Wherein, the database operation method includes:Reading pre-set to certain database or the database operating instruction example of data-base cluster, the database operating instruction example is the set of corresponding with sql like language elementary instruction semantic primitive composition;According to the grammar rule for pre-setting, the institute's meaning elements based on the sql like language elementary instruction corresponding with the database operating instruction example are obtained;With institute's meaning elements as node unit, and according to the certain database or the literary name section of data-base cluster, syntax tree corresponding with the database operating instruction example is generated;According to the syntax tree, the database operating instruction example is translated as corresponding to the stsndard SQL operational order of the certain database or data-base cluster;The stsndard SQL operational order is performed, and obtains the returned data of the certain database or data-base cluster.
Description
Technical field
The application is related to internet arena, more particularly to a kind of database operation method based on big data, letter
Breath processing method and related device.
Background technology
In today's society, various information can be collected, stored and utilized in digitized form, and with
The development of ICT, various information in digitized form stored data amount be it is huge, also
Be it has often been said that big data.Accordingly, the information processing based on big data is also increasingly paid attention to by people,
For example, being based on big data, the effective extraction and analysis carried out to information have become Internet enterprises and obtain business
The important step of industry advantage.
Based on effective extraction and analysis that big data is carried out to information, it usually needs from the mass data that is stored with
Specific data are inquired about in database or data-base cluster, the specific data that will be inquired are used as at information
The source of reason.In this case, user is often desirable to come from various dimensions and each with flexibility ratio higher
Plant under filter condition, the specific data of simple and quick acquisition, and the letter that these data are further shown
Breath.Meanwhile, user wishes the information for obtaining, and having plenty of can have been deposited with database or data-base cluster
Field directly reflect that some are synthesized or pushed away by existing field in database or data-base cluster
Lead what is drawn.Therefore, in order to obtain the information desired by user, need to be carried from database or data-base cluster
Take specific data, and and displaying for further processing to specific data.
In addition, inquiring about specific data from database or data-base cluster, conventional method is to use SQL
(SQL) language is operated to database.Sql like language is used as a kind of Advanced Database language
Speech, allows users to ignore the different fabric of disparate databases, uses unified SQL
As data input and the interface for managing.Accordingly, it is currently based on effective extraction that big data is carried out to information
And analysis, conventional method is data query and treatment based on sql like language.
In the prior art, the data query based on sql like language includes with the common method for the treatment of:From data
Storehouse or data-base cluster extract specific data, and using JAVA, (program of object-oriented sets to these data
Meter language) language carries out logical process, so as to obtain the information desired by user;Or, by various letters
When breath is stored in digitized form, to the data of the corresponding digitized forms of these information, wished with user
The information for obtaining is according to being combined or the logical process such as deriving, then by the corresponding digitlization of these information
The data of form, and by combination or the data tissue that obtains of logical process such as derive and store to database
Or in data-base cluster.
First method as described above, has the disadvantage that:
1st, need to be developed for the specific access to information demand of user, for from various dimensions and various
Specific data are obtained under filter condition, and obtains the angle of the information that these data are further shown
See, flexibility ratio is not high, development amount is larger, the construction cycle is long, it is impossible to obtain user's information needed in time.
2nd, for different access to information demand, or different Database Systems, code cannot be multiplexed,
It is portable poor.
It is less efficient when larger data amount is processed when the 3rd, largely using JAVA language.
Second method as described above, has the disadvantage that:
During by data storage to database or data-base cluster, logical process need to be carried out to data,
For different data sources, i.e., different raw information, it is necessary to carry out the related exploitation of specific logical process,
And modification or again development logic treatment code are needed if data source changes, cause flexibility ratio not high,
Portable poor, development amount is big, and the construction cycle is long, it is impossible to obtain user's information needed in time.
The content of the invention
The application provides a kind of database operation method, information processing method and related device, existing to solve
Based on real time updating method under big data background it is high to physical device performance requirement, calculate poor real, money
Source occupation rate is high and does not possess the problem of autgmentability.
In order to solve the above technical problems, this application provides a kind of database operation method, including:
Reading pre-set to certain database or the database operating instruction example of data-base cluster, it is described
Database operating instruction example is the set of semantic primitive composition corresponding with sql like language elementary instruction;Wherein,
The order parameter that the database operating instruction example is included is the code module with logical semantics function;
According to the grammar rule for pre-setting, obtain corresponding with the database operating instruction example based on institute
State institute's meaning elements of sql like language elementary instruction;Wherein, institute's meaning elements include the sql like language
Elementary instruction keyword, and correspond to the order parameter of each elementary instruction;
With institute's meaning elements as node unit, and according to the certain database or the literary name of data-base cluster
Section, generates syntax tree corresponding with the database operating instruction example;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data.
Optionally, it is described pre-set to certain database or the database operating instruction reality of data-base cluster
Example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the corresponding order parameter of the command keyword;
Accordingly, the order parameter that the described database operating instruction example is included is with logical semantics
The code module of function, specifically referring to the order parameter that the database operating instruction example includes at least includes
Hereinafter there is the one kind in the code module of logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Optionally, the code module with logical semantics function, the work(with incoming external user parameter
Energy.
Optionally, the grammar rule that the basis pre-sets is being performed, acquisition refers to the database manipulation
Before the step of institute's meaning elements for making example corresponding based on the sql like language elementary instruction, perform following
Step:
Judge in the order parameter, the language with logical semantics function being made up of velocity template instructions
Sentence module, and/or the template file with logical semantics function based on velocity template instructions, if bag
Containing |input paramete;
If comprising according to the |input paramete and the logical-semantic relations, it is determined that with described by velocity
The sentence module with logical semantics function of template instruction composition, and/or it is described based on velocity template languages
The corresponding code module with fixed semantic function of template file with logical semantics function of speech;
If not including, according to the logical-semantic relations, it is determined that being made up of velocity template instructions with described
The sentence module with logical semantics function, and/or it is described based on velocity template instructions with logic
The corresponding code module with fixed semantic function of template file of semantic function.
Optionally, the grammar rule for pre-setting includes:SQL grammar rules and JAVA codes syntax rule
Then.
Optionally, it is described with institute's meaning elements as node unit, and according to the certain database or data
The literary name section of storehouse cluster, generates syntax tree corresponding with the database operating instruction example, including:
Identified the sql like language elementary instruction keyword in institute's meaning elements as host node, and institute
State the content that host node mark can be identified for that institute's meaning elements;
Identified according to the host node, and according to the certain database or the literary name section of data-base cluster, it is right
The order parameter that the host node is relied on carries out the recurrence identification of node dependence;
According to the result that the recurrence is recognized, child node is set.
Optionally, it is described to be identified according to the host node, and according to the certain database or data-base cluster
Literary name section, to the host node rely on the order parameter carry out node dependence recurrence identification,
Including:
The host node is identified into corresponding semantic primitive according to JAVA codes grammar rule carries out content fragment
Change is processed;
According to the content fragmentation result, obtain node dependence corresponding with the host node and
Rely on field;
The dependence field is carried out into field with the literary name section in the certain database or data-base cluster
Match somebody with somebody;
According to matching result, the dependence field identification that will be matched is target child node, is not matched
The dependence field identification is common child node.
Optionally, it is described to be entered the corresponding semantic primitive of host node mark according to JAVA codes grammar rule
The treatment of row content fragmentation, is specifically referred to according to JAVA code grammar rules, and the host node is identified into correspondence
Semantic primitive be decomposed into specific keyword, object, class, variable, method etc., and then recognize therein
Dependence between variable, and variable;
It is described according to the content fragmentation result, obtain node corresponding with the host node and rely on and close
System and dependence field, specifically refer to the variable in the content fragmentation result, and between variable
Dependence generate corresponding with host node node dependent tree;Wherein, the node dependent tree is each
Node is the variable in the content fragmentation result, and the topological structure of the node dependent tree is corresponding
The top-down dependence between each variable.
Optionally, it is described according to the syntax tree, the database operating instruction example is translated as corresponding to
The stsndard SQL operational order of the certain database or data-base cluster, including:
According to the syntax tree, obtain corresponding with the database operating instruction example based on sql like language
Command unit;Wherein, the keyword of the command unit is the host node of the syntax tree, the instruction sheet
The parameter of unit is the child node under the host node;
Based on sql like language grammar rule, each described command unit for obtaining is spliced, to have obtained
It is whole corresponding to the certain database or the stsndard SQL operational order of data-base cluster.
Optionally, in the execution stsndard SQL operational order, and the certain database or database are obtained
After the step of returned data of cluster, following steps are performed:
It is corresponding to each host node of the syntax tree according to certain database or the returning result of data-base cluster
The code module with logical semantics function included in institute's meaning elements carries out corresponding logical process;
Obtain variable corresponding with each node in the node dependent tree.
Optionally, it is described according to certain database or the returning result of data-base cluster, it is each to the syntax tree
The code module with logical semantics function included in the corresponding institute's meaning elements of host node is carried out accordingly
Logical process, including one of situations below or combination:
To there is the JAVA of logical semantics function in the returned data substitution database operating instruction example
Type code module, carries out corresponding logical process;
Have described in logical semantics function during the returned data is substituted into the database operating instruction example
SQL, carries out corresponding logical process;
There is logical semantics function during the returned data is substituted into the database operating instruction example
The corresponding sentence module of velocity template instructions, carries out corresponding logical process;
There is logical semantics function during the returned data is substituted into the database operating instruction example
The corresponding template file of velocity template instructions, carries out corresponding logical process.
Accordingly, the application also provides a kind of information processing method, including:
Receive the data retrieval request based on certain database or data-base cluster that user sends;
According to the data retrieval request, corresponding database operating instruction example is set;Wherein, the number
Include specific command keyword according to storehouse operational order example, and with each specific command keyword pair
The order parameter with logical semantics function answered;
According to the grammar rule for pre-setting, syntax tree corresponding with the database instruction example is generated;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
Corresponding logical semantics processing is carried out to the data that the specific database or data-base cluster are returned,
And then extract data corresponding with the data retrieval request.
Optionally, corresponding database operating instruction example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the instruction ginseng with logical semantics function corresponding with the command keyword
Number;
Wherein, the corresponding order parameter with logical semantics function of the command keyword at least includes following
One kind in code module with logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Accordingly, the application also provides a kind of database manipulation device, including:
Reading database operational order example element, for read pre-set to certain database or data
The database operating instruction example of storehouse cluster, the database operating instruction example is to refer to substantially with sql like language
Make the set of corresponding semantic primitive composition;Wherein, the instruction ginseng that the database operating instruction example is included
Number is the code module with logical semantics function;
The unit of semantic primitive is obtained, for according to the grammar rule for pre-setting, obtaining and the database
The corresponding institute's meaning elements based on the sql like language elementary instruction of operational order example;Wherein, it is described
Semantic primitive includes the sql like language elementary instruction keyword, and the finger for corresponding to each elementary instruction
Make parameter;
Generative grammar tree unit, for institute's meaning elements as node unit, and according to the specific data
Storehouse or the literary name section of data-base cluster, generate syntax tree corresponding with the database operating instruction example;
Translation unit, for according to the syntax tree, the database operating instruction example being translated as into correspondence
In the certain database or the stsndard SQL operational order of data-base cluster;
Execution unit, for performing the stsndard SQL operational order, and obtains the certain database or number
According to the returned data of storehouse cluster.
Optionally, in the reading database operational order example element, it is described pre-set to specific
The database operating instruction example of database or data-base cluster includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the corresponding order parameter of the command keyword;
Accordingly, the order parameter that the described database operating instruction example is included is with logical semantics
The code module of function, specifically referring to the order parameter that the database operating instruction example includes at least includes
Hereinafter there is the one kind in the code module of logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Accordingly, the application also provides a kind of information processor, described information processing unit, including:
Data retrieval request receiving unit, for receive user transmission based on certain database or data base set
The data retrieval request of group;
Database operating instruction example element is set, for according to the data retrieval request, setting corresponding
Database operating instruction example;Wherein, the database operating instruction example includes specific command keyword,
And the order parameter with logical semantics function corresponding with each specific command keyword;
Generative grammar tree unit, for according to the grammar rule for pre-setting, generation and the database instruction
The corresponding syntax tree of example;
Translation unit, for according to the syntax tree, the database operating instruction example being translated as into correspondence
In the certain database or the stsndard SQL operational order of data-base cluster;
Execution unit, for performing the stsndard SQL operational order, and obtains the certain database or number
According to the returned data of storehouse cluster;
Logical semantics machining cell, for entering to the data that the specific database or data-base cluster are returned
The corresponding logic of row.
Optionally, in the setting database operating instruction example element, corresponding database manipulation
Command Example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the instruction ginseng with logical semantics function corresponding with the command keyword
Number;
Wherein, the corresponding order parameter with logical semantics function of the command keyword at least includes following
One kind in code module with logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Accordingly, the application also provides a kind of electronic equipment, including:
Display;
Processor;And
Memory, the memory is configured to store database manipulation device, and/or information processor,
When the database manipulation device is by the computing device, following steps are performed:
Reading pre-set to certain database or the database operating instruction example of data-base cluster, it is described
Database operating instruction example is the set of semantic primitive composition corresponding with sql like language elementary instruction;Wherein,
The order parameter that the database operating instruction example is included is the code module with logical semantics function;
According to the grammar rule for pre-setting, obtain corresponding with the database operating instruction example based on institute
State institute's meaning elements of sql like language elementary instruction;Wherein, institute's meaning elements include the sql like language
Elementary instruction keyword, and correspond to the order parameter of each elementary instruction;
With institute's meaning elements as node unit, and according to the certain database or the literary name of data-base cluster
Section, generates syntax tree corresponding with the database operating instruction example;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
When described information processing unit is by the computing device, following steps are performed:
Receive the data retrieval request based on certain database or data-base cluster that user sends;
According to the data retrieval request, corresponding database operating instruction example is set;Wherein, the number
Include specific command keyword according to storehouse operational order example, and with each specific command keyword pair
The order parameter with logical semantics function answered;
According to the grammar rule for pre-setting, syntax tree corresponding with the database instruction example is generated;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
Corresponding logical semantics processing is carried out to the data that the specific database or data-base cluster are returned,
And then extract data corresponding with the data retrieval request.The database operation method that the application is provided, reads
Take pre-set to certain database or the database operating instruction example of data-base cluster, the database
Operational order example is the set of semantic primitive composition corresponding with sql like language elementary instruction;Wherein, it is described
The order parameter that database operating instruction example is included is the code module with logical semantics function;According to pre-
The grammar rule for first setting, obtains corresponding with the database operating instruction example based on the sql like language
Institute's meaning elements of elementary instruction;With institute's meaning elements as node unit, and according to the specific data
Storehouse or the literary name section of data-base cluster, generate syntax tree corresponding with the database operating instruction example;Root
According to the syntax tree, the database operating instruction example is translated as to correspond to the certain database or number
According to the stsndard SQL operational order of storehouse cluster;The stsndard SQL operational order is performed, and obtains described specific
The returned data of database or data-base cluster.This method is applied in big data, each due to the method
Command unit is based on sql like language, and code writes simple for structure clear, so that user can be to certain number
A kind of shirtsleeve operation method, the customizing messages needed for quick obtaining user are used according to storehouse or data-base cluster.
Furthermore it is possible to flexible set the module with logical process function, and JAVA language, velocity can be used
(based on JAVA template engine) template instruction, and can be explained and be performed by JAVA engines it is self-defined
Function so that user when specific data are obtained under various dimensions and various filter conditions, flexibility ratio compared with
Height, and code has preferably portability, reduces development amount, shortens the construction cycle.Meanwhile,
Due to the use of velocity template instructions so that when larger data amount is processed, efficiency is compared with prior art
Mode greatly improve.
Brief description of the drawings
Fig. 1 is the schematic flow sheet of the database operation method that the application first embodiment is provided;
Fig. 2 is the logical semantics functional module based on velocity template instructions to be processed in first embodiment
The step of specific embodiment flow chart;
The flow chart of the specific embodiment of the step of Fig. 3 is generative grammar tree in first embodiment;
Fig. 4 is the schematic flow sheet of the information processing method that the application second embodiment is provided;
Fig. 5 is a kind of schematic diagram of database manipulation device that the application 3rd embodiment is provided;
Fig. 6 is a kind of schematic diagram of information processor that the application fourth embodiment is provided;
Fig. 7 is the schematic diagram of a kind of electronic equipment that the embodiment of the present application is provided.
Specific embodiment
Elaborate many details in order to fully understand the application in the following description.But the application
Can be implemented with being much different from other manner described here, those skilled in the art can without prejudice to
Similar popularization is done in the case of the application intension, therefore the application is not limited by following public specific implementation.
In this application, a kind of database operation method, information processing method and related device are each provided,
It is described in detail one by one in the following embodiments.
Fig. 1 is refer to, the schematic flow sheet of its database operation method provided for the application first embodiment.
Methods described comprises the following steps:
Step S101:Reading pre-set to certain database or the database operating instruction of data-base cluster
Example, the database operating instruction example is semantic primitive composition corresponding with sql like language elementary instruction
Set;Wherein, the order parameter that the database operating instruction example is included is with logical semantics function
Code module.
Present context, relates generally to the information processing carried out based on big data, information processing institute foundation
Information source be primarily referred to as from certain database or data-base cluster obtain specific data.And these are counted
May there are complicated relation, and some data foundations therein according to the data in storehouse or data-base cluster
Complicated relation can derive specific information each other.Therefore the first embodiment of the application, mainly relates to
And the method for the certain database or the specific data of data-base cluster acquisition from storage big data.
When big data analysis is carried out, topmost demand is according in certain database or data-base cluster
Data, simple and flexible obtains specific data under various dimensions or various filter conditions, and then obtains specific
Information.Simple and flexible mentioned here under various dimensions or various filter conditions obtains specific data,
Specifically, it is to refer to set the specific condition with logical semantics function in a straightforward manner, and obtains
Take the data for meeting these conditions.Therefore the starting point of the present embodiment is set to certain database or database
The database operating instruction example of cluster, the database operating instruction example should method to set up it is simple, again
Function including setting logical semantics.
In the present embodiment, it is above-mentioned pre-set to certain database or the database manipulation of data-base cluster
Command Example includes:
101-1:Based on sql like language grammar rule, instruction corresponding with sql like language elementary instruction is set and is closed
Key word;
101-2:Based on JAVA grammers, velocity template instructions, and encapsulated can be by JAVA engines
The SQL explained and perform, sets the corresponding order parameter of the command keyword.
Accordingly, the order parameter that the described database operating instruction example is included is with logical semantics
The code module of function, specifically referring to the order parameter that the database operating instruction example includes at least includes
Hereinafter there is the one kind in the code module of logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Wherein, the above-mentioned code module with logical semantics function, the function with incoming external user parameter.
In the present embodiment, it is specifically described with the sample of following database operating instruction example.
Above sample, the only format write of the major function of database operating instruction example, are only illustrated with this
The implementation method of the present embodiment, specific complete code is not represented.
In above-mentioned sample, made with " select ", " from ", " where ", " group by ", " order by "
Be command keyword corresponding with sql like language elementary instruction, and respectively with defined function " sumBy " and
" getIndCatNameById ", JAVA sentence modules, and velocity sentences module these there is logic
The module of semantic function is used as the corresponding order parameter of command keyword.There is logical semantics function at these
Have external user parameter incoming in module respectively, and according to external user parameter and database or database
Literary name section in cluster, obtains the filter condition that user wishes to set, or obtain the original that user wishes to obtain
This in database or data cluster non-existent dummy variable, and then according to these filter conditions and these
Dummy variable obtains specific information.
Because the introducing of velocity template instructions to above-mentioned database operating instruction example, it is necessary to perform the syntax
Before analysis, the logical semantics functional module based on velocity template instructions is processed.Fig. 2 is first real
Apply the specific reality of the step of processing the logical semantics functional module based on velocity template instructions in example
The flow chart of mode is applied, is concretely comprised the following steps:
Step S201:Judge in the order parameter, by velocity template instructions constitute with logic
The sentence module of semantic function, and/or the template with logical semantics function based on velocity template instructions
File, if comprising |input paramete.
Step S202:If comprising according to the |input paramete and the logical-semantic relations, it is determined that and institute
The sentence module with logical semantics function being made up of velocity template instructions is stated, and/or described is based on
Of velocity template instructions
Code module.
Step S203:If not including, according to the logical-semantic relations, it is determined that with described by velocity
The sentence module with logical semantics function of template instruction composition, and/or it is described based on velocity template languages
The corresponding code module with fixed semantic function of template file with logical semantics function of speech.
In the present embodiment, by starting velocity engines come implementation steps S201 to step S203.By
The treatment of velocity engines, is processed according to external user parameter and logical semantics, further determines that above-mentioned number
According to the order parameter structure of storehouse operational order example.For example, in above-mentioned sample, at velocity engines
Reason, if stock_num_1_15 variables are present, " where#genWhere () " is further determined as:
" where 1=1and stock_num_1_15>Xxx ", wherein xxx are the value of stock_num_1_15 variables;
If stock_num_1_15 variables do not exist, " where#genWhere () " is further determined as:“where
1=1 ".Thus, by defining external user parameter stock_num_1_15, it is possible to user is flexibly set
Putting filter condition carries out the extraction of specific data to certain database or data-base cluster.
Step S102:According to the grammar rule for pre-setting, obtain and the database operating instruction example pair
The institute's meaning elements based on the sql like language elementary instruction answered;Wherein, institute's meaning elements include institute
State sql like language elementary instruction keyword, and the order parameter for corresponding to each elementary instruction.
By the treatment of velocity engines, in addition it is also necessary to crucial to the instruction in above-mentioned database operating instruction example
Word, and other modules with logical semantics function are analyzed.
In the present embodiment, the above-mentioned grammar rule for pre-setting includes:SQL grammar rules and JAVA codes
Grammar rule.
By taking above-mentioned sample as an example, according to the grammar rule for pre-setting, above-mentioned sample be resolved to " select ",
" from ", " where ", " group by " and " order by " these keywords divide obtained by semantic primitive.
Step S103:With institute's meaning elements as node unit, and according to the certain database or database
The literary name section of cluster, generates syntax tree corresponding with the database operating instruction example.
Fig. 3 is the flow chart of the specific embodiment in first embodiment the step of generative grammar tree.Specific step
Suddenly it is:
Step S301:Using the sql like language elementary instruction keyword in institute's meaning elements as host node
Mark, and host node mark can be identified for that the content of institute's meaning elements.
For example, the above-mentioned sample in for the present embodiment, with keyword " select ", " from ", " where ",
" group by " and " order by " these keywords are identified as host node.
Step S302:Identified according to the host node, and according to the certain database or data-base cluster
Literary name section, the recurrence identification of node dependence is carried out to the order parameter that the host node is relied on.
The step of above-mentioned recurrence is recognized, comprises the following steps:
Step S302-1:The host node is identified into corresponding semantic primitive according to JAVA codes grammar rule to enter
The treatment of row content fragmentation.
The treatment of the above fragmentation, specifically refers to according to JAVA code grammar rules, by the host node mark
Know corresponding semantic primitive and be decomposed into specific keyword, object, class, variable, method etc., and then recognize
Variable therein, and the dependence between variable.
In the present embodiment, with " select ", " from ", " where ", " group by " and " order by "
Semantic primitive obtained by the division of these keywords, comprising the code module with logical semantics function, these generations
Code module or based on sql like language grammar rule, or based on JAVA code grammar rules, it is semantic single to these
Unit carries out fragmentation treatment by mutually deserved grammar rule, i.e., character string of semantic primitive etc. is entered with grammar rule
Row separates, and parses the content for obtaining the minimum units such as operator, variable.For example, for above-mentioned sample
For " select " host node, the variable that parsing is obtained includes:“sell_num”、“catName”、
" javaTest ", " stock_num_1_15 ", " stock_num_16_30 ", and " stock_num_46_60 ".
Step S302-2:According to the content fragmentation result, section corresponding with the host node is obtained
Point dependence and dependence field.
During above-mentioned fragmentation treatment is carried out, the minimum units such as operator, variable are obtained in parsing
While content, moreover it is possible to obtain the dependence between variable, current primary node, i.e. current semantics are thus obtained
Unit is to deserved node dependence.Specifically, refer to according in the content fragmentation result
Dependence between variable, and variable generates node dependent tree corresponding with the host node;Wherein, institute
Each node for stating node dependent tree is the variable in the content fragmentation result, and the node is relied on
The topological structure of tree corresponds to top-down dependence between each variable.
For example, the above-mentioned sample in for the present embodiment, for " select " host node, can obtain following
Dependence:
" catName " realization rely on variable be:" javaTest ", and the realization of " javaTest " is relied on
Variable be:" stock_num_1_15 ", " stock_num_16_30 ", and " stock_num_46_60 ".
Wherein, " stock_num_1_15 ", " stock_num_16_30 ", and " stock_num_46_60 " be according to
The bottom of the relation of relying, by " stock_num_1_15 ", " stock_num_16_30 ", and
" stock_num_46_60 " is used as dependence field.
Step S302-3:By the literary name section in dependence field and the certain database or the data-base cluster
Carry out fields match.
In the present embodiment, by setting field enumerator, respectively by above-mentioned dependence field one by one with the spy
The literary name section determined in database or data-base cluster is matched.In dependence field, with the certain database
Or the field of the literary name section matching in data-base cluster, i.e., it is true in described certain database or data-base cluster
The field of presence, look-up command when being just to look for the certain database or data-base cluster is truly corresponding
Parameter.For example, in above-mentioned sample " for select host nodes, " stock_num_1_15 ",
" stock_num_16_30 ", and " stock_num_46_60 " is the certain database or data-base cluster
The field of middle necessary being, then field " stock_num_1_15 ", " stock_num_16_30 ", and
" stock_num_46_60 " is real Lookup Field when performing the database operating instruction template,
And " javaTest " and " catName " further according to " stock_num_1_15 ", " stock_num_16_30 ",
The value of " stock_num_46_60 ", and corresponding logical-semantic relations are obtained.
For above-mentioned dependence, if " stock_num_1_15 ", " stock_num_16_30 ", and
" stock_num_46_60 " is the field of necessary being in the certain database or data-base cluster, then
" javaTest " and " catName " is considered as virtual presence in the certain database or data-base cluster
Field.
In above-mentioned sample, " select " host node also includes dependence corresponding with " sumBy " SQL
Relation, that is, depend on the field " sell_num " of necessary being in the certain database or data-base cluster
Virtual field " sell_sum ".
Step S302-4:According to matching result, the dependence field identification that will be matched is target child node,
The dependence field identification not matched is common child node.
Step S303:According to the result that the recurrence is recognized, child node is set.
For example, the above-mentioned sample in for the present embodiment, by " catName " and " sell_sum " as main
Child node under node " select ", " javaTest " as " catName " next stage child node,
" sell_num " as " sell_sum " next stage child node, and " stock_num_1_15 ",
" stock_num_16_30 ", and " stock_num_46_60 " but as " javaTest " next stage section
Point.Wherein " stock_num_1_15 ", " stock_num_16_30 ", " stock_num_46_60 " and
" sell_num " is the literary name section of necessary being in the certain database or data-base cluster, is identified as mesh
Mark child node.
Thus, the database operating instruction example forms syntax tree through parsing, and then will be to the data
The syntax identification and parsing of storehouse operational order example, are converted into the parsing to the syntax tree, to described specific
The true operation of database or data-base cluster, can be obtained by the concrete structure of syntax tree.
In the present embodiment, the generation of the setting of grammar rule, and syntax tree, be by syntactic analysis engine,
Such as ANTLR syntactic analyses engine is realized.
Step S104:According to the syntax tree, the database operating instruction example is translated as to correspond to institute
State the stsndard SQL operational order of certain database or data-base cluster.
In the present embodiment, the database operating instruction example is generated and the database manipulation through parsing
The corresponding syntax tree of Command Example.Each host node of the syntax tree can be regarded as what is divided with command keyword,
Command unit based on sql like language, thus above-mentioned translation steps specifically include:
Step S104-1:According to the syntax tree, base corresponding with the database operating instruction example is obtained
In the command unit of sql like language;Wherein, the keyword of the command unit is the host node of the syntax tree,
The parameter of the command unit is the child node under the host node.
Step S104-2:Based on sql like language grammar rule, each described command unit for obtaining is spliced,
It is complete corresponding to the certain database or the stsndard SQL operational order of data-base cluster to obtain.
For the sample that the present embodiment is provided, it is assumed that stock_num_1_15 variables are defined, and assignment
Xxx, then what is obtained is complete corresponding to the certain database or the stsndard SQL operational order of data-base cluster
It is as follows:
select sell_num,stock_num_1_15,stock_num_16_30,stock_num_46_60
from rbbDQ.dde_kuling_sku_data
Where 1=1and stock_num_1_15>xxx
group by cat_id_2th
Step S105:The stsndard SQL operational order is performed, and obtains the certain database or database
The returned data of cluster.
In the sample that the present embodiment is provided, after the stsndard SQL operational order is performed, returned data storehouse
In rbbDQ.dde_kuling_sku_data, eligible " stock_num_1_15>" sell_num " of xxx ",
The data of " stock_num_1_15 ", " stock_num_16_30 " and " stock_num_46_60 " field.
But the field and non-user of necessary being finally expect the data for obtaining in these databases, therefore, performing
The complete stsndard SQL operational order, and obtain the returned data of the certain database or data-base cluster
After step, following steps need to be performed:
Step S105-1:It is each to the syntax tree according to certain database or the returning result of data-base cluster
The code module with logical semantics function included in the corresponding institute's meaning elements of host node is carried out accordingly
Logical process.
Above-mentioned corresponding logical process includes one of situations below or combination:
1) there is logical semantics function in the returned data being substituted into the database operating instruction example
JAVA type code modules, carry out corresponding logical process.
2) institute that will there is logical semantics function in the returned data substitution database operating instruction example
SQL is stated, corresponding logical process is carried out.
3) there is logical semantics function in the returned data being substituted into the database operating instruction example
The corresponding sentence module of velocity template instructions, carries out corresponding logical process.
4) there is logical semantics function in the returned data being substituted into the database operating instruction example
The corresponding template file of velocity template instructions, carries out corresponding logical process.
Step S105-2:Obtain variable corresponding with each node in the node dependent tree.
For the sample that the present embodiment is provided, after the data of the field for getting necessary being in database,
The dependence of " sell_sum " and " catName " is found according to syntax tree respectively, corresponding logic is carried out
Treatment, and the data that end user expects to obtain are obtained, wherein " sell_sum " passes through SQL " sumBy "
Obtain, " catName " is by the code module based on JAVA grammers and calls
" getIndCatNameById " method is obtained.Meanwhile, when the data that user's expectation is obtained are given, also need
By the logical process of " order by javaTest ".
For example, for the dependence on " catName ", when " javaTest " is obtained, due to " javaTest "
It is the code module based on JAVA grammers, therefore JAVA engines can be started to be handled as follows:
1) content of pair code module related to " javaTest " is extracted.
2) structure based on JAVA grammers is carried out to the content, is compiled, loads and is called.
3) after being disposed, the data cleansings such as internal memory release treatment is carried out.
4) returned data.
In the sample that the present embodiment is provided, the final user for obtaining expects the form of the data for obtaining, with
Form using stsndard SQL operational order fetched data is identical, is the form of two-dimensional array.Simply,
In the final user for obtaining expects the data for obtaining, " sell_sum ", " catName " and " javaTest "
The field of necessary being, is user-defined virtual field in field and non-database.
In sum, the method described in the present embodiment there are provided a kind of database operating instruction template,
It is by setting the code module with logical semantics function and outside in the database operating instruction template
Customer parameter, so as to obtain specific corresponding in specific database or the database manipulation of data-base cluster
Command Example, and by velocity logical process, SQL and java syntax analysis, generate corresponding to the number
According to the syntax tree of storehouse operational order example, and then obtain and truly deposit in the specific database or data-base cluster
Field data, and further obtain user expect obtain data, and from user expect obtain
Specific information is obtained in data.
In the above-described embodiment, there is provided a kind of database operation method, corresponding, the application
Second embodiment provides a kind of information processing method.Fig. 4 is refer to, it is provided for the application second embodiment
The schematic flow sheet of information processing method.
Described information processing method comprises the following steps:
Step S401:Receive the data retrieval request based on certain database or data-base cluster that user sends.
Step S402:According to the data retrieval request, corresponding database operating instruction example is set;Its
In, the database operating instruction example include specific command keyword, and with each specific finger
The order parameter with logical semantics function that makes keyword corresponding.
Above-mentioned corresponding database operating instruction example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the instruction ginseng with logical semantics function corresponding with the command keyword
Number;
Wherein, the corresponding order parameter with logical semantics function of the command keyword at least includes following
One kind in code module with logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Step S403:According to the grammar rule for pre-setting, generate corresponding with the database instruction example
Syntax tree.
The specific steps of generative grammar tree have been discussed in detail in the application first embodiment in this step, at this
Repeated no more in embodiment, specific generation step referring to embodiment of the method appropriate section.
Step S404:According to the syntax tree, the database operating instruction example is translated as to correspond to institute
State the stsndard SQL operational order of certain database or data-base cluster.
The specific steps translated in this step have been discussed in detail in the application first embodiment, in the present embodiment
In repeat no more, specific translation steps referring to embodiment of the method appropriate section.
Step S405:The stsndard SQL operational order is performed, and obtains the certain database or database
The returned data of cluster.
Step S406:Corresponding logic is carried out to the data that the specific database or data-base cluster are returned
Semantic Processing, and then extract data corresponding with the data retrieval request.
The data and non-user of the return of the certain database or data-base cluster finally expect the number for obtaining
According to, therefore the data returned to the specific database or data-base cluster are also needed, according in order parameter
Corresponding logical semantics function carries out corresponding logical semantics processing, and then extracts and the data retrieval request
Corresponding data.The specific steps of logical semantics treatment are detailed in the application first embodiment in this step
Introduce, repeat no more in the present embodiment, specific process step referring to embodiment of the method appropriate section.
In the above-described embodiment, a kind of database operation method and information processing method, phase are each provided
Answer, present invention also provides corresponding device.Because device embodiment is substantially similar to embodiment of the method,
So description is fairly simple, the relevent part can refer to the partial explaination of embodiments of method.Described below
Device embodiment is only schematical.
Fig. 5 is refer to, a kind of schematic diagram of its database manipulation device provided for the application 3rd embodiment.
A kind of database manipulation device of the present embodiment, including:Reading database operational order example element 5-1, obtain
Take unit 5-2, generative grammar tree unit 5-3, the translation unit 5-4 and execution unit 5-5 of semantic primitive.
Above-mentioned reading database operational order example element 5-1, for read pre-set to certain database
Or the database operating instruction example of data-base cluster, the database operating instruction example is and sql like language
The set of the corresponding semantic primitive composition of elementary instruction;Wherein, the database operating instruction example is included
Order parameter is the code module with logical semantics function.
In above-mentioned reading database operational order example element 5-1, it is described pre-set to certain database
Or the database operating instruction example of data-base cluster includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the corresponding order parameter of the command keyword;
Accordingly, the order parameter that the described database operating instruction example is included is with logical semantics
The code module of function, specifically referring to the order parameter that the database operating instruction example includes at least includes
Hereinafter there is the one kind in the code module of logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
The unit 5-2 of above-mentioned acquisition semantic primitive, for according to the grammar rule that pre-sets, obtain with it is described
The corresponding institute's meaning elements based on the sql like language elementary instruction of database operating instruction example;Wherein,
Institute's meaning elements include the sql like language elementary instruction keyword, and the institute for corresponding to each elementary instruction
State order parameter.
Above-mentioned generative grammar tree unit 5-3, for institute's meaning elements as node unit, and according to the spy
Determine the literary name section of database or data-base cluster, generate grammer corresponding with the database operating instruction example
Tree.
Above-mentioned translation unit 5-4, for according to the syntax tree, by database operating instruction example translation
It is the stsndard SQL operational order corresponding to the certain database or data-base cluster.
Above-mentioned execution unit 5-5, for performing the stsndard SQL operational order, and obtains the specific data
Storehouse or the returned data of data-base cluster.
Fig. 6 is refer to, a kind of schematic diagram of its information processor provided for the application fourth embodiment.This
A kind of information processor of embodiment, including:Data retrieval request receiving unit 6-1, setting database behaviour
Make Command Example unit 6-2, generative grammar tree unit 6-3, translation unit 6-4, execution unit 6-5 and logic
Semantic Processing unit 6-6.
Above-mentioned data retrieval request receiving unit 6-1, for receive user transmission based on certain database or number
According to the data retrieval request of storehouse cluster.
Above-mentioned setting database operating instruction example element 6-2, for according to the data retrieval request, setting
Corresponding database operating instruction example;Wherein, the database operating instruction example includes specific instruction
Keyword, and the order parameter with logical semantics function corresponding with each specific command keyword.
In above-mentioned setting database operating instruction example element 6-2, corresponding database operating instruction reality
Example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the instruction ginseng with logical semantics function corresponding with the command keyword
Number;
Wherein, the corresponding order parameter with logical semantics function of the command keyword at least includes following
One kind in code module with logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
Above-mentioned generative grammar tree unit 6-3, for according to the grammar rule for pre-setting, generation and the data
The corresponding syntax tree of storehouse Command Example.
Above-mentioned translation unit 6-4, for according to the syntax tree, by database operating instruction example translation
It is the stsndard SQL operational order corresponding to the certain database or data-base cluster.
Above-mentioned execution unit 6-5, for performing the stsndard SQL operational order, and obtains the specific data
Storehouse or the returned data of data-base cluster.
Above-mentioned logical semantics machining cell 6-6, for what is returned to the specific database or data-base cluster
Data carry out corresponding logical semantics processing, and then extract data corresponding with the data retrieval request.
A kind of above-mentioned embodiment for each providing database operation method, information processing method and related device,
Accordingly, the application also provides a kind of electronic equipment.
Fig. 7 is refer to, it illustrates the schematic diagram of the electronic equipment provided according to embodiments herein.
The electronic equipment includes:
Display 701;
Processor 702;And
Memory 703, the memory is configured to store database manipulation device, and/or information processing apparatus
Put,
When the database manipulation device is performed by the processor 702, following steps are performed:
Reading pre-set to certain database or the database operating instruction example of data-base cluster, it is described
Database operating instruction example is the set of semantic primitive composition corresponding with sql like language elementary instruction;Wherein,
The order parameter that the database operating instruction example is included is the code module with logical semantics function;
According to the grammar rule for pre-setting, obtain corresponding with the database operating instruction example based on institute
State institute's meaning elements of sql like language elementary instruction;Wherein, institute's meaning elements include the sql like language
Elementary instruction keyword, and correspond to the order parameter of each elementary instruction;
With institute's meaning elements as node unit, and according to the certain database or the literary name of data-base cluster
Section, generates syntax tree corresponding with the database operating instruction example;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
When described information processing unit is performed by the processor 702, following steps are performed:
Receive the data retrieval request based on certain database or data-base cluster that user sends;
According to the data retrieval request, corresponding database operating instruction example is set;Wherein, the number
Include specific command keyword according to storehouse operational order example, and with each specific command keyword pair
The order parameter with logical semantics function answered;
According to the grammar rule for pre-setting, syntax tree corresponding with the database instruction example is generated;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
Corresponding logical semantics processing is carried out to the data that the specific database or data-base cluster are returned,
And then extract data corresponding with the data retrieval request.
Although the application is disclosed as above with preferred embodiment, it is not for limiting the application, Ren Heben
Art personnel are not being departed from spirit and scope, can make possible variation and modification,
Therefore the scope that the protection domain of the application should be defined by the application claim is defined.
In a typical configuration, computing device includes one or more processors (CPU), input/output
Interface, network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory
And/or the form, such as read-only storage (ROM) or flash memory (flash RAM) such as Nonvolatile memory (RAM).
Internal memory is the example of computer-readable medium.
1st, computer-readable medium includes that permanent and non-permanent, removable and non-removable media can be by
Any method or technique realizes information Store.Information can be computer-readable instruction, data structure, journey
The module of sequence or other data.The example of the storage medium of computer includes, but are not limited to phase transition internal memory
(PRAM), static RAM (SRAM), dynamic random access memory (DRAM), its
The random access memory (RAM) of his type, read-only storage (ROM), electrically erasable is read-only deposits
Reservoir (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage
(CD-ROM), digital versatile disc (DVD) or other optical storages, magnetic cassette tape, tape magnetic magnetic
Disk storage or other magnetic storage apparatus or any other non-transmission medium, can be used for storage can be set by calculating
The standby information for accessing.Defined according to herein, computer-readable medium does not include non-temporary computer-readable matchmaker
Body (transitory media), such as data-signal and carrier wave of modulation.
2nd, it will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer
Program product.Therefore, the application can use complete hardware embodiment, complete software embodiment or combine software
With the form of the embodiment of hardware aspect.And, the application can be used and wherein include meter at one or more
Calculation machine usable program code computer-usable storage medium (including but not limited to magnetic disk storage,
CD-ROM, optical memory etc.) on implement computer program product form.
Claims (18)
1. a kind of database operation method, it is characterised in that methods described includes:
Reading pre-set to certain database or the database operating instruction example of data-base cluster, it is described
Database operating instruction example is the set of semantic primitive composition corresponding with sql like language elementary instruction;Wherein,
The order parameter that the database operating instruction example is included is the code module with logical semantics function;
According to the grammar rule for pre-setting, obtain corresponding with the database operating instruction example based on institute
State institute's meaning elements of sql like language elementary instruction;Wherein, institute's meaning elements include the sql like language
Elementary instruction keyword, and correspond to the order parameter of each elementary instruction;
With institute's meaning elements as node unit, and according to the certain database or the literary name of data-base cluster
Section, generates syntax tree corresponding with the database operating instruction example;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data.
2. database operation method according to claim 1, it is characterised in that described to pre-set
Database operating instruction example to certain database or data-base cluster includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the corresponding order parameter of the command keyword;
Accordingly, the order parameter that the described database operating instruction example is included is with logical semantics
The code module of function, specifically referring to the order parameter that the database operating instruction example includes at least includes
Hereinafter there is the one kind in the code module of logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
3. database operation method according to claim 2, it is characterised in that described with logic language
The code module of adopted function, the function with incoming external user parameter.
4. database operation method according to claim 3, it is characterised in that performing the basis
The grammar rule for pre-setting, obtains corresponding with the database operating instruction example based on the SQL languages
Before the step of saying institute's meaning elements of elementary instruction, following steps are performed:
Judge in the order parameter, the language with logical semantics function being made up of velocity template instructions
Sentence module, and/or the template file with logical semantics function based on velocity template instructions, if bag
Containing |input paramete;
If comprising according to the |input paramete and the logical-semantic relations, it is determined that with described by velocity
The sentence module with logical semantics function of template instruction composition, and/or it is described based on velocity template languages
The corresponding code module with fixed semantic function of template file with logical semantics function of speech;
If not including, according to the logical-semantic relations, it is determined that being made up of velocity template instructions with described
The sentence module with logical semantics function, and/or it is described based on velocity template instructions with logic
The corresponding code module with fixed semantic function of template file of semantic function.
5. database operation method according to claim 4, it is characterised in that described to pre-set
Grammar rule includes:SQL grammar rules and JAVA code grammar rules.
6. database operation method according to claim 5, it is characterised in that described with the semanteme
Unit is node unit, and according to the certain database or the literary name section of data-base cluster, generation with it is described
The corresponding syntax tree of database operating instruction example, including:
Identified the sql like language elementary instruction keyword in institute's meaning elements as host node, and institute
State the content that host node mark can be identified for that institute's meaning elements;
Identified according to the host node, and according to the certain database or the literary name section of data-base cluster, it is right
The order parameter that the host node is relied on carries out the recurrence identification of node dependence;
According to the result that the recurrence is recognized, child node is set.
7. database operation method according to claim 6, it is characterised in that described according to the master
Node identification, and according to the certain database or the literary name section of data-base cluster, the host node is relied on
The order parameter carry out node dependence recurrence identification, including:
The host node is identified into corresponding semantic primitive according to JAVA codes grammar rule carries out content fragment
Change is processed;
According to the content fragmentation result, obtain node dependence corresponding with the host node and
Rely on field;
The dependence field is carried out into field with the literary name section in the certain database or data-base cluster
Match somebody with somebody;
According to matching result, the dependence field identification that will be matched is target child node, is not matched
The dependence field identification is common child node.
8. database operation method according to claim 7, it is characterised in that described according to JAVA
The host node is identified corresponding semantic primitive and carries out content fragmentation treatment by code grammar rule, specifically
Refer to according to JAVA code grammar rules, the host node is identified into corresponding semantic primitive is decomposed into specific pass
Key word, object, class, variable, method etc., and then variable therein is recognized, and the dependence pass between variable
System;
It is described according to the content fragmentation result, obtain node corresponding with the host node and rely on and close
System and dependence field, specifically refer to the variable in the content fragmentation result, and between variable
Dependence generate corresponding with host node node dependent tree;Wherein, the node dependent tree is each
Node is the variable in the content fragmentation result, and the topological structure of the node dependent tree is corresponding
The top-down dependence between each variable.
9. database operation method according to claim 8, it is characterised in that described according to institute's predicate
Method tree, the database operating instruction example is translated as to correspond to the certain database or data-base cluster
Stsndard SQL operational order, including:
According to the syntax tree, obtain corresponding with the database operating instruction example based on sql like language
Command unit;Wherein, the keyword of the command unit is the host node of the syntax tree, the instruction sheet
The parameter of unit is the child node under the host node;
Based on sql like language grammar rule, each described command unit for obtaining is spliced, to have obtained
It is whole corresponding to the certain database or the stsndard SQL operational order of data-base cluster.
10. database operation method according to claim 9, it is characterised in that performing the mark
Quasi- SQL operational orders, and the step of obtain the returned data of the certain database or data-base cluster after,
Perform following steps:
It is corresponding to each host node of the syntax tree according to certain database or the returning result of data-base cluster
The code module with logical semantics function included in institute's meaning elements carries out corresponding logical process;
Obtain variable corresponding with each node in the node dependent tree.
11. database operation methods according to claim 10, it is characterised in that described according to specific
The returning result of database or data-base cluster, to the corresponding institute's meaning elements of each host node of the syntax tree
In the code module with logical semantics function that includes carry out corresponding logical process, including situations below it
One combines:
To there is the JAVA of logical semantics function in the returned data substitution database operating instruction example
Type code module, carries out corresponding logical process;
Have described in logical semantics function during the returned data is substituted into the database operating instruction example
SQL, carries out corresponding logical process;
There is logical semantics function during the returned data is substituted into the database operating instruction example
The corresponding sentence module of velocity template instructions, carries out corresponding logical process;
There is logical semantics function during the returned data is substituted into the database operating instruction example
The corresponding template file of velocity template instructions, carries out corresponding logical process.
12. a kind of information processing methods, it is characterised in that methods described includes:
Receive the data retrieval request based on certain database or data-base cluster that user sends;
According to the data retrieval request, corresponding database operating instruction example is set;Wherein, the number
Include specific command keyword according to storehouse operational order example, and with each specific command keyword pair
The order parameter with logical semantics function answered;
According to the grammar rule for pre-setting, syntax tree corresponding with the database instruction example is generated;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
Corresponding logical semantics processing is carried out to the data that the specific database or data-base cluster are returned,
And then extract data corresponding with the data retrieval request.
13. information processing methods according to claim 12, it is characterised in that corresponding data
Storehouse operational order example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the instruction ginseng with logical semantics function corresponding with the command keyword
Number;
Wherein, the corresponding order parameter with logical semantics function of the command keyword at least includes following
One kind in code module with logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
14. a kind of database manipulation devices, it is characterised in that described device includes:
Reading database operational order example element, for read pre-set to certain database or data
The database operating instruction example of storehouse cluster, the database operating instruction example is to refer to substantially with sql like language
Make the set of corresponding semantic primitive composition;Wherein, the instruction ginseng that the database operating instruction example is included
Number is the code module with logical semantics function;
The unit of semantic primitive is obtained, for according to the grammar rule for pre-setting, obtaining and the database
The corresponding institute's meaning elements based on the sql like language elementary instruction of operational order example;Wherein, it is described
Semantic primitive includes the sql like language elementary instruction keyword, and the finger for corresponding to each elementary instruction
Make parameter;
Generative grammar tree unit, for institute's meaning elements as node unit, and according to the specific data
Storehouse or the literary name section of data-base cluster, generate syntax tree corresponding with the database operating instruction example;
Translation unit, for according to the syntax tree, the database operating instruction example being translated as into correspondence
In the certain database or the stsndard SQL operational order of data-base cluster;
Execution unit, for performing the stsndard SQL operational order, and obtains the certain database or number
According to the returned data of storehouse cluster.
15. database manipulation devices according to claim 14, it is characterised in that in the receive data
According to storehouse operational order example element, it is described pre-set to certain database or the data of data-base cluster
Storehouse operational order example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the corresponding order parameter of the command keyword;
Accordingly, the order parameter that the described database operating instruction example is included is with logical semantics
The code module of function, specifically referring to the order parameter that the database operating instruction example includes at least includes
Hereinafter there is the one kind in the code module of logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
16. a kind of information processors, it is characterised in that described device includes:
Data retrieval request receiving unit, for receive user transmission based on certain database or data base set
The data retrieval request of group;
Database operating instruction example element is set, for according to the data retrieval request, setting corresponding
Database operating instruction example;Wherein, the database operating instruction example includes specific command keyword,
And the order parameter with logical semantics function corresponding with each specific command keyword;
Generative grammar tree unit, for according to the grammar rule for pre-setting, generation and the database instruction
The corresponding syntax tree of example;
Translation unit, for according to the syntax tree, the database operating instruction example being translated as into correspondence
In the certain database or the stsndard SQL operational order of data-base cluster;
Execution unit, for performing the stsndard SQL operational order, and obtains the certain database or number
According to the returned data of storehouse cluster;
Logical semantics machining cell, for entering to the data that the specific database or data-base cluster are returned
The corresponding logical semantics processing of row, and then extract data corresponding with the data retrieval request.
17. information processors according to claim 16, it is characterised in that in the setting data
In the operational order example element of storehouse, corresponding database operating instruction example includes:
Based on sql like language grammar rule, command keyword corresponding with sql like language elementary instruction is set;
Based on JAVA grammers, velocity template instructions, and encapsulated can by JAVA engines explain and
The SQL of execution, sets the instruction ginseng with logical semantics function corresponding with the command keyword
Number;
Wherein, the corresponding order parameter with logical semantics function of the command keyword at least includes following
One kind in code module with logical semantics function:
The sentence module with logical semantics function being made up of JAVA language;
Based on JAVA language or based on other language and the self-defined letter that can be explained and be performed by JAVA engines
Number;
The sentence module with logical semantics function being made up of velocity template instructions;
The template file with logical semantics function based on velocity template instructions.
18. a kind of electronic equipment, it is characterised in that including:
Display;
Processor;And
Memory, the memory is configured to store database manipulation device, and/or information processor,
When the database manipulation device is by the computing device, following steps are performed:
Reading pre-set to certain database or the database operating instruction example of data-base cluster, it is described
Database operating instruction example is the set of semantic primitive composition corresponding with sql like language elementary instruction;Wherein,
The order parameter that the database operating instruction example is included is the code module with logical semantics function;
According to the grammar rule for pre-setting, obtain corresponding with the database operating instruction example based on institute
State institute's meaning elements of sql like language elementary instruction;Wherein, institute's meaning elements include the sql like language
Elementary instruction keyword, and correspond to the order parameter of each elementary instruction;
With institute's meaning elements as node unit, and according to the certain database or the literary name of data-base cluster
Section, generates syntax tree corresponding with the database operating instruction example;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
When described information processing unit is by the computing device, following steps are performed:
Receive the data retrieval request based on certain database or data-base cluster that user sends;
According to the data retrieval request, corresponding database operating instruction example is set;Wherein, the number
Include specific command keyword according to storehouse operational order example, and with each specific command keyword pair
The order parameter with logical semantics function answered;
According to the grammar rule for pre-setting, syntax tree corresponding with the database instruction example is generated;
According to the syntax tree, the database operating instruction example is translated as to correspond to the specific data
Storehouse or the stsndard SQL operational order of data-base cluster;
The stsndard SQL operational order is performed, and obtains the return of the certain database or data-base cluster
Data;
Corresponding logical semantics processing is carried out to the data that the specific database or data-base cluster are returned,
And then extract data corresponding with the data retrieval request.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510886241.5A CN106844380A (en) | 2015-12-04 | 2015-12-04 | A kind of database operation method, information processing method and related device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510886241.5A CN106844380A (en) | 2015-12-04 | 2015-12-04 | A kind of database operation method, information processing method and related device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106844380A true CN106844380A (en) | 2017-06-13 |
Family
ID=59150925
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510886241.5A Pending CN106844380A (en) | 2015-12-04 | 2015-12-04 | A kind of database operation method, information processing method and related device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106844380A (en) |
Cited By (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107526730A (en) * | 2017-08-29 | 2017-12-29 | 惠州Tcl移动通信有限公司 | A kind of management method, storage medium and electronic equipment for translating data |
CN107633094A (en) * | 2017-10-11 | 2018-01-26 | 江苏神州信源系统工程有限公司 | The method and apparatus of data retrieval in a kind of cluster environment |
CN108984620A (en) * | 2018-06-14 | 2018-12-11 | 中国科学院重庆绿色智能技术研究院 | A kind of relevant database and its design method of dynamic scalable |
CN109241037A (en) * | 2018-08-28 | 2019-01-18 | 郑州云海信息技术有限公司 | A kind of method, apparatus that realizing database processing, equipment and storage medium |
CN109284088A (en) * | 2018-08-02 | 2019-01-29 | 北京天元创新科技有限公司 | A kind of signaling big data processing method and electronic equipment |
CN109324905A (en) * | 2018-09-30 | 2019-02-12 | 拉卡拉支付股份有限公司 | Database operation method, device, electronic equipment and storage medium |
CN109582528A (en) * | 2018-09-11 | 2019-04-05 | 阿里巴巴集团控股有限公司 | State monitoring method, device, electronic equipment and computer readable storage medium |
CN109901873A (en) * | 2019-02-26 | 2019-06-18 | 北京真知科技有限公司 | Software function reconstructing method and device based on syntax tree |
CN109992614A (en) * | 2018-11-14 | 2019-07-09 | 阿里巴巴集团控股有限公司 | Data capture method, device and server |
CN110096513A (en) * | 2019-04-10 | 2019-08-06 | 阿里巴巴集团控股有限公司 | A kind of data query, fund checking method and device |
CN110716953A (en) * | 2019-10-10 | 2020-01-21 | 深圳前海微众银行股份有限公司 | SQL statement automatic generation method, device, equipment and readable storage medium |
CN110795451A (en) * | 2019-09-18 | 2020-02-14 | 平安科技(深圳)有限公司 | SQL fingerprint restoration method and device, computer equipment and storage medium |
CN111176802A (en) * | 2019-07-26 | 2020-05-19 | 腾讯科技(深圳)有限公司 | Task processing method and device, electronic equipment and storage medium |
CN111797073A (en) * | 2019-11-26 | 2020-10-20 | 北京京东尚科信息技术有限公司 | Database management method, electronic device, and computer-readable storage medium |
CN113268638A (en) * | 2021-04-21 | 2021-08-17 | 洛阳墨潇网络科技有限公司 | Action library generation method and device based on big data |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH10283371A (en) * | 1997-04-04 | 1998-10-23 | Nec Corp | Data base device |
CN101788992A (en) * | 2009-05-06 | 2010-07-28 | 厦门东南融通系统工程有限公司 | Method and system for converting query sentence of database |
CN103488738A (en) * | 2013-09-18 | 2014-01-01 | 北京思特奇信息技术股份有限公司 | Method and system for automatically realizing JAVA object and data table SQL (structured query language) file |
US20140181073A1 (en) * | 2012-12-20 | 2014-06-26 | Business Objects Software Ltd. | Method and system for generating optimal membership-check queries |
CN104252510A (en) * | 2013-11-05 | 2014-12-31 | 深圳市华傲数据技术有限公司 | SQL (Structural Query Language) language translation method and SQL language translation device |
-
2015
- 2015-12-04 CN CN201510886241.5A patent/CN106844380A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH10283371A (en) * | 1997-04-04 | 1998-10-23 | Nec Corp | Data base device |
CN101788992A (en) * | 2009-05-06 | 2010-07-28 | 厦门东南融通系统工程有限公司 | Method and system for converting query sentence of database |
US20140181073A1 (en) * | 2012-12-20 | 2014-06-26 | Business Objects Software Ltd. | Method and system for generating optimal membership-check queries |
CN103488738A (en) * | 2013-09-18 | 2014-01-01 | 北京思特奇信息技术股份有限公司 | Method and system for automatically realizing JAVA object and data table SQL (structured query language) file |
CN104252510A (en) * | 2013-11-05 | 2014-12-31 | 深圳市华傲数据技术有限公司 | SQL (Structural Query Language) language translation method and SQL language translation device |
Cited By (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107526730A (en) * | 2017-08-29 | 2017-12-29 | 惠州Tcl移动通信有限公司 | A kind of management method, storage medium and electronic equipment for translating data |
CN107526730B (en) * | 2017-08-29 | 2022-03-25 | 惠州Tcl移动通信有限公司 | Translation data management method, storage medium and electronic device |
CN107633094A (en) * | 2017-10-11 | 2018-01-26 | 江苏神州信源系统工程有限公司 | The method and apparatus of data retrieval in a kind of cluster environment |
CN108984620B (en) * | 2018-06-14 | 2021-02-05 | 中国科学院重庆绿色智能技术研究院 | Design method of dynamic extensible relational database |
CN108984620A (en) * | 2018-06-14 | 2018-12-11 | 中国科学院重庆绿色智能技术研究院 | A kind of relevant database and its design method of dynamic scalable |
CN109284088A (en) * | 2018-08-02 | 2019-01-29 | 北京天元创新科技有限公司 | A kind of signaling big data processing method and electronic equipment |
CN109284088B (en) * | 2018-08-02 | 2022-04-26 | 北京天元创新科技有限公司 | Signaling big data processing method and electronic equipment |
CN109241037A (en) * | 2018-08-28 | 2019-01-18 | 郑州云海信息技术有限公司 | A kind of method, apparatus that realizing database processing, equipment and storage medium |
CN109582528A (en) * | 2018-09-11 | 2019-04-05 | 阿里巴巴集团控股有限公司 | State monitoring method, device, electronic equipment and computer readable storage medium |
CN109582528B (en) * | 2018-09-11 | 2023-02-28 | 创新先进技术有限公司 | State monitoring method and device, electronic equipment and computer readable storage medium |
CN109324905B (en) * | 2018-09-30 | 2021-03-30 | 拉卡拉支付股份有限公司 | Database operation method and device, electronic equipment and storage medium |
CN109324905A (en) * | 2018-09-30 | 2019-02-12 | 拉卡拉支付股份有限公司 | Database operation method, device, electronic equipment and storage medium |
CN109992614A (en) * | 2018-11-14 | 2019-07-09 | 阿里巴巴集团控股有限公司 | Data capture method, device and server |
CN109901873B (en) * | 2019-02-26 | 2022-05-10 | 北京真知科技有限公司 | Software function reconstruction method and device based on syntax tree |
CN109901873A (en) * | 2019-02-26 | 2019-06-18 | 北京真知科技有限公司 | Software function reconstructing method and device based on syntax tree |
CN110096513A (en) * | 2019-04-10 | 2019-08-06 | 阿里巴巴集团控股有限公司 | A kind of data query, fund checking method and device |
CN111176802A (en) * | 2019-07-26 | 2020-05-19 | 腾讯科技(深圳)有限公司 | Task processing method and device, electronic equipment and storage medium |
WO2021051522A1 (en) * | 2019-09-18 | 2021-03-25 | 平安科技(深圳)有限公司 | Sql fingerprint restoration method and apparatus, computer device and storage medium |
CN110795451B (en) * | 2019-09-18 | 2023-05-16 | 平安科技(深圳)有限公司 | SQL fingerprint restoring method, SQL fingerprint restoring device, SQL fingerprint restoring computer equipment and storage medium |
CN110795451A (en) * | 2019-09-18 | 2020-02-14 | 平安科技(深圳)有限公司 | SQL fingerprint restoration method and device, computer equipment and storage medium |
CN110716953B (en) * | 2019-10-10 | 2023-08-22 | 深圳前海微众银行股份有限公司 | SQL sentence automatic generation method, device, equipment and readable storage medium |
CN110716953A (en) * | 2019-10-10 | 2020-01-21 | 深圳前海微众银行股份有限公司 | SQL statement automatic generation method, device, equipment and readable storage medium |
CN111797073A (en) * | 2019-11-26 | 2020-10-20 | 北京京东尚科信息技术有限公司 | Database management method, electronic device, and computer-readable storage medium |
CN113268638A (en) * | 2021-04-21 | 2021-08-17 | 洛阳墨潇网络科技有限公司 | Action library generation method and device based on big data |
CN113268638B (en) * | 2021-04-21 | 2024-04-16 | 普惠通科技(河南)股份有限公司 | Big data-based action library generation method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106844380A (en) | A kind of database operation method, information processing method and related device | |
US11334692B2 (en) | Extracting a knowledge graph from program source code | |
JP5431513B2 (en) | Interpreting command scripts using local and extended storage for command indexing | |
CN100557609C (en) | A kind of persistent layer generation method and device | |
US20140156282A1 (en) | Method and system for controlling target applications based upon a natural language command string | |
CN112560100B (en) | Data desensitizing method and device, computer readable storage medium and electronic equipment | |
CN108984155B (en) | Data processing flow setting method and device | |
CN102622453A (en) | Body-based food security event semantic retrieval system | |
CN110688151B (en) | Safety translation and analysis method for Ether house identity intelligent contract | |
CN104063314A (en) | Test data automatic generation device and test data automatic generation method | |
CN105706092A (en) | Methods and systems of four-valued simulation | |
CN100561476C (en) | A kind of code generating method based on the ASN type object | |
CN114328574A (en) | Data query method and device, electronic equipment and computer-readable storage medium | |
CN108536728A (en) | A kind of data query method and apparatus | |
CN103678396B (en) | A kind of data back up method and device based on data model | |
CN109933331A (en) | Data transfer device and associated component between a kind of client-server | |
CN109116828A (en) | Model code configuration method and device in a kind of controller | |
CN106599241A (en) | Big data visual management method for GIS software | |
CN113918149A (en) | Interface development method and device, computer equipment and storage medium | |
KR100762712B1 (en) | Method for transforming of electronic document based on mapping rule and system thereof | |
Härer | Towards Interoperability of Open and Permissionless Blockchains: A Cross-Chain Query Language | |
CN113741864B (en) | Automatic semantic service interface design method and system based on natural language processing | |
CN102999717A (en) | Rapid implantation code generating system applied to buffer area overflow in network security permeation test | |
CN114391151A (en) | Enhanced natural language generation platform | |
CN107341021A (en) | The software network of large complicated software belt restraining logical attribute represents, storage and retrieval method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20180423 Address after: Four story 847 mailbox of the capital mansion of Cayman Islands, Cayman Islands, Cayman Applicant after: CAINIAO SMART LOGISTICS HOLDING Ltd. Address before: Cayman Islands Grand Cayman capital building a four storey No. 847 mailbox Applicant before: ALIBABA GROUP HOLDING Ltd. |
|
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170613 |