In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "what is the design of sql rule engine". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Recently, I used the rule engine to make a simple summary. The rule, to put it bluntly, is, what is the status quo (fact), if (condition), then (action). The rule engine uses the rete algorithm, and I use drools here. In short, I wrap around a core to generate drl files, and the rest are executed by drools.
In order to facilitate the design, the business is uniformly encapsulated with OP (input parameter: param, entity: body, output parameter: res) and executor Exector, so that class can be introduced less. A label table, a rule engine table. There are all kinds of data, variables, instance variables, relational operations, instructions in the tag.
Conditional direct generation
Behavior
Sql padding: give sql to the rules engine. Sql can take parameters, using parameters from the variable library.
$op.setBody
{
"$op.setBody": "select lock_on_active from t_rule_engine where id='$ {id}'"
}
Query array: query sql to get an array.
Executor.sqlList ($op)
{"Executor.sqlList ($op);": "}
Query value: query sql to get the number
Executor.sqlLong ($op)
{"Executor. SqlLong ($op);": "}
Query map: query sql to get map
Executor.sqlMap ($op)
{"Executor. SqlMap ($op);": "}
Query character: query sql to get a string.
Executor.sqlStr ($op)
{"Executor. SqlStr ($op);": "}
Trigger rules: re-execute in the rules file.
Update ($op)
{"update ($op);": "}
Variable copy: put the result of execution into the reference condition.
Executor.paramCopy
{"Executor.paramCopy": ["data", "data1"]} / / assign the value of the query result data to the parameter data1
Variable assignment: assign a constant value to a variable, which can also be a value in the instance variable library.
Executor.let
{"Executor.let": ["data", "cheitemContent"]} / / assign data to cheitemContent in the reference
At present, only "sql fill" and "variable copy" are parameters, and the others are non-parameter actions.
Finally generate the rule file drl
This is the end of the content of "what is the design of the sql rules engine". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.