A data storage and retrieval method, apparatus, device and medium
By combining hash functions and area range values, a data structure is established to perform local searches of three-dimensional Boolean operations, which solves the high time complexity problem caused by global searches and improves computational efficiency.
Patent Information
- Application Number
- CN202210630718.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-06
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-06-06
AI Technical Summary
The global search algorithm in existing three-dimensional Boolean operations leads to high time complexity of points, which affects the operation efficiency.
A hash function is used to convert the coordinate data of the target point into a hash value, the target area is determined based on the preset area range value, and a data structure is established for storage and query, which is converted into a local search algorithm.
The time complexity of the three-dimensional Boolean search algorithm is reduced and the efficiency of the three-dimensional Boolean operation is improved.
Smart Images

Figure CN114969447B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of engineering modeling, and in particular to a data storage and retrieval method, apparatus, device, and medium. Background Technology
[0002] Boolean operations on 3D solids (hereinafter referred to as Boolean operations) are important operations in the field of computer-aided design (CAD). They primarily construct new geometric shapes through set operations such as intersection, union, and difference between entities. Boolean operations on 3D solids are widely used not only in game rendering and film modeling to render exquisite and realistic 3D models, providing a better immersive experience for gamers, but also in the field of architectural engineering. By building 3D models, Boolean operations such as intersection, union, and difference can be used to calculate the material quantities of the 3D model, and then the project budget can be calculated using the unit price of the materials, providing data support for pre- and post-construction budgets and bidding in the construction industry. However, in CAD model representations related to the construction industry, the data structure of a point, denoted as Point, uses three double-precision floating-point numbers (double) to represent its spatial location. Double-precision floating-point numbers are approximately containing more than ten decimal places, making direct comparison and sorting impossible. Furthermore, the fact that the Point's position data structure is represented by three doubles limits the efficiency of using sorting methods to improve the search efficiency of Point.
[0003] However, the essence of 3D Boolean operations is the determination and manipulation of the positional relationships of points, lines, and planes in 3D space. After breaking up spatial volumes and planes, the search is used to create new planes and analyze the process of creating volumes from new planes. These operations involve numerous search-related application scenarios: for example, adding a new point requires checking if the point already exists before adding it; this operation has a time complexity of O(n) in over 95% of cases. Another example is the surface search and analysis after plane breaks, which requires analyzing the connecting axes of each edge; for all edges, at least n searches are needed, and with n outer edges, the time complexity is O(n²).
[0004] When using this global search algorithm, the time complexity of O(n) does not affect the overall computational efficiency when n is small. However, as Boolean operations are performed and the entities are subtracted from each other, the number of points, lines, and surfaces of the entity increases accordingly. This means the size of n in the global search increases with the Boolean operations. When n is large, this significantly limits the speed of the search algorithm.
[0005] As can be seen from the above, in the process of searching for point data in three-dimensional Boolean operations, how to avoid the situation where the time complexity of searching for points in three-dimensional Boolean operations is high due to the existing global search method, which in turn leads to the low computational efficiency of three-dimensional Boolean operations, is a problem that needs to be solved in this field. Summary of the Invention
[0006] In view of this, the purpose of this invention is to provide a data storage and retrieval method, apparatus, device, and medium that can transform the global search algorithm in three-dimensional Boolean operations into a local search algorithm, reducing the time complexity of the three-dimensional Boolean search algorithm and thus improving the efficiency of three-dimensional Boolean operations. The specific solution is as follows:
[0007] Firstly, this application discloses a data storage and retrieval method, including:
[0008] Determine the coordinate data of the target point, and use a preset hash function to determine the hash value corresponding to the coordinate data;
[0009] The target region corresponding to the target point is determined based on the preset region range value and the coordinate data of the target point, and a data structure corresponding to the target region is established; the hash value has a unique correspondence with the target region;
[0010] Key-value pairs are constructed using the hash value as the key and the coordinate data as the value, and the key-value pairs are stored in the data structure corresponding to the target region;
[0011] When a query request for a target query point is received, the coordinate data of the target query point is determined, and the hash value corresponding to the coordinate data of the target query point is determined using the preset hash function. Then, the target query area is determined based on the hash value of the target query point, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
[0012] Optionally, determining the coordinate data of the target point and using a preset hash function to determine the hash value corresponding to the coordinate data includes:
[0013] Determine the coordinates of the target point and the preset area range.
[0014] Based on the coordinate data and the preset area range value, the index value corresponding to the target point is determined using a preset index value calculation method;
[0015] A hash value corresponding to the index value and generated with a preset data type is determined using a preset hash function.
[0016] Optionally, before determining the hash value corresponding to the index value and generated with a preset data type using a preset hash function, the method further includes:
[0017] Determine the default data type for the hash value;
[0018] Accordingly, storing the key-value pair into a preset data structure corresponding to the target region includes:
[0019] A preset sorting method is determined based on the preset data type;
[0020] The key-value pairs are stored in a preset data structure corresponding to the target region according to a preset sorting method.
[0021] Optionally, determining the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point includes:
[0022] Determine the type of the target point; the type of the target point includes one-dimensional, two-dimensional, and three-dimensional types.
[0023] The target area corresponding to the target point is determined based on the type of the target point, the coordinate data of the target point, and the preset area range value.
[0024] Optionally, establishing the data structure corresponding to the target region includes:
[0025] Establish a map structure corresponding to the target region;
[0026] Accordingly, storing the key-value pair into a preset data structure corresponding to the target region includes:
[0027] The key-value pairs are stored in a map structure corresponding to the target region.
[0028] Optionally, the data storage and query method further includes:
[0029] The updated value of the region range is obtained through the preset region range value acquisition interface, and the current region range value is updated to the updated value of the region range value.
[0030] Optionally, the data storage and query method further includes:
[0031] Obtain the coordinate data error value of the target point;
[0032] The region of the target point is determined based on the coordinate data error value of the target point, and all points falling within the region are identified as the target points.
[0033] Secondly, this application discloses a data storage and retrieval device, comprising:
[0034] The hash value determination module is used to determine the coordinate data of the target point and use a preset hash function to determine the hash value corresponding to the coordinate data.
[0035] A data structure establishment module is used to determine the target region corresponding to the target point based on a preset region range value and the coordinate data of the target point, and to establish a data structure corresponding to the target region; the hash value has a unique correspondence with the target region;
[0036] The key-value pair storage module is used to construct key-value pairs by using the hash value as the key and the coordinate data as the value, and to store the key-value pairs in the data structure corresponding to the target region;
[0037] The target query point query module is used to determine the coordinate data of the target query point when a query request for the target query point is received, and to determine the hash value corresponding to the coordinate data of the target query point using the preset hash function. Then, based on the hash value of the target query point, the target query area is determined, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
[0038] Thirdly, this application discloses an electronic device, comprising:
[0039] Memory, used to store computer programs;
[0040] A processor is used to execute the computer program to implement the aforementioned data storage and retrieval method.
[0041] Fourthly, this application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed data storage and retrieval method.
[0042] This application first determines the coordinate data of the target point and uses a preset hash function to determine the hash value corresponding to the coordinate data; based on a preset region range value and the coordinate data of the target point, it determines the target region corresponding to the target point and establishes a data structure corresponding to the target region; the hash value and the target region have a unique correspondence; key-value pairs are constructed using the hash value as the key and the coordinate data as the value, and the key-value pairs are stored in the data structure corresponding to the target region; when a query request for a target query point is received, the coordinate data of the target query point is determined, and the preset hash function is used to determine the hash value corresponding to the coordinate data of the target query point; then, based on the hash value of the target query point, the target query region is determined, the target query point is queried from the data structure corresponding to the target query region, and the query result is returned. In this way, the data storage method in this approach can use the coordinate data of the target point to determine its corresponding target region and store the coordinate data of the target point in its corresponding data structure, thereby utilizing the target point for index-partitioned data storage. When querying a target point stored in this way, it is only necessary to determine the target region corresponding to the point according to the hash value of the point, and determine the data structure corresponding to the target region. The query can be performed by comparing the data in the data structure. Using this method, the global search algorithm in three-dimensional Boolean operation can be transformed into a local search algorithm, which facilitates the query of points, reduces the time complexity of the three-dimensional Boolean search algorithm, and thus improves the efficiency of three-dimensional Boolean operation. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0044] Figure 1 A flowchart of a data storage and retrieval method provided in this application;
[0045] Figure 2 A schematic diagram of the display position of a target point provided in this application;
[0046] Figure 3 This application provides a schematic diagram of a map structure.
[0047] Figure 4 A schematic diagram of a map structure based on column data provided in this application;
[0048] Figure 5A flowchart illustrating a specific data storage and retrieval method provided in this application;
[0049] Figure 6 An example diagram of a display position provided for this application;
[0050] Figure 7 A schematic diagram of a data storage and retrieval device provided in this application;
[0051] Figure 8 This application provides a structural diagram of an electronic device. Detailed embodiments are described below.
[0052] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0053] Existing global search methods result in high time complexity for finding points in 3D Boolean operations, leading to low computational efficiency. This application transforms the global search algorithm in 3D Boolean operations into a local search algorithm, reducing the time complexity and thus improving the efficiency of 3D Boolean operations.
[0054] This invention discloses a data storage and retrieval method, see [link to relevant documentation]. Figure 1 The method includes:
[0055] Step S11: Determine the coordinate data of the target point, and use a preset hash function to determine the hash value corresponding to the coordinate data.
[0056] In this embodiment, the target point can be a one-dimensional point, a two-dimensional point, or a three-dimensional point, and the coordinate data of the corresponding point are (x), (x, y), and (x, y, z), respectively. The data type of the coordinate data for each point is double (i.e., double-precision floating-point number), as shown in the code below:
[0057] Point
[0058] {
[0059] double x;
[0060] };
[0061] Point2d
[0062] {
[0063] double x;
[0064] double y;
[0065] };
[0066] Point3d
[0067] {
[0068] double x;
[0069] double y;
[0070] double z;
[0071] };
[0072] In this step, a preset hash function is used to determine the hash value corresponding to the coordinate data. This hash value is used as the key for data storage when constructing the data structure later. Specifically, in this embodiment, a preset range value (range) can be used to encode all infinitely many floating-point numbers within the range of double into a value generated by a preset data type that can be arbitrarily sorted. The preset data type can be int, and is not limited here.
[0073] Taking column data as an example, if the side length of a column is 50 and the center point of the column is (32039, -12467), the coordinates of its four vertices Point are pt0(32014.234876547, -12442.455654356), pt1(32064.234876547, -12442.455654356), pt2(32064.234876547, -12392.455654356), and pt3(32014.234876547, -12392.455654356). This step will use these four vertices as target points and calculate the index code of each vertex Point2d according to range_x=100 and range_y=100.
[0074] Step S12: Determine the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point, and establish a data structure corresponding to the target region; the hash value has a unique correspondence with the target region.
[0075] In this embodiment, determining the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point may include: determining the type of the target point; the type of the target point includes one-dimensional type, two-dimensional type and three-dimensional type; and determining the target region corresponding to the target point based on the type of the target point, the coordinate data of the target point and the preset region range value.
[0076] In this embodiment, a preset area range value and the coordinate data of the target point are used to determine the target area corresponding to the target point. Specifically, when encoding a single double-represented Point data queue (corresponding to a one-dimensional coordinate point), these data represent a range interval in the x-axis direction. Each range interval has a certain key value encoding, and the hash code of points falling within this range is the key value. When encoding two double-represented Point2d data queues (corresponding to two-dimensional coordinate points), these data represent the generation of some interlaced grids along the x and y axes. Each grid has a corresponding hash code as a key value, and the hash code of two-dimensional planar points falling within that grid is the key value. When encoding three double-represented Point3d data queues (corresponding to three-dimensional coordinate points), these data represent the generation of some spatial cubes along the x, y, and z axes. Each cube has a corresponding hash code as a key value, and the hash code of three-dimensional spatial points falling within that space is the key value. In other words, the hash value has a unique correspondence with the target area.
[0077] In one specific implementation, the display position corresponding to the target point can be drawn first based on the coordinate data of the target point and a preset area range value. Then, the target area of the target point is determined based on the display position, where the display position is the location of the target point in the image. The target area can be determined based on the display position. For a one-dimensional point, its display position can be a point on a line segment on a number axis, and its target area is the corresponding line segment. For a two-dimensional point, its display position can be a point in a grid cell of a two-dimensional Cartesian coordinate system, and its target area is the corresponding grid cell. For a three-dimensional point, its display position can be a point in a cube of a three-dimensional Cartesian coordinate system, and its target area is the corresponding cube.
[0078] In a specific implementation, after determining the index code of each vertex of the above-mentioned column data in step S11, this step will determine the target region corresponding to each point. If the current region range value is range_x=100 and range_y=100, then... Figure 2To determine the positions of the points on the explicit graph, specifically the four points located within two grid areas (grid region 1 and grid region 2) defined by the two horizontal lines x=32000 and x=32100 and the three vertical lines y=-12500, y=-12400, and y=-12300, where pt2 and pt3 are located in region 1 (the grid bounded by x=32000, x=32100, y=-12400, and y=-12300) and pt0 and pt1 are located in region 2 (the grid bounded by x=32000, x=32100, y=-12400, and y=-12500), the target region for pt2 and pt3 is defined as region 1, and the target region for pt0 and pt1 is defined as region 2.
[0079] In this step, after determining the target area corresponding to each point, a data structure corresponding to the target area will be established. Specifically, the length of the data structure will be determined according to the number of target areas where the target point is located, and the length of the value corresponding to a certain key in the map structure will be determined according to the number of target points in the target area, wherein the key is a hash value determined based on the coordinate data of the target point.
[0080] In this embodiment, establishing a data structure corresponding to the target region may include: establishing a map structure corresponding to the target region; correspondingly, storing the key-value pairs into a preset data structure corresponding to the target region includes: storing the key-value pairs into the map structure corresponding to the target region. The type of the data structure includes, but is not limited to, a map structure. Figure 3 This is a schematic diagram of a map structure.
[0081] In a specific implementation, taking the above-mentioned column data as an example, since the four points in the column data are located in two target regions, the length of the constructed map structure is 2. Region 1 contains two target points pt2 and pt3, and Region 2 contains two target points pt0 and pt1. Therefore, a map structure of length 2 is constructed, and the length of the corresponding arrays in the two values of the map is determined to be 2. For example... Figure 4 This is the map structure built upon.
[0082] Step S13: Construct key-value pairs using the hash value as the key and the coordinate data as the value, and store the key-value pairs in the data structure corresponding to the target region.
[0083] In one specific implementation, taking the aforementioned column data as an example, the corresponding points in region 1 can be stored in, for example... Figure 4The first element of the map structure stores the points corresponding to region 2 of pt0 and pt1. Specifically, pt2 and pt3 can be stored in the two linked arrays corresponding to the first element of the map structure, and pt0 and pt1 can be stored in the two linked arrays corresponding to the second element of the map structure. This method is equivalent to storing the original coordinate data using an index + array approach. The entire search process involves O(1) index lookup, followed by a search within the linked arrays, significantly reducing the size of n in the search algorithm.
[0084] Step S14: When a query request for a target query point is received, the coordinate data of the target query point is determined, and the hash value corresponding to the coordinate data of the target query point is determined using the preset hash function. Then, the target query area is determined based on the hash value of the target query point, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
[0085] It is understandable that the data storage method in this approach can determine the corresponding target region based on the coordinate data of the target point, and store the target point's coordinate data in its corresponding data structure, thus utilizing the target point for index-partitioned data storage. When querying a target point stored using this method, it is only necessary to determine its corresponding target region based on the hash value of the point, determine the data structure corresponding to the target region, and search for the data within the data structure. This method avoids the global search method used in existing technologies, greatly reducing time complexity and facilitating point queries. It is also understood that the method for determining the hash value based on the point's coordinate data when querying a point is consistent with the hash value determination method used during data storage.
[0086] In this embodiment, when querying a single Point data represented by a double, the index code key value of the data is calculated according to the encoding process of the original data. The range is then retrieved based on the index value, and points falling within that range are compared to return the query result. When querying Point2d data represented by two doubles, the index code key value of the data is calculated according to the encoding process of the original data. The grid area is then retrieved based on the index value, and points falling within that grid area are compared to return the query result. When querying Point3d data represented by three doubles, the index code key value of the data is calculated according to the encoding process of the original data. The three-dimensional space is then retrieved based on the index value, and points falling within that three-dimensional space are compared to return the query result.
[0087] It should be noted that this solution proposes a point data storage and query method, which can be specifically applied to querying points and edges. When querying edges, the target point can be determined as the start and end point of the edge, and then a hash value corresponding to the start and end points is generated based on the range value. The hash function used to generate the hash value can be changed according to requirements and is not limited here. The code implementation process of a specific implementation is as follows:
[0088] template<class T, typename T1> class PMLineHashExt;
[0089] template<> / /
[0090] class PMLineHashExt<HashExt, int> {
[0091] public:
[0092] size_t operator()(const HashExt &ext1, const HashExt &ext2, intrange) const
[0093] {
[0094] / / Range of the sum of x-values of the starting and ending points
[0095] size_t h1 = std::hash <int>()((ext1.x+ext2.x) / range_x);
[0096] / / Range of the sum of y-values of the starting point and the ending point
[0097] size_t h2 = std::hash <int>()((ext1.y+ext2.y) / range_y);
[0098] return h1 ^ (h2 << 1); / / Combine into an easily sortable index key value
[0099] }
[0100] };
[0101] In this embodiment, the data storage and query method is characterized by further including: obtaining the coordinate data error value of the target point; determining the regional range of the target point based on the coordinate data error value of the target point, and determining all points falling within the regional range as the target point. It can be understood that this embodiment also sets a point error value (error) (points within the error range are considered to be the same point), which can restrict the point data expressed by three double-precision floating-point numbers to a regional range of a three-dimensional cube, and all points falling within this three-dimensional region represent that point.
[0102] This embodiment first determines the coordinate data of the target point and uses a preset hash function to determine the hash value corresponding to the coordinate data. Based on a preset region range value and the coordinate data of the target point, it determines the target region corresponding to the target point and establishes a data structure corresponding to the target region. The hash value and the target region have a unique correspondence. Key-value pairs are constructed using the hash value as the key and the coordinate data as the value, and these key-value pairs are stored in the data structure corresponding to the target region. When a query request for a target query point is received, the coordinate data of the target query point is determined, and the preset hash function is used to determine the hash value corresponding to the coordinate data of the target query point. Then, based on the hash value of the target query point, the target query region is determined, the target query point is queried from the data structure corresponding to the target query region, and the query result is returned. In this way, the data storage method in this approach can use the coordinate data of a target point to determine its corresponding target region and store the coordinate data of the target point in its corresponding data structure, thereby utilizing the target point for index-partitioned data storage. When querying a target point stored in this way, it is only necessary to determine the target region corresponding to the point according to the hash value of the point, and determine the data structure corresponding to the target region. The query can be performed by comparing the data in the data structure. Using this method, the global search algorithm in three-dimensional Boolean operation can be transformed into a local search algorithm, which facilitates the query of points, reduces the time complexity of the three-dimensional Boolean search algorithm, and thus improves the efficiency of three-dimensional Boolean operation.
[0103] Figure 5 A flowchart illustrating a specific data storage and retrieval method provided in this application embodiment. See also... Figure 5 As shown, the method includes:
[0104] Step S21: Determine the coordinate data of the target point and determine the preset area range value.
[0105] In this invention, range_x, range_y, and range_z values are used to express the range of the three components x, y, and z of a Point, respectively. For example, when range_x, range_y, and range_z are all 1, the three components of the Point are restricted to the region [0, 0.99999999...).
[0106] Step S22: Based on the coordinate data and the preset area range value, determine the index value corresponding to the target point using a preset index value calculation method.
[0107] Step S23: Determine the preset data type of the hash value, and use the preset hash function to determine the hash value corresponding to the index value and generated with the preset data type.
[0108] In this embodiment, taking a two-dimensional point as an example, the hash value can be generated in the following way:
[0109] template<class T, typename T1> class PMHashExt;
[0110] template<> / /
[0111] class PMHashExt<HashExt, int> {
[0112] public:
[0113] size_t operator()(const HashExt &ext, int range) const
[0114] {
[0115] int h1 = std::hash <int>()(ext.x / range_x); / / Low-order index data
[0116] int h2 = std::hash <int>()(ext.y / range_y); / / High-order index data
[0117] return h1 ^ (h2 << 1); / / Combine the data into a 64-bit integer for region indexing.
[0118] };
[0119] std::map<int,PmGePoint3dArray> ptsMapAry;
[0120] In step S23, the corresponding index values h1 and h2 can be determined using the coordinate data of the target point and the values of range_x and range_y. h1 and h2 are then combined into an integer. The value of the returned integer is the hash value in this embodiment. The integer can then be used to perform a region index.
[0121] Step S24: Determine the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point, and establish a data structure corresponding to the target region; the hash value has a unique correspondence with the target region.
[0122] For a more detailed description of the process of step S24, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0123] Step S25: Construct key-value pairs using the hash value as the key and the coordinate data as the value, and determine a preset sorting method based on the preset data type.
[0124] In this embodiment, a preset sorting method can be determined based on the preset data type, i.e., the data type of the hash value, and then the key-value pairs can be stored accordingly based on the sorting method.
[0125] Step S26: Store the key-value pairs into a preset data structure corresponding to the target region according to a preset sorting method.
[0126] In this embodiment, after determining the preset sorting method in step S25, the preset sorting method can be used for storage when storing key-value pairs, thereby enhancing the orderliness of storage in this method.
[0127] Step S27: When a query request for a target query point is received, the coordinate data of the target query point is determined, and the hash value corresponding to the coordinate data of the target query point is determined using the preset hash function. Then, the target query area is determined based on the hash value of the target query point, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
[0128] In this embodiment, the data storage and query method may further include: obtaining an updated value of the regional range value through a preset regional range value acquisition interface, and updating the current regional range value to the updated value of the regional range value.
[0129] In this embodiment, the preset region range largely determines the target region of the target point. Therefore, this solution requires the preset region range value to be as appropriate as possible. Figure 6 The three bars in the image are arranged such that the left bar is located in one index region, the middle bar is located in four index regions, and the right bar is located in two index regions. Therefore, the lengths of the map structures built from the three bars from left to right are 1, 4, and 2, respectively. In this case, the selection of range_x and range_y for the middle bar is inappropriate. When searching for data, it will degenerate into a one-to-one search, that is, a global search will be used.
[0130] It is understood that the area range value can also be updated in this embodiment. If the area range value is not selected appropriately, the area range value can be adjusted to complete the data storage and retrieval more efficiently.
[0131] This embodiment first determines the coordinate data of the target point and uses a preset hash function to determine the hash value corresponding to the coordinate data. Based on a preset region range value and the coordinate data of the target point, it determines the target region corresponding to the target point and establishes a data structure corresponding to the target region. The hash value and the target region have a unique correspondence. Key-value pairs are constructed using the hash value as the key and the coordinate data as the value, and these key-value pairs are stored in the data structure corresponding to the target region. When a query request for a target query point is received, the coordinate data of the target query point is determined, and the preset hash function is used to determine the hash value corresponding to the coordinate data of the target query point. Then, based on the hash value of the target query point, the target query region is determined, the target query point is queried from the data structure corresponding to the target query region, and the query result is returned. In this way, the data storage method in this approach can use the coordinate data of the target point to determine its corresponding target region and store the coordinate data of the target point in its corresponding data structure according to a preset sorting method, thereby utilizing the target point for index-partitioned data storage. When querying target points stored using this method, it is only necessary to determine the corresponding target region based on the hash value of the point, and then determine the data structure corresponding to the target region. The query is then performed by comparing the data within the data structure. This method transforms the global search algorithm in 3D Boolean operations into a local search algorithm, facilitating point queries, reducing the time complexity of 3D Boolean search algorithms, and thus improving the efficiency of 3D Boolean operations. Furthermore, this method can be applied not only to point queries but also to edge queries, making it highly practical.
[0132] See Figure 7 As shown in the figure, this application discloses a data storage and retrieval device, which may specifically include:
[0133] The hash value determination module 11 is used to determine the coordinate data of the target point and use a preset hash function to determine the hash value corresponding to the coordinate data;
[0134] The data structure establishment module 12 is used to determine the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point, and to establish a data structure corresponding to the target region; the hash value has a unique correspondence with the target region;
[0135] The key-value pair storage module 13 is used to construct key-value pairs by using the hash value as the key and the coordinate data as the value, and to store the key-value pairs in the data structure corresponding to the target region;
[0136] The target query point query module 14 is used to determine the coordinate data of the target query point when a query request for the target query point is received, and to determine the hash value corresponding to the coordinate data of the target query point using the preset hash function. Then, based on the hash value of the target query point, the target query area is determined, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
[0137] This embodiment first determines the coordinate data of the target point and uses a preset hash function to determine the hash value corresponding to the coordinate data. Based on a preset region range value and the coordinate data of the target point, it determines the target region corresponding to the target point and establishes a data structure corresponding to the target region. The hash value and the target region have a unique correspondence. Key-value pairs are constructed using the hash value as the key and the coordinate data as the value, and these key-value pairs are stored in the data structure corresponding to the target region. When a query request for a target query point is received, the coordinate data of the target query point is determined, and the preset hash function is used to determine the hash value corresponding to the coordinate data of the target query point. Then, based on the hash value of the target query point, the target query region is determined, the target query point is queried from the data structure corresponding to the target query region, and the query result is returned. In this way, the data storage method in this approach can use the coordinate data of a target point to determine its corresponding target region and store the coordinate data of the target point in its corresponding data structure, thereby utilizing the target point for index-partitioned data storage. When querying a target point stored in this way, it is only necessary to determine the target region corresponding to the point according to the hash value of the point, and determine the data structure corresponding to the target region. The query can be performed by comparing the data in the data structure. Using this method, the global search algorithm in three-dimensional Boolean operation can be transformed into a local search algorithm, which facilitates the query of points, reduces the time complexity of the three-dimensional Boolean search algorithm, and thus improves the efficiency of three-dimensional Boolean operation.
[0138] Furthermore, embodiments of this application also disclose an electronic device, Figure 8 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of use of this application.
[0139] Figure 8 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a display screen 24, an input / output interface 25, a communication interface 26, and a communication bus 27. The memory 22 is used to store computer programs, which are loaded and executed by the processor 21 to implement the relevant steps in the data storage and retrieval methods disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0140] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 26 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0141] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222 and virtual machine data 223, etc., and the storage method can be temporary storage or permanent storage.
[0142] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs capable of performing the data storage and retrieval methods executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0143] Furthermore, this application also discloses a computer-readable storage medium, which includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, magnetic disks, optical disks, or any other form of storage medium known in the art. When the computer program is executed by a processor, it implements the aforementioned data storage and retrieval method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0144] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatuses disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section. Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0145] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0146] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0147] The data storage and retrieval method, apparatus, device, and storage medium provided by the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.< / int> < / int> < / int> < / int>
Claims
1. A data storage and retrieval method, characterized in that, include: Determine the coordinate data of the target point, and use a preset hash function to determine the hash value corresponding to the coordinate data; The target region corresponding to the target point is determined based on the preset region range value and the coordinate data of the target point, and a data structure corresponding to the target region is established; the hash value has a unique correspondence with the target region; The hash value is generated by using a preset area range value to encode all floating-point numbers within the preset area range value into a value generated with a preset data type using a preset hash function; The step of determining the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point includes: drawing the display position corresponding to the target point based on the coordinate data of the target point and the preset region range value, and determining the target region corresponding to the target point based on the display position corresponding to the target point; the display position is the display position of the target point in the image; Key-value pairs are constructed using the hash value as the key and the coordinate data as the value, and the key-value pairs are stored in the data structure corresponding to the target region; When a query request for a target query point is received, the coordinate data of the target query point is determined, and the hash value corresponding to the coordinate data of the target query point is determined using the preset hash function. Then, the target query area is determined based on the hash value of the target query point, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
2. The data storage and query method according to claim 1, characterized in that, The process of determining the coordinate data of the target point and using a preset hash function to determine the hash value corresponding to the coordinate data includes: Determine the coordinates of the target point and the preset area range. Based on the coordinate data and the preset area range value, the index value corresponding to the target point is determined using a preset index value calculation method; A hash value corresponding to the index value and generated with a preset data type is determined using a preset hash function.
3. The data storage and query method according to claim 2, characterized in that, Before determining the hash value corresponding to the index value and generated with a preset data type using a preset hash function, the method further includes: Determine the default data type for the hash value; Accordingly, storing the key-value pair into a preset data structure corresponding to the target region includes: A preset sorting method is determined based on the preset data type; The key-value pairs are stored in a preset data structure corresponding to the target region according to a preset sorting method.
4. The data storage and query method according to claim 1, characterized in that, The step of determining the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point includes: Determine the type of the target point; the type of the target point includes one-dimensional, two-dimensional, and three-dimensional types. The target area corresponding to the target point is determined based on the type of the target point, the coordinate data of the target point, and the preset area range value.
5. The data storage and query method according to claim 1, characterized in that, The establishment of the data structure corresponding to the target region includes: Establish a map structure corresponding to the target region; Accordingly, storing the key-value pair into a preset data structure corresponding to the target region includes: The key-value pairs are stored in a map structure corresponding to the target region.
6. The data storage and query method according to claim 2, characterized in that, Also includes: The updated value of the region range is obtained through the preset region range value acquisition interface, and the current region range value is updated to the updated value of the region range value.
7. The data storage and retrieval method according to any one of claims 1 to 6, characterized in that, Also includes: Obtain the coordinate data error value of the target point; The region of the target point is determined based on the coordinate data error value of the target point, and all points falling within the region are identified as the target points.
8. A data storage and retrieval device, characterized in that, include: The hash value determination module is used to determine the coordinate data of the target point and use a preset hash function to determine the hash value corresponding to the coordinate data. A data structure establishment module is used to determine the target region corresponding to the target point based on a preset region range value and the coordinate data of the target point, and to establish a data structure corresponding to the target region; the hash value has a unique correspondence with the target region; The hash value is generated by using a preset area range value to encode all floating-point numbers within the preset area range value into a value generated with a preset data type using a preset hash function; The step of determining the target region corresponding to the target point based on the preset region range value and the coordinate data of the target point includes: drawing the display position corresponding to the target point based on the coordinate data of the target point and the preset region range value, and determining the target region corresponding to the target point based on the display position corresponding to the target point; the display position is the display position of the target point in the image; The key-value pair storage module is used to construct key-value pairs by using the hash value as the key and the coordinate data as the value, and to store the key-value pairs in the data structure corresponding to the target region; The target query point query module is used to determine the coordinate data of the target query point when a query request for the target query point is received, and to determine the hash value corresponding to the coordinate data of the target query point using the preset hash function. Then, based on the hash value of the target query point, the target query area is determined, the target query point is queried from the data structure corresponding to the target query area, and the query result is returned.
9. An electronic device, characterized in that, It includes a processor and a memory; wherein, when the processor executes a computer program stored in the memory, it implements the data storage and retrieval method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used for storing computer programs; wherein, when the computer programs are executed by a processor, they implement the data storage and retrieval method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Efficient distributed locality sensitive Hashing method
CN107391554A