Data processing method and system
Technical field
The present invention relates to computer field more particularly to a kind of data processing methods and system.
Background technique
With the development of electronic commerce affair, can encounter following two problems: (1) rule of business and branch are more and more multiple
Miscellaneous, the problems such as different types of rule has the different sequences that executes, and how multiple branches select, the if else in code refers to
It enables to safeguard being a very stubborn problem, because branch is more and more, how branch to be allowed to execute in a designated order, Duo Gefen
Branch how decision, can make to instruct if else logic extremely complex, for easily performing error in nested business;(2) business
Fast-growth, business branching logic handles hard coded, stable daily demand iteration can not quick response business change, can shadow
The business of sound operates normally and development, and simultaneously on-line running is at high cost for frequent altering system, and influences the stability of system, and system changes
Generation change is unable to satisfy business demand flexible development, and business personnel is black box to the processing of relevant branching logic, is not easy to business
Maintenance.
In the prior art, it is using regulation engine Drools, is the exploitation and maintenance for solving application program service logic
Frame, configures a kind of complicated statement formula of business branching logic and subsequent processing, and java code is directly embedded into regular text
In part, to meet the development of business.Regulation engine by operational decision making also pulled out from program code come, implementation rule variation and
Configuration, each issue rules will recompilate a regulation engine file according to template, and be loaded into memory.
But with business development, rule is more and more in business, and branching rule gradually increases, can not be according to business scenario
It is grouped management, when analyzing data every time, all rules must all be run, and running efficiency of system is lower and lower, time-consuming.Therefore
Traditional drools is unable to satisfy ever-increasing business demand, and bottleneck occurs in business development, expends system resource, at high cost.
Summary of the invention
The object of the present invention is to provide a kind of data processing method and system, to solve existing in the prior art not expiring
The ever-increasing business demand of foot, expend resource, low efficiency and it is at high cost the problems such as.
To achieve the above object, on the one hand, the present invention provides a kind of data processing methods, which comprises receive
The event that client is sent, the event includes data;The data are input in rule tree and are analyzed, the rule tree
Including multiple nodes, the node includes regular collection;The node of the rule tree is input to queue;Judge the queue
With the presence or absence of node;When the queue is there are when node, the first node in acquisition queue is present node, and will be described current
The regular collection of node is input to set to be screened;Judge whether the present node includes child node;When the present node
When including child node, the child node for the condition that meets is obtained;The child node for meeting condition is input to the queue.
On the other hand, the present invention provides a kind of data processing system, the system comprises: receiving unit, for receiving
The event that client is sent, the event includes data;Analytical unit is divided for the data to be input in rule tree
Analysis, the rule tree includes multiple nodes, and the node includes regular collection;Input unit, for by the rule tree
Node is input to queue;First judging unit, for judging the queue with the presence or absence of node;Processing unit, for when described
Queue is present node there are first node when node, obtained in queue, and the regular collection of the present node is inputted
To set to be screened;Second judgment unit, for judging whether the present node includes child node;Acquiring unit, for working as
When the present node includes child node, the child node for the condition that meets is obtained;The input unit is also used to meet item for described
The child node of part is input to the queue.
Data processing method provided in an embodiment of the present invention, enters data into and is analyzed into rule tree, by rule tree
Node be input to queue, with filter out meet scene rule data, improve the stability and scalability of system, avoid
Being increased bring by business is influenced, and the development of business is conducive to;When queue is there are when node, by the regular collection of present node
It is input to set to be screened, when present node includes child node, obtains the child node for the condition that meets, the son for the condition that meets is saved
Point is input to queue, reduces data rule set, avoids waste of resource, saves cost, improves the operational efficiency of system.
Detailed description of the invention
Fig. 1 is the data processing method flow chart that the embodiment of the present invention one provides;
Fig. 2 is the rule tree schematic diagram that the embodiment of the present invention one provides;
Fig. 3 is data processing method specific flow chart provided by Embodiment 2 of the present invention;
Fig. 4 is the data processing system schematic diagram that the embodiment of the present invention three provides.
Specific embodiment
Below by drawings and examples, technical scheme of the present invention will be described in further detail.
The event that the data processing method provided in the embodiment of the present invention, first acquisition client are sent, then passes through rule
Then tree filter out the regular collection to be screened to be run, rerun regulation engine when call regular collection to be screened.This method is
Regulation engine operation is preposition, and before regulation engine operation, regular prescreening optimization is added, rule operation set is reduced, to business
Developing rule, which gradually increases, substantially reduces system bring stability influence, and system performance has a distinct increment.Solution
The problem that traditional drools that determined supports extensive regular service ability limited.Regular collection is modeled by rule tree,
And business is made to Business Rule Management and regulation engine running optimizatin to operation rule set by breadth first traversal screening
Personnel are more convenient to regulation management, and regulation engine operation is more stable.The operation of calling rule engine specified rule, regulation engine can be fast
Speed finds rule and is run, and obtains the value of rule condition, compared to the operational process that drools loading rule file traverses one by one,
Performance has to be promoted to a high degree.
Data processing method provided in an embodiment of the present invention, by public JAVA regulation engine platform, with JAVA script
Implementation rule logical operation, and the flexible configuration management page, keep business regular with flexible configuration, while in regulation engine
It introduces rule and routes and carry out preparatory screening rule, to filter the rule for not needing operation to improve regulation engine operational efficiency, in addition
Make have clearly general view, the convenient operation control to entire regular collection to entire rule in business.By using rule tree knot
Structure carries out hierarchical classification modeling to rule, while improving to regular tree construction, connects in the father node and child node of rule tree
Increase condition on edge fit, judge whether node meets side condition using this condition as breadth first traversal, if it is satisfied, then will section
Regular collection in point is put into regular collection to be screened, so that breadth first traversal is carried out to rule tree, the rule after being screened
Then gather.
Embodiment one
The data processing method that embodiment one that the present invention will be described in detail by taking Fig. 1 as an example below provides, Fig. 1 are that the present invention is implemented
The data processing method flow chart that example one provides, subject of implementation can be server in embodiments of the present invention, or visitor
Family end, or execute plug-in unit or component in step described in the method for the present invention.As shown in Figure 1, this method includes following step
It is rapid:
Step 101 receives the event that client is sent, and the event includes data.
Here client can be Alipay client, Taobao's client or email client etc..
Here event can be transaction event or log-in events, or carry out the action event of regular monitoring.
Executing subject can also be client in addition to that can be server, or execute described in the method for the present invention
Plug-in unit or component in step, specifically can be the component in regulation engine.Component receives the event that client is sent, institute
The event of stating includes business datum.
Such as: user logs in Alipay in Alipay client, generates a log-in events, the component in regulation engine connects
The log-in events that client is sent are received, which may include the account logged in, when and where etc. data.
The data are input in rule tree and analyze by step 102.
The rule tree includes multiple nodes, and the node includes regular collection.Node in rule tree and node it
Between connected by side, the side between each node both define rule routing business side condition, referring specifically to rule shown in Fig. 2
Then set.
Rule tree is the frame for the monitoring tree of business scenario tissue, can be carried out according to different scenes granularity to scene
Multi-zone supervision facilitates the regular collection of management business convenient for the maintenance of entire regular collection, has entirety to the monitoring of business rule
Control.Each node can be named by business scenario in the structure of tree, then be divided for entire regular collection N, will
Rule is placed on scenario node, and rule can be placed in multiple groupings, and each subset NX after grouping constitutes the complete or collected works N, N of rule
={ N1, N2, N3, N4 ... }, Nx are the regular collection that each node of rule tree includes, node such as A, B, C, D ....
Optionally, node further includes number ID, to search the child node of node.
In addition to there is its regular collection in each scenario node, it is also necessary to node ID, the side condition of father node to the node, ID
For searching the child node of node, in breadth first traversal rule tree, service condition judge node to child node whether
It is reachable.
The structure of rule tree and the structure of rule tree interior joint is described below:
(1) regular tree construction:
MonitorTree:
RiskThemeId: scene ID
The root node of rootNode:MonitorTreeNode type
NodeId pairs of childrenNodeMap:Map<String, Map<String, MonitorTreeNode>>type
The leaf node ID answered.
(2) node structure:
MonitorTreeNode:
RuleUuid: the side condition ID of father node to the node
NodeId: node ID
Rule tree referring to fig. 2, node A are the father nodes of node B, and node D, node E and node F are the son sections of node B
Point.Assuming that the regular collection of node A is { A1, A2, A3 }, the regular collection of B is { B1, B2 }, and the regular collection of C is { C1, C2 },
The regular collection of D is { D1, D2, D3, D4 }, and the regular collection of E is { E1, E2, E3 }, and the regular collection of F is { F1, F2, F3 }, J
Regular collection be { J1, J2 }, the regular collection of K is { K1, K2 }, and the side rule condition of A-B is ruleAB, the side rule of A-C
Condition is ruleAC, and the side rule condition of B-D is ruleBD, and the side rule condition of B-E is ruleBE, the side rule condition of B-E
For ruleBE, the side rule condition of D-J is ruleDJ, and the side rule condition of D-K is ruleDK.
The node of the rule tree is input to queue by step 103;
Optionally, the queue is First Input First Output.
Specifically, the node being first input into queue first exports.
For example, the node A of rule tree is put into FIFO (First In First Out) queue Queue, Queue at this time
={ A }.
Step 104 judges the queue with the presence or absence of node;
For example, judging that there are nodes for the queue as Queue={ A };WhenWhen, judge that the queue is not present
Node.
Step 105, when the queue is there are when node, obtaining the first node in queue is present node, and will be described
The regular collection of present node is input to set to be screened;
When queue is there are when node, such as Queue={ A } at this time, the characteristics of according to fifo queue, the node that exports at this time
For node A, obtaining the first node A in queue is present node, and by the regular collection { A1, A2, A3 } of the first node A
It is input to set Waiting Rule Set to be screened, it is assumed that set to be screened is initially empty set, then Waiting Rule at this time
Set={ A1, A2, A3 }.
Optionally, when node is not present in the queue, set to be screened is exported.
When node is not present in the queue, at this timeDirectly export set to be screened.
Step 106 judges whether the present node includes child node;
Such as: node A includes child node B and child node C, and node D includes child node J and child node K;And node J does not have
Child node.So judging that present node includes child node, when present node is J, prosthomere is worked as in judgement when present node is node A
Point does not include child node.
Step 107, when the present node includes child node, obtain and meet the child node of condition;
For example, when present node is node A, and node A includes child node B and child node C, operation ruleAB and
RuleAC obtains the child node B for the condition that meets.
Further, when the present node includes child node, the child node for obtaining the condition that meets is specifically included:
Step 1071 obtains the child node that the present node includes, and reaches the son from the present node
The set of circumstances of node;
For example, obtaining the child node B and child node C that the present node A includes, and institute is reached from the present node A
State the set of circumstances R, R={ ruleAB, ruleAC } of child node B and child node C.
Step 1072, the operation set of circumstances, obtain running successful all conditions set;
For example, service condition set R={ ruleAB, ruleAC }, obtains running successful all conditions set
{ruleAB}。
Step 1073 obtains the corresponding child node for meeting condition of the set of circumstances.
Obtain first condition set { ruleAB } corresponding child node B for meeting condition.
Optionally, when the present node does not include child node, judge the queue with the presence or absence of node.I.e. circulation is held
Row step 104.
The child node for meeting condition is input to the queue by step 108.Circulation executes step 104.
The child node B for the condition that meets is input to queue, at this time Queue={ B }.It recycles and executes step 104, described in judgement
Queue whether there is node.
Queue at this time is there are node B, and the first node B obtained in queue is present node, and by the first node B's
Regular collection { B1, B2 }, is input to set to be screened.Waiting Rule Set={ A1, A2, A3, B1, B2 } at this time.
Judge whether the current node B includes child node, and current node B includes child node D, E, F.
When the current node B includes child node, the child node for the condition that meets is obtained.
Specifically, child node D, E, the F of node B are obtained, node B to child node D, the set of circumstances R, R=of E, F are run
{ ruleBD, ruleBE, ruleBF } is obtained and is run the corresponding child node D for meeting condition of successful ruleBD, by the satisfaction
The child node D of condition is input to the queue.Queue={ D } at this time.Recycling executes step 104, whether judges the queue
There are nodes.
Queue at this time is there are node D, and the first node D obtained in queue is present node, and by the first node D's
Regular collection { D1, D2, D3, D4 }, is input to set to be screened.At this time Waiting Rule Set=A1, A2, A3, B1, B2,
D1, D2, D3, D4 }.
Judge whether the present node D includes child node, and present node D includes child node J, K.
When the present node D includes child node, the child node for the condition that meets is obtained.
It obtains and runs the corresponding child node J for meeting condition of successful ruleDJ, the child node J for meeting condition is defeated
Enter to the queue.Queue={ J } at this time.Circulation executes step 104, judges the queue with the presence or absence of node.
The first node J obtained in queue is present node, and by the regular collection { J1, J2 } of the first node J, defeated
Enter to set to be screened.Waiting Rule Set={ A1, A2, A3, B1, B2, D1, D2, D3, D4, J1, J2 } at this time.
Judge that present node J does not include child node, and judge that node is not present in queue, then directly exports set to be screened
Waiting Rule Set={ A1, A2, A3, B1, B2, D1, D2, D3, D4, J1, J2 }.
Data processing method provided in an embodiment of the present invention, enters data into and is analyzed into rule tree, by rule tree
Node be input to queue, with filter out meet scene rule data, improve the stability and scalability of system, avoid
Being increased bring by business is influenced, and the development of business is conducive to;When queue is there are when node, by the regular collection of present node
It is input to set to be screened, when present node includes child node, obtains the child node for the condition that meets, the son for the condition that meets is saved
Point is input to queue, reduces data rule set, avoids waste of resource, saves cost, improves the operational efficiency of system.
Embodiment two
The data processing method that embodiment two that the present invention will be described in detail by taking Fig. 3 as an example below provides, Fig. 3 are that the present invention is implemented
The data processing method specific flow chart that example two provides, subject of implementation can be server in embodiments of the present invention, or execute
Plug-in unit or component in step described in the method for the present invention.As shown in figure 3, this method specifically comprises the following steps:
Step 301 receives the event that client is sent.
Event includes data.
Step 302 is entered data into and is analyzed into rule tree.
Rule tree includes multiple nodes, and node includes regular collection.
The node of rule tree is input to queue by step 303.
Step 304 judges queue with the presence or absence of node.When node is not present in queue, step 305 is executed;When queue is deposited
In node, step 306 is executed.
Step 305, output set to be screened.
Step 306, obtain queue in first node be present node, and by the regular collection of present node be input to
Screening set.
Step 307 judges whether present node includes child node.When the present node does not include child node, turn step
Rapid 304;When the present node includes child node, step 308 is executed.
Step 308 obtains the child node that present node includes, and the set of circumstances of child node is reached from present node;
Step 309, service condition set obtain running successful all conditions set.
Step 310 obtains the corresponding child node for meeting condition of set of circumstances.
The child node for the condition that meets is input to queue by step 311.Go to step 304.
Data processing method provided in an embodiment of the present invention, enters data into and is analyzed into rule tree, by rule tree
Node be input to queue, with filter out meet scene rule data, improve the stability and scalability of system, avoid
Being increased bring by business is influenced, and the development of business is conducive to;When queue is there are when node, by the regular collection of present node
It is input to set to be screened, when present node includes child node, obtains the child node for the condition that meets, the son for the condition that meets is saved
Point is input to queue, reduces data rule set, avoids waste of resource, saves cost, improves the operational efficiency of system.
Embodiment three
Corresponding with the data processing method that the embodiment of the present application one provides, the embodiment of the present application three additionally provides a kind of number
According to processing system, which can be server and is also possible to client, and referring to fig. 4, which can specifically include: receive single
Member 401, input unit 403, the first judging unit 404, processing unit 405, second judgment unit 406, obtains analytical unit 402
Take unit 407.
Receiving unit 401, for receiving the event of client transmission, the event includes data;
Analytical unit 402 is analyzed for the data to be input in rule tree, and the rule tree includes multiple sections
Point, the node include regular collection;
Input unit 403, for the node of the rule tree to be input to queue;
First judging unit 404, for judging the queue with the presence or absence of node;
Processing unit 405, for when the queue is there are when node, obtaining the first node in queue to be present node,
And the regular collection of the present node is input to set to be screened;
Second judgment unit 406, for judging whether the present node includes child node;
Acquiring unit 407, for obtaining the child node for the condition that meets when the present node includes child node;
The input unit 403 is also used to the child node for meeting condition being input to the queue.
The system can also include:
Output unit, for exporting set to be screened when node is not present in the queue.
The acquiring unit 407 is specifically used for:
The child node that the present node includes is obtained, and reaches the condition of the child node from the present node
Set;
The set of circumstances is run, obtains running successful all conditions set;
Obtain the corresponding child node for meeting condition of the set of circumstances.
The second judgment unit 406 is also used to when the present node does not include child node, judges that the queue is
It is no that there are nodes.
Data processing system provided in an embodiment of the present invention, enters data into and is analyzed into rule tree, by rule tree
Node be input to queue, with filter out meet scene rule data, improve the stability and scalability of system, avoid
Being increased bring by business is influenced, and the development of business is conducive to;When queue is there are when node, by the regular collection of present node
It is input to set to be screened, when present node includes child node, obtains the child node for the condition that meets, the son for the condition that meets is saved
Point is input to queue, reduces data rule set, avoids waste of resource, saves cost, improves the operational efficiency of system.
Professional should further appreciate that, described in conjunction with the examples disclosed in the embodiments of the present disclosure
Unit and algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, hard in order to clearly demonstrate
The interchangeability of part and software generally describes each exemplary composition and step according to function in the above description.
These functions are implemented in hardware or software actually, the specific application and design constraint depending on technical solution.
Professional technician can use different methods to achieve the described function each specific application, but this realization
It should not be considered as beyond the scope of the present invention.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can be executed with hardware, processor
The combination of software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only memory
(ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technical field
In any other form of storage medium well known to interior.
Above-described specific embodiment has carried out further the purpose of the present invention, technical scheme and beneficial effects
It is described in detail, it should be understood that being not intended to limit the present invention the foregoing is merely a specific embodiment of the invention
Protection scope, all within the spirits and principles of the present invention, any modification, equivalent substitution, improvement and etc. done should all include
Within protection scope of the present invention.