A method and device for exporting data
By dividing the query thread and the export thread when exporting the database, the problem of high CPU usage and idle resources during data export is solved, and the device stability and export speed are improved.
Patent Information
- Application Number
- CN201910973879.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-14
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2039-10-14
AI Technical Summary
When exporting data to existing databases, due to the huge amount of data written, CPU usage increases, a large amount of hardware resources are occupied, and device stability is reduced. During data query, a large amount of data writing resources are left idle, reducing resource utilization.
By detecting the triggering conditions for data export, all data export tasks are obtained and the threads in the thread pool are divided into query threads and export threads. The query thread extracts target data from the database and the export thread writes data to avoid all hardware resources being used for writing operations. , improve resource utilization.
Improved device stability and IO interface utilization, and increased the speed of big data export tasks.
Smart Images

Figure CN110851249B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data processing, and in particular relates to a method and device for exporting data. Background Art
[0002] As all kinds of files are digitized, the amount of data contained in the database is getting bigger and bigger. In daily work and life, users often need to query and export corresponding data through the database, so how to effectively export the required data is particularly important. In particular, when the amount of data to be exported is large, most databases often need to query the required data from the database when responding to the data export task. After querying all the target data, the data export operation is performed. Therefore, during the data export process, due to the huge amount of written data, the CPU usage will increase, occupying a large amount of hardware resources, reducing the stability of the device, and during the data query, a large amount of data writing resources are idle, reducing resource utilization. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a method and device for data export to solve the problem of existing data export response technology. When the amount of data to be exported is large, the huge amount of written data will cause the CPU occupancy to increase, occupy a large amount of hardware resources, reduce the stability of the device, and during data query, a large amount of data writing resources are idle, reducing resource utilization.
[0004] A first aspect of an embodiment of the present invention provides a method for exporting data, including:
[0005] If the preset data export triggering condition is met, all data export tasks associated with the data export triggering task are obtained;
[0006] Counting the number of tasks of the data export task and detecting the number of threads in the local thread pool;
[0007] Based on the number of tasks and the number of threads, the idle threads in the thread pool are divided into query threads and export threads;
[0008] The query thread is called to extract target data associated with each of the data export tasks from the database, and the target data is written into a preset task data document through the export thread.
[0009] A second aspect of an embodiment of the present invention provides a data export device, including:
[0010] A data export triggering unit, configured to obtain all data export tasks associated with the data export triggering task if a preset data export triggering condition is met;
[0011] A thread number counting unit, used to count the number of tasks of the data export task and detect the number of threads in the local thread pool;
[0012] A thread division unit, used for dividing the idle threads in the thread pool into query threads and export threads based on the number of tasks and the number of threads;
[0013] The data export execution unit is used to call the query thread to extract the target data associated with each data export task from the database, and write the target data into a preset task data document through the export thread.
[0014] A third aspect of an embodiment of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the first aspect when executing the computer program.
[0015] A fourth aspect of an embodiment of the present invention provides 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 steps of the first aspect are implemented.
[0016] The method and device for exporting data provided by the embodiment of the present invention have the following beneficial effects:
[0017] The embodiment of the present invention can obtain all data export tasks associated with the data export trigger condition when it is detected that the data export trigger condition is currently met, and identify the task number of the data export tasks obtained above, as well as the thread number of idle threads in the thread pool when the data export trigger condition is met, classify each idle thread based on the number of tasks and the number of threads, and divide it into a query thread for querying data and an export thread for exporting target data obtained by the query, and call the query thread to extract target data from the database. After obtaining the target data, it is immediately handed over to the export thread to perform the target data export operation, and then the next data export task is executed, thereby realizing the simultaneous execution of data query and data export operations. Compared with the existing data export technology, it does not query the target data of all data export tasks and then execute the data export operation uniformly, but divides the hardware resources in the device into different types, one part executes the data query operation, and the other part executes the data export operation, thereby avoiding all hardware resources being used for data writing operations, which would cause the CPU occupancy to increase instantly, and improve the stability of the device. On the other hand, in the process of executing the query operation, the target data that has been queried will also be exported, thereby improving the utilization rate of the device's IO interface and improving the data export speed when dealing with large data export tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0019] Figure 1 is a flow chart of a method for exporting data provided by the first embodiment of the present invention;
[0020] Figure 2 This is a specific implementation flow chart of a data export method S104 provided in the second embodiment of the present invention;
[0021] Figure 3 This is a specific implementation flow chart of a data export method S1044 provided in the third embodiment of the present invention;
[0022] Figure 4 This is a specific implementation flow chart of a method S1042 for exporting data provided in the fourth embodiment of the present invention;
[0023] Figure 5 is a specific implementation flow chart of a method for exporting data provided by the fifth embodiment of the present invention;
[0024] Figure 6 is a structural block diagram of a data export device provided by an embodiment of the present invention;
[0025] Figure 7 It is a schematic diagram of a terminal device provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0027] The embodiment of the present invention extracts the development process information of the product to be developed by performing image analysis on the received development process image, obtains the corresponding process page template according to the product type of the product to be developed, selects the process node template associated with each development node in the development process information from the process page template, imports the development content corresponding to each development node into the associated process node template, generates the node module of the process node, and connects each node module in sequence through the process connection line model in the process page template according to the node module of each process node and the node order corresponding to each process node in the development process image, generates the development process page of the product to be developed, realizes the automatic conversion from the development flow chart to the development process page, improves the efficiency of data export, and solves the problem that the existing data export technology requires the user to manually configure the corresponding node for each step in the flow chart, and layout the node modules for each node in the preset page, spends a lot of time on node creation and page layout, and has a low development speed.
[0028] In the embodiment of the present invention, the execution subject of the process is a terminal device, which includes but is not limited to: a server, a computer, a smart phone, a tablet computer and other devices capable of performing data export operations. Figure 1 The following is a flowchart of the method for exporting data according to the first embodiment of the present invention, which is described in detail as follows:
[0029] In S101, if a preset data export triggering condition is met, all data export tasks associated with the data export triggering task are acquired.
[0030] In this embodiment, the terminal device may be provided with a task library, in which a plurality of data export tasks that need to perform data export operations are stored, and each data export task may be configured with a corresponding data export trigger condition, wherein the data export trigger conditions of different data export tasks may be different or the same. For example, the terminal device executes the pending tasks in the task library with a preset response cycle, and the number of tasks executed in each response cycle is fixed. Based on this, the terminal device may determine the response cycle number of each pending task according to the order in which each pending task is received, and identify the response cycle number as the data export condition of the pending task. Therefore, the data export trigger conditions of all pending tasks with the same response cycle number are the same. In this case, when the terminal device detects that a certain response cycle has been reached, it will extract all the pending tasks associated with the response cycle from the task library as the data export tasks that need to be exported this time. Among them, each pending task may determine the processing order according to the order in which it is received. Of course, it may also configure corresponding processing priorities for different pending tasks according to the task content of the pending task and the request object to which the task belongs, and determine the processing order of each of the processing tasks based on the priority, and configure the associated response cycle.
[0031] Optionally, after receiving the pending task sent by the user terminal, the terminal device will parse the pending task, determine the task content of the pending task, and determine a first priority factor based on the task content. The first priority factor can be determined based on parameters such as the request type, expected data volume, and target feedback time of the task content; the terminal device determines the second priority factor based on the user level of the user to whom the user terminal belongs by identifying the user level; the terminal device records the receiving time of the pending task request, and determines the third priority factor of the pending request based on the number of historical pending tasks received and the receiving time. The terminal device imports the first priority factor, the second priority factor, and the third priority factor into the priority conversion model, calculates the processing priority of the pending task, and determines the response period associated with the pending task based on the processing priority.
[0032] In this embodiment, the data export task can be a periodic trigger task. For example, if the enterprise needs to count the daily product sales volume or the monthly employee attendance, this type of data export task can be configured with multiple trigger time points. In this case, if the terminal device detects that the current moment has reached the preset trigger time point of the data export task, it will identify the task trigger condition that satisfies the data export task and perform the data export operation on the data export task. Of course, the terminal device can identify the preset trigger time points of all data export tasks in the task library, and create a task response schedule based on the sequence of each trigger time point. The terminal device can create a task response monitoring thread to detect whether the current moment has reached any trigger time point in the task response schedule. If so, the corresponding data export task is executed.
[0033] Optionally, in this embodiment, the terminal device may be set with a resource threshold, and the resource occupancy rate of the terminal device may be obtained at a preset collection interval. If it is detected that the resource occupancy rate within a certain period of time is less than the resource threshold, it is identified that the terminal device is in an idle state, and a preset number of data export tasks may be extracted from the task library at this time, and operations S101 to S104 are performed.
[0034] In S102, the number of tasks of the data export task is counted, and the number of threads in the local thread pool is detected.
[0035] In this embodiment, after obtaining the data export task, the terminal device will count the number of tasks of the data export task to be executed this time, so as to divide the idle threads in the thread pool based on the number of tasks. At the same time, the terminal device can also detect the number of idle threads in the current thread pool. The terminal device can create multiple threads in the main process and execute different types of tasks through different threads. After the thread completes a task, it will be in an idle state and wait for the main process to assign other tasks. Therefore, before responding to the data export task, the terminal device can determine the total number of threads contained in the thread pool this time, detect the working status of each thread, and identify the number of threads in the idle state, that is, the number of threads mentioned above.
[0036] Optionally, in this embodiment, the terminal device can be set with a maximum number of threads. The terminal device can identify the number of threads created locally, and based on the number of created threads and the maximum number of threads, obtain the number that can be created, and identify the working status of each created thread, obtain the idle number of threads in the idle state, and calculate the above-mentioned number of threads based on the number that can be created and the idle number.
[0037] In S103, based on the number of tasks and the number of threads, the idle threads in the thread pool are divided into query threads and export threads.
[0038] In this embodiment, after determining the number of tasks and the number of threads, the terminal device can divide the idle threads contained in the thread pool into query threads and export threads according to the above two parameters, and perform initialization configuration operations on the query threads based on the query operation configuration script, and perform initialization configuration operations on the export threads based on the export operation configuration script.
[0039] Optionally, in this embodiment, the terminal device can be set with a query cycle number, and based on the ratio between the query cycle number and the task number, the number of query threads required to be configured for each query cycle is identified, and a corresponding number of query threads are allocated, and based on the number of query threads and the total number of idle threads, the number of export threads is obtained, and the corresponding number of idle threads in the thread pool are set as query threads and export threads.
[0040] Optionally, in this embodiment, the terminal device may be provided with a ratio of query to export, and according to the number of threads and the ratio, a corresponding number of query threads and export threads may be divided, that is, the ratio of the first number of query threads to the second number of export threads matches the above ratio. Preferably, the ratio may be 1:1. If the ratio of query threads to export threads is 1:1, the terminal device may establish a corresponding association relationship for each query thread and export thread. After the query thread obtains the target data, it may query the corresponding export thread based on the association relationship, and export the target data through the export thread. Optionally, the terminal device may establish a virtual data link between the export thread and the query thread based on the association relationship, so that the target data exported in the query thread can be quickly transmitted to the export thread to perform the export operation. Of course, if the query thread and the export thread are not the same, the terminal device may query the ratio between the thread and the export thread, and configure a corresponding export thread for each query thread. In this case, one export thread may correspond to multiple query threads, and the export operation is performed in sequence based on the output order of the target data.
[0041] In S104, the query thread is called to extract target data associated with each of the data export tasks from the database, and the target data is written into a preset task data document through the export thread.
[0042] In this embodiment, after dividing the threads, the terminal device can assign corresponding data export tasks to each query thread. The query thread will identify the task keywords contained in the data export task, and extract the data associated with the task keywords from the database, that is, the above-mentioned target data, and retrieve it from the database to the local. After the query thread completes all query tasks of a data export task, it will encapsulate all the target data obtained by the query and transmit it to the export thread. After the query completes a data export task, the query thread will extract the next data export task from the task pool and repeat the above operation until all data export tasks in the task pool are responded to and completed.
[0043] In this embodiment, the query thread can store the target data obtained by the query in the cache area. In this case, the export thread can extract the corresponding target data from the cache area to perform the data export operation, and after completing one data export operation, continue to extract another target data from the cache area to perform the data export operation. After the query thread obtains the target data through export, it can obtain the running status of each target data, select an export thread with an idle running status as the target export thread, and transfer the target data to the target export thread to perform the data export operation.
[0044] In this embodiment, the terminal device is configured with a data document template, and the export thread can import the target data into the data document template to generate a task data document. Of course, the terminal device can create corresponding data document templates for different data export tasks based on the task type. When performing the export operation, the associated data document template is selected based on the task type, and the target data is imported into the data document template to generate a task data document for the data export task.
[0045] From the above, it can be seen that a data export method provided by an embodiment of the present invention can obtain all data export tasks associated with the data export trigger condition when it is detected that the data export trigger condition is currently met, and identify the task number of the data export tasks obtained above, as well as the number of idle threads in the thread pool when the data export trigger condition is met, and classify each idle thread based on the number of tasks and the number of threads into a query thread for querying data and an export thread for exporting target data obtained by the query, and call the query thread to extract target data from the database, and after obtaining the target data, immediately hand it over to the export thread to perform the target data export operation, and then execute the next data export task, thereby realizing the simultaneous execution of data query and data export operations. Compared with the existing data export technology, it does not query the target data of all data export tasks and then execute the data export operation uniformly, but divides the hardware resources in the device into different types, one part executes the data query operation, and the other part executes the data export operation, thereby avoiding all hardware resources being used for data writing operations, which would cause the CPU occupancy to increase instantly, and improve the stability of the device. On the other hand, in the process of executing the query operation, the target data that has been queried will also be exported, thereby improving the utilization rate of the device's IO interface and improving the data export speed when dealing with large data export tasks.
[0046] Figure 2 FIG. 4 shows a specific implementation flow chart of a data export method S104 provided in the second embodiment of the present invention. Figure 2 , relative to Figure 1 In the embodiment, a data export method S104 provided in this embodiment includes: S1041 to S1044, which are described in detail as follows:
[0047] Further, the calling of the query thread to extract target data associated with each of the data export tasks from the database, and writing the target data into a preset task data document through the export thread, includes:
[0048] In S1041, the instantaneous maximum export amount of each of the export threads is collected, and the rated export data amount is calculated according to the instantaneous maximum export amount and the number of export threads of the export thread.
[0049] In this embodiment, when the terminal device executes the data export task, the data export task can be grouped. After completing the query task of an export task group through the query thread, all target data obtained by the query of the group can be exported. By grouping the data export tasks, hardware resources can be managed more effectively and data export operations can be estimated. On the other hand, when an abnormality in the exported data is detected, since different export task groups are independent of each other, the terminal device can quickly locate the group where the abnormal data export task is located, and re-respond to the data export task in the abnormal export task group, avoiding re-responding to all executed data export tasks, thereby improving the efficiency of abnormality repair.
[0050] In this embodiment, in order to realize the division of all data export tasks, the terminal device needs to determine the local rated export data volume. Since the query task mainly occupies the hardware resources of the database, and writing the target data to the local storage unit consumes the hardware resources of the terminal device, in this embodiment, the data export tasks are divided according to the rated export data volume.
[0051] In this embodiment, when creating each export thread, the terminal device configures the maximum export amount for each data export thread, so as to avoid occupying a large amount of hardware resources when an export thread is abnormal, thereby affecting the normal operation of the device. The maximum export amounts of different export threads can be the same or different. For example, if the priority of an export thread is higher, that is, the export thread is used to respond to data export tasks with higher priority, the allocated maximum export amount can be higher than other export threads with lower priority; of course, if the priorities of the export threads are the same, the corresponding instantaneous maximum export amounts can be the same.
[0052] In this embodiment, the terminal device may be set with an occupancy ratio. Based on the instantaneous maximum export volume and the occupancy ratio, the rated export volume of each export thread may be calculated, and the rated export data volume may be determined according to the rated export volume of all export threads.
[0053] In 1042, the task content of each of the data export tasks is parsed, and the expected data volume is determined based on the task content.
[0054] In this embodiment, the terminal device can estimate the data volume of the target data of each data export task. The specific implementation method can be: the terminal device parses the data export task and extracts the task content of the data export task. For example, the task content can be an SQL script, and the SQL script contains multiple SQL statements, each SQL statement corresponds to a keyword to be queried. Therefore, the terminal device can extract multiple keywords to be queried from the task content. If there are more query keywords, it means that the limiting information for the target data is greater, and the amount of data to be matched is less. Conversely, if there are fewer query keywords, the limiting information for the target data is less, and the amount of data to be matched is more. Therefore, the terminal device can determine the expected data volume of the data export task according to the number of target keywords contained in the task content.
[0055] In S1043, all the data export tasks are divided into at least one export task group according to the rated export data volume and the expected data volume of each data export task; the sum of the expected data volumes of all the data export tasks in the export task group is less than or equal to the rated export data volume.
[0056] In this embodiment, after the terminal device determines the expected data volume corresponding to each data export task, it can group the data export tasks based on the expected data volume. In order to avoid excessive resource usage of the terminal device during the export operation and affect the stability of the device, the sum of the expected data volumes of all data export tasks in the same export task group should not be greater than the rated export data volume of the export thread.
[0057] In S1044, the data export operation is performed on each of the export task groups respectively through the query thread and the export thread.
[0058] In this embodiment, after grouping the data export tasks, the terminal device can perform export operations separately based on the export task groups, that is, perform query operations on all data export tasks in the same export task group through a query thread, and after obtaining the target data, all target data in the export task group are handed over to the export thread to perform the export operation.
[0059] In an embodiment of the present invention, the terminal device divides the data export tasks into groups to ensure that the total amount of data export tasks in each export task group does not exceed the rated export amount of the terminal device, thereby ensuring the stability of the device operation and facilitating the management efficiency of the data export tasks.
[0060] Figure 3 FIG. 4 shows a specific implementation flow chart of a data export method S1044 provided in the third embodiment of the present invention. Figure 3, relative to Figure 2 In the embodiment described above, a data export method S1044 provided in this embodiment includes: S301 to S303, which are described in detail as follows:
[0061] Further, the performing the data export operation on each of the export task groups through the query thread and the export thread respectively includes:
[0062] In S301, the query thread is called to extract the target data of all the data export tasks in each of the export task groups from the database.
[0063] In this embodiment, the terminal device can configure a corresponding group number for each export task group, and respond to the data export tasks in each export task group in sequence based on the group number. When processing the export task group with group number 1, at this time, because the query thread is extracting the target data of the data export task from the database, and has not imported the target data locally, the export thread will be in an idle state. After the query thread completes all data export tasks in the export task group with group number 1, all target data of the group will be handed over to the export thread to perform the data export operation. At this time, the query thread will process the query task of the export task group with group number 2; and the export thread will process the export task of the export task group with group number 1. It can be seen that when the query thread executes the query task of the export task group with group number n, the export thread executes the export task of the export task group with group number n-1.
[0064] In S302, if it is detected that the target data of all the data export tasks in any of the export task groups is queried, a data export instruction is output; the data export instruction carries the group number of the export task group.
[0065] In this embodiment, after the terminal device detects that all data export tasks in the same export task group have completed the query operation, that is, after extracting the target data associated with the data export task from the database, a data export instruction can be generated, and based on the task number of each data export task, an index table between the target data and the task number can be established, and all target data and the index table can be encapsulated, and the data export instruction and the encapsulated target data packet can be transmitted to the export thread so that subsequent export operations can be performed through the export thread.
[0066] In this embodiment, since the query thread can perform query operations based on the order of group numbers, or randomly select the corresponding export task group to perform query operations, in order for the export thread to determine the export task group for this query, the group number can be added to the data export instruction, thereby facilitating the management of data export operations.
[0067] In S303, if the data export instruction is received, the export thread is controlled to perform a data export operation on the target data of the data export task corresponding to the group number.
[0068] In this embodiment, after detecting the data export instruction, the terminal device detects the working status of the export thread. If the export thread is still processing the target data output by the previous query thread, the target data output this time can be stored in the cache area, and the data export instruction can be added to the pending response list. After completing the task of the previous cycle, the export thread can process the export operations of the target data associated with each data export instruction in the pending response list in sequence based on the order of addition time; if the export thread is in an idle state, the target data can be encapsulated, and the target data packet can be transmitted to the export thread to perform the data export operation.
[0069] In this embodiment, the data export operation is the same as described in S104, and a data document template can be obtained, and according to the parameter type of each parameter in the target data, it is imported into the corresponding area of the data document template, thereby obtaining a data document for the data export task. For a specific description, please refer to the relevant description of S104, which will not be repeated here.
[0070] In the embodiment of the present invention, by querying each data export task and responding to the data export based on the export task group, the data export tasks can be effectively managed, thereby improving the stability of the terminal device and the management efficiency of the tasks.
[0071] Figure 4 FIG. 4 shows a specific implementation flow chart of a method S1042 for exporting data provided by the fourth embodiment of the present invention. Figure 4 , relative to Figure 2 In the embodiment, a data export method S1042 provided in this embodiment includes: S401 to S403, which are described in detail as follows:
[0072] Further, parsing the task content of each of the data export tasks and determining the expected data volume based on the task content includes:
[0073] In S401, task keywords in the task content are extracted through a preset semantic parsing algorithm.
[0074] In this embodiment, the terminal device is provided with a semantic parsing algorithm, which can identify the correlation between each character in the task content. If the correlation between any two or more characters is greater than a preset correlation threshold, the above-mentioned multiple characters are identified as the same phrase, so that the task content can be divided into multiple candidate keywords. The terminal device can extract task keywords from the candidate keywords based on the part of speech of each candidate keyword. For example, a noun candidate keyword can be selected as the task keyword.
[0075] Optionally, the terminal device can pre-process each task keyword. For example, if a task keyword appears a large number of times in the task content, a higher weight value can be configured for the task keyword. The weight value can be used to calculate the contribution weight when calculating the expected data volume. That is, the larger the weight value, the greater the contribution weight in the expected data volume, thereby improving the accuracy of the expected data volume calculation.
[0076] In S402, the word frequency parameters of each of the task keywords in the database are queried, and the word frequency parameters are imported into a preset expected data conversion model to calculate the expected data parameters of the word frequency parameters; the expected data conversion model is specifically:
[0077]
[0078] Among them, ξ Data is the expected data parameter; WF is the word frequency parameter; BF is the benchmark word frequency; BaseData is the benchmark data volume.
[0079] In this embodiment, after obtaining the task keyword, the terminal device can perform a global search for the task keyword in the database, detect the number of occurrences of the task keyword in the database, and identify the number of occurrences as the word frequency parameter of the task keyword. Preferably, the database establishes a word frequency index table. After new data is added to the database, the database can perform semantic analysis on the data, determine the data keywords contained in the data, and adjust the number of occurrences of the corresponding data keywords in the word frequency index table based on the number of occurrences of each data keyword, thereby achieving the purpose of real-time updating of the word frequency index table. In this case, the terminal device can directly obtain the word frequency parameters of each task keyword from the word frequency index table.
[0080] In this embodiment, the terminal device calculates the word frequency parameters of each task keyword respectively by importing the word frequency parameters of the task keyword into the expected data conversion model, and the expected data parameters corresponding to the task keyword can be calculated.
[0081] In S403, the expected data volume is determined according to all the expected data parameters of the task content.
[0082] In this embodiment, the terminal device can accumulate the expected data parameters corresponding to each task keyword in the task content, and then calculate the expected data volume of the task content. Preferably, if the task keyword has a corresponding weighted weight, as described above, the terminal device can calculate the weighted weight of each task keyword based on the number of times each task keyword appears in the task content, and perform weighted summation on each task keyword based on the weighted weight, thereby identifying the sum value as the expected data volume of the task content.
[0083] In an embodiment of the present invention, task keywords are identified by semantically parsing the task content, and expected data parameters are determined based on the word frequency parameters of each task keyword in the database. Thus, the expected data volume is calculated based on the expected data parameters of all task keywords, thereby achieving an estimation of the expected data volume of the task content and improving the accuracy of task management.
[0084] Figure 5 FIG. 5 shows a specific implementation flow chart of a data export method provided by the fifth embodiment of the present invention. Figure 5 , relative to Figures 1 to 4 In the embodiment, a method for data export provided by the embodiment further includes: S501 to S504, which are described in detail as follows:
[0085] Furthermore, before obtaining all data export tasks associated with the data export triggering task if the preset data export triggering condition is met, the method further includes:
[0086] In S501, a data export request sent by a user terminal is received; the data export request includes original data text.
[0087] In this embodiment, in addition to receiving the data export task sent by the user, the terminal device can also automatically configure the corresponding data export task based on the data export request sent by the task. For example, if the user needs to query whether there is an associated document with a high similarity to the preset document in the database, the data export request containing the preset document can be directly sent to the terminal device, and the terminal device can parse the data export request to extract the document data associated with the preset document from the database.
[0088] In this embodiment, the user can add the original text of the required query and export of associated data to the data export request, and send the data export request to the terminal device through the user terminal. In this case, the user terminal can be installed with a client associated with the terminal device, establish a communication link with the terminal device through the client, and transmit the data export request to the terminal device through the communication link. It should be noted that a query time limit can be set in the data export request, and the terminal device can configure the corresponding data export trigger condition based on the query time limit.
[0089] In S502, query keywords are extracted from the original text of the data.
[0090] In this embodiment, the terminal device can extract candidate keywords from the original text through a semantic parsing algorithm, and identify the query keywords from the candidate keywords. It should be noted that the terminal device can perform keyword optimization processing on the candidate keywords, and the optimization operations include: same or similar keyword merging operations, abnormal keyword filtering operations, etc. For example, if the first keyword and the second keyword are detected as synonyms or synonyms, the two keywords can be merged and replaced by the upper keyword; for another example, if the third keyword and the fourth keyword are detected as opposite keywords, such as "male" and "female", it is impossible to simultaneously satisfy the above two keywords for querying the target data, and one of the keywords needs to be filtered. The filtering method can calculate the number of occurrences of the above keywords, and select a keyword with a smaller number of occurrences as an abnormal keyword; or, the terminal device can identify the correlation between the keyword and other keywords, thereby calculating the fusion degree of the keyword, and select a keyword with a lower fusion degree as an abnormal keyword.
[0091] In S503, the data type associated with each query keyword in the data table of the database is identified, and an association relationship between the query keyword and the data type is established.
[0092] In this embodiment, since the table headers of the data tables of the database are set with different data types, such as "name", "address", "telephone number", etc., after the terminal device identifies the query keyword, it needs to determine the data type corresponding to each query keyword, so that based on the data type of the query keyword, an association relationship between the query keyword and the data type can be established, and through the association relationship, the corresponding SQL statement can be constructed.
[0093] In S504, a data export task of the data export request is output according to the association relationship.
[0094] In this embodiment, the terminal device can construct corresponding query statements, such as SQL statements, based on the association relationship, and merge and encapsulate all query statements to generate SQL scripts or data query scripts, and generate data export tasks based on the above scripts.
[0095] In the embodiment of the present invention, by creating a corresponding data export task for the original text sent by the user, users who do not have the compilation ability can also export the required query data in the database, thereby improving the versatility of data export.
[0096] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0097] Figure 6 The structure block diagram of a data export device provided by an embodiment of the present invention is shown. The data export device includes units for executing Figure 1 For details, please refer to the steps in the corresponding embodiment. Figure 1 and Figure 1 For the convenience of explanation, only the parts related to this embodiment are shown.
[0098] See also Figure 6 , the data export device includes:
[0099] A data export triggering unit 61 is used to obtain all data export tasks associated with the data export triggering task if a preset data export triggering condition is met;
[0100] A thread number counting unit 62, used to count the number of tasks of the data export task and detect the number of threads in the local thread pool;
[0101] A thread division unit 63, configured to divide the idle threads in the thread pool into query threads and export threads based on the number of tasks and the number of threads;
[0102] The data export execution unit 64 is used to call the query thread to extract the target data associated with each data export task from the database, and write the target data into a preset task data document through the export thread.
[0103] Optionally, the data export execution unit 64 includes:
[0104] A rated export data volume calculation unit, used for collecting the instantaneous maximum export volume of each of the export threads, and calculating the rated export data volume according to the instantaneous maximum export volume and the number of export threads of the export thread;
[0105] an expected data volume calculation unit, used for parsing the task content of each of the data export tasks and determining the expected data volume based on the task content;
[0106] An export task group division unit, used to divide all the data export tasks into at least one export task group according to the rated export data volume and the expected data volume of each data export task; the sum of the expected data volumes of all the data export tasks in the export task group is less than or equal to the rated export data volume;
[0107] The group export execution unit is used to execute data export operations on each of the export task groups through the query thread and the export thread.
[0108] Optionally, the grouping export execution unit includes:
[0109] A target data extraction unit, used for calling the query thread to extract the target data of all data export tasks in each of the export task groups from the database respectively;
[0110] A data export instruction output unit, configured to output a data export instruction if it is detected that the target data of all the data export tasks in any of the export task groups is queried; the data export instruction carries the group number of the export task group;
[0111] The export thread control unit is used to control the export thread to perform a data export operation on the target data of the data export task corresponding to the group number if the data export instruction is received.
[0112] Optionally, the expected data amount calculation unit includes:
[0113] A task keyword extraction unit, used to extract task keywords from the task content through a preset semantic parsing algorithm;
[0114] The expected data parameter calculation unit is used to query the word frequency parameters of each of the task keywords in the database, and import the word frequency parameters into a preset expected data conversion model to calculate the expected data parameters of the word frequency parameters; the expected data conversion model is specifically:
[0115]
[0116] Among them, ξ Data is the expected data parameter; WF is the word frequency parameter; BF is the base word frequency; BaseData is the base data volume;
[0117] The expected data volume conversion unit is used to determine the expected data volume according to all the expected data parameters of the task content.
[0118] Optionally, the data export device further includes:
[0119] A data export request receiving unit, configured to receive a data export request sent by a user terminal; the data export request includes an original text of the data;
[0120] A query keyword recognition unit, used to extract query keywords from the original text of the data;
[0121] An association relationship establishing unit, used to identify the data type associated with each query keyword in the data table of the database, and establish an association relationship between the query keyword and the data type;
[0122] A data export task creation unit is used to output the data export task of the data export request according to the association relationship.
[0123] Therefore, the data export device provided in the embodiment of the present invention does not query the target data of all data export tasks and then uniformly execute the data export operation, but divides the hardware resources in the device into different types, with one part executing the data query operation and the other part executing the data export operation, thereby avoiding all hardware resources being used for data writing operations, which would cause an instantaneous increase in CPU occupancy and improve the stability of the device. On the other hand, in the process of executing the query operation, the export operation will also be performed on the target data that has been queried, thereby improving the utilization rate of the device's IO interface and improving the data export speed when dealing with large data export tasks.
[0124] Figure 7 FIG. 1 is a schematic diagram of a terminal device provided by another embodiment of the present invention. Figure 7 As shown, the terminal device 7 of this embodiment includes: a processor 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70, such as a data export program. When the processor 70 executes the computer program 72, the steps in the above-mentioned various data export method embodiments are implemented, such as Figure 1 Alternatively, when the processor 70 executes the computer program 72, the functions of each unit in the above-mentioned device embodiments are realized, for example, Figure 6 The functions of modules 61 to 64 are shown.
[0125] Exemplarily, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to complete the present invention. The one or more units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into a data export trigger unit, a thread number counting unit, a thread division unit, and a data export execution unit, and the specific functions of each unit are as described above.
[0126] The terminal device 7 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will appreciate that Figure 7 It is only an example of the terminal device 7 and does not constitute a limitation on the terminal device 7. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0127] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0128] The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used to store the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
[0129] In addition, each functional unit in each embodiment of the present invention 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.
[0130] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for exporting data, characterized in that: include: If the preset data export trigger condition is met, all data export tasks associated with the data export trigger condition are obtained; Counting the number of tasks of the data export task and detecting the number of threads in the local thread pool; Based on the number of tasks and the number of threads, the idle threads in the thread pool are divided into query threads and export threads; Calling the query thread to extract target data associated with each of the data export tasks from the database, and writing the target data into a preset task data document through the export thread; The calling of the query thread to extract target data associated with each of the data export tasks from the database, and writing the target data into a preset task data document through the export thread, comprises: Collecting the instantaneous maximum export amount of each of the export threads, and calculating the rated export data amount according to the instantaneous maximum export amount and the number of export threads of the export thread; Analyzing the task content of each of the data export tasks, and determining the expected data volume based on the task content; According to the rated export data volume and the expected data volume of each data export task, all the data export tasks are divided into at least one export task group; the sum of the expected data volumes of all the data export tasks in the export task group is less than or equal to the rated export data volume; The data export operation is performed on each of the export task groups respectively through the query thread and the export thread.
2. The method according to claim 1, characterized in that The performing of the data export operation on each of the export task groups through the query thread and the export thread respectively includes: Calling the query thread to extract the target data of all data export tasks in each of the export task groups from the database respectively; If it is detected that the target data of all the data export tasks in any of the export task groups is queried, a data export instruction is output; the data export instruction carries the group number of the export task group; If the data export instruction is received, the export thread is controlled to perform a data export operation on the target data of the data export task corresponding to the group number.
3. The method according to claim 1, characterized in that: The parsing the task content of each of the data export tasks and determining the expected data volume based on the task content includes: Extracting task keywords from the task content through a preset semantic parsing algorithm; Query the word frequency parameters of each of the task keywords in the database, and import the word frequency parameters into a preset expected data conversion model to calculate the expected data parameters of the word frequency parameters; the expected data conversion model is specifically: Among them, ξ Data is the expected data parameter; WF is the word frequency parameter; BF is the base word frequency; BaseData is the base data volume; The expected data volume is determined based on all the expected data parameters of the task content.
4. The method according to any one of claims 1 to 3, characterized in that: Before obtaining all data export tasks associated with the data export trigger condition if the preset data export trigger condition is met, the method further includes: Receiving a data export request sent by a user terminal; the data export request includes original data text; Extracting query keywords from the original text of the data; Identify the data type associated with each query keyword in the data table of the database, and establish an association relationship between the query keyword and the data type; A data export task for the data export request is output according to the association relationship.
5. A data export device, characterized in that: include: A data export trigger unit, configured to obtain all data export tasks associated with a preset data export trigger condition if the preset data export trigger condition is met; A thread number counting unit, used to count the number of tasks of the data export task and detect the number of threads in the local thread pool; A thread division unit, used for dividing the idle threads in the thread pool into query threads and export threads based on the number of tasks and the number of threads; A data export execution unit, used for calling the query thread to extract target data associated with each data export task from the database, and writing the target data into a preset task data document through the export thread; The data export execution unit comprises: A rated export data volume calculation unit, used for collecting the instantaneous maximum export volume of each of the export threads, and calculating the rated export data volume according to the instantaneous maximum export volume and the number of export threads of the export thread; an expected data volume calculation unit, used for parsing the task content of each of the data export tasks and determining the expected data volume based on the task content; An export task group division unit, used to divide all the data export tasks into at least one export task group according to the rated export data volume and the expected data volume of each data export task; the sum of the expected data volumes of all the data export tasks in the export task group is less than or equal to the rated export data volume; The group export execution unit is used to execute data export operations on each of the export task groups through the query thread and the export thread.
6. The device according to claim 5, characterized in that The grouping derivation execution unit comprises: A target data extraction unit, used for calling the query thread to extract the target data of all data export tasks in each of the export task groups from the database respectively; A data export instruction output unit, configured to output a data export instruction if it is detected that the target data of all the data export tasks in any of the export task groups is queried; the data export instruction carries the group number of the export task group; An export thread control unit is used to control the export thread to perform a data export operation on the target data of the data export task corresponding to the group number if the data export instruction is received.
7. A terminal device, characterized in that: The terminal device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the steps of the method according to any one of claims 1 to 4 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 steps of the method according to any one of claims 1 to 4 are implemented.
