Data object writing method and apparatus, electronic device, and storage medium
By parsing the offset and length of the target data object, traversing the rectangular tree nodes, determining the target node, and writing it into the data object, the problem of the MBR minimization splitting strategy affecting query performance in R-tree insertion and deletion operations is solved, thus improving traversal and query efficiency.
Patent Information
- Application Number
- CN202611052838.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-15
- Publication Date
- 2026-11-06
AI Technical Summary
R-trees require minimizing the MBR during insertion and deletion operations, which causes the splitting strategy to affect the query performance of the tree and makes it difficult to efficiently handle 'nearby search' and 'range intersection' queries.
By receiving data object write requests, parsing the offset and length of the target data object, traversing the nodes in the rectangular tree, determining the target node, and writing the data object to the target node, the traversal efficiency is improved by utilizing one-dimensional information.
It improves the traversal efficiency of rectangular trees, optimizes the writing process of data objects, and enhances query performance.
Smart Images

Figure CN123048533A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data object writing method, apparatus, electronic device, and storage medium. Background Technology
[0002] An R-tree (R-Tree, Rectangle-Tree) is a balanced tree structure for multidimensional spatial data. It's a balanced hierarchical tree structure where all leaf nodes have the same depth. Each leaf node directly contains the target data, and its parent node contains several leaf nodes, nested upwards in a hierarchical manner. The root node indirectly contains all targets, and its range is the smallest bounding box containing all targets. The entire tree has only one root node, which is typically the entry point for various operations, such as spatial queries and updates. In real-world applications, R-trees can be used to store two-dimensional information, such as latitude and longitude in geographic information systems (GIS) and time and offset information in time-series multi-version databases.
[0003] R-trees are considered classic because they solve the pain point of traditional database indexes in efficiently handling "nearby search" or "range intersection" queries. However, they also have a challenge: insertion and deletion operations require maintaining the minimum bounding rectangle (MBR). To ensure search efficiency, nodes need to be split when they overflow, and the splitting strategy directly affects the query performance of the tree. Summary of the Invention
[0004] Embodiments of this disclosure provide a method, apparatus, electronic device, and storage medium for writing data objects.
[0005] In a first aspect, embodiments of this disclosure provide a data object writing method, comprising: in response to receiving a data object writing request, parsing the data object writing request, determining a target data object and a target offset value and a target length corresponding to the target data object; traversing each node in a rectangular tree according to the target offset value and the target data length to determine a target node; and writing the target data object into the target node.
[0006] Secondly, embodiments of this disclosure provide a data object writing apparatus, comprising: a request parsing unit configured to, in response to receiving a data object writing request, parse the data object writing request and determine a target data object and a target offset value and a target length corresponding to the target data object; a node determining unit configured to, based on the target offset value and the target data length, traverse each node in a rectangular tree to determine a target node; and an object writing unit configured to write the target data object into the target node.
[0007] Thirdly, embodiments of this disclosure provide an electronic device including a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the data object writing method as described in the first aspect.
[0008] Fourthly, embodiments of this disclosure provide a non-transitory computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the data object writing method as described in the first aspect.
[0009] By applying the technical solution of this disclosure, when a data object write request is received, the request can be parsed to determine the target data object to be written, as well as its corresponding target offset and target length. Then, based on the target offset and target length, each node in the rectangular tree is traversed to determine the target node. Finally, the target data object is written into the target node. This technical solution utilizes two parameters of the target data object—that is, one-dimensional information—to traverse each node in the rectangular tree, thereby effectively improving traversal efficiency.
[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0011] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0012] Figure 1 A flowchart illustrating one embodiment of the data object writing method of this disclosure;
[0013] Figure 2 A flowchart illustrating another embodiment of the data object writing method of this disclosure;
[0014] Figure 3 A schematic diagram of the structure of an embodiment of the data object writing apparatus of this disclosure;
[0015] Figure 4 This is a schematic diagram of the structure of an embodiment of the electronic device disclosed herein. Detailed Implementation
[0016] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of this disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains.
[0017] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this disclosure. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0018] Where there is no conflict, the embodiments and features described herein can be combined with each other.
[0019] To make the technical solutions and advantages of this disclosure clearer, the following description, in conjunction with the accompanying drawings and specific embodiments, will provide a more detailed account of this disclosure.
[0020] Figure 1 A flow 100 of one embodiment of the data object writing method of this disclosure is shown. For example... Figure 1 As shown, the data object writing method in this embodiment may include the following steps:
[0021] Step 101: In response to receiving a data object write request, parse the data object write request to determine the target data object and the target offset value and target length corresponding to the target data object.
[0022] In this embodiment, the executing entity can receive a data object write request, parse the request, and determine the target data object, its corresponding target offset, and target length. Here, the target data object is the basic unit of R-tree storage. In a leaf node, it contains a spatial object (such as a polygon) and a pointer to that object's data. In a non-leaf node, it contains a pointer to its child nodes. The target offset is the offset value of the target data object, and the target length is the length of the target data object.
[0023] Step 102: Based on the target offset value and the target data length, traverse each node in the rectangular tree to determine the target node.
[0024] After determining the target offset and target length, the target node can be determined by traversing the nodes in the rectangular tree based on these two parameter values. An R-tree is a height-balanced tree consisting of a root node, intermediate nodes, and leaf nodes. Each node can store multiple records, and each record can store a data object. In practice, for each node in the rectangular tree, the impact of adding the target data object to that node can be calculated individually. That is, whether it will affect the balance of the node. If it will not affect the balance of the node, the target data object can be added to that node, and that node can be designated as the target node.
[0025] Step 103: Write the target data object into the target node.
[0026] After identifying the target node, the target data object can be written to the target node. Specifically, a storage location can be determined within the target node, and then the target data object can be written to that storage location.
[0027] The data object writing method provided in the above embodiments of this disclosure can parse the data object writing request upon receiving it, determine the target data object to be written, and the corresponding target offset value and target length. Then, based on the target offset value and target data length, it traverses each node in the rectangular tree to determine the target node. Finally, it writes the target data object into the target node. This technical solution utilizes two parameters of the target data object, namely, one-dimensional information, to traverse each node in the rectangular tree, thereby effectively improving traversal efficiency.
[0028] See also Figure 2 This illustrates a flow 200 of another embodiment of the data object writing method according to this disclosure. For example... Figure 2 As shown, the method in this embodiment may include the following steps:
[0029] Step 201: In response to receiving a data object write request, parse the data object write request to determine the target data object and the target offset value and target length corresponding to the target data object.
[0030] The information stored in the rectangular tree can include the time epoch, offset value off, data length len, and storage address information addr. In this embodiment, upon receiving a data object write request, only the offset value off and data length len can be used when processing the data object write request. Thus, after parsing the data object write request, only the target offset value and target length corresponding to the target data object are extracted.
[0031] Step 202: Determine the target boundary rectangle based on the target offset value and the target data length; determine the target node from each node based on the target boundary rectangle and the boundary rectangles of the data objects already stored in each node of the rectangle tree.
[0032] After determining the target offset and target data length, the target boundary rectangle can be determined. Specifically, the target offset can be used as the width, and the target data length as the length to obtain the target boundary rectangle. In a rectangle tree, the minimum boundary rectangle is the smallest rectangle that can exactly enclose a spatial object (or all child objects within a node). After determining the target boundary rectangle, the target node can be determined from each node by combining it with the boundary rectangles of the stored data objects in each node of the rectangle tree. Specifically, the union of the target boundary rectangle and the boundary rectangles of each stored data object can be calculated, and the boundary rectangle of the union can be determined. If the boundary rectangle of the union is not larger than the boundary rectangle of the node, then the node can be taken as the target node.
[0033] In some optional implementations of this embodiment, the executing entity can perform calculations on individual nodes in the rectangular tree. Specifically, it can calculate the increase in area after adding the target boundary rectangle to the node. This increase in area can be obtained by subtracting the boundary rectangle of the node from the boundary rectangle of the union. Further, based on the increase in area of each node, the target node is determined from among the nodes. Specifically, the node with the smallest increase in area can be selected as the target node.
[0034] In some optional implementations of this embodiment, the node corresponding to the minimum increase in area can be used as the target node. Alternatively, if the minimum value corresponds to at least two nodes, the existing area of each of the at least two nodes can be further determined. Here, the existing area refers to the sum of the areas of the boundary rectangles of the stored data objects. Then, the node with the smallest existing area is used as the target node.
[0035] Step 203: Determine the boundary rectangle of the target node and the center of the target node; determine the center of the target data object based on the target boundary rectangle; determine the target distance between the center of the target node and the center of the target data based on the center of the target node and the center of the target data; determine the target storage location of the target data object in the target node based on the target distance.
[0036] After identifying the target node, its center can be determined based on its boundary rectangle. Simultaneously, the center of the target boundary rectangle can be determined as the center of the target data object. Then, the distance between the two centers can be calculated and denoted as the target distance. Finally, based on the target distance, the target storage location for storing the target data object is determined within the target node. Specifically, a correspondence between distance and storage location can be pre-defined, and the target storage location can be determined by querying this correspondence.
[0037] In some optional implementations of this embodiment, the executing entity can determine the distance between the center of the boundary rectangle of the stored data object in the target node and the center of the target node. Then, based on each distance and the target distance, the target storage location is determined. Specifically, the target storage location can be determined from the vicinity of the storage location corresponding to the same distance as the target distance.
[0038] In some optional implementations of this embodiment, the distances and the target distance can be sorted in ascending order. Then, from the sorted order, the two distances adjacent to the target distance are determined as reference distances. The storage locations corresponding to the two reference distances are further determined as reference storage locations. Finally, the target storage location is determined between the two reference storage locations. In this way, the data objects in the target node are stored according to the distance between the center of their boundary rectangle and the center of the target node. When inserting a new data object, a search can be performed using distance as the retrieval condition, thereby greatly improving retrieval efficiency.
[0039] Step 204: Store the target data object at the target storage location.
[0040] The data object writing method provided in the above embodiments of this disclosure can utilize two parameters of the target data object, namely one-dimensional information, to traverse each node in the rectangular tree, thereby effectively improving traversal efficiency.
[0041] Further reference Figure 3 As an implementation of the methods shown in the above figures, this disclosure provides an embodiment of a data object writing device, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0042] like Figure 3 As shown, the data object writing device 300 of this embodiment includes: a request parsing unit 301, a node determination unit 302, and an object writing unit 303.
[0043] The request parsing unit 301 is configured to parse the data object write request in response to receiving the data object write request, and determine the target data object and the target offset value and target length corresponding to the target data object.
[0044] The node determination unit 302 is configured to traverse each node in the rectangular tree based on the target offset value and the target data length to determine the target node.
[0045] The object writing unit 303 is configured to write the target data object into the target node.
[0046] In addition, an electronic device is also proposed in the technical solution of this application.
[0047] Figure 4 A schematic diagram of the structure of an electronic device provided in one embodiment of the present disclosure is shown.
[0048] like Figure 4 As shown, the electronic device may include a processor 401, a memory 402, a bus 403, and a computer program stored on the memory 402 and executable on the processor 401. The processor 401 and the memory 402 communicate with each other via the bus 403. When the processor 401 executes the computer program, it implements the steps of the above method, including, for example, parses the data object write request in response to receiving it, determines the target data object and its corresponding target offset and target length; traverses each node in the rectangular tree according to the target offset and target data length to determine the target node; and writes the target data object into the target node.
[0049] In addition, one embodiment of this disclosure also provides a non-transitory computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the above method, including, for example,: in response to receiving a data object write request, parsing the data object write request, determining the target data object and the target offset value and target length corresponding to the target data object; traversing each node in the rectangular tree according to the target offset value and the target data length to determine the target node; and writing the target data object into the target node.
[0050] In summary, the technical solution disclosed herein can parse a data object write request upon receipt to determine the target data object to be written, as well as its corresponding target offset and target length. Then, based on the target offset and target length, each node in the rectangular tree is traversed to determine the target node. Finally, the target data object is written into the target node. This technical solution utilizes two parameters of the target data object—that is, one-dimensional information—to traverse each node in the rectangular tree, thereby effectively improving traversal efficiency.
[0051] The above description is merely a preferred embodiment of this disclosure and is not intended to limit this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for writing a data object, comprising: In response to receiving a data object write request, the data object write request is parsed to determine the target data object and the target offset value and target length corresponding to the target data object; Based on the target offset value and the target data length, traverse each node in the rectangular tree to determine the target node; Write the target data object into the target node.
2. The method according to claim 1, wherein, The step of traversing each node in the rectangular tree to determine the target node based on the target offset value and the target data length includes: The target boundary rectangle is determined based on the target offset value and the target data length; The target node is determined from each node based on the target boundary rectangle and the boundary rectangles of the data objects already stored in each node of the rectangle tree.
3. The method according to claim 2, wherein, The step of determining the target node from each node based on the target boundary rectangle and the boundary rectangles of the data objects already stored in each node of the rectangle tree includes: For a single node in the rectangular tree, calculate the increase in area of the target boundary rectangle after adding that node; Based on the increase in area, the target node is determined from each node.
4. The method according to claim 3, wherein, The process of determining the target node from each node based on the increase in area includes: The node corresponding to the minimum increase in area is taken as the target node; or In response to determining that the minimum value corresponds to at least two nodes, the existing area of each of the at least two nodes is determined; the node with the smallest existing area is taken as the target node.
5. The method according to claim 2, wherein, The step of writing the target data object into the target node includes: Determine the boundary rectangle of the target node, and determine the center of the target node; The center of the target data object is determined based on the target boundary rectangle; Determine the target distance between the target node and the target data object based on their centers; Based on the target distance, determine the target storage location of the target data object in the target node; The target data object is stored at the target storage location.
6. The method according to claim 5, wherein, Determining the target storage location of the target data object in the target node based on the target distance includes: Determine the distance between the center of the boundary rectangle of the data objects stored in the target node and the center of the target node; The target storage location is determined based on the distances between each distance and the target distance.
7. The method according to claim 6, wherein, Determining the target storage location based on each distance and the target distance includes: Sort all distances and the target distance in ascending order, and determine the two distances adjacent to the target distance as reference distances; The storage locations corresponding to the two reference distances are determined as reference storage locations; The target storage location is determined between the two reference storage locations.
8. A data object writing device, comprising: The request parsing unit is configured to, in response to receiving a data object write request, parse the data object write request and determine the target data object, as well as the target offset value and target length corresponding to the target data object; The node determination unit is configured to traverse each node in the rectangular tree according to the target offset value and the target data length to determine the target node; An object writing unit is configured to write the target data object into the target node.
9. An electronic device comprising a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the computer program, it implements the data object writing method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the data object writing method as described in any one of claims 1 to 7.
