Specific embodiment
To keep the purposes, technical schemes and advantages of this specification clearer, it is embodied below in conjunction with this specification
This specification technical solution is clearly and completely described in example and corresponding attached drawing.Obviously, described embodiment is only this
Specification a part of the embodiment, instead of all the embodiments.The embodiment of base in this manual, ordinary skill people
Member's every other embodiment obtained without making creative work, belongs to the range of this specification protection.
Several relevant Name Resolutions are incorporated herein in the scheme of this specification embodiment for ease of understanding.
Directed acyclic graph (directed acyclic graph, DAG): in graph theory, if digraph can not be from
Some vertex, which is set out, returns to the point by several sides, then this figure is a DAG figure.
Abstract syntax tree (Abstract Syntax Tree, AST): being the tree-shaped performance of the abstract syntax structure of source code
Form, each node on tree indicate one of source code structure.Why say that grammer is " abstract ", is because here
Grammer can't represent each details occurred in true grammer.For example, nested parenthesis is implied in the structure of tree, and
It is presented not in the form of node;And it is similar to conditional jump sentence as if-condition-then, it can be used and have
The node of Liang Ge branch indicates.
This specification embodiment provides a kind of data query method, system and terminal device, to solve to count in the prior art
Lack normative, the problem of query logic is more complex, higher cost according to querying method.This specification embodiment provides a kind of data
Querying method, the executing subject of this method can be, but not limited to terminal device or can be configured as executing this specification implementation
The device or system of this method that example provides.
For ease of description, hereafter executing subject in this way is to be able to carry out for the terminal device of this method, to this
The embodiment of method is introduced.It is appreciated that it is that one kind is illustratively said that the executing subject of this method, which is terminal device,
It is bright, it is not construed as the restriction to this method.
Fig. 1 is the flow chart for the data query method that this specification embodiment provides, and the method for Fig. 1 can be by terminal device
It executes, as shown in Figure 1, this method may include:
Step 110, in response to the data inquiry request, obtain data query parameter.
The data inquiry request can be used for transmitting data query parameter.
Before executing step 110, the data query method can also include receiving data inquiry request.
The sending object of the data inquiry request can be peripheral system or other equipment.
Step 120, the corresponding DAG executive plan of the building data query parameter.
The DAG executive plan is directed acyclic graph executive plan.
The corresponding DAG executive plan of building data query parameter, it is specific to can be achieved are as follows: to be based on data query parameter, structure
Build the corresponding DAG executive plan of data query parameter.
Illustratively, by taking data query scene 1 as an example, the data query scene 1 have query node A, query node B,
Query node C and query node D.
The corresponding DAG executive plan of building data query parameter, it is specific to can be achieved are as follows: based on query node A, inquiry section
Point B, query node C and query node D construct directed acyclic graph DAG;Based on each query node in directed acyclic graph DAG it
Between logical relation, construct DAG executive plan.
Step 130, the input parameter that frame is inquired using the data query parameter as DAG, pass through the DAG query frame
Frame executes the corresponding DAG executive plan of the query argument.
The DAG inquires query logic of the frame for query node in characterize data query argument.
This inquires the input parameter of frame using the data query parameter as DAG, specific to can be achieved are as follows:
Firstly, by data query Parameter Switch at the input parameter of DAG inquiry frame, such as by the format of data query parameter
It is converted to the consistent format of input parameter with DAG inquiry frame.
Then, using the data query parameter after conversion as the input parameter of DAG inquiry frame.
What needs to be explained here is that when entering DAG inquiry frame, need to initialize the context, each of DAG inquiry frame
The context of node and the input parameter of part of nodes, for example, the Starting Executing Time etc. of initialization DAG inquiry frame.
Step 140, execution result back.
This specification embodiment is by the corresponding DAG executive plan of building data query parameter, with data query parameter work
The input parameter that frame is inquired for DAG inquires frame by DAG and executes the corresponding DAG executive plan of query argument, to pass through
DAG inquires frame for query logic node, and data query process is clearly showed by query node series connection
Come, query logic is simplified;Moreover, data query can all be realized by DAG inquiry unified frame in most of inquiry scenes,
With normalization;DAG inquiry frame can allow user freely to realize the distinctive query logic of each query node, avoid understanding
Analysis is time-consuming, and cost is relatively low.
Optionally, as one embodiment, after executing step 120, the data query of this specification embodiment offer
Method can also include:
Based on the data in query argument multiple queries node attribute information, DAG is split into multiple sub- DAG;
Based on the multiple sub- DAG, processing is optimized to the DAG executive plan.
Illustratively, as shown in Fig. 2, by taking data query scene 2 as an example, which has query node A
(inquiry product information), query node B (inquiry contract information) and query node C (pooling information).
Wherein, query node B (inquiry contract information) can be refined as query node B1(inquiry contract essential information) is looked into
Ask node B21(inquiry contract attribute information) and query node B3(merging contract information) and query node B1(inquiry contract base
This information), query node B22(inquiry contract text information) and query node B3(merging contract information).
Therefore, it in this specification embodiment, (can will be inquired based on query node A (inquiry product information), query node B
Contract information) and query node C (pooling information), the DAG of building split, obtained: based on query node A (inquiry product
Information), query node B1(inquiry contract essential information), query node B21(inquiry contract attribute information), query node B3It (closes
And contract information) and query node C (pooling information) building sub- DAG, and based on query node A (inquiry product information), look into
Ask node B1(inquiry contract essential information), query node B22(inquiry contract text information), query node B3(merge contract letter
Breath) and query node C (pooling information) construct sub- DAG.
Attribute information of this specification embodiment based on multiple queries node in data query parameter, DAG is split into more
A sub- DAG is based on multiple sub- DAG, optimizes processing to DAG executive plan, can be with so that subsequent when carrying out data query
Obtain detailed query result.
Optionally, as one embodiment, after executing step 120, the data query of this specification embodiment offer
Method can also include:
Based on the data in query argument between multiple queries node adjacent query node incidence relation, merge association
Query node, and update DAG;
Based on updated DAG, processing is optimized to the DAG executive plan.
Illustratively, as shown in figure 3, by taking data query scene 3 as an example, which has query node A
(preposition processing), query node B (contract number is inquired according to user id), query node C (contract information is inquired according to contract number)
With query node D (postpositive disposal).
Wherein, query node B (inquiring contract number according to user id) and query node C (inquire contract letter according to contract number
Breath) there are progressive incidence relations, it is (direct according to user id query node B and query node C can be merged into query node O
Inquire contract information).
Therefore, in this specification embodiment, query node A (preposition processing), query node B will can be based on (according to user
Id inquires contract number), query node C (contract information is inquired according to contract number) and query node D (postpositive disposal), building
DAG is updated, and is obtained: (contract letter is directly inquired according to user id based on query node A (preposition processing), query node O
Breath) and the new DAG of query node D (postpositive disposal) building.
This specification embodiment is closed based on the association of adjacent query node between multiple queries node in data query parameter
System, merges associated query node, and update DAG;Based on updated DAG, processing is optimized to DAG executive plan, it can
To simplify query node quantity, so that it is subsequent when carrying out data query, query procedure can be accelerated.
Need exist for supplement, can optimizing that treated, DAG executive plan caches, in order to it is subsequent again
It carries out that DAG executive plan can be read when data query directly from caching, reduces the consumption of data query time, improve data and look into
Ask efficiency.
Optionally, as one embodiment, step 130 specifically be can be achieved are as follows:
Enter angle value based on query node in the corresponding DAG of DAG inquiry frame, determines the in-degree of the query node
The query node that value is zero is pending query node;
Serially execute or parallel execute by way of, execute the pending query node, and by the DAG with institute
The angle value that enters for stating other query nodes of pending query node directed connection subtracts one.
It will be appreciated that the process of the execution is the process of a circulation.At the stage of execution, determine that respectively inquiry saves in DAG
Point enters angle value;Enter angle value based on query node each in DAG, determine query node enter query node that angle value is zero be to
Execute query node;When executing the stage into query node, all pending query nodes can by serially executing or parallel
The mode of execution executes.Wherein, the execution of pending query node can be controlled by the system switching of terminal device,
Can be specified by terminal device under specifically inquiry scene using specific executive mode, with for different inquiry scenes into
Row optimization.The angle value that enters of other query nodes with pending query node directed connection is subtracted one, until zero is reduced to, it can quilt
DAG inquiry frame is loaded and is executed, and the state of the query node after execution is set as completing, until all nodes are carried out
It completes.
Optionally, as one embodiment, step 130 specific implementation may include:
At least side of at least one query node in the DAG configures interface;Illustratively, in DAG extremely
The execution front-end configuration front interface of a few query node, and/or, after the execution of at least one query node in DAG
End configuration postposition interface.
Step 130 implements
By way of Java note, the input that the output parameter of current queries node is mapped to next query node is joined
Number.
It will be appreciated that the output parameter of current queries node is formatted processing, with unified current queries node and
The format of next query node;Again using the output parameter of current queries node as the input parameter of next query node.
The embodiment of the present invention is by configuring interface for at least side of at least one query node in DAG, with to look into
It askes node and executes the execution time that additional step is reserved in front and back, to improve scalability;By by the output of current queries node
Parameter is mapped to the input parameter of next query node, to support the customized various input parameters of user, improves flexibility.
Optionally, as one embodiment, after executing step 130, the data query of this specification embodiment offer
Method can also include:
By the note of total execution time of all query nodes in the execution time of query node each in the DAG and the DAG
Record is in journal file.
It will be appreciated that DAG inquires frame can be by all query nodes in the implementation procedure of entire DAG executive plan
Total execution time and the execution time of each query node are recorded in journal file in a standard format.
This specification embodiment, which inquires frame by DAG, to be owned in the execution time of query node each in DAG and DAG
Total execution time of query node is recorded in journal file, can be by being analyzed journal file and being counted, Ji Kefang
Just the entire data query process of grasp and efficiency data query can be not susceptible to performance bottleneck etc. and be asked with locating query node
Topic.
Optionally, as one embodiment, step 130 specific implementation can also include:
Determine whether the execution condition for executing the DAG executive plan meets exceptional condition;
The DAG executive plan is executed if so, terminating.
The execution condition can be query time and/or inquiry situation, correspondingly, the exceptional condition can be time-out or look into
It askes and exception occurs.
It will be appreciated that start execute DAG executive plan enter inquiry circulation when, it is thus necessary to determine that execute DAG executive plan
The execution time it is whether overtime, and/or, execute DAG executive plan occur it is abnormal;DAG executive plan is executed if so, terminating.
You need to add is that cause of accident can be fed back after terminating execution DAG executive plan.
This specification embodiment is by determining whether the execution condition for executing DAG executive plan meets exceptional condition;If so,
It then terminates and executes the DAG executive plan, the execution of DAG executive plan is effectively protected, safeguard measure is perfect.
Optionally, as one embodiment, after executing step 110, the data query of this specification embodiment offer
Method can also include:
Correctness and/or non-empty verification are carried out to the data query parameter.
The embodiment of the present invention is by carrying out correctness and/or non-empty verification to data query parameter, so that data query
Parameter is more acurrate, improves the accuracy, correctness and normalization of data query parameter.
Below in conjunction with specific embodiments, the method for the embodiment of the present invention is further described.
Fig. 4 shows flow chart of the data query method provided in an embodiment of the present invention under practical application scene;
Specifically, as shown in Figure 4:
400, data inquiry request is received, and in response to the data inquiry request, obtains data query parameter.
410, correctness is carried out to the data query parameter and/or non-empty verifies.
420, the corresponding DAG executive plan of the data query parameter is constructed.
430, data query parameter is converted to the consistent parameter of input parameter format with DAG inquiry frame.
440, the input parameter of frame is inquired using the data query parameter as DAG, and frame is inquired by the DAG
Execute the corresponding DAG executive plan of the query argument.
The specific implementation of this step can be with are as follows: angle value is entered based on query node in the corresponding DAG of DAG inquiry frame,
The query node that angle value is zero that enters for determining the query node is pending query node;By serially executing or executing parallel
Mode, execute the pending query node, and by other inquiries in the DAG with pending query node directed connection
The angle value that enters of node subtracts one.
The specific implementation of this step may include: to determine whether the execution condition for executing the DAG executive plan meets exception
Condition;The DAG executive plan is executed if so, terminating.
Wherein, which can be query time and/or inquiry situation, correspondingly, the exceptional condition can be super
When or inquiry occur it is abnormal.
The specific implementation of this step, which may include: that the front side configuration of at least one query node in the DAG is preposition, to be connect
Mouthful.
The specific implementation of this step may include: to be mapped the output parameter of current queries node by way of Java note
To the input parameter of next query node.
The specific implementation of this step may include: that the rear side configuration postposition of at least one query node in the DAG connects
Mouthful.
450, execution result back.
This specification embodiment is by the corresponding DAG executive plan of building data query parameter, with data query parameter work
The input parameter that frame is inquired for DAG inquires frame by DAG and executes the corresponding DAG executive plan of query argument, to pass through
DAG inquires frame for query logic node, and data query process is clearly showed by query node series connection
Come, query logic is simplified;Moreover, data query can all be realized by DAG inquiry unified frame in most of inquiry scenes,
With normalization;DAG inquiry frame can allow user freely to realize the distinctive query logic of each query node, avoid understanding
Analysis is time-consuming, and cost is relatively low.
More than, the data query method of this specification embodiment is described in detail in conjunction with Fig. 1 to Fig. 4, in the following, in conjunction with Fig. 5,
The data query system of this specification embodiment is described in detail.
Fig. 5 shows the structural schematic diagram of the data query system of this specification embodiment offer, as shown in figure 5, the number
May include: according to inquiry system 500
Module 510 is obtained, for obtaining data query parameter in response to data inquiry request;
Module 520 is constructed, for constructing the corresponding DAG executive plan of the data query parameter;
Execution module 530, for inquiring the input parameter of frame using the data query parameter as DAG, by described
DAG inquires frame and executes the corresponding DAG executive plan of the query argument;Wherein, the DAG inquiry frame is used for characterize data
The query logic of query node in query argument;
Feedback module 540 is used for execution result back.
In one embodiment, the data query system 500 can also include:
Module is split to split into DAG for the attribute information of multiple queries node in query argument based on the data
Multiple sub- DAG;
First processing module optimizes processing to the DAG executive plan for being based on the multiple sub- DAG.
In one embodiment, the data query system 500 can also include:
Merging module, the association for adjacent query node between multiple queries node in query argument based on the data
Relationship merges associated query node, and updates DAG;
Second processing module optimizes processing to the DAG executive plan for being based on updated DAG.
In one embodiment, the execution module 530 includes:
First determination unit is determined for entering angle value based on query node in the corresponding DAG of DAG inquiry frame
The query node that angle value is zero that enters of the query node is pending query node;
Execution unit, for serially execute or parallel execute by way of, execute the pending query node, and will
The angle value that enters in the DAG with other query nodes of the pending query node directed connection subtracts one.
In one embodiment, the execution module 530 can also include:
Configuration unit, at least side at least one query node in the DAG configure interface;
The execution module 530 may include:
Map unit, for by way of Java note, the output parameter of current queries node to be mapped to next inquiry
The input parameter of node.
In one embodiment, the data query system 500 can also include:
Logging modle, for by all query nodes in the execution time of query node each in the DAG and the DAG
Total execution time be recorded in journal file.
In one embodiment, the execution module 530 can also include:
Second determination unit, for determining whether the execution condition for executing the DAG executive plan meets exceptional condition;
Execution unit is terminated, if the execution condition for the DAG executive plan meets exceptional condition, terminates and executes institute
State DAG executive plan.
In one embodiment, the data query system 500 can also include:
Inspection module, for carrying out correctness and/or non-empty verification to the data query parameter.
This specification embodiment is by the corresponding DAG executive plan of building data query parameter, with data query parameter work
The input parameter that frame is inquired for DAG inquires frame by DAG and executes the corresponding DAG executive plan of query argument, to pass through
DAG inquires frame for query logic node, and data query process is clearly showed by query node series connection
Come, query logic is simplified;Moreover, data query can all be realized by DAG inquiry unified frame in most of inquiry scenes,
With normalization;DAG inquiry frame can allow user freely to realize the distinctive query logic of each query node, avoid understanding
Analysis is time-consuming, and cost is relatively low.
Fig. 6 is the structural schematic diagram for the terminal device that one embodiment of this specification provides.Referring to FIG. 6, in hardware
Level, the terminal device include processor, optionally further comprising internal bus, network interface, memory.Wherein, memory can
It can include memory, such as high-speed random access memory (Random-Access Memory, RAM), it is also possible to further include non-easy
The property lost memory (non-volatile memory), for example, at least 1 magnetic disk storage etc..Certainly, which is also possible to
Including hardware required for other business.
Processor, network interface and memory can be connected with each other by internal bus, which can be ISA
(Industry Standard Architecture, industry standard architecture) bus, PCI (Peripheral
Component Interconnect, Peripheral Component Interconnect standard) bus or EISA (Extended Industry Standard
Architecture, expanding the industrial standard structure) bus etc..The bus can be divided into address bus, data/address bus, control always
Line etc..Only to be indicated with a four-headed arrow in Fig. 6, it is not intended that an only bus or a type of convenient for indicating
Bus.
Memory, for storing program.Specifically, program may include program code, and said program code includes calculating
Machine operational order.Memory may include memory and nonvolatile memory, and provide instruction and data to processor.
Processor is from the then operation into memory of corresponding computer program is read in nonvolatile memory, in logical layer
The associated apparatus of resource increment object and resource object is formed on face.Processor executes the program that memory is stored, and specific
For performing the following operations:
In response to data inquiry request, data query parameter is obtained;
Construct the corresponding DAG executive plan of the data query parameter;
The input parameter that frame is inquired using the data query parameter as DAG is inquired frame by the DAG and executes institute
State the corresponding DAG executive plan of query argument;Wherein, the DAG inquiry frame is for inquiring section in characterize data query argument
The query logic of point;
Execution result back.
This specification embodiment is by the corresponding DAG executive plan of building data query parameter, with data query parameter work
The input parameter that frame is inquired for DAG inquires frame by DAG and executes the corresponding DAG executive plan of query argument, to pass through
DAG inquires frame for query logic node, and data query process is clearly showed by query node series connection
Come, query logic is simplified;Moreover, data query can all be realized by DAG inquiry unified frame in most of inquiry scenes,
With normalization;DAG inquiry frame can allow user freely to realize the distinctive query logic of each query node, avoid understanding
Analysis is time-consuming, and cost is relatively low.
Data query method disclosed in the above-mentioned embodiment illustrated in fig. 1 such as this specification can be applied in processor, or
It is realized by processor.Processor may be a kind of IC chip, the processing capacity with signal.During realization, on
Each step for stating method can be completed by the integrated logic circuit of the hardware in processor or the instruction of software form.It is above-mentioned
Processor can be general processor, including central processing unit (Central Processing Unit, CPU), network processes
Device (Network Processor, NP) etc.;Can also be digital signal processor (Digital Signal Processor,
DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate
Array (Field-Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or crystalline substance
Body pipe logical device, discrete hardware components.It may be implemented or execute and is in this specification one or more embodiment disclosed
Each method, step and logic diagram.General processor can be microprocessor or the processor be also possible to it is any conventional
Processor etc..The step of method in conjunction with disclosed in this specification one or more embodiment, can be embodied directly in hardware decoding
Processor executes completion, or in decoding processor hardware and software module combination execute completion.Software module can position
In random access memory, flash memory, read-only memory, programmable read only memory or electrically erasable programmable memory, register
In the storage medium of equal this fields maturation.The storage medium is located at memory, and processor reads the information in memory, in conjunction with it
Hardware completes the step of above method.
The terminal device can also carry out the data query method of Fig. 1 performed by the data query system of Fig. 5, and this specification exists
This is repeated no more.
Certainly, other than software realization mode, other implementations are not precluded in the terminal device of this specification, such as
Logical device or the mode of software and hardware combining etc., that is to say, that the executing subject of following process flow is not limited to multiple
Logic unit is also possible to hardware or logical device.
This specification embodiment also provides a kind of computer readable storage medium, is stored on computer readable storage medium
Computer program, the computer program realize multiple processes of above-mentioned multiple embodiments of the method when being executed by processor, and can reach
To identical technical effect, to avoid repeating, which is not described herein again.Wherein, the computer readable storage medium, it is such as read-only
Memory (Read-Only Memory, abbreviation ROM), random access memory (Random Access Memory, abbreviation
RAM), magnetic or disk etc..
It should be understood by those skilled in the art that, the embodiment of this specification can provide as method, system or computer journey
Sequence product.Therefore, in terms of this specification can be used complete hardware embodiment, complete software embodiment or combine software and hardware
Embodiment form.Moreover, it wherein includes computer usable program code that this specification, which can be used in one or more,
The computer implemented in computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of program product.
This specification is referring to the method, equipment (system) and computer program product according to this specification embodiment
Flowchart and/or the block diagram describes.It should be understood that can be realized by computer program instructions every in flowchart and/or the block diagram
The combination of process and/or box in one process and/or box and flowchart and/or the block diagram.It can provide these computers
Processor of the program instruction to general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices
To generate a machine, so that generating use by the instruction that computer or the processor of other programmable data processing devices execute
It is in realize the function of specifying in one or more flows of the flowchart and/or one or more blocks of the block diagram
System.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of system, the instruction system realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It is above-mentioned that specification specific embodiment is described.Other embodiments are within the scope of the appended claims.
In some cases, the movement recorded in detail in the claims or step can be executed according to the sequence being different from embodiment
And desired result still may be implemented.In addition, process depicted in the drawing not necessarily require the particular order shown or
Person's consecutive order is just able to achieve desired result.In some embodiments, multitasking and parallel processing are also possible
Or it may be advantageous.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including element
There is also other identical elements in process, method, commodity or equipment.
The above is only the embodiments of this specification, are not limited to this specification.For those skilled in the art
For, this specification can have various modifications and variations.All any modifications made within the spirit and principle of this specification,
Equivalent replacement, improvement etc., should be included within the scope of the claims of this specification.