Method, apparatus and medium for modifying grid index of spatial data set
By adjusting the size and number of intervals and dynamically adjusting the grid index, the problem of uneven data items after data updates is solved, index efficiency and performance are improved, and stable querying of spatial datasets under data update conditions is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2026-03-31
AI Technical Summary
After spatial data updates, the number of data items in the grid of an existing grid index becomes uneven, resulting in slow index query speed and low efficiency, which affects index performance.
By adjusting the size and number of intervals, the grid index is dynamically adjusted, and interval splitting, balancing, or merging operations are used to construct a B-tree index to adapt to the spatial dataset after data updates, ensuring that data items are evenly distributed within each interval.
It improves the indexing efficiency and performance of spatial datasets after data updates, maintains stable indexing performance, and mitigates fluctuations in the number of data items by dynamically adjusting the number of intervals and data items.
Smart Images

Figure CN120849728B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of spatial dataset indexing technology, and in particular to a method, apparatus, device, and medium for modifying the grid index of a spatial dataset. Background Technology
[0002] Spatial indexes can improve the efficiency of spatial data retrieval. Commonly used spatial indexes include R-tree indexes, grid indexes, and other indexing methods. Among them, grid indexes divide the space into uniformly sized grids, with each grid containing the same number of data items. When querying data, the specific grid is located first, and then the data items that meet the query conditions are searched within the grid.
[0003] However, when spatial data is updated, the data items in the spatial data change, which may cause a serious skew in the number of data items in the originally evenly divided grid. That is, some grids have too many data items and some grids have too few data items. This results in slow index query speed and low index efficiency when indexing the updated spatial data, affecting index performance. Summary of the Invention
[0004] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a method, apparatus, device, and medium for modifying the grid index of a spatial dataset, which can automatically adjust the size and number of intervals to adapt to the spatial dataset after data updates, thereby improving indexing efficiency and maintaining stable indexing performance during spatial data updates.
[0005] In a first aspect, embodiments of the present invention provide a method for modifying the grid index of a spatial dataset, comprising:
[0006] A first spatial dataset is obtained, grid partitioning parameters are determined based on the first spatial dataset, the first spatial dataset is divided into multiple first intervals based on the grid partitioning parameters, and multiple first B-tree indexes are obtained by constructing indexes based on all the first intervals. The first spatial dataset includes multiple first data items, the grid partitioning parameters include the number of first intervals and the data volume of the first interval, the data volume of the first interval is the total number of all the first data items in the first interval, and the number of first data items in each first interval is the same.
[0007] The first spatial dataset is updated to obtain a second spatial dataset. The second interval data volume is determined based on the second spatial dataset. The second spatial dataset includes multiple second data items. The second interval data volume is the number of second data items in each interval obtained by uniformly dividing all the second data items.
[0008] Based on any of the first intervals, the index of the first B-tree index is modified based on the data volume of the second interval and the data volume of the third interval to obtain at least one second B-tree index. Based on the data volume of the second interval and the data volume of the third interval, the first interval is adjusted to obtain at least one second interval. The data volume of the third interval is the number of second data items in the first interval. The interval adjustment includes interval splitting operation, interval balancing operation and interval merging operation.
[0009] According to some embodiments of the present invention, a first spatial dataset is obtained, grid partitioning parameters are determined based on the first spatial dataset, the first spatial dataset is divided into multiple first intervals based on the grid partitioning parameters, and multiple first B-tree indexes are obtained by constructing indexes based on all the first intervals, including:
[0010] Obtain all the first data items, and sort all the first data items from smallest to largest based on the first dimension value to obtain a first spatial data sequence, wherein the first data item includes the first dimension value and the second dimension value;
[0011] The grid partitioning parameters are determined based on the first spatial data sequence and the first formula. Based on the first spatial data sequence, m-1 first dimension values are obtained at intervals of the first interval data amount to form an interval boundary sequence. The first spatial dataset is partitioned into multiple first intervals based on the interval boundary sequence, wherein the first interval includes multiple first data items.
[0012] Based on any of the first intervals, obtain all the first data items of the first interval, and construct an index based on the second dimension values of all the first data items to obtain the first B-tree index;
[0013] The expression for the first spatial dataset is: D is the first spatial dataset, d n Let N be the nth first data item in the first spatial dataset, where n is a positive integer and N is the number of first data items in the first spatial dataset. The expression for the first data item is: , The first dimension value of the nth first data item in the first spatial dataset. Let the second dimension value be the nth first data item in the first spatial dataset, and the expression for the first spatial data sequence be: , The first spatial data sequence, For the i-th first data item in the first spatial data sequence, x iLet y be the first dimension value of the i-th first data item in the first spatial data sequence. i Let N be the second dimension value of the i-th first data item in the first spatial data sequence. The expression of the first formula is: N = m × k, where m is the number of the first intervals, k is the data volume of the first interval, and both m and k are positive integers. The expression of the interval boundary sequence is: P is the interval boundary sequence. Let ik be the first dimension value of the first spatial data sequence.
[0014] According to some embodiments of the present invention, the first spatial dataset is updated to obtain a second spatial dataset, and the data volume of the second interval is determined based on the second spatial dataset, including:
[0015] The first spatial dataset is updated to obtain the second spatial dataset, and the data volume of the first interval is updated to obtain the data volume of the third interval.
[0016] The second interval data volume is determined based on the second spatial dataset and the second formula, and a first threshold is determined based on the second interval data volume, wherein the expression of the second formula is: , This represents the data volume for the second interval. The first threshold is the total number of all the second data items, and is associated with the amount of data in the second interval. The first threshold is a positive integer.
[0017] According to some embodiments of the present invention, based on any first interval, the index of the first B-tree index is modified based on the data volume of the second interval and the data volume of the third interval to obtain at least one second B-tree index; the first interval is adjusted based on the data volume of the second interval and the data volume of the third interval to obtain at least one second interval, including:
[0018] Based on any of the first intervals, the data volume of the third interval is compared with the first threshold. When the data volume of the third interval is greater than the first threshold, the first B-tree index of the first interval is split to obtain two second B-tree indexes, wherein the expression of the first interval is: , For the i-th first interval of the first spatial dataset, For the (i-1)th first dimension value in the interval boundary sequence, This is the left boundary of the first interval. For the i-th value of the first dimension in the interval boundary sequence, The first B-tree index is the right boundary of the first interval. The first B-tree index includes multiple first index terms. In the second spatial dataset, one first index term corresponds to one second data term. The second B-tree index includes multiple second index terms. The number of second index terms in two second B-tree indexes is the same. The sum of the number of second index terms in two second B-tree indexes is equal to the number of first index terms in the first B-tree index.
[0019] Obtain the interval boundary sequence, add a boundary value between the left and right boundaries of the first interval, and obtain two second intervals based on the first interval, wherein the expressions of the two second intervals are as follows: and , Let t be a second interval, and t be the boundary value. This is another second interval.
[0020] According to some embodiments of the present invention, after comparing the amount of data in the third interval with the first threshold, the method further includes:
[0021] When the amount of data in the third interval is less than or equal to the first threshold, a second threshold and a third threshold are determined based on the amount of data in the second interval, wherein the first threshold is greater than the sum of the second threshold and the third threshold, the second threshold is less than the amount of data in the second interval, the amount of data in the second interval is less than the third threshold, and both the second threshold and the third threshold are positive integers;
[0022] Based on any of the first intervals, when the data volume of the third interval is less than the second threshold, the data volume of the third interval in the adjacent intervals of the first interval is obtained, and the data volume of the third interval in the adjacent intervals is compared with the third threshold. The adjacent intervals are located to the left or right of the first interval, and the expression for the adjacent intervals is: or , The adjacent interval located to the left of the first interval. The left boundary of the adjacent interval located to the left of the first interval. The right boundary of the adjacent interval located to the left of the first interval. The adjacent interval located to the right of the first interval. The left boundary of the adjacent interval located to the right of the first interval. The right boundary of the adjacent interval located to the right of the first interval;
[0023] When the amount of data in the third interval of the adjacent interval is greater than the third threshold, an interval balancing operation is performed on the first interval and the adjacent interval; or, when the amount of data in the third interval of the adjacent interval is less than or equal to the third threshold, an interval merging operation is performed on the first interval and the adjacent interval.
[0024] According to some embodiments of the present invention, when the data volume of the third interval in the adjacent intervals is greater than the third threshold, an interval balancing operation is performed on the first interval and the adjacent intervals, including:
[0025] When the amount of data in the third interval of the adjacent interval is greater than the third threshold, a balanced data amount is determined based on the amount of data in the third interval of the first interval and the amount of data in the third interval of the adjacent interval, wherein the second data item corresponding to the balanced data amount is located in the adjacent interval;
[0026] Obtain the first B-tree index of the first interval and the first B-tree index of the adjacent interval; delete the first index item corresponding to the balanced data volume from the first B-tree index of the adjacent interval to obtain the second B-tree index of the adjacent interval; add the first index item corresponding to the balanced data volume to the first B-tree index of the first interval to obtain the second B-tree index of the first interval; wherein the number of second index items in the second B-tree index of the adjacent interval is the same as the number of second index items in the second B-tree index of the first interval.
[0027] Obtain the interval boundary sequence. When the adjacent interval is to the left of the first interval, decrease the value of the right boundary of the adjacent interval and increase the value of the left boundary of the first interval to obtain two second intervals. Alternatively, when the adjacent interval is to the right of the first interval, increase the value of the left boundary of the adjacent interval and decrease the value of the right boundary of the first interval to obtain two second intervals.
[0028] According to some embodiments of the present invention, when the data volume of the third interval of the adjacent intervals is less than or equal to the third threshold, an interval merging operation is performed on the first interval and the adjacent intervals, including:
[0029] When the amount of data in the third interval of the adjacent interval is less than or equal to the third threshold, the first B-tree index of the first interval and the first B-tree index of the adjacent interval are obtained, all the first index entries of the first B-tree index of the adjacent interval are deleted, and all the first index entries of the first B-tree index of the adjacent interval are added to the first B-tree index of the first interval to obtain the second B-tree index of the first interval.
[0030] Obtain the interval boundary sequence. When the adjacent interval is to the left of the first interval, delete the right boundary of the adjacent interval in the interval boundary sequence to obtain the second interval. Alternatively, when the adjacent interval is to the right of the first interval, delete the left boundary of the adjacent interval in the interval boundary sequence to obtain the second interval.
[0031] In a second aspect, embodiments of the present invention provide an apparatus for modifying the grid index of a spatial dataset, comprising at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, the instructions being executed by the at least one control processor to enable the at least one control processor to perform the method for modifying the grid index of a spatial dataset as described in the first aspect above.
[0032] Thirdly, embodiments of the present invention provide an electronic device including a device for modifying the grid index of a spatial dataset as described in the second aspect above.
[0033] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions for performing a method for modifying the grid index of a spatial dataset as described in the first aspect above.
[0034] The method for modifying the grid index of a spatial dataset according to embodiments of the present invention has at least the following beneficial effects: A first spatial dataset is obtained; grid partitioning parameters are determined based on the first spatial dataset; the first spatial dataset is divided into multiple first intervals based on the grid partitioning parameters; multiple first B-tree indexes are constructed based on all the first intervals; wherein the first spatial dataset includes multiple first data items; the grid partitioning parameters include the number of first intervals and the data volume of the first intervals; the data volume of the first intervals is the total number of all first data items in the first intervals; and the number of first data items in each first interval is the same; the first spatial dataset is updated to obtain a second spatial dataset. The second interval data volume is determined based on the second spatial dataset, wherein the second spatial dataset includes multiple second data items, and the second interval data volume is the number of second data items in each interval obtained by uniformly dividing all the second data items; based on any first interval, the first B-tree index is modified based on the second interval data volume and the third interval data volume to obtain at least one second B-tree index, and the first interval is adjusted based on the second interval data volume and the third interval data volume to obtain at least one second interval, wherein the third interval data volume is the number of second data items in the first interval, and the interval adjustment includes interval splitting operation, interval balancing operation, or interval merging operation. According to the technical solution of the present invention, after the first spatial dataset is updated, the distribution of the second data items in the second spatial dataset is uneven in each first interval. The first B-tree index is modified based on the data volume of the second interval and the data volume of the third interval to obtain the second B-tree index. The first interval is adjusted based on the data volume of the second interval and the data volume of the third interval to obtain the second interval. Thus, the size of the first interval in the second spatial dataset is adjusted to obtain the second interval. The number of intervals and the number of data items within the intervals are dynamically adjusted based on the change in the number of data items. More intervals are used to divide the data in the sparse and dense parts of the second spatial dataset, and fewer intervals are used to divide the data in the sparse parts of the second spatial dataset. This achieves adaptive adjustment of the interval division in the second spatial dataset and dynamic adjustment of the number of data items within the intervals, alleviating the large fluctuations in the number of data items in the spatial dataset and keeping the number of data items in each interval of the second spatial dataset within a balanced range. This improves the indexing efficiency of the updated second spatial dataset in the data update state and maintains stable indexing performance. Attached Figure Description
[0035] Figure 1 This is a flowchart of a method for modifying the grid index of a spatial dataset according to an embodiment of the present invention;
[0036] Figure 2 This is a structural diagram of a device for modifying the grid index of a spatial dataset provided in another embodiment of the present invention. Detailed Implementation
[0037] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0038] In the description of this invention, it should be understood that the orientation descriptions, such as up, down, front, back, left, right, etc., are based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting this invention.
[0039] In the description of this invention, "several" means one or more, "multiple" means two or more, "greater than," "less than," and "exceeding" are understood to exclude the stated number, while "above," "below," and "within" are understood to include the stated number. The use of "first" and "second" in the description is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the order of the indicated technical features.
[0040] In the description of this invention, unless otherwise explicitly defined, terms such as "set up," "install," and "connect" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.
[0041] This invention provides a method, apparatus, device, and medium for modifying the grid index of a spatial dataset. The method includes: acquiring a first spatial dataset; determining grid partitioning parameters based on the first spatial dataset; dividing the first spatial dataset into multiple first intervals based on the grid partitioning parameters; and constructing multiple first B-tree indexes based on all first intervals. The first spatial dataset includes multiple first data items, and the grid partitioning parameters include the number of first intervals and the data volume of each first interval. The data volume of each first interval is the total number of first data items in that interval, and the number of first data items is the same in each first interval. The first spatial dataset is then processed... The second spatial dataset is updated to obtain a second spatial dataset. Based on the second spatial dataset, the data volume of the second interval is determined. The second spatial dataset includes multiple second data items, and the data volume of the second interval is the number of second data items in each interval obtained by uniformly dividing all the second data items. Based on any first interval, the first B-tree index is modified based on the data volume of the second interval and the data volume of the third interval to obtain at least one second B-tree index. The first interval is adjusted based on the data volume of the second interval and the data volume of the third interval to obtain at least one second interval. The data volume of the third interval is the number of second data items in the first interval. The interval adjustment includes interval splitting, interval balancing, or interval merging operations. According to the technical solution of the present invention, after the first spatial dataset is updated, the distribution of the second data items in each first interval of the second spatial dataset is uneven. Based on the data volume of the second interval and the data volume of the third interval, the first B-tree index is modified to obtain the second B-tree index. Based on the data volume of the second interval and the data volume of the third interval, the first interval is adjusted to obtain the second interval. Thus, the size of the first interval in the second spatial dataset is adjusted to obtain the second interval. The number of intervals and the number of data items within the intervals are dynamically adjusted based on the change in the number of data items. More intervals are used to divide the sparse and dense parts of the data items in the second spatial dataset, realizing the adaptive adjustment of the interval division in the second spatial dataset and the dynamic adjustment of the number of data items within the intervals. This alleviates the large fluctuations in the number of data items in the spatial dataset and keeps the number of data items in each interval of the second spatial dataset within a balanced range. This improves the indexing efficiency of the updated second spatial dataset in the data update state and maintains stable indexing performance.
[0042] The technical solutions of the embodiments of the present invention will be further illustrated in the following figures.
[0043] Reference Figure 1 , Figure 1The flowchart illustrates a method for modifying the grid index of a spatial dataset according to an embodiment of the present invention. This method includes, but is not limited to, the following steps:
[0044] S10, obtain the first spatial dataset, determine the grid partitioning parameters based on the first spatial dataset, divide the first spatial dataset into multiple first intervals based on the grid partitioning parameters, and construct indexes based on all first intervals to obtain multiple first B-tree indexes. The first spatial dataset includes multiple first data items, and the grid partitioning parameters include the number of first intervals and the data volume of the first interval. The data volume of the first interval is the total number of first data items in the first interval, and the number of first data items in each first interval is the same.
[0045] S20, the first spatial dataset is updated to obtain the second spatial dataset, and the second interval data volume is determined based on the second spatial dataset. The second spatial dataset includes multiple second data items, and the second interval data volume is the number of second data items in each interval obtained by uniformly dividing all the second data items.
[0046] S30, based on any first interval, modify the first B-tree index of the first interval based on the data volume of the second interval and the data volume of the third interval to obtain at least one second B-tree index, and adjust the first interval based on the data volume of the second interval and the data volume of the third interval to obtain at least one second interval, wherein the data volume of the third interval is the number of second data items in the first interval, and the interval adjustment includes interval splitting operation, interval balancing operation or interval merging operation.
[0047] It should be noted that spatial data includes multiple first data items. The first spatial dataset is represented as a set of all the first data items in the spatial data. The grid division parameters are determined based on the first spatial dataset according to actual needs. For example, if the number of first data items in the first spatial dataset is 300, the first spatial dataset can be divided into 10 first intervals, with 30 first data items in each first interval; alternatively, it can be divided into 15 first intervals, with 20 first data items in each first interval.
[0048] It should be noted that how to construct an index for the first interval to obtain a B-tree index is existing technology. This application does not make any improvement to how to construct a B-tree index, and will not elaborate further here.
[0049] It should be noted that the first spatial dataset is divided into multiple first intervals, and multiple first B-tree indexes are obtained by constructing indexes based on all first intervals. Each first interval corresponds to a first B-tree index, and the first B-tree index includes multiple first index terms. In the first spatial dataset, the first index terms are used to index the first data item in the first interval, and one first index term corresponds to one first data item.
[0050] It should be noted that data updates include data item deletion and data item addition. Data item modification is achieved by deleting data items and then adding them back. All first data items in the first spatial dataset are either deleted, added, modified, or left unchanged to obtain all second data items in the second spatial dataset. That is, after updating the first spatial dataset, the data items in the first interval become second data items.
[0051] It should be noted that in the first spatial dataset, the first B-tree index is used to index the first data item in the first interval; after the first spatial dataset is updated to obtain the second spatial dataset, the first interval remains unchanged, and the first B-tree index is used to index the data item in the first interval. That is, in the second spatial dataset, the first B-tree index is used to index the second data item in the first interval.
[0052] It should be noted that after obtaining the second spatial dataset, since the grid partitioning parameters remain unchanged, the division of the first interval remains the same. That is, after obtaining the second spatial dataset from the first spatial dataset, the number of data items within the first interval changes, updating from the data volume of the first interval to the data volume of the third interval. At this point, the multiple first intervals, which were originally evenly divided, may experience data skew, meaning that the number of second data items varies significantly across the different first intervals, and consequently, the data volume varies significantly across the different third intervals. This results in some first intervals having too many second data items and others having too few when indexing the second spatial dataset, affecting the indexing performance and efficiency. Therefore, when determining the data volume of the second interval based on the second spatial dataset and dividing the second spatial dataset into multiple intervals with an even number of second data items, the data volume of the second interval is the number of second data items in the interval obtained from the evenly divided second data items.
[0053] It should be noted that interval adjustment includes interval splitting, interval balancing, or interval merging operations. These operations all involve adjusting the interval size and the number of data items within each interval. Interval splitting and merging operations can adjust the number of intervals in the second spatial dataset. Based on any first interval, the first B-tree index of the first interval is modified according to the data volume of the second and third intervals. This modification includes deleting and adding index entries. The first B-tree index is then modified to obtain the second B-tree index. This modification, achieved by deleting or adding index entries to the first B-tree index, changes the number of index entries in the first B-tree index. By modifying the first B-tree index to obtain the second B-tree index, the size of the first interval in the second spatial dataset is adjusted. Based on the second spatial dataset, the number of intervals in the grid index and the number of data items within each interval are adjusted to smooth the distribution of data items across intervals, thus maintaining index performance and improving the index performance of the updated spatial dataset.
[0054] It should be noted that both index building and index modification are aimed at ensuring the index performance and efficiency of the spatial dataset. For ease of understanding, the following index query methods are provided: Obtain the query conditions, and construct a rectangular query range according to different index query methods. These methods include point lookup, range lookup, and nearest neighbor lookup (K-Nearest Neighbor algorithm, or KNN for short). The query conditions are typically data items within a rectangular range, i.e., finding data whose first and second dimension values are respectively within a specified interval. For range lookup, the expression for the query range is: Here, a and b are the boundary points of the rectangular query range, respectively. For query conditions that do not include an upper or lower bound, -∞ or +∞ are used instead, thus converting it into a rectangular query range. For the nearest neighbor query (K-Nearest Neighbor algorithm, or KNN for short), the step size and query point are set, and the expression for the query range of the nearest neighbor query is: , λ represents the search range for a nearest neighbor query, t represents the step size, and t represents the query point. The first dimension value of the query point t. Let be the second dimension value of the query point t. For each query result, select the k items closest to the query point t. If the query results are less than k items, increase the step size λ until the query results meet the requirements. k is a positive integer. For the query range... or First, process the first dimension value to find all intervals that intersect with the first dimension of the rectangular query range. For the found first-dimensional interval set For each interval, perform a second-dimensional value lookup, using either the first or second B-tree index to find the range of the second-dimensional values for each interval. All data items; by combining the data items searched in each interval, the query results that meet the requirements can be returned.
[0055] It should be noted that, after the first spatial dataset is updated, the second data item in the second spatial dataset is unevenly distributed across the various first intervals. Based on the data volume of the second interval, the first B-tree index is modified to obtain the second B-tree index, thereby adjusting the size of the first interval in the second spatial dataset. The number of intervals and the number of data items within each interval are dynamically adjusted according to the change in the number of data items. More intervals are used to divide the data in the sparse and dense parts of the second spatial dataset, and fewer intervals are used to divide the data in the sparse parts of the second spatial dataset. This achieves adaptive adjustment of interval division and dynamic adjustment of the number of data items within each interval, alleviating large fluctuations in the number of data items and keeping the number of data items within each interval within a balanced range. This improves the indexing efficiency and stable indexing performance of the spatial dataset under data update conditions.
[0056] Additionally, in one embodiment, refer to Figure 1. Figure 1 Step S10 shown includes, but is not limited to, the following steps:
[0057] S11, obtain all first data items, sort all first data items from smallest to largest based on the first dimension value to obtain the first spatial data sequence, wherein the first data item includes the first dimension value and the second dimension value;
[0058] S12, determine the grid partitioning parameters based on the first spatial data sequence and the first formula, obtain m-1 first dimension values based on the first spatial data sequence at intervals of the first interval data volume to form an interval boundary sequence, and divide the first spatial dataset into intervals based on the interval boundary sequence to obtain multiple first intervals, wherein the first interval includes multiple first data items;
[0059] S13, based on any first interval, obtain all first data items of the first interval, and construct an index based on the second dimension value of all first data items to obtain the first B-tree index;
[0060] The expression for the first spatial dataset is: D is the first spatial dataset, d n Let N be the nth first data item in the first spatial dataset, where n is a positive integer and N is the number of first data items in the first spatial dataset. The expression for the first data item is: , The first dimension value of the nth first data item in the first spatial dataset. Let be the second dimension value of the nth first data item in the first spatial dataset. The expression for the first spatial data sequence is: , This is the first spatial data sequence. Let x be the i-th first data item in the first spatial data sequence. i Let y be the first dimension value of the i-th first data item in the first spatial data sequence. i Let N be the second dimension value of the i-th first data item in the first spatial data sequence. The expression of the first formula is: N = m × k, where m is the number of the first intervals, k is the number of data items in the first interval, and both m and k are positive integers. The expression for the interval boundary sequence is: P is the interval boundary sequence. Let ik be the first dimension value of the first spatial data sequence.
[0061] It should be noted that the first spatial data sequence is obtained by traversing all the first data items in the first spatial dataset and sorting the first data items based on the first dimension value. In practice, the first spatial data sequence can be obtained by sorting the first data items based on the second dimension value, depending on the actual needs. Constructing the first spatial data sequence is to facilitate the determination of the number of first data items, the determination of the division boundary of the first interval, and the determination that the first data items in the first interval are all concentrated in the same area.
[0062] For example, the number of the first data items in the first spatial dataset is 300. Based on the first formula N=m×k, where m and k are both positive integers, and the grid partitioning parameters are determined based on actual needs, setting m=10 and k=30, multiple first dimension values are obtained by interval sampling based on the first interval data volume in the first spatial data sequence, such as x. 30 x 60 ..., based on all the first dimension values obtained from sampling, an interval boundary sequence is formed.
[0063] It should be noted that the first spatial dataset is divided into boundaries based on the interval boundary sequence. To facilitate searching, an R-tree index is constructed for each item in the interval boundary sequence. The index item of the R-tree index is the element of the interval boundary sequence. During the query process, the specific first interval is located first through the index item of the R-tree index, and then the specific data item or range is located through the first B-tree index of the first interval.
[0064] It should be noted that after sorting the first data items based on the first dimension value to obtain the first spatial data sequence, the grid partitioning parameters are determined based on the first spatial data sequence, and the first spatial dataset is divided into intervals to obtain multiple first intervals. Each first interval contains multiple first data items. An index is constructed based on the second dimension value of the first data items to obtain the first B-tree index. During index queries, the query conditions are obtained, converted into a rectangular query range, and the R-tree index constructed based on the interval boundary sequence searches for the first intervals that meet the first dimension value requirements of the rectangular query range. Then, the first B-tree index of the first intervals searches for the first data items that meet the second dimension value requirements of the rectangular query range.
[0065] Additionally, in one embodiment, refer to Figure 1. Figure 1 Step S20 shown includes, but is not limited to, the following steps:
[0066] S21, the first spatial dataset is updated to obtain the second spatial dataset, and the data volume of the first interval is updated to obtain the data volume of the third interval;
[0067] S22, determine the amount of data in the second interval based on the second spatial dataset and the second formula, and determine the first threshold based on the amount of data in the second interval, wherein the expression of the second formula is: , This represents the data volume for the second interval. The first threshold is the total number of all second data items. The first threshold is related to the amount of data in the second interval and is a positive integer.
[0068] It should be noted that in the second spatial dataset, each first index term of the first B-tree index corresponds one-to-one with each second data term of the first interval. The first B-tree index is adjusted to obtain the second B-tree index, so that the number of index terms in the second B-tree index is as close as possible to the amount of data in the second interval. This adjusts the number of second data terms in the first interval, ensuring that the second data terms are evenly distributed across the intervals of the second spatial dataset, avoiding data skew. This ensures that the number of data terms in the second intervals of the second spatial dataset remains balanced during index queries, thereby improving the indexing efficiency and performance of the spatial dataset during data updates.
[0069] It should be noted that determining the amount of data in the second interval based on the second spatial dataset and the second formula allows us to determine the number of intervals containing the same number of data items when dividing the second spatial dataset. The second spatial dataset is obtained by updating the first spatial dataset; the number of the first data items is N, and the number of the second data items is... The expression for the data size in the second interval is: , The expression for the number of intervals obtained by dividing the second spatial dataset, where the second interval data volume is: , This represents the number of intervals obtained by dividing the second spatial dataset.
[0070] Additionally, in one embodiment, refer to Figure 1. Figure 1 Step S30 shown includes, but is not limited to, the following steps:
[0071] S31, based on any first interval, compare the data volume of the third interval with the first threshold. If the data volume of the third interval is greater than the first threshold, split the first B-tree index of the first interval to obtain two second B-tree indices. The expression for the first interval is: , For the i-th first interval of the first spatial dataset, Let be the (i-1)th first-dimensional value in the interval boundary sequence. This is the left boundary of the first interval. Let be the i-th value of the first dimension in the interval boundary sequence. The first B-tree index is the right boundary of the first interval. The first B-tree index includes multiple first index terms. In the second spatial dataset, one first index term corresponds to one second data term. The second B-tree index includes multiple second index terms. The number of second index terms in the two second B-tree indexes is the same. The sum of the number of second index terms in the two second B-tree indexes is equal to the number of first index terms in the first B-tree index.
[0072] S32, obtain the interval boundary sequence, add boundary values between the left and right boundaries of the first interval, and obtain two second intervals based on the first interval, wherein the expressions of the two second intervals are as follows: and , Let t be the boundary value of the first second interval. This is the second second interval.
[0073] For example, the first threshold is set to 2 based on actual needs. Specifically, when the data volume of the third interval is greater than twice the data volume of the second interval, it is considered that the second spatial dataset has data skew. The first B-tree index of the first interval needs to be modified to adjust the size of the first interval and smooth out fluctuations in the number of data items. When the data volume of the third interval is greater than twice the data volume of the second interval, the first B-tree index of the first interval is split into two second B-tree indexes with the same number of index items. A new boundary value is inserted within the first interval, thus splitting one first interval into two second intervals containing the same number of data items. This achieves the goal of dividing the densely populated parts of the second spatial dataset into more intervals to maintain the indexing performance of the updated spatial dataset.
[0074] It should be noted that when the number of data items in the first interval is odd, when dividing the second interval, any second interval can have one more data item than the other, keeping the difference in the number of data items between the two second intervals zero or one.
[0075] Additionally, in one embodiment, refer to Figure 1. Figure 1 In step S31 shown, after comparing the data volume of the third interval with the first threshold, the following steps are included, but are not limited to:
[0076] S311, when the amount of data in the third interval is less than or equal to the first threshold, the second threshold and the third threshold are determined based on the amount of data in the second interval, wherein the first threshold is greater than the sum of the second threshold and the third threshold, the second threshold is less than the amount of data in the second interval, the amount of data in the second interval is less than the third threshold, and both the second threshold and the third threshold are positive integers.
[0077] S312, based on any first interval, when the data volume of the third interval is less than the second threshold, obtain the data volume of the third interval of the adjacent intervals of the first interval, and compare the data volume of the third interval of the adjacent intervals with the third threshold. The adjacent intervals are located to the left or right of the first interval, and the expression for the adjacent intervals is: or , The adjacent interval to the left of the first interval, This represents the left boundary of the adjacent interval to the left of the first interval. This represents the right boundary of the adjacent interval located to the left of the first interval. The adjacent interval to the right of the first interval, This represents the left boundary of the adjacent interval to the right of the first interval. It is the right boundary of the adjacent interval located to the right of the first interval;
[0078] S313, when the amount of data in the third interval of an adjacent interval is greater than the third threshold, perform an interval balancing operation on the first interval and the adjacent interval; or, when the amount of data in the third interval of an adjacent interval is less than or equal to the third threshold, perform an interval merging operation on the first interval and the adjacent interval.
[0079] It should be noted that when the number of items in the third interval is less than or equal to the first threshold, it is necessary to determine whether the number of items in the third interval is in a balanced state or too small; when the number of items in the third interval is less than or equal to the first threshold and the number of items in the third interval is greater than or equal to the second threshold, that is, the number of items in the third interval is in a balanced state, there is no need to modify the index of the first B-tree index of the first interval.
[0080] It should be noted that when the amount of data in the third interval is less than the second threshold, that is, when the number of data items in the first interval is too small and the number of data items in the first interval is uneven, the first B-tree index of the first interval needs to be modified to increase the number of data items in the first interval in order to maintain the even distribution of data items in the second spatial dataset, thereby maintaining the query performance of the second spatial dataset.
[0081] It should be noted that the adjacent intervals of the first interval are the first intervals located to the left or right of the first interval. That is, the adjacent intervals also have corresponding first B-tree indexes, third interval data volume, and second data items.
[0082] It should be noted that the first and second thresholds are used to determine whether the data volume in the third interval is too large or too small. This determines whether the first interval is located in a dense or sparse part of the second spatial set. The index of the first interval is then modified using the first B-tree index to dynamically adjust the number of second data items in the first interval. The third threshold is used to determine the number of second data items in adjacent intervals of the first interval. By adding second data items from adjacent intervals to the first interval, the number of second data items in the first interval where the data volume in the third interval is too small is increased, thus balancing the number of second data items in the second interval.
[0083] It should be noted that if the first threshold is greater than the sum of the second and third thresholds, then when the amount of data in the third interval of an adjacent interval is less than or equal to the third threshold, that is, the number of data items in both the first interval and the adjacent interval is too small, meaning that the first interval and the adjacent interval are located in the sparse part of the second spatial dataset, the coefficient part of the second spatial dataset can be divided with fewer intervals. The first interval and the adjacent interval can be merged to reduce the number of intervals and increase the number of data items in a single interval, thereby balancing the data skew in the second spatial dataset. Furthermore, the number of data items in the second interval obtained after merging the first interval and the adjacent interval will not be too large, so there is no need to split the second interval.
[0084] It should be noted that if the second threshold is less than the amount of data in the second interval, and the amount of data in the second interval is less than the third threshold, then when the amount of data in the third interval of an adjacent interval is greater than the third threshold, that is, the number of data items in the first interval is less than the amount of data in the second interval, and the number of data items in the adjacent interval is greater than the amount of data in the second interval, then the range of the adjacent interval is reduced and the range of the first interval is increased. This reduces the number of data items in the adjacent interval and increases the number of data items in the first interval, thereby achieving a difference of zero or one between the number of data items in the first interval and the adjacent interval, so as to smooth out the data skew between the first interval and the adjacent interval.
[0085] It should be noted that the first interval, which has more data in the third interval than the first threshold, is split into two second intervals. If the number of second data items in the second interval is still greater than the first threshold, the second interval is split again.
[0086] In another embodiment, in step S312, when the data volume of the third interval of the adjacent intervals is greater than the third threshold, an interval balancing operation is performed on the first interval and the adjacent intervals, including but not limited to the following steps:
[0087] S3121, when the amount of data in the third interval of an adjacent interval is greater than the third threshold, the amount of balanced data is determined based on the amount of data in the third interval of the first interval and the amount of data in the third interval of the adjacent interval, wherein the second data item corresponding to the amount of balanced data is located in the adjacent interval.
[0088] S3122, obtain the first B-tree index of the first interval and the first B-tree index of the adjacent interval, delete the first index item corresponding to the balance data volume from the first B-tree index of the adjacent interval to obtain the second B-tree index of the adjacent interval, add the first index item corresponding to the balance data volume to the first B-tree index of the first interval to obtain the second B-tree index of the first interval, wherein the number of second index items in the second B-tree index of the adjacent interval is the same as the number of second index items in the second B-tree index of the first interval.
[0089] S3123, obtain the interval boundary sequence. When the adjacent interval is to the left of the first interval, decrease the value of the right boundary of the adjacent interval and increase the value of the left boundary of the first interval to obtain two second intervals. Alternatively, when the adjacent interval is to the right of the first interval, increase the value of the left boundary of the adjacent interval and decrease the value of the right boundary of the first interval to obtain two second intervals.
[0090] For example, the second threshold is The third threshold is When the amount of data in the third interval of the first interval is less than The data volume of the third interval in the adjacent interval is greater than If the number of data items in the first interval is too small and the number of data items in the adjacent interval is greater than the number in the second interval, moving some data items from the adjacent interval to the first interval can reduce the difference between the number of data items in the first interval and the number of data items in the adjacent interval and the number of data items in the second interval. This will smooth out the difference between the number of data items in each first interval in the second spatial dataset and the number of second data items in the first interval and the number of second data items in the adjacent interval and the number of data items in the second interval.
[0091] In another embodiment, in step S312, when the data volume of the third interval of the adjacent interval is less than or equal to the third threshold, an interval merging operation is performed on the first interval and the adjacent interval, including but not limited to the following steps:
[0092] S3124, when the amount of data in the third interval of the adjacent interval is less than or equal to the third threshold, obtain the first B-tree index of the first interval and the first B-tree index of the adjacent interval, delete all the first index entries of the first B-tree index of the adjacent interval, and add all the first index entries of the first B-tree index of the adjacent interval to the first B-tree index of the first interval to obtain the second B-tree index of the first interval.
[0093] S3125, obtain the interval boundary sequence. When the adjacent interval is to the left of the first interval, delete the right boundary of the adjacent interval in the interval boundary sequence to obtain the second interval. Alternatively, when the adjacent interval is to the right of the first interval, delete the left boundary of the adjacent interval in the interval boundary sequence to obtain the second interval.
[0094] For example, the second threshold is The third threshold is When the amount of data in the third interval of the first interval is less than The data volume of the third interval of the adjacent interval is less than or equal to This means that the number of data items in the first interval and the number of data items in the adjacent intervals are both too small. In other words, the first interval and the adjacent intervals are both located in the sparse part of the data items in the second spatial dataset. In the sparse part of the data items, the number of intervals is reduced to expand the interval range so that the number of data items in each interval is balanced, thereby maintaining the indexing performance in the second spatial dataset.
[0095] It should be noted that the second B-tree index is obtained by merging the first B-tree index of the first interval and the first B-tree index of the adjacent interval. This merges the first interval with the adjacent interval, thereby increasing the number of data items in the first interval, expanding the size of the first interval, and reducing the number of intervals in the second spatial dataset. This improves the indexing efficiency and indexing performance of the second spatial dataset after data updates.
[0096] It should be noted that if the number of data items in the second interval after merging is still less than the second threshold, an interval balancing operation or an interval merging operation can be performed on the second interval and its adjacent intervals to adjust the size or number of the second interval.
[0097] To better understand the technical solution of the present invention, the following specific embodiments are provided:
[0098] S401, obtain all the first data items, sort all the first data items from smallest to largest based on the first dimension value to obtain a first spatial data sequence, determine the grid division parameters based on the first spatial data sequence and the first formula, obtain m-1 first dimension values based on the first spatial data sequence at intervals of the first interval data amount to form an interval boundary sequence, divide the first spatial dataset into intervals based on the interval boundary sequence to obtain multiple first intervals, wherein the first interval includes multiple first data items, and the first data item includes the first dimension value and the second dimension value;
[0099] S402, based on any first interval, obtain all the first data items of the first interval, and construct an index based on the second dimension values of all the first data items to obtain the first B-tree index;
[0100] S403, the first spatial dataset is updated to obtain the second spatial dataset, the first interval data volume is updated to obtain the third interval data volume, the second interval data volume is determined based on the second spatial dataset and the second formula, and the first threshold is determined based on the second interval data volume.
[0101] S404, based on any of the first intervals, compare the data volume of the third interval with the first threshold. When the data volume of the third interval is greater than the first threshold, split the first B-tree index of the first interval to obtain two second B-tree indices, obtain the interval boundary sequence, add a boundary value between the left boundary and the right boundary of the first interval, and obtain two second intervals based on the first interval.
[0102] S405, when the amount of data in the third interval is less than or equal to the first threshold, a second threshold and a third threshold are determined based on the amount of data in the second interval, wherein the first threshold is greater than the sum of the second threshold and the third threshold, the second threshold is less than the amount of data in the second interval, the amount of data in the second interval is less than the third threshold, and both the second threshold and the third threshold are positive integers;
[0103] S406, based on any of the first intervals, when the data volume of the third interval is less than the second threshold, obtain the data volume of the third interval of the adjacent intervals of the first interval, and compare the data volume of the third interval of the adjacent intervals with the third threshold;
[0104] S407, when the data volume of the third interval in the adjacent interval is greater than the third threshold, a balanced data volume is determined based on the data volume of the third interval in the first interval and the data volume of the third interval in the adjacent interval, wherein the second data item corresponding to the balanced data volume is located in the adjacent interval; the first B-tree index of the first interval and the first B-tree index of the adjacent interval are obtained, the first index item corresponding to the balanced data volume is deleted from the first B-tree index of the adjacent interval to obtain the second B-tree index of the adjacent interval, and the first index item corresponding to the balanced data volume is added to the first B-tree index of the first interval to obtain the second B-tree index of the first interval, wherein the number of second index items in the second B-tree index of the adjacent interval is the same as the number of second index items in the second B-tree index of the first interval; the interval boundary sequence is obtained, when the adjacent interval is located to the left of the first interval, the value of the right boundary of the adjacent interval is decreased and the value of the left boundary of the first interval is increased to obtain two second intervals, or, when the adjacent interval is located to the right of the first interval, the value of the left boundary of the adjacent interval is increased and the value of the right boundary of the first interval is decreased to obtain two second intervals;
[0105] S408, or, when the data volume of the third interval of the adjacent interval is less than or equal to the third threshold, obtain the first B-tree index of the first interval and the first B-tree index of the adjacent interval, delete all the first index entries of the first B-tree index of the adjacent interval, add all the first index entries of the first B-tree index of the adjacent interval to the first B-tree index of the first interval to obtain the second B-tree index of the first interval; obtain the interval boundary sequence, when the adjacent interval is located to the left of the first interval, delete the right boundary of the adjacent interval in the interval boundary sequence to obtain the second interval, or when the adjacent interval is located to the right of the first interval, delete the left boundary of the adjacent interval in the interval boundary sequence to obtain the second interval.
[0106] This invention involves partitioning a first spatial dataset into intervals and constructing indexes to obtain multiple first intervals and corresponding first B-tree indexes. The number of data items in each first interval is equal to the number of data items in the first interval. After updating the first spatial dataset, a second spatial dataset is obtained, in which the number and distribution of data items change. The number of data items in the second interval is determined for the second spatial dataset. Based on the number of data items in the first interval, a first threshold, a second threshold, and a third threshold are determined. Based on the first and second thresholds, it is determined whether data skew occurs in the second spatial dataset after the first interval partitioning. If data skew occurs, the first interval and its first B-tree index are split to obtain two second intervals and their corresponding second B-tree indexes. Alternatively, interval balancing or interval merging operations are performed on the first interval and its adjacent intervals to obtain at least one second interval and its corresponding second B-tree index, thereby ensuring a uniform number of second data items in the second intervals. This invention adjusts the size and number of intervals based on the number of data items in the second interval, thereby achieving a balanced partitioning of the second spatial dataset and improving the indexing performance of the updated second spatial dataset and the indexing efficiency of the spatial dataset in the update state.
[0107] like Figure 2 As shown, Figure 2 This is a structural diagram of a device for modifying the grid index of a spatial dataset according to an embodiment of the present invention. The present invention also provides a device for modifying the grid index of a spatial dataset, comprising:
[0108] The processor 501 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0109] The memory 502 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 502 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 502 and is called by the processor 501 to execute the method for modifying the grid index of the spatial dataset in the embodiments of this application.
[0110] The input / output interface 503 is used to implement information input and output;
[0111] The communication interface 504 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0112] Bus 505 transmits information between various components of the device (e.g., processor 501, memory 502, input / output interface 503, and communication interface 504);
[0113] The processor 501, memory 502, input / output interface 503, and communication interface 504 are connected to each other within the device via bus 505.
[0114] This application also provides an electronic device, including a device for modifying the grid index of a spatial dataset as described above.
[0115] This application embodiment also provides a storage medium, which is a computer-readable storage medium, storing a computer program that, when executed by a processor, implements the method for modifying the grid index of the aforementioned spatial dataset.
[0116] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate, and may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0117] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0118] The above provides a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of the present invention.
Claims
1. A method of modifying a grid index of a spatial data set, characterized in that, The method comprises: obtaining a first spatial data set, determining a grid division parameter based on the first spatial data set, dividing the first spatial data set into a plurality of first intervals based on the grid division parameter, and constructing an index based on all the first intervals to obtain a plurality of first B-tree indexes, wherein the first spatial data set comprises a plurality of first data items, the grid division parameter comprises a number of the first intervals and a first interval data amount, the first interval data amount is a number of the first data items in the first interval, and the number of the first data items in each first interval is the same; updating the first spatial data set to obtain a second spatial data set, and determining a second interval data amount based on the second spatial data set, wherein the second spatial data set comprises a plurality of second data items, and the second interval data amount is a number of the second data items in each interval obtained by uniformly dividing all the second data items; based on any first interval, modifying the first B-tree index based on the second interval data amount and a third interval data amount to obtain at least one second B-tree index, and adjusting the first interval based on the second interval data amount and the third interval data amount to obtain at least one second interval, wherein the third interval data amount is a number of the second data items in the first interval, and the interval adjustment comprises an interval splitting operation, an interval balancing operation, and an interval merging operation.
2. The method of modifying a grid index of a spatial dataset of claim 1, wherein, obtaining a first spatial data set, determining a grid division parameter based on the first spatial data set, dividing the first spatial data set into a plurality of first intervals based on the grid division parameter, and constructing an index based on all the first intervals to obtain a plurality of first B-tree indexes, comprising: obtaining all the first data items, and sorting all the first data items based on a first dimension value from small to large to obtain a first spatial data sequence, wherein the first data item comprises the first dimension value and a second dimension value; determining the grid division parameter based on the first spatial data sequence and a first formula, obtaining an interval boundary sequence composed of m-1 first dimension values by spacing the first interval data amount based on the first spatial data sequence, and dividing the first spatial data set into a plurality of first intervals based on the interval boundary sequence, wherein the first interval comprises a plurality of first data items; based on any first interval, obtaining all the first data items of the first interval, and constructing an index based on the second dimension value of all the first data items to obtain the first B-tree index; The expression of the first spatial data set is: D is the first spatial data set, d n is the nth first data item of the first spatial data set, n is a positive integer, N is the number of the first data items of the first spatial data set, and the expression of the first data item is: , is the first dimension value of the nth first data item of the first spatial data set, is the second dimension value of the nth first data item of the first spatial data set, and the expression of the first spatial data sequence is: , is the first spatial data sequence, is the ith first data item of the first spatial data sequence, x i is the first dimension value of the ith first data item of the first spatial data sequence, y i is the second dimension value of the ith first data item of the first spatial data sequence, and the expression of the first formula is: N=m×k, m is the number of the first intervals, k is the first interval data amount, m and k are both positive integers, and the expression of the interval boundary sequence is P is the interval boundary sequence, is the ithk first dimension value of the first spatial data sequence.
3. The method of modifying a grid index of a spatial dataset of claim 2, wherein, updating the first spatial data set to obtain a second spatial data set, and determining a second interval data amount based on the second spatial data set, comprising: updating the first spatial data set to obtain the second spatial data set, and updating the first interval data amount to obtain the third interval data amount; determining the second interval data amount based on the second spatial data set and a second formula, determining a first threshold value based on the second interval data amount, wherein an expression of the second formula is , is the second interval data amount, is a number of all the second data items, the first threshold value is associated with the second interval data amount, and the first threshold value is a positive integer.
4. The method of modifying a grid index of a spatial data set according to claim 3, wherein, Based on any one of the first interval, based on the second interval data volume and the third interval data volume, the first B-tree index is modified to obtain at least one second B-tree index, and the first interval is adjusted based on the second interval data volume and the third interval data volume to obtain at least one second interval, comprising: comparing the third interval data amount with the first threshold based on any one of the first intervals, when the third interval data amount is greater than the first threshold, splitting the first B-tree index of the first interval to obtain two second B-tree indexes, wherein the expression of the first interval is: , is the i-th first interval of the first spatial data set, is the (i-1)-th first dimension value in the interval boundary sequence, is the left boundary of the first interval, is the i-th first dimension value in the interval boundary sequence, is the right boundary of the first interval, the first B-tree index comprises a plurality of first index items, in the second spatial data set, one first index item corresponds to one second data item, the second B-tree index comprises a plurality of second index items, the number of second index items of two second B-tree indexes is the same, and the number of second index items of two second B-tree indexes is equal to the number of first index items of the first B-tree index; obtaining the interval boundary sequence, adding a boundary value between the left boundary and the right boundary of the first interval, obtaining two second intervals based on the first interval, wherein expressions of the two second intervals are respectively: and , for one of the second intervals, t is the boundary value, for another of the second intervals.
5. The method of modifying a grid index of a spatial dataset of claim 4, wherein, After comparing the third interval data volume with the first threshold value, further comprising: When the third interval data volume is less than or equal to the first threshold value, a second threshold value and a third threshold value are determined based on the second interval data volume, wherein the first threshold value is greater than the sum of the second threshold value and the third threshold value, the second threshold value is less than the second interval data volume, the second interval data volume is less than the third threshold value, and the second threshold value and the third threshold value are both positive integers; Based on any of the first interval, when the third interval data volume is less than the second threshold, the third interval data volume of the adjacent interval of the first interval is obtained, and the third interval data volume of the adjacent interval and the third threshold are compared, wherein the adjacent interval is located on the left side or the right side of the first interval, and the expression of the adjacent interval is: or , is the adjacent interval located on the left side of the first interval, is the left boundary of the adjacent interval located on the left side of the first interval, is the right boundary of the adjacent interval located on the left side of the first interval, is the adjacent interval located on the right side of the first interval, is the left boundary of the adjacent interval located on the right side of the first interval, is the right boundary of the adjacent interval located on the right side of the first interval; When the third interval data volume of the adjacent interval is greater than the third threshold value, interval balancing operation is performed on the first interval and the adjacent interval, or when the third interval data volume of the adjacent interval is less than or equal to the third threshold value, interval merging operation is performed on the first interval and the adjacent interval.
6. The method of modifying a grid index of a spatial dataset of claim 5, wherein, When the third interval data volume of the adjacent interval is greater than the third threshold value, interval balancing operation is performed on the first interval and the adjacent interval, comprising: When the third interval data volume of the adjacent interval is greater than the third threshold value, a balance data volume is determined based on the third interval data volume of the first interval and the third interval data volume of the adjacent interval, wherein the second data item corresponding to the balance data volume is located in the adjacent interval; The first B-tree index of the first interval and the first B-tree index of the adjacent interval are obtained, the first index item corresponding to the balance data volume is deleted from the first B-tree index of the adjacent interval to obtain the second B-tree index of the adjacent interval, and the first index item corresponding to the balance data volume is added to the first B-tree index of the first interval to obtain the second B-tree index of the first interval, wherein the number of the second index items of the second B-tree index of the adjacent interval is the same as the number of the second index items of the second B-tree index of the first interval; The interval boundary sequence is obtained, when the adjacent interval is located on the left side of the first interval, the value of the right boundary of the adjacent interval is decreased and the value of the left boundary of the first interval is increased to obtain two second intervals, or when the adjacent interval is located on the right side of the first interval, the value of the left boundary of the adjacent interval is increased and the value of the right boundary of the first interval is decreased to obtain two second intervals.
7. The method of claim 5, wherein, When the third interval data volume of the adjacent interval is less than or equal to the third threshold value, interval merging operation is performed on the first interval and the adjacent interval, comprising: when the third interval data amount of the adjacent interval is less than or equal to the third threshold value, obtaining the first B-tree index of the first interval and the first B-tree index of the adjacent interval, deleting all the first index entries of the first B-tree index of the adjacent interval, adding all the first index entries of the first B-tree index of the adjacent interval to the first B-tree index of the first interval to obtain the second B-tree index of the first interval; obtaining the interval boundary sequence, when the adjacent interval is located at the left side of the first interval, deleting the right boundary of the adjacent interval in the interval boundary sequence to obtain the second interval, or when the adjacent interval is located at the right side of the first interval, deleting the left boundary of the adjacent interval in the interval boundary sequence to obtain the second interval.
8. An apparatus for modifying a grid index of a spatial data set, characterized in that comprising at least one control processor and a memory communicatively connected to the at least one control processor; the memory stores instructions executable by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to perform the modification method of the grid index of the spatial data set according to any one of claims 1 to 7.
9. An electronic device, comprising: the modification device of the grid index of the spatial data set according to claim 8.
10. A computer-readable storage medium, characterized in that, the computer readable storage medium stores computer executable instructions for causing a computer to perform the modification method of the grid index of the spatial data set according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and equipment for building index table
CN106960020A
Distributed data gateway and front-end multi-domain data request method and system
CN117040967A