[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN109726213A - A kind of program code conversion method, device, medium and calculate equipment - Google Patents

A kind of program code conversion method, device, medium and calculate equipment Download PDF

Info

Publication number
CN109726213A
CN109726213A CN201811504924.XA CN201811504924A CN109726213A CN 109726213 A CN109726213 A CN 109726213A CN 201811504924 A CN201811504924 A CN 201811504924A CN 109726213 A CN109726213 A CN 109726213A
Authority
CN
China
Prior art keywords
program
statement
sentence
code
intermediate code
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.)
Granted
Application number
CN201811504924.XA
Other languages
Chinese (zh)
Other versions
CN109726213B (en
Inventor
王贝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Huabei Technology Co ltd
Original Assignee
Netease Kaola Hangzhou Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Netease Kaola Hangzhou Technology Co Ltd filed Critical Netease Kaola Hangzhou Technology Co Ltd
Priority to CN201811504924.XA priority Critical patent/CN109726213B/en
Publication of CN109726213A publication Critical patent/CN109726213A/en
Application granted granted Critical
Publication of CN109726213B publication Critical patent/CN109726213B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Embodiments of the present invention provide a kind of program code conversion method, device, medium and calculate equipment.This method comprises: the source code of reading program sentence by sentence;Judge whether the program statement currently read is particular statement;If so, program statement is converted into intermediate code;It explains and executes intermediate code;Program statement is executed if it is not, directly explaining.This method is by judging whether present procedure sentence is particular statement, and execution program statement is explained according to judging result, to realize that automatic identification and dynamic to program statement are modified, facilitate the modification of simplified program statement, the realization logical complexity and maintenance difficulties for reducing program statement, improve the versatility of program statement.

Description

A kind of program code conversion method, device, medium and calculate equipment
Technical field
Embodiments of the present invention are related to software field, more specifically, embodiments of the present invention are related to a kind of program generation Code converting method, device, medium and calculating equipment.
Background technique
Background that this section is intended to provide an explanation of the embodiments of the present invention set forth in the claims or context.Herein Description recognizes it is the prior art not because not being included in this section.
Optimistic locking (Optimistic Lock) is suitable for the application type more read, and helps to improve handling up for database table Amount.In the optimistic locking solution based on versions of data (Version) mechanism, versions of data is used to indicate data change Version identifier can be judged when data are submitted wait mention by increasing versions of data (such as version field) for database table Whether the data handed over are stale data, if it is data to be committed be not stale data if by the data and corresponding data version Originally it is updated to database, the data are not updated to database for determination if stale data if data to be committed.
Currently, the realization of optimistic locking solution mostly realizes that logic, such as exploitation are answered dependent on the optimistic locking added manually What the used time added manually in structuralized query (Structured Query Language, SQL) sentence is directed in database table The Rule of judgment of version field.Since optimistic locking realizes that logic needs to be set to core logic language in optimistic locking solution In sentence, so that the realization logic of optimistic locking is coupled in service code completely, cause the realization logic of optimistic locking complicated, maintenance difficulties Greatly, versatility is low, and pluggable property is poor.In addition, optimistic locking realizes the database that logic can also be related in optimistic locking solution Table quantity is more, further increases the development difficulty and maintenance difficulties of optimistic locking.
To sum up, at present there is realization logic complexity in optimistic locking solution, and maintenance difficulties are big, and versatility is low, pluggable property The problems such as poor.
Summary of the invention
Optimistic locking (Optimistic Lock) is suitable for the application type more read, and helps to improve handling up for database table Amount.But the realization of current optimistic locking solution is mostly dependent on the Rule of judgment added manually, due in optimistic locking solution Rule of judgment is set in core logic sentence, so that the realization logic of optimistic locking is coupled in service code completely, is caused at present The problems such as optimistic locking solution, which exists, realizes that logic is complicated, and maintenance difficulties are big, and versatility is low, and pluggable property is poor.Further, since The database table quantity that Rule of judgment is related in optimistic locking solution at present is more, further also results in opening for optimistic locking The problem of degree of raising difficult questions and maintenance difficulties increase.
In the present context, embodiments of the present invention be intended to provide a kind of program code conversion method, device, medium and Equipment is calculated, to solve the above problem existing for current optimistic locking solution.
In the first aspect of embodiment of the present invention, a kind of program code conversion method is provided, comprising: read sentence by sentence The source code of program;Judge whether the program statement currently read is particular statement;If so, program statement is converted into centre Code;It explains and executes intermediate code;Program statement is executed if it is not, directly explaining.
In one embodiment of the invention, it is different from execution program statement is explained to explain that execution intermediate code can be realized Function.
In another embodiment of the invention, the step of whether program statement that judgement is currently read is particular statement packet It includes: obtaining preset critical field in configuration file;It whether is particular statement according to critical field determining program sentence.
In yet another embodiment of the present invention, the step of whether being particular statement according to critical field determining program sentence It include: to judge whether critical field matches with each field in program statement;According to matching result determining program sentence whether For particular statement.
In yet another embodiment of the present invention, the step of particular statement in recognize program code includes: to obtain configuration Preset unique identification in file;It whether is particular statement according to unique identification determining program sentence.
In another embodiment of the present invention, the step of according to unique identification determining program sentence whether being particular statement It include: the unique identification for obtaining program statement;Judge whether preset unique identification matches with the unique identification of program statement;Root It whether is particular statement according to matching result determining program sentence.
In one embodiment of the invention, the step of program statement being converted into intermediate code includes: to obtain configuration text Preset intermediate code create-rule in part;It is rule-based that program statement is converted into intermediate code.
In one embodiment of the invention, preset intermediate code create-rule includes preset field and corresponding behaviour Make type, rule-based the step of program statement is converted into intermediate code includes: to splice preset field to program statement Designated position is to generate intermediate code;Or preset field is deleted from the designated position of program statement to generate intermediate code.
In one embodiment of the invention, preset field includes that can be realized the field of version control function.
In one embodiment of the invention, configuration file is stored in local or decentralized configuration management platform.
In the second aspect of embodiment of the present invention, a kind of program code conversion apparatus is provided, comprising: source code is read Modulus block is configured as sentence by sentence the source code of reading program;
Particular statement judgment module, is configured as whether the program statement that judgement is currently read is particular statement;
Intermediate code generation module, is configured as if the determination result is YES, and program statement is converted into intermediate code;
It explains execution module, is configured as explaining executing intermediate code;And
If judging result be it is no, directly explain execute program statement.
In one embodiment of the invention, it is different from execution program statement is explained to explain that execution intermediate code can be realized Function.
In one embodiment of the invention, particular statement judgment module is specifically used for: obtaining preset in configuration file Critical field;It whether is particular statement according to critical field determining program sentence.
In one embodiment of the invention, particular statement judgment module according to critical field determining program sentence whether When for particular statement, it is specifically used for: judges whether critical field matches with each field in program statement;According to matching result Whether determining program sentence is particular statement.
In one embodiment of the invention, particular statement judgment module is specifically used for: obtaining preset in configuration file Unique identification;It whether is particular statement according to unique identification determining program sentence.
In one embodiment of the invention, particular statement judgment module according to unique identification determining program sentence whether When for particular statement, it is specifically used for: obtains the unique identification of program statement;Judge preset unique identification and program statement only One identifies whether to match;It whether is particular statement according to matching result determining program sentence.
In one embodiment of the invention, intermediate code generation module is specifically used for: obtaining preset in configuration file Intermediate code create-rule;It is rule-based that program statement is converted into intermediate code.
In one embodiment of the invention, preset intermediate code create-rule includes preset field and corresponding behaviour Make type, intermediate code generation module it is rule-based program statement is converted into intermediate code when, be specifically used for: by predetermined word Section splicing is to the designated position of program statement to generate intermediate code;Or preset field is deleted from the designated position of program statement To generate intermediate code.
In one embodiment of the invention, preset field includes that can be realized the field of version control function.
In one embodiment of the invention, configuration file is stored in local or decentralized configuration management platform.
In the third aspect of embodiment of the present invention, a kind of medium is provided, which has computer executable Instruction, the method that computer executable instructions are used to that computer to be made to execute any embodiment in first aspect.
In the fourth aspect of embodiment of the present invention, provide a kind of calculating equipment, including processing unit, memory with And input/output (In/Out, I/O) interface;Memory, the program or instruction executed for storage processing unit;Processing unit, Program or instruction for being stored according to memory, the method for executing any embodiment in first aspect;I/O interface is used for Data are received or sent under the control of processing unit.
The technical solution that embodiments of the present invention provide, can reading program sentence by sentence source code, judge current read To program statement whether be particular statement;If program statement is then converted into intermediate code, and explain execution intermediate code; If otherwise directly explaining and executing program statement.Technical solution provided by the invention, by judging whether present procedure sentence is special Attribute sentence, and execution program statement is explained according to judging result, to realize that automatic identification and dynamic to program statement are modified, The modification for facilitating simplified program statement, reduces the realization logical complexity and maintenance difficulties of program statement, improves program The versatility of sentence.
Detailed description of the invention
The following detailed description is read with reference to the accompanying drawings, above-mentioned and other mesh of exemplary embodiment of the invention , feature and advantage will become prone to understand.In the accompanying drawings, if showing by way of example rather than limitation of the invention Dry embodiment, in which:
Fig. 1 schematically shows a kind of flow diagram of program code conversion of embodiment according to the present invention;
Fig. 2 schematically shows the process signals of another program code conversion method according to an embodiment of the present invention Figure;
Fig. 3 schematically shows a kind of structural schematic diagram of program code conversion apparatus according to an embodiment of the present invention;
Fig. 4 schematically shows a kind of structural schematic diagrams of medium according to an embodiment of the present invention;
Fig. 5 schematically shows a kind of structural schematic diagram for calculating equipment according to an embodiment of the present invention;
In the accompanying drawings, identical or corresponding label indicates identical or corresponding part.
Specific embodiment
The principle and spirit of the invention are described below with reference to several illustrative embodiments.It should be appreciated that providing this A little embodiments are used for the purpose of making those skilled in the art can better understand that realizing the present invention in turn, and be not with any Mode limits the scope of the invention.On the contrary, these embodiments are provided so that this disclosure will be more thorough and complete, and energy It is enough that the scope of the present disclosure is completely communicated to those skilled in the art.
One skilled in the art will appreciate that embodiments of the present invention can be implemented as a kind of system, device, equipment, method Or computer program product.Therefore, the present disclosure may be embodied in the following forms, it may be assumed that complete hardware, complete software The form that (including firmware, resident software, microcode etc.) or hardware and software combine.
Embodiment according to the present invention proposes a kind of program code conversion method, medium, device and calculates equipment.
Herein, it is to be understood that the meaning of involved several concepts is as follows:
MySQL: being a kind of relational database management system, and relational database saves the data in different tables, without It is to be placed on all data in one big warehouse, which adds speed and improves flexibility.SQL used in MySQL Language is the most frequently used standardized language for accessing database.MySQL software uses double authorization policies, be divided into Community Edition and Commercial version, since its is small in size, speed is fast, the total cost of ownership is low, especially this feature of open source code, general middle-size and small-size net The exploitation stood all selects MySQL as site databases.
SQL: i.e. structured query language, is a kind of data base querying and programming language, for access data and Query, update, and manage relational database system.SQL statement is exactly a kind of language operated to database.
Mybatis: being a outstanding Persistence Layer Framework, it supports to customize SQL, storing process and advanced mapping. MyBatis avoids almost all of JDBC code and manual setting parameter and obtains result set, and MyBatis is simple to use XML or note configure and map primary information, by interface and common Java object (Plain Old Java Objects, POJOs) it is mapped to the record in database.
Value object (VO): i.e. Value Object, commonly used in the data transmitting between operation layer, VO only includes number According to.
In addition, any number of elements in attached drawing is used to example rather than limitation and any name are only used for distinguishing, Without any restrictions meaning.
Below with reference to several representative embodiments of the invention, the principle and spirit of the present invention are explained in detail.
Summary of the invention
Optimistic locking is suitable for the application type more read, and helps to improve the handling capacity of database table.The inventors discovered that existing The realization of some optimistic locking solutions mostly realizes logic dependent on the optimistic locking added manually, but due to optimistic locking solution Middle optimistic locking realizes that logic needs to be set in core logic sentence, so that the realization logic of optimistic locking is coupled in business generation completely Code causes existing optimistic locking solution to exist and realizes that logic is complicated, and maintenance difficulties are big, and versatility is low, pluggable property difference etc. Problem.By taking SQL statement as an example, it is assumed that the SQL statement before addition optimistic locking is update lottery_table set Lottery_num=*where activity_id=*, then after adding optimistic locking using existing optimistic locking solution, SQL statement is update lottery_table set lottery_num=*where activity_id=*and Version=*.Also, optimistic locking realizes that logic can also be related to a fairly large number of database table in optimistic locking solution, into One step causes the problem of development difficulty and maintenance difficulties increase of optimistic locking.For example added using existing optimistic locking solution Add the increments logical that can increase version when optimistic locking in processing business logic.Therefore, existing optimistic locking solution is deposited Realizing that logic is complicated, the problems such as maintenance difficulties are big, and versatility is low, and pluggable property is poor.
It is of the existing technology in order to overcome the problems, such as, a kind of program code conversion method, device, Jie are proposed in the present invention Matter and calculating equipment.This method comprises: whether the source code of reading program, the program statement that judgement is currently read are special sentence by sentence Attribute sentence;If program statement is then converted into intermediate code, and explain execution intermediate code;If otherwise directly explaining and executing journey Sequence sentence.Method provided by the invention is solved by judging whether present procedure sentence is particular statement according to judging result Execution program statement is released, to realize that automatic identification and dynamic to program statement are modified, facilitates the modification for simplifying program statement Scheme reduces the realization logical complexity and maintenance difficulties of program statement, improves the versatility of program statement.
After introduced the basic principles of the present invention, lower mask body introduces various non-limiting embodiment party of the invention Formula.
Application scenarios overview
The embodiment of the present invention can be applied to the modification scene of the modification scene of program statement, especially SQL statement.This hair The program statement that bright embodiment is related to be not limited to inquiry (query) SQL statement for realizing query logic, for realizing One of update (update) SQL statement of more new logic or combination, can also be the program statement of other grammers or format.
Technical solution provided by the embodiment of the present invention be suitable for any server or service platform, be also applied for equipped with The electronic equipment of any software systems.The present embodiments relate to electronic equipment, can be directed to user provide image and/or The equipment of data connectivity has the handheld device of wireless connecting function or is connected to its elsewhere of radio modem Manage equipment.Wireless terminal device can be through wireless access network (Radio Access Network, RAN) and one or more cores Net is communicated, and wireless user equipment can be mobile terminal device, such as mobile phone and with the calculating of mobile terminal device Machine, for example, it may be portable, pocket, hand-held, built-in computer or vehicle-mounted mobile device.
Illustrative methods
Below with reference to above-mentioned application scenarios, it is described with reference to Figure 1 the program code of illustrative embodiments according to the present invention Conversion method.It should be noted which is shown only for the purpose of facilitating an understanding of the spirit and principles of the present invention for above-mentioned application scenarios, this The embodiment of invention is unrestricted in this regard.On the contrary, embodiments of the present invention can be applied to it is applicable any Scene.
The embodiment of the invention provides a kind of program code conversion methods, as shown in Figure 1, the program code conversion method packet It includes:
S101: the source code of reading program sentence by sentence.
S102: whether the program statement that judgement is currently read is particular statement.
S103: if so, program statement is converted into intermediate code.
S104: it explains and executes intermediate code.
S105: program statement is executed if it is not, directly explaining.
The source code of method shown in FIG. 1 reading program sentence by sentence judges whether the program statement currently read is specific Sentence;If program statement is then converted into intermediate code, and explain execution intermediate code;If otherwise directly explaining and executing program Sentence.Method provided by the invention is explained by judging whether present procedure sentence is particular statement according to judging result Program statement is executed, to realize that automatic identification and dynamic to program statement are modified, facilitates the modification side for simplifying program statement Case reduces the realization logical complexity and maintenance difficulties of program statement, improves the versatility of program statement.
In the embodiment of the present invention, particular statement refers to the program statement that can be realized certain logic, or can be realized spy Determine the program statement of function.For the modification scene of distinct program sentence, particular statement can be different sentences.With SQL statement Modification scene for, particular statement can be query SQL sentence and/or update SQL statement.
In the embodiment of the present invention, configuration file is at least stored with one of following configuration information or combines: unique identification, Critical field, intermediate code create-rule.It should be noted that unique identification, critical field and intermediate code herein is raw It will be described below at rule, being described in detail can be found in hereafter.The configuration information stored in configuration file is dynamic It can match, it is to be understood that can be realized pair in program code operational process by the configuration information in modification configuration file The modification of program code, to realize the pluggable of program code modification by the configuration file independently of source code Property.
Configuration file is stored in local or decentralized configuration management platform.By taking program statement is SQL statement as an example, configuration text Part can store inner in decentralized configuration service (disconf);Configuration file is stored in local, is using in the case of this It needs for the configuration file to be loaded into memory from local before configuration file, the configuration in scanning memory can be passed through so as to subsequent File monitors the modification of configuration file.
Judge in S102 the program statement currently read whether be particular statement method include it is a variety of, the present invention implement It is not limited in example.A kind of implementation method is preset critical field in configuration file to be obtained, according to the preset critical field Whether determining program sentence is particular statement.Wherein, preset critical field refers to field or energy with specific syntax meaning Enough realize that the field of specific function, such as critical field can be update or query.Specifically, obtaining pre- in configuration file If critical field, and program statement is divided to obtain each field in program statement, judges preset keyword Whether whether section matches with each field in program statement, be afterwards particular statement according to matching result determining program sentence. If matching result is the presence of the field that matches with preset critical field in program statement, illustrate preset critical field with Each field in program statement matches, and program statement is particular statement in the case of this;If matching result is program statement In there is no the fields that match with preset critical field, then illustrate each word in preset critical field and program statement Section mismatches, and program statement is not particular statement in the case of this.
Before S102, handled using source code of the encoding tool to the program using corresponding coded format, it will Source code is converted to the program statement that can be read.
By taking program statement shown in Fig. 2 modifies scene as an example, it is assumed that program statement is SQL statement.Before S102, pass through Mybatis tool is handled the SQL statement that can be read to using the pseudo- SQL statement of mybatis grammatical tagging.In S102 In, the blocker characteristic according to mybatis creates SQL statement blocker (Intercerpetor), configures SQL statement interception The type (Type) of device is Executor, according to critical field update and query preset in configuration file come to the SQL language The method (Method) of sentence blocker is configured;The SQL statement blocker completed using configuration judges the SQL language currently read With the presence or absence of the field to match with update or query in sentence, if then intercepting the SQL statement currently read, to pass through The automatic interception of SQL statement is realized to query SQL sentence and updated to SQL statement blocker.
By above-mentioned implementation method, can be realized based on the preset configuration information of configuration file to program code whether be The judgement of particular statement helps to reduce optimistic locking solution to realize the automatic acquisition to particular statement in source code Realization difficulty.
Further, in S102 according to the matching result of each field in preset critical field and program statement come After whether determining program sentence is particular statement, the particular statement in program code can also be identified.It identifies specific The implementation method of sentence is as follows: preset unique identification in configuration file is obtained, according to the preset unique identification determining program Whether sentence is particular statement.Unique identification includes but is not limited to the mark of the corresponding database table of program statement, program statement Mark, such as the mark of SQL statement.Specifically, obtaining preset unique identification in configuration file, and obtain program statement Unique identification, to judge whether the preset unique identification matches with the unique identification of the program statement, according to matching result Whether determining program sentence is particular statement.If matching result is the unique identification of the preset unique identification and the program statement Unanimously, then illustrate that the preset unique identification and the unique identification of the program statement match, program statement is in the case of this Particular statement;If matching result is that the preset unique identification and the unique identification of the program statement are inconsistent, illustrate that this is pre- If unique identification and the program statement unique identification mismatch, program statement is not particular statement in the case of this.It needs It is noted that being directed to the modification scene of same program sentence, the unique identification of preset unique identification and program statement can be same Belong to the mark of a type;For the modification scene of distinct program sentence, the type of preset unique identification can be identical, in advance If the type of unique identification can also be different, do not limit herein.Above-mentioned detailed process does not limit when judging matching result Used implementation is canonical matching or other modes.
By taking program statement shown in Fig. 2 modifies scene as an example, it is assumed that program statement is SQL statement.Intercepting current read SQL statement after, scan and read preset database table title and SQL statement Id in configuration file, and pass through Mapped The tools such as Statement and Bound SQL obtain database belonging to the SQL statement Id and the SQL statement that currently read Table name;Preset database table title and database belonging to the SQL statement currently read are judged using canonical matching respectively Whether table name consistent and whether the Id of the preset SQL statement and SQL statement Id that currently reads is consistent;According to canonical Whether the SQL statement currently read with result judgement is identified as particular statement.
By above-mentioned implementation method, the particular statement in program code can be known based on preset unique identification Not, to realize the automatic identification to particular statement in program code.
If it is determined that the program statement currently read is particular statement in S103, then program statement is converted into intermediate code Specific steps include: to obtain preset intermediate code create-rule in configuration file, based on the rule by the program statement turn Change intermediate code into.
By taking program statement shown in Fig. 2 modifies scene as an example, it is assumed that program statement is SQL statement, if it is determined that working as in S103 Before the SQL statement that reads be particular statement, then obtain preset intermediate code create-rule in configuration file, replaced by canonical It changes and the program statement is converted by intermediate code based on the rule.
Wherein, intermediate code create-rule be dependent on program statement modification scene modification demand be arranged, intermediate generation Code is the program code with the certain logic for meeting modification demand obtained after modifying.To add optimistic locking in program statement For the scene for realizing logic, intermediate code is that the program statement of logic is realized added with optimistic locking.In addition to optimistic locking is realized The certain logic for meeting modification demand is not limited except logic, in the embodiment of the present invention as other logics.
In the embodiment of the present invention, intermediate code create-rule includes at least preset field and corresponding action type.It should Preset field include but is not limited to can be realized the field of version control function, such as preset field can be that by it is incremental The field of logic and the field that can be realized decision logic.Preferably, preset field is the VO in database table, and the VO Including version field.According to the difference of action type, S103 can be mainly divided into following situation:
Situation one: action type is splicing SQL statement.
In the case, preset preset field and corresponding action type in configuration file are first obtained in S103, then The preset field is spliced to the designated position of program statement to generate intermediate code.
With program statement be update SQL statement, applicable scene be in SQL statement add optimistic locking realize logic for, Assuming that the SQL statement currently read is to update SQL statement, i.e. update tablename set num=# { num } where Id=# { id }, preset field be the first field ", version=version+1 " and the second field " and version=# { version } ", preset action type be splicing SQL statement, then in S103 obtain configuration file in preset first field and Second field and corresponding action type are spliced the first field and the second field to currently reading by canonical replacement The designated position of SQL statement is updated, so that intermediate code update tablename set num=# { num } is generated, Version=version+1where id=# { id } and version=# { version }.
It is query SQL sentence with program statement, applicable scene is to add in SQL statement for optimistic locking realizes logic, Assuming that the SQL statement currently read is query SQL sentence, i.e. select id, num from tablename where id =# { id }, preset field be field ", version ", preset action type be splicing SQL statement, then in S103 obtain configuration Preset first field and the second field and corresponding action type in file are replaced by canonical and splice field to current The query result of the query SQL sentence read is concentrated, to generate intermediate code: select id, num, version from Tablename where id=# { id }.
Situation two: action type is to delete SQL statement.
In the case, preset preset field and corresponding action type in configuration file are first obtained in S103, it will The preset field is deleted from the designated position of program statement to generate intermediate code.It is understood that specific in the case of this Example can be two exemplary reverse process in situation one above, and details are not described herein again.
It should be noted that the designated position of restricted program sentence is not head, the tail portion of the program statement in S103 Or it is intermediate;The quantity of designated position is not limited in S103 yet.
It is generated by the automation that S103 realizes intermediate code, facilitates the modification process for simplifying program statement, help In the realization difficulty for reducing optimistic locking solution.Especially, the scene of logic is realized for addition optimistic locking, S103 can be with The unfriendly code in service code is removed by integrating the increments logical of version in program statement, reduces optimistic locking The degree of coupling for realizing logical AND service code, further decreases the realization difficulty and maintenance difficulties of optimistic locking solution.Equally, Above-mentioned solution can also put off in other program statement modification scenes, to reduce the modified code degree of coupling, drop The modification difficulty and maintenance difficulties of low program statement.
There is the certain logic different from original program sentence by the intermediate code that S103 is generated, it is seen that explain and hold in S104 Row intermediate code can be realized the function different from execution program statement is explained.
With program statement be update SQL statement, applicable scene be in SQL statement add optimistic locking realize logic for, In S103 by preset field splice to currently read update SQL statement designated position to generate intermediate code after, It is explained in S104 and executes the intermediate code, realize the optimistic lock function for being different from former SQL statement afterwards.
If it is determined that the program statement currently read is not particular statement in S105, then directly explains and executes program statement, To avoid influencing the normal execution of service code.
By taking program statement shown in Fig. 2 modifies scene as an example, it is assumed that program statement is SQL statement, if it is determined that working as in S105 Before the SQL statement that reads be not particular statement, then directly explain and execute program statement.
Method provided by the invention, can reading program sentence by sentence source code, judge that the program statement currently read is No is particular statement, if program statement is then converted into intermediate code, and explains execution intermediate code, if otherwise directly explaining Execute program statement.Method provided by the invention is tied by judging whether present procedure sentence is particular statement, and according to judgement Fruit explains execution program statement, to realize that automatic identification and dynamic to program statement are modified, helps to simplify program statement Modification, reduce the realization logical complexity and maintenance difficulties of program statement, improve the versatility of program statement.
Exemplary means
After describing the method for exemplary embodiment of the invention, next, introducing, the present invention provides exemplary The device of implementation.Program code conversion apparatus provided by the invention may be implemented to appoint in the method that the corresponding embodiment of Fig. 1 provides The method of one execution.Referring to Fig. 3, which is included at least:
Source code read module is configured as sentence by sentence the source code of reading program;
Particular statement judgment module, is configured as whether the program statement that judgement is currently read is particular statement;
Intermediate code generation module, is configured as if the determination result is YES, and program statement is converted into intermediate code;
It explains execution module, is configured as explaining executing intermediate code;And
If judging result be it is no, directly explain execute program statement.
Optionally, explain that executing intermediate code can be realized the function different from execution program statement is explained.
Optionally, particular statement judgment module is specifically used for: obtaining preset critical field in configuration file;According to key Whether field determining program sentence is particular statement.
Optionally, whether particular statement judgment module is when being particular statement according to critical field determining program sentence, tool Body is used for: judging whether critical field matches with each field in program statement;It is according to matching result determining program sentence No is particular statement.
Optionally, particular statement judgment module is specifically used for: obtaining preset unique identification in configuration file;According to unique Identify whether determining program sentence is particular statement.
Optionally, whether particular statement judgment module is when being particular statement according to unique identification determining program sentence, tool Body is used for: obtaining the unique identification of program statement;Judge whether preset unique identification matches with the unique identification of program statement; It whether is particular statement according to matching result determining program sentence.
Optionally, intermediate code generation module is specifically used for: obtaining preset intermediate code create-rule in configuration file; It is rule-based that program statement is converted into intermediate code.
Optionally, preset intermediate code create-rule includes preset field and corresponding action type, intermediate code Generation module it is rule-based program statement is converted into intermediate code when, be specifically used for: preset field spliced to program word The designated position of sentence is to generate intermediate code;Or preset field is deleted from the designated position of program statement to generate intermediate generation Code.
Optionally, preset field includes that can be realized the field of version control function.
Optionally, configuration file is stored in local or decentralized configuration management platform.
Exemplary media
After describing the method and apparatus of exemplary embodiment of the invention, next, the present invention mentions with reference to Fig. 4 A kind of exemplary media is supplied, which there are computer executable instructions, which can be used for making institute It states computer and executes method described in any one of corresponding exemplary embodiment of the invention of Fig. 1.
Exemplary computer device
After method, medium and the device for describing exemplary embodiment of the invention, next, being introduced with reference to Fig. 5 A kind of exemplary computer device 50 provided by the invention, the calculating equipment 50 include processing unit 501, memory 502, bus 503, external equipment 504, I/O interface 505 and network adapter 506, the memory 502 include random access memory (random access memory, RAM) 5021, cache memory 5022, read-only memory (Read-Only Memory, ROM) 5023 and at least memory cell array 5025 that constitutes of a piece of storage unit 5024.The wherein memory 502, the program or instruction executed for storage processing unit 501;The processing unit 501, for being stored according to the memory 502 Program or instruction, execute method described in any one of corresponding exemplary embodiment of the invention of Fig. 1;The I/O interface 505, for receiving or sending data under the control of the processing unit 501.
It should be noted that although be referred in the above detailed description program code conversion apparatus several units/modules or Subelement/module, but it is this division be only exemplary it is not enforceable.In fact, embodiment party according to the present invention The feature and function of formula, two or more above-described units/modules can embody in a units/modules.Conversely, The feature and function of an above-described units/modules can be to be embodied by multiple units/modules with further division.
In addition, although describing the operation of the method for the present invention in the accompanying drawings with particular order, this do not require that or Hint must execute these operations in this particular order, or have to carry out shown in whole operation be just able to achieve it is desired As a result.Additionally or alternatively, it is convenient to omit multiple steps are merged into a step and executed by certain steps, and/or by one Step is decomposed into execution of multiple steps.
Although detailed description of the preferred embodimentsthe spirit and principles of the present invention are described by reference to several, it should be appreciated that, this It is not limited to the specific embodiments disclosed for invention, does not also mean that the feature in these aspects cannot to the division of various aspects Combination is benefited to carry out, this to divide the convenience merely to statement.The present invention is directed to cover appended claims spirit and Included various modifications and equivalent arrangements in range.

Claims (10)

1. a kind of program code conversion method, comprising:
The source code of reading program sentence by sentence;
Judge whether the program statement currently read is particular statement;
If so, described program sentence is converted into intermediate code;
It explains and executes the intermediate code;
Described program sentence is executed if it is not, directly explaining.
It can be realized 2. the method for claim 1, wherein explaining and executing the intermediate code and explain the execution journey The different function of sequence sentence.
3. the method for claim 1, wherein described judge whether the program statement currently read is particular statement Step includes:
Obtain preset critical field in configuration file;
Judge whether described program sentence is particular statement according to the critical field.
4. method as claimed in claim 3, wherein judge whether described program sentence is specific language according to the critical field Sentence the step of include:
Judge whether the critical field matches with each field in described program sentence;
Judge whether described program sentence is particular statement according to matching result.
5. the method for claim 1, wherein the step of particular statement in the recognize program code includes:
Obtain preset unique identification in configuration file;
Judge whether described program sentence is particular statement according to the unique identification.
6. method as claimed in claim 5, wherein judge whether described program sentence is specific language according to the unique identification Sentence the step of include:
Obtain the unique identification of described program sentence;
Judge whether the preset unique identification matches with the unique identification of described program sentence;
Judge whether described program sentence is particular statement according to matching result.
7. the step of described program sentence is the method for claim 1, wherein converted into intermediate code includes:
Obtain preset intermediate code create-rule in configuration file;
Described program sentence is converted into the intermediate code based on the rule.
8. a kind of program code conversion apparatus, comprising:
Source code read module is configured as sentence by sentence the source code of reading program;
Particular statement judgment module, is configured as whether the program statement that judgement is currently read is particular statement;
Intermediate code generation module, is configured as if the determination result is YES, and described program sentence is converted into intermediate code;
It explains execution module, is configured as explaining executing the intermediate code;And
If judging result be it is no, directly explain execute described program sentence.
9. a kind of computer readable storage medium, computer program, feature are stored in the computer readable storage medium It is, computer program perform claim when being run by processor requires the described in any item program code conversion sides 1-7 Method.
10. a kind of calculating equipment, comprising: memory, processor and be stored on the memory and can be on the processor The computer program of operation, which is characterized in that perform claim requires 1-7 any when the processor runs the computer program Program code conversion method described in.
CN201811504924.XA 2018-12-10 2018-12-10 Program code conversion method, device, medium and computing equipment Active CN109726213B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811504924.XA CN109726213B (en) 2018-12-10 2018-12-10 Program code conversion method, device, medium and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811504924.XA CN109726213B (en) 2018-12-10 2018-12-10 Program code conversion method, device, medium and computing equipment

Publications (2)

Publication Number Publication Date
CN109726213A true CN109726213A (en) 2019-05-07
CN109726213B CN109726213B (en) 2021-11-19

Family

ID=66294789

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811504924.XA Active CN109726213B (en) 2018-12-10 2018-12-10 Program code conversion method, device, medium and computing equipment

Country Status (1)

Country Link
CN (1) CN109726213B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984536A (en) * 2020-08-17 2020-11-24 四川爱创科技有限公司 Equipment automation test system
WO2022057357A1 (en) * 2020-09-18 2022-03-24 华为云计算技术有限公司 Data query method and apparatus, and database system

Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010052113A1 (en) * 1998-03-09 2001-12-13 John Hearne Data processing system and development method
US6820266B1 (en) * 1998-02-27 2004-11-16 Oracle International Corporation Application code conversion architecture
US20080295082A1 (en) * 2007-05-25 2008-11-27 Matsushita Electric Industrial Co., Ltd. Program re-writing apparatus
US20090064091A1 (en) * 2005-06-27 2009-03-05 Albert Donald Tonkin Code transformation
US20090132995A1 (en) * 2000-04-04 2009-05-21 Jose Iborra Automatic software production system
CN102999370A (en) * 2011-09-16 2013-03-27 腾讯科技(深圳)有限公司 Method and system for executing script
CN103218294A (en) * 2013-04-16 2013-07-24 华为技术有限公司 Debugging method for embedded system, debugging conversion device and system
CN104346383A (en) * 2013-07-31 2015-02-11 上海云端广告有限公司 Data access control method and system
CN105975489A (en) * 2016-04-26 2016-09-28 中国电子科技网络信息安全有限公司 Metadata-based online SQL code completion method
CN106055334A (en) * 2016-06-01 2016-10-26 努比亚技术有限公司 Code management system and method
CN106469282A (en) * 2015-08-21 2017-03-01 阿里巴巴集团控股有限公司 data access authority control method and device
CN106843822A (en) * 2015-12-07 2017-06-13 阿里巴巴集团控股有限公司 One kind performs code generating method and equipment
CN107103007A (en) * 2016-02-23 2017-08-29 阿里巴巴集团控股有限公司 A kind of SQL code conversion method and device
CN107851003A (en) * 2015-04-02 2018-03-27 数据仓库投资有限公司 For improving the field specialization system and method for program feature
CN107861728A (en) * 2017-10-25 2018-03-30 深圳四方精创资讯股份有限公司 Method from traditional program language to modern procedures language conversion and its system for
CN108008940A (en) * 2017-12-29 2018-05-08 成都邦永科技有限公司 A kind of software customized platform of service management and its method for customizing
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device

Patent Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6820266B1 (en) * 1998-02-27 2004-11-16 Oracle International Corporation Application code conversion architecture
US20010052113A1 (en) * 1998-03-09 2001-12-13 John Hearne Data processing system and development method
US20090132995A1 (en) * 2000-04-04 2009-05-21 Jose Iborra Automatic software production system
US20090064091A1 (en) * 2005-06-27 2009-03-05 Albert Donald Tonkin Code transformation
US20080295082A1 (en) * 2007-05-25 2008-11-27 Matsushita Electric Industrial Co., Ltd. Program re-writing apparatus
CN102999370A (en) * 2011-09-16 2013-03-27 腾讯科技(深圳)有限公司 Method and system for executing script
CN103218294A (en) * 2013-04-16 2013-07-24 华为技术有限公司 Debugging method for embedded system, debugging conversion device and system
CN104346383A (en) * 2013-07-31 2015-02-11 上海云端广告有限公司 Data access control method and system
CN107851003A (en) * 2015-04-02 2018-03-27 数据仓库投资有限公司 For improving the field specialization system and method for program feature
CN106469282A (en) * 2015-08-21 2017-03-01 阿里巴巴集团控股有限公司 data access authority control method and device
CN106843822A (en) * 2015-12-07 2017-06-13 阿里巴巴集团控股有限公司 One kind performs code generating method and equipment
CN107103007A (en) * 2016-02-23 2017-08-29 阿里巴巴集团控股有限公司 A kind of SQL code conversion method and device
CN105975489A (en) * 2016-04-26 2016-09-28 中国电子科技网络信息安全有限公司 Metadata-based online SQL code completion method
CN106055334A (en) * 2016-06-01 2016-10-26 努比亚技术有限公司 Code management system and method
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN107861728A (en) * 2017-10-25 2018-03-30 深圳四方精创资讯股份有限公司 Method from traditional program language to modern procedures language conversion and its system for
CN108008940A (en) * 2017-12-29 2018-05-08 成都邦永科技有限公司 A kind of software customized platform of service management and its method for customizing

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李磊: "C编译器中间代码生成及其后端的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984536A (en) * 2020-08-17 2020-11-24 四川爱创科技有限公司 Equipment automation test system
WO2022057357A1 (en) * 2020-09-18 2022-03-24 华为云计算技术有限公司 Data query method and apparatus, and database system

Also Published As

Publication number Publication date
CN109726213B (en) 2021-11-19

Similar Documents

Publication Publication Date Title
CN109739934B (en) Difference set account checking method, medium, computer equipment and system
CN107092656B (en) A kind of tree data processing method and system
US8037039B2 (en) Runtime class database operation
CN105793818A (en) Source code translation
CN107016071B (en) A kind of method and system using simple path characteristic optimization tree data
CN103164249A (en) Extension mechanism for scripting language compiler
CN105718593A (en) Database query optimization method and system
CN111324619B (en) Object updating method, device, equipment and storage medium in micro-service system
CN113157723B (en) SQL access method for Hyperridge Fabric
CN107943945A (en) Isomery operator management method in a kind of big data analysis development platform
KR101877828B1 (en) User interface integrated platform system based on artificial intelligence
CN107193917A (en) Whole station CONFIG.SYS lossless data update method based on IID
KR102141784B1 (en) System for managing ontology data of power grid
CN106484815B (en) A kind of automatic identification optimization method based on mass data class SQL retrieval scene
CN109726213A (en) A kind of program code conversion method, device, medium and calculate equipment
CN109582670B (en) Recommendation method of vehicle maintenance scheme and related equipment
CN108763323B (en) Meteorological grid point file application method based on resource set and big data technology
CN113486418B (en) BIM model cloud coding method and system
CN112395339B (en) Intersystem data admission verification method, device, computer equipment and storage medium
CN108459842A (en) A kind of model configuration method, device and electronic equipment
KR102045367B1 (en) System and method for feed verification task automation
CN107665181A (en) A kind of method and system of centralized configuration equipment
CN109298857A (en) Method for building up, medium, device and the calculating equipment of DSL statement model
CN111737529B (en) Multi-source heterogeneous data acquisition method
CN114238390A (en) Data warehouse optimization 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
TA01 Transfer of patent application right

Effective date of registration: 20191107

Address after: 310012 G building, 10 floor, A building, Paradise Software Park, 3 West Road, Hangzhou, Xihu District, Zhejiang

Applicant after: Alibaba (China) Co.,Ltd.

Address before: Hangzhou City, Zhejiang province 310051 Binjiang District River Street No. 1786 Jianghan Road Longsheng Building Room 803

Applicant before: NETEASE KOALA (HANGZHOU) TECH CO.,LTD.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20221207

Address after: Room 101, Warehouse 1, No. 88, Jingbin Avenue, Jingbin Industrial Park, Wuqing District, Tianjin 301739

Patentee after: Alibaba Huabei Technology Co.,Ltd.

Address before: 310012 G Block, 10th Building, Building A, Paradise Software Park, No. 3 Xidoumen Road, Xihu District, Hangzhou City, Zhejiang Province

Patentee before: Alibaba (China) Co.,Ltd.

TR01 Transfer of patent right