CN114791840A - Data assembling method and device, electronic equipment and medium - Google Patents

Data assembling method and device, electronic equipment and medium Download PDF

Info

Publication number
CN114791840A
CN114791840A CN202110105947.9A CN202110105947A CN114791840A CN 114791840 A CN114791840 A CN 114791840A CN 202110105947 A CN202110105947 A CN 202110105947A CN 114791840 A CN114791840 A CN 114791840A
Authority
CN
China
Prior art keywords
data
assembled
type
result set
items
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110105947.9A
Other languages
Chinese (zh)
Other versions
CN114791840B (en
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN202110105947.9A priority Critical patent/CN114791840B/en
Publication of CN114791840A publication Critical patent/CN114791840A/en
Application granted granted Critical
Publication of CN114791840B publication Critical patent/CN114791840B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/451Execution arrangements for user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking

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)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a data assembling method and device, electronic equipment and a medium. The method comprises the following steps: acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data; converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function; and assembling the data to be assembled of the same type to obtain a final result set. According to the scheme, the multi-source data are obtained through the at least two data interfaces and are converted into the same type for assembly, the problems that data management is difficult to effectively integrate under the condition of multiple data sources and the code maintenance cost is high are solved, and efficient and orderly assembly and use of the multi-source data are achieved.

Description

Data assembling method and device, electronic equipment and medium
Technical Field
The embodiment of the application relates to the technical field of internet, in particular to a data assembling method and device, electronic equipment and a medium.
Background
In internet development, for UI design, rendering is required to convert a design drawing of a UI into an application interface so as to vividly display.
In the page rendering technology, data of a page is usually a source, and page data is acquired from a data source to render a UI design drawing. If a plurality of data sources exist, the condition that the received data sources are disordered and disordered can be caused, the complexity of a UI rendering process is increased, and page rendering is difficult to realize efficiently.
Disclosure of Invention
Embodiments of the present invention provide a data assembly method and apparatus, an electronic device, and a medium, so as to implement effective and fast data integration for efficient page rendering when at least two data sources exist in a page rendering process.
In one embodiment, an embodiment of the present application provides a data assembling method, including:
acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function;
and assembling the data to be assembled of the same type to obtain a final result set.
In another embodiment, an embodiment of the present application further provides a data assembling apparatus, including:
the data acquisition module is used for acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
the conversion module is used for converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function;
and the assembling module is used for assembling the data to be assembled of the same type to obtain a final result set.
In another embodiment, an embodiment of the present application further provides an electronic device, including: one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors implement the data assembling method of any one of the embodiments of the present application.
In yet another embodiment, the present application further provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the data assembling method according to any one of the embodiments of the present application.
In the embodiment of the application, at least two items of data to be assembled are obtained through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data; converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function; and assembling the data to be assembled of the same type to obtain a final result set. According to the scheme, for the condition of at least two data sources, the data of the at least two data sources are received through the data interfaces of different types, the data are converted into the data to be assembled of the same type, the data to be assembled of the one type are assembled, the problems that the UI rendering process is complex and the maintenance cost is high due to the fact that the data are disordered and difficult to manage under the condition of the at least two data sources are solved, and therefore the efficient and rapid assembly of the at least two data sources is achieved and output to a UI layer, the rendering cost of the UI rendering is reduced, the rendering speed is improved, and the maintenance cost of codes is reduced through multiplexing of the method.
Drawings
FIG. 1 is a flow chart of a data assembling method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a data assembling method according to another embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a data assembling apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not to be construed as limiting the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Fig. 1 is a flowchart of a data assembling method according to an embodiment of the present invention. The data assembling method provided by the embodiment of the application can be suitable for the condition of assembling the data of at least two data sources. The method may be applicable to an Android system or other operating systems, and may specifically be executed by a data assembly apparatus, which may be implemented by software and/or hardware, and which may be integrated in an electronic device capable of implementing the data assembly method. Referring to fig. 1, the method of the embodiment of the present application specifically includes:
s110, acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data.
Wherein the at least two items of data to be assembled are data obtained from at least two data sources. The type of data obtained from different data sources may vary. The data to be assembled may be used to render the UI. At least two items of data to be assembled are used for rendering the same UI. Since the types of data obtained from different data sources may be different, data interfaces accessing different types of data need to be generated in advance to receive and process different types of data. When the data sources of the data to be assembled are different and the data types of at least two items of data to be assembled are different, the interfaces of different data types can be directly selected for data receiving and processing, and the original data interface does not need to be modified or redefined, so that decoupling of codes is realized, and the code reuse rate is improved.
In this embodiment of the application, before acquiring at least two items of data to be assembled through at least two data interfaces, the method further includes: defining a data transmission protocol; the parameters in the data transmission protocol are variable parameters, the parameter types are of any type, and the return value types are array types with variable lengths; defining an implementation class of the data transfer protocol to implement the data transfer protocol.
Illustratively, to achieve efficient reception and transmission of data to be assembled, a data transmission protocol may be predefined. Illustratively, a variable parameter is defined in the transmission protocol, and the observer monitors the received data, and when receiving the data to be assembled, the data to be assembled is packaged into a package object, and the returned value is the package object. When defining the data transmission protocol, the parameters are defined as variable parameters, so that any number of parameters can be received, and the expandability of the protocol is improved. The parameter type is defined as any type, such as any type or generic type, indicating that any number of any type of incoming parameter information can be received. The return value type is defined as a variable length array type to return an array of variable length data to be assembled. Because the data to be assembled is obtained from at least two data sources, and the data quantity and the data type of the at least two data sources are possibly different and difficult to be determined in advance, in the definition of the data transmission protocol, the parameters are set as variable parameters, the parameter type is set as any type, and the return value type is set as a variable-length data array type, so that the received data is not limited by the defined parameters. In addition, in order to enable the above protocol, an implementation class is defined, that is, a class is defined for a package object of data to be assembled. The above-described data transfer protocol is duplicated in the implementation class to perform implementation thereof.
In an embodiment of the present application, a data transmission protocol is defined, including: defining a package object of data to be assembled, wherein the package object comprises integer parameters and parameters of any type and is used as a bearing object of the data to be assembled.
For example, in a data transmission protocol, a package object of data to be assembled needs to be defined, so that the data to be assembled is packaged as an object for use. In order to be applicable to any type of data to be assembled, parameters in the package object are defined as parameters of integer type and parameters of any type as a carrying object of the data to be assembled.
In an embodiment of the present application, defining an implementation class of the data transmission protocol to implement the data transmission protocol includes: in the definition of the implementation class, the data transfer protocol is rewritten to implement the data transfer protocol.
Illustratively, for a data transfer protocol, an implementation class needs to be defined to implement the data transfer protocol. Since the implementation class inherits the data transfer protocol file, the data transfer protocol needs to be rewritten in the implementation class.
And S120, converting at least two items of data to be assembled into the data to be assembled of the same data type based on the data conversion function.
For example, since the data types of the data to be assembled obtained from different data sources may be different, and it is difficult to perform efficient and quick integration, before the data to be assembled is assembled, the data types of the data to be assembled need to be converted, and the data to be assembled of different types need to be converted into the same data type, so that the data to be assembled of the same data type can be assembled efficiently and orderly.
Specifically, the data transformation function may be a map function in which the input data of each data to be assembled is marked as a preset data type, for example, a videoplay bean, so that the method can transform the data to be assembled of the videoplay bean type. In each data conversion function, the data types of the returned data are set to be consistent, so that the data types of at least two data to be assembled after being converted by the data conversion function are ensured to be consistent.
And S130, assembling the data to be assembled of the same type to obtain a final result set.
Illustratively, for the same type of data to be assembled, a data adding method can be called for assembling, and at least two items of data to be assembled are assembled to a final result set, so as to realize unified management, avoid disorder and disorder of different data to be assembled and increase the application complexity. And outputting the final result set to a UI layer so as to directly render the UI by adopting the final result set, thereby reducing the rendering complexity and rendering cost of the UI, improving the rendering speed and efficiency, and reducing the code maintenance cost because the codes can be reused.
In the embodiment of the application, at least two items of data to be assembled are obtained through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data; converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function; and assembling the data to be assembled of the same type to obtain a final result set. According to the scheme, the data of the at least two data sources can be received through the data interfaces of different types under the condition of the at least two data sources, the data are converted into the data to be assembled of the same type, the data to be assembled of the one type are assembled, the problems that the UI rendering process is complex and the maintenance cost is high due to the fact that the data are disordered and difficult to manage under the condition of the at least two data sources are solved, and therefore the efficient and rapid assembly of the at least two data sources is achieved and output to a UI layer, the rendering cost of the UI rendering is reduced, the rendering speed is improved, and the maintenance cost of codes is reduced through multiplexing of the method.
Fig. 2 is a flowchart of a data assembling method according to another embodiment of the invention. In order to further optimize the embodiments, details which are not described in detail in the embodiments of the present application are described in the embodiments. Referring to fig. 2, a data assembling method provided in an embodiment of the present application may include:
and S210, calling a data interface acquisition method to acquire a data interface.
For example, since data interfaces for different types of data to be assembled are predefined, an obtaining method of the data interfaces may be called to obtain the data interfaces, so as to receive at least two items of data to be assembled and process the data by using the data interfaces.
S220, converting at least two items of data to be assembled into data to be assembled of the same data type based on the data conversion function in the data interface; and the data type of the input reference data in the data conversion function is consistent with the data type of the data to be assembled acquired by the data interface.
Illustratively, a data conversion function in the data interface is called, and the data to be assembled is input to the data conversion function, so that at least two items of data to be assembled are converted into the data to be assembled of the same data type. Because the data type of the input parameter data in the data conversion function is consistent with the data type of the data to be assembled acquired by the data interface, each conversion function can also convert the data to be assembled of different data types, so that at least two items of data to be assembled are converted into the same data type, and subsequent unified processing and assembly are facilitated.
And S230, judging whether the data to be assembled is empty or whether the quantity of the data to be assembled is zero. If yes, go to S240; if not, go to S250.
Illustratively, at least two items of data to be assembled received need to be added to the data result set for subsequent continued processing. At least two items of data to be assembled need to be legally checked before adding. Specifically, it is determined whether the data to be assembled is empty or whether the number of the data to be assembled is zero, so as to perform targeted processing.
And S240, assembling the null data and returning the null data.
Illustratively, if the data to be assembled is empty, or the number of data to be assembled is zero, the empty data is assembled, returned, and added to the data result set.
And S250, judging whether the data to be assembled is loaded for the first time, if so, executing S260-S270, and if not, executing S270.
And if the data to be assembled is not empty or the number of the data to be assembled is not zero, continuously judging whether the data to be assembled is loaded for the first time or not so as to carry out targeted processing on the data to be assembled which are loaded for the first time and are not loaded for the first time.
And S260, adding the element data information customized for the data to be assembled and the data to be assembled into a data result set.
Illustratively, if the data to be assembled is loaded for the first time, the element data information needs to be customized for the data to be assembled. The element data information may be defined according to actual conditions. For example, 10 pieces of data to be assembled are packaged, and a header and the like of the packaged data to be assembled are customized to adapt to a scene of a business function. And adding element data information self-defined for the data to be assembled and the data to be assembled to the data result set.
And S270, adding the data to be assembled to a data result set.
Illustratively, if the data to be assembled is not loaded for the first time, the data to be assembled is directly added to the data result set.
In this embodiment of the present application, if the data to be assembled is not loaded for the first time, adding the data to be assembled to a data result set includes: acquiring list data in the data to be assembled; and traversing the list data, and inserting one list data into the data result set in each traversal loop body.
Illustratively, list data is obtained from the data to be assembled, traversal is performed on the list data, and a piece of list data is inserted into the data result set in each traversal loop until all the list data are inserted into the data result set so as to wrap the list data for output.
And S280, assembling the data result set to obtain a final result set.
Illustratively, the data result set adding method is called to assemble at least two data result sets to obtain a final result set, and the final result set is output to the UI layer for rendering, so that effective assembly and management of at least two data to be assembled are realized, rendering efficiency is improved, and because the code is designed aiming at least two data sources, modification and change are not needed, and the code reuse rate is improved.
According to the scheme of the embodiment of the application, the data to be assembled of the same type is obtained by converting the at least two data to be assembled based on the data conversion function, so that the at least two data to be assembled of different types can be managed conveniently in the follow-up process. The data to be assembled are subjected to legality verification, the data to be assembled are null or zero in number, and whether the data to be assembled are loaded for the first time or not, so that the data to be assembled are added to the data result set in an efficient and orderly manner, the final result set is obtained through more efficient combination and used for UI rendering, the rendering complexity is reduced, and the rendering efficiency is improved.
The embodiment of the present application is a specific implementation flow of the data assembling method provided in the above embodiment, and the specific implementation flow is as follows:
the specific implementation manner in the embodiment of the application is suitable for assembling at least two data to be assembled of at least two data sources in Android, and the specific implementation method is as follows:
firstly, defining a data transmission protocol:
interface IRepository{fun requestData(vararg params:Any):Observable<MutableList<VMZItemWrapper>>}
the name of the protocol is IRepository, a parameter params with variable parameters is in the protocol function, the type is Any type, and the return value is a variable of Observable < MutableList < VMZItemWrapper >, wherein VMZItemWrapper is a self-defined class.
The beneficial effect of setting the parameters as variable parameters in the protocol definition is that any number of parameters can be accepted, thereby greatly improving the expandability of the protocol. The type of the parameter in the data transmission protocol is set as an type, which means that Any number and Any type of parameter information can be received. The return value type is an Observable type of data, wherein the Observable is internally a variable-length array type.
Vmzitwrapper in the data transfer protocol is a wrapped object of data, and the specific definition of the object is as follows:
class VMZItemWrapper(val type:Int,val data:Any){}
the name of the type is VMZItemWrapper, which contains a parameter type of an int type and a parameter data of an Any type, and is mainly a data bearing object.
In the embodiment of the present application, 2 data sources are taken as an example for description, and the same applies when the number of the data sources is other. Firstly, defining a protocol implementation class to implement a data transmission protocol, wherein the specific implementation class is defined as follows:
class PlayVodTaRepositoryNext:VMZContract.IRepository{}
since vmzcontact. hierarchy is inherited in the implementation class, the following method needs to be rewritten in the playdtareplosoryenxt class: override fun requestData (vararg params: Any): Observable < MutableList < VMZItemWrapper > > { }
Defining 2 methods for acquiring data observers in a PlayVodTaRapediitoryNext class, so that when at least two data sources exist, a single code does not need to be modified or rewritten, decoupling of the code can be realized, and the multiplexing rate of the code can be improved, and the specific definition is as follows:
Figure BDA0002917663120000101
Figure BDA0002917663120000111
the 2 methods are getTaApi and getrecormmendepi, respectively, the acquired data types are VideoPlayBean and VideoListBean types, respectively, both of the two types of data are different types of data, and the core logic of the 2 functions is to generate and return an api data interface for accessing different data. Specifically, in the definition of getTaApi, the role of observer is defined, and data of VideoPlayBean type is observed and monitored, where the observed object is dyhostappi. Similarly, in the getcorememdepai definition, the role of observer is defined, the data of VideoListBean type is observed and monitored, the observed object is dyhostappi.host _ URL _ MOBILE, and when the data of VideoListBean type is received, an instantiated object is returned through the getInstance function. The beneficial effect of the above scheme is that at least two observers for different types of data are defined (in the embodiment of the present application, two methods, namely getTaApi and getRecommendai, are taken as examples), so that the applicability of the api data interface is stronger, and different types of data of different data sources are observed and monitored, thereby avoiding the problems that when different data types of the data sources are different, the internal code logic of the observers needs to be changed, which leads to complicated program, increases the operation difficulty of technical personnel, wastes time, and thus improving the code reuse rate.
And aiming at least two data to be assembled, aligning and converting the data to be assembled of the same data type. For the convenience of conversion, the method is designed to be implemented as a function, and the specific function is defined as follows:
for a first set of data to be assembled: private fun getTabservable (reqplayVodWeban: ReqplayVodWeban) Observable < Mutabelist < VMZItemWrapper > > { }
The implementation logic of the above function is:
first, the api for data acquisition is acquired by calling the getTaApi (reqplayvodbean. offset, reqplayvodbean. limit, reqplayvodbean. orderBy) method, and since (offset: Int, limit: Int, orderBy: Int) is returned in the method for defining the api, (replayvodbean. offset, reqplayvodbean. limit, orderBy) of the object, that is, (replayvodbean. offset, reqplayvodbean. orderBy), index, length, and sort data representing the object are returned when the api is called. The data is then transformed by calling a map method in the api in which the parameter entry for each data is labeled videoPlayBean.
In order to store the converted result set, a local variable is defined to store the converted result, and the local variable is defined as follows:
val resultList:MutableList<VMZItemWrapper>=mutableListOf()
the result set is of the type MutableList < VMZItemWrapper > and is initialized.
And checking the legality of the parameter of the access parameter, wherein the specific checking logic is as follows:
if(videoPlayBean==null||videoPlayBean.count=="0")
if the data is null or the number is 0, then a null data can be directly assembled for returning, and the specific method for assembling the null data is as follows:
resultList.add(VMZItemWrapper(VMZItemType.TYPE_PLAY_VOD_EMPTY_TOP,""))
if the above conditions are not satisfied, it is necessary to determine whether the data to be assembled is loaded for the first time:
if(reqPlayVodBean.loadType==VMZContract.LOAD_TYPE_FIRST)
if the element data information is loaded for the first time, the element data information loaded for the first time needs to be added, and the specific assembly logic is as follows:
resultList.add(VMZItemWrapper(VMZItemType.TYPE_PLAY_VOD_COUNT_INFO,videoPlayBean.count))
if the loading is not the first time, the list element is required to be added into the result set at this time, and the specific adding method is as follows:
Figure BDA0002917663120000131
the method is characterized in that a forEach traversal function is defined, vodPlayRoomBean is defined object variables, list data in a VMZItemWrapper wrapping object is traversed, and result list. The method functions to traverse the received list of data to add each piece of data to the result set. A specific method of inserting data is resultlist.add (VMZItemWrapper (vmzitemtype. type _ PLAY _ VOD _ ROOM, vodPlayRoomBean)), where vmzitemtype. type _ PLAY _ VOD _ ROOM is a constant of int type, resultlist.add is a function of adding data to the result set, VMZItemWrapper is a wrapper object containing received data, vodPlayRoomBean is a defined object variable, and the method functions to add list data in VMZItemWrapper wrapper object to the result set.
Similarly, the definition and implementation of the second to-be-assembled data processing method are as follows:
Figure BDA0002917663120000141
similar to the first method for processing data to be assembled, the getTaApi (reqplayvodbean. offset, reqplayvodbean. limit, reqplayvodbean. orderBy) method is called to obtain the api obtained by data, and since (offset: Int, limit: Int, orderBy: Int) is returned in the method for defining the api, the (offset, limit, orderBy) of the object, i.e., (reqplayvodbean. offset, reqplayvodbean. limit, reqplayvodbean. orderBy) is returned when calling the api, indicating the index, length, and order data of the object. And then calling a map method in the api to convert the data, wherein the parameter of each data is marked as VideoListBean.
To store the translated result set, a local variable is therefore defined to store the translated result, the local variable being defined as follows:
val resultList:MutableList<VMZItemWrapper>=mutableListOf()
the result set is of the type MutableList < VMZItemWrapper > and is initialized.
And checking the legality of the parameter of the access parameter, wherein the specific checking logic is as follows:
if(vodListBean?.list!=null&&vodListBean.list.isNotEmpty());
if the data is null or the number is 0, then a null data can be directly assembled for returning, and the specific method for assembling the null data is as follows:
resultList.add(VMZItemWrapper(VMZItemType.TYPE_PLAY_VOD_EMPTY_TOP,""))
if the above conditions are not satisfied, it is necessary to determine whether the data to be assembled is loaded for the first time:
if(reqVideoListBean.loadType==VMZContract.LOAD_TYPE_FIRST)
if the element data information is loaded for the first time, the element data information loaded for the first time needs to be added, and the specific assembly logic is as follows:
resultList2.add(VMZItemWrapper(VMZItemType.TYPE_PLAY_VOD_RECO MMEND_ROOM,videoItemBean))
if the loading is not the first time, the list element is required to be added into the result set at this time, and the specific adding method is as follows:
Figure BDA0002917663120000161
wherein vmzitemtype, type _ PLAY _ VOD _ record _ ROOM is a constant of int type, resultlist2.add is a function of adding data to result set 2, VMZItemWrapper is a wrapped object containing received data, videoitemtbean is a defined object variable, the method functions to add list data in VMZItemWrapper wrapped object to result set 2.
After the conversion by the method, the data to be assembled acquired by the second data source and the data to be assembled acquired by the first data source are both of the Mutablelist < VMZItemWrapper > type.
The 2 data result sets are uniformly assembled, and the following specific implementation is as follows:
first, define a final result set object valresultFinal, MutableList < VMZItemWrapper > -MutableListOf ()
Then call resultfinal.addall (resultList) and call resultfinal.addall (resultList2) methods to assemble the 2 data result sets into a final result set, resultFinal, which is then returned to achieve a uniform logic of assembly of the entire set of data.
According to the scheme, the data of the at least two data sources can be received through the data interfaces of different types under the condition of the at least two data sources, the data are converted into the data to be assembled of the same type, the data to be assembled of the one type are assembled, the problems that the UI rendering process is complex and the maintenance cost is high due to the fact that the data are disordered and difficult to manage under the condition of the at least two data sources are solved, and therefore the efficient and rapid assembly of the at least two data sources is achieved and output to a UI layer, the rendering cost of the UI rendering is reduced, the rendering speed is improved, and the maintenance cost of codes is reduced through multiplexing of the method.
Fig. 3 is a schematic structural diagram of a data assembling apparatus according to an embodiment of the present invention. The apparatus may be adapted for use in the case of assembling data from at least two data sources. The apparatus may be implemented by software and/or hardware, and the apparatus may be integrated in an electronic device. Referring to fig. 3, the apparatus specifically includes:
the data acquisition module 310 is configured to acquire at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
the conversion module 320 is configured to convert at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function;
and the assembling module 330 is configured to assemble the same type of data to be assembled to obtain a final result set.
In an embodiment of the present application, the apparatus further includes:
the protocol definition module is used for defining a data transmission protocol; the parameters in the data transmission protocol are variable parameters, the parameter types are of any type, and the return value types are array types with variable lengths;
and the implementation class definition module is used for defining the implementation class of the data transmission protocol so as to realize the data transmission protocol.
In an embodiment of the present application, the protocol definition module includes:
and the parcel object determining unit is used for defining a parcel object of the data to be assembled, wherein the parcel object comprises an integer parameter and a parameter of any type and is used as a bearing object of the data to be assembled.
In an embodiment of the present application, the implementation class definition module includes:
and the protocol duplicating unit is used for duplicating the data transmission protocol in the definition of the implementation class so as to implement the data transmission protocol.
In an embodiment of the present application, the apparatus further includes:
the method calling module is used for calling the data interface acquisition method to acquire the data interface;
accordingly, the conversion module 320 includes:
the data conversion unit is used for converting at least two items of data to be assembled into data to be assembled of the same data type based on the data conversion function in the data interface; and the data type of the parameter data in the data conversion function is consistent with the data type of the data to be assembled acquired by the data interface.
In an embodiment of the present application, the apparatus further includes:
the return module is used for assembling the null data and returning the null data if the data to be assembled is null or the number of the data to be assembled is zero;
the loading judging module is used for judging whether the data to be assembled is loaded for the first time or not if the data to be assembled is not empty or the number of the data to be assembled is not zero;
the element data information adding module is used for adding element data information defined for the data to be assembled and the data to be assembled into a data result set if the data to be assembled is loaded for the first time;
and the data to be assembled adding module is used for adding the data to be assembled to the data result set if the data to be assembled is not loaded for the first time.
Correspondingly, the device further comprises: and the result set assembling module is used for assembling the data result set to obtain a final result set.
In this embodiment of the present application, the to-be-assembled data adding module includes:
the list data acquisition unit is used for acquiring list data in the data to be assembled;
and the inserting unit is used for traversing the list data and inserting one list data into the data result set in each traversal loop body.
The data assembling device provided by the embodiment of the application can execute the data assembling method provided by any embodiment of the application, and has corresponding functional modules and beneficial effects of the executing method.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. FIG. 4 illustrates a block diagram of an exemplary electronic device 412 suitable for use in implementing embodiments of the present application. The electronic device 412 shown in fig. 4 is only an example and should not bring any limitations to the function and the scope of use of the embodiments of the present application.
As shown in fig. 4, the electronic device 412 may include: one or more processors 416; the memory 428 is used for storing one or more programs, when the one or more programs are executed by the one or more processors 416, so that the one or more processors 416 implement the data assembling method provided by the embodiment of the present application, including:
acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function;
and assembling the data to be assembled of the same type to obtain a final result set.
The components of the electronic device 412 may include, but are not limited to: one or more processors or processors 416, a memory 428, and a bus 418 that couples the various device components including the memory 428 and the processors 416.
Bus 418 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 412 typically includes a variety of computer device-readable storage media. These storage media may be any available storage media that can be accessed by electronic device 412 and include both volatile and nonvolatile storage media, removable and non-removable storage media.
Memory 428 can include computer-device readable storage media in the form of volatile memory, such as Random Access Memory (RAM)430 and/or cache memory 432. The electronic device 412 may further include other removable/non-removable, volatile/nonvolatile computer device storage media. By way of example only, storage system 434 may be used to read from and write to non-removable, nonvolatile magnetic storage media (not shown in FIG. 4, commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical storage medium) may be provided. In these cases, each drive may be connected to bus 418 by one or more data storage media interfaces. Memory 428 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 440 having a set (at least one) of program modules 442 may be stored, for instance, in memory 428, such program modules 442 including, but not limited to, an operating device, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may include an implementation of a network environment. The program modules 442 generally perform the functions and/or methodologies of the described embodiments of the invention.
The electronic device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing device, display 424, etc.), one or more devices that enable a user to interact with the electronic device 412, and/or any device (e.g., network card, modem, etc.) that enables the electronic device 412 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 422. Also, the electronic device 412 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) through the network adapter 420. As shown in FIG. 4, network adapter 420 communicates with the other modules of electronic device 412 over bus 418. It should be appreciated that although not shown in FIG. 4, other hardware and/or software modules may be used in conjunction with the electronic device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID devices, tape drives, and data backup storage devices, among others.
The processor 416 executes various functional applications and data processing, such as implementing a data assembly method provided by embodiments of the present application, by executing at least one of the other programs stored in the memory 428.
One embodiment of the present invention provides a storage medium containing computer-executable instructions that when executed by a computer processor perform a data assembly method, comprising:
acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function;
and assembling the data to be assembled of the same type to obtain a final result set.
The computer storage media of the embodiments of the present application may take any combination of one or more computer-readable storage media. The computer readable storage medium may be a computer readable signal storage medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor device, apparatus, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having 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. In embodiments of the present application, a computer readable storage medium may be any tangible storage medium that can contain, or store a program for use by or in connection with an instruction execution apparatus, device, or apparatus.
A computer readable signal storage medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal storage medium may also be any computer readable storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution apparatus, device, or apparatus.
Program code embodied on a computer readable storage medium may be transmitted using any appropriate storage medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing description is only exemplary of the invention and that the principles of the technology may be employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method of data assembly, the method comprising:
acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function;
and assembling the data to be assembled of the same type to obtain a final result set.
2. The method of claim 1, wherein prior to obtaining at least two items of data to be assembled via at least two data interfaces, the method further comprises:
defining a data transmission protocol; the parameters in the data transmission protocol are variable parameters, the parameter types are of any type, and the return value types are array types with variable lengths;
defining an implementation class of the data transfer protocol to implement the data transfer protocol.
3. The method of claim 2, wherein defining a data transfer protocol comprises:
defining a package object of data to be assembled, wherein the package object comprises integer parameters and parameters of any type and is used as a bearing object of the data to be assembled.
4. The method of claim 2, wherein defining the implementation class of the data transfer protocol to implement the data transfer protocol comprises:
in the definition of the implementation class, the data transfer protocol is rewritten to implement the data transfer protocol.
5. The method of claim 1, wherein before converting at least two items of data to be assembled into data to be assembled of the same data type based on a data conversion function, the method further comprises:
calling a data interface acquisition method to acquire a data interface;
correspondingly, based on the data conversion function, converting at least two items of data to be assembled into data to be assembled of the same data type, including:
converting at least two items of data to be assembled into data to be assembled of the same data type based on the data conversion function in the data interface; and the data type of the parameter data in the data conversion function is consistent with the data type of the data to be assembled acquired by the data interface.
6. The method of claim 1, wherein at least two items of data to be assembled are converted into data to be assembled of the same data type based on the data conversion function in the data interface, and thereafter the method further comprises:
if the data to be assembled is empty or the number of the data to be assembled is zero, assembling the empty data and returning the empty data;
otherwise, judging whether the data to be assembled is loaded for the first time;
if the data to be assembled is loaded for the first time, adding element data information defined for the data to be assembled and the data to be assembled into a data result set;
and if the data to be assembled are not loaded for the first time, adding the data to be assembled to a data result set.
Correspondingly, assembling the data to be assembled of the same type to obtain a final result set, including:
and assembling the data result set to obtain a final result set.
7. The method of claim 6, wherein adding the data to be assembled to a data result set if the data to be assembled is not loaded for the first time comprises:
acquiring list data in the data to be assembled;
and traversing the list data, and inserting one list data into the data result set in each traversal loop body.
8. A data assembling apparatus, said apparatus comprising:
the data acquisition module is used for acquiring at least two items of data to be assembled through at least two data interfaces; the at least two data interfaces are pre-generated data interfaces for accessing different types of data;
the conversion module is used for converting at least two items of data to be assembled into data to be assembled of the same data type based on the data conversion function;
and the assembling module is used for assembling the data to be assembled of the same type to obtain a final result set.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a memory for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the data assembly method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out a data assembling method according to any one of claims 1-7.
CN202110105947.9A 2021-01-26 2021-01-26 Data assembling method, device, electronic equipment and medium Active CN114791840B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110105947.9A CN114791840B (en) 2021-01-26 2021-01-26 Data assembling method, device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110105947.9A CN114791840B (en) 2021-01-26 2021-01-26 Data assembling method, device, electronic equipment and medium

Publications (2)

Publication Number Publication Date
CN114791840A true CN114791840A (en) 2022-07-26
CN114791840B CN114791840B (en) 2023-09-22

Family

ID=82459901

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110105947.9A Active CN114791840B (en) 2021-01-26 2021-01-26 Data assembling method, device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN114791840B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070043759A1 (en) * 2005-08-19 2007-02-22 Bodin William K Method for data management and data rendering for disparate data types
CN108182233A (en) * 2017-12-27 2018-06-19 苏州麦迪斯顿医疗科技股份有限公司 A kind of distributed data abstracting method, device, computer equipment and storage medium
CN110263277A (en) * 2019-06-18 2019-09-20 广州虎牙科技有限公司 Display methods, update method, device, equipment and the storage medium of page data
CN110298784A (en) * 2019-06-27 2019-10-01 北京金山安全软件有限公司 Data conversion method and device and electronic equipment
CN110555073A (en) * 2019-09-10 2019-12-10 政采云有限公司 data processing method and device, electronic equipment and storage medium
CN110716952A (en) * 2019-09-24 2020-01-21 中国电子科技集团公司电子科学研究院 Multi-source heterogeneous data processing method and device and storage medium
CN111713097A (en) * 2019-04-22 2020-09-25 深圳市大疆创新科技有限公司 Image data processing method, transmission device and data interface conversion device
CN111949850A (en) * 2020-08-14 2020-11-17 北京锐安科技有限公司 Multi-source data acquisition method, device, equipment and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070043759A1 (en) * 2005-08-19 2007-02-22 Bodin William K Method for data management and data rendering for disparate data types
CN108182233A (en) * 2017-12-27 2018-06-19 苏州麦迪斯顿医疗科技股份有限公司 A kind of distributed data abstracting method, device, computer equipment and storage medium
CN111713097A (en) * 2019-04-22 2020-09-25 深圳市大疆创新科技有限公司 Image data processing method, transmission device and data interface conversion device
CN110263277A (en) * 2019-06-18 2019-09-20 广州虎牙科技有限公司 Display methods, update method, device, equipment and the storage medium of page data
CN110298784A (en) * 2019-06-27 2019-10-01 北京金山安全软件有限公司 Data conversion method and device and electronic equipment
CN110555073A (en) * 2019-09-10 2019-12-10 政采云有限公司 data processing method and device, electronic equipment and storage medium
CN110716952A (en) * 2019-09-24 2020-01-21 中国电子科技集团公司电子科学研究院 Multi-source heterogeneous data processing method and device and storage medium
CN111949850A (en) * 2020-08-14 2020-11-17 北京锐安科技有限公司 Multi-source data acquisition method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN114791840B (en) 2023-09-22

Similar Documents

Publication Publication Date Title
CN110764748B (en) Code calling method, device, terminal and storage medium
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
US8799469B2 (en) Subscriber message payload handling
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN111400760A (en) Method, device, server and storage medium for web application to access database
CN109033456B (en) Condition query method and device, electronic equipment and storage medium
CN112416303B (en) Software development kit hot repair method and device and electronic equipment
CN111767498B (en) Method and device for realizing file information sharing
CN112395437B (en) 3D model loading method and device, electronic equipment and storage medium
CN116628773A (en) Data processing method, device, electronic equipment and storage medium
CN114791840B (en) Data assembling method, device, electronic equipment and medium
CN113709171B (en) Method and device for cross-component state communication
CN113835748B (en) Packaging method, system and readable medium for application program based on HTML5
CN111459584B (en) Page rendering method and device and electronic equipment
CN116263690A (en) Method and device for virtual machine to read data from external system and relevant written data
CN114327404A (en) File processing method and device, electronic equipment and computer readable medium
CN109558375B (en) Optimized file storage method, storage medium, equipment and system
CN112306683A (en) Function hijacking method, device, medium and electronic equipment
CN113987471A (en) Executable file execution method and device, electronic equipment and computer readable medium
CN113760993A (en) Service data query method and device and electronic equipment
CN112464255A (en) Data processing method and device, storage medium and electronic equipment
CN112445820A (en) Data conversion method and device
CN114047922B (en) Transcoding method, device, medium and equipment for precompiled device
CN111562913B (en) Method, device and equipment for pre-creating view component and computer readable medium
CN109918209B (en) Method and equipment for communication between threads

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant