Data processing method and device, electronic device and storage medium
By synchronizing relational database data to non-relational databases and distributed search engines, and using the distributed publish-subscribe message system to process and store data, the performance bottleneck and maintenance cost problems of relational databases under large data volumes are solved, and the High concurrent processing and system stability.
Patent Information
- Application Number
- CN202410154058.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-02
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-02-02
AI Technical Summary
Existing relational databases have problems with performance bottlenecks and rising maintenance costs when processing large batches of business data. Especially when the amount of data increases and concurrent requests rise, it becomes difficult to expand the system architecture.
Use the data synchronization tool to synchronize the main table of the relational database to the non-relational database and distributed search engine, use the distributed publish and subscribe message system to split and process the data, generate entity objects and store them in the non-relational database, and achieve high efficiency. Concurrent writes and horizontal scaling.
It improves the availability and stability of the system, can cope with the growing data volume and concurrent requests, and reduces database pressure and maintenance costs.
Smart Images

Figure CN118012952B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method and device, an electronic device, and a storage medium. Background Art
[0002] At present, for large quantities of business data, relational databases are usually used to store data by year and by month, and this strategy has shown performance bottlenecks and rising maintenance costs. With the increase in business data, the write load of a single database or table in a relational database continues to rise, bringing a greater burden to the system. It also becomes more complicated to maintain indexes, add fields, and monitor the system, making it difficult to expand the system architecture.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a data processing method and device, an electronic device and a storage medium, aiming to cope with the ever-increasing amount of data and concurrent requests and improve the availability and stability of the system.
[0005] To achieve the above purpose, one aspect of an embodiment of the present application provides a data processing method, the method comprising:
[0006] Synchronize the first main table of the relational database to the first set of the non-relational database and the first index of the distributed search engine in the first time dimension through a data synchronization tool;
[0007] Splitting the data of the first set according to a second time dimension, generating a message according to the split data and sending it to a distributed publish-subscribe message system, wherein the second time dimension is a subset of the first time dimension;
[0008] The first index is queried according to the message through a distributed publish-subscribe message system to obtain a first coding list, and complete data is queried according to the first coding list. A first entity object is created through the complete data, wherein the complete data includes data of a first set and an associated table, and the first entity object includes a one-to-many structure of the first set and the associated table. There is associated data between the associated table and the first set, and the associated table is synchronized from the relational database to the non-relational database by the data synchronization tool;
[0009] The first entity object is stored in a second collection of the non-relational database according to a first time dimension.
[0010] In some embodiments, splitting the data of the first set according to the second time dimension, generating a message according to the split data and sending it to the distributed publish-subscribe message system includes:
[0011] The split data is stored in a third set and a fourth set, wherein the third set is used to record the result of the split data conversion and storage, and the fourth set is used to record the detailed records executed in the second time dimension, wherein the third set includes a third code, a start time, an end time, a creation time, an update time, and a status field, and the fourth set includes a fourth code, the third code, a date, a creation time, an update time, and a status field;
[0012] A message is generated by using the third code and the date field, and the message is sent to a publish-subscribe message system.
[0013] In some embodiments, the message includes a third code, querying the first index according to the message through the distributed publish-subscribe message system to obtain a first code list, querying according to the first code list to obtain complete data, and creating a first entity object through the complete data includes:
[0014] The distributed publish-subscribe message system uses a third encoding to group and remove duplicates from the messages;
[0015] The distributed publish-subscribe message system takes the deduplicated messages as thread tasks and puts them into a thread pool for parallel processing.
[0016] In some embodiments, the first time dimension adopts year, the second time dimension adopts day, the message includes date, querying the first index according to the message through the distributed publish-subscribe message system to obtain a first coding list, querying according to the first coding list to obtain complete data, and creating a first entity object through the complete data includes:
[0017] the date on which said message was obtained;
[0018] Using a distributed lock to perform mutually exclusive access through the distributed publish-subscribe message system, the key value of the distributed lock is the date;
[0019] Convert the corresponding year according to the date, and find the first matching index according to the year, where the first index includes a first code and a creation time field;
[0020] Calculate the start time and end time of the date, query the first index through the creation time field being greater than or equal to the start time and less than or equal to the end time, and obtain the first coding list;
[0021] querying the second set according to the first code list, and checking whether the query obtains a matching second record, wherein the second record includes an update time field;
[0022] If the query does not obtain a matching second record, query the first coding list to obtain complete data, and create a first entity object using the complete data;
[0023] If the query obtains a matching second record, the first set is queried according to the first coding list to obtain a matching first record. When the update time of the first record is greater than the update time of the second record, the complete data is obtained by querying according to the first coding list, and the first entity object is created through the complete data. The first record includes an update time field.
[0024] In some embodiments, the first entity object includes a creation time, and storing the first entity object in a second set of a non-relational database in a first time dimension includes:
[0025] Obtaining a corresponding first time dimension according to the creation time of the first entity object, and storing the first entity object into the corresponding second set according to the corresponding first time dimension;
[0026] Obtaining the third code from the message;
[0027] Setting the status field of the record in the fourth set corresponding to the third code to completed;
[0028] The update time recorded in the fourth set corresponding to the third code is updated according to the current time.
[0029] In some embodiments, storing the first entity object in a second set of a non-relational database in a first time dimension further includes:
[0030] Get the third record whose status field is unfinished in the third set;
[0031] According to the start time, end time and third code of the third record, obtaining a fourth record of a fourth set whose status field is incomplete and matches the third record;
[0032] If the fourth record does not exist, updating the status field of the third record to completed;
[0033] If the fourth record exists, a message is generated by using the third code and the date field of the fourth record, and the message is sent to a publish-subscribe messaging system.
[0034] In some embodiments, the method further comprises:
[0035] Splitting the data of the first index according to the second time dimension, generating a message from the split data of the nearest neighbor first time dimension and sending it to the distributed publish-subscribe message system;
[0036] The first index is queried according to the message through a distributed publish-subscribe message system to obtain a second list, second complete data is queried according to the second list, and a second entity object is created according to the second complete data, wherein the second complete data includes the first index and data of the second association table, the second entity object includes a one-to-many structure of the first index and the second association table, the second association table has associated data with the first index, and the second association table is synchronized from the relational database to the non-relational database by the data synchronization tool;
[0037] The second entity object is stored in a second index of the distributed search engine in a first time dimension.
[0038] To achieve the above object, another aspect of an embodiment of the present application provides a data processing device, the device comprising:
[0039] A synchronization module, used to synchronize a first main table of a relational database to a first set of non-relational databases and a first index of a distributed search engine in a first time dimension through a data synchronization tool;
[0040] a splitting module, configured to split the data of the first set according to a second time dimension, generate a message according to the split data and send it to a distributed publish-subscribe message system, wherein the second time dimension is a subset of the first time dimension;
[0041] A processing module, configured to obtain a first coding list by querying the first index according to the message through a distributed publish-subscribe message system, obtain complete data by querying the first coding list, and create a first entity object through the complete data, wherein the complete data includes data of a first set and an associated table, the first entity object includes a one-to-many structure of the first set and the associated table, the associated table has associated data with the first set, and the associated table is synchronized from the relational database to the non-relational database by the data synchronization tool;
[0042] A storage module is used to store the first entity object in a second set of a non-relational database according to a first time dimension.
[0043] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.
[0044] To achieve the above-mentioned purpose, a fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0045] The embodiments of the present application include at least the following beneficial effects: the present application provides a data processing method and device, an electronic device and a storage medium, which synchronizes a first main table of a relational database to a first set of a non-relational database and a first index of a distributed search engine in a first time dimension through a data synchronization tool; splits the data of the first set in a second time dimension, generates a message based on the split data and sends it to a distributed publish-subscribe message system; obtains a first coding list based on a message query of the first index through the distributed publish-subscribe message system, obtains complete data based on the first coding list query, creates a first entity object based on the complete data, and the distributed publish-subscribe message system is conducive to high-concurrency processing; stores the first entity object in a second set of a non-relational database in a first time dimension, and the non-relational database is conducive to high-concurrency writing, provides more powerful horizontal expansion capabilities, can cope with the growing amount of data and concurrent requests, and improves the availability and stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 is a flow chart of a data processing method provided in an embodiment of the present application;
[0047] Figure 2 yes Figure 1 Flow chart of step S103 in FIG.
[0048] Figure 3 yes Figure 1 Flow chart of step S104 in FIG.
[0049] Figure 4 is an optional flow chart of the data processing method provided in the embodiment of the present application;
[0050] Figure 5 This is an example diagram of connecting MySQL sub-library and sub-table data provided in an embodiment of the present application;
[0051] Figure 6 This is an example diagram of connecting to MongoDB provided in an embodiment of the present application;
[0052] Figure 7 This is a schematic diagram of a FlinkCDC synchronization task creation provided by an embodiment of the present application;
[0053] Figure 8 It is a schematic diagram of a data_migration set and a data_migration_detail set provided in an embodiment of the present application;
[0054] Fig. 9 It is a schematic diagram of data processing conversion provided by an embodiment of the present application;
[0055] Fig.10 is a business transformation interaction flow chart provided in an embodiment of the present application;
[0056] Fig.11 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0057] Fig.12 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0059] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0060] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0062] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0063] 1) ES (Elasticsearch) is an open source, distributed search engine based on Lucene.
[0064] 2) MongoDB is an open source, document-oriented, non-relational database.
[0065] 3) FlinkCDC (Apache Flink Change Data Capture) is an open source database change data capture framework that implements real-time data synchronization and processing based on the Apache Flink stream processing engine.
[0066] 4) Redisson is a Java in-memory data grid based on Redis, which implements a variety of distributed services, such as reentrant lock, fair lock, multilock, red lock, read-write lock, etc.
[0067] 5) Kafka is a distributed publish-subscribe messaging system designed to handle high-throughput data streams.
[0068] At present, for large quantities of business data, the strategy of using relational databases to divide databases by year and tables by month has shown problems such as performance bottlenecks and rising maintenance costs. With the increase of business data, the write load of a single database or table in the relational database continues to rise, bringing a greater burden to the system. Maintaining indexes, adding fields, and system monitoring work have also become more complicated, making it difficult to expand the system architecture.
[0069] Specifically, as the business develops and the amount of data continues to increase, the amount of data in a single database or table continues to rise, resulting in performance degradation. When processing large amounts of data writes, relational databases need to maintain the ACID properties (atomicity, consistency, isolation, and durability) of transactions, which becomes particularly time-consuming with large amounts of data. In order to improve query efficiency, relational databases use indexes, but as the amount of data increases and the table structure becomes more complex, the cost of index maintenance is also increasing. In the process of business development, new fields or tables may need to be added to adapt to changes in demand, which often requires complex operations in relational databases.
[0070] In view of this, a data processing method and device, an electronic device and a storage medium are provided in an embodiment of the present application. The scheme synchronizes a first main table of a relational database to a first set of a non-relational database and a first index of a distributed search engine in a first time dimension through a data synchronization tool; splits the data of the first set in a second time dimension, generates a message based on the split data and sends it to a distributed publish-subscribe message system; obtains a first coding list according to a message query of the first index through the distributed publish-subscribe message system, obtains complete data based on the first coding list query, creates a first entity object through the complete data, and the distributed publish-subscribe message system is conducive to high-concurrency processing; stores the first entity object in the second set of the non-relational database in the first time dimension, and the non-relational database is conducive to high-concurrency writing, provides more powerful horizontal expansion capabilities, can cope with the growing amount of data and concurrent requests, and improves the availability and stability of the system.
[0071] The data processing method provided in the embodiment of the present application relates to the field of data processing technology. The data processing method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The cloud server, the server can also be a node server in the blockchain network; the software can be an application that implements the data processing method, etc., but is not limited to the above forms.
[0072] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0073] Figure 1 is an optional flowchart of the data processing method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S104.
[0074] Step S101: synchronize a first main table of a relational database to a first set of non-relational databases and a first index of a distributed search engine in a first time dimension using a data synchronization tool.
[0075] Specifically, this application does not make any specific restrictions on the data synchronization tool, and it can be flexibly selected in combination with actual processing needs. For example, FlinkCDC can be used for data synchronization, or Canal can be used for data synchronization.
[0076] It should be noted that the present application does not specifically limit the first time dimension, and it can be flexibly selected in combination with actual processing needs. For example, the first time dimension can be a year time dimension or a month time dimension.
[0077] It is understandable that the present application does not make any specific limitation on relational databases, and can be flexibly selected in combination with actual processing needs. Exemplarily, relational databases may include MySQL databases, and may also include Oracle databases. The present application does not make any specific limitation on non-relational databases, and can be flexibly selected in combination with actual processing needs. Exemplarily, non-relational databases may include MongoDB databases, and may also include Couchbase databases. The present application does not make any specific limitation on distributed search engines, and can be flexibly selected in combination with actual processing needs. Exemplarily, distributed search engines may include Elasticsearch, and may also include Apache Solr.
[0078] In some embodiments, FlinkCDC is used to synchronize the first main table of the MySQL database to the first collection of the MongoDB database and the first index of Elasticsearch in the annual time dimension. FlinkCDC introduces a lock-free algorithm, which eliminates the need to lock the MySQL database during the synchronization process, reducing risks and database pressure. It supports concurrent reading, and can complete massive data synchronization faster during the full data synchronization phase, while the data processing speed can be accelerated by horizontally expanding the number of nodes. Its breakpoint resume function ensures that even if the synchronization task fails after running for a period of time, there is no need to rerun the entire data synchronization task, and synchronization can be continued from the failed location. Such advantages make data synchronization tasks more stable and efficient, and reduce the burden on the MySQL database.
[0079] In some embodiments, a data synchronization tool is used to synchronize an associated table in a relational database that is associated with the first main table with a non-relational database in a year time dimension, wherein the associated table has associated data with the first main table. Exemplarily, when the first main table is a character dynamics table, the associated table includes a child dynamics table, and the character dynamics table and the child dynamics table are in a one-to-many relationship, and one character dynamic can have multiple child dynamic records.
[0080] It can be understood that the first main table, the first set and the first index of the present application can be a single table or multiple tables.
[0081] Optionally, based on Canal+Kafka, the incremental data of the first main table of MySQL is monitored and synchronously written to the first set of the non-relational database.
[0082] In this embodiment, a data synchronization tool is used to synchronize the first main table of a relational database to a first set of a non-relational database and a first index of a distributed search engine in a first time dimension, thereby reducing the pressure and risk of the database, supporting concurrent reading and horizontal expansion of the number of nodes, improving data processing speed and data synchronization efficiency, improving the stability and efficiency of synchronization tasks, and being able to continue synchronization even after a task fails, thereby improving the real-time and accuracy of data.
[0083] Step S102: split the data of the first set according to the second time dimension, generate a message according to the split data, and send it to the distributed publish-subscribe message system.
[0084] Specifically, the second time dimension is a subset of the first time dimension, that is, the second time dimension needs to be smaller than the first time dimension. The present application does not specifically limit the second time dimension, and it can be flexibly selected in combination with actual processing needs. Exemplarily, the second time dimension can adopt a monthly time dimension or a daily time dimension. It is understandable that when the first time dimension is a year, the second time dimension can be a month or a day, and when the first time dimension is a month, the second time dimension can be a day or an hour.
[0085] Exemplarily, the data of the first set is split according to the daily time dimension, and a message is generated according to the split data and sent to the distributed publish-subscribe message system.
[0086] It should be noted that the third set includes the third code, start time, end time, creation time, update time, type and status fields, and the fourth set includes the fourth code, third code, date, creation time, update time and status fields. The third set is used to record the results of the split data conversion and storage, and the fourth set is used to record the detailed records executed in the second time dimension. Among them, the type field is used to identify whether the processed data is stored in a non-relational database or a distributed search engine.
[0087] In some embodiments, the split data is stored in the third set and the fourth set, a message is generated by using the third code and the date field, and the message is sent to the publish-subscribe message system. Specifically, the type field of the split data in the third set is a non-relational database, and the date field is the date field of the fourth set.
[0088] In this embodiment, the data of the first set is split according to the second time dimension, and a message is generated based on the split data and sent to the distributed publish-subscribe message system, which is conducive to multi-machine multi-threaded processing of the distributed publish-subscribe message system and improves the efficiency of data storage.
[0089] Step S103: query the first index according to the message to obtain the first coding list through the distributed publish-subscribe message system, query the first coding list to obtain complete data, and create the first entity object according to the complete data.
[0090] Specifically, the complete data includes the data of the first set and the associated table, the first entity object contains a one-to-many structure of the first set and the associated table, there is associated data between the associated table and the first set, the associated table is synchronized from the relational database to the non-relational database by a data synchronization tool, the message includes the third code and date, the distributed publish-subscribe messaging system is Kafka, the first code list includes the first code, and the first code is the ID of the first master table.
[0091] In some embodiments, the third encoding is used to group and deduplicate messages at the consumer end of the distributed publish-subscribe messaging system; the deduplicated messages are used as thread tasks and put into a thread pool for parallel processing by the distributed publish-subscribe messaging system.
[0092] In some embodiments, the first time dimension adopts year, the second time dimension adopts day, and the message includes date. Further, the date of the message is obtained; a distributed lock is used for mutual exclusive access through the consumer end of the distributed publish-subscribe message system; the corresponding year is converted according to the date, and the matching first index is found according to the year, and the first index includes a first code and a creation time field; the start time and the end time of the date are calculated, and the first index is queried through the creation time field greater than or equal to the start time and less than or equal to the end time to obtain the first code list; the second set is queried according to the first code list, and it is checked whether the query obtains a matching second record, and the second record includes an update time field; if the query does not obtain a matching second record, the first set and the associated table are queried according to the first code list to obtain complete data, and the first entity object is created through the complete data; if the query obtains a matching second record, the first set is queried according to the first code list to obtain a matching first record, and when the update time of the first record is greater than the update time of the second record, the first set and the associated table are queried according to the first code list to obtain complete data, and the first entity object is created through the complete data, and the first record includes an update time field.
[0093] In this embodiment, a first coding list is obtained according to a message query first index through a distributed publish-subscribe message system, complete data is obtained according to the query of the first coding list, and a first entity object is created through the complete data, thereby improving data integrity and consistency.
[0094] Step S104: store the first entity object in a second set of the non-relational database according to the first time dimension.
[0095] In some embodiments, the first entity object is stored in a second collection of a non-relational database in a first time dimension through a distributed publish-subscribe messaging system.
[0096] Optionally, the corresponding first time dimension is obtained through the creation time of the first entity object, and the first entity object is stored in the corresponding second set according to the corresponding first time dimension; the third code is obtained from the message; the status field of the record in the fourth set corresponding to the third code is set to completed; the update time of the record in the fourth set corresponding to the third code is updated according to the current time; the third record in the third set whose status field is unfinished; according to the start time, end time and third code of the third record, the fourth record of the fourth set whose status field is unfinished and matches the third record is obtained; if the fourth record does not exist, the status field of the third record is updated to completed; if the fourth record exists, a message is generated through the third code and the date field of the fourth record, and the message is sent to the publish-subscribe message system.
[0097] In this embodiment, the first entity object is stored in the second set of the non-relational database in the first time dimension, thereby improving the efficiency of data storage.
[0098] In steps S101 to S104 shown in the embodiment of the present application, a first main table of a relational database is synchronized to a first set of a non-relational database and a first index of a distributed search engine in a first time dimension through a data synchronization tool; the data of the first set is split in a second time dimension, and a message is generated according to the split data and sent to a distributed publish-subscribe message system; a first coding list is obtained according to a message query of the first index through the distributed publish-subscribe message system, complete data is obtained according to the first coding list query, and a first entity object is created through the complete data, and the distributed publish-subscribe message system is conducive to high-concurrency processing; the first entity object is stored in the second set of the non-relational database in the first time dimension, and the non-relational database is conducive to high-concurrency writing, providing a more powerful horizontal expansion capability, which can cope with the growing amount of data and concurrent requests, and improves the availability and stability of the system.
[0099] See also Figure 2 In some embodiments, step S103 may include but is not limited to steps S201 to S209:
[0100] Step S201: group and deduplicate messages using a third encoding in a distributed publish-subscribe message system.
[0101] Specifically, the first time dimension adopts year, the second time dimension adopts day, and the message includes the date.
[0102] Furthermore, all messages with the same third code are grouped, and the messages in each group are sorted according to date to remove duplicates.
[0103] In this embodiment, the distributed publish-subscribe message system uses the third encoding to group and deduplicate messages, thereby reducing the consumption of storage and processing resources and helping to ensure data consistency.
[0104] Step S202: putting the deduplicated messages into a thread pool as thread tasks through a distributed publish-subscribe message system.
[0105] In some embodiments, each message is treated as a thread task and placed in a thread pool. After the core thread finishes executing the logic of the previous message (date), it continues to take out new messages from the queue for execution. If the number of messages exceeds the queue quantity, the messages will be discarded.
[0106] For example, Kafka is configured with 3 partitions, the consumer service is configured in peer-to-peer mode, the thread pool of each service is configured with 10 core threads, and the number of queues is configured as 1000. Since 10 core threads are allocated to each of the three parallel consumer services, it is equivalent to processing 30 messages (i.e. 30 days of data) in parallel. The higher the partition configured by Kafka, the more matching service nodes there are, and the more messages (dates) are processed in parallel.
[0107] In this embodiment, the deduplicated messages are placed in a thread pool as thread tasks through a distributed publish-subscribe message system, so that tasks can be executed in parallel, thread resources can be managed effectively, and message processing speed can be faster.
[0108] Step S203, obtaining the date of the message.
[0109] Specifically, the first time dimension adopts year, the second time dimension adopts day. The date includes year, month and day. The message includes the third code and date.
[0110] Step S204: using a distributed lock to perform mutually exclusive access through a distributed publish-subscribe messaging system.
[0111] This application does not make specific restrictions on distributed locks, and can be flexibly selected in combination with actual processing needs. For example, the distributed lock can use a redisson distributed lock or a ZooKeeper distributed lock.
[0112] In some embodiments, the date is used as the distributed lock key. For example, "init:MongoDB:date" is used as the redisson distributed lock key to perform redisson distributed lock control.
[0113] In this embodiment, a distributed publish-subscribe message system uses a distributed lock for mutually exclusive access, thereby preventing multiple threads from accessing shared resources at the same time, which would lead to inconsistent data. This improves data accuracy and consistency and prevents waste of resources.
[0114] Step S205, convert the corresponding year according to the date, and find the matching first index according to the year.
[0115] Specifically, the first index includes a first code and a creation time field.
[0116] In some embodiments, the corresponding year is obtained according to the date, and the matching first index is found according to the year.
[0117] Step S206, calculate the start time and end time of the date, query the first index by creating a time field greater than or equal to the start time and less than or equal to the end time, and obtain the first coding list.
[0118] In some embodiments, the start time and end time of the date are calculated. For example, the date is "2022-01-01", the start time is (2022-01-01 00:00:00), and the end time is (2022-01-01 23:59:59). Correspondingly, the creation time field that meets the query condition may be (2022-01-01 01:00:00).
[0119] In some embodiments, the first coding list is obtained by querying the first index by creating a time field greater than or equal to the start time and less than or equal to the end time.
[0120] In this embodiment, the start time and end time of the date are calculated, and the first index is queried by creating a time field greater than or equal to the start time and less than or equal to the end time to obtain the first coding list, so as to prepare for the creation of the first entity object through the complete data for subsequent queries.
[0121] Step S207, query the second set according to the first encoding list to check whether the query obtains a matching second record.
[0122] Specifically, the second collection is used to store complete entity objects.
[0123] In this embodiment, the second set is queried according to the first coding list to check whether the query obtains a matching second record, thereby preparing for subsequent queries to obtain complete data and creating the first entity object through the complete data.
[0124] Step S208: If the query does not obtain a matching second record, complete data is obtained through querying according to the first coding list, and a first entity object is created through the complete data.
[0125] In some embodiments, if the query does not obtain a matching second record, the first set and the associated table of the non-relational database are queried according to the first coding list to obtain complete data, and the first entity object is created based on the complete data.
[0126] Specifically, the first entity object may include a one-to-many structure of an association table.
[0127] In this embodiment, if the query does not obtain a matching second record, the complete data is obtained by querying the first coding list, and the first entity object is created based on the complete data to implement the new data flow. The complete data and the first entity object obtained by the query ensure the integrity of the data.
[0128] Step S209: If the query obtains a matching second record, query the first set according to the first coding list to obtain a matching first record. When the update time of the first record is greater than the update time of the second record, query the first coding list to obtain complete data, and create the first entity object through the complete data.
[0129] Specifically, the first set includes an update time field, and the second set includes an update time field.
[0130] In some embodiments, if the query obtains a matching second record, the first set is queried according to the first coding list to obtain a matching first record, and it is determined whether the update time of the first record is greater than the update time of the second record.
[0131] Further, when the update time of the first record is greater than the update time of the second record, complete data is obtained by querying according to the first coding list, and the first entity object is created through the complete data.
[0132] It should be noted that when the update time of the first record is less than or equal to the update time of the second record, no processing is performed.
[0133] In this embodiment, if the query obtains a matching second record, the first set is queried according to the first code list to obtain a matching first record. When the update time of the first record is greater than the update time of the second record, the query obtains complete data according to the first code list, and the first entity object is created through the complete data, thereby improving the accuracy and latestness of the data. By comparing and updating records, it can be ensured that the latest data is always used to create or update entity objects, thereby maintaining the integrity and reliability of the data.
[0134] See also Figure 3 In some embodiments, the first time dimension is in years, and the second time dimension is in days. Step S104 may include but is not limited to steps S301 to S308:
[0135] Step S301, obtaining the corresponding year through the creation time of the first entity object, and storing the first entity object into the corresponding second set according to the corresponding year;
[0136] Specifically, the first entity object includes a creation time.
[0137] Step S302, obtaining a third code from the message;
[0138] Exemplarily, after the data processing of the current date is completed and stored in the second set, the third code is obtained from the message.
[0139] Step S303, setting the status field of the record in the fourth set corresponding to the third code to completed;
[0140] Specifically, the fourth set includes a third coding field, the third set is used to record the result of the split data conversion and storage, and the fourth set is used to record the detailed records executed in the daily time dimension.
[0141] In this embodiment, the status field of the record in the fourth set corresponding to the third code is set to completed, which can effectively manage the status of the data and improve the consistency and integrity of the data.
[0142] Step S304, updating the update time recorded in the fourth set corresponding to the third code according to the current time;
[0143] Specifically, the current time is the current real time.
[0144] In this embodiment, the update time recorded in the fourth set corresponding to the third code is updated according to the current time, thereby improving data consistency and integrity.
[0145] Step S305, periodically obtaining a third record in the third set whose status field is "unfinished";
[0146] Specifically, the third set includes type, start time, end time and a third encoding field.
[0147] Exemplarily, the type of the third record may be a non-relational database or a distributed search engine.
[0148] In some embodiments, a third record in the third set whose type is a non-relational database and whose status field is incomplete is obtained at a regular interval.
[0149] Step S306, acquiring a fourth record of a fourth set whose status field is incomplete and matches the third record according to the start time, end time and third code of the third record;
[0150] Step S307, if the fourth record does not exist, updating the status field of the third record to completed;
[0151] It is understandable that if the fourth record does not exist, it means that the data in the third record has been synchronized to the second set.
[0152] Step S308: If the fourth record exists, a message is generated using the third code and the date field of the fourth record, and the message is sent to the publish-subscribe messaging system.
[0153] It is understandable that if the fourth record exists, it means that there is still data that has not been processed and stored, and a program interruption may have occurred.
[0154] In this embodiment, if the fourth record exists, a message is generated using the third code and the date field of the fourth record, and the message is sent to the publish-subscribe message system, thereby achieving timed compensation retransmission of data and improving data consistency and integrity.
[0155] Figure 4 is an optional flowchart of the data processing method provided in the embodiment of the present application. Figure 4 The method may include but is not limited to steps S401 to S403.
[0156] Step S401: split the data of the first index according to the second time dimension, generate a message from the split data of the nearest neighbor first time dimension and send it to the distributed publish-subscribe message system.
[0157] Exemplarily, the first time dimension adopts years, the second time dimension adopts days, the data of the first index is split according to the daily time dimension, and messages are generated from the split data of nearly two years and sent to the distributed publish-subscribe message system.
[0158] It should be noted that the third set includes the third code, start time, end time, creation time, update time, type and status field, and the fourth set includes the fourth code, third code, date, creation time, update time and status field. The third set is used to record the results of the split data conversion and storage, and the fourth set is used to record the detailed records executed in the second time dimension.
[0159] In some embodiments, the split data is stored in the third set and the fourth set, a message is generated through the third code and date field, and the message is sent to the publish-subscribe message system. Specifically, the split data in the type field of the third set is a distributed search engine.
[0160] In this embodiment, the data of the first index is split according to the second time dimension, and the data after the split of the nearest neighbor first time dimension is generated into a message and sent to the distributed publish-subscribe message system, which is conducive to the distributed publish-subscribe message system to perform multi-machine multi-threaded processing, improve the efficiency of data storage, and facilitate subsequent data query through a distributed search engine, thereby improving the query efficiency.
[0161] Step S402: query the first index according to the message to obtain the second list through the distributed publish-subscribe message system, query the second list to obtain the second complete data, and create the second entity object according to the second complete data.
[0162] Specifically, the second complete data includes the first index and the data of the second associated table, the second entity object contains a one-to-many structure of the first index and the second associated table, there is associated data between the second associated table and the first index, the second associated table is synchronized from the relational database to the non-relational database by a data synchronization tool, the message includes a third code and a date, and the distributed publish-subscribe messaging system is Kafka.
[0163] In some embodiments, the distributed publish-subscribe messaging system uses the third encoding to group and deduplicate messages; the distributed publish-subscribe messaging system treats the deduplicated messages as thread tasks and puts them into a thread pool for parallel processing.
[0164] In some embodiments, the first time dimension adopts year and the second time dimension adopts day. Further, the date of the message is obtained; a distributed lock is used for mutually exclusive access through a distributed publish-subscribe message system; the corresponding year is converted according to the date, and a matching first index is found according to the year, and the first index includes a first code and a creation time field; the start time and the end time of the date are calculated, and the first index is queried through the creation time field greater than or equal to the start time and less than or equal to the end time to obtain the second list; the second index is queried according to the second list, and it is checked whether the query obtains a matching second record, and the second record includes an update time field; if the query does not obtain a matching second record, the second complete data is obtained according to the second list, and the second entity object is created through the second complete data; if the query obtains a matching second record, the first index is queried according to the second list to obtain a matching first record, and when the update time of the first record is greater than the update time of the second record, the second complete data is obtained according to the second list, and the second entity object is created through the second complete data. Wherein, the first record includes an update time field, and the second list includes the first code.
[0165] In this embodiment, the distributed publish-subscribe message system obtains the second list according to the message query first index, obtains the second complete data according to the second list query, and creates the second entity object according to the second complete data, thereby improving the integrity and consistency of the data.
[0166] Step S403: store the second entity object in the second index of the distributed search engine in the first time dimension.
[0167] In some embodiments, the second entity object is stored in a second index of the non-relational database in a first time dimension through a distributed publish-subscribe messaging system.
[0168] Optionally, the corresponding first time dimension is obtained through the creation time of the second entity object, and the second entity object is stored in the corresponding second index according to the corresponding first time dimension; the third code is obtained from the message; the status field of the record in the fourth set corresponding to the third code is set to completed; the update time of the record in the fourth set corresponding to the third code is updated according to the current time; the third record in the third set whose status field is unfinished; according to the start time, end time and third code of the third record, the fourth record of the fourth set whose status field is unfinished and matches the third record is obtained; if the fourth record does not exist, the status field of the third record is updated to completed; if the fourth record exists, a message is generated according to the third code and the date field of the fourth record, and the message is sent to the publish-subscribe message system.
[0169] In some embodiments, the second index achieves data synchronization with the second set through an eventual consistency scheme. Specifically, the eventual consistency scheme includes: when the data of the first master table is updated, an operation record with a synchronization status of "pending synchronization" is added to the fifth set; the operation record is encapsulated into a message id (operation record id) and a message content (dynamic object information), and sent to Kafka. The operation record information is batch-pulled through the Kafka consumer end to obtain the dynamic object information (i.e., the first entity object and the second entity object), write the dynamic object information into the second set and the second index, and update the synchronization status of the fifth set to "synchronized", where the fifth set is used to record whether the data is synchronized.
[0170] Among them, when sending to Kafka is abnormal or consumption fails on the Kafka consumer side, the "error" mark is updated for the fifth set; obtain the record of the fifth set whose synchronization status is "pending synchronization" and has the "error" mark, obtain the first entity object information through the record, extract the id and year of the first entity object, and query whether there is a matching record in the second set. If not, add a new one. If there is a matching record, determine whether the update time of the matching record is greater than the update time of the fifth set record. If it is greater, update it, otherwise do not process it.
[0171] In this embodiment, the second entity object is stored in the second index of the non-relational database in the first time dimension, thereby improving the efficiency of data storage and the synchronization of data.
[0172] In steps S401 to S403 shown in the embodiment of the present application, the data of the first index is split according to the second time dimension, and a message is generated from the split data of the nearest neighbor first time dimension and sent to the distributed publish-subscribe message system. The second list is obtained by querying the first index according to the message through the distributed publish-subscribe message system, and the second complete data is obtained according to the second list query. A second entity object is created according to the second complete data, and the second entity object is stored in the second index of the distributed search engine according to the first time dimension, thereby improving data consistency, meeting the performance requirements of the nearest neighbor first time dimension dynamic data and complex statistical queries, optimizing query efficiency, and improving user experience.
[0173] Next, the solution of the embodiment of the present invention is described in detail and explained in conjunction with a specific scenario of synchronizing MySQL sub-library and sub-table data with MongoDB:
[0174] The application method may include but is not limited to the following steps:
[0175] Step 1: Use FlinkCDC to synchronize MySQL data to MongoDB and ES in the year dimension.
[0176] Among them, FlinkCDC is used to synchronize the dynamic business main table (i.e., the first main table) of MySQL (i.e., relational database) to the first collection (init_year_daily) of MongoDB (i.e., non-relational database) and the first index of ES (i.e., distributed search engine) with the year dimension (i.e., the first time dimension), and FlinkCDC is used to synchronize the related tables (i.e., associated tables) of the dynamic business main table to the collection of MongoDB with the "init_year_xx" rule.
[0177] Specifically, the first index of es uses "es_year_daily" as the rule, and deep paging is used as a program to improve efficiency. The id (that is, the first code) and creation time of the dynamic business main table are synchronized to es, and the query efficiency is improved through search_after rolling query.
[0178] For example, the example diagram of connecting to MySQL sub-library and sub-table data is as follows: Figure 5 As shown, the example diagram of connecting to MongoDB is as follows Figure 6 As shown, the schematic diagram of FlinkCDC creating a synchronization task is as follows Figure 7 shown.
[0179] Step 2: Split the MongoDB source data by day dimension (i.e., the second time dimension);
[0180] Among them, MongoDB documents use id and List objects to map one-to-many relationships.
[0181] For example, assuming that there are 3 years of data in the MySQL dynamic business, there are at most 365*3=1095 days after splitting by the day dimension.
[0182] Step 3: Treat each day’s data as a message and use Kafka’s features to process it on multiple machines and threads.
[0183] Among them, two MongoDB collections data_migration (i.e. the third collection) and data_migration_detail (i.e. the fourth collection) are used to store records. The data_migration collection has fields id, syncType (type: MONGODB or ES), start time, end time, creation / update time, state (1-to be completed; 2-completed). The data_migration_detail collection records the day date (i.e. the date field), and has fields id, dataMigrationId (id of the data_migration collection), dateStr (day date), creation / update time, state (1-to be completed; 2-completed). It should be noted that the records with syncType of "MONGODB" record all the day dates (i.e. dates) calculated from the start time and end time, and the records with syncType of "ES" only record the day dates of the last two years. By way of example, the schematic diagrams of the data_migration collection and the data_migration_detail collection are as follows. Figure 8 shown.
[0184] Furthermore, the records with syncType of "MONGODB" use all the corresponding days and dates as the message key and message content: {"migrationDetaiId": id of the data_migration_detail collection, "dateStr": day and date}, and send them to the Kafka topic "init_MongoDB_data_topic" to process the MongoDB digital conversion process; the records with syncType of "ES" use all the corresponding days and dates as the message key and message content: {"migrationDetaiId": id of the data_migration_detail collection, "dateStr": day and date}, and send them to the Kafka topic "init_elasticsearch_data_topic" to process the ES data conversion. For example, the data processing conversion diagram is as follows Fig. 9 shown.
[0185] Optionally, use "init:MongoDB:day date" as the distributed lock key to perform redisson distributed lock control, and convert the year from the day date: find the matching es dynamic business main table index (i.e. the first index) es_year_daily (FlinkCDC synchronization), and convert the start timestamp and end timestamp of the day date [for example, if the day date is 2022-01-01, convert it to the matching start date (2022-01-01 00:00:00) and end date (2022-01-01 23:59:59)], through the creation time (timestamp) of the index field greater than or equal to the start timestamp and less than or equal to the end timestamp, search_after queries 500 records per page (using id as the only ascending order), and obtains the id list (i.e. the first code list) of es_year_daily (i.e. the first index); through the first code list, the MongoDB business collection "daily_year" (i.e. the second collection) is queried. If there is no matching record, the data flow of adding the second MongoDB collection is performed. If there is a matching record, it is determined whether the update time of the source dynamic business main table (i.e. the first collection) is greater than the update time of the business collection "daily_year" (i.e. the second collection). If it is satisfied, it is updated. If not satisfied, the record is not processed.
[0186] The data flow of the newly added MongoDB second set includes: querying the MongoDB source dynamic related data (init_year_xx) through the id list of the es dynamic business main table (i.e., the first index), and obtaining the complete data of the dynamic business main table (init_year_daily) and the related tables (init_year_children, init_year_img, etc.). The first entity object DailyMongo is created through the obtained dynamic related source data, and the data is structured (including the one-to-many structure of the related table). Exemplarily, the structure of the first entity object of DailyMongo is as follows:
[0187] public class DailyMongo{
[0188] private Long id;
[0189] private List <imgmongomodel>imgModels;
[0190] private List <childmongomodel>childModels;
[0191] }
[0192] Optionally, use "init:elasticsearch:day date" as the distributed lock key to perform redisson distributed lock control, and convert the year from the day date: find the matching es dynamic business main table index (i.e. the first index) es_year_daily (FlinkCDC synchronization), and convert the start timestamp and end timestamp of the day date, and perform search_after to query 500 records per page (with id as the only ascending order) through the creation time (timestamp) of the index field greater than or equal to the start timestamp and less than or equal to the end timestamp, and obtain the id list (i.e. the second list) of the es dynamic business main table (i.e. the first index): query the second index through the second list. If there is no matching record, perform the new data process. If there is a matching record, determine whether the update time of the first index is greater than the update time of the second index. If it is satisfied, update it. If not, the record is not processed.
[0193] Among them, the newly added data process includes: querying the MongoDB source dynamic related data (init_year_xx) through the id list of the es dynamic business main table (i.e. the first index), and obtaining the complete data of the dynamic business main table (init_year_daily) and the related tables (init_year_children, init_year_img, etc.). The second entity object DailyESModel is created through the obtained dynamic related source data, and the data is structured (including the one-to-many structure of the related table). Exemplarily, the second entity object structure of DailyESModel is as follows:
[0194] public class DailyESModel{
[0195] private Long id;
[0196] private List <imgmongomodel>imgModels;
[0197] private List <childmongomodel>childModels;
[0198] }
[0199] Step 4: Calculate the corresponding year by the creation time and store the corresponding MongoDB document data (i.e., archive by year);
[0200] Optionally, DailyMongo's first entity object is stored in mongdob's business collection "daily_year" (i.e., the second collection). After the data processing of the current day date (i.e., date) is completed, migrationDetaiId is extracted from the known message content, and the state of the update collection data_migration_detail (i.e., the fourth collection) is set to "2" to indicate "completed", and the time is updated, and the distributed lock is released.
[0201] Optionally, the second entity object of DailyESModel is stored in the es index "es_daily" (i.e. the second index). After all the date data of the day is stored in "es_daily", migrationDetaiId is also extracted from the known message content, and the state of the collection data_migration_detail is updated to "2", and the time is updated to release the distributed lock.
[0202] In some embodiments, the method further includes a timing compensation retransmission process, and the timing compensation retransmission process is as follows:
[0203] Specifically, by querying the records of the data_migration set (i.e., the third set) whose syncType is "MONGODB" and state=1 (i.e., not completed), the number of days in the range is calculated according to the start time and end time, and the matching records of the data_migration_detail set (i.e., the fourth set) whose state state=1 (i.e., not completed) are filtered out according to the matching days and id (i.e., the third code). If there is no record in the data_migration_detail set, the state of the data_migration set is updated to "2" and the update time. If there is a record in the data_migration_detail set, the query record is used to extract the content of the message to be sent: {"migrationDetaiId": id of the data_migration_detail set, "dateStr": number of days and date}, and send it to Kafka. It can be understood that the "ES" compensation retransmission process is similar to the "MONGODB" compensation retransmission process. By querying the records of the set data_migration (i.e. the third set) whose syncType is "ES" and state=1, the records matching the set data_migration_detail state state=1 are filtered out according to their ids, and the operation is performed.
[0204] For example, after the corresponding MongoDB document data and es index storage (i.e., archiving by year), the business transformation interaction process can be implemented. The business transformation interaction flow chart is as follows: Fig.10 As shown, the dotted line indicates that the corresponding id and the matching table name are extracted from ES, and MongoDB is used to obtain complete information. It can be understood that the data frequently accessed by the client is displayed by querying the index data of ES. ES performs queries that meet the conditions of the last two years (including multiple conditions, complex aggregation statistics, etc.), and the data that does not meet the conditions of the last two years are uniformly transformed and processed by MongoDB according to the routing rules (year). For internal interaction within the system, access to historical archived data is restricted by business, and there is no need for cross-year operations. Business access is performed through routing rules carrying years. Determine whether it meets the conditions of the last two years. If it meets the conditions, es will process complex query business or involve id query, convert time to year, and directly read the collection "daily_year". If it does not meet the conditions of the last two years, the statistics are processed by the collection "daily_year" (multiple conditions, paging, aggregation, etc.). The processing of archived data can allow time query efficiency to be lower.
[0205] It should be noted that the ES index "es_daily" (i.e. the second index) achieves data synchronization with the MongoDB "daily_year" (i.e. the second collection) through the eventual consistency solution.
[0206] Specifically, the final consistency solution includes: when the dynamic business is writing, the collection "daily_operate_record" (i.e., the fifth collection) adds an operation record with a synchronization status of "pending synchronization"; the operation record is encapsulated into a message id (operation record id) and a message content (dynamic object information), and sent to Kafka. The operation record information is pulled in batches through the consumer end, and the dynamic object information (i.e., the first entity object and the second entity object) is obtained, and written to the collection "daily_year" and written to the es index (es_daily), and the synchronization status of "daily_operate_record" is updated to "synchronized", and ack confirmation is performed. When sending to Kafka is abnormal or the consumption of the Kafka consumer fails, "daily_operate_record" is updated to the "error" mark; the records of the collection daily_operate_record with a synchronization status of "pending synchronization" and an "error" mark are obtained at intervals for logical processing.
[0207] The logic for processing the MongoDB dynamic business collection daily_year in the database includes: obtaining dynamic object information through operation records, extracting the id and year of the dynamic object, querying the collection "daily_year" to see if there is a matching record, and if not, adding a new record. If there is a matching record, determine whether the update time is greater than the update time of the query record. If it is greater, update it, otherwise do not process it.
[0208] It is understandable that the logic of processing the ES index es_daily and the logic of processing the MongoDB collection daily_year are similar. The id and year are obtained according to the dynamic object information to determine whether the year meets the two-year rule. If not, no processing is performed. If it meets the rule, the index es_daily is queried to see if there is a matching record. If not, a new record is added. If so, the update time is determined to determine whether to perform an update operation.
[0209] Furthermore, after MongoDB and es logic are processed, the synchronization status of the update collection "daily_operate_record" is set to "Synchronized".
[0210] Optionally, based on cannal+Kafka, the incremental data of the dynamic data of MySQL sub-libraries and sub-tables is monitored and synchronously written to the second set. Among them, FlinkCDC synchronizes the MySQL incremental data to the first set, and determines whether the second set has corresponding records based on the incremental data of the first set. If there are no records, add new ones; if there are records, judge according to the last update time: if the update time of the incremental data is greater than the update time of the second set record, update it, otherwise do not process it.
[0211] See also Fig.11 The present application also provides a data processing device that can implement the above data processing method. The device includes:
[0212] A synchronization module 1101 is used to synchronize a first main table of a relational database to a first set of non-relational databases and a first index of a distributed search engine in a first time dimension through a data synchronization tool;
[0213] A splitting module 1102 is used to split the data of the first set according to a second time dimension, generate a message according to the split data and send it to a distributed publish-subscribe message system, wherein the second time dimension is a subset of the first time dimension;
[0214] The processing module 1103 is used to query the first index according to the message through the distributed publish-subscribe message system to obtain a first coding list, query according to the first coding list to obtain complete data, and create a first entity object through the complete data, wherein the complete data includes data of a first set and an associated table, the first entity object includes a one-to-many structure of the first set and the associated table, the associated table has associated data with the first set, and the associated table is synchronized from the relational database to the non-relational database by the data synchronization tool;
[0215] The storage module 1104 is configured to store the first entity object in a second set of the non-relational database according to a first time dimension.
[0216] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0217] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above data processing method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0218] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0219] See also Fig.12 , Fig.12 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0220] The processor 1201 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0221] The memory 1202 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1202 can store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1202, and the processor 1201 calls and executes the data processing method of the embodiments of this application;
[0222] Input / output interface 1203, used to implement information input and output;
[0223] The communication interface 1204 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0224] A bus 1205 that transmits information between various components of the device (e.g., the processor 1201, the memory 1202, the input / output interface 1203, and the communication interface 1204);
[0225] The processor 1201 , the memory 1202 , the input / output interface 1203 and the communication interface 1204 are connected to each other in communication within the device via the bus 1205 .
[0226] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the above-mentioned data processing method when executed by a processor.
[0227] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0228] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0229] The data processing method, data processing device, electronic device and storage medium provided by the embodiments of the present application synchronize the first main table of the relational database to the first set of the non-relational database and the first index of the distributed search engine in the first time dimension through a data synchronization tool; split the data of the first set in the second time dimension, generate a message according to the split data and send it to the distributed publish-subscribe message system; obtain the first coding list according to the message query first index through the distributed publish-subscribe message system, obtain complete data according to the first coding list query, create the first entity object through the complete data, and the distributed publish-subscribe message system is conducive to high-concurrency processing; store the first entity object in the second set of the non-relational database in the first time dimension, and the non-relational database is conducive to high-concurrency writing, providing more powerful horizontal expansion capabilities, able to cope with the growing amount of data and concurrent requests, and improving the availability and stability of the system.
[0230] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0231] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0232] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0233] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0234] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0235] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.
[0236] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0237] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0238] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0239] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Accs Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0240] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the rights of the present application is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application should be within the scope of the rights of the present application.< / childmongomodel> < / imgmongomodel> < / childmongomodel> < / imgmongomodel>
Claims
1. A data processing method, characterized in that: The method comprises: Synchronize the first main table of the relational database to the first set of the non-relational database and the first index of the distributed search engine in the first time dimension through a data synchronization tool; Splitting the data of the first set according to a second time dimension, generating a message according to the split data and sending it to a distributed publish-subscribe message system, wherein the second time dimension is a subset of the first time dimension; The first index is queried according to the message through a distributed publish-subscribe message system to obtain a first coding list, and complete data is queried according to the first coding list. A first entity object is created through the complete data, wherein the complete data includes data of a first set and an associated table, and the first entity object includes a one-to-many structure of the first set and the associated table. There is associated data between the associated table and the first set, and the associated table is synchronized from the relational database to the non-relational database by the data synchronization tool; storing the first entity object in a second set of the non-relational database in a first time dimension; The message includes a third code, the querying the first index according to the message through the distributed publish-subscribe message system to obtain a first code list, querying according to the first code list to obtain complete data, and creating a first entity object through the complete data includes: The distributed publish-subscribe message system uses a third encoding to group and remove duplicates from the messages; The deduplicated messages are used as thread tasks through the distributed publish-subscribe message system and put into a thread pool for parallel processing; The first time dimension adopts year, the second time dimension adopts day, the message includes date, the querying the first index according to the message through the distributed publish-subscribe message system to obtain a first coding list, querying according to the first coding list to obtain complete data, and creating a first entity object through the complete data includes: the date on which said message was obtained; The distributed publish-subscribe message system uses distributed locks for mutually exclusive access. Convert the corresponding year according to the date, and find the first matching index according to the year, where the first index includes a first code and a creation time field; Calculate the start time and end time of the date, query the first index through the creation time field being greater than or equal to the start time and less than or equal to the end time, and obtain a first coding list; querying the second set according to the first code list, and checking whether the query obtains a matching second record, wherein the second record includes an update time field; If the query does not obtain a matching second record, query the first coding list to obtain complete data, and create a first entity object using the complete data; If the query obtains a matching second record, the first set is queried according to the first coding list to obtain a matching first record. When the update time of the first record is greater than the update time of the second record, the complete data is obtained by querying according to the first coding list, and the first entity object is created through the complete data. The first record includes an update time field.
2. The method according to claim 1, characterized in that The step of splitting the data of the first set according to the second time dimension and generating a message according to the split data and sending the message to the distributed publish-subscribe message system includes: The split data is stored in a third set and a fourth set, wherein the third set is used to record the result of the split data conversion and storage, and the fourth set is used to record the detailed records executed in the second time dimension, wherein the third set includes a third code, a start time, an end time, a creation time, an update time, and a status field, and the fourth set includes a fourth code, the third code, a date, a creation time, an update time, and a status field; A message is generated by using the third code and the date field, and the message is sent to a publish-subscribe message system.
3. The method according to claim 2, characterized in that The first entity object includes a creation time, and storing the first entity object in a second set of the non-relational database in a first time dimension includes: Obtaining a corresponding first time dimension according to the creation time of the first entity object, and storing the first entity object into the corresponding second set according to the corresponding first time dimension; Obtaining the third code from the message; Setting the status field of the record in the fourth set corresponding to the third code to completed; The update time recorded in the fourth set corresponding to the third code is updated according to the current time.
4. The method according to claim 2, characterized in that: The storing the first entity object in the second set of the non-relational database in the first time dimension further includes: Get the third record whose status field is unfinished in the third set; According to the start time, end time and third code of the third record, obtaining a fourth record of a fourth set whose status field is incomplete and matches the third record; If the fourth record does not exist, updating the status field of the third record to completed; If the fourth record exists, a message is generated by using the third code and the date field of the fourth record, and the message is sent to a publish-subscribe messaging system.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Splitting the data of the first index according to the second time dimension, generating a message from the split data of the nearest neighbor first time dimension and sending it to the distributed publish-subscribe message system; The first index is queried according to the message through a distributed publish-subscribe message system to obtain a second list, second complete data is queried according to the second list, and a second entity object is created according to the second complete data, wherein the second complete data includes the first index and data of the second association table, the second entity object includes a one-to-many structure of the first index and the second association table, the second association table has associated data with the first index, and the second association table is synchronized from the relational database to the non-relational database by the data synchronization tool; The second entity object is stored in a second index of the distributed search engine in a first time dimension.
6. A data processing device, characterized in that: The device comprises: A synchronization module, used to synchronize a first main table of a relational database to a first set of non-relational databases and a first index of a distributed search engine in a first time dimension through a data synchronization tool; a splitting module, configured to split the data of the first set according to a second time dimension, generate a message according to the split data and send it to a distributed publish-subscribe message system, wherein the second time dimension is a subset of the first time dimension; A processing module, configured to obtain a first coding list by querying the first index according to the message through a distributed publish-subscribe message system, obtain complete data by querying the first coding list, and create a first entity object through the complete data, wherein the complete data includes data of a first set and an associated table, the first entity object includes a one-to-many structure of the first set and the associated table, the associated table has associated data with the first set, and the associated table is synchronized from the relational database to the non-relational database by the data synchronization tool; A storage module, configured to store the first entity object in a second set of a non-relational database in a first time dimension; The message includes a third code, and the processing module is further used for: The distributed publish-subscribe message system uses a third encoding to group and remove duplicates from the messages; The deduplicated messages are used as thread tasks through the distributed publish-subscribe message system and put into a thread pool for parallel processing; The first time dimension adopts year, the second time dimension adopts day, the message includes date, and the processing module is further used for: the date on which said message was obtained; The distributed publish-subscribe message system uses distributed locks for mutually exclusive access. Convert the corresponding year according to the date, and find the first matching index according to the year, where the first index includes a first code and a creation time field; Calculate the start time and end time of the date, query the first index through the creation time field being greater than or equal to the start time and less than or equal to the end time, and obtain a first coding list; querying the second set according to the first code list, and checking whether the query obtains a matching second record, wherein the second record includes an update time field; If the query does not obtain a matching second record, query the first coding list to obtain complete data, and create a first entity object using the complete data; If the query obtains a matching second record, the first set is queried according to the first coding list to obtain a matching first record. When the update time of the first record is greater than the update time of the second record, the complete data is obtained by querying according to the first coding list, and the first entity object is created through the complete data. The first record includes an update time field.
7. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
