CN111191106A - DSL construction method, system, electronic device and medium - Google Patents

DSL construction method, system, electronic device and medium Download PDF

Info

Publication number
CN111191106A
CN111191106A CN201911395685.3A CN201911395685A CN111191106A CN 111191106 A CN111191106 A CN 111191106A CN 201911395685 A CN201911395685 A CN 201911395685A CN 111191106 A CN111191106 A CN 111191106A
Authority
CN
China
Prior art keywords
dsl
target
query
inverse
law
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
CN201911395685.3A
Other languages
Chinese (zh)
Other versions
CN111191106B (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.)
Shanghai Ctrip Business Co Ltd
Original Assignee
Shanghai Ctrip Business 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 Shanghai Ctrip Business Co Ltd filed Critical Shanghai Ctrip Business Co Ltd
Priority to CN201911395685.3A priority Critical patent/CN111191106B/en
Publication of CN111191106A publication Critical patent/CN111191106A/en
Application granted granted Critical
Publication of CN111191106B publication Critical patent/CN111191106B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • G06F16/9532Query formulation

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Complex Calculations (AREA)
  • Emergency Protection Circuit Devices (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a construction method, a construction system, electronic equipment and a medium of a DSL, wherein the construction method of the DSL comprises the following steps: converting the target arithmetic expression into a target Token set; traversing the target Token set to convert into an inverse wave form; the inverse wave form is traversed to build an operand stack, and the first operand is popped from the operand stack as the destination DSL. The invention reduces the complexity of DSL construction.

Description

DSL construction method, system, electronic device and medium
Technical Field
The present invention belongs to the technical field of DSL construction, and in particular, to a method, a system, an electronic device, and a medium for constructing a DSL.
Background
An Elasticsearch (a search server) as one of the open source distributed search engines has cluster deployment of different sizes in internet enterprises of various sizes, so that the Elasticsearch has very active communities and the use and mining of the Elasticsearch are not stopped at all. The Elasticsearch has a special Query DSL (Query expression). Due to the essential difference between the Elasticissearch and the traditional relational database, the Elasticissearch-SQL (a database) has limited supported functions, can only make simple logic queries and does not support join (a data type) types, and is an X-Pack (plug-in) plug-in, so that the complexity of deployment is increased.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a method, a system, an electronic device and a medium for constructing a DSL, in order to overcome the defect of high complexity of DSL construction in the prior art.
The invention solves the technical problems through the following technical scheme:
the invention provides a DSL construction method, which comprises the following steps:
converting the target arithmetic expression into a target Token (legal element) set;
traversing the target Token set to convert into an inverse wave form;
the inverse wave form is traversed to build an operand stack, and the first operand is popped from the operand stack as the destination DSL.
Preferably, the step of traversing the target Token set to convert into inverse wave form comprises:
identifying different types of target tokens in the target Token set, and packaging the target tokens into Function, Parameter and Operator objects.
Preferably, the step of traversing the inverse wave form to construct an operand stack comprises:
judging whether the query is a sub-query, if so, converting the inverse wavelet into a form of a sum of min terms according to a distribution law, a combination law, an exchange law and an inversion law of a logic expression, performing exchange sequencing on each min term according to parent-child document attributes, and constructing a sub-query DSL to generate a target DSL; if not, a target DSL is constructed for each Operator object.
Preferably, the target DSL is an Elasticsearch Query DSL.
The invention also provides a DSL construction system, which comprises a lexical analyzer, an inverse wavelet type converter and a grammar builder;
the lexical analyzer is used for converting the target arithmetic expression into a target Token set;
the inverse wave blue converter is used for traversing the target Token set to convert the target Token set into an inverse wave blue;
the syntax builder is for traversing the inverse wave form to build an operand stack, and for popping a first operand from the operand stack as the target DSL.
Preferably, the inverse wavelet transformer is further configured to identify different types of target tokens in the target Token set, and package the target tokens into Function, Parameter, and Operator objects.
Preferably, the syntax builder is further configured to determine whether the query is a sub-query, and if the query is a sub-query, convert the inverse wavelet into a form of a sum of minterms according to a distribution law, a combination law, an exchange law, and an inversion law of the logic expression, exchange-sort each minterm according to parent-child document attributes, and build a sub-query DSL to generate a target DSL; if not, a target DSL is constructed for each Operator object.
Preferably, the target DSL is an Elasticsearch Query DSL.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the DSL construction method of the invention.
The present invention also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the DSL construction method of the present invention.
The positive progress effects of the invention are as follows: the invention reduces the complexity of DSL construction.
Drawings
Fig. 1 is a flowchart of a DSL construction method according to embodiment 1 of the present invention.
Fig. 2 is a schematic structural diagram of a DSL construction system according to embodiment 1 of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to embodiment 3 of the present invention.
Detailed Description
The invention is further illustrated by the following examples, which are not intended to limit the scope of the invention.
Example 1
The present embodiment provides a method for constructing a DSL. Referring to fig. 1, the DSL construction method includes the steps of:
and step S101, converting the target arithmetic expression into a target Token set.
Step S102, traversing the target Token set to convert the target Token set into an inverse wave form.
Step S103, traversing the inverse wave form to construct an operand stack, and popping out a first operand from the operand stack as a target DSL.
In step S101, the arithmetic logic expression (generally, a character string) is parsed and divided into a set of tokens.
In step S102, different types of target tokens in the target Token set are identified, and the target tokens are packaged into Function, Parameter, and Operator objects. During which the Function is computed by the Function corrector as a dynamic Parameter. Through inverse wavelet transform, the priority relation in the arithmetic logic expression is removed, and the construction of the DSL is convenient.
In step S103, determining whether the query is a sub-query, if the query is a sub-query, converting the inverse wavelet into a form of a sum of minterms according to a distribution law, a combination law, an exchange law and an inversion law of the logic expression, performing exchange sorting on each minterm according to parent-child document attributes, and constructing a sub-query DSL to generate a target DSL; if not, a target DSL is constructed for each Operator object.
As an alternative embodiment, the target DSL is an Elasticsearch Query DSL.
The construction method of the DSL of the present embodiment simplifies the construction of the elastic search Query DSL, and in most cases only needs to be given, for example: | A The arithmetic logic expression of (field1 ═ x | | | field2 ═ y) & & field3> z can complete the construction of the DSL, thereby avoiding developers from hard coding to construct the DSL, reducing the development amount and improving the development efficiency. On the other hand, non-technical personnel such as service operation can conveniently use the arithmetic logic expression to inquire the required data, technical personnel such as development, operation and maintenance are avoided, and the working efficiency is improved.
Example 2
The present embodiment provides a DSL construction system. Referring to fig. 2, the DSL construction system includes a lexical analyzer (Lexer)201, a reverse wave and Parser (Reserve polar) 202, and a syntax Builder (Builder) 203.
The lexical analyzer 201 is used to convert the target arithmetic expression into a target Token set. The inverse wavelet transformer 202 is used to traverse the target Token set to transform into an inverse wavelet. The syntax builder 203 is used to traverse the inverse wave form to build the operand stack and to pop the first operand from the operand stack as the target DSL.
In specific implementation, the lexical analyzer 201 analyzes an arithmetic logic expression (generally, a character string), and divides the arithmetic logic expression into a set of tokens.
The inverse wavelet transformer 202 identifies different types of target tokens in the target Token set, and packages the target tokens into Function, Parameter, and Operator objects. During which the Function is computed by the Function corrector as a dynamic Parameter. Through inverse wavelet transform, the priority relation in the arithmetic logic expression is removed, and the construction of the DSL is convenient.
The grammar builder 203 judges whether the query is a sub-query, if the query is the sub-query, the inverse wave blue is converted into a form of min term sum according to the distribution law, the combination law, the exchange law and the inversion law of the logic expression, each min term is subjected to exchange sequencing according to the attributes of the parent and child documents, and a sub-query DSL is built to generate a target DSL; if not, a target DSL is constructed for each Operator object.
As an alternative embodiment, the target DSL is an Elasticsearch Query DSL.
The construction system of the DSL of the present embodiment simplifies the construction of the ElasticSearch Query DSL, and in most cases only needs to give, for example: | A The arithmetic logic expression of (field1 ═ x | | | field2 ═ y) & & field3> z can complete the construction of the DSL, thereby avoiding developers from hard coding to construct the DSL, reducing the development amount and improving the development efficiency. On the other hand, non-technical personnel such as service operation can conveniently use the arithmetic logic expression to inquire the required data, technical personnel such as development, operation and maintenance are avoided, and the working efficiency is improved.
Example 3
Fig. 3 is a schematic structural diagram of an electronic device provided in this embodiment. The electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the DSL construction method of embodiment 1 when executing the program. The electronic device 30 shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
The electronic device 30 may be embodied in the form of a general purpose computing device, which may be, for example, a server device. The components of the electronic device 30 may include, but are not limited to: the at least one processor 31, the at least one memory 32, and a bus 33 connecting the various system components (including the memory 32 and the processor 31).
The bus 33 includes a data bus, an address bus, and a control bus.
The memory 32 may include volatile memory, such as Random Access Memory (RAM)321 and/or cache memory 322, and may further include Read Only Memory (ROM) 323.
Memory 32 may also include a program/utility 325 having a set (at least one) of program modules 324, such program modules 324 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
The processor 31 executes various functional applications and data processing, such as a DSL construction method according to embodiment 1 of the present invention, by executing the computer program stored in the memory 32.
The electronic device 30 may also communicate with one or more external devices 34 (e.g., keyboard, pointing device, etc.). Such communication may be through input/output (I/O) interfaces 35. Also, model-generating device 30 may also communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via network adapter 36. As shown, network adapter 36 communicates with the other modules of model-generating device 30 via bus 33. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the model-generating device 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
It should be noted that although in the above detailed description several units/modules or sub-units/modules of the electronic device are mentioned, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more of the units/modules described above may be embodied in one unit/module according to embodiments of the invention. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
Example 4
The present embodiment provides a computer-readable storage medium on which a computer program is stored, which when executed by a processor, implements the steps of the DSL construction method of embodiment 1.
More specific examples, among others, that the readable storage medium may employ may include, but are not limited to: a portable disk, a hard disk, random access memory, read only memory, erasable programmable read only memory, optical storage device, magnetic storage device, or any suitable combination of the foregoing.
In a possible implementation, the invention can also be implemented in the form of a program product comprising program code for causing a terminal device to perform the steps of implementing the DSL construction method of embodiment 1 when said program product is run on said terminal device.
Where program code for carrying out the invention is written in any combination of one or more programming languages, the program code may be executed entirely on the user device, partly on the user device, as a stand-alone software package, partly on the user device and partly on a remote device or entirely on the remote device.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and that the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the spirit and scope of the invention, and these changes and modifications are within the scope of the invention.

Claims (10)

1. A method of constructing a DSL, comprising the steps of:
converting the target arithmetic expression into a target Token set;
traversing the target Token set to convert to an inverse wave form;
traversing the inverse wave form to construct an operand stack, and popping a first operand from the operand stack as a target DSL.
2. The DSL construction method of claim 1 wherein said step of traversing said target Token set for conversion to inverse landform comprises:
identifying different types of target tokens in the target Token set, and packaging the target tokens into Function, Parameter and Operator objects.
3. The DSL construction method of claim 2 wherein said step of traversing said inverse waveland to construct an operand stack comprises:
judging whether the query is a sub-query, if so, converting the inverse wavelet into a form of a sum of min terms according to a distribution law, a combination law, an exchange law and an inversion law of a logic expression, performing exchange sequencing on each min term according to parent-child document attributes, and constructing a sub-query DSL to generate the target DSL; if not, the target DSL is constructed for each Operator object.
4. The DSL construction method of claim 1 wherein the target DSL is an ElasticsearchQuery DSL.
5. A DSL construction system is characterized by comprising a lexical analyzer, an inverse wavelet transform device and a grammar builder;
the lexical analyzer is used for converting the target arithmetic expression into a target Token set;
the inverse wave blue converter is used for traversing the target Token set to convert into an inverse wave blue;
the syntax builder is for traversing the inverse wave form to build an operand stack, and for popping a first operand from the operand stack as a target DSL.
6. The DSL building system of claim 5, wherein the inverse wavelet transformer is further configured to identify different types of target Tokens in the set of target Tokens, and to package the target Tokens as Function, Parameter, Operator objects.
7. The DSL building system of claim 6, wherein the syntax builder is further configured to determine whether the query is a sub-query, and if the query is a sub-query, convert the inverse wavelet to a form of a sum of minterms according to a distribution law, a combination law, a crossover law, and an inversion law of logic expressions, crossover-sort each minterm according to parent-child document attributes, and build a sub-query DSL to generate the target DSL; if not, the target DSL is constructed for each Operator object.
8. The DSL building system of claim 5, wherein the target DSL is an ElasticisSearchQuery DSL.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the computer program, implements the DSL construction method of any of claims 1 to 4.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of constructing a DSL of any one of claims 1 to 4.
CN201911395685.3A 2019-12-30 2019-12-30 DSL construction method, system, electronic device and medium Active CN111191106B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911395685.3A CN111191106B (en) 2019-12-30 2019-12-30 DSL construction method, system, electronic device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911395685.3A CN111191106B (en) 2019-12-30 2019-12-30 DSL construction method, system, electronic device and medium

Publications (2)

Publication Number Publication Date
CN111191106A true CN111191106A (en) 2020-05-22
CN111191106B CN111191106B (en) 2023-05-12

Family

ID=70711069

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911395685.3A Active CN111191106B (en) 2019-12-30 2019-12-30 DSL construction method, system, electronic device and medium

Country Status (1)

Country Link
CN (1) CN111191106B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767004A (en) * 2020-06-30 2020-10-13 电子科技大学 Digital oscilloscope mathematical operation processing method based on inverse Polish algorithm

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6314564B1 (en) * 1997-11-17 2001-11-06 Agere Systems Guardian Corp. Method for resolving arbitrarily complex expressions at link-time
CN104915194A (en) * 2015-05-11 2015-09-16 南京国电南自美卓控制系统有限公司 Power failure data analysis formula editor based on arithmetic reverse polish algorithm
CN106980619A (en) * 2016-01-18 2017-07-25 北京国双科技有限公司 Data query method and device
CN108491207A (en) * 2018-03-02 2018-09-04 平安科技(深圳)有限公司 Expression processing method, apparatus, equipment and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6314564B1 (en) * 1997-11-17 2001-11-06 Agere Systems Guardian Corp. Method for resolving arbitrarily complex expressions at link-time
CN104915194A (en) * 2015-05-11 2015-09-16 南京国电南自美卓控制系统有限公司 Power failure data analysis formula editor based on arithmetic reverse polish algorithm
CN106980619A (en) * 2016-01-18 2017-07-25 北京国双科技有限公司 Data query method and device
CN108491207A (en) * 2018-03-02 2018-09-04 平安科技(深圳)有限公司 Expression processing method, apparatus, equipment and computer readable storage medium

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
SPRINGER,BERLIN,HEIDELBERG: "Deductive program development:Evaluation in reverse Polish notation as an example" *
周丰: "逆波兰表达式及其算法实现" *
易昌中;: "一个基于JAVA语言的编译器设计" *
李广强: "基于转换的程序分析技术的研究与应用" *
沈祖梁: "FORTH入门(上)" *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767004A (en) * 2020-06-30 2020-10-13 电子科技大学 Digital oscilloscope mathematical operation processing method based on inverse Polish algorithm
CN111767004B (en) * 2020-06-30 2022-02-11 电子科技大学 Digital oscilloscope mathematical operation processing method based on inverse Polish algorithm

Also Published As

Publication number Publication date
CN111191106B (en) 2023-05-12

Similar Documents

Publication Publication Date Title
US9053210B2 (en) Graph query processing using plurality of engines
US9122540B2 (en) Transformation of computer programs and eliminating errors
US8239847B2 (en) General distributed reduction for data parallel computing
US9684493B2 (en) R-language integration with a declarative machine learning language
CN112579626A (en) Construction method and device of multi-source heterogeneous SQL query engine
JP5791149B2 (en) Computer-implemented method, computer program, and data processing system for database query optimization
US20230028947A1 (en) Cost-aware integration process modeling in multi-cloud computing environment
Ono et al. Using Coq in specification and program extraction of Hadoop MapReduce applications
CN110780879A (en) Decision execution method, device, equipment and medium based on intelligent compiling technology
JP2009537906A (en) System and method for storing and retrieving data
CN115809063B (en) Storage process compiling method, system, electronic equipment and storage medium
US10268461B2 (en) Global data flow optimization for machine learning programs
CN112988163A (en) Intelligent programming language adaptation method and device, electronic equipment and medium
CN112347126A (en) Big data processing method, device, equipment and medium
CN111191106A (en) DSL construction method, system, electronic device and medium
Kostenetskii et al. Simulation of hierarchical multiprocessor database systems
CN112114817B (en) COBOL language-based data dictionary field information acquisition method and device
US10416971B2 (en) Method of creating the balanced parse tree having optimized height
US20090300038A1 (en) Methods and Apparatus for Reuse Optimization of a Data Storage Process Using an Ordered Structure
US8499292B2 (en) Virtual execution environment for streaming languages
US20220318314A1 (en) System and method of performing a query processing in a database system using distributed in-memory technique
CN116010461A (en) Data blood relationship analysis method and device, storage medium and electronic equipment
CN115809294A (en) Rapid ETL method based on Spark SQL temporary view
CN117251472B (en) Cross-source data processing method, device, equipment and storage medium
CN108052522B (en) Method and system for dynamically optimizing OLAP pre-calculation model

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
GR01 Patent grant
GR01 Patent grant