Data compiling method, electronic equipment, storage medium and program product

By splitting the knowledge package into multiple sharded packages and compiling in parallel, the memory consumption problem caused by knowledge package compilation in the rule engine is solved, and more efficient resource utilization and rapid compilation are achieved.

CN119621070APending Publication Date: 2025-03-14KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411720307.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

In the rules engine, the rule compilation process of the knowledge package leads to a significant increase in memory consumption, especially when business needs increase and rule complexity increases.

Method used

By splitting the huge knowledge package into multiple shard packages, each shard package contains a decision flow in the knowledge package, and compiling each shard package in parallel, finally integrating the compiled rules.

Benefits of technology

Reduces memory usage during a single compilation process, reduces the requirements for configuration center hardware resources, and improves the overall compilation speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621070A_ABST
    Figure CN119621070A_ABST
Patent Text Reader

Abstract

The invention provides a data compiling method, electronic equipment, a readable storage medium and a computer program product. The data compiling method comprises the steps of responding to a compiling request of a to-be-compiled rule, and retrieving a plurality of fragment packages corresponding to the to-be-compiled rule; the fragment packages are compiled in parallel, multiple pieces of compiled data are obtained, and each piece of compiled data is obtained by compiling one fragment package; integrating the plurality of compiled data to obtain a compiled rule; wherein the to-be-compiled rule corresponds to one knowledge packet, and each fragment packet contains one decision stream in the knowledge packet.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data compilation method, an electronic device, a storage medium, and a program product. Background Art

[0002] In the rule engine, a series of rules are usually integrated into a knowledge package. When the system is started or the rules are updated, the configuration center needs to compile the knowledge package, convert the rules of the knowledge package into executable code or data structure, and then distribute it to each rule call end for use. This compilation process consumes a lot of computing resources and memory resources. With the continuous increase in business needs and the increase in the complexity of rules, the rules of the knowledge package are becoming more and more large and complex. The knowledge package with complex rules will cause a significant expansion of memory consumption during the compilation process, resulting in a significant increase in the consumption of memory and computing resources. Summary of the invention

[0003] The present disclosure provides a data compilation method, an electronic device, a storage medium, and a program product.

[0004] According to one aspect of the present disclosure, a data compilation method is provided, comprising: in response to a compilation request of a rule to be compiled, retrieving multiple slice packages corresponding to the rule to be compiled; compiling each of the slice packages in parallel to obtain multiple compiled data, each of the compiled data is compiled from one of the slice packages; and integrating the multiple compiled data to obtain compiled rules; wherein the rule to be compiled corresponds to a knowledge package, and each of the slice packages contains a decision flow in the knowledge package.

[0005] According to at least one embodiment of the data compilation method of the present disclosure, it also includes: acquiring the knowledge package and identifying the topological structure of the knowledge package; and in response to the topological structure of the knowledge package being a decision flow forest structure, splitting the knowledge package into a plurality of slice packages, each of the slice packages corresponding to a decision flow in the knowledge package.

[0006] According to the data compilation method of at least one embodiment of the present disclosure, in response to the topological structure of the knowledge package only including decision flows, the knowledge package is split into multiple shard packages, including: obtaining the number of decision flows of the knowledge package; determining the number of shards according to the number of decision flows of the knowledge package; creating multiple new knowledge packages according to the number of shards, and determining the new knowledge packages as the shard packages, each of the shard packages containing a decision flow of the knowledge package; and publishing the multiple shard packages in the routing table.

[0007] According to the data compilation method of at least one embodiment of the present disclosure, the knowledge package is split into multiple slice packages, and also includes: obtaining the identity identification code of the knowledge package and the rule mapping table where the identity identification code of the knowledge package is located, the rule mapping table is used to store the mapping relationship between the rule file and the knowledge package; configuring an identity identification code for each slice package, and configuring the identity identification code of the knowledge package as the parent identity code of each slice package; and storing the identity identification code of each slice package, the parent identity code, and the correspondence between the slice package and the decision flow in the rule mapping table where the identity identification code of the knowledge package is located.

[0008] According to at least one embodiment of the data compilation method of the present disclosure, it also includes: in response to a modification instruction of the knowledge package, modifying the knowledge package to obtain the modified knowledge package; querying the rules that are newly added, modified or deleted in the modified knowledge package relative to the knowledge package before modification; in response to the modified knowledge package having newly added rules relative to the knowledge package before modification, creating a new slicing package, the new slicing package containing the decision flow corresponding to the newly added rules; and / or in response to the modified knowledge package having modified rules relative to the knowledge package before modification, retrieving a rule change slicing package, the rule change slicing package containing the decision flow corresponding to the modified rules, and replacing the decision flow contained in the rule change slicing package with the decision flow corresponding to the modified rules; and / or in response to the modified knowledge package having deleted rules relative to the knowledge package before modification, retrieving and deleting redundant slicing packages, the redundant slicing packages containing the decision flow corresponding to the deleted rules.

[0009] According to at least one embodiment of the data compilation method disclosed herein, in response to a compilation request for a rule to be compiled, multiple shard packages corresponding to the rule to be compiled are retrieved, including: obtaining a rule field in the compilation request; querying a decision flow corresponding to the rule field in a rule mapping table, and determining the decision flow corresponding to the rule field as a designated decision flow; and obtaining the shard package corresponding to the designated decision flow; wherein the rule mapping table is used to store the correspondence between the decision flow and the shard package.

[0010] According to the data compilation method of at least one embodiment of the present disclosure, obtaining the slice package corresponding to the specified decision flow includes: querying the identity code of the slice package containing the specified decision flow in the rule mapping table; and querying the slice package corresponding to the identity code in the routing table, and obtaining the slice package. According to another aspect of the present disclosure, an electronic device is provided, including: a memory, the memory storing execution instructions; and a processor, the processor executing the execution instructions stored in the memory, so that the processor executes the data compilation method of any embodiment of the present disclosure.

[0011] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the data compiling method of any embodiment of the present disclosure is implemented.

[0012] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the data compiling method of any one embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0014] Figure 1 It is a schematic diagram of an application scenario of a data compilation method according to an embodiment of the present invention.

[0015] Figure 2 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0016] Figure 3 It is a schematic diagram of the execution process of a data compilation method according to an embodiment of the present disclosure.

[0017] Figure 4 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0018] Figure 5 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0019] Figure 6 It is a schematic diagram of the topological structure of a knowledge package of a data compilation method according to an embodiment of the present disclosure.

[0020] Figure 7 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0021] Figure 8 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0022] Fig. 9 It is a schematic diagram of the execution process of a data compilation method according to an embodiment of the present disclosure.

[0023] Fig.10 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0024] Fig.11 It is a schematic diagram of the execution process of a data compilation method according to an embodiment of the present disclosure.

[0025] Fig.12 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0026] Fig.13 It is a flowchart of a data compilation method according to an embodiment of the present disclosure.

[0027] Fig.14 It is a schematic block diagram of the structure of a data compiling device according to an embodiment of the present disclosure.

[0028] Fig.15 It is a schematic block diagram of the structure of an electronic device equipped with a data compiling device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0029] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.

[0030] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0031] In modern information systems, rule engines are widely used in various systems and platforms as core components for processing complex business logic. Rule engines automatically drive system behavior through pre-defined rule sets, which can reduce manual intervention and improve the automation and response speed of the system. When the system starts or the rules are updated, the configuration center needs to compile these pre-defined rule sets and convert the rules into executable code or data structures. In order to unify and centrally manage rule configuration, most current systems integrate a series of pre-defined rules into knowledge packages, and use the configuration center to centrally compile the knowledge packages. However, if the knowledge package is complex and large, the memory consumed during the compilation process will expand significantly.

[0032] Figure 1 The application scenario of the data compilation method of an embodiment of the present disclosure is shown. The application scenario is applied to a series of to-be-compiled rules of a rule engine that need to be compiled, and the compiled rules are obtained after the to-be-compiled rules are compiled.

[0033] like Figure 1As shown, an embodiment of the present disclosure pre-segmented the knowledge package, splitting the huge knowledge package into multiple fragment packages, each fragment package containing a decision flow in the knowledge package. Decision flow refers to a mechanism used to define the order and logic of rule execution in a knowledge package, which can be expressed as an ordered combination of a series of decision steps generated based on a rule. These steps are executed in a certain logical order to achieve the final decision result.

[0034] There are usually multiple knowledge packages stored in the system, and different knowledge packages correspond to different rule sets. If a rule set needs to be compiled, the rule set to be compiled is determined as the rule to be compiled, and the rule to be compiled corresponds to one knowledge package.

[0035] On the basis of the knowledge package corresponding to the rule to be compiled being split and processed to obtain the corresponding multiple fragment packages, in response to the compilation request of the rule to be compiled, the multiple fragment packages corresponding to the rule to be compiled are retrieved, and the multiple fragment packages retrieved at this time correspond to the same knowledge package as the rule to be compiled. After retrieving multiple fragment packages, each fragment package is compiled respectively to obtain the compiled data after each fragment package is compiled. Finally, the multiple compiled data obtained by compiling multiple fragment packages are integrated to obtain the compiled rules after compiling the rules to be compiled. In this process, by converting the compilation of the knowledge package into the compilation of multiple fragment packages, the memory usage in a single compilation process can be reduced, so as to reduce memory consumption, thereby reducing the requirements for hardware resources of the configuration center. In addition, each fragment package can be compiled independently, and the compilation tasks of multiple fragment packages can be processed in parallel, so as to improve the speed of the overall compilation.

[0036] Furthermore, when business requirements change and the rule set is expanded, a fragment package can be dynamically added according to the expanded decision flow, so that the added fragment package contains the expanded decision flow, so that the compilation of the rule set can quickly adapt to the changes in business requirements. Similarly, when business requirements change and the rules in the rule set are reduced, the fragment package can be dynamically deleted according to the decision flow corresponding to the reduced rules, so that the deleted fragment package contains the reduced decision flow, so as to dynamically adapt to the changes in business requirements.

[0037] Figure 2 FIG. 1 is a schematic diagram showing the overall flow of a data compilation method M100 according to an embodiment of the present disclosure. Figure 2 The method shown includes steps S120 to S160. The method can be executed by electronic devices such as mobile phones and tablet computers.

[0038] Specifically, Figure 2 The methods shown include: S120 . In response to a compilation request of a rule to be compiled, retrieve multiple fragment packages corresponding to the rule to be compiled.

[0039] The compilation request of the rule to be compiled is used to instruct to compile a rule to be compiled. The rule to be compiled is a set of rules. The knowledge package integrating these rules is the knowledge package corresponding to the rule to be compiled. The knowledge package contains multiple decision flows, and each decision flow corresponds to a rule. Multiple fragment packages are obtained by splitting the knowledge package, and each fragment package contains a decision flow in the knowledge package.

[0040] In one example, the compilation request includes the project code of the rule to be compiled and the identity code of the knowledge package corresponding to the rule to be compiled. When responding to the compilation request of the rule to be compiled, the corresponding knowledge package is retrieved according to the identity code in the compilation request, and multiple fragment packages split from the knowledge package are queried to retrieve multiple fragment packages corresponding to the rule to be compiled.

[0041] S140 , compile each slice package in parallel to obtain a plurality of compiled data, each compiled data being compiled from one slice package.

[0042] In the process of parallel compilation of each shard package, on the one hand, the compilation complexity of a single shard package is lower, the memory consumption is lower, and the independent compilation of each shard package can improve the stability of the system; on the other hand, parallel compilation of each shard package can improve the compilation efficiency of the system and disperse the compilation pressure of the configuration center.

[0043] S160, integrating multiple compiled data to obtain compiled rules.

[0044] Each of the multiple compiled data obtained by compiling multiple fragment packages is equivalent to data obtained after compiling one of the rules to be compiled. Therefore, the compiled rules compiled and transformed by the rules to be compiled can be obtained by integrating the multiple compiled data.

[0045] In some implementations of the present disclosure, modifications may be made to an existing compilation method for compiling a knowledge package to obtain the compilation method for compiling a slice package of the present disclosure.

[0046] Please combine Figure 3, assuming that the existing system configuration is: in response to the compilation request of the rule to be compiled, the knowledge package corresponding to the rule to be compiled is compiled to obtain the compiled rule. Then, on the basis of the existing system configuration, the knowledge package that can be called by the system can be split in advance to obtain multiple shard packages, and a shard compilation strategy is introduced. When responding to the compilation request of the rule to be compiled, it is determined whether the shard compilation strategy is enabled. If the shard compilation strategy is not enabled, the knowledge package is compiled according to the original system configuration; if the shard compilation strategy is enabled, the above steps S110 to S130 of the data compilation method disclosed in the present invention are executed to retrieve multiple shard packages corresponding to the compilation rules for compilation. For example, the data compilation method disclosed in the present invention can implement a strategy for rule compilation based on shard packages by making a small amount of changes to the compilation configuration of the existing system, thereby being able to quickly and conveniently optimize the compilation capability of the existing system and reduce memory usage during compilation.

[0047] In some embodiments of the present disclosure, if the knowledge package has not been split, that is, if multiple fragment packages obtained by splitting the knowledge package have not been obtained, the data compilation method M100 may further include the following steps: Figure 4 Step S110 is shown to obtain multiple fragment packets.

[0048] S110, split the knowledge package to obtain multiple fragment packages.

[0049] For example, when optimizing the compilation method of an existing system based on the data compilation method disclosed in the present invention, the existing system can only call knowledge packages for compilation, and the callable knowledge packages have not been split. In this case, the knowledge package can be split using the method of step S110 to obtain multiple fragment packages, so that the existing system can be optimized to compile multiple fragment packages using the method of steps S120 to S160.

[0050] Regarding step S110, in some embodiments of the present disclosure, it may include: Figure 5 Steps S1110 to S1120 are shown.

[0051] S1110 , obtaining a knowledge package and identifying a topological structure of the knowledge package.

[0052] S1120 , in response to the topological structure of the knowledge package being a decision flow forest structure, split the knowledge package into multiple fragment packages, each fragment package corresponding to a decision flow in the knowledge package.

[0053] The decision flow in the knowledge package is a process arranged according to business logic. These processes need to reference various library files (such as data tables, functions, variables, etc.) when running. Figure 6If the topological structure of the knowledge package includes the decision flow file topology (such as the rate network), if the reference relationship of the library files in the decision flow file topology is sorted and merged, a decision flow tree can be obtained. If the topological structure of the knowledge package is composed of only multiple decision flow trees, such a topological structure is called a decision flow forest structure. The reference relationship of each decision flow in the decision flow forest structure is clear, so that each decision tree in the decision flow forest structure can be split out separately. Such a topological structure is a splittable topological structure. If the topological structure of the knowledge package includes the reference of the library file to other library files, the topological structure of the knowledge package includes the library file network in addition to the decision flow tree. The reference relationship of the library file network is relatively complex. If it is split, it may affect its logical consistency and integrity. Therefore, such a topological structure is an inseparable topological structure.

[0054] Specifically, the core principle of the data compilation method based on shard packages to reduce memory consumption lies in the refined management and optimization of knowledge packages. In existing rule engines, knowledge packages are usually dominated by decision flows. Due to the characteristics of its process orchestration, decision flows often reference a large number of resources downward. When the knowledge package becomes large, the number of referenced resources also increases, resulting in a sharp increase in memory usage during the compilation process. These reference relationships lead to the expansion of knowledge packages during the compilation process, which becomes the main reason for the increase in memory consumption in the configuration center. For the decision flow forest structure, the reference relationship between each decision flow and the library file referenced by the decision flow is relatively clear. A decision flow forest structure can be regarded as a topological structure composed of multiple decision flow trees. If the decision flow forest structure is split according to the reference relationship of the decision flow, the reference relationship of each decision flow can split out a decision flow tree, thereby splitting the decision flow forest structure into multiple decision flow trees. In this way, the number of resources referenced by each decision flow tree is greatly reduced relative to the number of resources referenced by the decision flow forest, so that the memory consumption of the configuration center can be greatly reduced when the compilation of each decision flow tree is processed separately. For the topological structure containing the library file network, the reference relationship of the library files is complex. On the one hand, it is difficult to split according to the reference relationship while ensuring the consistency and integrity of the business logic. On the other hand, even if the library file network is split according to the reference relationship, the number of resources referenced by the reference relationship of the split library files is still large, and the memory consumption of the configuration center is still large. Therefore, the data compilation method disclosed in the present invention adopts step S1110 to identify the topological structure of the knowledge package, and only when the topological structure of the knowledge package is identified as a decision flow forest structure, step S1110 is adopted to split the knowledge package into multiple fragment packages to ensure that the fragmentation strategy can reduce the compilation complexity and memory consumption of a single fragment package, and ensure that the reference relationship of the split fragment packages is not affected, so as to ensure the consistency and integrity of the business logic.

[0055] Regarding step S1120, in some embodiments of the present disclosure, it may include: Figure 7 Steps S1121 to S1124 are shown.

[0056] S1121. Obtain the number of decision flows of the knowledge package.

[0057] In one example, each decision flow of a knowledge package has a corresponding identifiable item such as a name, an ID, or a rule field, and the number of decision flows of the knowledge package can be obtained by identifying the number of identifiable items in the knowledge package. For example, the decision flows in the knowledge package are represented as scripts, and each decision flow script has a corresponding script name. The number of decision flows of the knowledge package can be obtained by identifying the number of script names in the knowledge package.

[0058] S1122. Determine the number of shards according to the number of decision flows of the knowledge package.

[0059] The number of shards is equal to the number of decision flows in the knowledge package. In this way, each decision flow in the knowledge package can be split into a shard package, making each shard package a minimum independently runnable decision flow unit. In this way, the compilation complexity and memory consumption of each shard package can be minimized.

[0060] In other embodiments, step S1122 can be replaced by: determining the number of shards according to the number of business logics corresponding to the decision flows of the knowledge package. For example, assuming that the knowledge package contains 3 decision flows, 2 of which correspond to business logic A, and the other 1 decision flow corresponds to business logic B, then the number of business logics corresponding to the decision flows of the knowledge package is 2, and the determined number of shards is 2. In this way, the 2 decision flows corresponding to business logic A can be split into one shard package, and the 1 decision flow corresponding to business logic B can be split into another shard package to ensure the integrity of the business logic. In this case, each shard package is not limited to containing only 1 decision flow, but can also contain 2, 3, 4, 5, or more decision flows, which are not limited here.

[0061] S1123. Create multiple new knowledge packages according to the number of shards, and determine the new knowledge packages as shard packages, each shard package containing a decision flow of the knowledge package.

[0062] To avoid name confusion, this article refers to the knowledge package before splitting that contains multiple decision flows as a main package, and the new knowledge package created in step S1123 as a sub-package.

[0063] Creating a new knowledge package (sub-package) and identifying the new knowledge package (sub-package) as a shard package means that the splitting of the knowledge package (main package) does not change the data of the knowledge package (main package) by editing the knowledge package (main package), but creates a new knowledge package (sub-package) for each decision flow tree of the knowledge package (main package) based on the topological result of the knowledge package (main package). In this way, the knowledge package (main package) and the sub-package coexist in the system, giving the system a high elastic scaling capability. For example, when the system needs to be scaled, all sub-packages can be directly deleted. When the system scaling is completed, the main package can be re-split to quickly generate new sub-packages.

[0064] S1124. Publish multiple fragment packets in the routing table.

[0065] Multiple fragment packets are published in the routing table so that the fragment packets can be quickly accessed when they are retrieved.

[0066] Regarding step S1120, in some embodiments of the present disclosure, it may include: Figure 8 Steps S1125 to S1127 are shown.

[0067] S1125, obtaining the identity identification code of the knowledge package and the rule mapping table where the identity identification code of the knowledge package is located.

[0068] The rule mapping table is used to store the mapping relationship between the rule file and the knowledge package.

[0069] In one example, in the rule mapping table, each knowledge package has a unique id (identification code), belongs to a certain project (project_code), has its own code (code), name (name) and description (remark). The mapping relationship between rule files and knowledge packages is also stored in the rule mapping table. For example, a rule file A is a rule file corresponding to the bill verification business, and the rule file A has a mapping relationship with knowledge package 01. If the rule engine needs to call rule file A, knowledge package 01 can be compiled to obtain the compiled data corresponding to rule file A.

[0070] In addition, the rule mapping table may also include the knowledge package's state, current version number (current_version), published version number (published_version), creator id (create_ucid), creation time (create_time), updater id (update_ucid), and update time (update_time), etc. The knowledge package's state can indicate its validity. The current version number and published version number of the knowledge package indicate the latest knowledge package version and the published knowledge package version, respectively. The user ids of the creator and updater, as well as the creation time and update time, provide important information about the knowledge package life cycle.

[0071] In addition, the rule mapping table may also include the number of shards (shard_num) of the knowledge package. The number of shards of a knowledge package can indicate whether the knowledge package has been split, and the number of splits. In one example, the number of shards of a knowledge package can also be regulated in conjunction with the shard compilation strategy. For example, suppose a knowledge package has been split, and its current number of shards is 5. If you choose to turn on the sharding strategy, the number of shards will not be modified, so that the system can determine that the knowledge package has 5 corresponding shard packages, so that it can access and compile the shard packages; if you choose to turn off the sharding strategy, the number of shards can be modified to 0, so that the system determines that the knowledge package has no corresponding shard package, so that the system compiles the knowledge package; if you turn on the sharding strategy again after turning off the sharding strategy, the number of shards will be modified from 0 to 5, so that the system can access and compile the shard packages.

[0072] S1126: Configure an identity code for each fragment package, and configure the identity code of the knowledge package as the parent identity code of each fragment package.

[0073] After creating a slice package, a unique ID (identification code) is configured for the slice package to identify the slice package. At the same time, the parent identity code is configured for the slice package to identify the knowledge package to which the slice package belongs, so that when the system is scaled, all the slice packages belonging to a knowledge package can be found through the parent identity code for deletion.

[0074] S1127, storing the identity code of each fragment package, the parent identity code, and the corresponding relationship between the fragment package and the decision flow into the rule mapping table where the identity code of the knowledge package is located.

[0075] That is to say, after creating a shard package, there is no need to create a new rule mapping table for each shard package, but to add the relevant information of the newly created shard package to the existing rule mapping table of the knowledge package. In this way, when introducing a shard compilation strategy to a system that originally did not have a shard compilation strategy, the rule mapping table of the original knowledge package of the system can be improved to make it compatible with the relevant information of the shard package, thereby minimizing the transformation. In addition, the shard package and the knowledge package to which it belongs are stored in the same rule mapping table, which can improve the efficiency of tracing queries when tracing the shard package is needed.

[0076] Please combine Fig. 9 , Fig. 9 The diagram illustrates the process of writing a knowledge package when a shard compilation strategy is enabled and the process of deleting a knowledge package when a shard compilation strategy is disabled, based on a system capable of compiling knowledge packages. Fig. 9 The red process box is used to distinguish the added process of enabling the sharding strategy and the added process of canceling the sharding strategy.

[0077] like Fig. 9 As shown, the modules of the system include a knowledge package management module, a knowledge package version module, a knowledge package rule module, a MongoDB database, and a knowledge package publishing module. Among them, the knowledge package management module is used to manage the addition and deletion of knowledge packages. The knowledge package version module is used to manage the addition and deletion of version information of knowledge packages. The knowledge package rule module is used to manage the addition and deletion of a series of rules contained in the knowledge package, such as the addition and deletion of decision flows and reference relationships of decision flows in the knowledge package. The MongoDB database is used to store unstructured or semi-structured data, such as historical versions of knowledge packages, publishing records, rule files corresponding to knowledge packages, etc. The knowledge package publishing module is used to manage the creation and deletion of publishing records of knowledge packages.

[0078] In the original process of the system, if a new knowledge package needs to be added, the corresponding new process will be entered, the knowledge package management module will add a new knowledge package, the knowledge package version module will add an initial version of the knowledge package, the knowledge package rule module will clean up all the rule relationships of the knowledge package, and insert new rule relationships, and then write the rule file, initial version and rule relationship corresponding to the above knowledge package into the MongoDB database. After the sharding compilation strategy is introduced, a process for enabling the sharding strategy is added, including: passing in the identity identification code of the knowledge package that needs to be sharded, executing the above steps S1121 to S1127 to split the knowledge package to obtain multiple sharding packages, and marking the knowledge package as a sharded knowledge package and registering its number of shards. Then, after the process of enabling the sharding strategy, the original new process of the system is connected, and the addition of each sharding package is processed in the same way as the new knowledge package in the original new process of the system.

[0079] In the original process of the system, if a knowledge package needs to be deleted, the deletion process will be entered accordingly. The knowledge package management module deletes a knowledge package, the knowledge package version module deletes the corresponding version of the knowledge package, the knowledge package rule module deletes all rule relationships of the knowledge package, and then deletes all historical versions of the knowledge package in the MongoDB database. Finally, the knowledge package publishing module deletes the publishing record of the knowledge package. After the sharding compilation strategy is introduced, a process for canceling the sharding strategy is added, including passing in the identity code of the knowledge package that needs to be canceled, selecting all sharding packages belonging to the identity code and constructing a sharding knowledge package Dto, and marking the knowledge package as an unsharded knowledge package to reset its shard count to zero. Then, after the process of canceling the sharding strategy, the original deletion process of the system is connected, and the deletion of each sharding package is handled in the same way as deleting the knowledge package in the original deletion process of the system.

[0080] By combining the above-mentioned methods of adding a process for enabling the sharding strategy and adding a process for canceling the sharding strategy, it is possible to introduce a sharding compilation strategy while keeping the original logical architecture of the system unchanged, and use the system's original process for adding and deleting knowledge packages to implement the addition and deletion of sharding packages, thereby optimizing the original system with minimal changes.

[0081] In some embodiments of the present disclosure, the rule engine adopts a dynamic and static separation architecture and only operates on dynamic databases. Accordingly, when storing knowledge packages and shard packages, heavier static data such as rule files are stored in a MongoDB database, and the MongoDB database is recorded as a static database, while dynamic data such as reference relationships of decision flows and rule mapping tables of knowledge packages are stored in a MySQL database, and the MySQL database is recorded as a dynamic database. In this way, the amount of data stored in the dynamic database is relatively lightweight, and memory usage can be reduced when the rule engine operates the dynamic database.

[0082] Regarding step S110, in some embodiments of the present disclosure, it may also include the following Fig.10 Steps S1130 to S1170 are shown.

[0083] S1130 . In response to the modification instruction of the knowledge package, modify the knowledge package to obtain a modified knowledge package.

[0084] The modification instruction of the knowledge package is used to instruct to modify the rules of the knowledge package of a specific identity code. The method of modifying the rules includes adding new rules, modifying the original rules and deleting the original rules.

[0085] S1140 , query the rules that are added, modified, or deleted in the modified knowledge package relative to the knowledge package before modification.

[0086] According to the modification instruction, the modified knowledge package may have the following changes relative to the knowledge package before modification: new rules are added, original rules are modified, and original rules are deleted. The rule changes of the modified knowledge package relative to the knowledge package before modification can be obtained by comparing the two knowledge packages before and after modification, or can be determined according to the modification instruction, which is not limited here.

[0087] S1150 , in response to the modified knowledge package having a newly added rule relative to the knowledge package before modification, creating a new fragmentation package, wherein the new fragmentation package includes a decision flow corresponding to the newly added rule.

[0088] If the modified knowledge package adds new rules relative to the previous knowledge package, it is necessary to add a new shard package containing the decision flow corresponding to the newly added rules on the basis of the newly added rules in the knowledge package and on the basis of the existing shard package, so that the shard package can be modified synchronously to adapt to the modification of the knowledge package.

[0089] S1160. In response to the modified knowledge package having modified rules relative to the knowledge package before modification, retrieve the rule change segment package, which contains the decision flow corresponding to the modified rule, and replace the decision flow contained in the rule change segment package with the decision flow corresponding to the modified rule.

[0090] If the modified knowledge package has a modified rule compared to the knowledge package before the modification, the modified rule can retrieve the fragment package containing the decision flow according to its corresponding decision flow, which is recorded as the rule change fragment package. In the case that a rule of the knowledge package is modified to a new rule, the rule change fragment package needs to be modified synchronously, and the decision flow corresponding to the modified rule contained in the rule change fragment package is replaced with the decision flow corresponding to the modified rule, so that the fragment package can adapt to the modification of the knowledge package and be modified synchronously.

[0091] S1170 , in response to the modified knowledge package having a deleted rule relative to the knowledge package before modification, retrieving and deleting a redundant fragment package, wherein the redundant fragment package includes a decision flow corresponding to the deleted rule.

[0092] If the modified knowledge package deletes the original rules relative to the knowledge package before the modification, it is necessary to synchronously delete the shard package containing the decision flow corresponding to the deleted rules in the existing shard package based on the knowledge package deletion rules, so that the shard package can be modified synchronously to adapt to the modification of the knowledge package.

[0093] Please combine Fig.11 , Fig.11 The diagram illustrates a process of modifying a knowledge package when a shard compilation strategy is enabled on a system capable of compiling knowledge packages. Fig. 9 The red process box indicates the added process of modifying the fragment package.

[0094] like Fig.11 As shown, the original process of the system includes a modification process. After entering the modification process, it is determined whether to change the version. If the version is changed, the knowledge package of the changed version is obtained through the knowledge package management module to update the version, and then the process of adding a new knowledge package is continued to store the updated knowledge package.

[0095] After the shard compilation strategy is introduced, before entering the modification process, it is first determined whether the shard compilation strategy is enabled. If the shard compilation strategy is enabled, the method in the above steps S1130 to S1170 is executed, and the modification of the knowledge package is synchronized to create, modify or delete the shard package, and then the modification process in the original process of the system is continued to store the modified knowledge package and shard package. In this way, the shard compilation strategy can be introduced on the basis of keeping the original logical architecture of the system unchanged, and the modification of the shard package can be realized by using the original modification process of the system, so that the original system can be optimized with minimal changes.

[0096] Regarding step S120, in some embodiments of the present disclosure, it may include the following steps: Fig.12 Steps S1210 to S1230 are shown.

[0097] S1210: Obtain a rule field in a compilation request.

[0098] The rule field is a field related to the rule, and each rule field corresponds to a rule in the rule (set) to be compiled. For example, the rule field can be the name of a script in the rule file, the name of a configuration file, and so on.

[0099] S1220. Query the decision flow corresponding to the rule field in the rule mapping table, and determine the decision flow corresponding to the rule field as the designated decision flow.

[0100] In combination with the foregoing, the mapping relationship between the knowledge package and the rule file is stored in the rule mapping table, and the information of each shard package is also stored in the rule mapping table, and each shard package contains a decision flow of the knowledge package, so that the information stored in the rule mapping table also includes the correspondence between the decision flow and the shard package. Based on the mapping relationship between the knowledge package and the rule file, and the knowledge package contains multiple decision flows, and the rule field represents a rule in the rule file, the mapping relationship between the knowledge package and the rule file can be specifically expressed as a mapping relationship between the decision flow and the specific rule of the rule file, that is, a mapping relationship between the decision flow and the rule field. In this way, the corresponding decision flow can be queried in the rule mapping table according to a rule field. When querying the corresponding decision flow based on the rule field in the compilation request, the queried decision flow is recorded as the specified decision flow, and the specified decision flow is the decision flow related to the compilation of the rule to be compiled.

[0101] S1230. Obtain the fragmentation package corresponding to the specified decision flow.

[0102] After the specified decision flow is queried, the fragment package containing the specified decision flow is a fragment package corresponding to the rule to be compiled. In this way, it is only necessary to query the specified decision flows corresponding to each of the multiple rule fields in the compilation request to obtain the fragment packages to which these specified decision flows belong, and obtain multiple fragment packages corresponding to the rules to be compiled.

[0103] In summary, the method of step S1210 to step S1230 can obtain multiple fragment packages corresponding to the rules to be compiled when the compilation request does not provide the identity identification code of the knowledge package corresponding to the rules to be compiled. In this way, the minimum compilation unit of the rules to be compiled can be reduced to the rules corresponding to one fragment package. For example, a knowledge package contains rules corresponding to 5 decision flows. If a certain compilation only needs to compile the rules corresponding to 4 decision flows, the rule fields of the rules corresponding to these 4 decision flows can be added to the compilation request, and the fragment packages corresponding to these 4 decision flows can be directly queried for access without going through the knowledge package level.

[0104] Regarding step S1230, in some embodiments of the present disclosure, it may include: Fig.13 Steps S1231 to S1232 are shown.

[0105] S1231. Query the rule mapping table for the identity code of the fragment package containing the specified decision flow.

[0106] The rule mapping table does not store the relevant rule files of the slicing package, but only stores the identity information of the slicing package, the number of slicing information of the slicing package, the corresponding relationship between the slicing package and the decision flow, the parent-child relationship between the knowledge package to which it belongs, and other resource relationships. In this case, when the specified decision flow is determined, the identity code of the slicing package containing the specified decision flow can be queried to further access the slicing package based on the identity code.

[0107] S1232. Query the fragmented packet corresponding to the identity code in the routing table, and obtain the fragmented packet.

[0108] The surviving shard packages are published to the routing table. The identity code of the shard package is queried in the routing table. The resource location of the shard package corresponding to the identity code can be automatically traced in the background, so that the request can be routed to the corresponding shard package. In this way, when the client makes a rule call, it does not need to pay attention to the specific sharding details of the knowledge package. It only needs to call the interface of the rule engine like a system that does not introduce the sharding compilation strategy. The system that introduces the sharding compilation strategy will automatically process the sharding relationship corresponding to the request according to the content of the request, search the routing table to obtain the shard package, and transparently forward the request to the obtained shard package for processing, so as to achieve non-perceived operation when the user calls.

[0109] Based on any of the above implementations, the present disclosure also provides a data compilation device. Fig.12 It is a schematic block diagram of the structure of a data compiling device according to an embodiment of the present disclosure.

[0110] like Fig.14 As shown, the data compiling device comprises: The retrieval module 110 is used to retrieve a plurality of fragment packages corresponding to the rule to be compiled in response to a compilation request of the rule to be compiled.

[0111] The compiling module 120 is used to compile each slice package in parallel to obtain a plurality of compiled data, each of which is compiled from one slice package.

[0112] The integration module 130 is used to integrate a plurality of compiled data to obtain compiled rules.

[0113] In some embodiments of the present disclosure, the data compilation device further includes a sharding module (not shown), which is used to split the knowledge package to obtain multiple sharding packages. Specifically, the sharding module can be used to obtain the knowledge package and identify the topological structure of the knowledge package; and in response to the topological structure of the knowledge package being a decision flow forest structure, split the knowledge package into multiple sharding packages, each sharding package corresponding to a decision flow in the knowledge package.

[0114] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0115] The execution subject of the data compilation method in the specific implementation manner of the present disclosure may be an electronic device such as a mobile phone, a tablet computer, or a server.

[0116] Therefore, based on any of the above embodiments, the present disclosure further provides an electronic device, which can execute the data compilation method of any of the above embodiments of the present disclosure, and the data compilation device of any of the above embodiments can be configured on the electronic device.

[0117] Fig.13 It is a schematic block diagram of the structure of an electronic device 1000 equipped with a data compiling device according to an embodiment of the present disclosure.

[0118] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.

[0119] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.

[0120] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0121] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.

[0122] A computer program or instruction may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, a computer program or instruction may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0123] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0124] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data compilation device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data compilation device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0125] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data compiling device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0126] These computer program instructions may also be loaded onto a computer or other programmable data encoding device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0127] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.

[0128] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0129] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. A data compilation method, characterized in that: include: In response to a compilation request of a rule to be compiled, retrieving a plurality of fragment packages corresponding to the rule to be compiled; Compile each of the slice packages in parallel to obtain a plurality of compiled data, each of the compiled data being compiled from one of the slice packages; as well as Integrate a plurality of the compiled data to obtain compiled rules; The rule to be compiled corresponds to a knowledge package, and each of the fragment packages contains a decision flow in the knowledge package.

2. The data compiling method according to claim 1, characterized in that: Also includes: Acquire the knowledge package and identify the topological structure of the knowledge package; as well as In response to the topological structure of the knowledge package being a decision flow forest structure, the knowledge package is split into a plurality of slice packages, each of which corresponds to a decision flow in the knowledge package.

3. The data compiling method according to claim 2, characterized in that: In response to the topology structure of the knowledge package only including the decision flow, splitting the knowledge package into a plurality of fragment packages, including: Obtaining the number of decision flows of the knowledge package; Determine the number of shards according to the number of decision flows of the knowledge package; Creating a plurality of new knowledge packages according to the number of shards, and determining the new knowledge packages as the shard packages, each of the shard packages containing a decision flow of the knowledge package; and The plurality of fragment packets are published in a routing table.

4. The data compiling method according to claim 3, characterized in that: Splitting the knowledge package into a plurality of fragment packages further comprises: Obtaining the identity identification code of the knowledge package and the rule mapping table where the identity identification code of the knowledge package is located, wherein the rule mapping table is used to store the mapping relationship between the rule file and the knowledge package; Assigning an identity code to each of the slice packages, and configuring the identity code of the knowledge package as the parent identity code of each of the slice packages; and The identity identification code of each of the slice packages, the parent identity code, and the corresponding relationship between the slice package and the decision flow are stored in the rule mapping table where the identity identification code of the knowledge package is located.

5. The data compiling method according to claim 2, characterized in that: Also includes: In response to the modification instruction of the knowledge package, modify the knowledge package to obtain the modified knowledge package; Querying the rules that are newly added, modified or deleted in the modified knowledge package relative to the knowledge package before modification; In response to the modified knowledge package having a newly added rule relative to the knowledge package before the modification, creating a new slice package, wherein the new slice package includes a decision flow corresponding to the newly added rule; and / or In response to the modified knowledge package having a modified rule relative to the knowledge package before modification, retrieving a rule change fragment package, the rule change fragment package including a decision flow corresponding to the modified rule, and replacing the decision flow included in the rule change fragment package with the decision flow corresponding to the modified rule; and / or In response to the modified knowledge package having a deleted rule relative to the knowledge package before modification, a redundant slice package is retrieved and deleted, wherein the redundant slice package includes a decision flow corresponding to the deleted rule.

6. The data compiling method according to claim 1, characterized in that: In response to a compilation request of a rule to be compiled, retrieving a plurality of fragment packages corresponding to the rule to be compiled, including: Obtaining a rule field in the compilation request; Querying the decision flow corresponding to the rule field in the rule mapping table, and determining the decision flow corresponding to the rule field as the designated decision flow; and Obtain the fragment package corresponding to the specified decision flow; The rule mapping table is used to store the corresponding relationship between the decision flow and the fragmentation packet.

7. The data compiling method according to claim 6, characterized in that: Obtaining the fragment package corresponding to the specified decision flow includes: Searching the rule mapping table for the identity code of the slice packet containing the specified decision flow; and The fragmented packet corresponding to the identity code is searched in the routing table, and the fragmented packet is obtained.

8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instructions stored in the memory, so that the processor executes the data compilation method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the data compilation method according to any one of claims 1 to 7 when executed by a processor.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the data compilation method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Low-coupling simulation behavior rule resource construction method based on reflection mechanism

    CN120315677A

  • A method for constructing low-coupling simulation behavior rule resources based on reflection mechanism

    CN120315677B