Query structure automatic conversion method and apparatus, electronic device, and storage medium
By automatically extracting and parsing the valid information of the SPARQL query code, a data model suitable for the source database is generated, which solves the problems of high development costs and low query efficiency in the existing technology, and realizes automatic conversion of the query structure and reduction of development costs.
Patent Information
- Application Number
- PCT/CN2023/116596
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-09-01
- Publication Date
- 2025-03-06
AI Technical Summary
In the field of industrial automation, the prior art requires developers to manually write SPARQL query code to query the source data of industrial equipment, resulting in high development costs, time-consuming and inefficient query.
By obtaining the code text of the SPARQL query program, extracting and parsing its valid information, and generating a data model suitable for the source database, thereby realizing automatic conversion of the query structure.
This method can automatically convert query structures, reduce development costs, simplify development processes, improve query efficiency, and reduce duplicate code analysis.
Smart Images

Figure CN2023116596_06032025_PF_FP_ABST
Abstract
Description
Query structure automatic conversion method, device, electronic device and storage medium Technical Field
[0001] The present application relates to the field of industrial automation technology, and in particular to a method, device, electronic device and storage medium for automatic conversion of query structures. Background Art
[0002] In the field of industrial automation, in application scenarios such as automated operation of industrial equipment such as robotic arms and real-time status monitoring, it is necessary to query the source database in advance for a large amount of source data generated during the automated operation of industrial equipment.
[0003] Currently, source data queries are primarily implemented through SPARQL queries. Developers need to pre-write SPARQL query code, which often contains a large number of query statements. Source data queries are only possible by repeatedly analyzing the query statements in the SPARQL query code to extract useful information and then generating a data model suitable for the source database based on the extracted useful information. This not only requires manual and repetitive development, which is time-consuming and labor-intensive, but also places high demands on developers, requiring them to be familiar with the relationship between relevant business content and data models, resulting in higher overall development costs. Furthermore, frequent queries require repeated analysis of the SPARQL query code, which seriously impacts source data query efficiency.
[0004] Therefore, a conversion tool is needed to automatically convert SPARQL query code into a query structure suitable for the source database, thereby reducing development costs.
[0005] Summary of the Invention
[0006] In view of this, the query structure automatic conversion method, device, electronic device and storage medium provided in the present application can realize the automatic conversion of query structure, thereby reducing development costs.
[0007] According to a first aspect of an embodiment of the present application, a method for automatically converting a query structure is provided, comprising:
[0008] Obtaining a code text of a first query program, wherein the first query program is used to query source data of a target object to generate feature data of the target object;
[0009] extracting valid information of the first query program from the code text of the first query program, wherein the valid information of the first query program at least includes data structure information of the characteristic data of the target object;
[0010] Parse the data structure information of the characteristic data to generate a data model representing the first business, the data model includes one data model or two or more different data models associated with each other, each of the data models is used to query the source data of the target object to generate characteristic information of the target object, and the characteristic information of the target object is used to form the characteristic data of the target object.
[0011] According to a second aspect of an embodiment of the present application, there is provided a query structure automatic conversion device, comprising:
[0012] an acquisition unit, configured to acquire a code text of a first query program, wherein the first query program is configured to query source data of a target object to generate feature data of the target object;
[0013] an extraction unit, configured to extract valid information of the first query program from a code text of the first query program, wherein the valid information of the first query program at least includes data structure information of the characteristic data of the target object;
[0014] A parsing unit is used to parse the data structure information of the characteristic data to generate a data model representing the first business, wherein the data model includes one data model or two or more different data models associated with each other, each of the data models is used to query the source data of the target object to generate characteristic information of the target object, and the characteristic information of the target object is used to form the characteristic data of the target object.
[0015] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor, a memory, a communication interface and a bus, wherein the processor, the memory and the communication interface communicate with each other through the bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the query structure automatic conversion method described in the first aspect above.
[0016] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer instructions are stored. When the computer instructions are executed by a processor, the processor executes the query structure automatic conversion method as described in the second aspect above.
[0017] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, which is tangibly stored on a computer-readable medium and includes computer-executable instructions, which, when executed, enable at least one processor to perform the query structure automatic conversion method described in the first aspect above.
[0018] As can be seen from the above technical solution, by obtaining the code text of the first query program, extracting the data structure information in the first query program from the code text of the first query program, parsing the data structure information to generate a data model representing the first business, the data model can include one data model or two or more different data models associated with each other, each data model is used to query the source data of the target object to generate feature information of the target object, and the feature information of the target object is used to form the feature data of the target object. Therefore, the embodiment of the present application can automatically convert query programs such as SPARQL queries into data models representing the business supported by the source database, which can simplify the development process and reduce duplicate code and development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] FIG1 is a flowchart of a method for automatically converting a query structure according to an embodiment of the present invention;
[0020] FIG2 is a schematic diagram of the code text of the first query program according to an embodiment of the present application;
[0021] FIG3 is a schematic diagram of the structure of a first business model according to an embodiment of the present application;
[0022] FIG4 is a schematic diagram of a data model according to an embodiment of the present application;
[0023] FIG5 is a flow chart of the automatic conversion process of a data model according to an embodiment of the present application;
[0024] FIG6 is a schematic diagram of a query structure automatic conversion device according to an embodiment of the present application;
[0025] FIG7 is a schematic diagram of an electronic device according to an embodiment of the present application.
[0026] List of reference numerals: 101: Obtain code text of a first query program 102: Extract valid information of the first query program from the code text of the first query program 103: Parse data structure information of feature data to generate a data model representing a first business 500: Automatic conversion process of data model 501: Obtain code text of a SPARQL query structure 502: Filter code text of a SPARQL query structure 503: Extract valid information of the SPARQL query structure from the filtered code text of the SPARQL query structure 504: Classify valid information of the SPARQL query structure to determine the field structure of each data model corresponding to the first business and the association relationship between data models 505: Generate a data model representing a business model 100: Automatic conversion method for query structure 200: SPARQL query structure 300: Data model of first business 301: Data model 3011: Field 600: Automatic conversion device for query structure 601: Acquisition unit 602: Extraction unit 603: Parsing unit 700: Electronic device 702: Processor 704: Communication interface 706: Memory 708: Bus 710: Program DETAILED DESCRIPTION
[0027] As mentioned earlier, in applications such as automated operation and real-time status monitoring of industrial equipment like robotic arms, it's necessary to query source databases for large amounts of source data generated during automated operation. Using SPARQL queries to query source databases for this data requires developers to write SPARQL query code in advance and repeatedly analyze the numerous query statements in the SPARQL query code during the query process. This results in high development costs, is time-consuming, and inefficient.
[0028] In an embodiment of the present application, by obtaining the code text of the first query program, extracting the data structure information in the first query program from the code text of the first query program, parsing the data structure information to generate a data model representing the first business, the data model may include one data model or two or more different data models associated with each other, each data model is used to query the source data of the target object to generate feature information of the target object, and the feature information of the target object is used to form the feature data of the target object. It can be seen that the embodiment of the present application can automatically convert query programs such as SPARQL queries into data models supported by the source database, and there is no need to repeatedly perform statement analysis of the query program during the query process, thereby effectively reducing development costs.
[0029] The following describes in detail the query structure automatic conversion method, device, electronic device and storage medium provided by the embodiments of the present application in conjunction with the accompanying drawings.
[0030] Automatic query structure conversion method
[0031] FIG1 is a flow chart of a method for automatically converting a query structure according to an embodiment of the present invention. As shown in FIG1 , the method 100 for automatically converting a query structure includes the following steps:
[0032] Step 101: Obtain code text of a first query program, where the first query program is used to query source data of a target object to generate feature data of the target object;
[0033] The first query program can be any query language structure. In one example, the first query program can be a SPARQL query structure. FIG2 shows a schematic diagram of the code text layer of the SPARQL query structure. Referring to FIG2 , the SPARQL query structure 200 can include a SPARQL query and a SPARQL query response.
[0034] The target object may be industrial equipment or a component of industrial equipment. For example, the target object may be a robotic arm, and the characteristic data of the target object may be data characterizing temperature characteristics, position characteristics, and / or other characteristics of the robotic arm's joints. In one example, the characteristic data of the target object may include multiple pieces of characteristic information. Taking the position characteristics of the robotic arm's joints as an example, the characteristic information may be the position information of a particular joint of the robotic arm.
[0035] Source data can include, but is not limited to, all raw data generated by industrial equipment during the manufacturing process. For example, using a robotic arm as an example, source data can include sensor signal data collected by all sensors installed on the robotic arm within a certain period of time.
[0036] The source data may be stored in a database. In one example, different types of source data may be stored in the same database or in different databases. The database may be, but is not limited to, a relational database.
[0037] Step 102: extracting valid information of the first query program from the code text of the first query program, where the valid information of the first query program at least includes data structure information of characteristic data of the target object;
[0038] The data structure information of the feature data of the target object may include sub-data structure information corresponding to each piece of feature information in the feature data, and each piece of sub-data structure information may indicate the data structure of the corresponding feature information.
[0039] To improve efficiency, valid information extraction can be performed after filtering. Before extracting the valid information of the first query program from the code text of the first query program, the code text of the first query program can be filtered to remove statements in the code text of the first query program that are not relevant to the valid information. Statements that are not relevant to the valid information may include, but are not limited to, the version, name, or other similar statements of the first query program.
[0040] Various applicable methods can be used to extract valid information. In one possible implementation, XML parsing technology can be used to extract valid information from the first query program. For example, the code text of the first query program can be filtered, and then an XML tool can be used to perform XML parsing on the filtered code text to obtain valid information from the first query program.
[0041] In addition to the aforementioned data structure information, the first query program's valid information may also include other information. In one example, the first query program's valid information may also include business attribute information for each piece of feature information in the feature data, so that the business attribute information can be used to query the corresponding business rules and use the business rules to determine the data structure of the data model.
[0042] Step 103: Parse the data structure information of the characteristic data to generate a data model representing the first service.
[0043] In one example, the data model representing the first business may be a relational data model. For example, the data model representing the first business may be a data model using SPARQL.
[0044] Figure 3 shows a schematic diagram of the structure of a data model 300 corresponding to a first service in one embodiment of the present application. As shown in Figure 3 , the data model 300 corresponding to the first service includes one data model 301 or two or more different data models 301 associated with each other. Each data model 301 can be used to query the source data of a target object to generate feature information of the target object, thereby forming feature data of the target object using the feature information of the target object.
[0045] In one possible implementation method, the field structure of the data model and the association relationship between data models can be determined based on the data structure information of the feature data, and then a data model statement can be generated based on the field structure of the data model, and the node statement and edge statement of the first business can be generated based on the association relationship between the data models, wherein the data model statement is used to create the data model, the node statement is used to define the data model corresponding to each node in the first business, and the edge statement is used to define the relationship between each node in the first business.
[0046] In one possible implementation method, the data structure information of the feature data can be classified according to the business attribute information of the feature information in the feature data to determine the sub-data structure information corresponding to each data model, and then the sub-data structure information corresponding to each data model can be parsed separately to determine the field structure of the data model and the relationship between the data models.
[0047] The data model 301 may include one or more fields, and the fields of the data model and their ordering may constitute the field structure of the data model. FIG4 shows a schematic diagram of the structure of the data model 301 in an embodiment of the present application. Referring to FIG4 , the data model 301 may include a plurality of different fields 3011, and each field 3011 is used to indicate a business attribute in the feature information. For example, the position feature information of a joint of a robotic arm may be the three-dimensional coordinate system coordinates of the joint, and the corresponding data model may include three fields, which may respectively indicate the three coordinates of the position feature information of the robotic arm joint.
[0048] FIG5 shows a schematic diagram of the automatic conversion process of a data model in one embodiment of the present application. Referring to FIG5 , the automatic conversion process 500 may include the following steps:
[0049] Step 501: Obtain code text of a SPARQL query structure, where the SPARQL query structure is used to query sensor signal data of a robotic arm to generate joint position feature data of the robotic arm;
[0050] Step 502: Filter the code text of the SPARQL query structure to remove invalid statements therein;
[0051] Step 503: extract valid information of the SPARQL query structure from the code text of the filtered SPARQL query structure;
[0052] Step 504: Classify the valid information of the SPARQL query structure to determine the field structure of each data model in the data model corresponding to the first business and the association relationship between the data models;
[0053] Step 505: Generate a data model representing the first service, where the data model includes a data model statement, a node statement, and an edge statement.
[0054] In an embodiment of the present application, by obtaining the code text of the first query program, extracting the data structure information in the first query program from the code text of the first query program, parsing the data structure information to generate a data model representing the first business, the data model of the first business can include one data model or two or more different data models associated with each other, each data model is used to query the source data of the target object to generate feature information of the target object, and the feature information of the target object is used to form the feature data of the target object. It can be seen that the embodiment of the present application can automatically convert query programs such as SPARQL queries into data models supported by the source database, and there is no need to repeatedly perform statement analysis of the query program during the query process, thereby effectively reducing development costs.
[0055] Query structure automatic conversion device
[0056] Corresponding to the above method embodiment, FIG6 shows a schematic diagram of a query structure automatic conversion device according to an embodiment of the present application. As shown in FIG6 , the query structure automatic conversion device 600 includes:
[0057] An acquisition unit 601 is configured to acquire a code text of a first query program, where the first query program is configured to query source data of a target object to generate feature data of the target object;
[0058] An extraction unit 602 is configured to extract valid information of the first query program from the code text of the first query program, where the valid information of the first query program includes at least data structure information of feature data of the target object;
[0059] The parsing unit 603 is used to parse the data structure information of the feature data to generate a data model representing the first business. The data model of the first business includes one data model or two or more different data models associated with each other. Each data model is used to query the source data of the target object to generate feature information of the target object. The feature information of the target object is used to form the feature data of the target object.
[0060] In an embodiment of the present application, the acquisition unit 601 may be used to execute step 101 in the aforementioned method embodiment, the extraction unit 602 may be used to execute step 102 in the aforementioned method embodiment, and the parsing unit 603 may be used to execute step 103 in the aforementioned method embodiment.
[0061] It should be noted that the information interaction, execution process, etc. between the various units in the above-mentioned query structure automatic conversion device are based on the same concept as the above-mentioned query structure automatic conversion method embodiment. The specific content can be found in the description of the above-mentioned query structure automatic conversion method embodiment and will not be repeated here.
[0062] electronic devices
[0063] FIG7 is a schematic diagram of an electronic device provided in Example 4 of the present application. The specific embodiments of the present application do not limit the specific implementation of the electronic device. Referring to FIG7 , the electronic device 700 provided in the embodiment of the present application includes: a processor 702, a communications interface 704, a memory 706, and a bus 708. Among them:
[0064] The processor 702 , the communication interface 704 , and the memory 706 communicate with each other via a bus 708 .
[0065] The communication interface 704 is used to communicate with other electronic devices or servers.
[0066] The processor 702 is configured to execute the program 710 , and specifically to execute the relevant steps in the above-mentioned query structure automatic conversion method embodiment.
[0067] Specifically, the program 710 may include program codes, which include computer operation instructions.
[0068] Processor 702 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0069] The memory 706 is used to store the program 710. The memory 706 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0070] The program 710 may be specifically configured to enable the processor 702 to execute the query structure automatic conversion method in any of the aforementioned embodiments.
[0071] The specific implementation of each step in program 710 can be found in the corresponding descriptions of the corresponding steps and units in the above-mentioned query structure automatic conversion method embodiment, and will not be repeated here. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding process descriptions in the above-mentioned method embodiment, and will not be repeated here.
[0072] Through the electronic device of this embodiment, by obtaining the code text of the first query program, extracting the data structure information in the first query program from the code text of the first query program, parsing the data structure information to generate a data model representing the first business, the data model of the first business can include one data model or two or more different data models associated with each other, each data model is used to query the source data of the target object to generate feature information of the target object, and the feature information of the target object is used to form the feature data of the target object. It can be seen that the embodiment of the present application can automatically convert query programs such as SPARQL queries into data models supported by the source database, and there is no need to repeatedly perform statement analysis of the query program during the query process, thereby effectively reducing development costs.
[0073] Computer-readable storage medium
[0074] This application also provides a computer-readable storage medium storing instructions for causing a machine to execute the method for automatically converting query structures as described herein. Specifically, a system or device equipped with a storage medium can be provided, wherein the storage medium stores software program code that implements the functions of any of the above-described embodiments, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.
[0075] In this case, the program code read from the storage medium itself can realize the function of any one of the above embodiments, so the program code and the storage medium storing the program code constitute part of this application.
[0076] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0077] In addition, it should be clear that the functions of any of the above embodiments can be achieved not only by executing the program code read by the computer, but also by enabling the operating system operating on the computer to complete part or all of the actual operations based on the instructions of the program code.
[0078] In addition, it can be understood that the program code read from the storage medium is written into a memory provided in an expansion board inserted into the computer or into a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above embodiments.
[0079] Computer program product
[0080] The present application also provides a computer program product tangibly stored on a computer-readable medium and comprising computer-executable instructions. When executed, the computer-executable instructions cause at least one processor to perform the query structure automatic conversion method provided in the aforementioned embodiments. It should be understood that each solution in this embodiment has the corresponding technical effects of the aforementioned method embodiments and will not be further elaborated here.
[0081] It should be noted that not all steps and modules in the above-mentioned processes and device structure diagrams are required, and certain steps or modules can be omitted according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or may be implemented by certain components in multiple independent devices.
[0082] Nouns and pronouns referring to persons in this patent application are not limited to a specific gender.
[0083] In the above embodiments, the hardware module can be implemented mechanically or electrically. For example, a hardware module can include a permanent dedicated circuit or logic (such as a dedicated processor, FPGA or ASIC) to complete the corresponding operation. The hardware module can also include programmable logic or circuits (such as a general-purpose processor or other programmable processors), which can be temporarily set by software to complete the corresponding operation. The specific implementation method (mechanical method, or dedicated permanent circuit, or temporarily set circuit) can be determined based on cost and time considerations.
[0084] The above text has demonstrated and explained the present application in detail through the accompanying drawings and preferred embodiments. However, the present application is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present application, and these embodiments are also within the scope of protection of the present application.
Claims
1. A query structure automatic conversion method (100), comprising: Obtaining a code text of a first query program, wherein the first query program is used to query source data of a target object to generate feature data of the target object; Extracting effective information of the first query program from the code text of the first query program, wherein the effective information of the first query program at least includes data structure information of the characteristic data of the target object; Parse the data structure information of the characteristic data to generate a data model representing the first business, the data model includes one data model or two or more different data models associated with each other, each of the data models is used to query the source data of the target object to generate characteristic information of the target object, and the characteristic information of the target object is used to form the characteristic data of the target object.
2. The method according to claim 1, before extracting the valid information of the first query program from the code text of the first query program, the method further comprises: The code text of the first query program is filtered to remove statements in the code text of the first query program that are irrelevant to the valid information.
3. The method according to claim 1 or 2, wherein: Extracting valid information of the first query program from the code text of the first query program includes: extracting valid information of the first query program using XML analysis technology.
4. The method according to claim 1, wherein: The parsing the data structure information of the characteristic data to generate a data model representing the first service includes: Determining the field structure of the data model and the association relationship between data models according to the data structure information of the feature data; generating a data model statement according to the field structure of the data model, wherein the data model statement is used to create the data model; A node statement and an edge statement representing the first business are generated according to the association relationship between the data models, wherein the node statement is used to define the data model corresponding to each node in the first business, and the edge statement is used to define the relationship between each node in the first business.
5. The method according to claim 1, wherein: The valid information of the first query program also includes the business attribute information of the feature information in the feature data; the data structure information of the feature data includes the sub-data structure information corresponding to each piece of feature information; The field structure of the data model and the relationship between the data models are determined according to the data structure information of the feature data. Relationships include: Classifying the data structure information of the feature data according to the business attribute information of the feature information in the feature data to determine the sub-data structure information corresponding to each data model; The sub-data structure information corresponding to each data model is parsed respectively to determine the field structure of the data model and the association relationship between the data models.
6. The method according to claim 1, wherein: The first query program is a SPARQL query structure, and the data model representing the first business is a relational data model.
7. The method according to claim 1 or 6, wherein: The first query program includes a SPARQL query and a SPARQL response.
8. A query structure automatic conversion device (600), comprising: An acquisition unit (601) is used to acquire a code text of a first query program, wherein the first query program is used to query source data of a target object to generate feature data of the target object; An extraction unit (602) is used to extract valid information of the first query program from the code text of the first query program, wherein the valid information of the first query program at least includes data structure information of the characteristic data of the target object; A parsing unit (603) is used to parse the data structure information of the characteristic data to generate a data model representing the first business, wherein the data model includes one data model or two or more different data models associated with each other, each of the data models is used to query the source data of the target object to generate characteristic information of the target object, and the characteristic information of the target object is used to form the characteristic data of the target object.
9. An electronic device (700), comprising: A processor (702), a communication interface (704), a memory (706) and a bus (708), wherein the processor (702), the communication interface (704) and the memory (706) communicate with each other via the bus (708); The memory (706) is used to store at least one executable instruction, and the executable instruction enables the processor (702) to perform operations corresponding to the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having computer instructions stored thereon, wherein when the computer instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 7.
11. A computer program product tangibly stored on a computer readable medium and comprising computer executable instructions which, when executed, cause at least one processor to perform the method according to any one of claims 1-7.
Citation Information
Patent Citations
Target query statement construction method and device, storage medium and electronic device
CN113127506A
Data query method, device, equipment, system and storage medium
CN114676163A
Data query method and device, electronic equipment and storage medium
CN115687386A
Query statement conversion method and device, electronic equipment and storage medium
CN115982204A
Data query method and device, electronic equipment and readable storage medium
CN116127143A