CN113779077B - Time period query method, device, electronic equipment and storage medium - Google Patents

Time period query method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113779077B
CN113779077B CN202111146169.4A CN202111146169A CN113779077B CN 113779077 B CN113779077 B CN 113779077B CN 202111146169 A CN202111146169 A CN 202111146169A CN 113779077 B CN113779077 B CN 113779077B
Authority
CN
China
Prior art keywords
time period
statistical
period
count value
query
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
CN202111146169.4A
Other languages
Chinese (zh)
Other versions
CN113779077A (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.)
Jingdong City Beijing Digital Technology Co Ltd
Original Assignee
Jingdong City Beijing Digital 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 Jingdong City Beijing Digital Technology Co Ltd filed Critical Jingdong City Beijing Digital Technology Co Ltd
Priority to CN202111146169.4A priority Critical patent/CN113779077B/en
Publication of CN113779077A publication Critical patent/CN113779077A/en
Application granted granted Critical
Publication of CN113779077B publication Critical patent/CN113779077B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2477Temporal data queries

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a time period query method, a device, an electronic device and a storage medium, wherein the method comprises the following steps: obtaining a query request of a time period set, reading an index structure, wherein the index structure comprises a starting point total count value and an ending point total count value corresponding to each statistic time period, querying the index structure according to a first statistic time period where the starting point of the query time period is located in the query request to obtain the starting point total count value corresponding to the first statistic time period, querying the index structure according to a second statistic time period where the ending point of the query time period is located in the query request to obtain the ending point total count value corresponding to the second statistic time period, determining the time period number intersecting the query time period in the time period set according to the total time period number of the time period set, the starting point total count value corresponding to the first statistic time period and the ending point total count value corresponding to the second statistic time period, and constructing a lightweight index structure to realize rapid acquisition of the time period number intersecting the query time period in the time period set and improve the time period query efficiency.

Description

Time period query method, device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of query optimization, and in particular relates to a time period query method, a device, electronic equipment and a storage medium.
Background
For a given time period, it is useful to query from a time period database for the minimum number of time periods intersecting the given time period, wherein a typical application is query optimization in the database, and if the number of results satisfying the condition can be quickly known, the query optimizer of the database can determine a better query plan based on the obtained number of results, thereby accelerating the execution efficiency. In some scenarios where accurate query results are not required, only the number of time periods intersecting a given query time period need be returned quickly. Therefore, it is significant to acquire the query result for the time period.
Disclosure of Invention
The present disclosure aims to solve, at least to some extent, one of the technical problems in the related art.
For this reason, the present disclosure proposes a time period query method, apparatus, electronic device, and storage medium to improve efficiency of time period query.
An embodiment of an aspect of the present disclosure provides a time period query method, including the following steps:
acquiring a query request of a time period set;
Reading an index structure; the index structure comprises a starting point total count value and an end point total count value corresponding to each statistical period; the starting point total count value is used for indicating the starting point total number of the corresponding statistical time period and a first time period which is later than the corresponding statistical time period in the time period set; the total count value of the end points is used for indicating the total number of the end points in the time period set in the corresponding statistical time period and the second time period earlier than the corresponding statistical time period;
Inquiring the index structure according to a first statistical period in which the starting point of the inquiry period is positioned in the inquiry request so as to obtain a starting point total count value corresponding to the first statistical period;
Inquiring the index structure according to a second statistical period in which the end point of the inquiry period in the inquiry request is positioned, so as to obtain an end point total count value corresponding to the second statistical period;
And determining the number of time periods intersecting the query time period in the time period set according to the total number of time periods of the time period set, the total count value of the starting points corresponding to the first statistical time period and the total count value of the ending points corresponding to the second statistical time period.
Another embodiment of the present disclosure proposes a time period query apparatus, including:
the acquisition module is used for acquiring the query request of the time period set;
The reading module is used for reading the index structure; the index structure comprises a starting point total count value and an end point total count value corresponding to each statistical period; the starting point total count value is used for indicating the starting point total number of the corresponding statistical time period and a first time period which is later than the corresponding statistical time period in the time period set; the total count value of the end points is used for indicating the total number of the end points in the time period set in the corresponding statistical time period and the second time period earlier than the corresponding statistical time period;
The query module is used for querying the index structure according to a first statistical period where the starting point of the query period is located in the query request so as to obtain a starting point total count value corresponding to the first statistical period;
The query module is further configured to query the index structure according to a second statistical period in which an end point of the query period in the query request is located, so as to obtain an end point total count value corresponding to the second statistical period;
The determining module is used for determining the number of time periods intersecting the query time period in the time period set according to the total number of time periods of the time period set, the total count value of the starting points corresponding to the first statistical time period and the total count value of the end points corresponding to the second statistical time period.
Another embodiment of the present disclosure proposes an electronic device, including:
At least one processor; and a memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the preceding aspect.
Another aspect of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of the preceding aspect.
Another aspect of the present disclosure proposes a computer program product comprising computer instructions which, when executed by a processor, implement the method of the preceding aspect.
The technical scheme provided by the embodiment of the disclosure comprises the following beneficial effects:
obtaining a query request of a time period set, and reading an index structure, wherein the index structure comprises a starting point total count value and an end point total count value corresponding to each statistic time period, and the starting point total count value is used for indicating the total number of first time periods of starting points in the time period set in the corresponding statistic time period and later than the corresponding statistic time period; the method comprises the steps of inquiring an index structure according to a first statistical time period where a starting point of an inquiring time period in an inquiring request is located, obtaining a starting point total count value corresponding to the first statistical time period, inquiring the index structure according to a second statistical time period where the ending point of the inquiring time period in the inquiring request is located, obtaining an end point total count value corresponding to the second statistical time period, determining the time period number intersecting the inquiring time period in the time period set according to the time period total number of the time period set, the starting point total count value corresponding to the first statistical time period and the end point total count value corresponding to the second statistical time period, and constructing a lightweight index structure to achieve the purpose of rapidly obtaining the time period number intersecting the inquiring time period in the time period set and improving the efficiency of time period inquiring.
Additional aspects and advantages of the disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the disclosure.
Drawings
The foregoing and/or additional aspects and advantages of the present disclosure will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
fig. 1 is a flow chart of a time period query method provided in an embodiment of the disclosure;
FIG. 2 is a schematic diagram of a time period intersection provided by an embodiment of the present disclosure;
Fig. 3 is a flowchart of another time period query method provided in an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a period set and statistical period partitioning provided by an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of an index structure provided by an embodiment of the present disclosure;
fig. 6 is a flowchart of another time period query method provided in an embodiment of the present disclosure;
fig. 7 is a flowchart of another time period query method according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a time period query device according to an embodiment of the present disclosure;
fig. 9 is a block diagram of an electronic device 10 according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and intended for the purpose of explaining the present disclosure and are not to be construed as limiting the present disclosure.
The following describes a time period query method, apparatus, electronic device, and storage medium of an embodiment of the present disclosure with reference to the accompanying drawings.
Fig. 1 is a flowchart of a time period query method provided in an embodiment of the present disclosure.
As shown in fig. 1, the method comprises the steps of:
step 101, a query request of a period set is obtained.
Wherein the time period set comprises a plurality of time periods, the time periods are two-dimensional data and have a starting time and a terminating time, the time periods can be represented as [ t s,te ], the starting time is t s, and the terminating time is t e.
In the present disclosure, the query request carries a query period, for example, the query period is [2,4].
Step 102, reading the index structure.
The index structure comprises a starting point total count value and an end point total count value corresponding to each statistical period; the starting point total count value is used for indicating the total number of the starting points in the corresponding statistical time period and the first time period which is later than the corresponding statistical time period in the time period set; and the total count value of the end points is used for indicating the total number of the end points in the period set in the corresponding statistical period and the second period which is earlier than the corresponding statistical period.
In the disclosed embodiments, the index structure may be predetermined. The index structure includes a plurality of statistical time periods that are discrete and disjoint, and as an implementation, each statistical time period may be a discrete and disjoint statistical time period, but the same length, e.g., [0,4 ], [4,8 ], [8, 12), and [12,16], where each statistical time period has a corresponding starting point total count value and ending point total count value.
The Index structure in the embodiment of the present disclosure is a time period Count Index (TIME RANGE Count Index, TRC-Index), and includes a start total Count value and an end total Count value corresponding to each statistical period. The starting point total count value and the end point total count value can be represented by an array or a hash table.
Step 103, according to a first statistical period where the start point of the query period is located in the query request, querying the index structure to obtain a final point total count value corresponding to the first statistical period.
The query request includes a query period, for example, the query period is [2,4].
In the embodiment of the present disclosure, the starting point of the query period is 2, and the starting point of the query period is compared with each statistical period, so that the statistical period in which the starting point of the query period is located can be determined, and for convenience of distinction, the statistical period is referred to as a first statistical period. By inquiring the index structure, the total count value of the starting points corresponding to the corresponding statistical time period in the index structure can be inquired, and the inquired total count value of the starting points is used as the total count value of the end points corresponding to the first statistical time period. For example, the statistical period where the start point of the query period [2,4] is the above [0, 4], so that the statistical period [0, 4] is the first statistical period, and the total end point count value corresponding to the statistical period [0, 4] in the query index structure is 0, and then the total end point count value corresponding to the first statistical period is determined to be 0.
It should be noted that, the total count value of the end points corresponding to the first statistics period indicates that the time corresponding to the end point of each period in the period set is smaller than the total number of periods corresponding to the start point in the inquiry period, that is, the total number of periods disjoint to the inquiry period.
Step 104, according to the second statistical period where the end point of the query period in the query request is located, querying the index structure to obtain the starting point total count value corresponding to the second statistical period.
In the embodiment of the present disclosure, the end point of the inquiry period is 4, and the end point of the inquiry period is compared with each statistical period, so that the statistical period in which the end point of the inquiry period is located can be determined, and for convenience of distinction, the statistical period is referred to as a second statistical period. By querying the index structure, the total count value of the starting points corresponding to the corresponding statistical time period in the index structure can be queried, and the queried total count value of the starting points is used as the total count value of the starting points corresponding to the second statistical time period.
For example, the statistical period in which the end point of the query period [2,4] is located is [4,8 ] described above, so that the statistical period [4,8 ] is the first statistical period, the total count value of the start points corresponding to the statistical period [4,8 ] in the query index structure is 3, and then the total count value of the start points corresponding to the first statistical period is determined to be 3.
It should be noted that the total count value of the start points corresponding to the second statistical period indicates that the time corresponding to the start point of each period in the period set is greater than the total number of periods corresponding to the end point in the inquiry period, that is, the total number of periods disjoint to the inquiry period.
Step 105, determining the number of time periods intersecting the query time period in the time period set according to the total number of time periods in the time period set, the total count value of the end point corresponding to the first statistical time period and the total count value of the start point corresponding to the second statistical time period.
In the embodiment of the present disclosure, the period set includes a plurality of periods, and the total number of periods included in the set is determined, for example, 5 periods.
Fig. 2 is a schematic diagram of a period intersection provided by an embodiment of the present disclosure, where fig. 2 shows 4 cases where two periods intersect, for example, given a period database D, a query period q= [ t qs,tqe ], and the period intersecting q in D is divided into four cases in fig. 1, formally defined as: d' = { t r|tr.ts≤tqe and t r.te≥tqs }, thus, the case other than 4 cases, i.e., the case where there is no intersection of two time periods, i.e., the end time of one time period a is smaller than the start time of the other time period B, or the start time of one time period a is larger than the end time of the other time period B.
In the embodiment of the disclosure, the number of time periods in which the query time period does not have an intersection in the time period set is determined through the constructed index structure, and the time periods intersected with the query time period and the corresponding number are determined according to the number of the time periods in which the query time period does not have an intersection in the time period set, so that the number of the time periods in the time period set is rapidly acquired. In one implementation of the embodiment of the present disclosure, the total count value of the end point corresponding to the first statistical period and the total count value of the start point corresponding to the second statistical period are subtracted from the total number of the periods in the period set, so as to obtain the number of the periods intersecting the query period in the period set.
In the time period query method of the embodiment of the disclosure, a query request of a time period set is obtained, and an index structure is read, wherein the index structure comprises a starting point total count value and an end point total count value corresponding to each statistic time period, and the starting point total count value is used for indicating the total number of starting points in the time period set in the corresponding statistic time period and a first time period which is later than the corresponding statistic time period; the method comprises the steps of inquiring an index structure according to a first statistical period where a starting point of an inquiring period in an inquiring request is located, obtaining a starting point total count value corresponding to the first statistical period, inquiring the index structure according to a second statistical period where the ending point of the inquiring period in the inquiring request is located, obtaining an end point total count value corresponding to the second statistical period, determining the number of periods intersecting the inquiring period in the period set according to the total number of the periods in the period set, the starting point total count value corresponding to the first statistical period and the end point total count value corresponding to the second statistical period, and constructing a lightweight index structure to achieve rapid acquisition of the number of the periods in the period set and improve the inquiring efficiency of the periods.
Based on the foregoing embodiments, another time period query method is provided in the embodiments of the present disclosure, and fig. 3 is a schematic flow chart of another time period query method provided in the embodiments of the present disclosure, as shown in fig. 3, where the method includes the following steps:
Step 301, a query request for a set of time periods is obtained.
In step 301, the principle is the same with reference to the explanation in the foregoing embodiment, and the details are not repeated in this embodiment.
And step 302, dividing the time span of the time interval set into equal parts according to the set equal part number to obtain the statistical time interval of the equal part number.
In one implementation manner of the embodiment of the disclosure, the time span is determined according to the time period included in the time period set, and the time span of the time period set is divided equally according to a set dividing number, for example, 4 dividing equally, so as to obtain the statistical time of the dividing number, which can be represented by the following formula:
BinLen = [ |td (D) |/binNum ], where TD (D) is the time span of all time periods in the set and binNum is the set number of aliquots.
As shown in fig. 4, in a time period t r1-tr5 included in the time period set, if the minimum value of time is 1 and the maximum value of time is 15, in order to improve accuracy, a continuous time span is determined to be 0-16, where the set number of aliquots is 4, and the statistical time periods of the number of aliquots obtained after the aliquots are b1 respectively: [0, 4), b2: [4, 8), b3: [8, 12) and b4: [12,16].
In one implementation of the disclosed embodiments, the query accuracy of the equal number and the period set is a forward relationship. When the number of aliquots is larger, this means that the query accuracy of the period set is higher, but the corresponding space occupation is larger, and in some scenarios, such as distributed computing, the more data needs to be transmitted. In the embodiment of the disclosure, the balance of space occupation and query precision is provided by the equal number so as to meet the query requirements of different scenes, and the query precision and the space occupation are effectively balanced.
Step 303, counting the time slot set according to each counting period to obtain an index structure.
In the embodiment of the disclosure, according to each statistical period, counting is performed on the time slot set to obtain a starting point total count value and an end point total count value corresponding to each statistical period included in the index structure. The starting point total count value is used for indicating the total number of the starting points in the corresponding statistical time period and the first time period which is later than the corresponding statistical time period in the time period set; and the total count value of the end points is used for indicating the total number of the end points in the period set in the corresponding statistical period and the second period which is earlier than the corresponding statistical period.
Fig. 5 is a schematic diagram of an index structure provided in an embodiment of the present disclosure, as shown in fig. 5, in the embodiment of the present disclosure, two arrays are used to respectively represent a starting point total count value and an ending point count value corresponding to each statistics period, each statistics period in the arrays is represented by a container with a same length and discrete and disjoint, for example, the container is a bucket, where [0,4 ] corresponds to one container, and [4, 8) also corresponds to one container, which is not listed here. The index structure corresponding to the diagram (c) in FIG. 5, in which the arrayIn (a) is the total count value of starting points corresponding to each statistical time,/>And (5) counting the total end point count value corresponding to each statistical time. In embodiments of the present disclosure, according to the generated index structure,/>, may be utilizedRapidly finding the number of time segments in each time segment of the set, the starting time of which is greater than the ending time of the query time segment, and utilizing/>And (3) rapidly obtaining the number of time periods with the ending time smaller than the starting time of the query time period in each time period of the set, namely rapidly determining the number of time periods which are disjoint in the set and the query time period, and improving the query efficiency.
Step 304, the index structure is read.
Step 305, querying the index structure according to the first statistical period where the start point of the query period is located in the query request, so as to obtain the end point total count value corresponding to the first statistical period.
Step 306, querying the index structure according to a second statistical period in which the end point of the query period is located in the query request, so as to obtain a starting point total count value corresponding to the second statistical period.
Step 307, determining the number of time periods intersecting the query time period in the time period set according to the total number of time periods in the time period set, the total count value of the end point corresponding to the first statistical time period and the total count value of the start point corresponding to the second statistical time period.
Specifically, the steps 304-307 may refer to the explanation in the foregoing method embodiment, and the principles are the same, which is not repeated in this embodiment.
According to the time period query method, the time spans of the time period sets are divided equally according to the set equal division number to obtain equal division number of statistical time periods, the time period sets are counted according to the statistical time periods to obtain an index structure, the index structure is obtained by dividing the time spans of the time period sets equally, the index structure comprises a starting point total count value corresponding to each statistical time and an end point total count value corresponding to each statistical time, the number of time periods with starting time being larger than the end time of the query time period in each time period of the set can be rapidly obtained by using the starting point total count value corresponding to each statistical time according to the generated index structure, and the number of time periods with ending time being smaller than the starting time of the query time period in each time period of the set can be rapidly obtained by using the end point total count value corresponding to each statistical time, so that the number of each time period without intersecting the query time period in the set is rapidly determined, and the query efficiency is improved.
In order to implement the above embodiments, the embodiments of the present disclosure provide a time period query method, and fig. 6 is a flowchart of another time period query method provided by the embodiments of the present disclosure, which specifically illustrates how to generate a starting point total count value corresponding to each statistical period when generating an index structure. As shown in fig. 6, the step 303 includes the steps of:
In step 601, in the period set, the number of periods with the statistical starting point in each statistical period is counted.
In the embodiments of the present disclosure, description is made with reference to fig. 4 and 5. The period set includes 5 periods, and a period t r1 is taken as an example for illustration. For time period t r1 = [5,14], we calculate that the statistical period corresponding to the start point is bmin= [ (5-0)/4 ] = 2, and then add 1 to the number of periods in the statistical period corresponding to b 2. And the other time periods in the set are calculated in the same mode until all the time periods are calculated, so that the time period number of the starting point in each statistical time period in the time period set is counted. Wherein, the number of time periods shown in the group Tmin in the graph (b) in fig. 5 is the number of time periods of the starting point in each statistical time period, for example, the statistical time period b1, i.e., [0,4], and the number of time periods of the corresponding starting point is 2; b4, i.e., [12, 16], corresponds to a starting point having a period number of 2, not specifically recited herein.
Step 602, accumulating the time period number corresponding to any one of the statistical time periods and the time period number corresponding to each of the statistical time periods later than the one of the statistical time periods according to the time period number of the starting point in each of the statistical time periods, so as to obtain a first time period total number corresponding to the one of the statistical time periods.
As shown in fig. 4 and 5, regarding the number of time periods starting at each statistical time period, taking the statistical time period b1 as an example, the number of time periods corresponding to the statistical time period b1 and the number of time periods corresponding to the statistical time period after the statistical time period b1 are accumulated, that is, the numbers of time periods corresponding to b2, b3 and b4 and b1 are accumulated, so that the total number of first time periods corresponding to the statistical time period b 1=2+0+1+2=5; taking the statistical period b3 as an example, the number of periods corresponding to the statistical period b3 and the number of periods corresponding to the statistical period after the statistical period b3 are accumulated, that is, the numbers of periods corresponding to b4 and b3 are accumulated, and the total number of the first periods corresponding to the statistical period b 3=2+0=2. Not specifically listed here.
Step 603, taking the total number of the first time periods corresponding to each statistic time period as the total count value of the starting points corresponding to each statistic time period in the index structure.
The array is shown in FIG. 5 (c)The starting point total count value corresponding to each statistical period in the index structure is shown in (c), wherein the array/>, in the diagramThe arrow direction in (a) indicates the accumulation direction when the total number of the first period corresponding to each statistical period is calculated.
In the time period query method of the embodiment of the disclosure, in a time period set, counting the number of time periods of starting points in each counting time period, according to the number of time periods of starting points in each counting time period, accumulating the number of time periods corresponding to any one counting time period and the number of time periods corresponding to each counting time period later than one counting time period to obtain a first time period total number corresponding to one counting time period, taking the first time period total number corresponding to each counting time period as a starting point total count value corresponding to each counting time period in an index structure, thereby realizing rapid determination of the counting time period corresponding to the starting point of each time period in the time period set according to each counting time period, and further realizing establishment of an index data structure by accumulating accumulated values of the starting points corresponding to each counting time period in the index structure, so as to be used for rapid query of the following time period.
In order to implement the above embodiments, the embodiments of the present disclosure provide a time period query method, and fig. 7 is a flowchart of another time period query method provided by the embodiments of the present disclosure, specifically illustrating how to generate an endpoint total count value corresponding to each statistical period when generating an index structure. As shown in fig. 7, the step 303 includes the steps of:
in step 701, in the period set, the number of periods of each statistical period at the statistical end point is counted.
In the embodiments of the present disclosure, description is made with reference to fig. 4 and 5. Wherein the set includes 5 time periods, and the time period t r1 is taken as an example for illustration. For time period t r1 = [5,14], we calculate the statistical period bmax= [ (14-0)/4 ] = 4 for its end point, then add 1 to the number of periods in the statistical period corresponding to b 4. Wherein, other time periods in the set until all time periods are calculated.
And the other time periods in the set are calculated in the same mode until all the time periods are calculated, so that the time period number of the end point in each statistical time period in the time period set is counted. Wherein, the number of periods of each statistical period at the end point, i.e., the statistical period b1, i.e., [0,4], is shown in the set Tmax in the graph (b) of fig. 5, and the number of periods of the corresponding end point is 0; b4, i.e., [12, 16], corresponds to an endpoint period number of 3, not specifically recited herein.
Step 702, accumulating the time period number corresponding to any one of the statistical time periods and the time period number corresponding to each of the statistical time periods earlier than the one of the statistical time periods according to the time period number of the terminal point in each of the statistical time periods, so as to obtain a second time period total number corresponding to the one of the statistical time periods.
As shown in fig. 4 and 5, regarding the number of time periods at each statistical time period at the end point, taking the statistical time period b4 as an example, the number of time periods corresponding to the statistical time period b4 and the number of time periods corresponding to the statistical time period earlier than the statistical time period b4 are accumulated, that is, the numbers of time periods corresponding to b1, b2, b3 and b4 are accumulated, so that the total number of second time periods corresponding to the statistical time period b 4=0+1+1+3=5; taking the statistical period b3 as an example, the number of periods corresponding to the statistical period b3 and the number of periods corresponding to the statistical period earlier than the statistical period b3 are accumulated, that is, the numbers of periods corresponding to b1, b2 and b3 are accumulated, and the total number of the second periods corresponding to the statistical period b 3=0+1+1=2. Not specifically listed here.
Step 703, taking the total number of the second time periods corresponding to each statistic time period as the starting point total count value corresponding to each statistic time period in the index structure.
The array is shown in FIG. 5 (c)The final point total count value corresponding to each statistic period in the index structure is shown in (c), wherein the array/>, in the diagramThe arrow direction in (a) indicates the accumulation direction when the total number of the second period corresponding to each statistical period is calculated.
According to the time period query method, the statistical time periods corresponding to the endpoints of the time periods in the time period set are rapidly determined according to the statistical time periods, and then the accumulated values of the endpoints corresponding to the statistical time periods are accumulated and determined, namely the total count value of the endpoints corresponding to the statistical time periods in the index structure, so that the index data structure is established for rapid query of the time period.
In order to implement the above embodiment, the present disclosure further proposes a time period query device.
Fig. 8 is a schematic structural diagram of a time period query device according to an embodiment of the present disclosure.
As shown in fig. 8, the apparatus includes:
an obtaining module 81 is configured to obtain a query request of the period set.
A reading module 82 for reading the index structure; the index structure comprises a starting point total count value and an end point total count value corresponding to each statistical period; the starting point total count value is used for indicating the starting point total number of the corresponding statistical time period and a first time period which is later than the corresponding statistical time period in the time period set; and the total count value of the end points is used for indicating the total number of the end points in the period set in the corresponding statistical period and the second period earlier than the corresponding statistical period.
And the query module 83 is configured to query the index structure according to a first statistical period in which a start point of the query period is located in the query request, so as to obtain an end point total count value corresponding to the first statistical period.
The query module 83 is further configured to query the index structure according to a second statistical period in which an end point of the query period in the query request is located, so as to obtain a total count value of start points corresponding to the second statistical period.
A determining module 84, configured to determine the number of time periods intersecting the query time period in the time period set according to the total number of time periods in the time period set, the total count value of the end points corresponding to the first statistical time period, and the total count value of the start points corresponding to the second statistical time period.
Further, in an implementation of an embodiment of the disclosure, the apparatus further includes:
and the dividing module is used for dividing the time span of the time period set into equal parts according to the set equal part number so as to obtain the statistical time period of the equal part number.
And the statistics module is used for counting the time period set according to each statistics time period to obtain the index structure.
In one implementation manner of the embodiment of the disclosure, the statistics module is specifically configured to:
In the time period set, counting the time period number of the starting point in each counting time period; according to the time period number of the starting point in each statistical time period, accumulating the time period number corresponding to any one statistical time period and the time period number corresponding to each statistical time period later than the one statistical time period to obtain the total number of first time periods corresponding to the one statistical time period; and taking the total number of the first time periods corresponding to the statistical time periods as the total count value of the starting points corresponding to the statistical time periods in the index structure.
In one implementation manner of the embodiment of the disclosure, the statistics module is specifically configured to:
In the time period set, counting the time period number of the end point in each counting time period; according to the time period number of the terminal point in each statistical time period, accumulating the time period number corresponding to any one statistical time period and the time period number corresponding to each statistical time period earlier than the one statistical time period to obtain a second time period total number corresponding to the one statistical time period; and taking the total number of the second time periods corresponding to the statistical time periods as the starting point total count value corresponding to the statistical time periods in the index structure.
In one implementation of the embodiments of the present disclosure, the number of aliquots is in a forward relationship with the query accuracy of the period set.
In one implementation of the embodiment of the disclosure, the determining module 84 is specifically configured to:
Subtracting the total count value of the end point corresponding to the first statistical time period and the total count value of the start point corresponding to the second statistical time period from the total number of the time periods in the time period set to obtain the number of time periods intersecting the query time period in the time period set.
It should be noted that the foregoing explanation of the method embodiment is also applicable to the apparatus of this embodiment, and the principles are the same, and will not be repeated here.
In the time period query device of the embodiment of the disclosure, a query request of a time period set is acquired, and an index structure is read, wherein the index structure comprises a starting point total count value and an end point total count value corresponding to each statistic time period, and the starting point total count value is used for indicating the total number of starting points in the time period set in the corresponding statistic time period and a first time period which is later than the corresponding statistic time period; the method comprises the steps of inquiring an index structure according to a first statistical period where a starting point of an inquiring period in an inquiring request is located, obtaining a starting point total count value corresponding to the first statistical period, inquiring the index structure according to a second statistical period where the ending point of the inquiring period in the inquiring request is located, obtaining an end point total count value corresponding to the second statistical period, determining the number of periods intersecting the inquiring period in the period set according to the total number of the periods in the period set, the starting point total count value corresponding to the first statistical period and the end point total count value corresponding to the second statistical period, and constructing a lightweight index structure to achieve rapid acquisition of the number of the periods in the period set and improve the inquiring efficiency of the periods.
In order to achieve the above embodiments, an embodiment of the present disclosure proposes an electronic device including:
At least one processor; and a memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the preceding method embodiment.
To achieve the above embodiments, the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of the foregoing method embodiments.
To achieve the above embodiments, the disclosed embodiments propose a computer program product comprising computer instructions, which when executed by a processor implement the method of the foregoing method embodiments.
Fig. 9 is a block diagram of an electronic device 10 according to an embodiment of the present disclosure. The electronic device shown in fig. 9 is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 9, the electronic device 10 includes a processor 11 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 12 or a program loaded from a Memory 16 into a random access Memory (RAM, random Access Memory) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 are also stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An Input/Output (I/O) interface 15 is also connected to bus 14.
The following components are connected to the I/O interface 15: a memory 16 including a hard disk and the like; and a communication section 17 including a network interface card such as a LAN (local area network ) card, a modem, or the like, the communication section 17 performing communication processing via a network such as the internet; the drive 18 is also connected to the I/O interface 15 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program embodied on a computer readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from the network through the communication section 17. The above-described functions defined in the methods of the present disclosure are performed when the computer program is executed by the processor 11.
In an exemplary embodiment, a storage medium is also provided, such as a memory 16, comprising instructions executable by the processor 11 of the electronic device 10 to perform the above-described method. Alternatively, the storage medium may be a non-transitory computer readable storage medium, which may be, for example, ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present disclosure. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, the meaning of "a plurality" is at least two, such as two, three, etc., unless explicitly specified otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and additional implementations are included within the scope of the preferred embodiment of the present disclosure in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the embodiments of the present disclosure.
Logic and/or steps represented in the flowcharts or otherwise described herein, e.g., a ordered listing of executable instructions for implementing logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). In addition, the computer readable medium may even be paper or other suitable medium on which the program is printed, as the program may be electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner, if necessary, and then stored in a computer memory.
It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. As with the other embodiments, if implemented in hardware, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable Gate Arrays (PGAs), field Programmable Gate Arrays (FPGAs), and the like.
Those of ordinary skill in the art will appreciate that all or a portion of the steps carried out in the method of the above-described embodiments may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and where the program, when executed, includes one or a combination of the steps of the method embodiments.
Furthermore, each functional unit in the embodiments of the present disclosure may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product.
The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, or the like. Although embodiments of the present disclosure have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the present disclosure, and that variations, modifications, alternatives, and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the present disclosure.

Claims (13)

1. A time period query method, comprising the steps of:
acquiring a query request of a time period set;
Reading an index structure; the index structure comprises a starting point total count value and an end point total count value corresponding to each statistical period; the starting point total count value is used for indicating the starting point total number of the corresponding statistical time period and a first time period which is later than the corresponding statistical time period in the time period set; the total count value of the end points is used for indicating the total number of the end points in the time period set in the corresponding statistical time period and the second time period earlier than the corresponding statistical time period;
inquiring the index structure according to a first statistical period in which the starting point of the inquiry period is positioned in the inquiry request so as to obtain a final point total count value corresponding to the first statistical period;
inquiring the index structure according to a second statistical period in which the end point of the inquiry period in the inquiry request is positioned, so as to obtain a starting point total count value corresponding to the second statistical period;
Subtracting the total count value of the end point corresponding to the first statistical time period and the total count value of the start point corresponding to the second statistical time period from the total number of the time periods in the time period set to obtain the number of time periods intersecting the query time period in the time period set.
2. The method of claim 1, wherein prior to reading the index structure, further comprising:
dividing the time span of the time period set into equal parts according to the set equal parts to obtain the statistical time periods of the equal parts;
And counting the time period set according to each counting time period to obtain the index structure.
3. The method of claim 2, wherein said counting said set of time periods according to each of said counted time periods to obtain said index structure comprises:
In the time period set, counting the time period number of the starting point in each counting time period;
according to the time period number of the starting point in each statistical time period, accumulating the time period number corresponding to any one statistical time period and the time period number corresponding to each statistical time period later than the one statistical time period to obtain the total number of first time periods corresponding to the one statistical time period;
and taking the total number of the first time periods corresponding to the statistical time periods as the total count value of the starting points corresponding to the statistical time periods in the index structure.
4. The method of claim 2, wherein said counting said set of time periods according to each of said counted time periods to obtain said index structure comprises:
in the time period set, counting the time period number of the end point in each counting time period;
According to the time period number of the terminal point in each statistical time period, accumulating the time period number corresponding to any one statistical time period and the time period number corresponding to each statistical time period earlier than the one statistical time period to obtain a second time period total number corresponding to the one statistical time period;
And taking the total number of the second time periods corresponding to the statistical time periods as the starting point total count value corresponding to the statistical time periods in the index structure.
5. The method of claim 2, wherein the number of aliquots is in a forward relationship with the query accuracy of the set of time periods.
6. A time period query device, comprising:
the acquisition module is used for acquiring the query request of the time period set;
The reading module is used for reading the index structure; the index structure comprises a starting point total count value and an end point total count value corresponding to each statistical period; the starting point total count value is used for indicating the starting point total number of the corresponding statistical time period and a first time period which is later than the corresponding statistical time period in the time period set; the total count value of the end points is used for indicating the total number of the end points in the time period set in the corresponding statistical time period and the second time period earlier than the corresponding statistical time period;
the query module is used for querying the index structure according to a first statistical period where the starting point of the query period is located in the query request so as to obtain a final point total count value corresponding to the first statistical period;
the query module is further configured to query the index structure according to a second statistical period in which an end point of the query period in the query request is located, so as to obtain a starting point total count value corresponding to the second statistical period;
the determining module is used for subtracting the end point total count value corresponding to the first statistical time period and the start point total count value corresponding to the second statistical time period from the total number of time periods in the time period set to obtain the time period number intersecting with the query time period in the time period set.
7. The apparatus of claim 6, wherein the apparatus further comprises:
The dividing module is used for dividing the time span of the time period set into equal parts according to the set equal parts so as to obtain the statistical time periods of the equal parts;
and the statistics module is used for counting the time period set according to each statistics time period to obtain the index structure.
8. The apparatus of claim 7, wherein the statistics module is specifically configured to:
In the time period set, counting the time period number of the starting point in each counting time period;
according to the time period number of the starting point in each statistical time period, accumulating the time period number corresponding to any one statistical time period and the time period number corresponding to each statistical time period later than the one statistical time period to obtain the total number of first time periods corresponding to the one statistical time period;
and taking the total number of the first time periods corresponding to the statistical time periods as the total count value of the starting points corresponding to the statistical time periods in the index structure.
9. The apparatus of claim 7, wherein the statistics module is specifically configured to:
in the time period set, counting the time period number of the end point in each counting time period;
According to the time period number of the terminal point in each statistical time period, accumulating the time period number corresponding to any one statistical time period and the time period number corresponding to each statistical time period earlier than the one statistical time period to obtain a second time period total number corresponding to the one statistical time period;
And taking the total number of the second time periods corresponding to the statistical time periods as the starting point total count value corresponding to the statistical time periods in the index structure.
10. The apparatus of claim 7, wherein the number of aliquots is in a forward relationship with the query accuracy of the set of time periods.
11. An electronic device, comprising:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5.
12. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-5.
13. A computer program product comprising computer instructions which, when executed by a processor, implement the method of any one of claims 1-5.
CN202111146169.4A 2021-09-28 2021-09-28 Time period query method, device, electronic equipment and storage medium Active CN113779077B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111146169.4A CN113779077B (en) 2021-09-28 2021-09-28 Time period query method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111146169.4A CN113779077B (en) 2021-09-28 2021-09-28 Time period query method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113779077A CN113779077A (en) 2021-12-10
CN113779077B true CN113779077B (en) 2024-06-18

Family

ID=78854197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111146169.4A Active CN113779077B (en) 2021-09-28 2021-09-28 Time period query method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113779077B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391502A (en) * 2016-05-16 2017-11-24 阿里巴巴集团控股有限公司 The data query method, apparatus and index structuring method of time interval, device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013051101A1 (en) * 2011-10-04 2013-04-11 株式会社日立製作所 System and method for management of time-series data
CN110019218B (en) * 2017-12-08 2023-08-25 阿里巴巴集团控股有限公司 Data storage and query method and equipment
US11016971B2 (en) * 2018-01-26 2021-05-25 Vmware, Inc. Splitting a time-range query into multiple sub-queries for parallel execution
CN110704507B (en) * 2019-09-27 2020-09-29 京东城市(北京)数字科技有限公司 Method and device for storing data and method and device for querying data
CN111694839B (en) * 2020-04-28 2023-07-14 平安科技(深圳)有限公司 Time sequence index construction method and device based on big data and computer equipment
CN113326257B (en) * 2020-04-30 2023-12-15 阿里巴巴集团控股有限公司 Index construction method, recommendation method, device, electronic equipment and computer storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391502A (en) * 2016-05-16 2017-11-24 阿里巴巴集团控股有限公司 The data query method, apparatus and index structuring method of time interval, device

Also Published As

Publication number Publication date
CN113779077A (en) 2021-12-10

Similar Documents

Publication Publication Date Title
CN109657213B (en) Text similarity detection method and device and electronic equipment
CN107463482B (en) Method and device for determining index relevance
CN113779077B (en) Time period query method, device, electronic equipment and storage medium
CN117708547B (en) Method and system for processing vibration signals of steam turbine unit
CN105117489A (en) Database management method and device and electronic equipment
CN109284193B (en) Distributed data processing method based on multithreading and server
CN108463813B (en) Method and device for processing data
CN113918648A (en) Data synchronization method and device, electronic equipment and storage medium
CN114116795A (en) Data storage and query method, device, storage medium and electronic equipment
CN116706876A (en) Broadband oscillation identification method, device and equipment for dual-high power system
CN112214394A (en) Memory leak detection method, device and equipment
CN116067359A (en) Low-precision track data processing method and system based on delaunay triangle network
CN112054741B (en) Motor control method and device, terminal equipment and storage medium
CN115222900A (en) Method, device, equipment and computer program product for determining elevation of ground point
CN109995613B (en) Flow calculation method and device
CN111491060B (en) Information click log and ticket splicing method and device
CN112149696B (en) Training method and device for graph embedding model
CN111401796A (en) Method and device for establishing equipment energy efficiency model
JP6097660B2 (en) Input data aggregation processing apparatus, system and method
CN111669104B (en) Motor driving method, device, terminal and storage medium
CN108664504B (en) Method for simplifying structured data
US20130304782A1 (en) Method for searching a lookup table
CN112463125B (en) Timing method and equipment of virtual timer
CN116681767B (en) Point cloud searching method and device and terminal equipment
CN112380489B (en) Data processing time calculation method, data processing platform evaluation method and system

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
GR01 Patent grant
GR01 Patent grant