CN117632961A - Data query method, device, equipment and medium based on sustainable line segment tree - Google Patents

Data query method, device, equipment and medium based on sustainable line segment tree Download PDF

Info

Publication number
CN117632961A
CN117632961A CN202311604661.0A CN202311604661A CN117632961A CN 117632961 A CN117632961 A CN 117632961A CN 202311604661 A CN202311604661 A CN 202311604661A CN 117632961 A CN117632961 A CN 117632961A
Authority
CN
China
Prior art keywords
line segment
segment tree
sustainable
discretization
time range
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.)
Pending
Application number
CN202311604661.0A
Other languages
Chinese (zh)
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.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN202311604661.0A priority Critical patent/CN117632961A/en
Publication of CN117632961A publication Critical patent/CN117632961A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the technical field of financial science and technology, and discloses a data query method, a data query device, computer equipment and a storage medium based on a sustainable line segment tree. The method comprises the following steps: discretizing the clicking times in each sub-time range of a preset time range to obtain an index array, sequentially inserting discretization indexes in the index array into blank sustainable line segment trees according to the sequence of the sub-time ranges, storing the current blank sustainable line segment tree into an independent sustainable line segment tree each time one discretization index is inserted, obtaining a sustainable line segment tree set containing all independent sustainable line segment trees, and further selecting a target line segment tree from the sustainable line segment tree set based on query parameters to perform data query. Therefore, the invention can query the data of the target line segment tree in the sustainable line segment tree set according to the query parameters without querying the full click data, thereby achieving the purpose of improving the data query efficiency.

Description

Data query method, device, equipment and medium based on sustainable line segment tree
Technical Field
The present invention relates to the technical field of financial science and technology, and in particular, to a data query method, device, computer device and storage medium based on a sustainable line segment tree.
Background
In the financial field, more and more merchants start to put advertisements in order to improve sales of their own products, and calculate click rate of the advertisements while putting the advertisements to evaluate attraction degree of the advertisements, so as to determine whether to optimize advertisement content according to the attraction degree of the advertisements.
Currently, when calculating the click rate of an advertisement, it is required to acquire a click data set of the advertisement in a period of time, such as [ (2022-01-01, 40), (2022-01-02, 20), (2022-01-03, 30), (2022-01-04, 25), … …, (2022-05-31, 26) ], and when querying the maximum click frequency, the minimum click frequency or the maximum click frequency or the minimum click frequency in different time ranges in the click data set, it is required to perform a number query on the whole click data set, so that there is a problem of low data query efficiency.
Disclosure of Invention
The embodiment of the invention provides a data query method, a data query device, computer equipment and a storage medium based on a sustainable line segment tree, which are used for solving the problem of low data query efficiency.
A data query method based on a sustainable line segment tree, the method comprising:
acquiring click data in a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
performing discretization processing based on the click times in the sub-time ranges to obtain an index array comprising discretization indexes of each sub-time range;
constructing a blank sustainable line segment tree based on the number of the discretized indexes in the index array;
sequentially inserting discretization indexes of each sub time range into the blank sustainable line segment tree according to the sequence of each sub time range in the preset time range, and storing the current blank sustainable line segment tree as an independent sustainable line segment tree when each discretization index is inserted into the blank sustainable line segment tree, and storing all the independent sustainable line segment trees into a sustainable line segment tree set;
and carrying out data query on the target line segment tree in the sustainable line segment tree set based on the query parameters.
In the above method, optionally, the performing discretization processing based on the number of clicks in the sub-time range to obtain an index array including a discretization index of each sub-time range includes:
Sorting according to the number of clicking times in each sub-time range;
and sequentially endowing discretization indexes to the ordered click times in the sub-time range to obtain the index array.
The method, optionally, performs data query on a target line segment tree in the sustainable line segment tree set based on a query parameter, including:
acquiring the query parameters; the query parameters at least comprise a query time range and a query numerical requirement;
acquiring the sub-time range included in the query time range;
determining the target line segment tree to be queried in the sustainable line segment tree set according to the sub-time range;
and determining the target click times in the target line segment tree according to the query numerical requirement.
In the above method, optionally, the sorting mode is descending sorting; the query numerical value requirement is the Nth numerical value in the query time range;
wherein, the determining the target click times in the target line segment tree according to the query numerical requirement includes:
judging whether the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N;
If the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, traversing the discretization indexes contained in the left subtree to obtain the discretization index with the Nth small;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is smaller than N, traversing the discretization indexes contained in the right subtree of the target line segment tree to obtain the discretization indexes with the Nth small;
and acquiring target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
In the above method, optionally, the sorting mode is ascending; the query numerical value requirement is the Nth numerical value in the query time range;
wherein the determining the target value in the target line segment tree according to the query value requirement includes:
judging whether the number of the discretization indexes contained in the right subtree of the target line segment tree is greater than or equal to N;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, traversing the discretization indexes contained in the left subtree to obtain the Nth big discretization index;
If the number of the discretization indexes contained in the left subtree of the target line segment tree is smaller than N, traversing the discretization indexes contained in the right subtree of the target line segment tree to obtain the Nth big discretization index;
and acquiring target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
The method, optionally, the inquiry time range includes an upper critical time range and a lower critical time range;
the determining, according to the sub-time range, a target line segment tree to be queried for the sustainable line segment tree set includes:
determining an upper critical line segment tree to be queried of the sustainable line segment tree set according to the upper critical time range;
determining a lower critical line segment tree to be queried of the sustainable line segment tree set according to the lower critical time range;
and obtaining a target line segment tree based on the upper critical line segment tree and the lower critical line segment tree.
The method, optionally, the obtaining a target line segment tree based on the upper critical line segment tree and the lower critical line segment tree includes:
and calculating a line segment tree difference between the lower critical line segment tree and the upper critical line segment tree based on the discretization index contained in the lower critical line segment tree and the discretization index contained in the upper critical line segment tree, so as to obtain the target line segment tree.
A data querying device based on a sustainable line segment tree, the device comprising:
the click data acquisition unit is used for acquiring click data of the target advertisement in a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
the discretization processing unit is used for performing discretization processing based on the click times in the sub-time ranges to obtain an index array comprising discretization indexes of each sub-time range;
a blank line segment tree construction unit, configured to construct a blank sustainable line segment tree based on the number of the discretized indexes in the index array;
the line segment tree set acquisition unit is used for sequentially inserting discretization indexes of the sub time ranges into the blank sustainable line segment tree according to the sequence of each sub time range in the preset time range, and when each discretization index is inserted into the blank sustainable line segment tree, the current blank sustainable line segment tree is saved as an independent sustainable line segment tree, and all the independent sustainable line segment trees are saved into a sustainable line segment tree set;
And the data query unit is used for querying the data of the target line segment tree in the sustainable line segment tree set based on the query parameters.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing a data query method based on a sustainable line segment tree as described above when the computer program is executed.
A computer readable storage medium storing a computer program which when executed by a processor implements a data query method based on a sustainable line segment tree as described above.
According to the data query method, the device, the computer equipment and the storage medium based on the sustainable line segment tree, the index array of the discretization index of each sub-time range is obtained by discretizing click data in the preset time range, then a sustainable line segment tree set is constructed based on the discretization index array according to the sequence of the sub-time range in the preset time range, and further data query is performed on the target line segment tree in the sustainable line segment tree set according to query parameters. Therefore, the invention can query the data of the target line segment tree in the sustainable line segment tree set according to the query parameters without querying the data of the full click data within the preset time range every time, thereby reducing the time complexity of each data and achieving the purpose of improving the data query efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments of the present invention will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an implementation of a data query method based on a sustainable line segment tree according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a blank sustainable line segment tree according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a structure of a sustainable line segment tree in a sustainable line segment tree set according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the structure of another sustainable line segment tree in a collection of sustainable line segment trees according to one embodiment of the present invention;
FIG. 5 is a flow chart of a partial implementation of a data query method based on a sustainable line segment tree according to an embodiment of the present invention;
FIG. 6 is a flow chart of a partial implementation of a data query method based on a sustainable line segment tree according to an embodiment of the present invention;
FIG. 7 is a flow chart of a partial implementation of a data query method based on a sustainable line segment tree according to an embodiment of the present invention;
FIG. 8 is a flow chart of a partial implementation of a data query method based on a sustainable line segment tree, according to the present disclosure;
FIG. 9 is a flow chart of a partial implementation of a data query method based on a sustainable line segment tree according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a data query device based on a sustainable line segment tree according to an embodiment of the present invention.
Fig. 11 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that some, but not all embodiments of the invention are described. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In addition, in the description of the present specification and the appended claims, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the invention. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more, but not all, embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The invention discloses a data query method, a device, computer equipment and a storage medium based on a sustainable line segment tree. Therefore, the invention can query the data of the target line segment tree in the sustainable line segment tree set according to the query parameters without querying the data of the full click data within the preset time range every time, thereby reducing the time complexity of each data and achieving the purpose of improving the data query efficiency. The following is a description of specific examples.
As shown in fig. 1, the data query method based on the sustainable line segment tree disclosed in the embodiment of the invention is applicable to devices such as mobile phones, tablet computers, personal computers or servers with data processing capability. The method specifically comprises the following steps:
S101: and acquiring click data in a preset time range.
The click data comprises the click times in each sub-time range of the preset time range.
It should be understood that the click data within the preset time range in this embodiment may be the number of clicks per day in 1 month of the advertisement being placed, or the number of clicks per day in 3 months, or even the number of clicks per day in 6 months. When the data volume of the click data is huge, the data query method has obvious effect of improving the query efficiency.
In a specific implementation, the click data in this embodiment includes a date and a number of clicks corresponding to each date, that is, a key pair of the date and the number of clicks, for example: the terms [ (2022-01-01, 40), (2022-01-02, 20), (2022-01-03, 30), (2022-01-04, 25), … …, (2022-05-31, 26) ], are described in terms of (2022-01-01, 40), and (2022-01-01, 40) are a key pair of date and number of clicks, where "(2022-01-01, 40)" is a date, and "40" is number of clicks, each date is a sub-time range, and the number of clicks corresponding to each date is number of clicks of each sub-time range.
Note that the sub-time range in this embodiment may be 1 hour, 6 hours, 12 hours, 1 day, etc., and is not particularly limited in this embodiment.
S102: discretizing based on the clicking times in the sub-time ranges to obtain an index array comprising discretized indexes of each sub-time range.
In a specific implementation, in this embodiment, the number of clicks in each sub-time in the click data may be ordered, for example, in ascending order or in descending order, and then each sub-time range discretization index is sequentially given to the order of the number of clicks, so that the number of clicks may decrease with an increase in the discretization index value, or the number of clicks may increase with an increase in the discretization index value.
For example, taking click data [ (2022-01-01, 40), (2022-01-02, 20), (2022-01-03, 30), (2022-01-04, 25), (2022-01-05, 50) ] as an example, the click number is subjected to descending order to obtain [ (2022-01-05, 50), (2022-01-01, 40), (2022-01-03, 30), (2022-01-04, 25), (2022-01-02, 20) ] and then discretization indexes are sequentially given to the click data after descending order to obtain [ (2022-01-05,1), (2022-01-01,2), (2022-01-03, 3), (2022-01-04,4), (2022-01-02,5) ], thereby obtaining an index array in which the discretization indexes in the index array have a correspondence with the click number in the click data over a sub-time range.
S103: based on the number of discretized indexes in the index array, a blank sustainable line segment tree is constructed.
A blank sustainable line segment tree is constructed based on the number of discretized indexes in an index array, and comprises three attributes, namely L, R and cnt, wherein L represents a left subtree, R represents a right subtree, and cut represents the number of elements in a current value range, namely the number of elements contained in the left subtree and the right subtree of a current structure.
The blank sustainable line segment tree may be shown in fig. 2, where the numerical range displayed on each node is a numerical range of pluggable discretization indexes, for example, the node corresponding to 1-3 can be plugged with three discretization indexes of 1, 2 and 3, and when the node is not plugged with the discretization index, the number of value range elements of the node defaults to zero.
S104: according to the sequence of each sub-time range in the preset time range, sequentially inserting the discretization indexes of the sub-time ranges into the blank sustainable line segment tree, and when each discretization index is inserted into the blank sustainable line segment tree, storing the current blank sustainable line segment tree as an independent sustainable line segment tree, and storing all independent sustainable line segment trees into a sustainable line segment tree set.
Specifically, when the discretization indexes are inserted into the blank sustainable line segment tree, the discretization indexes are sequentially inserted into the blank sustainable line segment tree according to the sequence of the sub-time ranges corresponding to each discretization index in the index array, and independent sustainable line segment trees are respectively constructed. For example, taking the index array [ (2022-01-05,1), (2022-01-01,2), (2022-01-03, 3), (2022-01-04,4), (2022-01-02,5) ] as an example, wherein 2022-01-01 is a first sub-time range, then the discretized index in the first insert-blank sustainable line segment tree is 2, the blank sustainable line segment tree inserted with the discretized index 2 is marked as a first sustainable line segment tree, wherein the first sustainable line segment tree can be as shown in fig. 3, the displayed nodes are only the nodes inserted with the discretized index, and the nodes with the number of elements are not displayed; then, a discretization index 5 corresponding to 2022-01-02 is inserted into the first sustainable line segment tree, the first sustainable line segment tree inserted with the discretization index 5 is marked as a second sustainable line segment tree, as shown in fig. 4, and the like, a new sustainable line segment tree can be obtained by inserting a new discretization index, thereby obtaining a sustainable line segment tree set. It should be noted that fig. 2-4 are only exemplary illustrations in this embodiment, and are not intended to limit the specific structure of the sustainable line segment tree and the number of pluggable discretized indexes.
It should be appreciated that, according to the order of the sub-time ranges, the first sustainable line segment tree comprises one discretization index, i.e. the discretization index corresponding to the one sub-time range with the earliest time sequence, and the second sustainable line segment tree comprises two discretization indexes, i.e. the discretization index corresponding to the two sub-time ranges with the earliest time sequence, so as to obtain the sustainable line segment tree set. In addition, the elements (i.e. discretized indexes) in the first sustainable line segment tree in the sustainable line segment tree set are the least, the inquiry is the simplest, the time complexity of the inquiry is the least, the number of the elements in the second sustainable line segment tree is more than that of the first sustainable line segment tree, the inquiry time complexity of the inquiry is slightly increased compared with that of the first sustainable line segment tree, and the like, the inquiry time complexity of the last sustainable line segment tree in the sustainable line segment tree set is the highest, so the inquiry difficulty is also the greater.
S105: and carrying out data query on the target line segment tree in the sustainable line segment tree set based on the query parameters.
In a specific implementation, in this embodiment, a target line segment tree with a smaller number of elements may be selected from the sustainable line segment tree set based on the query parameter to perform data query. According to the query parameters, the sustainable line segment tree set is selected to meet the query requirement, and the sustainable line segment tree with the minimum number of elements is used for data query, so that the aim of improving the data query efficiency is fulfilled.
The invention discloses a data query method based on a sustainable line segment tree, which is characterized in that click data in a preset time range is discretized to obtain an index array of a discretization index of each sub-time range, then a sustainable line segment tree set is constructed based on the discretization index array according to the sequence of the sub-time range in the preset time range, and then data query is performed on a target line segment tree in the sustainable line segment tree set according to query parameters. Therefore, in this embodiment, the data query can be performed on the target line segment tree in the sustainable line segment tree set according to the query parameters, and the data query is not required to be performed on the full click data within the preset time range each time, so that the time complexity of each data is reduced, and the purpose of improving the data query efficiency can be achieved.
In the implementation based on fig. 1, step S102 may be implemented specifically as follows, as shown in fig. 5
S501: ordering according to the number of clicks in each sub-time range.
S502: and sequentially endowing discretization indexes to the ordered click times in the sub-time range to obtain an index array.
The sorting method in this embodiment includes ascending sorting or descending sorting according to the number of clicks, and after sorting is completed, discrete indexes corresponding to the number of clicks are sequentially assigned, if the number of clicks on different dates is the same, de-duplication processing is performed, for example, (2022-02-22, 55) and (2022-02-31, 55) are taken as examples, wherein the number of clicks of 2022-02-22 and 2022-02-31 are both 55, and then it may be noted that (2022-02-22 &2022-02-31, 55) is indicated that the number of clicks of 2022-02-22 and 2022-02-31 are both 55, and only one discrete index needs to be assigned. That is, when the sustainable line segment tree set is obtained, the repeated clicking times do not repeatedly give indexes, and therefore the indexes are not inserted into the blank sustainable line segment tree. Based on the discrete indexes, discrete indexes are sequentially given to the click times in the ordered sub-time range, and an index array is obtained.
It should be noted that, in this embodiment, different methods according to the sorting method may also result in different manners of finally performing data query based on the sustainable line segment tree set, and a process of performing data query on the target line segment tree in the sustainable line segment tree set based on the query parameter will be described below, which is not described in detail herein.
In the specific implementation based on fig. 1, step S105 may be specifically implemented by the following steps, as shown in fig. 6:
s601: query parameters are obtained.
Wherein the query parameters include at least a query time range and a query numerical requirement. Where the query time range refers to a specific time range, such as 2022-01-01 to 2022-02-30, the query number requirement may be a maximum, a minimum, or a second largest value within the query time range, etc., such as 2022-01-01 to 2022-02-30, which day the number of daily clicks is greatest, or such as what number of clicks is greatest, etc. In this embodiment, the query time range and the query numerical requirement are not particularly limited.
S602: and acquiring a sub-time range included in the query time range.
For example, the sub-time ranges may be determined according to the query time ranges in the present embodiment, for example, the query time ranges are 2022-01-01 to 2022-02-30, and then the sub-time ranges are 2022-01-01, 2022-01-02, 2022-01-03- … …, 2022-02-30. Thus, a sub-time range included in the inquiry time range can be acquired.
S603: and determining a target line segment tree to be queried in the sustainable line segment tree set according to the sub-time range.
Because the sustainable line segment tree in the sustainable line segment tree set is sequentially obtained according to the sequence of the sub-time ranges, the target line segment tree in the sustainable line segment tree set can be determined according to the sub-time ranges contained in the query time ranges.
For example, taking the click times of 2022-01-01 to 2022-01-31 as an example, a sustainable line segment tree set including 31 sustainable line segment trees can be obtained based on the click data, and when the query time range is 2022-01-01 to 2022-01-20, since the start time of the query time range is the same as the start time of the data included in the click data, the 20 th sustainable line segment tree in the sustainable line segment tree set is obtained as a target line segment tree including all the discretized indexes corresponding to 2022-01-01 to 2022-01-20.
S604: and determining the target click times in the target line segment tree according to the query numerical requirement.
The target line segment tree selected at this time only contains discretization indexes corresponding to 2022-01-01 to 2022-01-20, and is not a full-scale discretization index, so that the target click times in the target line segment tree are determined according to the query numerical requirement, and the purpose of improving the search efficiency can be achieved.
In the specific implementation based on fig. 6, step S604 may be specifically implemented by the following steps, as shown in fig. 7:
specifically, in this embodiment, the sorting manner of the clicking times is descending sorting, and when the query value requirement is the nth largest value in the query time range, step S604 may be implemented based on the following steps:
s701: and judging whether the number of discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N.
If the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, executing step S701, namely traversing the discretization indexes contained in the left subtree to obtain the N-th small discretization index; if the number of discretization indexes contained in the left subtree of the target line segment tree is smaller than N, step S702 is executed, i.e. the discretization index contained in the right subtree is traversed, and the nth smallest discretization index is obtained.
In a specific implementation, since the order of the number of clicks is descending order, after the discretization index corresponding to each number of clicks is given, the value of the discretization index is smaller, and the larger the value of the corresponding number of clicks is, as shown in fig. 1, the value of the left subtree of the sustainable line segment tree is smaller than the value of the left subtree, so when the number of discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, the number of target clicks is necessarily present in the left subtree, so the left subtree of the target line segment tree is traversed, that is, step S702 is executed, and when the number of discretization indexes contained in the left subtree of the target line segment tree is smaller than N, the number of target clicks is necessarily present in the right subtree, so the right subtree of the target line segment tree is traversed, that is step S703 is executed.
S702: and traversing the discretization index contained in the left subtree to obtain the Nth small discretization index.
S703: and traversing the discretization index contained in the right subtree of the target line segment tree to obtain the Nth small discretization index.
It should be noted that, when the number of discretization indexes included in the left subtree of the target line segment tree is smaller than N and the right subtree needs to be traversed, the number of discretization indexes in the left subtree of the target line segment tree needs to be considered, because the value of the discretization index in the left subtree must be smaller than the value of the discretization index in the right subtree, and therefore, when the right subtree is traversed, the number of the discretization indexes in the left subtree needs to be subtracted from N.
For example, taking N as 9 as an example, the number of discretization indexes in the left subtree of the target line segment tree is 7, where N is greater than 7, so when the ninth largest click frequency of the target line segment tree is obtained, the 2 nd smallest discretization index in the right subtree of the target line segment tree needs to be traversed, that is, N-7=2, so as to obtain the N small discretization index in the target line segment tree.
S704: and obtaining the target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
It should be understood that in the process of obtaining the index array, a mapping relationship between the discretization index and the clicking times exists based on the sub-time range, so that the corresponding clicking times are mapped according to the discretization index, and the clicking times obtained by mapping are the target clicking times.
In summary, the size of the N value in this embodiment may further reduce the query unit in the target line segment tree, thereby further improving the data query efficiency.
In the specific implementation based on fig. 6, step S604 may also be implemented by the following steps, as shown in fig. 8:
specifically, in this embodiment, the sorting manner of the clicking times is ascending sorting, and when the query value requirement is the nth largest value in the query time range, step S604 may be implemented based on the following steps:
s801: and judging whether the number of discretization indexes contained in the right subtree of the target line segment tree is greater than or equal to N.
If the number of the discretization indexes contained in the right subtree of the target line segment tree is greater than or equal to N, executing step S801, namely traversing the discretization indexes contained in the right subtree to obtain the Nth large discretization index; if the number of discretization indexes contained in the right subtree of the target line segment tree is smaller than N, step S802 is executed, that is, the discretization index contained in the left subtree is traversed, and the nth largest discretization index is obtained.
In a specific implementation, since the order of the number of clicks is ascending order, after the discretization index corresponding to each number of clicks is given, the larger the value of the discretization index is, the larger the value of the corresponding number of clicks is, as shown in fig. 1, the smaller the value of the left subtree of the sustainable line segment tree is, so when the number of discretization indexes contained in the right subtree of the target line segment tree is greater than or equal to N, the number of target clicks is necessarily present in the right subtree, so the left subtree of the target line segment tree is traversed, that is, step S802 is performed, and when the number of discretization indexes contained in the right subtree of the target line segment tree is less than N, the number of target clicks is necessarily present in the left subtree, so the left subtree of the target line segment tree is traversed, that is, step S803 is performed.
S802: and traversing the discretization index contained in the right subtree to obtain the Nth large discretization index.
S803: and traversing the discretization index contained in the left subtree of the target line segment tree to obtain the Nth large discretization index.
It should be noted that, when the number of discretization indexes included in the right subtree of the target line segment tree is smaller than N and the left subtree needs to be traversed, the number of discretization indexes in the right subtree of the target line segment tree needs to be considered, because the value of the discretization index in the right subtree must be larger than the value of the discretization index in the right subtree, and therefore, when the left subtree is traversed, the number of the discretization indexes in the right subtree needs to be subtracted from N.
For example, taking N as 9 as an example, the number of discretization indexes in the right subtree of the target line segment tree is 7, where N is greater than 7, so when the 9 th largest click number of the target line segment tree is obtained, the 2 nd largest discretization index in the left subtree of the target line segment tree needs to be traversed, that is, N-7=2, so that the N small discretization index in the target line segment tree can be obtained.
S804: and obtaining the target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
It should be understood that in the process of obtaining the index array, a mapping relationship between the discretization index and the clicking times exists based on the sub-time range, so that the corresponding clicking times are mapped according to the discretization index, and the clicking times obtained by mapping are the target clicking times.
In summary, the size of the N value in this embodiment may further reduce the query unit in the target line segment tree, thereby further improving the data query efficiency.
In the specific implementation based on fig. 6, step S603 may be specifically implemented by the following steps, as shown in fig. 9:
in a specific implementation, the query time range in the present embodiment includes an upper critical time range and a lower critical time range. For example, the query time ranges 2022-01-05 to 2022-01-20 are exemplified, wherein 2022-01-05 is an upper critical time range and 2022-01-20 is a lower critical time range. Based on the upper critical time range and the lower critical time range, step S603 in the present embodiment may be implemented by:
s901: and determining an upper critical line segment tree to be queried for the sustainable line segment tree set according to the upper critical time range.
S902: and determining a lower critical line segment tree to be queried for the sustainable line segment tree set according to the lower critical time range.
S903: and obtaining a target line segment tree based on the upper critical line segment tree and the lower critical line segment tree.
And determining an upper critical line segment tree to be queried for the sustainable line segment tree set according to the upper critical time range, determining a lower critical line segment tree to be queried for the sustainable line segment tree set according to the lower critical time range, and then obtaining a target line segment tree based on difference between the lower critical line segment tree and the upper critical line segment tree.
For example, taking the example that the preset time range of the click data is 2022-01-01 to 2022-01-31, the query time range is 2022-01-05 to 2022-01-20, then the fourth sustainable line segment tree in the sustainable line segment tree set is determined to be the upper critical node number according to the upper critical time range 2022-01-05, and the twentieth sustainable line segment tree in the sustainable line segment tree set is determined to be the lower critical node number according to the lower critical time range 2022-01-20. It should be appreciated that the twentieth sustainable line segment tree must include the discretized index in the fourth sustainable line segment tree, and thus the discretized index in the fourth sustainable line segment tree is subtracted from the twentieth sustainable line segment tree to obtain the target line segment tree, and thus only the discretized indexes corresponding to 2022-01-05 to 2022-01-20 are included in the target line segment tree.
In summary, in this embodiment, the target broken tree including only the discretized index within the query time range is obtained by making a difference between the sustainable line segment trees, so that a complex data screening process is avoided, a required target line segment tree can be obtained quickly, and the search efficiency is improved.
In one implementation, step S903 may be implemented based on the following:
And calculating the line segment tree difference of the lower critical line segment tree and the upper critical line segment tree based on the discretization index contained in the lower critical line segment tree and the discretization index contained in the upper critical line segment tree to obtain the target line segment tree.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present invention.
Fig. 10 is a schematic structural diagram of a data query device based on a sustainable line segment tree according to an embodiment of the present invention, where the device is suitable for a mobile phone, a tablet computer, a personal computer, or a server with data processing capability.
Specifically, the apparatus in this embodiment may specifically include the following units:
a click data acquisition unit 1001, configured to acquire click data of a target advertisement within a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
a discretization processing unit 1002, configured to perform discretization processing based on the number of clicks in the sub-time range, to obtain an index array including discretization indexes of each sub-time range;
A blank line segment tree construction unit 1003, configured to construct a blank sustainable line segment tree based on the number of discretized indexes in the index array;
a line segment tree set obtaining unit 1004, configured to insert discretization indexes of sub-time ranges into blank sustainable line segment trees in sequence according to the sequence of each sub-time range in a preset time range, and when each discretization index is inserted into a blank sustainable line segment tree, store the current blank sustainable line segment tree as an independent sustainable line segment tree, and store all independent sustainable line segment trees into a sustainable line segment tree set;
the data query unit 1005 is configured to perform a data query on a target line segment tree in the sustainable line segment tree set based on the query parameters.
In one implementation, discretization processing unit 1002 may be configured to:
sorting according to the number of clicking times in each sub-time range;
and sequentially endowing discretization indexes to the ordered click times in the sub-time range to obtain an index array.
In one implementation, the data query unit 1005 may be configured to:
acquiring query parameters; the query parameters at least comprise a query time range and a query numerical requirement;
Acquiring a sub-time range included in a query time range;
determining a target line segment tree to be queried in the sustainable line segment tree set according to the sub-time range;
and determining the target click times in the target line segment tree according to the query numerical requirement.
In one implementation, the manner of ordering is a descending order ordering; the query value requirement is the Nth big value in the query time range; the data query unit 1005 may also be configured to:
judging whether the number of discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, traversing the discretization indexes contained in the left subtree to obtain the N-th small discretization index;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is smaller than N, traversing the discretization indexes contained in the right subtree of the target line segment tree to obtain the N-th small discretization index;
and obtaining the target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
In one implementation, the ordering is in ascending order; the query value requirement is the Nth big value in the query time range; the data query unit 1005 may also be configured to:
Judging whether the number of discretization indexes contained in the right subtree of the target line segment tree is greater than or equal to N;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, traversing the discretization indexes contained in the left subtree to obtain an Nth large discretization index;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is smaller than N, traversing the discretization indexes contained in the right subtree of the target line segment tree to obtain the Nth large discretization index;
and obtaining the target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
In one implementation, the query time range includes an upper critical time range and a lower critical time range; the data query unit 1005 may also be configured to:
determining an upper critical line segment tree to be queried of a sustainable line segment tree set according to the upper critical time range;
determining a lower critical line segment tree to be queried of a sustainable line segment tree set according to the lower critical time range;
and obtaining a target line segment tree based on the upper critical line segment tree and the lower critical line segment tree.
In one implementation, the data query unit 1005 may also be configured to:
And calculating the line segment tree difference of the lower critical line segment tree and the upper critical line segment tree based on the discretization index contained in the lower critical line segment tree and the discretization index contained in the upper critical line segment tree to obtain the target line segment tree.
For a specific limitation of the data query device based on the sustainable line segment tree, reference may be made to the above related limitation of the data query method based on the sustainable line segment tree, and the description thereof will not be repeated here. The above-described modules in the sustainable line segment tree-based data query apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is disclosed, which may be a server, and its internal structure may be as shown in fig. 11. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a data query method based on a sustainable line segment tree.
In one embodiment, a computer device is provided comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of when executing the computer program:
acquiring click data in a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
performing discretization processing based on the click times in the sub-time ranges to obtain an index array comprising discretization indexes of each sub-time range;
constructing a blank sustainable line segment tree based on the number of discretized indexes in the index array;
according to the sequence of each sub-time range in the preset time range, sequentially inserting discretization indexes of the sub-time ranges into the blank sustainable line segment tree, and when each discretization index is inserted into the blank sustainable line segment tree, storing the current blank sustainable line segment tree as an independent sustainable line segment tree, and storing all independent sustainable line segment trees into a sustainable line segment tree set;
and carrying out data query on the target line segment tree in the sustainable line segment tree set based on the query parameters.
In one embodiment, a computer-readable storage medium is disclosed, which when executed by a processor in a computer device, causes the computer device to perform the steps of any of the embodiments of a data query method based on a sustainable line segment tree as disclosed herein. The computer readable storage medium may be nonvolatile or may be volatile.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
acquiring click data in a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
performing discretization processing based on the click times in the sub-time ranges to obtain an index array comprising discretization indexes of each sub-time range;
constructing a blank sustainable line segment tree based on the number of discretized indexes in the index array;
according to the sequence of each sub-time range in the preset time range, sequentially inserting discretization indexes of the sub-time ranges into the blank sustainable line segment tree, and when each discretization index is inserted into the blank sustainable line segment tree, storing the current blank sustainable line segment tree as an independent sustainable line segment tree, and storing all independent sustainable line segment trees into a sustainable line segment tree set;
And carrying out data query on the target line segment tree in the sustainable line segment tree set based on the query parameters.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (10)

1. A data query method based on a sustainable line segment tree, the method comprising:
acquiring click data in a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
Performing discretization processing based on the click times in the sub-time ranges to obtain an index array comprising discretization indexes of each sub-time range;
constructing a blank sustainable line segment tree based on the number of the discretized indexes in the index array;
sequentially inserting discretization indexes of each sub time range into the blank sustainable line segment tree according to the sequence of each sub time range in the preset time range, and storing the current blank sustainable line segment tree as an independent sustainable line segment tree when each discretization index is inserted into the blank sustainable line segment tree, and storing all the independent sustainable line segment trees into a sustainable line segment tree set;
and carrying out data query on the target line segment tree in the sustainable line segment tree set based on the query parameters.
2. A data query method based on a sustainable line segment tree according to claim 1, wherein said discretizing based on said number of clicks in said sub-time ranges results in an index array comprising discretized indexes for each of said sub-time ranges, comprising:
Sorting according to the number of clicking times in each sub-time range;
and sequentially endowing discretization indexes to the ordered click times in the sub-time range to obtain the index array.
3. A data query method based on a sustainable line segment tree according to claim 1, wherein said querying a target line segment tree in said sustainable line segment tree set based on query parameters comprises:
acquiring the query parameters; the query parameters at least comprise a query time range and a query numerical requirement;
acquiring the sub-time range included in the query time range;
determining the target line segment tree to be queried in the sustainable line segment tree set according to the sub-time range;
and determining the target click times in the target line segment tree according to the query numerical requirement.
4. A data query method based on a sustainable line segment tree as claimed in claim 2 or 3, wherein the ordering is in a descending order; the query numerical value requirement is the Nth numerical value in the query time range;
wherein, the determining the target click times in the target line segment tree according to the query numerical requirement includes:
Judging whether the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, traversing the discretization indexes contained in the left subtree to obtain the discretization index with the Nth small;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is smaller than N, traversing the discretization indexes contained in the right subtree of the target line segment tree to obtain the discretization indexes with the Nth small;
and acquiring target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
5. A data query method based on a sustainable line segment tree as claimed in claim 2 or 3, wherein the ordering is in ascending order; the query numerical value requirement is the Nth numerical value in the query time range;
wherein the determining the target value in the target line segment tree according to the query value requirement includes:
judging whether the number of the discretization indexes contained in the right subtree of the target line segment tree is greater than or equal to N;
If the number of the discretization indexes contained in the left subtree of the target line segment tree is greater than or equal to N, traversing the discretization indexes contained in the left subtree to obtain the Nth big discretization index;
if the number of the discretization indexes contained in the left subtree of the target line segment tree is smaller than N, traversing the discretization indexes contained in the right subtree of the target line segment tree to obtain the Nth big discretization index;
and acquiring target click times according to the discretization index and the mapping relation of the click times based on the sub-time range.
6. A sustainable line segment tree based data query method according to claim 3, wherein the query time range comprises an upper critical time range and a lower critical time range;
the determining, according to the sub-time range, a target line segment tree to be queried for the sustainable line segment tree set includes:
determining an upper critical line segment tree to be queried of the sustainable line segment tree set according to the upper critical time range;
determining a lower critical line segment tree to be queried of the sustainable line segment tree set according to the lower critical time range;
And obtaining a target line segment tree based on the upper critical line segment tree and the lower critical line segment tree.
7. The method for querying data based on a sustainable line segment tree according to claim 6, wherein the obtaining a target line segment tree based on the upper critical line segment tree and the lower critical line segment tree comprises:
and calculating a line segment tree difference between the lower critical line segment tree and the upper critical line segment tree based on the discretization index contained in the lower critical line segment tree and the discretization index contained in the upper critical line segment tree, so as to obtain the target line segment tree.
8. A data query device based on a sustainable line segment tree, the device comprising:
the click data acquisition unit is used for acquiring click data of the target advertisement in a preset time range; the click data comprises the click times in each sub-time range of the preset time range;
the discretization processing unit is used for performing discretization processing based on the click times in the sub-time ranges to obtain an index array comprising discretization indexes of each sub-time range;
a blank line segment tree construction unit, configured to construct a blank sustainable line segment tree based on the number of the discretized indexes in the index array;
The line segment tree set acquisition unit is used for sequentially inserting discretization indexes of the sub time ranges into the blank sustainable line segment tree according to the sequence of each sub time range in the preset time range, and when each discretization index is inserted into the blank sustainable line segment tree, the current blank sustainable line segment tree is saved as an independent sustainable line segment tree, and all the independent sustainable line segment trees are saved into a sustainable line segment tree set;
and the data query unit is used for querying the data of the target line segment tree in the sustainable line segment tree set based on the query parameters.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements a data query method based on a sustainable line segment tree as claimed in any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium storing a computer program, which when executed by a processor implements a data query method based on a sustainable line segment tree as claimed in any one of claims 1 to 7.
CN202311604661.0A 2023-11-27 2023-11-27 Data query method, device, equipment and medium based on sustainable line segment tree Pending CN117632961A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311604661.0A CN117632961A (en) 2023-11-27 2023-11-27 Data query method, device, equipment and medium based on sustainable line segment tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311604661.0A CN117632961A (en) 2023-11-27 2023-11-27 Data query method, device, equipment and medium based on sustainable line segment tree

Publications (1)

Publication Number Publication Date
CN117632961A true CN117632961A (en) 2024-03-01

Family

ID=90028228

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311604661.0A Pending CN117632961A (en) 2023-11-27 2023-11-27 Data query method, device, equipment and medium based on sustainable line segment tree

Country Status (1)

Country Link
CN (1) CN117632961A (en)

Similar Documents

Publication Publication Date Title
US11562012B2 (en) System and method for providing technology assisted data review with optimizing features
CN110321408B (en) Searching method and device based on knowledge graph, computer equipment and storage medium
US9135572B2 (en) Method and arrangement for processing data
CN108021673A (en) A kind of user interest model generation method, position recommend method and computing device
CN110363580B (en) Information recommendation method and device, computer equipment and storage medium
Borgs et al. Multiscale matrix sampling and sublinear-time PageRank computation
CN109388634A (en) Processing method, terminal device and the computer readable storage medium of address information
CN112070550A (en) Keyword determination method, device and equipment based on search platform and storage medium
CN105677645A (en) Data sheet comparison method and device
CN112632395A (en) Search recommendation method and device, server and computer-readable storage medium
CN117312657A (en) Abnormal function positioning method and device for financial application, computer equipment and medium
CN117632961A (en) Data query method, device, equipment and medium based on sustainable line segment tree
US20190087387A1 (en) Method and system for asynchronous correlation of data entries in spatially separated instances of heterogenous databases
CN113010550B (en) Batch object generation and batch processing method and device for structured data
CN112016017A (en) Method and device for determining characteristic data
CN111639099A (en) Full-text indexing method and system
Vu et al. On the initial value problem for random fuzzy differential equations with Riemann-Liouville fractional derivative: Existence theory and analytical solution
CN118013026B (en) Query result display method and related device
CN115309870B (en) Knowledge acquisition method and device
CN108829874A (en) A kind of information methods of exhibiting and show device
CN114780561A (en) Entity attribute editing method and device, computer equipment and storage medium
CN116881543A (en) Financial resource object recommendation method, device, equipment, storage medium and product
CN113987322A (en) Index data query method and device, computer equipment and computer program product
CN117130708A (en) Application program language switching method, device, computer equipment and storage medium
CN118133044A (en) Problem extension method, device, computer equipment, storage medium and product

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