CN114896317A - Data structure conversion method and device, electronic equipment and storage medium - Google Patents

Data structure conversion method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114896317A
CN114896317A CN202210488387.4A CN202210488387A CN114896317A CN 114896317 A CN114896317 A CN 114896317A CN 202210488387 A CN202210488387 A CN 202210488387A CN 114896317 A CN114896317 A CN 114896317A
Authority
CN
China
Prior art keywords
data
data structure
data field
service
field
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210488387.4A
Other languages
Chinese (zh)
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202210488387.4A priority Critical patent/CN114896317A/en
Publication of CN114896317A publication Critical patent/CN114896317A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a data structure conversion method, a data structure conversion device, electronic equipment and a storage medium. The method comprises the following steps: acquiring business data conforming to a first data structure and a mapping relation which is configured in advance, wherein the mapping relation comprises a mapping relation between a first data field expanded in the first data structure and a second data field expanded in a second data structure; writing a second data field in the mapping relation into an extended data field preset in a second data structure; and aiming at the extended data corresponding to the first data field in the mapping relation in the service data, writing the extended data into a second data field positioned under the extended data field so as to enable the written service data to conform to a second data structure. The technical scheme of the embodiment of the invention can quickly realize the conversion process of the data structure after the data field is expanded.

Description

Data structure conversion method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computer application, in particular to a data structure conversion method and device, electronic equipment and a storage medium.
Background
For the back end of the business data presentation class, it usually needs to implement the function of data structure conversion.
The data structure of the business data returned by the upstream service to the back end is changed continuously as the required version is iterated, wherein the change refers to the change of the data structure caused by the expansion of the data field. Therefore, the back end also needs to correspondingly and iteratively develop and expand the data fields suitable for the front-end page so as to realize the smooth conversion of the data structure. At present, the above-mentioned processes are mainly realized according to the flows of back-end development, self-testing, deployment and the like.
In the process of implementing the invention, the inventor finds that the following technical problems exist in the prior art: it is difficult to quickly implement the conversion process of the data structure after the data field is extended.
Disclosure of Invention
The embodiment of the invention provides a data structure conversion method, a data structure conversion device, electronic equipment and a storage medium, which are used for quickly realizing the conversion process of a data structure after data field expansion.
According to an aspect of the present invention, there is provided a data structure conversion method, which may include:
acquiring business data conforming to a first data structure and a mapping relation which is configured in advance, wherein the mapping relation comprises a mapping relation between a first data field expanded in the first data structure and a second data field expanded in a second data structure;
writing a second data field in the mapping relation into an extended data field preset in a second data structure;
and aiming at the extended data corresponding to the first data field in the mapping relation in the service data, writing the extended data into a second data field positioned under the extended data field so as to enable the written service data to conform to a second data structure.
According to another aspect of the present invention, there is provided a data structure converting apparatus, which may include:
the mapping relation obtaining module is used for obtaining the business data conforming to the first data structure and the mapping relation which is configured in advance, wherein the mapping relation comprises the mapping relation between a first data field expanded in the first data structure and a second data field expanded in the second data structure;
a second data field writing module, configured to write a second data field in the mapping relationship into an extended data field preset in a second data structure;
and the extended data writing module is used for writing the extended data into a second data field positioned below the extended data field aiming at the extended data corresponding to the first data field in the mapping relation in the service data so as to enable the written service data to conform to a second data structure.
According to another aspect of the present invention, there is provided an electronic device, which may include:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to cause the at least one processor to perform a data structure transformation method provided by any of the embodiments of the present invention when executed.
According to another aspect of the present invention, there is provided a computer-readable storage medium having stored thereon computer instructions for causing a processor to execute a method for data structure conversion provided by any of the embodiments of the present invention.
According to the technical scheme of the embodiment of the invention, the business data conforming to the first data structure and the mapping relation which is configured in advance are obtained, wherein the mapping relation comprises the mapping relation between the first data field expanded in the first data structure and the second data field expanded in the second data structure, which shows that the expansion process of the second data field is realized through a configuration mode, and the important premise that the data structure conversion after the data field expansion is realized quickly is provided; writing the second data field in the mapping relationship into an extended data field preset in the second data structure, because the second data field is an extended data field, that is, the second data field is not preset in the second data structure; in this way, for the extended data corresponding to the first data field in the mapping relationship in the service data, the extended data may be written into the second data field located below the extended data field, so that the written service data conforms to the second data structure. According to the technical scheme, the extension process of the second data field is realized through a configuration mode, namely the extension process of the second data field can be realized under the conditions of zero development, zero test and zero deployment, and after the extension process is matched with the rest steps, the effect of quickly realizing data structure conversion after the data field is extended is achieved, and the version iteration speed is greatly improved.
It should be understood that the statements in this section do not necessarily identify key or critical features of any embodiment of the present invention, nor do they necessarily limit the scope of the present invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow chart of a data structure conversion method provided according to an embodiment of the invention;
FIG. 2 is a flow chart of yet another data structure transformation method provided in accordance with an embodiment of the present invention;
FIG. 3 is a flow chart of another data structure conversion method provided in accordance with an embodiment of the present invention;
FIG. 4a is a first diagram illustrating an alternative example of another data structure transformation method provided in accordance with an embodiment of the invention;
FIG. 4b is a second diagram illustrating an alternative example of another data structure transformation method provided in accordance with an embodiment of the invention;
fig. 5 is a block diagram illustrating a data structure conversion apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device implementing the data structure conversion method according to the embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. The cases of "target", "original", etc. are similar and will not be described in detail herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Before the embodiment of the present invention is described, an application scenario of the embodiment of the present invention is exemplarily described: taking an e-commerce scenario as an example, assume that the business data returned by the upstream service is a four-layer nested data structure, such as a package field nested in one checkout page, a store field nested in the package field, and a goods field nested in the store field. However, the business data that can be exposed by the front end (i.e., the page end) needs to be a two-level nested data structure, such as a package field, a store field, and a commodity field nested at the same level in one checkout page. Therefore, the back end needs to convert the service data nested in the four layers into the service data nested in the two layers. On the basis, when the package field is nested with not only the shop field but also the coupon field as time goes on, the coupon field belongs to the expanded data field, and then the back end needs to correspondingly expand the data field which corresponds to the coupon field and is suitable for the front end page.
Fig. 1 is a flowchart of a data structure conversion method provided in an embodiment of the present invention. The embodiment can be suitable for the condition of quickly realizing the data structure conversion after the data field is expanded. The method can be executed by the data structure conversion device provided by the embodiment of the invention, the device can be realized by software and/or hardware, the device can be integrated on electronic equipment, and the equipment can be various user terminals or servers.
Referring to fig. 1, the method of the embodiment of the present invention specifically includes the following steps:
s110, acquiring service data conforming to a first data structure and a mapping relation which is configured in advance, wherein the mapping relation comprises a mapping relation between a first data field expanded in the first data structure and a second data field expanded in a second data structure.
The service data may be data conforming to a service layer of a first data structure, and the first data structure may indicate that the service data is data of several layers of nested data, which fields are included, and a nested relationship between the fields. The second data structure may be a target of data structure conversion, i.e. the data structure conversion means may convert the service data conforming to the first data structure into service data conforming to the second data structure, e.g. convert the service data nested in four layers into service data nested in two layers as in the above exemplary description.
It should be noted that, in general, what data field (referred to as a first basic field herein) is included in the first data structure, which is written into the code in the code development stage; accordingly, a second base field, corresponding to the first base field, contained in the second data structure has also been written into the code in the code development stage. On the basis, when the first data structure expands the first data field due to the change of the actual service requirement, the second data structure also needs to expand the second data field corresponding to the first data field, so as to ensure the correspondence between the first data structure and the second data structure. Therefore, how to extend the second data field in the second data structure is critical.
If the second data field is written into the code according to the code development link, the latest data structure conversion can be realized after a large amount of time is consumed, and the quick change business requirements are difficult to meet. To this end, the embodiment of the present invention proposes to implement the extended requirement of the second data field in the second data structure by a configuration manner. Specifically, after obtaining the second data field set for the first data field, the configurator may configure the correspondence between the first data field and the second data field as a mapping relationship at a certain place that can be acquired by the data structure conversion device, so as to realize the latest conversion of the data structure based on the acquired mapping relationship. The time consumption of the data configuration process is much shorter than that of the code development process.
In practical applications, optionally, when each first data field is expanded in the first data structure, a configuration person may configure a mapping relationship accordingly. Therefore, the number of the mapping relationships obtained in this step may be one, two, or more, which mainly depends on how many mapping relationships are configured by the configurator after the code development is finished, and the second data fields in the mapping relationships are all data fields that are not written into the code in the code development link (i.e., configured after the code development is finished).
And S120, writing the second data field in the mapping relationship into an extended data field preset in a second data structure.
Wherein the second data field is not present in the code because it is a data field that is expanded after the code development is completed. Therefore, to implement the conversion of the data structure, the second data field may be written into the extended data field first. It should be noted that the extended data field may be a data field that is set in the second data structure in the code development link, so that by writing the second data field into the extended data field, an effect of extending the second data field on the basis of the second basic field is achieved, which is an important prerequisite for implementing data structure conversion subsequently.
S130, aiming at the extended data corresponding to the first data field in the mapping relation in the service data, writing the extended data into a second data field positioned under the extended data field, so that the written service data conforms to a second data structure.
The business data may include basic data corresponding to the first basic field and extended data corresponding to the first data field, and of course, if no first basic field is set in the first data structure in the code development link, the business data and the extended data are identical. The extended data is written in the second data field under the extended data field, and since the extended data is equal to or belongs to a part of the service data, the writing operation is helpful for realizing the conversion of the data structure, that is, for making the written service data conform to the second data structure. In practical applications, optionally, if the service data includes the first basic data, since the first basic field is written in the code, the first basic data may be directly mapped to the first basic field, thereby ensuring complete conversion of the data structure.
It should be noted that, for the above technical solution, firstly, since a developer does not need to perform links such as code development, self-test, and deployment according to the first data field, the zero development, zero test, and zero deployment mode can quickly respond to the extension requirement of the data field, thereby realizing quick extension of the data field. And secondly, data field extension is realized through zero development, zero test and zero deployment, so that compared with developers, the development cost is reduced, and the development process is simplified. And thirdly, the expansion of the data field is realized through a configuration mode, the data field can be flexibly expanded according to the actual service requirement, and the expandability is strong.
According to the technical scheme of the embodiment of the invention, the business data conforming to the first data structure and the mapping relation which is configured in advance are obtained, wherein the mapping relation comprises the mapping relation between the first data field expanded in the first data structure and the second data field expanded in the second data structure, which shows that the expansion process of the second data field is realized through a configuration mode, and the important premise that the data structure conversion after the data field expansion is realized quickly is provided; writing the second data field in the mapping relationship into an extended data field preset in the second data structure, because the second data field is an extended data field, that is, the second data field is not preset in the second data structure; in this way, for the extended data corresponding to the first data field in the mapping relationship in the service data, the extended data may be written into the second data field located below the extended data field, so that the written service data conforms to the second data structure. According to the technical scheme, the extension process of the second data field is realized through a configuration mode, namely the extension process of the second data field can be realized under the conditions of zero development, zero test and zero deployment, and after the extension process is matched with the rest steps, the effect of quickly realizing data structure conversion after the data field is extended is achieved, and the version iteration speed is greatly improved.
An optional technical solution is that a mapping relationship includes a mapping relationship between a first data field in a first service class in a first data structure and a second data field in a second service class in a second data structure, and writing the second data field in the mapping relationship into an extended data field preset in the second data structure, where the mapping relationship may include: aiming at the first service class determined according to the mapping relation, determining a second service class matched with the first service class in a second data structure according to the mapping relation; and aiming at a second data field which is determined according to the mapping relation and is matched with the first data field, acquiring an extended data field which is preset under a second service class, and writing the second data field into the extended data field. In practical application, optionally, the data field may be set in a service class, and the service class may be set in a data structure, so as to avoid a situation that an erroneous data field is located according to a mapping relationship due to renaming of data fields in different service classes, where the mapping relationship may specifically be a first data field expanded under a first service class in a first data structure and a second data field expanded under a second service class in a second data structure, so that a certain data field may be accurately located through the service class and the data field in the mapping relationship in the following. Specifically, a second service class matched with the first service class in the second data structure can be determined according to the mapping relationship, and then the second data field is written into an extended data field preset under the second service class, so that the effect of accurately writing the second data field is achieved, that is, the position of the second data field is accurately located.
Another optional technical solution, where the extended data field includes a field of a dictionary data structure, writing a second data field in the mapping relationship into a preset extended data field, includes: for each mapping relation, writing a second data field in the mapping relation into a preset extended data field by taking the second data field as a key; writing the extended data under a second data field located under the extended data field may include: the extended data is written as a value corresponding to the key under a second data field located under the extended data field. The obtained mapping relationships are full mapping relationships configured after the code development link is finished, that is, the number of the mapping relationships may be one, two, or more, and therefore, in order to ensure effective writing of the second data field in each mapping relationship, the extended data field may be set as a field of a dictionary data structure (that is, a Map data structure) with extensibility. Specifically, for each mapping relationship, the second data field is used as a key and written into a preset extended data field; then, the extended data is written under a second data field located under the extended data field as a value corresponding to the key. That is, the above steps are performed by training each mapping relationship in turn, thereby achieving efficient mapping of the expanded data in each of the expanded first data fields.
Another optional technical solution, where the service data includes serialized service data, and after the service data conforming to the first data structure is obtained, the data structure conversion method may further include: performing deserialization on the acquired service data, and updating the service data according to a deserialization result; after the written service data conforms to the second data structure, the data structure conversion method may further include: and serializing the service data conforming to the second data structure, and transmitting a serialization result. In order to achieve effective transmission of the service data, the service data to be transmitted may be serialized, that is, the received service data may be serialized service data. On this basis, in order to effectively apply the received service data, the received service data may be deserialized and then applied. Similarly, the service data after the data structure conversion may also be serialized so that the serialized service data is transmitted to the side matched with the converted second data structure. According to the technical scheme, effective transmission of service data is achieved through serialization and deserialization.
Another optional technical solution, the data structure conversion method may further include: receiving a data access request sent by a page terminal, and sending the data access request to a target service; acquiring the service data conforming to the first data structure may include: receiving business data which are corresponding to the data access request and are returned by the target service and accord with a first data structure, wherein the first data structure is a data structure matched with the target service; after the written service data conforms to the second data structure, the data structure conversion method may further include: and returning the service data conforming to the second data structure to the page end, wherein the second data structure is a data structure matched with the page end. In combination with an application scenario that may be involved in the embodiment of the present invention, a user may trigger a data access request through a page end, and then the page end sends the data access request to a backend where a data conversion device is located, so that the backend sends the received data access request to a target service, and optionally, with respect to the backend, the target service may be regarded as an upstream service of the backend. In general, complex business processing logic is uniformly processed by a target service, and then the processed business data is encapsulated into a first data structure matched with the business data and returned to a back end, so that the back end performs data structure conversion on the received business data. The back end converts the service data from the first data structure into a second data structure matched with the page end, and then sends the converted service data to the page end, so that the page end can display the received service data. Therefore, the access and display process of the business data is completed.
Fig. 2 is a flowchart of another data structure conversion method provided in the embodiment of the present invention. The present embodiment is optimized based on the above technical solutions. In this embodiment, optionally, the data structure conversion method may further include: responding to a configuration data updating event, acquiring a dependent package name, and downloading an updating dependent package corresponding to the dependent package name, wherein a first data structure is stored in the updating dependent package; updating the current package file cached in the cache based on the downloaded update package file under the update dependent package, wherein the current package file is the package file which is currently applied; for the extended data corresponding to the first data field in the mapping relationship in the service data, the method may include: and determining the extended data corresponding to the first data field in the mapping relation in the service data based on the current packet file cached in the cache. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
Referring to fig. 2, the method of the present embodiment may specifically include the following steps:
s210, responding to a configuration data updating event, obtaining a dependent package name, and downloading an updating dependent package corresponding to the dependent package name, wherein a first data structure is stored in the updating dependent package.
The configuration data update event may be an event triggered when the configuration data is updated, such as an event triggered when a configuration person adds new configuration data to a configuration center to update the configuration data in the configuration center. In practical applications, optionally, the new configuration data may include a newly added mapping relationship, a dependent package name and an update version number of an update dependent package, and the like, which is not specifically limited herein. And responding to a configuration data updating event, acquiring a dependent package name, and downloading an updating dependent package corresponding to the dependent package name, wherein the updating dependent package can be a dependent package which updates a current dependent package currently applied because a first data field is expanded in a first data structure, namely the first data structure is stored in the updating dependent package.
And S220, updating the current package file cached in the cache based on the downloaded update package file under the update dependent package, wherein the current package file is the package file which is currently applied.
The update package file may be a package file under the update dependent package, and may be a field file obtained by encapsulating a data field in the first data structure, a class file obtained by encapsulating a service class, and the like, which is not specifically limited herein. Similarly, the current package file is the package file in the current dependent package. Since the current dependent package is the dependent package currently being applied, the current package file thereunder is already cached in the cache. In order to realize the conversion of the data structure after the data field is expanded, the current package file in the cache can be replaced based on the updated package file, so that the replacement work of new and old codes is realized, namely, the quick upgrade of the old codes is realized. The above replacement process of the current package file may be understood as a process of loading the update dependent package into the item being run in the backend.
S230, acquiring the service data conforming to the first data structure and a mapping relation which is configured in advance, wherein the mapping relation comprises a mapping relation between a first data field expanded in the first data structure and a second data field expanded in the second data structure.
S240, writing the second data field in the mapping relation into an extended data field preset in a second data structure.
And S250, determining the extended data corresponding to the first data field in the mapping relation in the service data based on the current packet file cached in the cache.
Since the current packet file cached in the cache is already the packet file containing the first data structure, the service data can be analyzed based on the current packet file, and the extended data corresponding to the first data field is obtained from the analysis.
And S260, writing the extended data into a second data field positioned under the extended data field so as to enable the written service data to conform to a second data structure.
According to the technical scheme of the embodiment of the invention, the dependent package name is obtained in response to the configuration data updating event, the updating dependent package which is stored with the first data structure and corresponds to the dependent package name is downloaded, then the current package file cached in the cache is updated based on the updating package file under the downloaded updating dependent package, and at the moment, the current package file cached in the cache comprises the first data structure, so that the service data is analyzed based on the current package file in the following process, and the extension data corresponding to the first data field is obtained, and therefore, the effect of accurately obtaining the extension data is achieved.
On this basis, an optional technical solution is that after responding to the configuration data update event, the data structure conversion method may further include: acquiring an update version number and a current version number of a current dependent package which is currently applied and corresponds to the name of the dependent package, and comparing the update version number with the current version number, wherein the current package file is a package file under the current dependent package; downloading the update dependency package corresponding to the dependency package name may include: and if the update version number is higher than the current version number, downloading the update dependent package corresponding to the dependent package name and the update version number. And if so, downloading the corresponding update dependent package according to the name of the dependent package and the update version number, and ensuring to update when the current dependent package needs to be updated through the bottom condition of the pocket.
Fig. 3 is a flowchart of another data structure conversion method provided in the embodiment of the present invention. The present embodiment is optimized based on the above technical solutions. The same or corresponding terms as those in the above embodiments are not explained in detail herein. It should be noted that the method of this embodiment may be applied to the back end of the service data presentation class. After the data field is extended by the upstream service, the back-end developer may confirm with the upstream developer what data field under what service class the extended data field in the upstream service is (here, taking the first data field under the first service class as an example), the dependent packet name and the update version of the update dependent packet corresponding to the first data structure in which the first data field is located, and what service class (here, taking the second service class as an example) the first service class corresponds to in the back-end; then, configuring the dependent packet name, the updated version number, and the corresponding mapping relationship as configuration data into a configuration center, where the mapping relationship may include a mapping relationship between a first data field in a first service class in a first data structure and a second data field in a second service class in a second data structure, the second data field may be a data field set by a back-end developer according to a presentation requirement of a front-end for the first data field, the first data structure may be a data structure matched with an upstream service, and the second data structure may be a data structure matched with a page end. Since the backend subscribes to update of the configuration data in the configuration center, after the backend developer configures the configuration data to the configuration center, the backend can receive a configuration data update event. In addition, when the back-end developer develops, an extended data field of the Map data structure is preset in the second service class, so that the extended data field is continuously extended outside the basic field in the second service class. The following embodiments are realized on this basis.
Referring to fig. 3, the method of this embodiment may specifically include the following steps:
s3010, responding to a configuration data updating event, and acquiring configuration data of the current configuration, wherein the configuration data includes a dependent package name, an updating version number and a mapping relation of the current configuration.
S3020, acquiring the current version number of the currently applied current dependency package corresponding to the name of the dependency package, and comparing the updated version number with the current version number.
S3030, if the update version number is higher than the current version number, downloading an update dependency package corresponding to the dependency package name and the update version number from the warehouse, wherein the update dependency package stores a first data structure.
Wherein, after the first data field is expanded, the upstream service stores the update dependency package containing the first data structure (i.e. the data structure containing the first data field) into the repository. Thus, the update dependent package may be downloaded from the repository when the update version number of the current configuration is higher than the current version number. Optionally, the essence of the update dependency package may be a jar package, and the jar package may be understood as a result of packing, encapsulating and compressing the plurality of service classes in the first data structure, so that the update dependency package includes a plurality of class files, the class files in the update dependency package are referred to as update class files, and the class files in the current dependency package are referred to as current class files.
When the newer version number is lower than or equal to the current version number, the update of the current dependent package is not necessary, and thus the return may be made directly without performing the download operation in S3030 and S3040.
S3040 decompressing the downloaded update dependent packet, acquiring an update class file under the update dependent packet, and updating the current class file cached in the cache based on the update class file.
And the early preparation work after the data field is expanded is finished.
S3050, receiving a data access request sent by a page end, sending the data access request to an upstream service, receiving serialized service data which is returned by the upstream service and corresponds to the data access request and accords with a first data structure, performing deserialization on the received service data, and updating the service data according to a deserialization result.
The service data received by the back end may be data that is processed by the upstream service through service logic based on the received data access request, assembled with the processing result based on the update dependency package, and then serialized with the assembly result.
S3060, obtaining the mapping relation of the pre-configured total quantity from the configuration center.
The mapping relationship of the total amount may be all mapping relationships configured in the configuration center in advance, which may include the mapping relationship configured currently and the mapping relationship configured before the current configuration, and of course, if the mapping relationship of the current configuration is the mapping relationship configured for the first time, it may only include the mapping relationship of the current configuration. For each mapping relationship, performing S3070-S3090, which is only described as an example that the mapping relationship is between the first data field and the second data field.
It should be noted that, after obtaining the mapping relationship, the back end may locate the first data field in the first service class configured in the first data structure, and further determine the extended data of the service data in the first data field (this is set forth in S3090).
S3070, aiming at the first service class determined according to the mapping relation, determining a second service class matched with the first service class in the second data structure according to the mapping relation.
S3080, aiming at the second data field which is determined according to the mapping relation and is matched with the first data field, writing the second data field into the extended data field under the second service class by taking the second data field as a key.
S3090, based on the current class file cached in the cache, determining the extended data corresponding to the first data field in the mapping relation in the service data, and writing the extended data into a second data field located below the extended data field by taking the extended data as a value corresponding to the key so as to enable the written service data to conform to a second data structure.
And S3100, serializing the service data conforming to the second data structure, and transmitting the serialized service data to the page end, so that the page end deserializes the serialized service data, and displays the deserialized service data.
According to the technical scheme of the embodiment of the invention, the conversion process of the data structure after the data field is expanded can be quickly realized through the mutual cooperation of the technical means.
In order to more clearly understand the technical solution, the following description is made by way of example with reference to specific examples. Illustratively, referring to fig. 4a, downloading and loading of the update dependency package is implemented by configuration data configured in the configuration center, and replacement of new and old codes is implemented by loading the update dependency package (i.e., the update operation in S3040), so that after service data is acquired by a Remote Procedure Call Protocol (RPC), extended data under the first data field may be acquired from the service data. Then, when a data access request triggered by a user through a page end is received, acquiring a full mapping relation from a configuration center, taking a currently configured mapping relation in the full mapping relation as an example, mapping extended data to a second data field under an extended service field according to the mapping relation, and thus realizing a response function of acquiring a first service field extended from an upstream without development and deployment.
Referring to fig. 4b, the backend mainly performs the following two functions: update dependency packages and fast maps. Specifically, for function one: the acquisition of the dependent package name and the update version number, the version number verification (i.e., the judgment operation in S3030), and the downloading, parsing (i.e., the decompression operation in S3040) and loading of the update dependent package are realized according to the dependent package name and the update version number in the configuration center. Aiming at the second function: sending a data access request triggered by a user to an upstream service, acquiring service data returned by the upstream service through rpc, and performing deserialization on the service data; then, acquiring a first data field and a second data field corresponding to the first data field according to a mapping relation in the configuration center; then, matching and mapping the service data, namely mapping the second data field to the expanded data field, and mapping the expanded data of the service data in the first data field to the second data field under the expanded data field, thereby obtaining the service data conforming to the second data structure; and finally, returning the service data conforming to the second data structure to the page end.
Fig. 5 is a block diagram of a data structure conversion apparatus provided in an embodiment of the present invention, and the apparatus is configured to execute a data structure conversion method provided in any of the above embodiments. The apparatus and the data structure conversion method of the above embodiments belong to the same inventive concept, and details that are not described in detail in the embodiments of the data structure conversion apparatus may refer to the embodiments of the data structure conversion method described above. As shown in fig. 5, the apparatus may specifically include: a mapping relation obtaining module 410, a second data field writing module 420 and an extended data writing module 430.
The mapping relationship obtaining module 410 is configured to obtain service data that conforms to a first data structure and a mapping relationship that is configured in advance, where the mapping relationship includes a mapping relationship between a first data field expanded in the first data structure and a second data field expanded in a second data structure;
a second data field writing module 420, configured to write a second data field in the mapping relationship into an extended data field preset in a second data structure;
the extended data writing module 430 is configured to write, for extended data corresponding to a first data field in the mapping relationship in the service data, the extended data into a second data field located below the extended data field, so that the written service data conforms to a second data structure.
Optionally, the mapping relationship includes a mapping relationship between a first data field in a first service class in the first data structure and a second data field in a second service class in the second data structure, and the second data field writing module 420 may include:
the second service class determining unit is used for determining a second service class matched with the first service class in the second data structure according to the mapping relation aiming at the first service class determined according to the mapping relation;
and the second data field first writing unit is used for acquiring an extended data field preset under the second service class aiming at a second data field which is determined according to the mapping relation and is matched with the first data field, and writing the second data field into the extended data field.
Optionally, the extended data field includes a field of a dictionary data structure, and the second data field writing module 420 may include:
the second data field second writing unit is used for taking the second data field in the mapping relation as a key and writing the second data field in the mapping relation into an extended data field preset in a second data structure aiming at each mapping relation;
the extended data writing module 430 may include:
and an extended data writing unit configured to write extended data as a value corresponding to the key under a second data field located under the extended data field.
Optionally, the data structure conversion apparatus may further include:
the updating dependent package downloading module is used for responding to a configuration data updating event, acquiring a dependent package name and downloading an updating dependent package corresponding to the dependent package name, wherein a first data structure is stored in the updating dependent package;
the current package file updating module is used for updating the current package file cached in the cache based on the downloaded update package file under the update dependent package, and the current package file is the package file which is currently applied;
the extended data writing module 430 may include:
and the extended data determining unit is used for determining extended data corresponding to the first data field in the mapping relation in the service data based on the current packet file cached in the cache.
Optionally, on the basis of the above apparatus, the apparatus may further include:
the version number comparison module is used for acquiring an update version number and a current version number of a currently applied current dependency package corresponding to the dependency package name after responding to a configuration data update event, and comparing the update version number with the current version number, wherein the current package file is a package file under the current dependency package;
the update dependent package downloading module may include:
and the updating dependent package downloading unit is used for downloading the updating dependent package corresponding to the dependent package name and the updating version number if the updating version number is higher than the current version number.
Optionally, if the service data is serialized service data, the data structure conversion apparatus may further include:
the deserializing module is used for deserializing the acquired service data after the service data conforming to the first data structure is acquired and updating the service data according to a deserializing result;
and the serialization module is used for serializing the service data conforming to the second data structure after the written service data conforms to the second data structure, and transmitting a serialization result.
Optionally, the data structure conversion apparatus may further include:
the data access request sending module is used for receiving a data access request sent by a page terminal and sending the data access request to a target service;
accordingly, the mapping relationship obtaining module 410 may include:
the service data receiving unit is used for receiving service data which are returned by the target service and correspond to the data access request and accord with a first data structure, wherein the first data structure is a data structure matched with the target service;
correspondingly, the data structure conversion device may further include:
and the service data returning module is used for returning the service data which accords with the second data structure to the page end after the written service data accords with the second data structure, wherein the second data structure is a data structure matched with the page end.
The data structure conversion device provided by the embodiment of the invention acquires the service data conforming to the first data structure and the mapping relation configured in advance through the mapping relation acquisition module, wherein the mapping relation comprises the mapping relation between the first data field expanded in the first data structure and the second data field expanded in the second data structure, which indicates that the expansion process of the second data field is realized through a configuration mode, and the configuration mode is an important premise for quickly realizing the data structure conversion after the data field is expanded; because the second data field in the mapping relation is an expanded data field, namely the second data field is not preset in the second data structure, the second data field is written into the expanded data field preset in the second data structure through the second data field writing module; in this way, the extended data writing module can write the extended data corresponding to the first data field in the mapping relationship into the second data field located below the extended data field in the service data, so that the written service data conforms to the second data structure. The device realizes the extension process of the second data field through a configuration mode, namely the extension process of the second data field can be realized under the conditions of zero development, zero test and zero deployment, and after the extension process is matched with the rest steps, the effect of quickly realizing data structure conversion after the data field is extended is achieved, and the version iteration speed is greatly improved.
The data structure conversion device provided by the embodiment of the invention can execute the data structure conversion method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the data structure conversion apparatus, the included units and modules are only divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be realized; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
FIG. 6 illustrates a schematic structural diagram of an electronic device 10 that may be used to implement an embodiment of the present invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM)12, a Random Access Memory (RAM)13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 can perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM)12 or the computer program loaded from a storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 11 performs the various methods and processes described above, such as the data structure conversion method.
In some embodiments, the data structure conversion method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the data structure conversion method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the data structure conversion method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired results of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for data structure conversion, comprising:
acquiring service data conforming to a first data structure and a mapping relation which is configured in advance, wherein the mapping relation comprises a mapping relation between a first data field expanded in the first data structure and a second data field expanded in a second data structure;
writing the second data field in the mapping relation into an extended data field preset in the second data structure;
and for the extended data corresponding to the first data field in the mapping relation in the service data, writing the extended data into the second data field located under the extended data field, so that the written service data conforms to the second data structure.
2. The method of claim 1, wherein the mapping comprises a mapping between the first data field in a first traffic class in the first data structure and the second data field in a second traffic class in the second data structure;
the writing the second data field in the mapping relationship into an extended data field preset in the second data structure includes:
for the first service class determined according to the mapping relation, determining the second service class matched with the first service class in the second data structure according to the mapping relation;
and aiming at the second data field which is determined according to the mapping relation and is matched with the first data field, acquiring an extended data field which is preset under the second service class, and writing the second data field into the extended data field.
3. The method according to claim 1, wherein the extended data field comprises a field of a dictionary data structure, and the writing the second data field in the mapping relationship into an extended data field preset in the second data structure comprises:
for each mapping relation, taking the second data field in the mapping relation as a key, and writing the second data field into an extended data field preset in the second data structure;
the writing the extended data under the second data field under the extended data field comprises:
and writing the extended data as a value corresponding to the key under the second data field located under the extended data field.
4. The method of claim 1, further comprising:
responding to a configuration data updating event, acquiring a dependent package name, and downloading an updating dependent package corresponding to the dependent package name, wherein the first data structure is stored in the updating dependent package;
updating the current package file cached in the cache based on the downloaded update package file under the update dependent package, wherein the current package file is the package file which is currently applied;
the step of aiming at the extended data in the business data corresponding to the first data field in the mapping relation comprises the following steps:
and determining the extended data corresponding to the first data field in the mapping relation in the service data based on the current packet file cached in the cache.
5. The method of claim 4, further comprising, after the updating event in response to configuration data:
acquiring an update version number and a current version number of a current dependent package which is currently applied and corresponds to the dependent package name, and comparing the update version number with the current version number, wherein the current package file is a package file under the current dependent package;
the downloading of the update dependent package corresponding to the dependent package name comprises:
and if the update version number is higher than the current version number, downloading the update dependent package corresponding to the dependent package name and the update version number.
6. The method of claim 1, wherein the service data is serialized service data, and further comprising, after the obtaining the service data conforming to the first data structure:
performing deserialization on the acquired service data, and updating the service data according to a deserialization result;
after the making the written service data conform to the second data structure, further comprising:
and serializing the service data which accords with the second data structure, and transmitting a serialization result.
7. The method of claim 1, further comprising:
receiving a data access request sent by a page end, and sending the data access request to a target service;
the acquiring of the service data conforming to the first data structure includes:
receiving business data which is corresponding to the data access request and is returned by the target service and accords with a first data structure, wherein the first data structure is a data structure matched with the target service;
after the making the written service data conform to the second data structure, further comprising:
and returning the service data which accords with the second data structure to the page end, wherein the second data structure is a data structure matched with the page end.
8. A data structure conversion apparatus, comprising:
the mapping relation acquisition module is used for acquiring service data conforming to a first data structure and a mapping relation which is configured in advance, wherein the mapping relation comprises a mapping relation between a first data field expanded from the first data structure and a second data field expanded from a second data structure;
a second data field writing module, configured to write the second data field in the mapping relationship into an extended data field preset in the second data structure;
and an extended data writing module, configured to write, for extended data in the service data corresponding to the first data field in the mapping relationship, the extended data into the second data field located below the extended data field, so that the written service data conforms to the second data structure.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to cause the at least one processor to perform the data structure conversion method of any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing a processor to perform the data structure conversion method of any one of claims 1 to 7 when executed.
CN202210488387.4A 2022-05-06 2022-05-06 Data structure conversion method and device, electronic equipment and storage medium Pending CN114896317A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210488387.4A CN114896317A (en) 2022-05-06 2022-05-06 Data structure conversion method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210488387.4A CN114896317A (en) 2022-05-06 2022-05-06 Data structure conversion method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114896317A true CN114896317A (en) 2022-08-12

Family

ID=82720594

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210488387.4A Pending CN114896317A (en) 2022-05-06 2022-05-06 Data structure conversion method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114896317A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858457A (en) * 2023-02-09 2023-03-28 中航金网(北京)电子商务有限公司 File conversion method and device and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858457A (en) * 2023-02-09 2023-03-28 中航金网(北京)电子商务有限公司 File conversion method and device and electronic equipment

Similar Documents

Publication Publication Date Title
CN109739573B (en) Processing method and device for realizing API (application program interface) call and system for realizing API
WO2017166447A1 (en) Method and device for loading kernel module
CN108846753B (en) Method and apparatus for processing data
US10554726B1 (en) Remote device drivers for internet-connectable devices
CN109614088B (en) Form component generation method and device
CN112926008B (en) Method, device, electronic equipment and storage medium for generating form page
CN114816393B (en) Information generation method, device, equipment and storage medium
CN104408073A (en) Data operation method and device
CN110109983B (en) Method and device for operating Redis database
CN112269706A (en) Interface parameter checking method and device, electronic equipment and computer readable medium
CN114896317A (en) Data structure conversion method and device, electronic equipment and storage medium
CN115168130A (en) Chip testing method and device, electronic equipment and storage medium
CN117234582A (en) Project code processing method and device, electronic equipment and storage medium
CN116149728A (en) CI/CD assembly conversion method and device
CN115408034A (en) Vehicle-mounted controller upgrading method and device, electronic equipment and storage medium
CN113076343B (en) Data query method, device, equipment and storage medium
CN115269431A (en) Interface testing method and device, electronic equipment and storage medium
CN114510334A (en) Class instance calling method and device, electronic equipment and automatic driving vehicle
CN110471708B (en) Method and device for acquiring configuration items based on reusable components
CN113986476A (en) Sensor equipment virtualization method and device, electronic equipment and storage medium
CN114579520B (en) Mirror image data processing method, mirror image data loading method and device
CN113535187B (en) Service online method, service updating method and service providing method
CN112882922B (en) Test method and related device
CN117908989A (en) Method, device, equipment and medium for generating deployment configuration file
CN113220576A (en) Management method, device, equipment and storage medium of test environment

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