WO2022252791A1 - 数据传输方法、电子设备及计算机可读存储介质 - Google Patents

数据传输方法、电子设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2022252791A1
WO2022252791A1 PCT/CN2022/084522 CN2022084522W WO2022252791A1 WO 2022252791 A1 WO2022252791 A1 WO 2022252791A1 CN 2022084522 W CN2022084522 W CN 2022084522W WO 2022252791 A1 WO2022252791 A1 WO 2022252791A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
version
mapping
data
electronic device
Prior art date
Application number
PCT/CN2022/084522
Other languages
English (en)
French (fr)
Inventor
陈刚
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP22814838.3A priority Critical patent/EP4339796A1/en
Publication of WO2022252791A1 publication Critical patent/WO2022252791A1/zh

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/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • 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/23Updating
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the present application relates to the technical field of data processing, and in particular to a data transmission method, electronic equipment, and a computer-readable storage medium.
  • An electronic device can synchronize local data to another electronic device through data synchronization.
  • the data synchronization process is one piece of data synchronization, and the reading and writing process involves data format conversion, which takes a long time and the data synchronization speed is slow.
  • the data synchronization speed of the prior art is relatively slow.
  • Embodiments of the present application provide a data transmission method, an electronic device, and a computer-readable storage medium, which can increase a data synchronization speed.
  • the embodiment of the present application provides a cross-device data transmission method, which is applied to the second electronic device, and the method includes: receiving a first event from the first electronic device, the first event includes the first database version information, and the second A database version information is used to describe the database version of the second source database, the second source database is the local database of the first electronic device; according to the first database version information, create a first empty mapping database of the first source database, the first source The database is a local database of the second electronic device; the first source database and the first empty mapping database are virtualized to obtain the first virtual database; data mapping is performed in the first virtual database to convert the data in the first source database Mapping to the first empty mapping database to obtain the first database with data mapping completed; obtaining the first mapping database based on the first database; sending the first mapping database to the first electronic device.
  • the embodiment of the present application maps the database as a whole to the peer device, realizes data synchronization at the database level, does not involve data format conversion, reduces time-consuming data synchronization, improves data synchronization speed, and makes data available faster faster.
  • the first mapping database is obtained based on the first database, including:
  • the second database version information is used to describe the database version of the first source database
  • the version of the first source database is higher than the version of the second source database, the version of the first database is downgraded to obtain the first mapping database, and the version of the first mapping database is consistent with the version of the second source database;
  • the first database is used as the first mapping database, and the version of the first mapping database is consistent with the version of the first source database.
  • the embodiment of the present application will downgrade the version accordingly based on the database versions of the two electronic devices, so that the database level synchronization method of the embodiment of the present application
  • the scope of application is wider.
  • the version of the first empty mapping database when the version of the first source database is higher than the version of the second source database, the version of the first empty mapping database is consistent with the version of the first source database, and the version of the first empty mapping database
  • the table structure is consistent with the table structure of the second source database
  • the version of the first source database is lower than the version of the second source database
  • the version of the first empty mapping database is consistent with the version of the first source database
  • the table structure of the first empty mapping database is consistent with the table structure of the first source database
  • the method further includes:
  • the second mapping database from the first electronic device is received, and the second mapping database is a mapping database of the second source database established by the first electronic device according to the second database version information.
  • both the first electronic device and the second electronic device can synchronize the local database as a whole to the peer device.
  • the method after receiving the second mapping database from the first electronic device, the method further includes:
  • the second mapping database and the first source database are virtualized to obtain a second virtual database
  • the second mapping database is upgraded to obtain the upgraded second mapping database, and the version of the upgraded second mapping database is consistent with the version of the first source database ;
  • the upgraded second mapping database and the first source database are virtualized to obtain a second virtual database.
  • virtualization is performed based on the first source database and the second mapping database to obtain a virtualized database, without synchronizing the data in the two databases one by one, thereby further increasing the speed of data synchronization.
  • the second virtual database includes the first source database and the second mapping database which are independent of each other.
  • virtualizing the two databases into one virtual database can facilitate subsequent cross-device data fusion access.
  • the method further includes:
  • the first data access request includes the device identifier of the first electronic device, query the second mapping database in the second virtual database, obtain the first query result, and return the first query result to the first application;
  • the first data access request does not include the device identifier, query the second mapping database and the first source database in the second virtual database, obtain a second query result, and return the second query result to the first application;
  • the first data access request includes the device identifier of the second electronic device, query the first source database in the second virtual database, obtain a third query result, and return the third query result to the first application.
  • the second electronic device pre-maps the local database of the first electronic device to the local storage space, so that when accessing the data of the first electronic device, it can be accessed like a local database, that is, providing cross-device access similar to local databases data access.
  • the process from the initiation of the access request to the obtaining of the query result does not involve processes such as linking to the remote database, data return from the remote database, etc., and the query speed is not affected by the quality of network transmission. The time is shorter, which in turn makes cross-device data access performance higher.
  • the second electronic device virtualizes the local database and the mapping data database of the peer device into one database, and can query and filter the data of multiple devices through a single query request, realizing cross-device data fusion access.
  • the database is mapped to the peer device as a whole, which reduces the time-consuming data synchronization, improves the speed of data availability, and further improves the performance of data fusion access.
  • the method further includes:
  • the first change script including a table for recording change data of the second source database
  • the first change script is upgraded to obtain the upgraded first change script, and the table structure of the upgraded first change script is consistent with the table structure of the first source database Consistent structure;
  • the changed data of the second source database is loaded into the second mapping database by executing the first change script.
  • the method further includes:
  • the first data state tree determine whether the data in the first source database is changed, and the first data state tree is used to describe the state of the data mapped to the first empty mapping database in the first source database;
  • the changed data in the first source data is recorded in the second change script, and the second change script includes a table for recording the changed data;
  • the table structure of the second change script is consistent with the table structure of the second source database
  • the table structure of the second change script is consistent with the table structure of the first source database.
  • the data status information is recorded during data mapping, and based on the data status information, it is monitored in real time whether the data is found to be changed. When the data is found to be changed, the changed data is synchronized to the peer device based on the data status information.
  • Device data status management realizing real-time query of cross-device data.
  • the method further includes:
  • the embodiment of the present application provides a cross-device data transmission method, which is applied to the first electronic device, and the method includes:
  • the first event includes first database version information
  • the first database version information is used to describe the database version of the second source database
  • the second source database is a local database of the first electronic device
  • the first mapping database is the mapping database of the first source database established by the second electronic device according to the first database version information, and the first source database is the local database of the second electronic device.
  • the method after receiving the first mapping database from the second electronic device, the method further includes:
  • the first mapping database is upgraded to obtain the upgraded first mapping database, and the version of the upgraded first mapping database is consistent with the version of the second source database ;
  • the upgraded first mapping database and the second source database are virtualized to obtain a third virtual database.
  • the method further includes:
  • the second data access request includes the device identifier of the first electronic device, query the second source database in the third virtual database to obtain a fourth query result, and return the fourth query result to the second application;
  • the second data access request does not include the device identifier, query the first mapping database and the second source database in the third virtual database, obtain a fifth query result, and return the fifth query result to the second application;
  • the second data access request includes the device identifier of the second electronic device, query the first mapping database in the third virtual database to obtain a sixth query result, and return the sixth query result to the second application.
  • the method after receiving the first mapping database from the second electronic device, the method further includes:
  • the second change script including a table for recording change data of the first source database
  • the second change script is upgraded to obtain the upgraded second change script, and the table structure of the upgraded second change script is consistent with the table structure of the second source database. Consistent structure
  • the changed data of the first source database is loaded into the first mapping database by executing the second change script.
  • the method further includes:
  • the second electronic device receiving a second event from the second electronic device, the second event including second database version information, the second database version information is used to describe the database version of the first source database;
  • the second mapping database is sent to the second electronic device.
  • the second mapping database is obtained based on the second database, including:
  • the version of the first source database is lower than or equal to the version of the second source database, the version of the second database is downgraded to obtain the second mapping database, and the version of the second mapping database is consistent with the version of the first source database;
  • the second database is used as the first mapping database, and the version of the second mapping database is consistent with the version of the second source database.
  • the version of the second empty mapping database when the version of the first source database is lower than the version of the second source database, the version of the second empty mapping database is consistent with the version of the second source database, and the version of the second empty mapping database
  • the table structure is consistent with the table structure of the first source database
  • the version of the first source database is higher than the version of the second source database
  • the version of the second empty mapping database is consistent with the version of the second source database
  • the table structure of the second empty mapping database is consistent with the table structure of the second source database
  • the second data state tree determine whether the data in the second source database is changed, and the second data state tree is used to describe the state of the data mapped to the second empty mapping database in the second source database;
  • the first change script includes a table for recording the changed data
  • the table structure of the first change script is consistent with the table structure of the first source database
  • the table structure of the first change script is consistent with the table structure of the second source database.
  • the embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and operable on the processor.
  • the processor executes the computer program, the above-mentioned first aspect or second A method for any of the aspects.
  • an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of the first aspect or the second aspect above is implemented.
  • the embodiment of the present application provides a chip system, the chip system includes a processor, the processor is coupled with the memory, and the processor executes the computer program stored in the memory, so as to realize any one of the first aspect or the second aspect. method described in the item.
  • the chip system can be a single chip, or a chip module composed of multiple chips.
  • an embodiment of the present application provides a computer program product, which, when the computer program product is run on an electronic device, causes the electronic device to execute the method described in any one of the first aspect or the second aspect.
  • FIG. 1 is a schematic block diagram of a system architecture provided by an embodiment of the present application
  • FIG. 2 is a specific schematic diagram of the system architecture provided by the embodiment of the present application.
  • FIG. 3 is a schematic flow diagram of a data mapping process provided by an embodiment of the present application.
  • FIG. 4 is a schematic flow diagram of a database mapping mode provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of database mapping when the database versions provided by the embodiment of the present application are the same;
  • FIG. 6 is a schematic diagram of database mapping from a high version to a low version provided in the embodiment of the present application.
  • FIG. 7 is a schematic diagram of database mapping from a low version to a high version provided in the embodiment of the present application.
  • FIG. 8 is a schematic flow diagram of a database mapping mode provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a table mapping process provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of the data change monitoring process provided by the embodiment of the present application.
  • Fig. 11 is a schematic diagram of the data change monitoring process for synchronizing the high version to the low version provided by the embodiment of the present application;
  • FIG. 12 is a schematic diagram of the data change monitoring process for synchronizing the lower version to the higher version provided by the embodiment of the present application;
  • FIG. 13 is a schematic flow diagram of a data fusion access process provided by an embodiment of the present application.
  • FIG. 14 is a schematic diagram of cross-device media data fusion access provided by the embodiment of the present application.
  • FIG. 15 is a schematic diagram of cross-device access to image data provided by an embodiment of the present application.
  • FIG. 16 is a schematic diagram of cross-device image search provided by the embodiment of the present application.
  • FIG. 17 is a schematic diagram of data fusion access in the database mapping mode provided by the embodiment of the present application.
  • FIG. 18 is a schematic diagram of data fusion access in the table mapping mode provided by the embodiment of the present application.
  • FIG. 19 is a schematic diagram of a database mapping mode based on distributed data middleware provided by the embodiment of the present application.
  • FIG. 20 is a schematic diagram of a table mapping mode based on distributed data middleware provided by the embodiment of the present application.
  • FIG. 21 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the system may include a first electronic device 11 and at least one second electronic device 12 .
  • the first electronic device 11 and the second electronic device 12 can communicate with each other through a communication connection.
  • the communication connection between the first electronic device 11 and the second electronic device 12 can be a short-distance communication connection, such as Wi-Fi point-to-point connection and Bluetooth connection, etc.; it can also be a long-distance communication connection, such as an Internet connection, here
  • the specific type of communication connection is not limited.
  • the first electronic device 11 may be a terminal device such as a mobile phone, a tablet computer, or a notebook computer, or may be a non-terminal device such as a server.
  • the second electronic device 12 may be a terminal device such as a mobile phone, a tablet computer, or a notebook computer, or may be a non-terminal device such as a server.
  • the embodiment of the present application does not limit the device types of the first electronic device 11 and the second electronic device 12 .
  • the system includes a mobile phone 21 , a mobile phone 22 , a tablet 23 and a cloud server 24 .
  • the first electronic device is specifically a mobile phone 21
  • the second electronic device includes a mobile phone 22 , a tablet 23 and a cloud server 24 .
  • the communication connection between the mobile phone 21 and the mobile phone 22 can be a Wi-Fi point-to-point connection
  • the communication connection between the mobile phone 21 and the tablet 23 can be a Wi-Fi point-to-point connection
  • the communication connection between the mobile phone 21 and the cloud server 24 can be for internet connection.
  • the first electronic device 11 can map the data of the second electronic device 12 to a local storage space, so that the first electronic device 11 can store locally Spatial access to the data of the second electronic device 12 realizes cross-device data fusion access.
  • the second electronic device 12 can also map the data of the first electronic device 11 to the local storage space, so as to realize cross-device data fusion access.
  • the data fusion access means that through one query request, the data of multiple electronic devices can be filtered, sorted, and so on.
  • the first electronic device 11 maps the database of the second electronic device 12 to a local storage space, and virtualizes the database of the first electronic device 12 and the local database to obtain a virtual database. Based on the virtual database, the first electronic device 11 can access the data of the first electronic device 11 and the data of the second electronic device 12 from the virtual database through a query request, and filter, sort, etc. the data of the two devices , get the query result.
  • Data accessed across devices may be media data, such as video, audio, and pictures, or other types of data, and this embodiment of the present application does not limit the type of data accessed across devices.
  • the user can browse or search for pictures stored on any electronic device on the mobile phone 22 , tablet 23 , and cloud server 24 in the gallery on the mobile phone 21 .
  • the technical solutions provided by the embodiments of the present application may include a data mapping process, a data change monitoring process, and a data fusion accessing process.
  • the embodiments of the present application map the database or database tables as a whole to the peer device, so as to realize data synchronization at the database level or file level.
  • the data mapping process of the embodiment of the present application can improve the data synchronization speed, and the data availability speed is faster.
  • the ordinary data synchronization process is to synchronize data one by one, and the reading and writing process involves data format conversion, which takes a long time and the data synchronization speed is slow.
  • the first electronic device reads the data of the second electronic device one by one, and writes the read data locally, and format conversion is required during the read and write process.
  • the data mapping process of the embodiment of the present application realizes data synchronization at the database level or file level, does not involve data format conversion, reduces data synchronization time, improves data synchronization speed, and makes data available faster.
  • the data of the second electronic device is mapped to the first electronic device in a very short time, so that the data of the second electronic device can be
  • the data is available at a fast speed and realizes plug-and-play, that is, as soon as the second electronic device is online, the first electronic device can locally access the data of the second electronic device.
  • the data mapping process of the embodiment of the present application improves the data synchronization speed, the cross-device data fusion access performance is further improved.
  • the method may include the following steps:
  • Step S301 the first electronic device sends a first event to the second electronic device.
  • the above-mentioned first event may include but not limited to device information and database version information of the first electronic device.
  • the device information of the first electronic device includes, but is not limited to, the device type, device identifier, and Internet Protocol Address (Internet Protocol Address, IP).
  • the database version information of the first electronic device is used to describe information such as the version number (ie version code) of the local database of the first electronic device.
  • the first event may include database version information, while in other embodiments, the first event may not include database version information.
  • the above-mentioned first event can be expressed as a device online event, that is, after the first electronic device and the second electronic device establish a communication connection, in order to map the data of the second electronic device to the local, the first electronic device can send the device Live event.
  • the mobile phone sends a device online event to the tablet, or the mobile phone is connected to a wireless router, and after the tablet is connected to the same wireless router, the mobile phone Send a device online event to the tablet.
  • the first event is not limited to the device going online event, it may be other events that can play the same role, and the time point when the first electronic device sends the first event is not limited to after the device goes online.
  • Step S302 the second electronic device sends a second event to the first electronic device.
  • the above-mentioned second event may include but not limited to device information and database version information of the second electronic device.
  • the device information of the second electronic device includes, but is not limited to, the device type, device identifier, and IP address.
  • the database version information of the second electronic device is used to describe information such as the version number of the local database of the second electronic device. In some cases, the second event may also not include database version information.
  • the above-mentioned second event can be expressed as a device online event, that is, after the first electronic device and the second electronic device establish a communication connection, in order to map the data of the first electronic device to the local, the second electronic device can send a device Live event.
  • the second event is not limited to the device going online event, and may be other types of events.
  • the time point at which the second electronic device sends the second event is not limited to after the device goes online.
  • step S301 the execution sequence between the above step S301 and step S302 may be arbitrary.
  • Step S303 the second electronic device creates a first mapping data set of the first source data set according to the first event.
  • the first source data set refers to a local data set of the second electronic device, which may specifically be a database or a database table.
  • the first mapping data set is correspondingly a mapping database of the local database;
  • the first mapping data set is correspondingly a mapping table of the local database table.
  • Step S304 the second electronic device sends the first mapping data set to the first electronic device.
  • the first electronic device may virtualize the first mapping data set and the local database into a virtual database, so as to facilitate subsequent data fusion access.
  • the first mapping data set and the local data set may not be virtualized into a virtual database.
  • the first electronic device may load the first mapping data set into the intermediate result database.
  • the first electronic device After receiving the first mapping data set, the first electronic device can associate the device information of the second electronic device with the first mapping data set, so that the first mapping data set can be queried through the device information of the second electronic device.
  • Step S305 the first electronic device creates a second mapping data set of the second source data set according to the second event.
  • the above-mentioned second source data set refers to a local data set of the first electronic device, which may be a database or a database table.
  • the second mapping data set is a mapping database of the local database; when the first source data set is a local database table, the second mapping data set is a mapping table of the local database table.
  • Step S306 the first electronic device sends the second mapping data set to the second electronic device.
  • the second electronic device may virtualize the second mapping data set and the local database into a virtual database, so as to realize data fusion access.
  • the second mapped data set and the local data set may not be virtualized into a virtual database.
  • the second electronic device may load the second mapping data set into the intermediate result database.
  • the second electronic device After receiving the second mapping data set, the second electronic device can associate the device information of the first electronic device with the second mapping data set, so that the second mapping data set can be queried through the device information of the first electronic device.
  • Fig. 3 shows the process of the second electronic device mapping the local data set to the first electronic device, specifically including step S301, step S303 and step S304; it also shows that the first electronic device maps the local data set to the second electronic device
  • the process of the device specifically includes step S302, step S305 and step S306. That is to say, in some embodiments, the data mapping process of the embodiment of the present application may include a process in which the second electronic device maps the local data set to the first electronic device, and the first electronic device maps the local data set to the second electronic device. Electronic device process.
  • the data mapping process may only include the process of the second electronic device mapping the local data set to the first electronic device, that is, the first electronic device maps the data set of the second electronic device to the local The data set is mapped to the second electronic device; it may also only include the process of the first electronic device mapping the local data set to the second electronic device.
  • the embodiment of the present application maps the database or database table as a whole to the peer device, realizes data synchronization at the database level or file level, reduces the time-consuming data synchronization, makes data available faster, and further improves cross-device data fusion access performance.
  • the data mapping process can be divided into a database mapping process or a table mapping process.
  • the data mapping process is a database mapping process, also known as the database mapping mode;
  • the mapping data set established by the first electronic device or the second electronic device A collection is a mapping database table, and the data mapping process is a table mapping process, also known as a table mapping mode.
  • FIG. 4 is a schematic flow diagram of the database mapping mode provided by the embodiment of the present application, the flow may include the following steps:
  • Step S401 the first electronic device sends a first event to the second electronic device.
  • Step S402 the second electronic device creates a first empty mapping database of the first source database according to the database version information in the first event.
  • the first source data set is specifically the first source database, which is the local database of the second electronic device, and the above-mentioned first empty mapping database refers to an empty database that has not been loaded with data, and is still an empty database.
  • the second electronic device compares the database version of the first electronic device with the database version of the second electronic device.
  • the version of the first empty mapping database is consistent with the version of the first source database, and the table structure of the first empty mapping database is the same as that of the first source database The table structure is consistent.
  • the version of the first empty mapping database is consistent with the version of the first source database, and the table structure in the first empty mapping database is the same as that of the first source database.
  • the table structure of the local database of an electronic device is consistent.
  • the high-version database can know the table structure information of the low-version database, so the second electronic device can know the table structure information of the database of the first electronic device.
  • Step S403 the second electronic device virtualizes the first source database and the first empty mapping database to obtain a first virtual database.
  • Step S404 the second electronic device performs data mapping in the first virtual database, so as to map the data in the first source database to the first empty mapping database, and obtain a mapped mapping database.
  • the table structure in the first empty mapping database is consistent with the table structure of the local database of the first electronic device, so during data mapping according to The table structure of the local database of the first electronic device filters the data.
  • Step S405 the second electronic device obtains the first mapping database based on the mapped mapping database.
  • the first mapping data set is specifically the first mapping database.
  • the second electronic device uses the mapped database as the first set of mapped data.
  • the second electronic device will downgrade the database version of the mapped database to obtain the first mapped database, the version of the first mapped database and the version of the first electronic device
  • the version of the local database is the same.
  • Step S406 the first electronic device receives the first mapping database from the second electronic device.
  • the version of the first mapping database is consistent with the version of the local database of the first electronic device, and the table structure is also consistent with that of the local database of the first electronic device.
  • the table structures are consistent.
  • the first electronic device may virtualize the first mapping database and the local database to obtain the third virtual database.
  • the version of the first mapping database is consistent with the version of the first source database of the second electronic device, and the table structure is also the same as that of the first source database of the second electronic device.
  • the table structures of the source databases are consistent.
  • the first electronic device needs to upgrade the version of the first mapping database to obtain an upgraded mapping database.
  • the version of the upgraded mapping database is consistent with the version of the local database of the first electronic device, and the table structure is also consistent with the table structure of the local database of the first electronic device.
  • the first electronic device virtualizes the version-upgraded mapping database and the local database to obtain a third virtual database.
  • the first electronic device can merge and access the data of the second electronic device across devices.
  • the first electronic device may associate the device information of the second electronic device with the first mapping database.
  • mapping database and the local source database can be realized without data fusion one by one.
  • data fusion can be realized without data fusion one by one.
  • the step of virtualizing the mapping database and the local source database may not be performed.
  • the first mapping database and the first virtual database in the second electronic device exist temporarily. Specifically, after the second electronic device sends the first mapping database to the first electronic device, it can be stored in the local cache Clear the first mapping database. Similarly, after performing data version downgrade on the mapped database, the second electronic device may also clear the mapped database in the local cache. After mapping the data in the first source database to the first empty mapped database, the second electronic device may revoke the first virtual database.
  • the database mapping process maps the database as a whole to the peer device, which reduces the time-consuming data synchronization, improves the speed of data availability, and improves the performance of cross-device data fusion access.
  • FIG. 5 is a schematic diagram of database mapping when the database versions provided by the embodiment of the present application are the same
  • FIG. 6 is a schematic diagram of database mapping from a high version to a low version provided by the embodiment of the present application
  • the second electronic device 52 includes a source database 53 and a mapping database 54
  • the first electronic device 51 includes a mapping database 54 and a target database 55 .
  • the database versions and table structures of the first electronic device 51 and the second electronic device 52 are the same, that is, the versions of the source database 53 and the target database 55 are the same, and the table structures are the same.
  • the above-mentioned first source data set is specifically the source database 53
  • the first mapping data set is specifically the mapping database 54 .
  • the local database of the first electronic device is the target database 55 .
  • the second electronic device 52 After receiving the first event from the first electronic device 51 , the second electronic device 52 creates a first empty mapping database of the source database 53 .
  • the table structure of the first empty mapping database is consistent with the table structure of the target database 53, and the database version is consistent with the version of the source database 53; then, the first empty mapping database and the source database 53 are virtualized to obtain the first virtual database, And perform fast data mapping in the first virtual database, and map the data of the source database 53 to the first empty mapping database to obtain the mapping database 54; finally, transmit the mapping database 54 to the first electronic device 51.
  • the first electronic device 51 After receiving the mapping database 54, the first electronic device 51 virtualizes the mapping database 54 and the target database 55 to obtain a third virtual database.
  • the second electronic device 52 may transmit the database file of the mapping database 54 to the first electronic device 51 , and may also transmit the data of the mapping database 54 to the first electronic device 51 .
  • the second electronic device 52 performs data mapping on the first virtual database, and after obtaining the mapping database 54, the first virtual database can be revoked, and after sending the mapping database 54 to the first electronic device 51, it can be cached locally Clear the mapping database 54 in.
  • the database version of the second electronic device 62 is higher than that of the first electronic device 61 , that is, the version of the source database 63 is higher than that of the target database 66 .
  • the second electronic device 62 includes a source database 63 , a mapping database 64 and a mapping database 65
  • the first electronic device 61 includes a mapping database 65 and a target database 66 .
  • the above-mentioned first source data set is specifically the source database 63
  • the mapped mapping database is specifically the mapping database 64
  • the first mapping data set is specifically the mapping database 65
  • the local database of the first electronic device is the target database 66 .
  • the second electronic device 62 After the second electronic device 62 receives the first event from the first electronic device 61, according to the database version information in the first event, it is determined that the version of the source database 63 is higher than the version of the target database 66, and based on the database version of the target database 66 Version information, know the table structure information of target database 66; Then, create the first empty mapping database of source database 63, at this moment, the version of the first empty mapping database is consistent with the version of source database 63, table structure and target database 66 The table structure is consistent.
  • mapping database 64 The version of the mapping database 64 is consistent with that of the source database 63 , and the table structure is consistent with that of the target database 66 .
  • the second electronic device 62 downgrades the version of the mapping database 64 to obtain a mapping database 65 .
  • the version of the mapping database 65 is consistent with that of the target database 66
  • the table structure is consistent with that of the target database 66 .
  • the second electronic device 62 transmits the mapping database 65 to the first electronic device 61 .
  • the first electronic device 61 After receiving the mapping database 65, the first electronic device 61 virtualizes the mapping database 65 and the target database 66 to obtain a third virtual database.
  • the second electronic device 62 after the second electronic device 62 performs data mapping to obtain the mapping database 64, it can revoke the first virtual database; after performing version downgrade to obtain the mapping database 65, it can clear the mapping database 64 in the local cache; After sending the mapping database 65 to the first electronic device 61, the mapping database 65 may be cleared in the local cache.
  • the database version of the first electronic device 71 is higher than that of the second electronic device 72 , that is, the version of the target database 76 is higher than that of the source database 73 .
  • the first electronic device 71 includes a target database 76 , a mapping database 75 and a mapping database 74
  • the second electronic device 72 includes a source database 73 and a mapping database 74 .
  • the above-mentioned first source data set is specifically the source database 73
  • the mapped mapping database and the first mapping data set are both specifically the mapping database 74
  • the local database of the first electronic device is the target database 76 .
  • the second electronic device 72 After the second electronic device 72 receives the first event of the first electronic device 71, according to the database version information in the first event, determine that the version of the target database 76 is higher than the version of the source database 73; then, create the first event of the source database 73 An empty mapping database, the version of the first empty mapping database is consistent with the version of the source database 73, and the table structure is consistent with the table structure of the source database 73; then, the first empty mapping database and the source database 73 are virtualized to obtain the first A virtual database, and fast data mapping is performed on the first virtual database to obtain a mapping database 74 .
  • the version of the mapping database 74 is consistent with that of the source database 73 , and the table structure is consistent with that of the source database 73 ; finally, the second electronic device 72 transmits the mapping database 74 to the first electronic device 71 .
  • the first electronic device 71 After receiving the mapping database 74 , the first electronic device 71 upgrades the database version of the mapping database 74 to obtain a mapping database 75 .
  • the version of the mapping database 75 is consistent with the version of the target database 76, and the table structure is consistent with the table structure of the target database 76. Then, the first electronic device 71 virtualizes the mapping database 75 and the target database 76 to obtain a third virtual database.
  • the second electronic device 72 after the second electronic device 72 performs data mapping and obtains the mapping database 74, it can revoke the first virtual database; after sending the mapping database 74 to the first electronic device 71, it can clear the mapping database in the local cache 74.
  • the first electronic device 71 after the first electronic device 71 performs version upgrade to obtain the mapping database 75, it may clear the mapping database 74 in the local cache.
  • the embodiment of the present application provides the database mapping process when the table structure between devices is the same (that is, the database version is the same), and the database mapping process when the table structure between devices is different (that is, the database version is different), so that even if the table structure between devices At the same time, database mapping can still be realized, and the application range is wider.
  • the above shows the specific process for the second electronic device to establish the first mapping data set of the first source data set according to the first event of the first electronic device. event, the process of establishing the second mapping data set of the second source data set is introduced.
  • FIG. 8 is a schematic flow diagram of the database mapping mode provided by the embodiment of the present application, the flow may include the following steps:
  • Step S801 the second electronic device sends a second event to the first electronic device.
  • Step S802 the first electronic device creates a second empty mapping database of the second source database according to the database version information in the second event.
  • the second source database refers to the local database of the first electronic device.
  • the database version information included in the second event is used to describe the version of the local database of the second electronic device.
  • the second hole mapping database refers to an empty database, with no data loaded yet.
  • Step S803 the first electronic device virtualizes the second source database and the second empty mapping database to obtain a fourth virtual database.
  • Step S804 the first electronic device performs data mapping in the fourth virtual database, so as to map the data in the second source database to the second empty mapping database, and obtain a mapped mapping database.
  • Step S805 the first electronic device obtains a second mapping database based on the mapped database.
  • Step S806 the first electronic device sends the second mapping database to the second electronic device.
  • the second electronic device may perform virtualization according to the second mapping database and the second source database to obtain a third virtual database. Based on the third virtual database, the second electronic device can merge and access the data of the first electronic device across devices.
  • the table mapping process may include the following steps:
  • Step S901 the first electronic device sends a first event to the second electronic device.
  • the first event may not include the database version information.
  • Step S902 the second electronic device creates a first mapping table of the first source table according to the first event.
  • the first source data set is specifically the first source table
  • the first mapping data set is specifically the first mapping table.
  • the first source table refers to a database table in the local database of the second electronic device.
  • the second electronic device maps the data content of the first source table to the first mapping table, it may not consider whether the structures of the first mapping table and the first source table are the same.
  • Step S903 the second electronic device sends the first mapping table to the first electronic device.
  • Step S904 the second electronic device sends a second event to the first electronic device.
  • the first electronic device may not need to consider the database version when creating the second mapping table, therefore, the second event may not include database version information.
  • Step S905 the first electronic device creates a second mapping table of the second source table according to the two events.
  • the above-mentioned second source data set is specifically the second source table
  • the above-mentioned second mapping data set is specifically the second mapping table.
  • the second source table refers to a database table in the local database of the first electronic device.
  • the structure of the second mapping table is consistent with the structure of the second source table.
  • the first electronic device maps the data content of the second source table to the second mapping table, it may not consider whether the structures of the second mapping table and the second source table are the same.
  • Step S906 the first electronic device sends the second mapping table to the second electronic device.
  • the first electronic device may associate the device information of the second electronic device with the first mapping table.
  • the second electronic device may associate the device information of the first electronic device with the second mapping table.
  • mapping the database table as a whole to the peer device realizes data synchronization at the database table level, reduces the time-consuming data synchronization, and improves the speed of data availability.
  • the first electronic device or the second electronic device can create an intermediate result database, load the mapping table of the peer device into the intermediate result database, and load the local mapping table into the intermediate result database.
  • the intermediate result database so that the data of multiple devices can be accessed from the intermediate result database through one query.
  • the first electronic device may create a mapping table of the local database table.
  • the first electronic device sends the first event to the second electronic device to create an intermediate result database; after receiving the first mapping table from the second electronic device, load the first mapping table and the mapping table of the local database table into the created The intermediate result database.
  • the application program on the first electronic device can access the data of the first electronic device and the data of the second electronic device from the intermediate result database through a query request.
  • the second electronic device can create a mapping table of the local database table, send a second event to the first electronic device, and create an intermediate result database; after receiving the second mapping table from the first electronic device , loading the second mapping table and the mapping table of the local database table into the created intermediate result database.
  • the application program on the second electronic device can access the data of the first electronic device and the data of the second electronic device from the intermediate result database through a query request.
  • database-level and database-table-level data mapping synchronization solutions provided in the embodiments of the present application can be applied to data fusion access scenarios, and can also be applied to other scenarios.
  • the first electronic device or the second electronic device can monitor the data change information of the peer device in real time, and after receiving the data change information of the peer device, change the The data is loaded into the mapping data set of the peer device in the local storage space.
  • FIG. 10 Refer to a schematic diagram of the data change monitoring process provided by the embodiment of the present application shown in FIG. 10, which may include the following steps:
  • Step S1001 the second electronic device monitors whether local data is changed based on the data state information.
  • the above data status information is created by the second electronic device during execution of the data mapping.
  • the second electronic device when the second electronic device performs data mapping in the first virtual database, it records data status information.
  • the data state information is used to describe the state of the data mapped to the peer device, which may specifically be a data state tree.
  • the second electronic device Based on the data status information, the second electronic device compares the data at the current moment with the data status recorded in the data status information, and determines whether the data at the current moment has changed compared with the data previously mapped to the first electronic device.
  • Step S1002 When the monitored data is changed, the second electronic device generates data change information.
  • the second electronic device If it is determined that the data is changed, the second electronic device generates data change information according to the changed data.
  • the data change information is used to describe changed data.
  • the second electronic device may also modify the data state information, that is, update the state record about the changed data in the data state information according to the changed data.
  • the modified data status information can be used as a basis for judging whether the data changes next time.
  • Step S1003 the second electronic device sends data change information to the first electronic device.
  • the second electronic device can monitor and record data changes through the change script, record the data change information in a table in the change script, and then transmit the change script to the first electronic device. In this way, file-level synchronization is realized, and the speed of data change synchronization is improved.
  • the second electronic device may also synchronize the changed data to the first electronic device one by one.
  • Step S1004 the first electronic device loads the changed data into the first mapping data set of the second electronic device according to the data change information.
  • the database versions of the first electronic device and the second electronic device may be different, at this time, the first electronic device can fuse the changed data with the data in the first mapping data set according to the level of the database version .
  • the data change monitoring process will be introduced below with reference to FIG. 11 and FIG. 12 .
  • the database version of the first electronic device 111 is lower than the database version of the second electronic device 112, and the second electronic device 112 Including a source database 113 and a change script 114 , the first electronic device 111 includes a change script 114 , a mapping database 115 and a target database 116 .
  • the source database 113 is a local database of the second electronic device 112
  • the mapping database 115 is a mapping database of the source database 113
  • the target database 116 is a local database of the first electronic device.
  • the second electronic device 112 transmits the mapping database of the source database 113 to the first electronic device 111, and the first electronic device 111 virtualizes the mapping database 115 and the target database 116 into a virtual database.
  • the second electronic device 112 monitors the data changes of the source database 113 in real time through the change script 114 based on the data state tree created by the data mapping process, and records the change data of the source database 113 in the table in the change script 114 .
  • the table structure in the change script 114 is consistent with the database in the target database 116 .
  • the above-mentioned data change information is embodied as the change script 114 .
  • the second electronic device 112 After determining that the data has changed, the second electronic device 112 records the changed data in the database table in the change script 114 , updates the data status tree, and then transmits the change script 114 to the first electronic device 111 .
  • the first electronic device 111 After receiving the change script 114 , the first electronic device 111 loads changed data into the mapping database 115 in batches through the change script 114 . In this way, after data mapping, when the data of the second electronic device changes, the changed data can be synchronized to the first electronic device in real time.
  • the database version of the first electronic device 121 is higher than the database version of the second electronic device 122 .
  • the second electronic device 122 includes a source database 123 and a change script 124
  • the first electronic device 121 includes a change script 124 , a change script 125 , a mapping database 126 and a target database 127 .
  • the source database 123 is a local database of the second electronic device 122
  • the mapping database 126 is a mapping database of the source database 123
  • the target database 127 is a local database of the first electronic device 121 .
  • the second electronic device 122 transmits the mapping database of the source database 123 to the first electronic device 121, and the first electronic device 121 virtualizes the mapping database 126 and the target database 127 into a virtual database.
  • the second electronic device 122 monitors the data changes of the source database 113 in real time through the change script 124 based on the data state tree created by the data mapping process, and records the change data of the source database 123 in the table in the change script 124 .
  • the table structure of the modification script 124 is consistent with the table structure of the database of the source database 123 .
  • the above-mentioned data change information is embodied as the change script 124 .
  • the second electronic device 122 After determining that the data has changed, the second electronic device 122 records the changed data in the database table in the change script 124 , updates the data status tree, and transmits the change script 124 to the first electronic device 121 .
  • the first electronic device 121 After receiving the modification script 124 , the first electronic device 121 upgrades the version of the modification script 124 to obtain the modification script 125 , the table structure of the modification script 125 is consistent with the table structure of the target database 127 . Then, the changed data is loaded into the mapping database 126 in batches through the change script 125 . In this way, after data mapping, when the data of the second electronic device changes, the changed data can be synchronized to the first electronic device in real time.
  • the data change monitoring process can be shown in Figure 11, that is, the data change monitoring process when the database versions of the two devices are the same can be the same as the higher version to the lower version
  • the data change monitoring process during synchronization is the same.
  • the second electronic device can monitor and record data changes through the change script, and record the changed data in the table in the change script.
  • the first electronic device receives the change script from the first electronic device, it can batch load the changed data into the corresponding mapping table of the intermediate result database through the change script, and the corresponding mapping table refers to the local database of the second electronic device A mapping table for tables.
  • the above shows the processes on the side of the first electronic device and the side of the second electronic device when the data on the side of the second electronic device changes.
  • the process on the side of the first electronic device is similar to the process on the side of the second electronic device above
  • the process on the side of the second electronic device is similar to the process on the side of the first electronic device above.
  • the process on one side is similar and will not be repeated here.
  • the data status information is recorded during data mapping, and based on the data status information, it is monitored in real time whether the data has changed.
  • the changed data is synchronized to the peer device based on the data status information, which can realize cross- Device data status management, realizing real-time query of cross-device data.
  • Electronic devices can achieve cross-device data fusion access through a database link (Data Base link, DBlink).
  • Data Base link Data Base link
  • the electronic device presets the DBlink of the peer device in the local database; after obtaining the access request, it first links to the database of the peer device based on the DBlink of the peer device, then scans the database of the peer device, and All the data of the peer device database is sent back to the local database; finally, the database connection with the peer device is disconnected, and the access result corresponding to the access request is returned.
  • the electronic device can query the data of the peer device in the local database through one query, and realize cross-device data access.
  • the following will exemplarily introduce the data fusion access process from the side of the first electronic device.
  • the data fusion access process on the side of the second electronic device reference may be made to the process on the side of the first electronic device, which will not be repeated here.
  • FIG. 13 is a schematic flow diagram of the data fusion access process provided by the embodiment of the present application, the process may include the following steps:
  • Step S1301 the first electronic device obtains a data access request of an application program, where the first electronic device includes the application program.
  • the application program on the first electronic device may be, for example, a gallery or a third-party application program, etc., and the application program is not limited here.
  • Step S1302 the first electronic device determines that the data access request includes the device identifier of the second electronic device, then queries the first data set in the target database to obtain the first query result, the first data set is the local data set of the second electronic device
  • the target database includes a first data set and a second data set, the second data set is a local data set of the first electronic device or a mapping data set of the local data set, and the first electronic device includes the target database.
  • the data access request initiated by the application program carries a device identifier, and the device identifier is used to uniquely identify the device.
  • the device identifier may specifically be a device ID.
  • the data access request carries a device ID, access the data of the corresponding device according to the pre-established association between the device ID and the data set; when the data access request does not carry a device ID, access the data of all devices.
  • the device identifier of the second electronic device may be pre-stored locally on the first electronic device.
  • the first electronic device receives the second event from the second electronic device, and locally stores the device identifier of the second electronic device carried in the second event.
  • the above-mentioned target database can be a virtual database or an intermediate result database.
  • the first data set is specifically the mapping database of the local database of the second electronic device, and the first data set is specifically the local database of the first electronic device.
  • the target database is an intermediate result database
  • the first data set is specifically a mapping table of a local database table of the second electronic device
  • the first data set is specifically a mapping table of a local database table of the first electronic device.
  • the first electronic device queries the mapping database of the second electronic device in the target database to obtain a first query result.
  • Step S1303 the first electronic device returns the first query result to the application program.
  • the first electronic device determines that the data access request does not include the device identifier, then queries the first data set and the second data set in the target database, obtains the second query result, and returns the second query to the application program result.
  • Step S1305 the first electronic device determines that the data access request includes the device identifier of the first electronic device, then queries the second data set in the target database, obtains a third query result, and returns the third query result to the application program.
  • cross-device media data fusion access refers to the schematic diagram of cross-device media data fusion access provided by the embodiment of the present application shown in FIG.
  • the local media library database so that when the application program of the first electronic device 141 needs to access the data of the second electronic device 142 or the cloud 143, it can realize cross-device data by accessing the corresponding data in the local media library database. Fusion access.
  • the cloud 143 can be regarded as a device.
  • the first electronic device 141 includes a media library (Media library), which is a media data management framework self-developed by Huawei, and supports application programs to access distributed media data.
  • Media library is a media data management framework self-developed by Huawei, and supports application programs to access distributed media data.
  • the first electronic device 141 exemplarily includes an application program 1, an application program 2, an application program 3, and an application program 4, and each application program can perform cross-device media data fusion access by calling a unified interface of the media library.
  • the application program 1 can initiate a data access request by calling the unified interface of the media library, and specify the device identifier of the second electronic device 142 in the data access request, that is, the application program 1 needs to access the data of the second electronic device 142.
  • Media data the media library service framework transmits the data access request to the media data fusion access module, and the media data fusion access module queries the data of the second electronic device in the fusion data based on the device identification carried in the data access request, and obtains the query result ; Finally, the media library database returns the query result to the application program 1.
  • FIG. 15 shows a schematic diagram of cross-device access to image data provided by the embodiment of the present application.
  • the first electronic device is specifically a mobile phone 151
  • the second electronic device includes a tablet and a mobile phone 2 .
  • the main interface of the mobile phone 151 includes multiple application programs such as setting, calendar, clock, application store and gallery 152 .
  • the mobile phone 151 receives a click operation on the gallery 152
  • the mobile phone 151 displays the photo album interface 153 in response to the click operation.
  • the photo album interface 153 displays photos, videos, camera pictures, etc. on the machine. If the user needs to access the image data of other devices, he can click "other devices" on the camera interface 153 .
  • the mobile phone 151 receives a click operation on “other devices”, it displays an interface 154 in response to the click operation.
  • the interface 154 includes a folder 155 of the tablet and a folder 156 of the mobile phone 2 .
  • the user wants to access the data on the tablet across devices, he can click on the folder 155, and if he wants to access the data on the mobile phone 2 across devices, he can click on the folder 156.
  • the mobile phone 151 receives a click operation on the folder 155, and displays an interface 157 in response to the click operation.
  • the interface 157 includes a camera folder 158 , a picture folder 159 , a Huawei shared folder 1510 and a screen capture folder 1511 .
  • the mobile phone 151 calls the unified interface of the media library to initiate a data access request, and specifies the device identifier of the tablet in the data access request.
  • the media data fusion access module in the mobile phone 151 is based on the data access request, queries the data of the tablet in the media library database, and returns the query result to the gallery.
  • the library displays an interface 157 based on the query result.
  • the mobile phone 151 When the mobile phone 151 receives a click operation on the camera folder 158, in response to the click operation, an interface 1512 is displayed, and the interface 1512 includes each photo taken by the tablet camera. In this way, the user can access the image data on the tablet on the mobile phone 151 .
  • the camera interface of the mobile phone includes a search box 161, and the user can enter corresponding information in the search box 161 to search for this machine or other devices Photo.
  • the user inputs "8.7" in the search box 161, that is, the user searches for photos whose shooting time is August 7.
  • the mobile phone displays the interface 162 based on the search results. At this point, the mobile phone finds a photo that meets the search criteria on the phone, and finds 2 photos that meet the search criteria on the tablet.
  • the gallery calls the unified interface of the media library to initiate a data access request.
  • the data access request does not include the device identification, that is, the data of all devices needs to be queried.
  • the data fusion access module on the mobile phone queries the data of the local machine, the data of the tablet and the data of the mobile phone 2 in the media library database, obtains the query result, and returns the query result to the gallery.
  • the library displays the interface 162 based on the query result.
  • the first electronic device pre-maps the data of the second electronic device (that is, the peer device) to the local storage space, so that when accessing the data of the second electronic device, it can be accessed like a local The same as the database, which provides cross-device data access similar to local database access.
  • the process from the initiation of the access request to the obtaining of the query result does not involve processes such as linking to the remote database, data return from the remote database, etc., and the query speed is not affected by the quality of network transmission, and consumes The time is shorter, which in turn makes cross-device data access performance higher.
  • the first electronic device integrates the local data set and the mapping data set of the peer device into a target database, and can query and filter the data of multiple devices through a single query request, realizing cross-device data fusion access.
  • the data of the second electronic device Before the data fusion access, the data of the second electronic device needs to be synchronized locally to the first electronic device.
  • the data of the second electronic device can be synchronized to the local storage space of the first electronic device one by one, or the database or database table of the second electronic device can be mapped as a whole through the data mapping process mentioned above
  • the data of the second electronic device can also be synchronized to the local storage space of the first electronic device in other ways.
  • the method of mapping the database or database table as a whole to the peer device reduces the time-consuming data synchronization and improves the speed of data availability.
  • the data of the second electronic device is mapped locally to the first electronic device in a database mapping manner.
  • the data of the second electronic device is mapped locally to the first electronic device in a table mapping manner.
  • the process of cross-device data fusion access may also be different. The access process in the two modes is exemplified below in conjunction with FIG. 17 and FIG. 18 .
  • the first electronic device 171 includes a media library (Media library), a media data fusion access module 174 and a fusion Data management module 175.
  • media library Media library
  • media data fusion access module 174 the media data fusion access module 174
  • the media data fusion access module 174 is used to obtain the data access request of the application program, and in response to the data access request, query the corresponding media data through the fusion data management module 175, and return the query result to the application program.
  • the media data fusion access module 174 can provide cross-device media data fusion access capability.
  • the converged data management module 175 is used to manage local data and cross-device data.
  • the distributed data mapping module 176 is used to realize the mapping and changing of cross-device media data.
  • the distributed database mapping module 176 may be a module in the cross-device distributed data middleware.
  • the cloud 172 and the second electronic device 173 can map the entire local media database to the first electronic device 171 .
  • the cloud 172 can be regarded as a special second electronic device.
  • the application program of the first electronic device 171 can initiate a data access request by calling the interface of the media library, so as to access the media data of the cloud 172 and the second electronic device 173 .
  • FIG. 18 shows a schematic diagram of data fusion access in the table mapping mode provided by the embodiment of the present application
  • the first electronic device 181 can access the data of the cloud 182 and the data of the second electronic device 183 across devices .
  • the distributed data mapping module 186 is used to implement cross-device media data mapping and modification.
  • the first electronic device 181 creates a mapping table of the local database table through the distributed data mapping module 186 , and loads the mapping table into the intermediate process data 185 .
  • the cloud 182 and the second electronic device 183 can map the entire local database table to the intermediate process data 185 of the first electronic device 181 through the distributed data mapping module 186 .
  • the intermediate process data 185 may be embodied as an intermediate result database, which may include a mapping table of the local database table of the first electronic device 181 , a mapping table of the local database table of the cloud 182 , and a mapping table of the local database table of the second electronic device 183 .
  • the application program on the first electronic device 181 can initiate a data access request by calling the media library interface.
  • the media data fusion access module 184 queries the intermediate process data 185 in response to the data access request to obtain a query result. Wherein, if the data access request includes the device identifier of the first electronic device 181 , query the mapping table of the first electronic device 181 in the intermediate process data 185 . If the data access request includes the device identifier of the cloud 182 or the second electronic device 183 , query the mapping table of the cloud 182 or the second electronic device 183 in the intermediate process data 185 . If the data access request does not include a device identifier, the mapping tables of all devices in the intermediate process data 185 are queried.
  • the distributed data mapping module can be used to implement cross-device data mapping and changes.
  • the distributed data mapping module is a module in the distributed data middleware. The following will exemplarily introduce the data based on the distributed data middleware Mapping process.
  • the distributed data middleware includes the following parts: driver (Driver) 191, metadata storage warehouse (Metadata Store) 192, Execution Engine 193, Batch Operator 194 and Real-time Operator 195.
  • the media library includes the following parts: media library interface 196 , data fusion access module 197 , virtual mapping database 198 and local database 199 .
  • the database mapping process based on distributed data middleware may include the following steps:
  • the media library library After the media library library receives the device online event, it calls the distributed data middleware interface through the media library interface 196 to create a virtual mapping database 198.
  • the distributed data middleware first defines the mapping database, for example, defines the tables and database file names contained in the mapping database; then creates the mapping database according to the definition of the mapping database. At this time, the mapping database has not yet been installed. Then, perform database mapping and load stateful data, that is, first create a data state tree, then start data loading based on the data state, load the data in the source database into the pre-created mapping database in batches, and obtain the data loading Enter the completed mapping database to obtain the virtual mapping database 198.
  • the distributed database middleware of the second electronic device 52 according to the device online event of the first electronic device 51 Define the mapping database for database version information, etc., and then create a mapping database according to the definition of the mapping database; then, create a data state tree, and perform data mapping in the first virtual database to obtain the mapping database 54 that has been mapped, and then map the mapping database. 54 is transmitted to the first electronic device 51 across devices.
  • the mapping database 54 on the first electronic device 51 is the above-mentioned virtual mapping database.
  • the distributed data middleware After the distributed data middleware completes the cross-device database mapping, it can also monitor the database change information in real time, and based on the database monitoring result, load the change data of the remote database into the virtual mapping database 198 in real time. As shown in FIG. 19 , after monitoring the data changes in real time, the real-time operation processor 195 in the distributed data middleware loads the data changes of the remote device into the virtual mapping database 198 statefully.
  • the application program can call the media library interface 196 to initiate a data fusion access request to the data fusion access module 197, and the data fusion access module 197 queries the local database 199 and/or the virtual map in response to the data fusion access request
  • the database 198 obtains the query result, and then returns the query result to the application program through the media library interface 196 .
  • the distributed data middleware is cross-device, so the flow shown by the distributed middleware in FIG. 19 includes the flow of two devices.
  • the process of the distributed data middleware shown in FIG. 19 includes the processes of the first electronic device 51 and the second electronic device 52 in FIG. 5 .
  • the distributed data middleware includes the following parts: driver (Driver) 201, metadata storage warehouse ( Metadata Store) 202, execution engine (Execution Engine) 203, batch operation processor (Batch Operator) 204 and real-time operation processor (Real-time Operator) 205.
  • the media library includes the following parts: media library interface 206 , data fusion access module 207 , and intermediate result database 208 .
  • the distributed data middleware first creates a local mapping table and a remote mapping table.
  • the distributed data middleware of the first electronic device creates a mapping table of the local database table
  • the distributed database middleware of the second electronic device creates a local mapping table.
  • the mapping table of the database table (that is, the above remote mapping table).
  • the distributed data middleware creates an intermediate process database, then creates a data state tree, and loads data statefully based on the data state tree, that is, loads the local mapping table and the remote mapping table into the intermediate process database in batches, and obtains intermediate results database 208 .
  • the remote mapping table needs to be transmitted to the local, for example, the second electronic device transmits the created mapping table to the first electronic device.
  • the distributed data middleware can also monitor data changes in real time.
  • the monitoring objects include local data and cross-device data. When data changes are detected, the changed data will be loaded into the intermediate result database.
  • the application program can call the media library interface 206 to initiate a data fusion access request to the data fusion access module 207, and the data fusion access module 207 queries the intermediate result database 208 in response to the data fusion access request to obtain the query result , and then return the query result to the application program through the media library interface 206.
  • the distributed data middleware is cross-device, so the flow shown by the distributed middleware in FIG. 19 includes the flow of two devices.
  • the data mapping process provided by the embodiment of this application maps the database or database table as a whole to the peer device, and realizes data synchronization at the database level or data table level.
  • this application reduces time-consuming data synchronization across devices, and improves data availability speed. In this way, the plug-and-play of the device is realized, that is, as soon as the device is online, the data of the device can be quickly synchronized to the peer device, making the data of the device available faster.
  • the first electronic device may clear the data set of the offline device in the local cache.
  • the first electronic device is a mobile phone
  • the second electronic device is a tablet.
  • the mobile phone and the tablet establish a Wi-Fi point-to-point connection
  • the mobile phone stores the mapping database of the tablet locally after receiving the mapping database sent by the tablet.
  • the Wi-Fi point-to-point connection between the mobile phone and the tablet is disconnected, that is, after the tablet goes offline, the mobile phone clears the mapping database of the tablet in the local cache.
  • the embodiment of the present application also provides a different table structure mapping scheme, so that even if the table structures between devices are different, it can still To achieve database mapping, the application range is wider.
  • the embodiment of the present application also creates and records data state information during data mapping, monitors whether the data changes based on the data state information, and synchronizes the changed data to the peer device when the data changes, so as to realize cross-device data change monitoring. Provide real-time data query capabilities across devices.
  • the data fusion access process maps the database of the peer device to the local storage space in advance, improves cross-device data fusion access similar to local database access, avoids the influence of network transmission quality on query performance, and realizes high-performance Cross-device data fusion access.
  • the data transmission device includes:
  • the first receiving module is configured to receive the first event from the first electronic device, the first event includes the first database version information, the first database version information is used to describe the database version of the second source database, and the second source database is the first a local database of the electronic device;
  • the first creation module is configured to create a first empty mapping database of the first source database according to the first database version information, where the first source database is a local database of the second electronic device;
  • the first virtualization module is used to virtualize the first source database and the first empty mapping database to obtain the first virtual database;
  • the first mapping module is used to perform data mapping in the first virtual database, so as to map the data in the first source database to the first empty mapping database to obtain the first database with data mapping completed;
  • a first obtaining module configured to obtain a first mapping database based on the first database
  • the first sending module is configured to send the first mapping database to the first electronic device.
  • the first obtaining module is specifically configured to: compare the database version level between the first source database and the second source database according to the first database version information and the second database version information, and the second database version The information is used to describe the database version of the first source database; if the version of the first source database is higher than the version of the second source database, the version of the first database is downgraded to obtain the first mapping database, and the version of the first mapping database is the same as that of the second source database.
  • the versions of the two source databases are consistent; if the version of the first source database is lower than or equal to the version of the second source database, the first database is used as the first mapping database, and the version of the first mapping database is consistent with the version of the first source database.
  • the version of the first source database when the version of the first source database is higher than the version of the second source database, the version of the first empty mapping database is consistent with the version of the first source database, and the table structure of the first empty mapping database is the same as that of the second source database.
  • the table structure of the second source database is consistent; when the version of the first source database is lower than the version of the second source database, the version of the first empty mapping database is consistent with the version of the first source database, and the table structure of the first empty mapping database is the same as that of the second source database.
  • the table structure of a source database is consistent.
  • the device also includes:
  • a second sending module configured to send a second event to the first electronic device, where the second event includes second database version information
  • the second receiving module is configured to receive the second mapping database from the first electronic device, and the second mapping database is a mapping database of the second source database established by the first electronic device according to the second database version information.
  • the device further includes a second virtualization module, configured to: if the version of the first source database is lower than the version of the second source database, virtualize the second mapping database and the first source database , to obtain the second virtual database; if the version of the first source database is higher than the version of the second source database, the second mapping database is upgraded to obtain the upgraded second mapping database, and the version of the upgraded second mapping database is the same as The versions of the first source database are consistent; the upgraded second mapping database and the first source database are virtualized to obtain the second virtual database.
  • a second virtualization module configured to: if the version of the first source database is lower than the version of the second source database, virtualize the second mapping database and the first source database , to obtain the second virtual database; if the version of the first source database is higher than the version of the second source database, the second mapping database is upgraded to obtain the upgraded second mapping database, and the version of the upgraded second mapping database is the same as The versions of the first source database are consistent; the upgraded second mapping database and the first source database are virtualized to obtain
  • the apparatus further includes a first converged access module, configured to: acquire a first data access request of a first application, and the second electronic device includes the first application; if the first data access request includes the first For the device identifier of the electronic device, query the second mapping database in the second virtual database, obtain the first query result, and return the first query result to the first application; if the first data access request does not include the device identifier, query the second virtual database The second mapping database and the first source database in the database obtain the second query result, and return the second query result to the first application; if the first data access request includes the device identification of the second electronic device, query the second virtual database The first source database in the database obtains the third query result and returns the third query result to the first application.
  • a first converged access module configured to: acquire a first data access request of a first application, and the second electronic device includes the first application; if the first data access request includes the first For the device identifier of the electronic device, query the second mapping database in the second virtual database, obtain the
  • the device also includes:
  • the first change script receiving module is used to receive the first change script from the first electronic device, the first change script includes a table for recording the change data of the second source database;
  • the first batch update module is used to upgrade the first change script to obtain the upgraded first change script if the version of the first source database is higher than the version of the second source database, and the table of the upgraded first change script
  • the structure is consistent with the table structure of the first source database; by executing the upgraded first change script, the changed data of the second source database is loaded into the second mapping database; if the version of the first source database is lower than that of the second source database version, load the changed data of the second source database into the second mapping database by executing the first change script.
  • the device further includes a first update module, configured to: determine whether data in the first source database is changed according to the first data status tree, the first data status tree is used to describe the first source The status of the data in the database that is mapped to the first empty mapping database; if the data in the first source database is changed, the changed data in the first source data is recorded in the second change script, and the second change script includes for recording changing the table of data; sending the second changing script to the first electronic device;
  • the table structure of the second change script is consistent with the table structure of the second source database
  • the table structure of the second change script is consistent with the table structure of the first source database.
  • the above-mentioned first update module is further configured to: update the first data state tree.
  • the data transmission device includes:
  • the third sending module is configured to send the first event to the second electronic device, the first event includes the first database version information, the first database version information is used to describe the database version of the second source database, and the second source database is the first local database of electronic devices;
  • the third receiving module is configured to receive the first mapping database from the second electronic device, the first mapping database is the mapping database of the first source database established by the second electronic device according to the first database version information, and the first source database is the first A local database of the second electronic device.
  • the device further includes a third virtualization module, configured to: if the version of the first source database is higher than the version of the second source database, virtualize the first mapping database and the second source database , to obtain the third virtualized database; if the version of the first source database is lower than the version of the second source database, the first mapping database is upgraded to obtain the upgraded first mapping database, and the version of the upgraded first mapping database The version is consistent with that of the second source database; the upgraded first mapping database and the second source database are virtualized to obtain a third virtual database.
  • a third virtualization module configured to: if the version of the first source database is higher than the version of the second source database, virtualize the first mapping database and the second source database , to obtain the third virtualized database; if the version of the first source database is lower than the version of the second source database, the first mapping database is upgraded to obtain the upgraded first mapping database, and the version of the upgraded first mapping database The version is consistent with that of the second source database; the upgraded first mapping database and the second source database are virtualized to obtain
  • the apparatus further includes a second fusion access module, configured to: obtain a second data access request of a second application, the first electronic device includes the second application; if the second data access request includes the first For the device identifier of the electronic device, query the second source database in the third virtual database, obtain the fourth query result, and return the fourth query result to the second application; if the second data access request does not include the device identifier, query the third virtual database The first mapping database and the second source database in the database obtain the fifth query result, and return the fifth query result to the second application; if the second data access request includes the device identifier of the second electronic device, query the third virtual database The first mapping database in the database obtains the sixth query result and returns the sixth query result to the second application.
  • a second fusion access module configured to: obtain a second data access request of a second application, the first electronic device includes the second application; if the second data access request includes the first For the device identifier of the electronic device, query the second source database in the third virtual database, obtain the fourth query
  • the device also includes:
  • the second change script receiving module is used to receive the second change script from the second electronic device, the second change script includes a table for recording the change data of the first source database;
  • the second batch update module is used to upgrade the second change script to obtain the upgraded second change script if the version of the first source database is lower than the version of the second source database, and the table of the upgraded second change script
  • the structure is consistent with the table structure of the second source database; by executing the upgraded second change script, the changed data of the first source database is loaded into the first mapping database; if the version of the first source database is higher than that of the second source database Version, by executing the second change script, the change data of the first source database is loaded into the first mapping database.
  • the device also includes:
  • a fourth receiving module configured to receive a second event from the second electronic device, the second event includes second database version information, and the second database version information is used to describe the database version of the first source database;
  • the second creation module is used to create a second empty mapping database of the second source database according to the version information of the second database;
  • a fourth virtualization module configured to virtualize the second source database and the second empty mapping database to obtain a fourth virtual database
  • the second mapping module is used to perform data mapping in the fourth virtual database, so as to map the data in the second source database to the second empty mapping database to obtain the second database with data mapping completed;
  • the second obtaining module is configured to obtain a second mapping database based on the second database
  • a fourth sending module configured to send the second mapping database to the second electronic device.
  • the second obtaining module is specifically configured to: compare the database versions between the first source database and the second source database according to the first database version information and the second database version information; if the first source The version of the database is lower than or equal to the version of the second source database, and the version of the second database is downgraded to obtain the second mapping database.
  • the version of the second mapping database is consistent with the version of the first source database; if the version of the first source database The version of the second source database is higher than that of the second source database, and the second database is used as the first mapping database, and the version of the second mapping database is consistent with the version of the second source database.
  • the version of the first source database when the version of the first source database is lower than the version of the second source database, the version of the second empty mapping database is consistent with the version of the second source database, and the table structure of the second empty mapping database is the same as that of the first The table structure of the first source database is consistent; when the version of the first source database is higher than the version of the second source database, the version of the second empty mapping database is consistent with the version of the second source database, and the table structure of the second empty mapping database is the same as that of the first The table structures of the two source databases are consistent.
  • the device further includes a second update module, configured to: determine whether the data in the second source database is changed according to the second data status tree, the second data status tree is used to describe the second source The status of the data in the database that is mapped to the second empty mapping database; if the data in the second source database changes, the changed data in the second source data is recorded in the first change script, and the first change script includes for recording changing the table of data; updating the second data state tree; sending the first change script to the second electronic device;
  • the table structure of the first change script is consistent with the table structure of the first source database
  • the table structure of the first change script is consistent with the table structure of the second source database.
  • Fig. 21 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device 21 of this embodiment includes: at least one processor 210 (only one is shown in FIG. 21 ), a processor, a memory 211 and stored in the memory 211 and can be processed in the at least one processor.
  • a computer program 212 running on the processor 210 when the processor 210 executes the computer program 212, implements the steps in any of the foregoing embodiments of the data transmission method.
  • the electronic device 21 may be computing devices such as desktop computers, notebooks, palmtop computers, and cloud servers.
  • the electronic device may include, but not limited to, a processor 210 and a memory 211 .
  • FIG. 21 is only an example of the electronic device 21, and does not constitute a limitation to the electronic device 21. It may include more or less components than shown in the figure, or combine certain components, or different components. , for example, may also include input and output devices, network access devices, and so on.
  • the so-called processor 210 can be a central processing unit (Central Processing Unit, CPU), and the processor 210 can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit , ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the storage 211 may be an internal storage unit of the electronic device 21 in some embodiments, such as a hard disk or memory of the electronic device 21 .
  • the memory 211 may also be an external storage device of the electronic device 21 in other embodiments, such as a plug-in hard disk equipped on the electronic device 21, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash memory card (Flash Card), etc. Further, the memory 211 may also include both an internal storage unit of the electronic device 21 and an external storage device.
  • the memory 211 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of the computer program.
  • the memory 211 can also be used to temporarily store data that has been output or will be output.
  • the embodiment of the present application also provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the foregoing method embodiments can be realized.
  • An embodiment of the present application provides a computer program product.
  • the computer program product runs on an electronic device, the electronic device can implement the steps in the foregoing method embodiments when executed.
  • the embodiment of the present application also provides a chip system, the chip system includes a processor, the processor is coupled with the memory, and the processor executes the computer program stored in the memory, so as to realize the above-mentioned method embodiments. method.
  • the chip system may be a single chip, or a chip module composed of multiple chips.
  • references to "one embodiment” or “some embodiments” or the like in the specification of the present application means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application.
  • appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in other embodiments,” etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless specifically stated otherwise.

Landscapes

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

Abstract

一种数据传输方法、电子设备及计算机可读存储介质,用于提高数据同步速度。方法包括:第二电子设备接收来自第一电子设备的第一事件(S401),第一事件包括第一数据库版本信息,第一数据库版本信息用于描述第一电子设备本地的第二源数据库的数据库版本;根据第一数据库版本信息,创建第一源数据库的第一空映射数据库(S402),第一源数据库为第二电子设备的本地数据库;将第一源数据库和第一空映射数据库进行虚拟化,得到第一虚拟数据库(S403);在第一虚拟数据库中进行数据映射,以将第一源数据库内的数据映射至第一空映射数据库,得到数据映射完成的第一数据库(S404);基于第一数据库,得到第一映射数据库(S405);向第一电子设备发送第一映射数据库(S406)。

Description

数据传输方法、电子设备及计算机可读存储介质
本申请要求于2021年05月31日提交国家知识产权局、申请号为202110604841.3、申请名称为“数据传输方法、电子设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,尤其涉及一种数据传输方法、电子设备及计算机可读存储介质。
背景技术
一个电子设备可以通过数据同步,将本地数据同步至另一个电子设备。目前,数据同步过程是一条条数据同步的,并且读写过程涉及数据格式转换,耗时较长,数据同步速度较慢。
也就是说,现有技术的数据同步速度较慢。
发明内容
本申请实施例提供一种数据传输方法、电子设备及计算机可读存储介质,可以提高数据同步速度。
第一方面,本申请实施例提供一种跨设备的数据传输方法,应用第二电子设备,该方法包括:接收来自第一电子设备的第一事件,第一事件包括第一数据库版本信息,第一数据库版本信息用于描述第二源数据库的数据库版本,第二源数据库为第一电子设备的本地数据库;根据第一数据库版本信息,创建第一源数据库的第一空映射数据库,第一源数据库为第二电子设备的本地数据库;将第一源数据库和第一空映射数据库进行虚拟化,得到第一虚拟数据库;在第一虚拟数据库中进行数据映射,以将第一源数据库内的数据映射至第一空映射数据库,得到数据映射完成的第一数据库;基于第一数据库,得到第一映射数据库;向第一电子设备发送第一映射数据库。
可以看出,本申请实施例将数据库作为一个整体映射至对端设备,实现了数据库级别的数据同步,不涉及数据格式转换,减少了数据同步耗时,提高了数据同步速度,使得数据可用速度更快。
在第一方面的一些可能的实现方式中,基于第一数据库,得到第一映射数据库,包括:
根据第一数据库版本信息和第二数据库版本信息,比较第一源数据库和第二源数据库之间的数据库版本高低,第二数据库版本信息用于描述第一源数据库的数据库版本;
若第一源数据库的版本高于第二源数据库的版本,将第一数据库进行版本降级,得到第一映射数据库,第一映射数据库的版本与第二源数据库的版本一致;
若第一源数据库的版本低于或等于第二源数据库的版本,将第一数据库作为第一映射数据库,第一映射数据库的版本与第一源数据库的版本一致。
进一步地,在两个电子设备的数据版本不同,数据表结构不同时,本申请实施例 基于两个电子设备的数据库版本高低,相应地进行版本降级,使得本申请实施例的数据库级别同步方法的适用范围更广。
在第一方面的一些可能的实现方式中,当第一源数据库的版本高于第二源数据库的版本,第一空映射数据库的版本与第一源数据库的版本一致,第一空映射数据库的表结构与第二源数据库的表结构一致;
当第一源数据库的版本低于第二源数据库的版本,第一空映射数据库的版本与第一源数据库的版本一致,第一空映射数据库的表结构与第一源数据库的表结构一致。
在第一方面的一些可能的实现方式中,该方法还包括:
向第一电子设备发送第二事件,第二事件包括第二数据库版本信息;
接收来自第一电子设备的第二映射数据库,第二映射数据库为第一电子设备根据第二数据库版本信息建立的第二源数据库的映射数据库。
在该实现方式中,第一电子设备和第二电子设备之间均可以将本地数据库作为一个整体同步至对端设备。
在第一方面的一些可能的实现方式中,在接收来自第一电子设备的第二映射数据库之后,该方法还包括:
若第一源数据库的版本低于第二源数据库的版本,将第二映射数据库和第一源数据库进行虚拟化,得到第二虚拟数据库;
若第一源数据库的版本高于第二源数据库的版本,将第二映射数据库进行升级,得到升级后的第二映射数据库,升级后的第二映射数据库的版本与第一源数据库的版本一致;
将升级后的第二映射数据库和第一源数据库进行虚拟化,得到第二虚拟数据库。
在该实现方式,基于第一源数据库和第二映射数据库进行虚拟化,得到一个虚拟化数据库,不用将两个数据库内数据逐条同步,进一步提高数据同步速度。其中,第二虚拟数据库包括相互独立的第一源数据库和第二映射数据库。
另外,将两个数据库虚拟化成一个虚拟数据库,可以便于后续的跨设备数据融合访问。
在第一方面的一些可能的实现方式中,在将第二映射数据库和第一源数据库进行虚拟化,得到第二虚拟数据库之后,方法还包括:
获取第一应用的第一数据访问请求,第二电子设备包括第一应用;
若第一数据访问请求包括第一电子设备的设备标识,查询第二虚拟数据库中的第二映射数据库,得到第一查询结果,并向第一应用返回第一查询结果;
若第一数据访问请求不包括设备标识,查询第二虚拟数据库中的第二映射数据库和第一源数据库,得到第二查询结果,并向第一应用返回第二查询结果;
若第一数据访问请求包括第二电子设备的设备标识,查询第二虚拟数据库中的第一源数据库,得到第三查询结果,并向第一应用返回第三查询结果。
在该实现方式中,第二电子设备将第一电子设备的本地数据库预先映射至本地存储空间,使得访问第一电子设备的数据时可以像访问本地数据库一样,即提供类本地数据库访问的跨设备数据访问。并且,在访问第一电子设备的数据时,从访问请求发起至获得查询结果的过程,不用涉及链接远端数据库、远端数据库的数据回传等过程, 查询速度不受网络传输质量影响,耗时较短,进而使得跨设备数据访问性能较高。另外,第二电子设备将本地数据库和对端设备的映射数据数据库虚拟化成一个数据库,通过一次查询请求即可对多个设备的数据进行查询、过滤,实现了跨设备数据融合访问。
进一步地,在数据同步时,采用数据库作为一个整体映射至对端设备的方式,减少了数据同步耗时,提高了数据可用速度,进一步提高了数据融合访问性能。
在第一方面的一些可能的实现方式中,在第二电子设备接收来自第一电子设备的第二映射数据库之后,还包括:
接收来自第一电子设备的第一变更脚本,第一变更脚本包括用于记录第二源数据库的变更数据的表;
若第一源数据库的版本高于第二源数据库的版本,将第一变更脚本进行升级,得到升级后的第一变更脚本,升级后的第一变更脚本的表结构与第一源数据库的表结构一致;
通过执行升级后的第一变更脚本,将第二源数据库的变更数据装入第二映射数据库;
若第一源数据库的版本低于第二源数据库的版本,通过执行第一变更脚本,将第二源数据库的变更数据装入第二映射数据库。
在第一方面的一些可能的实现方式中,该方法还包括:
根据第一数据状态树,确定第一源数据库内的数据是否发生变更,第一数据状态树用于描述第一源数据库内映射至第一空映射数据库的数据的状态;
若第一源数据库内的数据发生变更,将第一源数据内发生变更的数据记录在第二变更脚本,第二变更脚本包括用于记录变更数据的表;
向第一电子设备发送第二变更脚本;
其中,当第一源数据库的版本高于第二源数据库的版本,第二变更脚本的表结构与第二源数据库的表结构一致;
当第一源数据库的版本低于第二源数据库的版本,第二变更脚本的表结构与第一源数据库的表结构一致。
在该实现方式中,在数据映射时记录数据状态信息,并基于数据状态信息实时监听数据是否发现变化,当数据发现变化时,基于数据状态信息将变化的数据同步至对端设备,可以实现跨设备的数据状态管理,实现跨设备数据实时查询。
在第一方面的一些可能的实现方式中,在确定第一源数据库内的数据发生变更之后,还包括:
更新第一数据状态树。
第二方面,本申请实施例提供一种跨设备的数据传输方法,应用于第一电子设备,该方法包括:
向第二电子设备发送第一事件,第一事件包括第一数据库版本信息,第一数据库版本信息用于描述第二源数据库的数据库版本,第二源数据库为第一电子设备的本地数据库;
接收来自第二电子设备的第一映射数据库,第一映射数据库为第二电子设备根据 第一数据库版本信息建立的第一源数据库的映射数据库,第一源数据库为第二电子设备的本地数据库。
在第二方面的一些可能的实现方式中,在接收来自第二电子设备的第一映射数据库之后,还包括:
若第一源数据库的版本高于第二源数据库的版本,将第一映射数据库和第二源数据库进行虚拟化,得到第三虚拟化数据库;
若第一源数据库的版本低于第二源数据库的版本,将第一映射数据库进行升级,得到升级后的第一映射数据库,升级后的第一映射数据库的版本与第二源数据库的版本一致;
将升级后的第一映射数据库和第二源数据库进行虚拟化,得到第三虚拟数据库。
在第二方面的一些可能的实现方式中,在获得第三虚拟数据库之后,该方法还包括:
获取第二应用的第二数据访问请求,第一电子设备包括第二应用;
若第二数据访问请求包括第一电子设备的设备标识,查询第三虚拟数据库中的第二源数据库,得到第四查询结果,并向第二应用返回第四查询结果;
若第二数据访问请求不包括设备标识,查询第三虚拟数据库中的第一映射数据库和第二源数据库,得到第五查询结果,并向第二应用返回第五查询结果;
若第二数据访问请求包括第二电子设备的设备标识,查询第三虚拟数据库中的第一映射数据库,得到第六查询结果,并向第二应用返回第六查询结果。
在第二方面的一些可能的实现方式中,在接收来自第二电子设备的第一映射数据库之后,该方法还包括:
接收来自第二电子设备的第二变更脚本,第二变更脚本包括用于记录第一源数据库的变更数据的表;
若第一源数据库的版本低于第二源数据库的版本,将第二变更脚本进行升级,得到升级后的第二变更脚本,升级后的第二变更脚本的表结构与第二源数据库的表结构一致;
通过执行升级后的第二变更脚本,将第一源数据库的变更数据装入第一映射数据库;
若第一源数据库的版本高于第二源数据库的版本,通过执行第二变更脚本,将第一源数据库的变更数据装入第一映射数据库。
在第二方面的一些可能的实现方式中,该方法还包括:
接收来自第二电子设备的第二事件,第二事件包括第二数据库版本信息,第二数据库版本信息用于描述第一源数据库的数据库版本;
根据第二数据库版本信息,创建第二源数据库的第二空映射数据库;
将第二源数据库和第二空映射数据库进行虚拟化,得到第四虚拟数据库;
在第四虚拟数据库中进行数据映射,以将第二源数据库内的数据映射至第二空映射数据库,得到数据映射完成的第二数据库;
基于第二数据库,得到第二映射数据库;
向第二电子设备发送第二映射数据库。
在第二方面的一些可能的实现方式中,基于第二数据库,得到第二映射数据库,包括:
根据第一数据库版本信息和第二数据库版本信息,比较第一源数据库和第二源数据库之间的数据库版本高低;
若第一源数据库的版本低于或等于第二源数据库的版本,将第二数据库进行版本降级,得到第二映射数据库,第二映射数据库的版本与第一源数据库的版本一致;
若第一源数据库的版本高于第二源数据库的版本,将第二数据库作为第一映射数据库,第二映射数据库的版本与第二源数据库的版本一致。
在第二方面的一些可能的实现方式中,当第一源数据库的版本低于第二源数据库的版本,第二空映射数据库的版本与第二源数据库的版本一致,第二空映射数据库的表结构与第一源数据库的表结构一致;
当第一源数据库的版本高于第二源数据库的版本,第二空映射数据库的版本与第二源数据库的版本一致,第二空映射数据库的表结构与第二源数据库的表结构一致。
在第二方面的一些可能的实现方式中,在向第一电子设备发送第一映射数据库之后,还包括:
根据第二数据状态树,确定第二源数据库内的数据是否发生变更,第二数据状态树用于描述第二源数据库内映射至第二空映射数据库的数据的状态;
若第二源数据库内的数据发生变更,将第二源数据内发生变更的数据记录在第一变更脚本,第一变更脚本包括用于记录变更数据的表;
更新第二数据状态树;
向第二电子设备发送第一变更脚本;
其中,当第一源数据库的版本低于第二源数据库的版本,第一变更脚本的表结构与第一源数据库的表结构一致;
当第一源数据库的版本高于第二源数据库的版本,第一变更脚本的表结构与第二源数据库的表结构一致。
第三方面,本申请实施例提供一种电子设备,包括存储器、处理器以及存储在存储器中并可在处理器上运行的计算机程序,处理器执行计算机程序时实现如上述第一方面或第二方面任一项的方法。
第四方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现如上述第一方面或第二方面任一项的方法。
第五方面,本申请实施例提供一种芯片系统,该芯片系统包括处理器,处理器与存储器耦合,处理器执行存储器中存储的计算机程序,以实现如上述第一方面或第二方面任一项所述的方法。该芯片系统可以为单个芯片,或者多个芯片组成的芯片模组。
第六方面,本申请实施例提供一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行上述第一方面或第二方面任一项所述的方法。
可以理解的是,上述第二方面至第六方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。
附图说明
图1为本申请实施例提供的系统架构示意框图;
图2为本申请实施例提供的系统架构具体示意图;
图3为本申请实施例提供的数据映射过程的一种流程示意框图;
图4为本申请实施例提供的数据库映射模式的一种流程示意图;
图5为本申请实施例提供的数据库版本相同时的数据库映射示意图;
图6为本申请实施例提供的高版本向低版本映射的数据库映射示意图;
图7为本申请实施例提供的低版本向高版本映射的数据库映射示意图;
图8为本申请实施例提供的数据库映射模式的一种流程示意图;
图9为本申请实施例提供的表映射流程的一种示意图;
图10为本申请实施例提供的数据变更监听过程的一种示意图;
图11为本申请实施例的提供的高版本向低版本同步的数据变更监听过程示意图;
图12为本申请实施例提供的低版本向高版本同步的数据变更监听过程示意图;
图13为本申请实施例提供的数据融合访问过程的一种流程示意框图;
图14为本申请实施例提供的跨设备媒体数据融合访问示意图;
图15为本申请实施例提供的跨设备访问图像数据的示意图;
图16为本申请实施例提供的跨设备图片搜索示意图;
图17为本申请实施例提供的数据库映射模式下的数据融合访问示意图;
图18为本申请实施例提供的表映射模式下的数据融合访问示意图;
图19为本申请实施例提供的基于分布式数据中间件的数据库映射模式的示意图;
图20为本申请实施例提供的基于分布式数据中间件的表映射模式的示意图;
图21为本申请实施例提供的电子设备的结构示意图。
具体实施方式
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。
下面首先示例性地介绍本申请实施例可能涉及的系统架构和应用场景。
参见图1示出的本申请实施例提供的系统架构示意框图,该系统可以包括第一电子设备11,以及至少一个第二电子设备12。第一电子设备11与第二电子设备12之间能够通过通信连接相互通信。第一电子设备11和第二电子设备12之间的通信连接可以为短距离通信连接,例如,Wi-Fi点对点连接及蓝牙连接等;也可以为长距离通信连接,例如,互联网连接,在此不对通信连接的具体类型作限定。
第一电子设备11可以为手机、平板电脑及笔记本电脑等终端设备,也可以为服务器等非终端设备。同理,第二电子设备12可以为手机、平板电脑及笔记本电脑等终端设备,也可以为服务器等非终端设备。本申请实施例对第一电子设备11和第二电子设备12的设备类型不作限定。
示例性地,参见图2示出的本申请实施例提供的系统架构具体示意图,该系统包括手机21、手机22、平板23以及云端服务器24。此时,第一电子设备具体为手机21,而第二电子设备包括手机22、平板23及云端服务器24。
其中,手机21和手机22之间的通信连接可以为Wi-Fi点对点连接,手机21和平板23之间的通信连接可以为Wi-Fi点对点连接,手机21和云端服务器24之间的通信 连接可以为互联网连接。
基于第一电子设备11和第二电子设备12之间的通信连接,第一电子设备11可以将第二电子设备12的数据映射至本地存储空间,这样,第一电子设备11则可以在本地存储空间访问第二电子设备12的数据,实现跨设备的数据融合访问。同理,第二电子设备12也可以将第一电子设备11的数据映射至本地存储空间,以实现跨设备的数据融合访问。
其中,数据融合访问是指通过一次查询请求,可以对多个电子设备的数据进行过滤查询、排序查询等。例如,第一电子设备11将第二电子设备12的数据库映射至本地存储空间,并将第一电子设备12的数据库和本地数据库进行虚拟化,得到一个虚拟数据库。基于该虚拟数据库,第一电子设备11可以通过一次查询请求,从该虚拟数据库中访问第一电子设备11的数据和第二电子设备12的数据,对这两个设备的数据进行过滤、排序等,得到查询结果。
跨设备访问的数据可以是媒体数据,例如,视频、音频以及图片等;也可以是其它类型的数据,本申请实施例对跨设备访问的数据类型不作限定。
示例性地,在分布式图库场景下,用户可以在手机21上的图库,浏览或搜索手机22、平板23以及云端服务器24上任一个电子设备上存储的图片。
下面将对本申请实施例提供的技术方案进行具体阐述。
本申请实施例提供的技术方案可以包括数据映射过程、数据变更监听过程以及数据融合访问过程。
数据映射过程(又可称数据传输过程):
在数据映射过程中,本申请实施例将数据库或数据库表作为一个整体映射至对端设备,实现数据库级别或文件级别的数据同步。相较于普通的数据同步过程,本申请实施例的数据映射过程,可以提高数据同步速度,数据可用速度更快。
具体来说,普通的数据同步过程是一条条数据同步的,并且读写过程涉及数据格式转换,耗时较长,数据同步速度较慢。例如,第一电子设备为了将第二电子设备的数据同步至本地,逐条地读取第二电子设备的数据,并将读取到的数据写入本地,在读写过程中需要进行格式转换。
而本申请实施例的数据映射过程,实现了数据库级别或文件级别的数据同步,不涉及数据格式转换,减少了数据同步时间,提高了数据同步速度,使得数据可用速度更快。
例如,第二电子设备联网后,通过本申请实施例的数据映射过程,在极短时间内将第二电子设备的数据映射至第一电子设备,这样,第二电子设备的数据即可被第一电子设备使用(例如,查询),数据可用速度快,实现即插即用,即第二电子设备一上线,第一电子设备即可在本地访问到第二电子设备的数据。
另外,由于本申请实施例的数据映射过程提高了数据同步速度,进一步提高了跨设备数据融合访问性能。
为了更好地介绍数据映射过程,下面将结合附图对数据映射过程进行具体介绍。
参见图3示出的本申请实施例提供的数据映射过程的一种流程示意框图,该方法可以包括以下步骤:
步骤S301、第一电子设备向第二电子设备发送第一事件。
上述第一事件可以包括但不限于第一电子设备的设备信息和数据库版本信息。第一电子设备的设备信息包括但不限于设备类型、设备标识以及互联网协议地址(Internet Protocol Address,IP)等。第一电子设备的数据库版本信息用于描述第一电子设备的本地数据库的版本号(即version code)等信息。
在一些实施例中,第一事件可以包括数据库版本信息,而在另一些实施例中,第一事件可以不包括数据库版本信息。
上述第一事件可以表现为设备上线事件,即第一电子设备和第二电子设备建立通信连接之后,为了将第二电子设备的数据映射至本地,第一电子设备可以向第二电子设备发送设备上线事件。例如,手机和平板建立Wi-Fi点对点连接之后,为了将平板的数据映射至手机本地,手机向平板发送设备上线事件,或者手机已连接至无线路由器,在平板连接至同一个无线路由器之后,手机向平板发送设备上线事件。
当然,第一事件不限于设备上线事件,其可以为其它可以起到相同作用的事件,并且,第一电子设备发送第一事件的时间点也不限于设备上线之后。
步骤S302、第二电子设备向第一电子设备发送第二事件。
上述第二事件可以包括但不限于第二电子设备的设备信息和数据库版本信息。第二电子设备的设备信息包括但不限于设备类型、设备标识以及IP地址等。第二电子设备的数据库版本信息用于描述第二电子设备的本地数据库的版本号等信息。在一些情况下,第二事件也可以不包括数据库版本信息。
上述第二事件可以表现为设备上线事件,即第一电子设备和第二电子设备建立通信连接之后,为了将第一电子设备的数据映射至本地,第二电子设备可以向第一电子设备发送设备上线事件。当然,第二事件不限于设备上线事件,可以为其它类型的事件。并且,第二电子设备发送第二事件的时间点也不限于设备上线之后。
需要说明的是,上述步骤S301和步骤S302之间的执行顺序可以是任意的。
步骤S303、第二电子设备根据第一事件,建立第一源数据集合的第一映射数据集合。
第一源数据集合是指第二电子设备本地的数据集合,其可以具体为数据库或数据库表。当第一源数据集合为数据库时,第一映射数据集合相应地为本地数据库的映射数据库;当第一源数据集合为数据库表时,第一映射数据集合相应地为本地数据库表的映射表。
步骤S304、第二电子设备向第一电子设备发送第一映射数据集合。
如果第一映射数据集合为映射数据库,第一电子设备接收到第一映射数据集合之后,可以将该第一映射数据集合和本地数据库虚拟化成一个虚拟数据库,以方便后面的数据融合访问。当然,如果不用进行数据融合访问,可以不用将第一映射数据集合和本地数据集合虚拟化成一个虚拟数据库。
如果第一映射数据集合为映射表,第一电子设备在接收到第一映射数据集合之后,可以将第一映射数据集合装入中间结果数据库。
第一电子设备接收到第一映射数据集合之后,可以将第二电子设备的设备信息和第一映射数据集合进行关联,这样可以通过第二电子设备的设备信息查询到第一映射 数据集合。
步骤S305、第一电子设备根据第二事件,建立第二源数据集合的第二映射数据集合。
上述第二源数据集合是指第一电子设备的本地数据集合,其可以为数据库或数据库表。当第一源数据集合为本地数据库,第二映射数据集合则为本地数据库的映射数据库;当第一源数据集合为本地数据库表,第二映射数据集合则为本地数据库表的映射表。
步骤S306、第一电子设备向第二电子设备发送第二映射数据集合。
如果第二映射数据集合为映射数据库,第二电子设备接收到第二映射数据集合之后,可以将该第二映射数据集合和本地数据库虚拟化成一个虚拟数据库,以实现数据融合访问。当然,如果不用进行数据融合访问,可以不用将第二映射数据集合和本地数据集合虚拟化成一个虚拟数据库。
如果第二映射数据集合为映射表,第二电子设备在接收到第二映射数据集合之后,可以将第二映射数据集合装入中间结果数据库。
第二电子设备接收到第二映射数据集合之后,可以将第一电子设备的设备信息和第二映射数据集合进行关联,这样可以通过第一电子设备的设备信息查询到第二映射数据集合。
图3示出了第二电子设备将本地数据集合映射至第一电子设备的过程,具体包括步骤S301、步骤S303以及步骤S304;还示出了第一电子设备将本地数据集合映射至第二电子设备的过程,具体包括步骤S302、步骤S305以及步骤S306。也就是说,在一些实施例中,本申请实施例的数据映射过程可以包括第二电子设备将本地数据集合映射至第一电子设备的过程,以及第一电子设备将本地数据集合映射至第二电子设备的过程。
在另一些实施例中,数据映射过程可以只包括第二电子设备将本地数据集合映射至第一电子设备的过程,即第一电子设备将第二电子设备的数据集合映射至本地,不用将本地数据集合映射至第二电子设备;也可以只包括第一电子设备将本地数据集合映射至第二电子设备的过程。
由上可见,本申请实施例将数据库或数据库表作为一个整体映射至对端设备,实现数据库级别或文件级别的数据同步,减少了数据同步耗时,数据可用速度更快,进一步提高了跨设备的数据融合访问性能。
根据第一电子设备或第二电子设备建立的映射数据集合类型的不同,数据映射过程可以分为数据库映射流程或表映射流程。其中,当第一电子设备或第二电子设备建立的映射数据集合是映射数据库,数据映射过程则为数据库映射流程,又称数据库映射模式;当第一电子设备或第二电子设备建立的映射数据集合是映射数据库表,数据映射过程则为表映射流程,又称表映射模式。下面将分别对这两种模式进行介绍。
数据库映射流程:
参见图4示出的本申请实施例提供的数据库映射模式的一种流程示意图,该流程可以包括以下步骤:
步骤S401、第一电子设备向第二电子设备发送第一事件。
步骤S402、第二电子设备根据第一事件中的数据库版本信息,创建第一源数据库的第一空映射数据库。
此时,第一源数据集合具体为第一源数据库,其为第二电子设备的本地数据库,上述第一空映射数据库是指空的数据库,还没有装入数据,还是一个空库。
第二电子设备基于第一事件中的数据库版本信息,比较第一电子设备的数据库版本和第二电子设备的数据库版本之间的高低。
如果第一电子设备的数据库版本高于第二电子设备的数据库版本,上述第一空映射数据库的版本和第一源数据库的版本一致,并且,第一空映射数据库的表结构和第一源数据库的表结构一致。
如果第一电子设备的数据库版本低于或等于第二电子设备的数据库版本,上述第一空映射数据库的版本和第一源数据库的版本一致,并且,第一空映射数据库内的表结构和第一电子设备的本地数据库的表结构一致。其中,高版本数据库可以知道低版本数据库的表结构信息,故第二电子设备可以得知第一电子设备的数据库的表结构信息。
步骤S403、第二电子设备将第一源数据库和第一空映射数据库进行虚拟化,得到第一虚拟数据库。
步骤S404、第二电子设备在第一虚拟数据库内进行数据映射,以将第一源数据库中的数据映射至第一空映射数据库,得到映射完成的映射数据库。
其中,如果第一电子设备的数据库版本低于或等于第二电子设备的数据库版本,第一空映射数据库内的表结构和第一电子设备的本地数据库的表结构一致,故在数据映射时按照第一电子设备的本地数据库的表结构过滤数据。
步骤S405、第二电子设备基于映射完成的映射数据库,得到第一映射数据库。此时,第一映射数据集合具体为第一映射数据库。
如果第一电子设备的数据库版本高于第二电子设备的数据库版本,第二电子设备将映射完成的映射数据库作为第一映射数据集合。
如果第一电子设备的数据库版本低于第二电子设备的数据库版本,第二电子设备将映射完成的映射数据库进行数据库版本降级,得到第一映射数据库,第一映射数据库的版本和第一电子设备的本地数据库的版本一致。
步骤S406、第一电子设备接收来自第二电子设备的第一映射数据库。
如果第一电子设备的数据库版本低于或等于第二电子设备的数据库版本,则第一映射数据库的版本与第一电子设备本地数据库的版本一致,且表结构也与第一电子设备本地数据库的表结构一致,此时,第一电子设备在接收到第一映射数据库之后,可以将第一映射数据库和本地数据库进行虚拟化,得到第三虚拟数据库。
如果第一电子设备的数据库版本高于第二电子设备的数据库版本,则第一映射数据库的版本与第二电子的第一源数据库的版本一致,且表结构也与第二电子设备的第一源数据库的表结构一致,此时,第一电子设备需要将第一映射数据库进行版本升级,得到版本升级后的映射数据库。版本升级后的映射数据库的版本和第一电子设备的本地数据库的版本一致,且表结构也与第一电子设备的本地数据库的表结构一致。第一电子设备在版本升级完成后,再将版本升级后的映射数据库和本地数据库进行虚拟化, 得到第三虚拟数据库。
基于第三虚拟数据库,第一电子设备可以跨设备融合访问第二电子设备的数据。
其中,第一电子设备在接收到第一映射数据库之后,可以将第二电子设备的设备信息和第一映射数据库关联。
需要说明的是,将映射数据库和本地的源数据库进行虚拟化,得到一个虚拟化数据库,可以避免数据逐条融合的情况下实现数据融合。同时,也是为了让后续的数据融合访问得以实现,即可以通过一次查询请求,从一个数据库中查询、过滤多个电子设备的数据。当然,在另一些实施例中,也可以不用执行将映射数据库和本地的源数据库进行虚拟化的步骤。
还需要说明的是,第二电子设备中的第一映射数据库、第一虚拟数据库是临时存在的,具体地,第二电子设备向第一电子设备发送第一映射数据库之后,可以在本地缓存中清除第一映射数据库。同理,映射完成的数据库在执行数据版本降级之后,第二电子设备也可以在本地缓存中清除该映射完成的数据库。在将第一源数据库中的数据映射至第一空映射数据库之后,第二电子设备可以撤销第一虚拟数据库。
可以看出,数据库映射流程将数据库作为一个整体映射至对端设备,减少了数据同步耗时,提高了数据可用速度,提高了跨设备的数据融合访问性能。
为了更好地介绍数据库映射过程,下面将结合图5、图6和图7进行介绍说明。其中,图5为本申请实施例提供的数据库版本相同时的数据库映射示意图,图6为本申请实施例提供的高版本向低版本映射的数据库映射示意图,图7为本申请实施例提供的低版本向高版本映射的数据库映射示意图。
参见图5,第二电子设备52包括源数据库53和映射数据库54,第一电子设备51包括映射数据库54和目标数据库55。
此时,第一电子设备51和第二电子设备52的数据库版本相同,表结构相同,即源数据库53和目标数据库55的版本相同,表结构相同。上述第一源数据集合具体为源数据库53,第一映射数据集合具体为映射数据库54。第一电子设备的本地数据库为目标数据库55。
第二电子设备52接收来自第一电子设备51的第一事件之后,创建源数据库53的第一空映射数据库。第一空映射数据库的表结构和目标数据库53的表结构一致,且数据库版本和源数据库53的版本一致;然后,将第一空映射数据库和源数据库53进行虚拟化,得到第一虚拟数据库,并在第一虚拟数据库内进行快速数据映射,将源数据库53的数据映射至第一空映射数据库,得到映射数据库54;最后,将映射数据库54传输至第一电子设备51。
第一电子设备51接收到映射数据库54之后,将映射数据库54和目标数据库55进行虚拟化,得到第三虚拟数据库。
其中,第二电子设备52可以将映射数据库54的数据库文件传输至第一电子设备51,也可以将映射数据库54的数据传输至第一电子设备51。
在一些实施例中,第二电子设备52在第一虚拟数据库执行数据映射,得到映射数据库54之后,可以撤销第一虚拟数据库,在向第一电子设备51发送映射数据库54之后,可以在本地缓存中清除映射数据库54。
参见图6,第二电子设备62的数据库版本高于第一电子设备61的数据库版本,即源数据库63的版本高于目标数据库66。第二电子设备62包括源数据库63、映射数据库64以及映射数据库65,第一电子设备61包括映射数据库65和目标数据库66。
此时,上述第一源数据集合具体为源数据库63,映射完成的映射数据库为映射数据库64,第一映射数据集合具体为映射数据库65,第一电子设备的本地数据库为目标数据库66。
第二电子设备62接收到来自第一电子设备61的第一事件之后,根据第一事件中的数据库版本信息,确定源数据库63的版本高于目标数据库66的版本,并基于目标数据库66的数据库版本信息,得知目标数据库66的表结构信息;然后,创建源数据库63的第一空映射数据库,此时,第一空映射数据库的版本和源数据库63的版本一致,表结构和目标数据库66的表结构一致。再将源数据库63和第一空映射数据库进行虚拟化,得到第一虚拟数据库,并在第一虚拟数据库内进行快速数据映射,按照目标数据库66的表结构进行数据过滤,以将源数据库63的数据映射至第一空映射数据库,得到映射数据库64。映射数据库64的版本和源数据库63的版本一致,表结构和目标数据库66的表结构一致。
接着,第二电子设备62将映射数据库64进行版本降级,得到映射数据库65。映射数据库65的版本和目标数据库66的版本一致,表结构和目标数据库66的表结构一致。最后,第二电子设备62将映射数据库65传输至第一电子设备61。
第一电子设备61接收到映射数据库65之后,将映射数据库65和目标数据库66进行虚拟化,得到第三虚拟数据库。
在一些实施例中,第二电子设备62在执行数据映射,得到映射数据库64之后,可以撤销第一虚拟数据库;在执行版本降级,得到映射数据库65之后,可以在本地缓存中清除映射数据库64;在向第一电子设备61发送映射数据库65之后,可以在本地缓存中清除映射数据库65。
参见图7,第一电子设备71的数据库版本高于第二电子设备72的数据库版本,即目标数据库76的版本高于源数据库73的版本。第一电子设备71包括目标数据库76、映射数据库75和映射数据库74,第二电子设备72包括源数据库73和映射数据库74。
此时,上述第一源数据集合具体为源数据库73,映射完成的映射数据库和第一映射数据集合均具体为映射数据库74,第一电子设备的本地数据库为目标数据库76。
第二电子设备72接收到第一电子设备71的第一事件之后,根据第一事件中的数据库版本信息,确定目标数据库76的版本高于源数据库73的版本;然后,创建源数据库73的第一空映射数据库,该第一空映射数据库的版本和源数据库73的版本一致,表结构和源数据库73的表结构一致;接着,将第一空映射数据库和源数据库73进行虚拟化,得到第一虚拟数据库,并在第一虚拟数据库进行快速数据映射,得到映射数据库74。映射数据库74的版本和源数据库73的版本一致,表结构和源数据库73的表结构一致;最后,第二电子设备72将映射数据库74传输至第一电子设备71。
第一电子设备71接收到映射数据库74之后,对映射数据库74进行数据库版本升级,得到映射数据库75。映射数据库75的版本和目标数据库76的版本一致,表结构 和目标数据库76的表结构一致。然后,第一电子设备71将映射数据库75和目标数据库76进行虚拟化,得到第三虚拟数据库。
在一些实施例中,第二电子设备72在执行数据映射,得到映射数据库74之后,可以撤销第一虚拟数据库;在向第一电子设备71发送映射数据库74之后,可以清除本地缓存中的映射数据库74。另外,第一电子设备71在执行版本升级得到映射数据库75之后,可以清除本地缓存中的映射数据库74。
本申请实施例提供了设备间表结构相同(即数据库版本相同)时的数据库映射流程,以及设备间表结构不同(即数据库版本不同)时的数据库映射流程,这样,即使设备之间的表结构不同时仍然可以实现数据库映射,应用范围更广。
上文示出了第二电子设备根据第一电子设备的第一事件,建立第一源数据集合的第一映射数据集合的具体过程,下文将对第一电子设备根据第二电子设备的第二事件,建立第二源数据集合的第二映射数据集合的过程进行介绍。
参见图8示出的本申请实施例提供的数据库映射模式的一种流程示意图,该流程可以包括以下步骤:
步骤S801、第二电子设备向第一电子设备发送第二事件。
步骤S802、第一电子设备根据第二事件中的数据库版本信息,创建第二源数据库的第二空映射数据库。
第二源数据库是指第一电子设备的本地数据库。第二事件包括的数据库版本信息用于描述第二电子设备本地数据库的版本。第二孔映射数据库是指空的数据库,还没有装入数据。
步骤S803、第一电子设备将第二源数据库和第二空映射数据库进行虚拟化,得到第四虚拟数据库。
步骤S804、第一电子设备在第四虚拟数据库内进行数据映射,以将第二源数据库中的数据映射至第二空映射数据库,得到映射完成的映射数据库。
步骤S805、第一电子设备基于映射完成的数据库,得到第二映射数据库。
步骤S806、第一电子设备向第二电子设备发送第二映射数据库。
第二电子设备在接收到第二映射数据库之后,可以根据第二映射数据库和第二源数据库进行虚拟化,得到第三虚拟数据库。基于第三虚拟数据库,第二电子设备可以跨设备融合访问第一电子设备的数据。
需要说明的是,第二电子设备建立第二映射数据库的过程与第一电子设备建立第一映射数据库的过程类似,相同或类似的部分请参见图4、图5、图6以及图7的相关内容,在此不再赘述。
在介绍完数据库映射流程之后,下面将结合图9对表映射流程进行介绍。
表映射流程:
参见图9示出的本申请实施例提供的表映射流程的一种示意图,该表映射流程可以包括以下步骤:
步骤S901、第一电子设备向第二电子设备发送第一事件。
此时,由于第二电子设备在创建第一映射表时,可以不考虑数据库版本,因此,第一事件可以不包括数据库版本信息。
步骤S902、第二电子设备根据第一事件,建立第一源表的第一映射表。
此时,上述第一源数据集合具体为第一源表,上述第一映射数据集合具体为第一映射表。第一源表是指第二电子设备本地数据库内的数据库表。
具体应用中,第二电子设备将第一源表的数据内容映射到第一映射表时,可以用不考虑第一映射表和第一源表之间的结构是否相同。
步骤S903、第二电子设备向第一电子设备发送第一映射表。
步骤S904、第二电子设备向第一电子设备发送第二事件。
同理,第一电子设备在创建第二映射表时,可以不需要考虑数据库版本,因此,第二事件可以不包括数据库版本信息。
步骤S905、第一电子设备根据二事件,建立第二源表的第二映射表。
此时,上述第二源数据集合具体为第二源表,上述第二映射数据集合具体为第二映射表。第二源表是指第一电子设备本地数据库内的数据库表。第二映射表的结构和第二源表的结构一致。
同理,第一电子设备将第二源表的数据内容映射到第二映射表时,可以用不考虑第二映射表和第二源表之间的结构是否相同。
步骤S906、第一电子设备向第二电子设备发送第二映射表。
第一电子设备接收到第二电子设备的第一映射表之后,可以将第二电子设备的设备信息和第一映射表关联。同理,第二电子设备可以将第一电子设备的设备信息和第二映射表关联。
可以看出,将数据库表作为一个整体映射至对端设备,实现了数据库表级的数据同步,减少了数据同步耗时,提高了数据可用速度。
在一些实施例中,为了实现跨设备的数据融合访问,第一电子设备或第二电子设备可以创建中间结果数据库,将对端设备的映射表装入中间结果数据库,将本地的映射表装入中间结果数据库,这样,通过一次查询则可以从中间结果数据库中访问多个设备的数据。
具体地,第一电子设备在本地数据数据库初始化之后,可以创建本地数据库表的映射表。第一电子设备向第二电子设备发送第一事件,创建中间结果数据库;在接收到来自第二电子设备的第一映射表之后,将第一映射表和本地数据库表的映射表装入已创建的中间结果数据库。这样,第一电子设备上的应用程序可以通过一次查询请求,从中间结果数据库中访问第一电子设备的数据和第二电子设备的数据。
同理,第二电子设备在本地数据库初始化之后,可以创建本地数据库表的映射表,向第一电子设备发送第二事件,创建中间结果数据库;在接收来自第一电子设备的第二映射表之后,将第二映射表和本地数据库表的映射表装入已创建的中间结果数据库。第二电子设备上的应用程序可以通过一次查询请求,从中间结果数据库中访问第一电子设备的数据和第二电子设备的数据。
需要说明的是,本申请实施例提供的数据库级别和数据库表级别的数据映射同步方案,可以应用于数据融合访问场景,也可以应用于其它场景。
数据变更监听过程:
第一电子设备或第二电子设备在接收对端设备的映射数据集合之后,可以实时监 听对端设备的数据变更信息,并在接收到对端设备的数据变更信息之后,基于数据变更信息将变更数据装入本地存储空间中的对端设备的映射数据集合。
参加图10示出的本申请实施例提供的数据变更监听过程的一种示意图,该过程可以包括以下步骤:
步骤S1001、第二电子设备基于数据状态信息,监听本地数据是否发生变更。
上述数据状态信息是第二电子设备在执行数据映射创建的。例如,如图5、图6和图7所示,第二电子设备在第一虚拟数据库中执行数据映射时,则记录数据状态信息。该数据状态信息用于描述映射至对端设备的数据的状态,其可以具体为数据状态树。
第二电子设备以数据状态信息作为依据,将当前时刻的数据和数据状态信息中记录的数据状态进行比较,判断当前时刻的数据相较于之前映射至第一电子设备的数据是否发现变化。
步骤S1002、当监听数据发生变更时,第二电子设备生成数据变更信息。
如果确定数据发生变更,第二电子设备则根据变化的数据,生成数据变更信息。该数据变更信息用于描述变更的数据。
在一些实施例,第二电子设备在生成数据变更信息之后,还可以修改数据状态信息,即根据变化的数据,更新数据状态信息中关于变化数据的状态记录。修改后的数据状态信息可以用于下一次判断数据是否变化的依据。
步骤S1003、第二电子设备向第一电子设备发送数据变更信息。
在一些实施例中,第二电子设备可以通过变更脚本监听和记录数据变化,并将数据变更信息记录在变更脚本内的表,再将变更脚本传输至第一电子设备。这样实现了文件级别的同步,提高了数据变更同步速度。
当然,在另一些实施例中,第二电子设备也可以将变更数据逐条同步至第一电子设备。
步骤S1004、第一电子设备根据数据变更信息,将变更数据装入第二电子设备的第一映射数据集合。
在数据库映射模式下,第一电子设备和第二电子设备的数据库版本可能不相同,此时,第一电子设备可以根据数据库版本的高低,将变更数据与第一映射数据集合中的数据进行融合。下面结合图11和图12对数据变更监听过程进行介绍。
参见图11示出的本申请实施例的提供的高版本向低版本同步的数据变更监听过程示意图,第一电子设备111的数据库版本低于第二电子设备112的数据库版本,第二电子设备112包括源数据库113和变更脚本114,第一电子设备111包括变更脚本114、映射数据库115和目标数据库116。
其中,源数据库113为第二电子设备112的本地数据库,映射数据库115是源数据库113的映射数据库,目标数据库116是第一电子设备的本地数据库。
经过数据映射过程,第二电子设备112在将源数据库113的映射数据库传输至第一电子设备111,第一电子设备111将映射数据库115和目标数据库116虚拟化成一个虚拟数据库。
在数据映射之后,第二电子设备112基于数据映射过程创建的数据状态树,通过 变更脚本114实时监听源数据库113的数据变化,并将源数据库113的变化数据记录在变更脚本114内的表中。其中,变更脚本114中的表结构和目标数据库116的数据库一致。此时,上述数据变更信息具体表现为变更脚本114。
第二电子设备112在确定出数据发生变化之后,将变化的数据记录在变更脚本114内的数据库表中,并且更新数据状态树,再将变更脚本114传输至第一电子设备111。
第一电子设备111接收到变更脚本114之后,通过变更脚本114将变化的数据批量装入映射数据库115。这样,在数据映射之后,当第二电子设备的数据发生变化时,可以实时将变化的数据同步至第一电子设备。
参见图12示出的本申请实施例提供的低版本向高版本同步的数据变更监听过程示意图,第一电子设备121的数据库版本高于第二电子设备122的数据库版本。第二电子设备122包括源数据库123和变更脚本124,第一电子设备121包括变更脚本124、变更脚本125、映射数据库126以及目标数据库127。
其中,源数据库123为第二电子设备122的本地数据库,映射数据库126是源数据库123的映射数据库,目标数据库127为第一电子设备121的本地数据库。
经过数据映射过程,第二电子设备122在将源数据库123的映射数据库传输至第一电子设备121,第一电子设备121将映射数据库126和目标数据库127虚拟化成一个虚拟数据库。
在数据映射之后,第二电子设备122基于数据映射过程创建的数据状态树,通过变更脚本124实时监听源数据库113的数据变化,并将源数据库123的变化数据记录在变更脚本124内的表中。其中,变更脚本124的表结构和源数据库123的数据库的表结构一致。此时,上述数据变更信息具体表现为变更脚本124。
第二电子设备122在确定出数据发生变化之后,将变化的数据记录在变更脚本124内的数据库表中,并且更新数据状态树,将变更脚本124传输至第一电子设备121。
第一电子设备121接收到变更脚本124之后,先将变更脚本124进行版本升级,得到变更脚本125,变更脚本125的表结构和目标数据库127的表结构一致。然后,通过变更脚本125将变化的数据批量装入映射数据库126。这样,在数据映射之后,当第二电子设备的数据发生变化时,可以实时将变化的数据同步至第一电子设备。
当第一电子设备的数据库版本等于第二电子设备的数据库版本时,数据变更监听过程可以如图11所示,即两个设备的数据库版本相同时的数据变更监听过程可以和高版本向低版本同步时的数据变更监听过程相同。
当数据映射流程为表映射流程时,第二电子设备可以通过变更脚本监听并记录数据变化,并将变更数据记录在变更脚本内的表中。第一电子设备在接收到来自第一电子设备的变更脚本时,可以通过变更脚本将变化的数据批量装入中间结果数据库的对应映射表中,该对应映射表是指第二电子设备的本地数据库表的映射表。
上文示出当第二电子设备一侧的数据发生变化时,第一电子设备一侧和第二电子设备一侧的流程。而当第一电子设备一侧的数据发生变化时,第一电子设备一侧的流程与上文第二电子设备一侧的流程类似,第二电子设备一侧的流程与上文第一电子设备一侧的流程类似,在此不再赘述。
本申请实施例中,在数据映射时记录数据状态信息,并基于数据状态信息实时监 听数据是否发现变化,当数据发现变化时,基于数据状态信息将变化的数据同步至对端设备,可以实现跨设备的数据状态管理,实现跨设备数据实时查询。
数据融合访问过程:
电子设备可以通过数据库链接(Data Base link,DBlink)实现跨设备数据融合访问。
具体地,电子设备在本地数据库内预先设置对端设备的DBlink;在获取访问请求之后,首先基于对端设备的DBlink,链接对端设备的数据库,然后对对端设备的数据库进行扫描,且把对端设备数据库的全部数据传回本地数据库;最后断开与对端设备的数据库链接,返回访问请求对应的访问结果。这样,电子设备即可通过一次查询,在本地数据库中查询到对端设备的数据,实现跨设备的数据访问。
由上可见,从发起访问到获得访问结果,经过了链接对端设备的数据库、对端设备的数据库扫描以及数据回传等过程,耗时较长,从而导致跨设备数据访问性能低下。并且,将对端设备的数据回传至本地,数据传输量较大,会占用较多带宽,传输时间的长短取决网络质量好坏,即网络传输质量好坏影响着跨设备数据访问性能高低。
下面将从第一电子设备一侧示例性介绍数据融合访问过程。第二电子设备一侧的数据融合访问过程可以参见第一电子设备一侧的过程,在此不再赘述。
参见图13示出的本申请实施例提供的数据融合访问过程的一种流程示意框图,该过程可以包括以下步骤:
步骤S1301、第一电子设备获取应用程序的数据访问请求,第一电子设备包括应用程序。
第一电子设备上的应用程序可以例如为图库或第三方应用程序等,在此不对应用程序作限定。
步骤S1302、第一电子设备确定数据访问请求包括第二电子设备的设备标识,则查询目标数据库中的第一数据集合,得到第一查询结果,第一数据集合为第二电子设备的本地数据集合的映射数据集合,目标数据库包括第一数据集合和第二数据集合,第二数据集合为第一电子设备的本地数据集合或本地数据集合的映射数据集合,第一电子设备包括目标数据库。
应用程序发起的数据访问请求中携带着有设备标识,该设备标识用于唯一标识设备,例如,该设备标识可以具体为设备ID。当数据访问请求携带有设备标识,根据预先建立的设备标识和数据集合之间的关联关系,访问对应设备的数据;当数据访问请求没有携带有设备标识,则访问所有设备的数据。
第二电子设备的设备标识可以是预先存储在第一电子设备本地。示例性地,在数据映射过程,第一电子设备接收来自第二电子设备的第二事件,将第二事件中携带的第二电子设备的设备标识存储在本地。
上述目标数据库可以为虚拟数据库或中间结果数据库。当目标数据库为虚拟数据库时,第一数据集合具体为第二电子设备的本地数据库的映射数据库,第一数据集合具体为第一电子设备的本地数据库。当目标数据库为中间结果数据库时,第一数据集合具体为第二电子设备的本地数据库表的映射表,第一数据集合具体为第一电子设备的本地数据库表的映射表。
当数据访问请求中包括第二电子设备的设备标识时,第一电子设备则查询目标数据库中的第二电子设备的映射数据库,获得第一查询结果。
步骤S1303、第一电子设备向应用程序返回第一查询结果。
可选地,步骤S1304、第一电子设备确定数据访问请求不包括设备标识,则查询目标数据库中的第一数据集合和第二数据集合,得到第二查询结果,并向应用程序返回第二查询结果。
步骤S1305、第一电子设备确定数据访问请求包括第一电子设备的设备标识,则查询目标数据库中的第二数据集合,得到第三查询结果,并向应用程序返回第三查询结果。
以跨设备媒体数据融合访问为例,参见图14示出的本申请实施例提供的跨设备媒体数据融合访问示意图,第一电子设备141将第二电子设备142的数据以及云端143的数据映射至本地的媒体图书库数据库,这样,第一电子设备141的应用程序在需要访问第二电子设备142或云端143的数据时,可以通过访问本地的媒体图书库数据库内的对应数据,实现跨设备数据融合访问。此时,云端143可以看作一个设备。
其中,第一电子设备141包括媒体图书库(Media library),媒体图书库是华为自研的媒体数据管理框架,支持应用程序访问分布式媒体数据。
第一电子设备141示例性包括应用程序1、应用程序2、应用程序3以及应用程序4,每个应用程序均可以通过调用媒体图书库统一接口进行跨设备媒体数据融合访问。
示例性地,应用程序1可以通过调用媒体图书库统一接口,发起数据访问请求,并在该数据访问请求中指定第二电子设备142的设备标识,即应用程序1需要访问第二电子设备142的媒体数据;媒体图书库服务框架将数据访问请求传递至媒体数据融合访问模块,媒体数据融合访问模块基于数据访问请求中携带的设备标识,查询融合数据中的第二电子设备的数据,得到查询结果;最后,媒体图书库数据库向应用程序1返回查询结果。
示例性地,参见图15示出的本申请实施例提供的跨设备访问图像数据的示意图,此时,第一电子设备具体为手机151,第二电子设备包括平板和手机2。
如图15所示,手机151的主界面包括设置、日历、时钟、应用商城以及图库152等多个应用程序。当手机151接收到针对图库152的点击操作,手机151则响应于该点击操作,显示相册界面153。相册界面153显示有本机上的照片、视频和相机图片等。用户如果需要访问其他设备的图像数据,可以点击相机界面153上的“其他设备”。手机151接收到针对“其他设备”的点击操作时,响应于该点击操作,显示界面154。界面154包括平板的文件夹155和手机2的文件夹156。
用户如果想要跨设备访问平板上的数据,则可以点击文件夹155,如果想要跨设备访问手机2上的数据,则可以点击文件夹156。
手机151接收到针对文件夹155的点击操作,则响应于该点击操作,显示界面157。界面157包括相机文件夹158、图片文件夹159、华为分享文件夹1510以及截屏录屏文件夹1511。
手机151则响应于针对文件夹155的点击操作,调用媒体图书库统一接口以发起数据访问请求,并在数据访问请求中指定平板的设备标识。手机151中的媒体数据融 合访问模块基于数据访问请求,查询媒体图书库数据库中的平板的数据,并将查询结果返回给图库。图库接收到查询结果之后,基于该查询结果显示界面157。
手机151接收到针对相机文件夹158的点击操作,则响应于该点击操作,显示界面1512,界面1512包括平板相机拍摄的各张照片。这样,用户即可在手机151上访问平板上的图像数据。
参见图16示出的本申请实施例提供的跨设备图片搜索示意图,基于图15,手机的相机界面上包括搜索框161,用户可以在搜索框161上输入相应信息,以搜索本机或其他设备的照片。示例性地,用户在搜索框161上输入了“8.7”,即用户搜索拍摄时间为8月7日的照片。在用户输入完成之后,手机基于搜索结果,显示界面162。此时,手机在本机上找到一张符合搜索条件的照片,在平板上找到2张符合搜索条件的照片。
当用户在搜索框161上输入搜索条件时,图库通过调用媒体图书库统一接口,以发起数据访问请求,此时,该数据访问请求中没有包含设备标识,即需要查询所有设备的数据。手机上的数据融合访问模块基于图库发起的数据访问请求,查询媒体图书库数据库中本机的数据、平板的数据以及手机2的数据,得出查询结果,并向图库返回查询结果。图库接收到该查询结果之后,基于查询结果显示界面162。
本申请实施例提供的跨设备数据融合访问方案,第一电子设备将第二电子设备(即对端设备)的数据预先映射至本地存储空间,使得访问第二电子设备的数据时可以像访问本地数据库一样,即提供类本地数据库访问的跨设备数据访问。并且,在访问第二电子设备的数据时,从访问请求发起至获得查询结果的过程,不用涉及链接远端数据库、远端数据库的数据回传等过程,查询速度不受网络传输质量影响,耗时较短,进而使得跨设备数据访问性能较高。另外,第一电子设备将本地数据集合和对端设备的映射数据集合集成在一个目标数据库中,通过一次查询请求即可对多个设备的数据进行查询、过滤,实现了跨设备数据融合访问。
在数据融合访问之前,需要将第二电子设备的数据同步至第一电子设备本地。在一些实施例中,可以将第二电子设备的数据逐条同步至第一电子设备的本地存储空间,也可以通过上文提及的数据映射过程,将第二电子设备的数据库或数据库表整体映射至第一电子设备,当然,也可以通过其它方式将第二电子设备的数据同步至第一电子设备本地存储空间。相较而言,将数据库或数据库表作为一个整体映射至对端设备的方式,减少了数据同步耗时,提高了数据可用速度。
当上述目标数据库为虚拟数据库时,则采用数据库映射方式将第二电子设备的数据映射至第一电子设备本地。当上述目标数据库为中间结果数据库时,则采用表映射方式将第二电子设备的数据映射至第一电子设备本地。数据映射流程的不同,跨设备数据融合访问的过程可能也会有所不同,下面结合图17和图18对两种模式下的访问过程进行示例性介绍。
参见图17示出的本申请实施例提供的数据库映射模式下的数据融合访问示意图,如图17所示,第一电子设备171包括媒体图书库(Media library)、媒体数据融合访问模块174以及融合数据管理模块175。
其中,媒体数据融合访问模块174用于获取应用程序的数据访问请求,并响应于 该数据访问请求,通过融合数据管理模块175查询到对应的媒体数据,向应用程序返回查询结果。通过媒体数据融合访问模块174可以提供跨设备媒体数据融合访问能力。
融合数据管理模块175用于管理本地数据和跨设备数据。
分布式数据映射模块176用于实现跨设备媒体数据的映射和变更。该分布式数据库映射模块176可以是跨设备的分布式数据中间件中的模块。
通过分布式数据映射模块176,云端172和第二电子设备173可以将本地的媒体数据库整体映射至第一电子设备171。此时,云端172可以看作一个特殊的第二电子设备。
第一电子设备171的应用程序可以通过调用媒体图书库接口发起数据访问请求,以访问云端172和第二电子设备173的媒体数据。
参见图18示出的本申请实施例提供的表映射模式下的数据融合访问示意图,如图18所示,第一电子设备181可以跨设备访问云端182的数据,以及第二电子设备183的数据。
其中,第一电子设备181中的媒体数据融合访问模块184可以参见图17的相关内容,在此不再赘述。
分布式数据映射模块186用于实现跨设备媒体数据的映射和变更。此时,第一电子设备181通过分布式数据映射模块186,创建本地数据库表的映射表,并将该映射表装入中间过程数据185。而云端182和第二电子设备183通过分布式数据映射模块186,可以将本地数据库表整体映射至第一电子设备181的中间过程数据185。
中间过程数据185可以具体体现为中间结果数据库,其可以包括第一电子设备181本地数据库表的映射表、云端182本地数据库表的映射表以及第二电子设备183本地数据库表的映射表。
第一电子设备181上的应用程序可以通过调用媒体图书库接口,以发起数据访问请求。媒体数据融合访问模块184响应于数据访问请求,查询中间过程数据185,以得到查询结果。其中,如果数据访问请求包括第一电子设备181的设备标识,则查询中间过程数据185中第一电子设备181的映射表。如果数据访问请求包括云端182或第二电子设备183的设备标识,则查询中间过程数据185中云端182或第二电子设备183的映射表。如果数据访问请求不包括设备标识,则查询中间过程数据185中所有设备的映射表。
具体应用中,分布式数据映射模块可以用于实现跨设备的数据映射和变更,分布式数据映射模块是分布式数据中间件中的模块,下面将示例性地介绍基于分布式数据中间件的数据映射过程。
参见图19示出的本申请实施例提供的基于分布式数据中间件的数据库映射模式的示意图,分布式数据中间件包括以下部分:驱动(Driver)191、元数据存储仓(Metadata Store)192、执行引擎(Execution Engine)193、批操作处理员(Batch Operator)194以及实时操作处理员(Real-time Operator)195。媒体图书库包括以下部分:媒体图书库接口196、数据融合访问模块197、虚拟映射数据库198和本地数据库199。
基于分布式数据中间件的数据库映射流程可以包括以下步骤:
首先,媒体图书库接收到设备上线事件之后,通过媒体图书库接口196调用分布 式数据中间件接口,创建虚拟映射数据库198。
如图19所示,分布式数据中间件先定义映射数据库,例如,定义映射数据库包含的表和数据库文件名等;再根据映射数据库的定义,创建映射数据库,此时,该映射数据库还没有装入数据;然后,执行数据库映射,进行数据有状态装入,即先创建数据状态树,然后基于数据状态启动数据装入,将源数据库里面的数据批量装入预先创建的映射数据库,得到数据装入完成的映射数据库,得到虚拟映射数据库198。
例如,参见图5,第二电子设备52的媒体图书库接收到第一电子设备51的设备上线事件之后,第二电子设备52的分布式数据库中间件根据第一电子设备51的设备上线事件的数据库版本信息等,定义映射数据库,再根据映射数据库的定义,创建映射数据库;然后,创建数据状态树,并在第一虚拟数据库内进行数据映射,得到映射完成的映射数据库54,再将映射数据库54跨设备传输至第一电子设备51。此时,第一电子设备51上的映射数据库54即为上述虚拟映射数据库。
分布式数据中间件完成跨设备的数据库映射之后,还可以实时监听数据库变化信息,并基于数据库监听结果,将远端数据库的变更数据实时装入虚拟映射数据库198。如图19所示,在实时监听数据变化之后,分布式数据中间件中的实时操作处理员195将远端设备的数据变化有状态地装入虚拟映射数据库198。
如图19所示,应用程序可以调用媒体图书库接口196,以向数据融合访问模块197发起数据融合访问请求,数据融合访问模块197响应于数据融合访问请求,查询本地数据库199和/或虚拟映射数据库198,得到查询结果,再将查询结果通过媒体图书库接口196返回给应用程序。
需要说明的是,分布式数据中间件是跨设备的,故图19中的分布式中间件示出的流程包括两个设备的流程。例如,图19示出的分布式数据中间件的流程包括图5中第一电子设备51和第二电子设备52的流程。
参见图20示出的本申请实施例提供的基于分布式数据中间件的表映射模式的示意图,与图19类似,分布式数据中间件包括以下部分:驱动(Driver)201、元数据存储仓(Metadata Store)202、执行引擎(Execution Engine)203、批操作处理员(Batch Operator)204以及实时操作处理员(Real-time Operator)205。媒体图书库包括以下部分:媒体图书库接口206、数据融合访问模块207、中间结果数据库208。
分布式数据中间件先创建本地映射表和远端的映射表,例如,第一电子设备的分布式数据中间件,创建本地数据库表的映射表,第二电子设备的分布式数据库中间件创建本地数据库表的映射表(即上述远端的映射表)。然后,分布式数据中间件创建中间过程数据库,再创建数据状态树,并基于数据状态树进行数据有状态装入,即将本地映射表和远端的映射表批量装入中间过程数据库,得到中间结果数据库208。其中,远端的映射表需要传输至本地,例如,第二电子设备将创建的映射表传输至第一电子设备。
分布式数据中间件还可以实时监听数据变更,监听对象包括本地数据和跨设备数据,当监听到数据变更时,则将变更数据装入中间结果数据库。
如图20所示,应用程序可以调用媒体图书库接口206,以向数据融合访问模块207发起数据融合访问请求,数据融合访问模块207响应于数据融合访问请求,查询中间 结果数据库208,得到查询结果,再将查询结果通过媒体图书库接口206返回给应用程序。
需要说明的是,分布式数据中间件是跨设备的,故图19中的分布式中间件示出的流程包括两个设备的流程。
需要说明的是,上文示出的基于分布式数据中间件实现跨设备的数据映射和数据变更的过程仅仅是一种示例,不造成对跨设备数据映射和数据变更的具体实现手段的限定。数据映射和数据变更可以参见上文的数据映射过程和数据变更监听过程,在此不再赘述。
由上可见,本申请实施例提供的数据映射过程,将数据库或数据库表整体映射至对端设备,实现了数据库级别或数据表级别的数据同步,相较于逐条同步的数据同步过程,本申请实施例减少了跨设备的数据同步耗时,提高了数据可用速度。这样,实现了设备即插即用,即设备一上线,该设备的数据即可快速同步至对端设备,使得该设备的数据可用速度更快。
在一些实施例中,第一电子设备在对端设备下线之后,可以在本地缓存中清除下线设备的数据集合。例如,第一电子设备为手机,第二电子设备为平板。在手机和平板建立Wi-Fi点对点连接之后,手机接收平板发送的映射数据库之后,将平板的映射数据库存储在本地。在手机和平板之间的Wi-Fi点对点连接断开之后,即平板下线之后,手机在本地缓存中清除平板的映射数据库。
进一步地,为了解决在数据库映射时,不同设备之间的表结构不同导致数据映射失败的问题,本申请实施例还提供了异表结构映射方案,这样即使设备之间的表结构不同时仍然可以实现数据库映射,应用范围更广。
本申请实施例还在数据映射时创建记录数据状态信息,基于数据状态信息监听数据是否发生变化,并在数据发生变化时,将变更数据同步至对端设备,以实现跨设备的数据变更监听,提供跨设备的数据实时查询能力。
本申请实施例提供的数据融合访问过程,预先将对端设备的数据库映射至本地存储空间,提高类本地数据库访问的跨设备数据融合访问,避免网络传输质量对查询性能的影响,实现高性能的跨设备数据融合访问。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
对应于上文实施例所述的数据传输方法,下面对本申请实施例提供的数据传输装置进行介绍说明,为了便于说明,仅示出了与本申请实施例相关的部分。
该数据传输装置包括:
第一接收模块,用于接收来自第一电子设备的第一事件,第一事件包括第一数据库版本信息,第一数据库版本信息用于描述第二源数据库的数据库版本,第二源数据库为第一电子设备的本地数据库;
第一创建模块,用于根据第一数据库版本信息,创建第一源数据库的第一空映射数据库,第一源数据库为第二电子设备的本地数据库;
第一虚拟化模块,用于将第一源数据库和第一空映射数据库进行虚拟化,得到第 一虚拟数据库;
第一映射模块,用于在第一虚拟数据库中进行数据映射,以将第一源数据库内的数据映射至第一空映射数据库,得到数据映射完成的第一数据库;
第一获得模块,用于基于第一数据库,得到第一映射数据库;
第一发送模块,用于向第一电子设备发送第一映射数据库。
在一些可能的实现方式中,第一获得模块具体用于:根据第一数据库版本信息和第二数据库版本信息,比较第一源数据库和第二源数据库之间的数据库版本高低,第二数据库版本信息用于描述第一源数据库的数据库版本;若第一源数据库的版本高于第二源数据库的版本,将第一数据库进行版本降级,得到第一映射数据库,第一映射数据库的版本与第二源数据库的版本一致;若第一源数据库的版本低于或等于第二源数据库的版本,将第一数据库作为第一映射数据库,第一映射数据库的版本与第一源数据库的版本一致。
在一些可能的实现方式中,当第一源数据库的版本高于第二源数据库的版本,第一空映射数据库的版本与第一源数据库的版本一致,第一空映射数据库的表结构与第二源数据库的表结构一致;当第一源数据库的版本低于第二源数据库的版本,第一空映射数据库的版本与第一源数据库的版本一致,第一空映射数据库的表结构与第一源数据库的表结构一致。
在一些可能的实现方式中,该装置还包括:
第二发送模块,用于向第一电子设备发送第二事件,第二事件包括第二数据库版本信息;
第二接收模块,用于接收来自第一电子设备的第二映射数据库,第二映射数据库为第一电子设备根据第二数据库版本信息建立的第二源数据库的映射数据库。
在一些可能的实现方式中,该装置还包括第二虚拟化模块,用于:若第一源数据库的版本低于第二源数据库的版本,将第二映射数据库和第一源数据库进行虚拟化,得到第二虚拟数据库;若第一源数据库的版本高于第二源数据库的版本,将第二映射数据库进行升级,得到升级后的第二映射数据库,升级后的第二映射数据库的版本与第一源数据库的版本一致;将升级后的第二映射数据库和第一源数据库进行虚拟化,得到第二虚拟数据库。
在一些可能的实现方式中,该装置还包括第一融合访问模块,用于:获取第一应用的第一数据访问请求,第二电子设备包括第一应用;若第一数据访问请求包括第一电子设备的设备标识,查询第二虚拟数据库中的第二映射数据库,得到第一查询结果,并向第一应用返回第一查询结果;若第一数据访问请求不包括设备标识,查询第二虚拟数据库中的第二映射数据库和第一源数据库,得到第二查询结果,并向第一应用返回第二查询结果;若第一数据访问请求包括第二电子设备的设备标识,查询第二虚拟数据库中的第一源数据库,得到第三查询结果,并向第一应用返回第三查询结果。
在一些可能的实现方式中,该装置还包括:
第一变更脚本接收模块,用于接收来自第一电子设备的第一变更脚本,第一变更脚本包括用于记录第二源数据库的变更数据的表;
第一批量更新模块,用于若第一源数据库的版本高于第二源数据库的版本,将第 一变更脚本进行升级,得到升级后的第一变更脚本,升级后的第一变更脚本的表结构与第一源数据库的表结构一致;通过执行升级后的第一变更脚本,将第二源数据库的变更数据装入第二映射数据库;若第一源数据库的版本低于第二源数据库的版本,通过执行第一变更脚本,将第二源数据库的变更数据装入第二映射数据库。
在一些可能的实现方式中,该装置还包括第一更新模块,用于:根据第一数据状态树,确定第一源数据库内的数据是否发生变更,第一数据状态树用于描述第一源数据库内映射至第一空映射数据库的数据的状态;若第一源数据库内的数据发生变更,将第一源数据内发生变更的数据记录在第二变更脚本,第二变更脚本包括用于记录变更数据的表;向第一电子设备发送第二变更脚本;
其中,当第一源数据库的版本高于第二源数据库的版本,第二变更脚本的表结构与第二源数据库的表结构一致;
当第一源数据库的版本低于第二源数据库的版本,第二变更脚本的表结构与第一源数据库的表结构一致。
在一些可能的实现方式中,上述第一更新模块还用于:更新第一数据状态树。
需要说明的是,上述装置和模块之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。
对应于上文实施例所述的数据传输方法,下面对本申请实施例提供的数据传输装置进行介绍说明,为了便于说明,仅示出了与本申请实施例相关的部分。
该数据传输装置包括:
第三发送模块,用于向第二电子设备发送第一事件,第一事件包括第一数据库版本信息,第一数据库版本信息用于描述第二源数据库的数据库版本,第二源数据库为第一电子设备的本地数据库;
第三接收模块,用于接收来自第二电子设备的第一映射数据库,第一映射数据库为第二电子设备根据第一数据库版本信息建立的第一源数据库的映射数据库,第一源数据库为第二电子设备的本地数据库。
在一些可能的实现方式中,该装置还包括第三虚拟化模块,用于:若第一源数据库的版本高于第二源数据库的版本,将第一映射数据库和第二源数据库进行虚拟化,得到第三虚拟化数据库;若第一源数据库的版本低于第二源数据库的版本,将第一映射数据库进行升级,得到升级后的第一映射数据库,升级后的第一映射数据库的版本与第二源数据库的版本一致;将升级后的第一映射数据库和第二源数据库进行虚拟化,得到第三虚拟数据库。
在一些可能的实现方式中,该装置还包括第二融合访问模块,用于:获取第二应用的第二数据访问请求,第一电子设备包括第二应用;若第二数据访问请求包括第一电子设备的设备标识,查询第三虚拟数据库中的第二源数据库,得到第四查询结果,并向第二应用返回第四查询结果;若第二数据访问请求不包括设备标识,查询第三虚拟数据库中的第一映射数据库和第二源数据库,得到第五查询结果,并向第二应用返回第五查询结果;若第二数据访问请求包括第二电子设备的设备标识,查询第三虚拟 数据库中的第一映射数据库,得到第六查询结果,并向第二应用返回第六查询结果。
在一些可能的实现方式中,该装置还包括:
第二变更脚本接收模块,用于接收来自第二电子设备的第二变更脚本,第二变更脚本包括用于记录第一源数据库的变更数据的表;
第二批量更新模块,用于若第一源数据库的版本低于第二源数据库的版本,将第二变更脚本进行升级,得到升级后的第二变更脚本,升级后的第二变更脚本的表结构与第二源数据库的表结构一致;通过执行升级后的第二变更脚本,将第一源数据库的变更数据装入第一映射数据库;若第一源数据库的版本高于第二源数据库的版本,通过执行第二变更脚本,将第一源数据库的变更数据装入第一映射数据库。
在一些可能的实现方式中,该装置还包括:
第四接收模块,用于接收来自第二电子设备的第二事件,第二事件包括第二数据库版本信息,第二数据库版本信息用于描述第一源数据库的数据库版本;
第二创建模块,用于根据第二数据库版本信息,创建第二源数据库的第二空映射数据库;
第四虚拟化模块,用于将第二源数据库和第二空映射数据库进行虚拟化,得到第四虚拟数据库;
第二映射模块,用于在第四虚拟数据库中进行数据映射,以将第二源数据库内的数据映射至第二空映射数据库,得到数据映射完成的第二数据库;
第二获得模块,用于基于第二数据库,得到第二映射数据库;
第四发送模块,用于向第二电子设备发送第二映射数据库。
在一些可能的实现方式中,第二获得模块具体用于:根据第一数据库版本信息和第二数据库版本信息,比较第一源数据库和第二源数据库之间的数据库版本高低;若第一源数据库的版本低于或等于第二源数据库的版本,将第二数据库进行版本降级,得到第二映射数据库,第二映射数据库的版本与第一源数据库的版本一致;若第一源数据库的版本高于第二源数据库的版本,将第二数据库作为第一映射数据库,第二映射数据库的版本与第二源数据库的版本一致。
在一些可能的实现方式中,当第一源数据库的版本低于第二源数据库的版本,第二空映射数据库的版本与第二源数据库的版本一致,第二空映射数据库的表结构与第一源数据库的表结构一致;当第一源数据库的版本高于第二源数据库的版本,第二空映射数据库的版本与第二源数据库的版本一致,第二空映射数据库的表结构与第二源数据库的表结构一致。
在一些可能的实现方式中,该装置还包括第二更新模块,用于:根据第二数据状态树,确定第二源数据库内的数据是否发生变更,第二数据状态树用于描述第二源数据库内映射至第二空映射数据库的数据的状态;若第二源数据库内的数据发生变更,将第二源数据内发生变更的数据记录在第一变更脚本,第一变更脚本包括用于记录变更数据的表;更新第二数据状态树;向第二电子设备发送第一变更脚本;
其中,当第一源数据库的版本低于第二源数据库的版本,第一变更脚本的表结构与第一源数据库的表结构一致;
当第一源数据库的版本高于第二源数据库的版本,第一变更脚本的表结构与第二 源数据库的表结构一致。
需要说明的是,上述装置和模块之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。
图21为本申请一实施例提供的电子设备的结构示意图。如图21所示,该实施例的电子设备21包括:至少一个处理器210(图21中仅示出一个)处理器、存储器211以及存储在所述存储器211中并可在所述至少一个处理器210上运行的计算机程序212,所述处理器210执行所述计算机程序212时实现上述任意各个数据传输方法实施例中的步骤。
所述电子设备21可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。该电子设备可包括,但不仅限于,处理器210、存储器211。本领域技术人员可以理解,图21仅仅是电子设备21的举例,并不构成对电子设备21的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。
所称处理器210可以是中央处理单元(Central Processing Unit,CPU),该处理器210还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器211在一些实施例中可以是所述电子设备21的内部存储单元,例如电子设备21的硬盘或内存。所述存储器211在另一些实施例中也可以是所述电子设备21的外部存储设备,例如所述电子设备21上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器211还可以既包括所述电子设备21的内部存储单元也包括外部存储设备。所述存储器211用于存储操作系统、应用程序、引导装载程序(BootLoader)、数据以及其他程序等,例如所述计算机程序的程序代码等。所述存储器211还可以用于暂时地存储已经输出或者将要输出的数据。
本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现可实现上述各个方法实施例中的步骤。
本申请实施例提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行时实现可实现上述各个方法实施例中的步骤。
本申请实施例还提供一种芯片系统,所述芯片系统包括处理器,所述处理器与存储器耦合,所述处理器执行存储器中存储的计算机程序,以实现如上述各个方法实施例所述的方法。所述芯片系统可以为单个芯片,或者多个芯片组成的芯片模组。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。此外,在本申请说明书和所附权利要 求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。
最后应说明的是:以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (19)

  1. 一种数据传输方法,其特征在于,应用第二电子设备,所述方法包括:
    接收来自第一电子设备的第一事件,所述第一事件包括第一数据库版本信息,所述第一数据库版本信息用于描述第二源数据库的数据库版本,所述第二源数据库为所述第一电子设备的本地数据库;
    根据所述第一数据库版本信息,创建第一源数据库的第一空映射数据库,所述第一源数据库为所述第二电子设备的本地数据库;
    将所述第一源数据库和所述第一空映射数据库进行虚拟化,得到第一虚拟数据库;
    在所述第一虚拟数据库中进行数据映射,以将所述第一源数据库内的数据映射至第一空映射数据库,得到数据映射完成的第一数据库;
    基于所述第一数据库,得到第一映射数据库;
    向所述第一电子设备发送所述第一映射数据库。
  2. 根据权利要求1所述的方法,其特征在于,所述基于所述第一数据库,得到所述第一映射数据库,包括:
    根据所述第一数据库版本信息和第二数据库版本信息,比较所述第一源数据库和所述第二源数据库之间的数据库版本高低,所述第二数据库版本信息用于描述所述第一源数据库的数据库版本;
    若所述第一源数据库的版本高于所述第二源数据库的版本,将所述第一数据库进行版本降级,得到所述第一映射数据库,所述第一映射数据库的版本与所述第二源数据库的版本一致;
    若所述第一源数据库的版本低于或等于所述第二源数据库的版本,将所述第一数据库作为所述第一映射数据库,所述第一映射数据库的版本与所述第一源数据库的版本一致。
  3. 根据权利要求1所述的方法,其特征在于,当所述第一源数据库的版本高于所述第二源数据库的版本,所述第一空映射数据库的版本与所述第一源数据库的版本一致,所述第一空映射数据库的表结构与所述第二源数据库的表结构一致;
    当所述第一源数据库的版本低于所述第二源数据库的版本,所述第一空映射数据库的版本与所述第一源数据库的版本一致,所述第一空映射数据库的表结构与所述第一源数据库的表结构一致。
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述方法还包括:
    向所述第一电子设备发送第二事件,所述第二事件包括第二数据库版本信息;
    接收来自所述第一电子设备的第二映射数据库,所述第二映射数据库为所述第一电子设备根据所述第二数据库版本信息建立的所述第二源数据库的映射数据库。
  5. 根据权利要求4所述的方法,其特征在于,在接收来自所述第一电子设备的第二映射数据库之后,所述方法还包括:
    若所述第一源数据库的版本低于所述第二源数据库的版本,将所述第二映射数据库和所述第一源数据库进行虚拟化,得到第二虚拟数据库;
    若所述第一源数据库的版本高于所述第二源数据库的版本,将所述第二映射数据库进行升级,得到升级后的第二映射数据库,所述升级后的第二映射数据库的版本与 所述第一源数据库的版本一致;
    将所述升级后的第二映射数据库和所述第一源数据库进行虚拟化,得到第二虚拟数据库。
  6. 根据权利要求5所述的方法,其特征在于,在将所述第二映射数据库和所述第一源数据库进行虚拟化,得到第二虚拟数据库之后,所述方法还包括:
    获取第一应用的第一数据访问请求,所述第二电子设备包括所述第一应用;
    若所述第一数据访问请求包括第一电子设备的设备标识,查询第二虚拟数据库中的第二映射数据库,得到第一查询结果,并向所述第一应用返回所述第一查询结果;
    若所述第一数据访问请求不包括设备标识,查询所述第二虚拟数据库中的所述第二映射数据库和所述第一源数据库,得到第二查询结果,并向所述第一应用返回所述第二查询结果;
    若所述第一数据访问请求包括所述第二电子设备的设备标识,查询所述第二虚拟数据库中的所述第一源数据库,得到第三查询结果,并向所述第一应用返回所述第三查询结果。
  7. 根据权利要求4所述的方法,其特征在于,在所述第二电子设备接收来自所述第一电子设备的第二映射数据库之后,还包括:
    接收来自所述第一电子设备的第一变更脚本,所述第一变更脚本包括用于记录所述第二源数据库的变更数据的表;
    若所述第一源数据库的版本高于所述第二源数据库的版本,将所述第一变更脚本进行升级,得到升级后的第一变更脚本,所述升级后的第一变更脚本的表结构与所述第一源数据库的表结构一致;
    通过执行所述升级后的第一变更脚本,将所述第二源数据库的变更数据装入所述第二映射数据库;
    若所述第一源数据库的版本低于所述第二源数据库的版本,通过执行所述第一变更脚本,将所述第二源数据库的变更数据装入所述第二映射数据库。
  8. 根据权利要求1至7任一项所述的方法,其特征在于,所述方法还包括:
    根据第一数据状态树,确定所述第一源数据库内的数据是否发生变更,所述第一数据状态树用于描述所述第一源数据库内映射至所述第一空映射数据库的数据的状态;
    若所述第一源数据库内的数据发生变更,将所述第一源数据内发生变更的数据记录在第二变更脚本,所述第二变更脚本包括用于记录变更数据的表;
    向所述第一电子设备发送所述第二变更脚本;
    其中,当所述第一源数据库的版本高于所述第二源数据库的版本,所述第二变更脚本的表结构与所述第二源数据库的表结构一致;
    当所述第一源数据库的版本低于所述第二源数据库的版本,所述第二变更脚本的表结构与所述第一源数据库的表结构一致。
  9. 根据权利要求8所述的方法,其特征在于,在确定所述第一源数据库内的数据发生变更之后,还包括:
    更新所述第一数据状态树。
  10. 一种数据传输方法,其特征在于,应用于第一电子设备,所述方法包括:
    向第二电子设备发送第一事件,所述第一事件包括第一数据库版本信息,所述第一数据库版本信息用于描述第二源数据库的数据库版本,所述第二源数据库为所述第一电子设备的本地数据库;
    接收来自所述第二电子设备的第一映射数据库,所述第一映射数据库为所述第二电子设备根据所述第一数据库版本信息建立的第一源数据库的映射数据库,所述第一源数据库为所述第二电子设备的本地数据库。
  11. 根据权利要求10所述的方法,其特征在于,在接收来自所述第二电子设备的第一映射数据库之后,还包括:
    若所述第一源数据库的版本高于所述第二源数据库的版本,将所述第一映射数据库和所述第二源数据库进行虚拟化,得到第三虚拟化数据库;
    若所述第一源数据库的版本低于所述第二源数据库的版本,将所述第一映射数据库进行升级,得到升级后的第一映射数据库,所述升级后的第一映射数据库的版本与所述第二源数据库的版本一致;
    将所述升级后的第一映射数据库和所述第二源数据库进行虚拟化,得到第三虚拟数据库。
  12. 根据权利要求11所述的方法,其特征在于,在获得第三虚拟数据库之后,所述方法还包括:
    获取第二应用的第二数据访问请求,所述第一电子设备包括所述第二应用;
    若所述第二数据访问请求包括第一电子设备的设备标识,查询第三虚拟数据库中的所述第二源数据库,得到第四查询结果,并向所述第二应用返回所述第四查询结果;
    若所述第二数据访问请求不包括设备标识,查询所述第三虚拟数据库中的所述第一映射数据库和所述第二源数据库,得到第五查询结果,并向所述第二应用返回所述第五查询结果;
    若所述第二数据访问请求包括所述第二电子设备的设备标识,查询所述第三虚拟数据库中的所述第一映射数据库,得到第六查询结果,并向所述第二应用返回所述第六查询结果。
  13. 根据权利要求10所述的方法,其特征在于,在接收来自所述第二电子设备的第一映射数据库之后,所述方法还包括:
    接收来自所述第二电子设备的第二变更脚本,所述第二变更脚本包括用于记录所述第一源数据库的变更数据的表;
    若所述第一源数据库的版本低于所述第二源数据库的版本,将所述第二变更脚本进行升级,得到升级后的第二变更脚本,所述升级后的第二变更脚本的表结构与所述第二源数据库的表结构一致;
    通过执行所述升级后的第二变更脚本,将所述第一源数据库的变更数据装入所述第一映射数据库;
    若所述第一源数据库的版本高于所述第二源数据库的版本,通过执行所述第二变更脚本,将所述第一源数据库的变更数据装入所述第一映射数据库。
  14. 根据权利要求10至13任一项所述的方法,其特征在于,所述方法还包括:
    接收来自所述第二电子设备的第二事件,所述第二事件包括第二数据库版本信息, 所述第二数据库版本信息用于描述所述第一源数据库的数据库版本;
    根据所述第二数据库版本信息,创建第二源数据库的第二空映射数据库;
    将所述第二源数据库和所述第二空映射数据库进行虚拟化,得到第四虚拟数据库;
    在所述第四虚拟数据库中进行数据映射,以将所述第二源数据库内的数据映射至第二空映射数据库,得到数据映射完成的第二数据库;
    基于所述第二数据库,得到第二映射数据库;
    向所述第二电子设备发送所述第二映射数据库。
  15. 根据权利要求14所述的方法,其特征在于,所述基于所述第二数据库,得到所述第二映射数据库,包括:
    根据所述第一数据库版本信息和所述第二数据库版本信息,比较所述第一源数据库和所述第二源数据库之间的数据库版本高低;
    若所述第一源数据库的版本低于或等于所述第二源数据库的版本,将所述第二数据库进行版本降级,得到所述第二映射数据库,所述第二映射数据库的版本与所述第一源数据库的版本一致;
    若所述第一源数据库的版本高于所述第二源数据库的版本,将所述第二数据库作为所述第一映射数据库,所述第二映射数据库的版本与所述第二源数据库的版本一致。
  16. 根据权利要求14所述的方法,其特征在于,当所述第一源数据库的版本低于所述第二源数据库的版本,所述第二空映射数据库的版本与所述第二源数据库的版本一致,所述第二空映射数据库的表结构与所述第一源数据库的表结构一致;
    当所述第一源数据库的版本高于所述第二源数据库的版本,所述第二空映射数据库的版本与所述第二源数据库的版本一致,所述第二空映射数据库的表结构与所述第二源数据库的表结构一致。
  17. 根据权利要求14所述的方法,其特征在于,在向所述第一电子设备发送所述第一映射数据库之后,还包括:
    根据第二数据状态树,确定所述第二源数据库内的数据是否发生变更,所述第二数据状态树用于描述所述第二源数据库内映射至所述第二空映射数据库的数据的状态;
    若所述第二源数据库内的数据发生变更,将所述第二源数据内发生变更的数据记录在第一变更脚本,所述第一变更脚本包括用于记录变更数据的表;
    更新所述第二数据状态树;
    向所述第二电子设备发送所述第一变更脚本;其中,当所述第一源数据库的版本低于所述第二源数据库的版本,所述第一变更脚本的表结构与所述第一源数据库的表结构一致;当所述第一源数据库的版本高于所述第二源数据库的版本,所述第一变更脚本的表结构与所述第二源数据库的表结构一致。
  18. 一种电子设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至9或10至17任一项所述的方法。
  19. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至9或10至17任一项所述的方法。
PCT/CN2022/084522 2021-05-31 2022-03-31 数据传输方法、电子设备及计算机可读存储介质 WO2022252791A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
EP22814838.3A EP4339796A1 (en) 2021-05-31 2022-03-31 Data transmission method, electronic device, and computer readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110604841.3A CN115481101A (zh) 2021-05-31 2021-05-31 数据传输方法、电子设备及计算机可读存储介质
CN202110604841.3 2021-05-31

Publications (1)

Publication Number Publication Date
WO2022252791A1 true WO2022252791A1 (zh) 2022-12-08

Family

ID=84322617

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/084522 WO2022252791A1 (zh) 2021-05-31 2022-03-31 数据传输方法、电子设备及计算机可读存储介质

Country Status (3)

Country Link
EP (1) EP4339796A1 (zh)
CN (1) CN115481101A (zh)
WO (1) WO2022252791A1 (zh)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103299602A (zh) * 2011-01-14 2013-09-11 苹果公司 数据同步
EP2672385A2 (en) * 2012-06-08 2013-12-11 Apple Inc. Cloud tabs
CN107220259A (zh) * 2016-03-22 2017-09-29 北京京东尚科信息技术有限公司 一种数据库扩展系统、设备和用于扩展数据库的方法
CN107491510A (zh) * 2017-08-03 2017-12-19 国网江苏省电力公司信息通信分公司 一种混合异构数据源统一查询系统及分布式查询方法
CN110663037A (zh) * 2017-06-02 2020-01-07 苹果公司 在多个计算设备之间共享数据
CN111651526A (zh) * 2020-08-04 2020-09-11 北京和利时系统工程有限公司 冗余前端处理器的数据同步方法、前端处理器和处理系统
WO2021055016A1 (en) * 2020-04-13 2021-03-25 Futurewei Technologies, Inc. Detection and resolution of data synchronization conflicts
WO2021062427A1 (en) * 2020-04-30 2021-04-01 Futurewei Technologies, Inc. Multi-schema version support in data synchronization

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103299602A (zh) * 2011-01-14 2013-09-11 苹果公司 数据同步
EP2672385A2 (en) * 2012-06-08 2013-12-11 Apple Inc. Cloud tabs
CN107220259A (zh) * 2016-03-22 2017-09-29 北京京东尚科信息技术有限公司 一种数据库扩展系统、设备和用于扩展数据库的方法
CN110663037A (zh) * 2017-06-02 2020-01-07 苹果公司 在多个计算设备之间共享数据
CN107491510A (zh) * 2017-08-03 2017-12-19 国网江苏省电力公司信息通信分公司 一种混合异构数据源统一查询系统及分布式查询方法
WO2021055016A1 (en) * 2020-04-13 2021-03-25 Futurewei Technologies, Inc. Detection and resolution of data synchronization conflicts
WO2021062427A1 (en) * 2020-04-30 2021-04-01 Futurewei Technologies, Inc. Multi-schema version support in data synchronization
CN111651526A (zh) * 2020-08-04 2020-09-11 北京和利时系统工程有限公司 冗余前端处理器的数据同步方法、前端处理器和处理系统

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
AGARWAL S,ET AL: "On the scalability of data synchronization protocols for PDAs and mobile devices", IEEE NETWORK., IEEE SERVICE CENTER, NEW YORK, NY., US, vol. 16, no. 4, 1 July 2002 (2002-07-01), US , pages 22 - 28, XP002252896, ISSN: 0890-8044, DOI: 10.1109/MNET.2002.1020232 *
YUAN CHAO, YUE MIN;MA TAO;GOU SHIZHE;WANG YONGPING;ZHANG WEI: "(HIRFL Database Migration and Performance Optimization Based on Fusion Compute Virtualization Platform", ATOMIC ENERGY SCIENCE AND TECHNOLOGY, BEIJING : YUANZINENG CHUBANSHE, CN, vol. 53, no. 9, 30 September 2019 (2019-09-30), CN , pages 1697 - 1701, XP093010209, ISSN: 1000-6931, DOI: 10.7538/yzk.2019.youxian.0158 *

Also Published As

Publication number Publication date
CN115481101A (zh) 2022-12-16
EP4339796A1 (en) 2024-03-20

Similar Documents

Publication Publication Date Title
CN107168905B (zh) 一种文件显示方法、装置、存储介质及移动终端
JP6248182B2 (ja) プレースホルダを用いるファイル管理
JP5624479B2 (ja) 同期サーバープロセス
US8090685B2 (en) Knowledge based synchronization of subsets of data with no move condition
US9298747B2 (en) Deployable, consistent, and extensible computing environment platform
US8825598B2 (en) Media file synchronization
US9996549B2 (en) Method to construct a file system based on aggregated metadata from disparate sources
US20110119233A1 (en) System, method and computer program for synchronizing data between data management applications
US8639661B2 (en) Supporting media content revert functionality across multiple devices
US11336588B2 (en) Metadata driven static determination of controller availability
US20140279899A1 (en) Data bus architecture for inter-database data distribution
US20120109952A1 (en) System, method, and computer program for remote management of digital content
US9747303B1 (en) File location application programming interface
WO2022156484A1 (zh) 媒体数据处理方法、装置及终端设备
WO2024113740A1 (zh) 数据查询方法、系统、设备及计算机可读存储介质
CN114116611A (zh) 一种文件扫描方法及相关装置
CN103246729A (zh) 一种处理安卓移动端的多媒体文件的方法和系统
US20130179414A1 (en) Mechanisms for connecting files between applications
WO2022252791A1 (zh) 数据传输方法、电子设备及计算机可读存储介质
CN115113989B (zh) 事务执行方法、装置、计算设备及存储介质
CN114490727A (zh) 目标数据库的高维向量搜索方法及相关设备
WO2024001280A1 (zh) 数据流动感知方法及相关装置
WO2024131959A1 (zh) 虚拟单元启动方法及装置、云计算系统
WO2024046184A1 (zh) 一种文件管理、应用管理的方法和电子设备
WO2023273426A1 (zh) 一种从摄像机获取数据的方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22814838

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 18564610

Country of ref document: US

WWE Wipo information: entry into national phase

Ref document number: 2022814838

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022814838

Country of ref document: EP

Effective date: 20231212

NENP Non-entry into the national phase

Ref country code: DE