CN112199083A - Configurable ID generation system and method based on expression - Google Patents
Configurable ID generation system and method based on expression Download PDFInfo
- Publication number
- CN112199083A CN112199083A CN202011108191.5A CN202011108191A CN112199083A CN 112199083 A CN112199083 A CN 112199083A CN 202011108191 A CN202011108191 A CN 202011108191A CN 112199083 A CN112199083 A CN 112199083A
- Authority
- CN
- China
- Prior art keywords
- expression
- generation
- sequence
- module
- configurable
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000014509 gene expression Effects 0.000 title claims abstract description 92
- 238000000034 method Methods 0.000 title claims abstract description 27
- 238000010195 expression analysis Methods 0.000 claims abstract description 16
- 238000010586 diagram Methods 0.000 description 5
- 241001124156 Mecoptera Species 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000003860 storage Methods 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
Abstract
The invention discloses a configurable ID generation system and a method based on expressions, wherein the system comprises: the ID expression setting module is used for setting an ID expression, the ID expression comprises at least one node, and all the nodes are combined to form the ID expression; the ID expression analysis module is used for analyzing the ID expressions set by the ID expression setting module and analyzing all nodes contained in the ID expressions; and the ID generation module is used for generating corresponding IDs according to the nodes of the ID expressions analyzed by the ID expression analysis module and the analysis result of the ID expression analysis module. The configurable ID generation system and method based on the expression can complete the customization requirements of various IDs through simple mode configuration, do not need hard coding, and can reduce the coding workload and the error probability.
Description
Technical Field
The invention belongs to the technical field of computer software, relates to an ID generation system, and particularly relates to a configurable ID generation system and method based on expressions.
Background
In modern software systems, unique numbers, business serial numbers or primary keys are the most common design elements. Such as a user number, order number, request for running water. These numbers generally require one or more of the following characteristics: (1) the global is unique; (2) (7) the length is moderate, and the service requirement can be met; (8) the generation efficiency required under the high concurrency scene is met.
In terms of solving distributed IDs, many enterprises or individuals propose good solutions, typically uuid, guid, database self-increment sequence, snowflow algorithm, and the like. These solutions address one or more of the 4 basic features. For example, uuid has the above-mentioned characteristics 1 and 4, but cannot satisfy the above-mentioned characteristics 2, 3, 5, etc., and thus cannot be used for the database primary key; guid satisfies the characteristics 1, 2, 4 and 5, but the length is 128bit, which is not satisfied, and the storage consumption is too large; the database self-increment sequence meets the characteristics 1, 3 and 7, but does not meet the requirements 4, 5, 6 and 8, and is generally used in scenes with small non-sensitive data volume. The snowfly meets the requirements of 1, 2, 4, 5 and 8, is a very excellent ID generation algorithm and is also the algorithm which is most used in the internet industry at present, but the sequence length of the snowfly is generally greater than 19 bits, the snowfly is overlong in most occasions, and in addition, the service date attribute of the snowfly is not obvious and can be deduced through complex bit operation.
To summarize, the prior art provides solutions from a unique perspective, with fewer solutions in customization.
In actual production, enterprises generally use various ID generation algorithms comprehensively, and on the basis of the original algorithm, some generation modes are subjected to secondary transformation through modes of character string splicing, filling and the like, and finally, a numbering rule meeting requirements is generated. This transformation process is typically done by hard coding and cannot be flexibly customized to some specific scenarios. Hard coding can also easily damage historical rules, causing errors in the generating system.
In view of the above, there is a need to design a new ID generation method to overcome at least some of the above-mentioned disadvantages of the existing ID generation methods.
Disclosure of Invention
The invention provides a configurable ID generation system and method based on expressions, which can complete the customization requirements of various IDs through simple mode configuration without hard coding, and can reduce the coding workload and the error probability.
In order to solve the technical problem, according to one aspect of the present invention, the following technical solutions are adopted:
an expression-based configurable ID generation system, the system comprising:
the ID expression setting module is used for setting an ID expression, the ID expression comprises at least one node, and all the nodes are combined to form the ID expression;
the ID expression analysis module is used for analyzing the ID expressions set by the ID expression setting module and analyzing all nodes contained in the ID expressions;
and the ID generation module is used for generating corresponding IDs according to the nodes of the ID expressions analyzed by the ID expression analysis module and the analysis result of the ID expression analysis module.
As an embodiment of the invention, unlike other ID solutions, the generation of unique sequences is repeated, regardless of the need to include critical business implications in the ID. The invention mainly solves the problem that various service meanings are included in the expression according to requirements, and the sequence length is cut according to the requirements, thereby ensuring that the total length of the ID is maintained in a set length range.
Unlike hard-coded implementations that require custom development of the ID in different programming languages, business personnel will not have the ability to custom tune the ID as an embodiment of the invention. The invention uses a simple character string expression mode, hides the coding details, realizes the quick customization of the ID, and can customize the ID according to the requirement even for operators without programming experience.
As an embodiment of the present invention, the ID generation module introduces a sequence generation interface in the sequence converter, and the client uses a customized sequence generator through the sequence generation interface.
As an embodiment of the present invention, the ID generation module uses a precompilation method to initialize each transcoder in advance, and assigns and compiles related parameters, so that it is not necessary to initialize an object each time the ID generation module generates the ID.
According to another aspect of the invention, the following technical scheme is adopted: a method of configurable ID generation based on expressions, the method comprising:
setting an ID expression, wherein the ID expression comprises at least one node, and all the nodes are combined to form the ID expression;
analyzing the set ID expression and analyzing each node contained in the ID expression from the ID expression;
and generating a corresponding ID by using the analysis result of the ID expression analysis step according to each node of the analyzed ID expression.
As an embodiment of the invention, a sequence generation interface is introduced into the sequence converter, and the client uses a self-defined sequence generator through the sequence generation interface.
As an embodiment of the invention, a precompilation mode is adopted to initialize each sequence converter in advance, and the relevant parameters are assigned and compiled, so that the object does not need to be initialized every time the sequence converter is generated.
The invention has the beneficial effects that: the configurable ID generation system and method based on the expression can complete the customization requirements of various IDs through simple mode configuration, do not need hard coding, and can reduce the coding workload and the error probability.
Drawings
Fig. 1 is a schematic diagram illustrating a configurable ID generation system according to an embodiment of the present invention.
Fig. 2 is a flowchart of a configurable ID generation method according to an embodiment of the present invention.
FIG. 3 is a schematic diagram of ID configuration according to an embodiment of the present invention.
FIG. 4 is a flowchart illustrating ID expression conversion according to an embodiment of the present invention.
Fig. 5 is a schematic diagram of node type free combination according to an embodiment of the present invention.
Detailed Description
Preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
For a further understanding of the invention, reference will now be made to the preferred embodiments of the invention by way of example, and it is to be understood that the description is intended to further illustrate features and advantages of the invention, and not to limit the scope of the claims.
The description in this section is for several exemplary embodiments only, and the present invention is not limited only to the scope of the embodiments described. It is within the scope of the present disclosure and protection that the same or similar prior art means and some features of the embodiments may be interchanged.
The term "connected" in the specification includes both direct connection and indirect connection.
The invention discloses a configurable ID generation system based on an expression, and FIG. 1 is a schematic diagram of the configurable ID generation system in an embodiment of the invention; referring to fig. 1, the system includes: an ID expression setting module 1, an ID expression analysis module 2 and an ID generation module 3.
The ID expression setting module 1 is used for setting an ID expression, and the ID expression includes at least one node, and the nodes are combined to form the ID expression (a combination mode or a decorator mode can be used in implementation). The ID expression parsing module 2 is configured to parse the ID expression set by the ID expression setting module, and parse each node included in the ID expression from the ID expression (in implementation, an interpreter mode may be used to parse the expression to generate a combined ID generator). The ID generation module 3 is configured to generate a corresponding ID by using an analysis result of the ID expression analysis module according to each node of the ID expression analyzed by the ID expression analysis module.
The invention is different from other ID solutions in that a unique sequence is generated, and the key service significance is not considered to be contained in the ID. The invention mainly solves the problem that various service meanings are included in the expression according to requirements, and the sequence length is cut according to the requirements, thereby ensuring that the total length of the ID is maintained in a set length range.
Meanwhile, the method of the invention is different from the hard coding method, the ID needs to be customized and developed in different programming languages, and business personnel have no ability to customize and adjust the ID. The invention uses a simple character string expression mode, hides the coding details, realizes the quick customization of the ID, and can customize the ID according to the requirement even for operators without programming experience.
In an embodiment of the present invention, the ID generation module 3 introduces a sequence generation interface in the sequence converter, and the client uses a customized sequence generator through the sequence generation interface. In an embodiment, the ID generation module 3 uses a precompilation mode to initialize each sequence converter in advance, and assigns and compiles the relevant parameters, so that it is not necessary to initialize the object each time the generation is performed.
The invention further discloses a configurable ID generation method based on expression, and FIG. 2 is a flow chart of the configurable ID generation method in an embodiment of the invention; referring to fig. 2, the method includes:
step S1, setting an ID expression, wherein the ID expression comprises at least one node, and all the nodes are combined to form the ID expression;
step S2, parsing the set ID expression, and parsing out each node included in the ID expression from the ID expression;
step S3, the corresponding ID is generated from each node of the ID expression analyzed by the ID expression analysis step using the analysis result of the ID expression analysis step.
In an embodiment of the present invention, in step S3, a sequence generation interface is introduced into the sequence converter, and the client uses a customized sequence generator through the sequence generation interface. In an embodiment, a precompilation mode is adopted to initialize each sequence converter in advance, and the relevant parameters are assigned and compiled, so that the object does not need to be initialized every time the object is generated.
In an embodiment of the present invention, a configurable ID generation method includes:
step S1, an ID expression design step.
The ID typically has one or more of the following elements: fixed identifiers, variable identifiers, dates (different formats are used on different occasions), relative date values (difference values with respect to a reference date), random numbers, sequences (increasing trend, and will not repeat under certain conditions; for example, when conditions other than sequences are consistent, sequences will not repeat), and lengths of segments. A typical flow diagram is shown in figure 3.
The segment identifiers are described using special keywords, such as: d or date represents a date field, seq represents a traffic flow, r represents a random number, offset day represents an offset date, ph represents a dynamic variable, these keys are identified with a% number, and the value following the% number identifies the field length of this field. And the identifier is not represented by a fixed identifier and is output as it is. The above business numbering rule may be described as A% 2 ph% 8 date% 10 seq.
In an embodiment of the invention, further enhancement and optimization are carried out on the basis of the following steps: (1) the length that the input party can guarantee can not be disposed, for example the service identifier itself is also 2 bits, the default is 8 bits after the date is formatted, then these two do not need to dispose again, simplify to: a% ph% date% 10 seq; (2) sequence we expect to use a specific service sequence, avoiding global mix-ups, the date requirement can be configured in other formats, where corresponding parameters can be added, such as: a% ph% date { yyMMdd }% 10seq { BIZ _ TAG }.
Based on the idea, the invention can freely expand the keywords and add more elements which are expected to be used, such as complex expression operation, special character filling and the like.
Step S2, an ID expression parsing step.
The ID expression is processed by a Parser to be responsible for conversion, and the conversion process is shown in FIG. 4.
The final nodes comprise simple nodes and combined nodes, and the analyzed nodes form a chain relation. As shown in fig. 5, the node types are freely combined.
Step S3, an ID generation implementation step of the ID expression.
When generating the ID, the nodes are actually output character strings conforming to the node rule and spliced together. For example: the data output by the date node is implemented as follows: i.e. the current date is formatted and output.
The focus here is on the implementation of the sequence segments. The sequence is the core of an ID and is an essential part. Therefore, the scheme does not create a sequence generation scheme additionally, but introduces a sequence generation interface in the sequence converter, and the client can use a self-defined sequence generator by implementing the interface, so that the modification of the existing system is reduced with the minimum cost.
In order to improve the efficiency of sequence generation, the scheme also adopts a precompilation mode to initialize each converter in advance, and assigns and compiles related parameters, so that an object does not need to be initialized every time of generation.
The Converter is an abstraction of the Converter, and a customer can customize the Converter to meet the composition requirements of more elements and customize a more personalized ID scheme.
The invention realizes the customized output of different ID elements through different converters by innovatively abstracting various common elements in the ID. And then, the combination processing of each element is completed through a simple and easy-to-use regular expression, and finally a format requirement meeting the ID under different scenes is generated, so that the ID customization workload is greatly simplified, and the development time is saved. Meanwhile, the format expression perspectives the sequence rule to a user, so that the user can understand and use the sequence rule more conveniently.
The invention creatively completes the customization of a complex ID through a simple expression without any additional coding on a using end, which is not available in the prior art. By using the scheme, the efficiency of ID customization realization can be improved by hundreds of times.
The following are currently several typical ID customization schemes comparisons:
TABLE 1 several exemplary ID customization scenarios comparison tables
The table shows that the invention can meet various coding customization requirements with little cost, and has the characteristics of customizable length, high degree of freedom and small development workload.
In summary, the system and the method for generating configurable IDs based on expressions provided by the present invention can fulfill the customization requirements of various IDs through simple mode configuration, and do not need hard coding, thereby reducing the coding workload and the error probability.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The description and applications of the invention herein are illustrative and are not intended to limit the scope of the invention to the embodiments described above. Effects or advantages referred to in the embodiments may not be reflected in the embodiments due to interference of various factors, and the description of the effects or advantages is not intended to limit the embodiments. Variations and modifications of the embodiments disclosed herein are possible, and alternative and equivalent various components of the embodiments will be apparent to those skilled in the art. It will be clear to those skilled in the art that the present invention may be embodied in other forms, structures, arrangements, proportions, and with other components, materials, and parts, without departing from the spirit or essential characteristics thereof. Other variations and modifications of the embodiments disclosed herein may be made without departing from the scope and spirit of the invention.
Claims (8)
1. An expression-based configurable ID generation system, the system comprising:
the ID expression setting module is used for setting an ID expression, the ID expression comprises at least one node, and all the nodes are combined to form the ID expression;
the ID expression analysis module is used for analyzing the ID expressions set by the ID expression setting module and analyzing all nodes contained in the ID expressions;
and the ID generation module is used for generating corresponding IDs according to the nodes of the ID expressions analyzed by the ID expression analysis module and the analysis result of the ID expression analysis module.
2. The expression-based configurable ID generation system of claim 1, wherein:
the expression includes various business meanings according to requirements, and the sequence length is cut according to requirements, so that the total length of the ID is maintained in a set length range.
3. The expression-based configurable ID generation system of claim 1, wherein:
and the encoding details are hidden by using a character string expression mode, so that the ID is quickly customized.
4. The expression-based configurable ID generation system of claim 1, wherein:
the ID generation module introduces a sequence generation interface into the sequence converter, and the client uses a self-defined sequence generator through the sequence generation interface.
5. The expression-based configurable ID generation system of claim 1, wherein:
the ID generation module adopts a pre-compiling mode to initialize each sequence converter in advance and carry out assignment and compilation on related parameters, and an object does not need to be initialized every time when the ID generation module generates the corresponding parameters.
6. A method for generating a configurable ID based on an expression, the method comprising:
setting an ID expression, wherein the ID expression comprises at least one node, and all the nodes are combined to form the ID expression;
analyzing the set ID expression and analyzing each node contained in the ID expression from the ID expression;
and generating a corresponding ID by using the analysis result of the ID expression analysis step according to each node of the analyzed ID expression.
7. The expression-based configurable ID generation method of claim 6, wherein:
and introducing a sequence generation interface in the sequence converter, and using a self-defined sequence generator by the client through the sequence generation interface.
8. The expression-based configurable ID generation method of claim 6, wherein:
and the method adopts a pre-compiling mode to initialize each sequence converter in advance, assigns and compiles the related parameters, and does not need to initialize the object every time of generation.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011108191.5A CN112199083A (en) | 2020-10-16 | 2020-10-16 | Configurable ID generation system and method based on expression |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011108191.5A CN112199083A (en) | 2020-10-16 | 2020-10-16 | Configurable ID generation system and method based on expression |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112199083A true CN112199083A (en) | 2021-01-08 |
Family
ID=74009243
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011108191.5A Pending CN112199083A (en) | 2020-10-16 | 2020-10-16 | Configurable ID generation system and method based on expression |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112199083A (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101145226A (en) * | 2007-10-30 | 2008-03-19 | 金蝶软件(中国)有限公司 | Method and system for creating operation code |
CN103257862A (en) * | 2013-04-23 | 2013-08-21 | 浪潮集团山东通用软件有限公司 | Encoding method of cross-interval free configuration asset turnover serial number |
US8856540B1 (en) * | 2010-12-29 | 2014-10-07 | Amazon Technologies, Inc. | Customized ID generation |
CN107247695A (en) * | 2017-05-31 | 2017-10-13 | 深圳市长亮科技股份有限公司 | Coding rule generation method, system and storage device |
CN108322222A (en) * | 2018-01-16 | 2018-07-24 | 四川斐讯信息技术有限公司 | A method of it generates and using distributed unique ID |
CN109697280A (en) * | 2018-12-27 | 2019-04-30 | 北京中电普华信息技术有限公司 | A kind of big concurrently autocoding generation method and system |
CN110928912A (en) * | 2018-09-20 | 2020-03-27 | 北京京东尚科信息技术有限公司 | Method and device for generating unique identifier |
CN111538594A (en) * | 2020-04-21 | 2020-08-14 | 招商局金融科技有限公司 | Order ID generation method, device, equipment and medium based on distributed system |
-
2020
- 2020-10-16 CN CN202011108191.5A patent/CN112199083A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101145226A (en) * | 2007-10-30 | 2008-03-19 | 金蝶软件(中国)有限公司 | Method and system for creating operation code |
US8856540B1 (en) * | 2010-12-29 | 2014-10-07 | Amazon Technologies, Inc. | Customized ID generation |
CN103257862A (en) * | 2013-04-23 | 2013-08-21 | 浪潮集团山东通用软件有限公司 | Encoding method of cross-interval free configuration asset turnover serial number |
CN107247695A (en) * | 2017-05-31 | 2017-10-13 | 深圳市长亮科技股份有限公司 | Coding rule generation method, system and storage device |
CN108322222A (en) * | 2018-01-16 | 2018-07-24 | 四川斐讯信息技术有限公司 | A method of it generates and using distributed unique ID |
CN110928912A (en) * | 2018-09-20 | 2020-03-27 | 北京京东尚科信息技术有限公司 | Method and device for generating unique identifier |
CN109697280A (en) * | 2018-12-27 | 2019-04-30 | 北京中电普华信息技术有限公司 | A kind of big concurrently autocoding generation method and system |
CN111538594A (en) * | 2020-04-21 | 2020-08-14 | 招商局金融科技有限公司 | Order ID generation method, device, equipment and medium based on distributed system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7043686B1 (en) | Data compression apparatus, database system, data communication system, data compression method, storage medium and program transmission apparatus | |
US6825781B2 (en) | Method and system for compressing structured descriptions of documents | |
US9336188B2 (en) | Generating a statistical tree for encoding/decoding an XML document | |
CN101841515B (en) | Target variable protocol data unit codec code automatic generation implementation method | |
US20030135508A1 (en) | Translating configuration files among network devices | |
EP2124419B1 (en) | An object oriented management device for asn.1 message | |
CN109522008B (en) | Intelligent contract construction method for block chain | |
CN108829884B (en) | Data mapping method and device | |
CN109116828B (en) | Method and device for configuring model codes in controller | |
CN101179580B (en) | Method for implementing encoding/decoding of WiMAX system information | |
CN101370003B (en) | Method and apparatus for customizing communication protocol, method and apparatus for converting communication protocol description | |
Sakamoto et al. | A space-saving approximation algorithm for grammar-based compression | |
CN112199083A (en) | Configurable ID generation system and method based on expression | |
CN110806973A (en) | Automatic generation method and device of interface message | |
Riedel et al. | A model driven internet of things | |
US6111660A (en) | Efficient digital data encoding in a data processing system | |
CN110569487B (en) | Base64 expansion coding method and system based on high-frequency character substitution algorithm | |
US20060253833A1 (en) | System and method for efficient hosting of wireless applications by encoding application component definitions | |
CN113254026A (en) | Low code development method and device | |
CN110826151A (en) | Electric automobile model design method | |
Huarng et al. | OKCFTR: translators for Knowledge Reuse | |
US6999010B2 (en) | Table look-up method for abstract syntax notation encoding/decoding system | |
CN109918396A (en) | A kind of multiplicity data search method | |
CN107992566A (en) | Data mapping method and system based on Hibernate | |
CN116644121A (en) | Data format verification method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |