A method and apparatus for non-blocking parallel computation of electronic spreadsheet formulas
The spreadsheet formula calculation method using a main thread and worker thread architecture solves the problem of serial blocking calculation, realizes non-blocking parallel calculation of formulas, dynamically responds to user operations, and improves calculation efficiency and interface update efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAN GRAPE CITY SOFTWARE CO LTD
- Filing Date
- 2026-06-04
- Publication Date
- 2026-07-03
Smart Images

Figure CN122332136A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of computer data processing and spreadsheet technology, and in particular to a non-blocking parallel computing method and apparatus for spreadsheet formulas. Background Technology
[0002] With the widespread use of spreadsheets in data statistics, financial accounting, and business analysis, spreadsheets often contain a large number of interdependent calculation formulas, leading to a continuous increase in the amount of formula data and computational complexity. However, traditional spreadsheet formula calculations often adopt a holistic execution mode, which can easily occupy the interface process during the calculation, preventing users from performing normal editing or modification operations while formulas are being calculated, thus greatly affecting the user experience.
[0003] Current spreadsheet formula calculation methods are mostly serial blocking calculations, which cannot achieve staged parallel processing. They cannot display calculation results and progress in real time, and it is difficult to detect and respond to user operations promptly. Furthermore, existing calculation schemes are mostly based on fixed initial settings, unable to dynamically adapt to real-time user operations, easily leading to invalid calculations and redundant calculation processes, resulting in low formula calculation efficiency and low operational responsiveness.
[0004] In the patent with publication number CN119129568A, the blocking problem is alleviated by segmenting the main thread for computation. However, the computation task is still executed in the same main thread as the user response task. It can only reduce the duration of a single blocking by segmenting the computation, but cannot fundamentally avoid the computation occupying the main thread. There is still a response delay in user operations, and true parallel computing cannot be achieved.
[0005] Therefore, how to achieve non-blocking parallel computation of spreadsheet formulas, fundamentally avoid the blocking of computation tasks on user responses, and ensure computation execution while responding to user operations in real time, dynamically adapting and adjusting the computation scheme, and synchronously displaying the computation status, is an urgent problem to be solved in this field. Summary of the Invention
[0006] In view of this, the present application provides a non-blocking parallel computing method and apparatus for spreadsheet formulas, which can realize non-blocking parallel computing of spreadsheet formulas, fundamentally avoiding the blocking of user response by the computing task, and responding to user operations in real time, dynamically adapting and adjusting the computing scheme, and synchronously displaying the computing status while ensuring the execution of the calculation. The non-blocking parallel computing method and apparatus for spreadsheet formulas provided in the present application are implemented as follows: This application provides a non-blocking parallel computing method for spreadsheet formulas, including: The main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation on the formula to be calculated, obtains the formula calculation data, and sends the formula calculation data and the corresponding calculation task to the worker thread through the message queue. The worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data to obtain an initial formula calculation scheme. The worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme, obtains the formula calculation result and the real-time calculation progress, and sends the formula calculation result and the real-time calculation progress to the main thread through a message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and the real-time calculation progress to obtain the real-time table display data. The main thread performs real-time detection and response processing on user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through the message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain the adapted and adjusted formula calculation scheme. The worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches the preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data.
[0007] In some embodiments, the worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme to obtain the formula calculation result and real-time calculation progress, and sends the formula calculation result and the real-time calculation progress to the main thread through a message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and the real-time calculation progress to obtain real-time table display data, including: The worker thread performs execution timing and calculation unit splitting on the initial formula calculation scheme to obtain multiple calculation stages ordered according to the formula calculation dependency relationship; The worker thread performs dependency validity checks and numerical calculations on the formula to be calculated corresponding to the calculation stage to obtain the formula calculation result of the current calculation stage. The worker thread updates the computational dependencies of the formula to be calculated that depend on the calculation results of the formula in the current calculation stage, and obtains the dependency adjustment data of the corresponding formula to be calculated. The worker thread performs statistical processing on the percentage of completed calculations of the formula to be calculated based on the formula calculation results of the current calculation stage and the dependency adjustment data of the corresponding formula to be calculated, and obtains the real-time calculation progress. The worker thread sends the formula calculation result of the current calculation stage and the real-time calculation progress to the main thread through a message queue. The main thread performs table interface rendering and update processing on the received formula calculation result and real-time calculation progress to obtain the real-time table display data.
[0008] In some embodiments, the main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation processing on the formula to obtain formula calculation data, including: The main thread performs syntax compliance checks and standardized decomposition on the formulas to be calculated in the obtained spreadsheet to obtain the basic data of the formulas; The main thread performs reference association identification and statistical processing on the basic data of the formula to obtain computational dependency data; The main thread performs a verification process on the formula to be calculated to obtain calculation execution adaptation data. The main thread performs structured integration processing on the computation dependency data and the computation execution adaptation data to obtain the formula calculation data.
[0009] In some embodiments, the worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data to obtain an initial formula calculation scheme, including: The worker thread sorts the computation dependency data in the formula calculation data by computation priority to obtain the execution timing data of the formula to be calculated; The worker thread performs unit splitting on the calculation task corresponding to the formula to be calculated based on the execution timing data to obtain the calculation execution unit; The worker thread performs execution scenario matching processing on the calculation execution unit and the calculation execution adaptation data in the formula calculation data to obtain the execution adaptation rules; The worker thread performs structured integration processing on the execution timing data, the computation execution unit, and the execution adaptation rules to obtain an initial formula calculation scheme.
[0010] In some embodiments, the main thread performs real-time detection and response processing on user operation events based on the table presentation state corresponding to the real-time displayed data, obtains operation response results, and sends the operation response results to the worker thread through a message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response results to obtain an adapted formula calculation scheme, including: The main thread performs real-time detection and type classification processing on the table presentation status corresponding to the real-time data displayed in the table to obtain categorized user operation data. The main thread performs compliance verification and corresponding response processing on the categorized user operation data to obtain the operation response results; The main thread sends the operation response result to the worker thread through a message queue. The worker thread calculates the impact range and identifies the adjustment requirements of the operation response result to obtain the formula calculation scheme adjustment parameters. The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the formula calculation scheme adjustment parameters to obtain the adapted and adjusted formula calculation scheme.
[0011] In some embodiments, the worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches a preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through a message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data, including: The worker thread performs a full verification of the calculation completion status of the formula to be calculated corresponding to the adapted and adjusted formula calculation scheme, and obtains full calculation completion data. The worker thread compares and verifies the full calculation completion data with the preset completion threshold to obtain the calculation completion status matching result. When the calculation completion status matching result reaches the preset completion threshold, the worker thread sends the calculation results of each stage formula corresponding to the formula to be calculated to the main thread through the message queue; The main thread performs consistency verification and integration on the received formula calculation results to obtain the target calculation result. It then performs full table interface rendering and display update processing on the target calculation result to obtain the table display data corresponding to the target calculation result.
[0012] In some embodiments, the phased computation process is executed by a worker thread, which executes computation tasks in batches according to a preset time slice. After each batch of computation is completed, the worker thread checks and processes the messages sent by the main thread.
[0013] This application provides a non-blocking parallel computing device for spreadsheet formulas, comprising: The acquisition module is used to acquire the formula to be calculated in the spreadsheet through the main thread, perform expression tree parsing, dependency parsing and adaptation processing on the formula to be calculated to obtain the formula calculation data, and send the formula calculation data and the corresponding calculation task to the worker thread through the message queue. The processing module is used to schedule and plan the calculation tasks corresponding to the formula to be calculated based on the formula calculation data through the worker thread, so as to obtain the initial formula calculation scheme. The update module is used to perform phased calculations on the formula to be calculated based on the initial formula calculation scheme through a worker thread, obtain the formula calculation result and the real-time calculation progress, and send the formula calculation result and the real-time calculation progress to the main thread through a message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and the real-time calculation progress to obtain the real-time table display data; The processing module is also used to detect and respond to user operation events in real time through the main thread based on the table presentation status corresponding to the real-time data displayed in the table, obtain operation response results, and send the operation response results to the worker thread through a message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response results to obtain the adapted and adjusted formula calculation scheme. The processing module is further configured to perform a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme through a worker thread, to obtain the calculation completion degree. When the calculation completion degree reaches a preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through a message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data.
[0014] The computer device provided in this application includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements the method described in this application.
[0015] The computer-readable storage medium provided in this application embodiment stores a computer program thereon, which, when executed by a processor, implements the method described in this application embodiment.
[0016] This application provides a non-blocking parallel computing method and apparatus for spreadsheet formulas. The main thread acquires the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation processing to obtain the formula calculation data, and sends it to the worker threads. The worker threads complete the calculation task scheduling and planning, generating an initial formula calculation scheme. The formula calculation is executed in stages according to the scheme, and the calculation results and real-time progress are sent to the main thread to update the interface. The main thread detects and responds to user operations in real time and synchronizes this to the worker threads, dynamically adjusting the calculation scheme. The calculation completion rate is verified, and once it reaches the target, all results are sent to the main thread for final display and update. This enables non-blocking parallel computing of spreadsheet formulas, fundamentally avoiding the blocking of user responses by calculation tasks. It ensures calculation execution while responding to user operations in real time, dynamically adapting and adjusting the calculation scheme, and synchronously displaying the calculation status, thus solving the technical problems mentioned in the background art. Compared with the patent with publication number CN119129568A, the core improvement of this application is as follows: In the previous patent, the calculation task and the user response task were still executed in the same main thread, and long-term blocking was avoided only by segmented calculation; This application introduces a dedicated worker thread to undertake the formula calculation task, realizing complete thread separation between the calculation task and the user response task. The main thread does not need to undertake the calculation task at all, but is only responsible for user operation response and interface rendering, realizing true parallel computing, fundamentally eliminating the blocking of the main thread by the calculation process, further reducing the response latency of user operation, and greatly improving the user experience in the scenario of large-scale formula calculation in spreadsheets. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A schematic diagram illustrating the implementation process of a non-blocking parallel computing method for spreadsheet formulas provided in this application embodiment; Figure 2 This application provides a schematic diagram of an implementation process for obtaining and displaying table data in real time. Figure 3 This is a schematic diagram of the structure of a non-blocking parallel computing device for spreadsheet formulas provided in an embodiment of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0020] The following description of some technologies involved in the embodiments of this application is provided to aid understanding and should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and brevity, some descriptions of well-known functions and structures are omitted in the following description.
[0021] In this embodiment, a dual-threaded architecture of main thread and worker thread is used to achieve non-blocking parallel computing. The two threads communicate bidirectionally through a message queue, and their responsibilities are divided as follows: The main thread is responsible for: responding to user operation events (such as cell editing, formula modification, etc.); drawing and updating the spreadsheet interface; displaying real-time calculation progress; receiving calculation results sent by worker threads and refreshing the interface; handling formula calculations that worker threads cannot complete (such as formulas involving UI operations); and parsing the expression tree and dependencies of the formulas to be calculated.
[0022] The worker thread is responsible for: receiving the expression tree, formula calculation data, and calculation tasks sent by the main thread; performing dependency analysis and numerical calculations of the formulas; executing calculations in batches according to preset time slices (200 milliseconds), and checking for new messages from the main thread after each batch is completed; sending the calculation results and real-time progress to the main thread; initiating remote calculation requests to the main thread for formulas that cannot be executed on the worker thread; and dynamically adjusting the calculation scheme and terminating invalid calculations based on user operation instructions sent by the main thread.
[0023] After each batch of calculations is completed, the worker thread actively checks and processes the messages of the main thread to ensure timely response to user operations. The entire process does not occupy the main thread's resources, thus fundamentally achieving non-blocking computation.
[0024] Figure 1 This is a schematic diagram illustrating the implementation flow of a non-blocking parallel computing method for spreadsheet formulas provided in an embodiment of this application, including steps 101 to 105. Wherein, Figure 1 This is merely one execution order shown in the embodiments of this application and does not represent the only execution order of a non-blocking parallel computing method for spreadsheet formulas. Where the final result can be achieved, Figure 1 The steps shown can be performed in parallel or in reverse order.
[0025] Step 101: The main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation processing on the formula to obtain the formula calculation data, and sends the formula calculation data and the corresponding calculation task to the worker thread through the message queue.
[0026] In this embodiment, the main thread first obtains all formulas to be calculated, either edited by the user or imported by the system. This covers all cell formulas in the spreadsheet that require calculation, including all types such as single-cell independent formulas and multi-cell related formulas. Then, the main thread processes each formula individually: First, it performs formula syntax compliance checks to eliminate syntax errors, missing operators, invalid cell references, etc. Formulas that pass the checks are then standardized and decomposed to generate corresponding expression trees, obtaining basic formula data. Next, based on this basic formula data, it focuses on identifying other cell formulas referenced in each formula, clarifying the pre-dependencies (the result data generated by other formulas required for the formula's calculation) and post-dependent dependencies (other formulas that depend on the calculation result of this formula). The pre-dependencies and post-dependent dependencies of all formulas are statistically analyzed and recorded for each formula. The formula's dependency sources and associated destinations form clear computational dependency data. Then, the adaptability of the computation execution entity for all formulas to be calculated is verified, distinguishing between pure numerical calculation formulas that can be executed on worker threads and formulas involving UI operations and system interactions that require execution on the main thread, thus obtaining computation execution adaptation data. Finally, the parsed computational dependency data and the computation execution adaptation data obtained after adaptation verification are structurally integrated to establish a unique data association record for each formula to be calculated, forming complete formula computation data. The main thread sends the formula computation data and the corresponding full computation task to the worker threads via a message queue.
[0027] Step 102: The worker thread performs scheduling and planning processing on the calculation tasks corresponding to the formula to be calculated based on the formula calculation data, and obtains the initial formula calculation scheme.
[0028] In this embodiment, after receiving the formula calculation data and calculation tasks sent by the main thread, the worker thread performs overall scheduling planning for the calculation tasks corresponding to all formulas to be calculated, based on the formula calculation data and the dependencies and calculation priorities of the formulas. Specifically, the worker thread first counts the number of references for each formula to be calculated, and performs topological sorting based on the number of references. Formulas with a reference count of 0 are prioritized as having the highest execution priority. Then, calculation tasks that depend on the results of the planned formulas are planned in sequence. After completing the priority sorting of each formula, the reference count of the associated formulas is updated synchronously, ultimately forming the execution time sequence data of all formulas to be calculated. Based on the execution time sequence data, the calculation tasks corresponding to all formulas to be calculated are divided into non-blocking and interruptible units, dividing formulas to be calculated within the same execution batch that have no mutual dependencies into independent calculation executions. The unit is a computational execution unit where formulas can be executed in parallel. The splitting process balances parallel computing efficiency with the rational allocation of computing resources, avoiding computational congestion caused by an excessive number of formulas in a single computational execution unit. Subsequently, for each computational execution unit, computational execution adaptation data is matched with the formula calculation data to formulate exclusive execution adaptation rules for each computational execution unit, including the number of parallel executions, the proportion of computing resources allocated, and the execution time limit. Finally, the execution time sequence data, computational execution units, and execution adaptation rules are structurally integrated to form a complete initial formula calculation scheme, providing an execution basis for subsequent phased parallel computing.
[0029] Step 103: The worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme, obtains the formula calculation result and real-time calculation progress, and sends the formula calculation result and real-time calculation progress to the main thread through the message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and real-time calculation progress to obtain the real-time display data of the table.
[0030] In this embodiment, the worker thread, following the execution sequence planned in the initial formula calculation scheme and incorporating a preset time slice of 200 milliseconds, divides the initial formula calculation scheme into multiple consecutive calculation stages, each with an execution duration not exceeding 200 milliseconds. The worker thread executes the parallel calculation of the formula to be calculated stage by stage. Upon entering the current calculation stage, it first performs dependency validity checks on all formulas to be calculated within that stage, confirming whether the required prerequisite dependency data for each formula is complete and whether it represents a valid calculation result from a previous calculation stage, excluding cases of missing dependencies or invalid dependency data. After passing the checks, it performs parallel numerical calculations on the formulas to be calculated within that stage, calculating the numerical result of each formula one by one according to the calculation rules of spreadsheet formulas, and summing the results to obtain the formula calculation result for the current calculation stage.
[0031] After the current calculation phase is completed, the worker thread identifies all subsequent formulas in the entire set of formulas to be calculated that depend on the calculation results of the formulas in the current phase. It updates the calculation dependencies of these subsequent formulas one by one, marking that their required prerequisites have been calculated and their dependency data has been updated to the valid calculation results of the current phase. It records the dependency update status of each subsequent formula and integrates this information to form the dependency adjustment data for the corresponding formula to be calculated. Simultaneously, the worker thread combines the formula calculation results of the current calculation phase with the dependency adjustment data to calculate the total number of formulas in the entire set of formulas to be calculated that have completed calculations. It divides the total number of completed calculations by the total number of formulas in the entire set of formulas to be calculated to obtain the percentage of formulas that have completed calculations, i.e., the real-time calculation progress. Each time the worker thread completes a formula calculation for a preset number of iterations matching a preset time slice, it synchronously updates the real-time calculation progress to ensure the real-time nature of the progress update.
[0032] Subsequently, the worker thread sends the formula calculation result and real-time calculation progress of the current calculation stage to the main thread via a message queue. Upon receiving the data, the main thread renders the formula calculation result according to the corresponding cell position, ensuring the result is accurately displayed in the corresponding cell. Simultaneously, it renders and displays the real-time calculation progress as a progress bar and tooltip text in the designated area of the spreadsheet interface. After completing the display update process, a real-time table display containing the current calculation result and progress information is generated. After each calculation stage is completed, the worker thread proactively checks the messages sent by the main thread in the message queue, prioritizing user-operated commands before executing the next calculation stage, ensuring timely responses to user actions.
[0033] Step 104: The main thread performs real-time detection and response processing on user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through the message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result, and obtains the adapted and adjusted formula calculation scheme.
[0034] In this embodiment, the main thread runs entirely within the table interface. Based on the real-time display of data in the table, the thread monitors user actions on the table interface in real time using an operation detection module. Detected user operation events include cell editing, formula modification, calculation task pause / resume, calculation progress query, formula deletion / addition, etc. The main thread categorizes each detected user operation event according to its nature and scope of impact. For example, cell editing and formula modification are categorized as calculation-impact operations, calculation pause / resume as calculation control operations, and progress query as query operations. The categorized operation details are then summarized to form categorized user operation data.
[0035] The main thread then performs compliance checks on each user operation data category. The core of the check is to determine whether the user operation conforms to the execution logic of the current formula calculation and whether it will lead to data conflicts or calculation errors. For example, it checks whether the user-modified formula has syntax errors, whether the edited cell is a locked cell that has already completed calculation, and whether pausing calculations conforms to thread execution specifications. For compliant operations that pass the check, the specific content of the operation, the timing of execution, and the scope of impact are recorded, and a permission response instruction is generated. For non-compliant operations that fail the check, the reason for the operation's abnormality is recorded, a refusal response instruction is generated, and the user is informed of the specific circumstances of the non-compliance. All user operation check results and response instructions are summarized to form a complete operation response result.
[0036] The main thread sends operation response results to worker threads in real time via a message queue. Upon receiving the messages, the worker threads analyze the impact of each allowed user operation on the current formula calculation process, identifying which calculation stages, execution units, and formulas are involved. Based on the impact scope, they also identify adjustment requirements for the initial formula calculation scheme. For example, if a user modifies a formula, the corresponding calculation dependencies, execution sequence, and execution units need to be readjusted; if a user pauses calculation, the execution status of the execution units needs adjustment; if a user adds or deletes a formula, the corresponding execution units need to be added or removed, and the overall execution sequence adjusted; if a user modifies a formula that has already been calculated, subsequent invalid calculation tasks dependent on that formula's result are terminated. Based on the identified adjustment requirements, the worker threads determine the specific adjustment content, methods, and parameters, forming formula calculation scheme adjustment parameters. They then dynamically adapt and adjust the initial formula calculation scheme according to these parameters. After adjustment, the scheme undergoes logical consistency verification to ensure that the adjusted scheme has no dependency conflicts or execution logic contradictions, ultimately forming the adapted formula calculation scheme.
[0037] Step 105: The worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion rate. When the calculation completion rate reaches the preset completion threshold, the full formula calculation results are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formula to be calculated to obtain the target calculation result and the corresponding table display data.
[0038] In this embodiment, the worker thread continues to execute subsequent calculation stages according to the adapted and adjusted formula calculation scheme, while periodically performing a full verification of the calculation completion status of all formulas to be calculated. During the verification process, a complete list of all formulas to be calculated under the adapted and adjusted scheme is first defined, including the original formulas before adjustment, formulas added after user operations, and formulas recalculated after modification, ensuring no formulas are omitted. Then, the calculation completion status of each formula in the list is verified, confirming whether each formula has completed all numerical calculations, whether the calculation result is valid, and whether it meets the calculation requirements of the adapted and adjusted scheme. Finally, the number of formulas that have completed calculations is counted, and the calculation completion rate is obtained by dividing the number of completed formulas by the total number of formulas to be calculated.
[0039] A preset completion threshold for formula calculation is set at 100% completion of all valid calculations for all formulas to be calculated. Worker threads compare their calculated completion rates with this preset threshold to determine if the completion rate meets the requirement, generating a completion status matching result. If the matching result indicates that the preset completion threshold has not been reached, the worker thread continues execution of subsequent calculation stages according to the adapted formula calculation scheme until the completion rate is met. If the matching result indicates that the preset completion threshold has been reached, the worker thread aggregates all formula calculation results from all calculation stages and sends them to the main thread via a message queue.
[0040] After receiving all the formula calculation results, the main thread performs consistency checks, checking for conflicts between different formulas and mismatches in dependency results to ensure all calculation results are accurate and logically consistent. After integrating the results, the target calculation result is obtained. Subsequently, following the spreadsheet's interface display rules, the main thread performs full interface rendering of the target calculation results, accurately mapping the final calculation result of each formula to the corresponding cell in the spreadsheet, optimizing the result display format, and updating the overall spreadsheet interface to ensure users can intuitively see the final calculation results of all formulas without any data delays or display errors. After the update, all displayed data in the spreadsheet interface is integrated to form a table display data corresponding to the target calculation result, completing the entire non-blocking parallel calculation process of the spreadsheet formulas.
[0041] In this embodiment, a remote computation interaction process between the worker thread and the main thread is also included: during the computation process, if the worker thread identifies a formula that cannot be executed on the worker thread (such as a formula involving UI operations or system permission calls), it will generate a remote computation request and send it to the main thread through a message queue; the main thread receives and processes the remote computation request, completes the calculation of the corresponding formula, and returns the calculation result to the worker thread through a message queue; based on the calculation result returned by the main thread, the worker thread continues to execute subsequent computation tasks to ensure that all formulas can be calculated normally, while not disrupting the division of responsibilities between the two threads.
[0042] This application's embodiments fundamentally solve the blocking problem in spreadsheet formula calculations by employing a dual-thread architecture based on a main thread and worker threads. Through complete thread separation of calculation tasks and user response tasks, the worker threads independently handle all numerical calculations, while the main thread focuses entirely on user operation responses and interface rendering. This achieves true parallelism between calculation and operation, allowing users to edit and modify data at any time during the calculation process without waiting for completion. Simultaneously, a phased calculation and real-time progress feedback mechanism is employed to visualize the calculation status and display progressive results. It supports dynamically adjusting the calculation scheme based on user operations, promptly terminating invalid calculations, and improving resource utilization. Finally, full verification and consistency checks ensure accurate results while maintaining compatibility with various special formulas and exhibiting good scalability.
[0043] In the above Figure 1 Based on the method flow shown, this application embodiment also provides a schematic diagram of the implementation flow for obtaining real-time display data of a table. For example... Figure 2 As shown, steps 201 to 205 are included: Step 201: The worker thread performs execution timing and calculation unit splitting on the initial formula calculation scheme to obtain multiple calculation stages sorted according to the formula calculation dependency relationship.
[0044] In this embodiment, the worker thread, based on the initial formula calculation scheme and considering the formula dependencies in the formula calculation data, performs a phased breakdown of the initial formula calculation scheme. The breakdown process strictly adheres to the principle of no cross-stage dependencies, prioritizing formulas without any prior dependencies as the first calculation stage, then formulas dependent only on the results of the first calculation stage as the second calculation stage, and so on, progressively breaking down the scheme into multiple consecutive calculation stages. Simultaneously, the worker thread finely breaks down the calculation stages according to a preset time slice of 200 milliseconds, ensuring that the execution time of each calculation stage does not exceed this preset time slice. Formulas within each calculation stage have no mutual dependencies, can be executed in parallel, and depend only on the formula results of the preceding calculation stage, ensuring the orderliness and parallelism of the phased calculations. After each calculation stage is completed, the worker thread actively checks the messages sent by the main thread in the message queue, prioritizing user operation-related instructions before executing the next calculation stage.
[0045] Step 202: The worker thread performs dependency validity verification and numerical calculation on the formula to be calculated corresponding to the calculation stage to obtain the formula calculation result of the current calculation stage.
[0046] In this embodiment, after entering the current calculation stage, the worker thread first performs dependency validity checks on all formulas to be calculated in the stage, confirming one by one whether the prerequisite dependency data required by each formula is complete and whether it is a valid calculation result of the previous calculation stage, excluding cases of missing dependencies or invalid dependency data; after the verification is passed, the worker thread performs parallel numerical calculations on the formulas to be calculated in the stage, calculating the numerical result of each formula one by one according to the calculation rules of spreadsheet formulas, ensuring that the calculation process conforms to the formula syntax specification and calculation logic, and after the calculation is completed, the calculation results of all formulas in the stage are summarized to obtain the formula calculation result of the current calculation stage.
[0047] Step 203: The worker thread updates the computational dependencies of the formula to be calculated that depend on the calculation results of the formula in the current calculation stage, and obtains the dependency adjustment data of the corresponding formula to be calculated.
[0048] In this embodiment, after the numerical calculation is completed in the current calculation stage, the worker thread identifies all subsequent formulas in the full set of formulas to be calculated that depend on the calculation results of the formulas in the current stage, updates the calculation dependencies of these subsequent formulas one by one, and marks that the required prerequisites have been calculated and the dependent data has been updated to the valid calculation results of the current stage. At the same time, it records the dependency update status of each subsequent formula, including the updated dependent formula, the status of the dependent data, the number of remaining uncompleted dependencies, etc., and integrates them to form the dependency adjustment data of the corresponding formula to be calculated, providing an accurate dependency basis for the execution and execution priority adjustment of the subsequent calculation stages.
[0049] Step 204: Based on the formula calculation results of the current calculation stage and the dependency adjustment data of the corresponding formula to be calculated, the worker thread performs statistical processing on the percentage of completed calculations of the formula to be calculated, and obtains the real-time calculation progress.
[0050] In this embodiment, the worker thread combines the formula calculation results of the current calculation stage to count the number of formulas to be calculated that have been completed in the current stage; then, based on dependency adjustment data, it confirms the dependency preparation status of subsequent formulas to be calculated, and simultaneously counts the total number of formulas to be calculated that have been calculated; the total number of completed calculations is divided by the total number of formulas to be calculated to obtain the percentage of formulas to be calculated that have been calculated, which is the real-time calculation progress at the current moment. Every time the worker thread completes a formula calculation for a preset number of iterations matching a preset time slice, it simultaneously updates the real-time calculation progress to ensure that the calculation progress can truly and in real-time reflect the overall progress of formula calculation.
[0051] Step 205: The worker thread sends the formula calculation results and real-time calculation progress of the current calculation stage to the main thread through the message queue. The main thread performs table interface rendering and update processing on the received formula calculation results and real-time calculation progress to obtain the real-time table display data.
[0052] In this embodiment, after receiving the formula calculation results and real-time calculation progress of the current calculation stage from the worker thread, the main thread renders the formula calculation results according to the corresponding spreadsheet cell position for each formula, ensuring that the calculation results are displayed accurately and in real time in the corresponding cells. At the same time, the real-time calculation progress is rendered in an intuitive form such as a progress bar and prompt text, and displayed in a designated area of the spreadsheet interface, so that users can easily view the calculation progress in real time. After the rendering update is completed, the main thread integrates the current cell display data and the progress display data to form the real-time display data of the table, providing a basis for the current table presentation status for the detection and response to subsequent user operation events.
[0053] This application embodiment separates the threads of formula calculation and interface rendering, and the phased calculation process does not occupy the main thread resources. At the same time, the interface display is updated synchronously after each calculation stage is completed. This not only ensures the orderly execution of parallel computing, but also realizes real-time visualization of the calculation status. In addition, a response window for user operation is reserved, which fundamentally realizes the core effect of non-blocking computing.
[0054] In some embodiments, the main thread obtains the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution and adaptation processing on the formula to be calculated, and obtains the formula calculation data, including: the main thread performs syntax compliance verification and standardized decomposition processing on the formula to be calculated from the obtained spreadsheet to obtain the basic formula data.
[0055] Specifically, the main thread retrieves all formulas within the table that require calculation, covering all types, including formulas within a single cell and formulas linked across multiple cells. Each formula then undergoes dual processing: firstly, formula validation checks the syntax of each formula, eliminating syntax errors, missing operators, invalid cell references, and other issues to ensure the formula is computationally valid; secondly, formula decomposition breaks down each formula into its basic components, such as operators, cell reference identifiers, constant data, and function components, generating a standardized expression tree to clarify the relationships and functions of each component. After validation and decomposition, the validation results and the decomposed basic components are summarized to form basic formula data, providing a foundation for subsequent dependency parsing and adaptation.
[0056] Furthermore, the main thread performs reference association identification and statistical processing on the basic formula data to obtain computational dependency data.
[0057] Specifically, the main thread identifies and statistically processes the basic formula data to obtain computational dependencies. Based on the basic formula data obtained in the first step, it focuses on identifying other cell formulas referenced by each formula, clarifying the pre-dependencies of each formula, i.e., the result data generated by other formulas required for the formula's calculation, and identifying the post-dependencies of each formula, i.e., other formulas that depend on the calculation result of this formula. Subsequently, the pre-dependencies and post-dependencies of all formulas are statistically analyzed, recording the dependency source and association destination of each formula, forming a clear computational dependency relationship, clarifying which formulas can be calculated independently and which formulas need to rely on other formulas to complete the calculation, providing a core basis for the scheduling and planning of subsequent calculation tasks.
[0058] Furthermore, the main thread performs validation on the formula to be calculated to obtain the data suitable for calculation execution.
[0059] Specifically, the main thread performs compatibility checks on the formulas to be calculated, obtaining computation execution adaptation data. For all formulas to be calculated, compatibility checks are conducted considering the spreadsheet's computational environment and the execution capabilities of the parallel computing engine. The checks include: whether the formula's computational complexity is compatible with the current computing engine's processing capabilities; whether the function components in the formula support parallel computation; whether the data format referenced by the formula is compatible with the computational environment; whether data conflicts will occur when multiple formulas are computed in parallel; and whether the formula involves UI operations and requires execution by the main thread. For formulas that pass the checks and can be executed by worker threads, their conditions for parallel execution and adaptation parameters are recorded. For formulas with compatibility issues or those requiring execution by the main thread, adjustment suggestions and adaptation requirements are recorded. All check results and adaptation parameters are summarized to form computation execution adaptation data, ensuring that subsequent computation tasks can be executed stably and efficiently in the current environment.
[0060] Furthermore, the main thread performs structured integration processing on the computation dependency data and computation execution adaptation data to obtain the formula calculation data.
[0061] Specifically, the main thread integrates computational dependencies and computational execution adaptation data to obtain formula calculation data. This data is structured and integrated, creating a dedicated data association record for each formula to be calculated. Each formula corresponds to one record, containing its computational dependencies (prerequisite dependencies, postrequisite associations) and computational execution adaptation data (adaptation conditions, execution parameters, execution subject). During integration, the consistency between dependencies and adaptation data is ensured to avoid data conflicts and omissions, ultimately forming complete formula calculation data. This data can be directly sent to worker threads via a message queue for scheduling and planning computational tasks, providing comprehensive and accurate data support for generating the initial formula calculation scheme.
[0062] This application embodiment, through verification and decomposition of the formula to be calculated, dependency identification and statistics, adaptability verification and data integration, can ensure that the formula to be calculated is legal and valid, the dependencies between formulas are clear, and the calculation execution is compatible with the operating environment. This provides an accurate and complete data foundation for subsequent calculation task scheduling and parallel execution, and improves the stability of the overall calculation process.
[0063] In some embodiments, the worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data to obtain an initial formula calculation scheme, including: the worker thread sorts the calculation dependency data in the formula calculation data by calculation priority to obtain the execution timing data of the formula to be calculated.
[0064] Specifically, worker threads, based on formula calculation data, focus on extracting computational dependencies. Following the principles of prioritizing formulas with no dependencies and proceeding sequentially, they sort all formulas to be calculated. The worker threads count the number of references for each formula and use this count as the core criterion for topological sorting. Formulas with zero references are prioritized and placed in the first batch for execution. Formulas that depend solely on the results of the first batch are then selected for the second batch, and so on. This process is repeated batch by batch according to the dependency hierarchy. After each formula is calculated, the number of references to other formulas that reference it is decremented by 1, and the execution priority of the corresponding formulas is updated accordingly. This clarifies the execution order of each batch of formulas, ultimately forming a complete execution sequence. This ensures that subsequent calculation tasks are executed sequentially, avoiding calculation errors caused by chaotic dependencies.
[0065] Furthermore, the worker thread performs unit splitting on the computation task corresponding to the formula to be calculated based on the execution time sequence data, and obtains the computation execution unit.
[0066] Specifically, worker threads split the computational tasks corresponding to all formulas to be calculated based on their execution sequence. The core of this splitting is to group the formulas within the same execution batch according to computational complexity and data interrelationships, forming multiple independent computational execution units. The formulas within each computational execution unit are independent of each other and can be executed in parallel within the same time period. Different computational execution units proceed sequentially according to their execution sequence. During the splitting process, both parallel computing efficiency and the rational allocation of computing resources are considered to avoid computational congestion caused by an excessive number of formulas within a single computational execution unit, ensuring that each computational execution unit can efficiently complete its computational tasks.
[0067] Furthermore, the worker thread performs execution scenario matching processing on the calculation execution unit and the calculation execution adaptation data in the formula calculation data to obtain the execution adaptation rules.
[0068] Specifically, worker threads match the execution scenario and adaptation requirements of each computational execution unit one by one, based on the computational execution adaptation data in the formula calculation data. Specifically, for each computational execution unit, adaptation parameters for all formulas to be calculated within the unit are extracted, including computational complexity, function support, and data format requirements. These parameters are then combined with the spreadsheet's computational runtime environment and the processing power of the parallel computing engine to formulate unique execution adaptation rules for each computational execution unit. These adaptation rules include the number of parallel executions for the unit, the allocation ratio of computational resources, execution time limits, and data interaction methods, ensuring that each computational execution unit can execute stably and efficiently in parallel within the current runtime environment, avoiding computational blocking or adaptation conflicts.
[0069] Furthermore, the worker thread performs structured integration processing on the execution timing data, computation execution units, and execution adaptation rules to obtain the initial formula calculation scheme.
[0070] Specifically, the worker threads structurally integrate the execution sequence, computational execution units, and execution adaptation rules to form a complete initial formula calculation scheme. This clearly records the batch to which each computational execution unit belongs, its execution order, the list of formulas to be calculated within each unit, and the execution adaptation rules for each unit. During the integration process, consistency between the execution sequence, computational execution units, and execution adaptation rules is ensured to avoid data conflicts or logical contradictions. The resulting initial formula calculation scheme can be directly used for the phased parallel computation of the formulas to be calculated, providing a clear and unambiguous execution basis for subsequent calculations.
[0071] This application embodiment sorts the formula calculation data to form an execution sequence, splits the calculation execution units, matches the execution scenarios and generates adaptation rules, and finally integrates them to obtain an initial formula calculation scheme. This makes the calculation tasks reasonably divided, the execution order clear, and the resource utilization efficient, further improving the execution efficiency and orderliness of parallel formula calculation.
[0072] In some embodiments, the main thread performs real-time detection and response processing on user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through a message queue; the worker thread performs dynamic adaptation and adjustment processing on the initial formula calculation scheme based on the operation response result, and obtains the adapted and adjusted formula calculation scheme, including: the main thread performs real-time detection and type classification processing on the table presentation status corresponding to the real-time data displayed in the table, and obtains classified user operation data.
[0073] Specifically, after updating the real-time data display in the spreadsheet, the process enters a phased calculation interval. During this interval, the main thread uses the spreadsheet's display state as a baseline and the spreadsheet's operation detection module to monitor user actions on the spreadsheet interface in real time. The detected user operation events cover various types, including but not limited to cell editing, formula modification, pausing or resuming calculations, querying calculation progress, and formula deletion or addition. Each detected user operation event is categorized according to its nature and scope of impact. For example, cell editing and formula modification are classified as calculation-impact operations, pausing or resuming calculations as calculation control operations, and progress queries as query operations. The categorized operation details are then summarized to form categorized user operation data, providing clear operational guidelines for subsequent verification and response.
[0074] Furthermore, the main thread performs compliance checks and corresponding response processing on the categorized user operation data to obtain the operation response results.
[0075] Specifically, the main thread performs compliance checks on each user operation based on categorized user operation data. The core of the check is to determine whether the user operation conforms to the execution logic of the current formula calculation and whether it will lead to calculation data conflicts or errors. For example, it checks whether the formula modified by the user has syntax errors, whether the edited cell is a formula cell that has not been completed in the current calculation stage, and whether the operation of pausing the calculation is initiated during the execution interval of the current calculation stage. For compliant operations that pass the check, the specific content of the operation, the execution time and the scope of impact are recorded, and an execution-allowed response instruction is generated. For non-compliant operations that fail the check, the reason for the operation exception is recorded, and a rejection response instruction is generated, while also indicating to the user the specific circumstances of the non-compliance. The check results and response instructions of all user operations are summarized to form a complete operation response result, clarifying which user operations are executable, which are not, and the specific execution requirements of executable operations.
[0076] Furthermore, the main thread sends the operation response result to the worker thread through the message queue. The worker thread calculates the impact range and identifies the adjustment requirements of the operation response result to obtain the formula calculation scheme adjustment parameters.
[0077] Specifically, worker threads receive operation response results from the main thread via a message queue. For each user operation permitted in the response, the impact on the current formula calculation process is analyzed, clarifying which calculation stages, execution units, and formulas to be calculated are involved. Simultaneously, based on the impact scope, adjustment requirements for the initial formula calculation scheme are identified. For example, if a user modifies a formula to be calculated, the corresponding calculation dependencies, execution sequence, and execution units need to be adjusted; if a user pauses calculation and then resumes, the execution status of the execution units and subsequent execution sequence need to be adjusted; if a user adds a formula to be calculated, a new execution unit needs to be added and the overall execution sequence adjusted; if a user deletes or modifies a calculated formula, subsequent invalid calculation tasks dependent on that formula's result are terminated. Based on the identified adjustment requirements, specific adjustment content, methods, and parameters are determined, such as the order of execution sequence adjustments, the splitting or merging of execution units, and modifications to execution adaptation rules. These are summarized to form formula calculation scheme adjustment parameters, providing a clear basis for subsequent adjustments to the initial formula calculation scheme.
[0078] Furthermore, the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the formula calculation scheme parameters to obtain the adapted formula calculation scheme.
[0079] Specifically, the worker threads, based on the initial formula calculation scheme, adjust parameters according to the scheme, dynamically adapting and adjusting the scheme one by one. During the adjustment process, the dependencies between formula calculations and the parallel computing logic are strictly followed to ensure that the adjusted scheme does not have dependency conflicts or execution chaos. Specifically, if the adjusted parameters involve the execution timing, the execution order of the calculation units is reordered; if they involve calculation units, the corresponding calculation units are split or merged, and the list of formulas to be calculated within the unit is updated; if they involve execution adaptation rules, the parallel execution parameters and resource allocation ratios of the corresponding calculation units are modified. After the adjustment is completed, the adjusted scheme is logically consistent to confirm that the execution timing, calculation units, and execution adaptation rules in the scheme match each other and are consistent. Finally, the adapted and adjusted formula calculation scheme is formed, which can be directly used for the completion status verification of the formula to be calculated and subsequent calculation execution, ensuring that the calculation process can adapt to the user's real-time operation and achieve the core effect of non-blocking parallel computing.
[0080] This application embodiment detects, classifies, verifies compliance, and identifies the impact of user operations in real time, and dynamically adjusts the formula calculation scheme accordingly. It can respond to user operations in a timely manner during the calculation process, avoid calculation blockage and process conflict, realize parallel processing of calculation execution and user operations, and enhance the core effect of non-blocking computing.
[0081] In some embodiments, the worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches a preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through a message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data, including: the worker thread performs a full verification of the calculation completion status of the formulas to be calculated corresponding to the adapted and adjusted formula calculation scheme to obtain full calculation completion degree data.
[0082] Specifically, the worker thread, based on the adapted and adjusted formula calculation scheme, clearly defines a complete list of all formulas to be calculated under the scheme, including the original formulas before adjustment, formulas added after user operations, and formulas recalculated after modification, ensuring no formulas are omitted. Then, the completion status of each formula in the list is verified, confirming whether each formula has completed all numerical calculations, whether the calculation result is valid, and whether it meets the calculation requirements of the adapted and adjusted scheme. The number of formulas that have completed calculations is counted, and the completion rate of each formula is obtained by dividing the number of completed formulas by the total number of formulas to be calculated. This completion rate directly reflects the overall completion status of formula calculations and provides a core basis for subsequent decisions on whether to terminate the calculation.
[0083] Furthermore, the worker thread compares and verifies the calculation completion status with the preset completion threshold to obtain the calculation completion status matching result. When the calculation completion status matching result reaches the preset completion threshold, the worker thread sends the calculation results corresponding to all the formulas to be calculated to the main thread. The main thread integrates and processes the received calculation results to obtain the target calculation result.
[0084] Specifically, a preset completion threshold for formula calculation is established. This threshold represents the standard for all formulas to be calculated to complete valid calculations (i.e., a completion rate of 100%), ensuring that all formulas are calculated and the results are valid. Worker threads compare the completion rate with the preset threshold to determine if the completion rate meets the threshold requirement, generating a completion status matching result. If the matching result indicates that the preset threshold has not been met, the worker threads continue executing subsequent calculation stages according to the adapted formula calculation scheme until the completion rate meets the standard. If the matching result indicates that the preset threshold has been met, the calculation result integration process is initiated. The worker threads summarize the calculation results of all formulas obtained from all calculation stages and send them to the main thread via a message queue. The main thread performs consistency checks on the summarized results, investigating conflicts in calculation results between different formulas, errors in matching results corresponding to dependencies, etc., ensuring that all calculation results are accurate and logically consistent. After integration, the target calculation result is obtained, which is the final set of calculation results for all formulas to be calculated.
[0085] Furthermore, the main thread performs UI rendering and display updates on the target calculation results to obtain table display data corresponding to the target calculation results.
[0086] Specifically, based on the target calculation result, the main thread renders the final calculation result of each formula according to the spreadsheet's interface display rules. It accurately maps the target calculation result of each formula to the corresponding cell in the spreadsheet, ensuring that the displayed result is completely consistent with the target calculation result. Simultaneously, it optimizes the result display format to conform to standard spreadsheet display specifications, facilitating user viewing and use. After rendering, the entire spreadsheet interface is updated, synchronously updating the display content of all cells to ensure users can intuitively see the final calculation results of all formulas without any data delays or display errors. After the update, all display data in the spreadsheet interface is integrated to form the table display data corresponding to the target calculation result, completing the entire non-blocking parallel calculation process of spreadsheet formulas and providing users with a complete and accurate display of formula calculation results.
[0087] This application embodiment can accurately determine whether the calculation is fully completed by verifying the completion status, comparing the completion degree with a preset threshold, integrating the results after completion, and rendering and displaying them. This ensures that the final calculation results are complete, accurate, and displayed in a standardized manner, and ensures that the entire non-blocking parallel computing process is reliable and the output results are trustworthy.
[0088] While this application provides the method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-inventive labor. The order of steps listed in this embodiment is merely one possible execution order among many and does not represent the only execution order. In actual device or client product execution, the methods shown in this embodiment or the accompanying drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment).
[0089] like Figure 3 As shown in the illustration, this application also provides a non-blocking parallel computing device 300 for spreadsheet formulas. The device includes: The acquisition module 301 is used to acquire the formula to be calculated in the spreadsheet through the main thread, perform expression tree parsing, dependency parsing and adaptation processing on the formula to be calculated, obtain the formula calculation data, and send the formula calculation data and the corresponding calculation task to the worker thread through the message queue.
[0090] The processing module 302 is used to schedule and plan the calculation tasks corresponding to the formula to be calculated based on the formula calculation data through the worker thread, so as to obtain the initial formula calculation scheme.
[0091] The update module 303 is used to perform phased calculations on the formula to be calculated based on the initial formula calculation scheme through the worker thread, obtain the formula calculation result and real-time calculation progress, and send the formula calculation result and real-time calculation progress to the main thread through the message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and real-time calculation progress to obtain the real-time table display data.
[0092] The processing module 302 is also used to detect and respond to user operation events in real time through the main thread based on the table presentation status corresponding to the real-time data displayed in the table, obtain the operation response result, and send the operation response result to the worker thread through the message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain the adapted and adjusted formula calculation scheme.
[0093] The processing module 302 is also used to perform full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme through the worker thread, so as to obtain the calculation completion degree. When the calculation completion degree reaches the preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data.
[0094] Some modules in the apparatus described in this application can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0095] The apparatus or module described in the above embodiments can be implemented by a computer chip or physical entity, or by a product with a certain function. For ease of description, the above apparatus is described by dividing it into various modules according to their functions. When implementing the embodiments of this application, the functions of each module can be implemented in one or more software and / or hardware. Of course, a module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.
[0096] The methods, apparatus, or modules described in this application can be implemented in a computer-readable program code manner. The controller can be implemented in any suitable manner, such as a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of a memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code manner, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included within it for implementing various functions can also be considered as structures within the hardware component. Alternatively, the device used to implement various functions can be viewed as either a software module that implements the method or a structure within a hardware component.
[0097] This application also provides an apparatus, the apparatus comprising: a processor; a memory for storing processor-executable instructions; wherein, when the processor executes the executable instructions, it implements the method described in this application.
[0098] This application also provides a non-volatile computer-readable storage medium storing a computer program or instructions thereon, which, when executed, enables the method described in this application embodiment to be implemented.
[0099] Furthermore, in the various embodiments of the present invention, each functional module can be integrated into a processing module, or each module can exist independently, or two or more modules can be integrated into a single module.
[0100] The aforementioned storage media include, but are not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), Cache, Hard Disk Drive (HDD), or Memory Card. The memory can be used to store computer program instructions.
[0101] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, or it can be embodied in the process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, mobile terminal, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0102] The various embodiments described in this specification are presented in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. All or part of this application can be used in numerous general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, mobile communication terminals, multiprocessor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices, etc.
[0103] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of this application.
Claims
1. A non-blocking parallel computation method for spreadsheet formulas, characterized in that, The method includes: The main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation on the formula to be calculated, obtains the formula calculation data, and sends the formula calculation data and the corresponding calculation task to the worker thread through the message queue. The worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data to obtain an initial formula calculation scheme. The worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme, obtains the formula calculation result and the real-time calculation progress, and sends the formula calculation result and the real-time calculation progress to the main thread through a message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and the real-time calculation progress to obtain the real-time table display data. The main thread performs real-time detection and response processing on user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through the message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain the adapted and adjusted formula calculation scheme. The worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches the preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data.
2. The method according to claim 1, characterized in that, The worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme, obtains the formula calculation result and the real-time calculation progress, and sends the formula calculation result and the real-time calculation progress to the main thread through a message queue. The main thread performs table interface rendering and display updates on the calculation results of the formula and the real-time calculation progress to obtain real-time table display data, including: The worker thread performs execution timing and calculation unit splitting on the initial formula calculation scheme to obtain multiple calculation stages ordered according to the formula calculation dependency relationship; The worker thread performs dependency validity checks and numerical calculations on the formula to be calculated corresponding to the calculation stage to obtain the formula calculation result of the current calculation stage. The worker thread updates the computational dependencies of the formula to be calculated that depend on the calculation results of the formula in the current calculation stage, and obtains the dependency adjustment data of the corresponding formula to be calculated. The worker thread performs statistical processing on the percentage of completed calculations of the formula to be calculated based on the formula calculation results of the current calculation stage and the dependency adjustment data of the corresponding formula to be calculated, and obtains the real-time calculation progress. The worker thread sends the formula calculation result of the current calculation stage and the real-time calculation progress to the main thread through a message queue. The main thread performs table interface rendering and update processing on the received formula calculation result and real-time calculation progress to obtain the real-time table display data.
3. The method according to claim 1, characterized in that, The main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation processing on the formula to obtain the formula calculation data, including: The main thread performs syntax compliance checks and standardized decomposition on the formulas to be calculated in the obtained spreadsheet to obtain the basic data of the formulas; The main thread performs reference association identification and statistical processing on the basic data of the formula to obtain computational dependency data; The main thread performs a verification process on the formula to be calculated to obtain calculation execution adaptation data. The main thread performs structured integration processing on the computation dependency data and the computation execution adaptation data to obtain the formula calculation data.
4. The method according to claim 1, characterized in that, The worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data, to obtain an initial formula calculation scheme, including: The worker thread sorts the computation dependency data in the formula calculation data by computation priority to obtain the execution timing data of the formula to be calculated; The worker thread performs unit splitting on the calculation task corresponding to the formula to be calculated based on the execution timing data to obtain the calculation execution unit; The worker thread performs execution scenario matching processing on the calculation execution unit and the calculation execution adaptation data in the formula calculation data to obtain the execution adaptation rules; The worker thread performs structured integration processing on the execution timing data, the computation execution unit, and the execution adaptation rules to obtain an initial formula calculation scheme.
5. The method according to claim 1, characterized in that, The main thread performs real-time detection and response processing of user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through the message queue. The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain an adapted formula calculation scheme, including: The main thread performs real-time detection and type classification processing on the table presentation status corresponding to the real-time data displayed in the table to obtain categorized user operation data. The main thread performs compliance verification and corresponding response processing on the categorized user operation data to obtain the operation response results; The main thread sends the operation response result to the worker thread through a message queue. The worker thread calculates the impact range and identifies the adjustment requirements of the operation response result to obtain the formula calculation scheme adjustment parameters. The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the formula calculation scheme adjustment parameters to obtain the adapted and adjusted formula calculation scheme.
6. The method according to claim 1, characterized in that, The worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches the preset completion threshold, the calculation results of the full set of formulas to be calculated are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formula to be calculated, obtaining the target calculation result and the corresponding table display data, including: The worker thread performs a full verification of the calculation completion status of the formula to be calculated corresponding to the adapted and adjusted formula calculation scheme, and obtains full calculation completion data. The worker thread compares and verifies the full calculation completion data with the preset completion threshold to obtain the calculation completion status matching result. When the calculation completion status matching result reaches the preset completion threshold, the worker thread sends the calculation results of each stage formula corresponding to the formula to be calculated to the main thread through the message queue; The main thread performs consistency verification and integration on the received formula calculation results to obtain the target calculation result. It then performs full table interface rendering and display update processing on the target calculation result to obtain the table display data corresponding to the target calculation result.
7. The method according to claim 1, characterized in that, The phased computation process is executed by worker threads, which execute computation tasks in batches according to preset time slices. After each batch of computation is completed, the worker threads check and process the messages sent by the main thread.
8. A non-blocking parallel computing device for spreadsheet formulas, characterized in that, include: The acquisition module is used to acquire the formula to be calculated in the spreadsheet through the main thread, perform expression tree parsing, dependency parsing and adaptation processing on the formula to be calculated to obtain the formula calculation data, and send the formula calculation data and the corresponding calculation task to the worker thread through the message queue. The processing module is used to schedule and plan the calculation tasks corresponding to the formula to be calculated based on the formula calculation data through the worker thread, so as to obtain the initial formula calculation scheme. The update module is used to perform phased calculations on the formula to be calculated based on the initial formula calculation scheme through a worker thread, obtain the formula calculation result and the real-time calculation progress, and send the formula calculation result and the real-time calculation progress to the main thread through a message queue; The main thread performs table interface rendering and display updates on the calculation results of the formula and the real-time calculation progress to obtain the real-time table display data. The processing module is also used to detect and respond to user operation events in real time through the main thread based on the table presentation status corresponding to the real-time data displayed in the table, obtain operation response results, and send the operation response results to the worker thread through the message queue; The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain the adapted and adjusted formula calculation scheme. The processing module is further configured to perform a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme through a worker thread, to obtain the calculation completion degree. When the calculation completion degree reaches a preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through a message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data.
9. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.