CN109558221B - Task processing method and device - Google Patents

Task processing method and device Download PDF

Info

Publication number
CN109558221B
CN109558221B CN201710888276.1A CN201710888276A CN109558221B CN 109558221 B CN109558221 B CN 109558221B CN 201710888276 A CN201710888276 A CN 201710888276A CN 109558221 B CN109558221 B CN 109558221B
Authority
CN
China
Prior art keywords
time range
task
time
total time
total
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710888276.1A
Other languages
Chinese (zh)
Other versions
CN109558221A (en
Inventor
刘绍华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201710888276.1A priority Critical patent/CN109558221B/en
Publication of CN109558221A publication Critical patent/CN109558221A/en
Application granted granted Critical
Publication of CN109558221B publication Critical patent/CN109558221B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a task processing method and a device, which are used for acquiring a first task and a second task which is generated before the first task and has generation time adjacent to the generation time of the first task, acquiring a word time range carried in the first task and a first total time range carried in the second task, and acquiring a second total time range carried in the first task according to a sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task, so that the time range corresponding to the data to be processed by all tasks can be acquired by only inquiring the first task, and the acquisition efficiency is improved.

Description

Task processing method and device
Technical Field
The invention relates to the technical field of data query, in particular to a task processing method and a task processing device.
Background
With the development of applications, more and more applications are applied to data analysis, for example, in the field of finance, transaction trends are analyzed and transaction amount is counted through data analysis; in the manufacturing industry, the processing amount and the processing efficiency are counted through data analysis, and in these applications for data analysis, the range query is one of the most important query types, and a feasible way of a specific range query method is as follows:
the method comprises the steps of giving a time range, inquiring transaction data in the time range to obtain inquiry results meeting inquiry requirements, dividing the time range into sub-time ranges under the condition of large data volume, generating a task according to the sub-time ranges, and inquiring data under the task by sequentially executing tasks corresponding to different sub-time ranges to obtain the inquiry results in each time range. After the query result of each time range is queried, the query results are combined according to the time ranges, so that the query time is reduced, and the query efficiency is improved.
However, in the above range query method, if the time ranges corresponding to the data to be processed by all the tasks are to be obtained, all the tasks in each time range need to be traversed, thereby reducing the acquisition efficiency.
Disclosure of Invention
In view of the above problems, the present invention is proposed to provide a task processing method and apparatus for overcoming the above problems or at least partially solving the above problems, so as to improve the efficiency of acquiring a time range, and the technical solution is as follows:
the invention provides a task processing method, which comprises the following steps:
acquiring a first task and a second task which is generated before the first task and has a generation time adjacent to that of the first task;
acquiring a sub-time range carried in the first task and a first total time range carried in the second task, wherein the sub-time range is a time range corresponding to data required to be processed by the first task, and the first total time range is a time range corresponding to data required to be processed by other tasks except the first task;
and obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task.
Preferably, the method further comprises: reconstructing other tasks generated before the first task according to the second total time range.
Preferably, the reconstructing the other tasks generated before the first task according to the second total time range includes: and replacing a first total time range carried by other tasks generated before the first task with a second total time range, wherein the second total time range is time corresponding to data to be processed of all tasks including the first task, and the time is a time range within a preset relative time range from the generation time of the first task.
Preferably, the obtaining a second total time range carried in the first task according to the sub-time range and the first total time range includes:
acquiring the starting time of the sub time range and the ending time of the sub time range;
acquiring the starting time of the first total time range and the ending time of the first total time range;
acquiring a third total time range within a preset relative time range from the production time of the first task, and acquiring the starting time of the third total time range and the ending time of the third total time range;
according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), a second total time range carried in the first task is obtained, a is the start time of the second total time range, B is the end time of the second total time range, a3 and a4 are the start time of the first total time range and the end time of the first total time range respectively, B3 and B4 are the start time of the sub time range and the end time of the sub time range respectively, and c1 and c2 are the start time of the third total time range and the end time of the third total time range respectively.
Preferably, the method further comprises: identifying the first task as a timed task;
sequencing the query sequence of the first task and other tasks generated before the first task according to a preset condition;
and sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
The present invention also provides a task processing device, including:
a first acquisition unit configured to acquire a first task and a second task that is generated before the first task and whose generation time is adjacent to a generation time of the first task;
a second obtaining unit, configured to obtain a sub time range carried in the first task and a first total time range carried in the second task, where the sub time range is a time range corresponding to data that needs to be processed by the first task, and the first total time range is a time range corresponding to data that needs to be processed by other tasks except the first task;
and an obtaining unit, configured to obtain a second total time range carried in the first task according to the sub-time range and the first total time range, where the second total time range is a time range corresponding to data to be processed by all tasks including the first task.
Preferably, the apparatus further comprises: and the reconstruction unit is used for reconstructing other tasks generated before the first task according to the second total time range.
Preferably, the reconstructing unit is configured to replace a first total time range carried by other tasks generated before the first task with a second total time range, where the second total time range is a time range corresponding to data to be processed by all tasks including the first task and a time of the second total time range is within a preset relative time range from the generation time of the first task.
Preferably, the obtaining unit includes: a first acquisition subunit, a second acquisition subunit, a third acquisition subunit and an acquisition subunit;
the first acquiring subunit is configured to acquire a start time of the sub-time range and an end time of the sub-time range;
the second obtaining subunit is configured to obtain a start time of the first total time range and an end time of the first total time range;
the third obtaining subunit is configured to obtain a third total time range within a preset relative time range from the production time of the first task, and obtain a start time of the third total time range and an end time of the third total time range;
the obtaining subunit is configured to obtain, according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), a second total time range carried in the first task, where a is a start time of the second total time range, B is an end time of the second total time range, a3 and a4 are a start time of the first total time range and an end time of the first total time range, B3 and B4 are a start time of the sub time range and an end time of the sub time range, respectively, and c1 and c2 are a start time of the third total time range and an end time of the third total time range, respectively.
Preferably, the apparatus further comprises: an identification unit, configured to identify the first task as a timing task;
the sequencing unit is used for sequencing the first task and the query sequence of other tasks generated before the first task according to preset conditions;
and the execution unit is used for sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
The present invention also provides a storage medium including a stored program, wherein the program executes the above-described task processing method.
The invention also provides a processor, which is used for running the program, wherein the task processing method is executed when the program runs.
By means of the technical scheme, after the first task and the second task which is generated before the first task and has generation time adjacent to the generation time of the first task are obtained, the word time range carried in the first task and the first total time range carried in the second task are obtained, and the second total time range carried in the first task is obtained according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task, so that the time ranges corresponding to the data to be processed by all tasks can be obtained by only inquiring the first task, and the obtaining efficiency is improved.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a flowchart of a task processing method provided by an exemplary embodiment of the present disclosure;
FIG. 2 illustrates a schematic diagram of a first task and a second task provided by an exemplary embodiment of the present disclosure;
FIG. 3 illustrates a schematic diagram of first time tasks provided by an exemplary embodiment of the present disclosure;
FIG. 4 illustrates a flowchart of a possible way to obtain a second total time range provided by an exemplary embodiment of the present disclosure;
FIG. 5 illustrates an example graph resulting in a second total time range provided by an example embodiment of the disclosure;
FIG. 6 illustrates another flowchart of a task processing method provided by an exemplary embodiment of the present disclosure;
FIG. 7 illustrates yet another flowchart of a task processing method provided by an exemplary embodiment of the present disclosure;
FIG. 8 shows a flowchart of a task processing device provided by an exemplary embodiment of the present disclosure;
fig. 9 shows another flowchart of a task processing device provided by an exemplary embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Referring to fig. 1, a flowchart of a task processing method provided in an exemplary embodiment of the present disclosure is shown, which is used for obtaining time ranges corresponding to data to be processed of all tasks by querying only a second total time range carried in a first task, so as to improve acquisition efficiency, and specifically, the task processing method may include the following steps:
101: the method includes acquiring a first task and a second task which is generated before the first task and has a generation time adjacent to that of the first task.
The first task is a task inserted into the task queue and located at the head of the task queue, and the first task may be a task input by the user according to the time corresponding to the data to be processed, for example, when the task processing method provided by the exemplary embodiment of the present disclosure is applied to a data query application in a dynamic range, the first task is a task input by the user according to the time corresponding to some data in the dynamic range.
In an exemplary embodiment of the disclosure, the first task and the second task are located in one task queue, and the task queue records a generation time of each task, where the generation time indicates a time for generating the corresponding task, for example, if the second task queries data from 5 days before 5 month 15 to 10 days before 5 month 15, the generation time of the second task is 5 month 15, and if the first task continues to query data from 5 days before 5 month 16 to 10 days before 5 month 16, the generation time of the first task is 5 month 16 (the generation time may be the same as the time for inserting the first task into the task queue).
As can be seen from the above example, the generation sequence of each task in the task queue can be determined by the generation time, and which task is adjacent to which task can be determined, so in the exemplary embodiment of the present disclosure, the second task can be determined according to the generation time of the first task and the generation times of other tasks in the task queue.
102: the method comprises the steps of obtaining a sub-time range carried in a first task and a first total time range carried in a second task, wherein the sub-time range is a time range corresponding to data needing to be processed by the first task, and the first total time range is a time range corresponding to data needing to be processed by other tasks except the first task.
It can be understood that: the first task and the second task carry a time structure, the time structure includes a sub-time range and a total time range, for the sub-time ranges of different tasks, the time under the sub-time ranges of adjacent tasks is continuous, so as to ensure that the data under each time can be processed in the application of data query in a dynamic range, for the total time range of different tasks, the initial total time range carried in the first task is a time range formed by the start time and the end time of the sub-time range carried in the first task, and the total time range carried in the second task is the first total time range.
Taking fig. 2 as an example, the sub-time ranges carried in the first task are (0510, 0511), the total time range carried in the first task is [0510, 0511], the sub-time range carried in the second task is (0507, 0510], so as to ensure the time continuity under the sub-time ranges of the two tasks, and the first total time range carried in the second task is [0505, 0510], namely, the time range corresponding to the data to be processed by all tasks including the second task, wherein "(" represents the upper limit without the sub-time range, and "]" represents the lower limit including the sub-time range and the upper limit and the lower limit including the total time range.
Taking ((0510, 0511) as an example, "(" indicates a time after the start time of the sub-time range of the first task is No. 5 months 10, i.e. after the end time of No. 5 months 10 as the start time, "]" indicates the start time of the sub-time range of the first task is No. 5 months 11 as the end time.
The points to be explained here are: for the task inserted for the first time in the task queue, no matter the task is located at the head of the task queue or at other positions of the task queue, the total time range carried by the task is the time range corresponding to the data to be processed of all the tasks inserted for the first time, and the sub-time range of the task with the minimum starting time value in the sub-time range of the task inserted for the first time is expressed in the form of [ ], so that the initial starting time of all the tasks is ensured to be included.
For example, a task (identified as a first task) inserted for the first time in the task queue is generated in No. 5/15, the first task is used to pre-aggregate data in a preset relative time range, such as the previous 10 days to the previous 5 days, data to be processed for controlling the first task in the pre-aggregation may be divided into the previous 10 days to the previous 5 days by a time range, such as dividing data every 3 days, to generate two first tasks shown in fig. 3, which are respectively marked as a first task 1 and a first task 2, in fig. 3, process is the current time (such as No. 5/15), timeWindow is a preset relative time range, section is a sub-time range in the first task, if the query range cannot completely divide the time range in the first task, it can be ensured that the sub-time range of (P-1) first tasks in all the P first tasks that are divided is the value corresponding to Section, the sub-time range of the remaining first task is the difference between the end time and the start time of the preset relative time range and (P-1) × (the value corresponding to Section), where P is the total number of the divided first tasks, thisStart is the start time of the sub-time range, thisEnd is the end time of the sub-time range, allStart is the start time of the total time range, allEnd is the end time of the total time range, and the start time of the first task 1 includes 5 months and 5 # (0505 shown in fig. 3). Of course, the first task may be represented by the time structure shown in fig. 2 in addition to the time structure shown in fig. 3, and an exemplary embodiment of the present disclosure will not be described.
103: and obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task, so that the time ranges corresponding to the data to be processed by all tasks can be obtained only by querying the first task, and the obtaining efficiency is improved.
In an exemplary embodiment of the present disclosure, a first possible way to obtain the second total time range carried in the first task is: and acquiring a difference value between the ending time of the first total time range and the ending time of the sub time range, determining the sum of the starting time of the first total time range and the difference value as the starting time of the second total time range, and determining the sum of the ending time of the first total time range and the difference value as the ending time of the second total time range.
In an exemplary embodiment of the disclosure, a second possible way of obtaining the second total time range carried in the first task is shown in fig. 4, and may include the following steps:
401: the start time of the sub-time range and the end time of the sub-time range are obtained.
402: a start time of the first total time range and an end time of the first total time range are obtained.
403: and acquiring a third total time range within a preset relative time range from the production time of the first task, and acquiring the starting time of the third total time range and the ending time of the third total time range.
404: according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), a second total time range carried in the first task is obtained, a is the start time of the second total time range, B is the end time of the second total time range, a3 and a4 are the start time of the first total time range and the end time of the first total time range respectively, B3 and B4 are the start time of the sub time range and the end time of the sub time range respectively, and c1 and c2 are the start time of the third total time range and the end time of the third total time range respectively.
The second total time range obtained by the two possible ways is a time range corresponding to data to be processed by all tasks including the first task, and needs to satisfy a point: the time of the second total time range is a time range within a preset relative time range from the generation time of the first task, so that the time ranges of all the tasks in the task queue, which need to process data, are within the preset relative time range, and the data query in the dynamic range under the relative time range is ensured.
In the following, the two possible ways are described by taking fig. 5 as an example, where in fig. 5 the sub-time ranges of the second task are (0507, 0510), the first total time range is [0505, 0510], the sub-time range of the first task is (0510, 0511), the initial second total time range of the first task is [0510, 0511], the process of the second total time range of the first task obtained according to the first possible way is shown by a dotted line, the second total time range is modified to [0506, 0511]. In fig. 5, a third total time range [0506, 0511] within a preset relative time range from the production time of the first task is shown by a dotted line, the process of the second total time range of the first task obtained according to the second possible way is shown by a solid line, the second total time range is also modified to [0506, 0511]. It is known from fig. 5 that the second total time range moves the start time and end time of the first total time range back to the solid line, thereby ensuring that the first total time range is within the preset relative time range of the first total time range.
In the exemplary embodiment of the present disclosure, the value of the preset relative time range may be determined according to a data query in a dynamic range, and the exemplary embodiment of the present disclosure does not limit the value, and the task processing method provided by the present disclosure may also be applied to other data processing applications, and the application process thereof is not described in detail.
According to the technical scheme, after the first task and the second task which is generated before the first task and has generation time adjacent to the generation time of the first task are obtained, the word time range carried in the first task and the first total time range carried in the second task are obtained, the second total time range carried in the first task is obtained according to the sub-time range and the first total time range, and the second total time range is the time range corresponding to the data which needs to be processed by all tasks including the first task, so that the time ranges corresponding to the data which needs to be processed by all tasks can be obtained by only inquiring the first task, and the obtaining efficiency is improved.
Referring to fig. 6, which shows another flowchart of a task processing method provided by an exemplary embodiment of the present disclosure, the method may include the following steps:
601: the method includes acquiring a first task and a second task which is generated before the first task and has a generation time adjacent to that of the first task.
602: the method comprises the steps of obtaining a sub-time range carried in a first task and a first total time range carried in a second task, wherein the sub-time range is a time range corresponding to data needing to be processed by the first task, and the first total time range is a time range corresponding to data needing to be processed by other tasks except the first task.
603: and obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task, so that the time ranges corresponding to the data to be processed by all tasks can be obtained only by querying the first task, and the obtaining efficiency is improved.
In an exemplary embodiment of the present disclosure, steps 601 to 603: similar to steps 101 to 103, for steps 601 to 603, the implementation process and the descriptions thereof refer to the descriptions of steps 101 to 103, and the exemplary embodiments of the present disclosure will not be described again.
604: and reconstructing other tasks generated before the first task according to the second total time range so as to avoid the total time range of the other tasks from conflicting with the second total time range of the first task.
In particular, in an exemplary embodiment of the present disclosure, one possible way to reconstruct other tasks generated before the first task is to: and replacing the first total time range carried by other tasks generated before the first task with the second total time range, so that the first total time range carried by other tasks and the second total time range avoid the conflict of the total time ranges of different tasks.
The second total time range is a time range corresponding to data to be processed by all tasks including the first task, and needs to satisfy a point: the time of the second total time range is a time range within a preset relative time range from the generation time of the first task, so that the time ranges of data to be processed of all tasks in the task queue are within the preset relative time range, and data query in the dynamic range under the relative time range is ensured.
It can be known from the foregoing technical solutions that, after the second total time range carried in the first task is obtained, other tasks generated before the first task may be reconstructed according to the second total time range, so as to avoid that the total time ranges of the other tasks conflict with the second total time range of the first task.
Referring to fig. 7, which shows a flowchart of another task processing method provided by an exemplary embodiment of the present disclosure, the method may include the following steps:
701: the method includes acquiring a first task and a second task which is generated before the first task and has a generation time adjacent to that of the first task.
702: and acquiring a sub-time range carried in the first task and a first total time range carried in the second task, wherein the sub-time range is a time range corresponding to data to be processed by the first task, and the first total time range is a time range corresponding to data to be processed by other tasks except the first task.
703: and obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task, so that the time ranges corresponding to the data to be processed by all tasks can be obtained only by querying the first task, and the obtaining efficiency is improved.
704: and reconstructing other tasks generated before the first task according to the second total time range so as to avoid the total time range of the other tasks from conflicting with the second total time range of the first task.
In an exemplary embodiment of the present disclosure, steps 701 to 703: similar to steps 101 to 103, for steps 701 to 703, the implementation process and the descriptions thereof refer to the descriptions of steps 101 to 103, and for step 704, the implementation process and the descriptions thereof refer to step 604, so that the implementation process and the descriptions thereof refer to the descriptions thereof of step 604, and the descriptions thereof of steps 701 to 704 are omitted.
705: the first task is identified as a timed task.
706: and sequencing the query sequence of the first task and other tasks generated before the first task according to a preset condition.
In an exemplary embodiment of the present disclosure, the preset conditions include, but are not limited to: the priority of the timing task is higher than that of the first task; the priority of the timing task with small time is higher than that of the timing task with large time; the priority of the first task with small time is lower than that of the first task with large time, so that the timing task with small time can be sequenced before other tasks, and the execution of the timing task is facilitated.
707: and sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
Corresponding to the foregoing method embodiment, an embodiment of the present invention further provides a task processing device, an optional structure of which is shown in fig. 8, and may include: a first acquisition unit 11, a second acquisition unit 12 and an acquisition unit 13.
A first acquiring unit 11 configured to acquire a first task and a second task that is generated before the first task and has a generation time adjacent to a generation time of the first task. The first task is a task inserted into the task queue and located at the head of the task queue, and the first task may be a task input by the user according to the time corresponding to the data to be processed, for example, when the task processing device provided by the exemplary embodiment of the present disclosure is applied to a data query application in a dynamic range, the first task is a task input by the user according to the time corresponding to some data in the dynamic range.
In the exemplary embodiment of the present disclosure, the first task and the second task are located in one task queue, and the task queue records the generation time of each task, where the generation time indicates the time for generating the corresponding task, so that the generation order of each task in the task queue can be determined by the generation time, and which task is adjacent to which task can be determined.
The second obtaining unit 12 is configured to obtain a sub time range carried in the first task and a first total time range carried in the second task, where the sub time range is a time range corresponding to data that needs to be processed by the first task, and the first total time range is a time range corresponding to data that needs to be processed by other tasks except the first task.
It can be understood that: the first task and the second task carry a time structure, where the time structure includes a sub-time range and a total time range, and for the sub-time ranges of different tasks, the time under the sub-time ranges of adjacent tasks is continuous, so as to ensure that data at each time can be processed in the application of data query in a dynamic range.
The obtaining unit 13 is configured to obtain a second total time range carried in the first task according to the sub-time range and the first total time range, where the second total time range is a time range corresponding to data to be processed by all tasks including the first task.
In an exemplary embodiment of the present disclosure, one possible way for the obtaining unit 12 to obtain the second total time range carried in the first task is: and acquiring a difference value between the ending time of the first total time range and the ending time of the sub time range, determining the sum of the starting time of the first total time range and the difference value as the starting time of the second total time range, and determining the sum of the ending time of the first total time range and the difference value as the ending time of the second total time range.
Or the obtaining unit 12 is obtained by other methods, for example, an alternative structure of the obtaining unit 12 includes: a first acquisition subunit, a second acquisition subunit, a third acquisition subunit and an acquisition subunit. The first acquiring subunit is configured to acquire a start time of the sub-time range and an end time of the sub-time range.
And the second acquiring subunit is used for acquiring the starting time of the first total time range and the ending time of the first total time range. And the third acquiring subunit is used for acquiring a third total time range within a preset relative time range from the production time of the first task, and acquiring the start time of the third total time range and the end time of the third total time range.
Obtaining subunits, configured to obtain a second total time range carried in the first task according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), where a is a start time of the second total time range, B is an end time of the second total time range, a3 and a4 are a start time of the first total time range and an end time of the first total time range, B3 and B4 are a start time of the sub time range and an end time of the sub time range, respectively, and c1 and c2 are a start time of the third total time range and an end time of the third total time range, respectively.
The second total time range obtained in the above manner needs to satisfy a point, in addition to the time ranges corresponding to the data to be processed by all tasks including the first task: the time of the second total time range is a time range within a preset relative time range from the generation time of the first task, so that the time ranges of all the tasks in the task queue, which need to process data, are within the preset relative time range, and the data query in the dynamic range under the relative time range is ensured.
In the exemplary embodiment of the present disclosure, the value of the preset relative time range may be determined according to a data query in a dynamic range, and the exemplary embodiment of the present disclosure does not limit the value, and the task processing method provided by the present disclosure may also be applied to other data processing applications, and the application process thereof is not described in detail.
According to the technical scheme, after the first task and the second task which is generated before the first task and has the generation time adjacent to the generation time of the first task are obtained, the word time range carried in the first task and the first total time range carried in the second task are obtained, the second total time range carried in the first task is obtained according to the sub-time range and the first total time range, and the second total time range is the time range corresponding to the data which needs to be processed by all tasks including the first task, so that the time range corresponding to the data which needs to be processed by all tasks can be obtained by only inquiring the first task, and the obtaining efficiency is improved.
Referring to fig. 9, which shows another alternative structure of the task processing device provided in the exemplary embodiment of the present disclosure, on the basis of fig. 8, the task processing device may further include: the reconstructing unit 14 is configured to reconstruct, according to the second total time range, the other tasks generated before the first task, so as to avoid that the total time range of the other tasks conflicts with the second total time range of the first task.
Specifically, one way of reconstructing by the reconstruction unit 14 is: and replacing the first total time range carried by other tasks generated before the first task with a second total time range, wherein the second total time range is the time corresponding to the data to be processed of all tasks including the first task and is the time range which is within the preset relative time range from the generation time of the first task.
It can be known from the foregoing technical solutions that, after the second total time range carried in the first task is obtained, other tasks generated before the first task may be reconstructed according to the second total time range, so as to avoid that the total time ranges of the other tasks conflict with the second total time range of the first task.
Furthermore, a task processing device provided by an exemplary embodiment of the present disclosure may further include: the device comprises an identification unit, a sorting unit and an execution unit. The identification unit is used for identifying the first task as the timing task.
And the sequencing unit is used for sequencing the first task and the query sequence of other tasks generated before the first task according to a preset condition. In an exemplary embodiment of the present disclosure, the preset conditions include, but are not limited to: the timing task has a higher priority than the first task; the priority of the timing task with small time is higher than that of the timing task with large time; the priority of the first task with small time is lower than that of the first task with large time, so that the timing task with small time can be sequenced before other tasks, and the execution of the timing task is facilitated.
And the execution unit is used for sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
The task processing device comprises a processor and a memory, wherein the first acquiring unit, the second acquiring unit, the reconstructing unit, the identifying unit, the sequencing unit, the executing unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more, and the efficiency of obtaining the time range is improved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium, which includes a stored program thereon, and the program executes the above-described task processing method.
The embodiment of the invention provides a processor, which is used for running a program, wherein the task processing method is executed when the program runs.
The embodiment of the present invention provides a device, where the device in this document may be a server, a PC, a PAD, a mobile phone, and the like, where the device includes a processor, a memory, and a program stored in the memory and capable of running on the processor, and the processor implements the following steps when executing the program:
acquiring a first task and a second task which is generated before the first task and has generation time adjacent to that of the first task;
acquiring a sub-time range carried in the first task and a first total time range carried in the second task, wherein the sub-time range is a time range corresponding to data to be processed by the first task, and the first total time range is a time range corresponding to data to be processed by other tasks except the first task;
and obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed by all tasks including the first task.
Preferably, the processor executes the program to further perform the steps of: and reconstructing other tasks generated before the first task according to the second total time range.
Preferably, the reconstructing the other tasks generated before the first task according to the second total time range includes: and replacing a first total time range carried by other tasks generated before the first task with a second total time range, wherein the second total time range is time corresponding to data to be processed of all tasks including the first task, and the time is a time range within a preset relative time range from the generation time of the first task.
Preferably, the obtaining a second total time range carried in the first task according to the sub-time range and the first total time range includes:
acquiring the starting time of the sub-time range and the ending time of the sub-time range;
acquiring the starting time of the first total time range and the ending time of the first total time range;
acquiring a third total time range within a preset relative time range from the production time of the first task, and acquiring the starting time of the third total time range and the ending time of the third total time range;
according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), a second total time range carried in the first task is obtained, a is the start time of the second total time range, B is the end time of the second total time range, a3 and a4 are the start time of the first total time range and the end time of the first total time range respectively, B3 and B4 are the start time of the sub time range and the end time of the sub time range respectively, and c1 and c2 are the start time of the third total time range and the end time of the third total time range respectively.
Preferably, the processor executes the program to further perform the steps of: identifying the first task as a timed task;
sequencing the query sequence of the first task and other tasks generated before the first task according to a preset condition;
and sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
An embodiment of the present invention further provides a computer program product, which, when executed on a data processing apparatus, is adapted to execute a program that initializes the following method steps:
acquiring a first task and a second task which is generated before the first task and has a generation time adjacent to that of the first task;
acquiring a sub-time range carried in the first task and a first total time range carried in the second task, wherein the sub-time range is a time range corresponding to data required to be processed by the first task, and the first total time range is a time range corresponding to data required to be processed by other tasks except the first task;
and obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed of all tasks including the first task.
Preferably, the program, when executed on a data processing device, is adapted to perform the initialization further with the method steps of: reconstructing other tasks generated before the first task according to the second total time range.
Preferably, the reconstructing the other tasks generated before the first task according to the second total time range includes: and replacing a first total time range carried by other tasks generated before the first task with a second total time range, wherein the second total time range is time corresponding to data to be processed of all tasks including the first task, and the time is a time range within a preset relative time range from the generation time of the first task.
Preferably, the obtaining a second total time range carried in the first task according to the sub-time range and the first total time range includes:
acquiring the starting time of the sub time range and the ending time of the sub time range;
acquiring the starting time of the first total time range and the ending time of the first total time range;
acquiring a third total time range within a preset relative time range from the production time of the first task, and acquiring the starting time of the third total time range and the ending time of the third total time range;
according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), a second total time range carried in the first task is obtained, a is the start time of the second total time range, B is the end time of the second total time range, a3 and a4 are the start time of the first total time range and the end time of the first total time range respectively, B3 and B4 are the start time of the sub time range and the end time of the sub time range respectively, and c1 and c2 are the start time of the third total time range and the end time of the third total time range respectively.
Preferably, the program, when executed on a data processing device, is adapted to perform the initialization further comprising the method steps of: identifying the first task as a timed task;
sequencing the query sequence of the first task and other tasks generated before the first task according to a preset condition;
and sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of the present application shall be included in the scope of the claims of the present application.

Claims (10)

1. A method for processing a task, the method comprising:
acquiring a first task and a second task which is generated before the first task and has a generation time adjacent to that of the first task;
acquiring a sub-time range carried in the first task and a first total time range carried in the second task, wherein the sub-time range is a time range corresponding to data required to be processed by the first task, and the first total time range is a time range corresponding to data required to be processed by other tasks except the first task;
obtaining a second total time range carried in the first task according to the sub-time range and the first total time range, wherein the second total time range is a time range corresponding to data to be processed of all tasks including the first task, and the time of the second total time range is a time range within a preset relative time range from the generation time of the first task;
wherein the obtaining of the second total time range carried in the first task according to the sub-time range and the first total time range includes: and acquiring a difference value between the ending time of the first total time range and the ending time of the sub time range, determining the sum of the starting time of the first total time range and the difference value as the starting time of the second total time range, and determining the sum of the ending time of the first total time range and the difference value as the ending time of the second total time range.
2. The method of claim 1, further comprising: reconstructing other tasks generated before the first task according to the second total time range.
3. The method of claim 2, wherein reconstructing other tasks generated prior to the first task according to the second total time horizon comprises: and replacing a first total time range carried by other tasks generated before the first task with a second total time range, wherein the second total time range is time corresponding to data to be processed of all tasks including the first task, and the time is a time range within a preset relative time range from the generation time of the first task.
4. The method according to any one of claims 1 to 3, wherein the obtaining a second total time range carried in the first task according to the sub-time range and the first total time range comprises:
acquiring the starting time of the sub-time range and the ending time of the sub-time range;
acquiring the starting time of the first total time range and the ending time of the first total time range;
acquiring a third total time range within a preset relative time range from the production time of the first task, and acquiring the starting time of the third total time range and the ending time of the third total time range;
according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), a second total time range carried in the first task is obtained, a is the start time of the second total time range, B is the end time of the second total time range, a3 and a4 are the start time of the first total time range and the end time of the first total time range respectively, B3 and B4 are the start time of the sub time range and the end time of the sub time range respectively, and c1 and c2 are the start time of the third total time range and the end time of the third total time range respectively.
5. The method of claim 4, further comprising: identifying the first task as a timed task;
sequencing the query sequence of the first task and other tasks generated before the first task according to a preset condition;
and sequentially executing the first task and other tasks generated before the first task according to the sorted query sequence.
6. A task processing apparatus, characterized in that the apparatus comprises:
a first acquisition unit configured to acquire a first task and a second task that is generated before the first task and whose generation time is adjacent to a generation time of the first task;
a second obtaining unit, configured to obtain a sub time range carried in the first task and a first total time range carried in the second task, where the sub time range is a time range corresponding to data that needs to be processed by the first task, and the first total time range is a time range corresponding to data that needs to be processed by other tasks except the first task;
an obtaining unit, configured to obtain a second total time range carried in the first task according to the sub-time range and the first total time range, where the second total time range is a time range corresponding to data to be processed by all tasks including the first task, and the time of the second total time range is a time range within a preset relative time range from the generation time of the first task;
wherein the obtaining, by the obtaining unit, a second total time range carried in the first task according to the sub time range and the first total time range includes: and acquiring a difference value between the end time of the first total time range and the end time of the sub time range, determining the sum of the start time of the first total time range and the difference value as the start time of the second total time range, and determining the sum of the end time of the first total time range and the difference value as the end time of the second total time range.
7. The apparatus of claim 6, further comprising: and the reconstruction unit is used for reconstructing other tasks generated before the first task according to the second total time range.
8. The apparatus according to claim 6 or 7, wherein the obtaining unit comprises: a first acquisition subunit, a second acquisition subunit, a third acquisition subunit and an acquisition subunit;
the first acquiring subunit is configured to acquire a start time of the sub-time range and an end time of the sub-time range;
the second obtaining subunit is configured to obtain a start time of the first total time range and an end time of the first total time range;
the third obtaining subunit is configured to obtain a third total time range within a preset relative time range from the production time of the first task, and obtain a start time of the third total time range and an end time of the third total time range;
the obtaining subunit is configured to obtain a second total time range carried in the first task according to formulas a = max (min (a 3, B3), c 1) and B = min (max (a 4, B4), c 2), where a is a start time of the second total time range, B is an end time of the second total time range, a3 and a4 are respectively a start time of the first total time range and an end time of the first total time range, B3 and B4 are respectively a start time of the sub time range and an end time of the sub time range, and c1 and c2 are respectively a start time of the third total time range and an end time of the third total time range.
9. A storage medium characterized by comprising a stored program, wherein the program executes to execute the task processing method according to any one of claims 1 to 5.
10. A processor, characterized in that the processor is configured to run a program, wherein the program when running performs the task processing method according to any one of claims 1 to 5.
CN201710888276.1A 2017-09-27 2017-09-27 Task processing method and device Active CN109558221B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710888276.1A CN109558221B (en) 2017-09-27 2017-09-27 Task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710888276.1A CN109558221B (en) 2017-09-27 2017-09-27 Task processing method and device

Publications (2)

Publication Number Publication Date
CN109558221A CN109558221A (en) 2019-04-02
CN109558221B true CN109558221B (en) 2022-10-04

Family

ID=65863721

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710888276.1A Active CN109558221B (en) 2017-09-27 2017-09-27 Task processing method and device

Country Status (1)

Country Link
CN (1) CN109558221B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5999924A (en) * 1997-07-25 1999-12-07 Amazon.Com, Inc. Method and apparatus for producing sequenced queries
CN106406993A (en) * 2016-09-06 2017-02-15 努比亚技术有限公司 Timed task management method and system
CN106648839A (en) * 2015-10-30 2017-05-10 北京国双科技有限公司 Method and device for processing data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5999924A (en) * 1997-07-25 1999-12-07 Amazon.Com, Inc. Method and apparatus for producing sequenced queries
CN106648839A (en) * 2015-10-30 2017-05-10 北京国双科技有限公司 Method and device for processing data
CN106406993A (en) * 2016-09-06 2017-02-15 努比亚技术有限公司 Timed task management method and system

Also Published As

Publication number Publication date
CN109558221A (en) 2019-04-02

Similar Documents

Publication Publication Date Title
CN109104327B (en) Service log generation method, device and equipment
CN110895544B (en) Interface data processing method, device, system and storage medium
CN106897342B (en) Data verification method and equipment
CN110019298B (en) Data processing method and device
CN108874379B (en) Page processing method and device
CN106648839B (en) Data processing method and device
CN109597678A (en) Task processing method and device
CN110765151A (en) Calculation formula processing method and device
CN108121712B (en) Keyword storage method and device
CN114138745A (en) Data integration method and device, storage medium and processor
CN110825764B (en) SQL script generation method, system, storage medium and processor
CN106648567B (en) Data acquisition method and device
CN110908587A (en) Method and device for storing time sequence data
CN108062323B (en) Log reading method and device
CN109558221B (en) Task processing method and device
CN110083602B (en) Method and device for data storage and data processing based on hive table
CN110019295B (en) Database retrieval method, device, system and storage medium
CN110019357B (en) Database query script generation method and device
CN111125087A (en) Data storage method and device
CN110968500A (en) Test case execution method and device
CN110019507B (en) Data synchronization method and device
CN110083437A (en) Handle the method and device of block chain affairs
CN108062329B (en) Data import method and device
CN110019198B (en) Data query method and device
CN110019296B (en) Database query script generation method and device, storage medium and processor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100080 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

Address before: 100086 Beijing city Haidian District Shuangyushu Area No. 76 Zhichun Road cuigongfandian 8 layer A

Applicant before: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant