A spatial data management method and electronic device and storage medium thereof
By dividing the space into multiple grid spaces in the spatial data management system and dynamically adjusting the number of processes, the performance bottlenecks and scalability problems of existing systems when facing a large amount of user data are solved, and more efficient data management and resource utilization are achieved.
Patent Information
- Application Number
- CN202411625048.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-11-14
AI Technical Summary
When the existing spatial data management system faces a large amount of user data, communication overhead becomes a performance bottleneck, the system is not scalable, and it is difficult to cope with the problem of skewed data distribution.
By dividing the continuous space into multiple grid spaces, each grid space is managed by one or more spatial data management processes. When the number of users exceeds the threshold, the scheduler divides the grid space and activates more processes to share the load; when the number of users decreases, the process is merged to optimize resource usage.
It improves the scalability of the distributed data management system and the ability to process skewed data distribution, can more effectively carry a large number of users, and improves the stability and resource utilization of the system.
Smart Images

Figure CN119166724B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of distributed storage technology, and in particular relates to a spatial data management method and electronic equipment and storage medium thereof. Background Art
[0002] With the increase in the number of Internet users and the popularity of online social networking, games and other applications, people's demand for real-time interaction with tens of thousands of people has also increased. In the scenario of tens of thousands of people interacting, since the frequency of interaction between users is significantly higher than that of hundreds or thousands of people, it is necessary to effectively manage the spatial data in the space to meet the needs of users for real-time interaction. At the same time, in application scenarios such as games, hot spots may appear in the map to attract a large number of players to gather, resulting in a spatial tilt of user data, which puts higher requirements on the spatial data management system.
[0003] Traditional spatial indexing algorithms include quadtree indexing and R-tree indexing. Quadtree indexing (see [Finkel, RA; Bentley, JL (1974). "Quad trees a data structure for retrieval on composite keys". Acta Informatica. 4 (1): 1–9. Retrieved 6 November 2019]) partitions the global map and recursively divides the map block into four sub-map blocks to form a quadtree. When querying neighboring objects, traversing the tree structure will reduce the query efficiency; R-tree indexing (see [Guttman, A. (1984). "R-Trees: A Dynamic Index Structure for Spatial Searching" (PDF). Proceedings ofthe 1984 ACM SIGMOD international conference on Management of data – SIGMOD '84. p. 47]) The nodes are split by aggregating some objects in a map block into a minimum bounding rectangle. The complex splitting algorithm makes the index maintenance cost high. Neither the quadtree index nor the R-tree index is optimized for distributed environments. The commonly used Redis database currently supports distributed deployment and integrates the GeoHash algorithm. It determines the location of objects on the earth by longitude and latitude coordinates and performs range queries on other objects within a certain range. The distributed deployment of Redis is a simple multi-copy deployment, which ensures consistency through broadcast update operations. The performance decreases as the number of copies increases, and it can only support a small number of application scenarios because it only supports the geodetic coordinate system.
[0004] From the above analysis, it can be seen that most of the existing solutions do not adopt distributed systems, resulting in system performance being limited to a single machine, such as quadtrees and R-trees; secondly, the communication methods of some distributed system solutions are too simple, resulting in communication overhead becoming a performance bottleneck when facing a large amount of user data, and the system's scalability is not high, such as Redis's GeoHash component; finally, most distributed spatial data management systems divide the space of different regions in a relatively uniform way, making it difficult for the system to cope with skewed data distribution. When the division granularity is large, the workload in the hot spot area is large, and when the division granularity is small, resources are wasted in non-hot spot areas. Summary of the invention
[0005] In view of the above, the present invention provides a spatial data management method, which can improve the scalability of a distributed data management system and the ability to handle skewed data distribution, and increase the number of users that the system can carry.
[0006] A spatial data management method is applied to a spatial data management system, wherein the spatial data management system is used to manage spatial data in a continuous space, wherein the continuous space is divided into a plurality of grid spaces, each grid space having its own spatial data, and the spatial data management system comprises a scheduler and a series of spatial data management processes, wherein the states of the spatial data management processes are activated or inactivated, wherein the activated spatial data management processes are used to manage the spatial data of the grid spaces, and the inactivated spatial data management processes do not manage the spatial data; the spatial data management method comprises:
[0007] When the number of users in any grid space is greater than the set threshold, the scheduler sends a split instruction to the spatial data management process corresponding to the grid space, and sends an activation request to several inactivated spatial data management processes at the same time. The activation request carries the unique identifier of the grid space, and manages the corresponding grid space by making these inactivated spatial data management processes activated.
[0008] The spatial data management process that receives the segmentation instruction segments the grid space, and then manages the segmented grid space in conjunction with the newly activated spatial data management process.
[0009] The above technical features should be understood as follows: when the number of users in any grid space is greater than the threshold, the corresponding spatial data management process may not be able to efficiently handle the increased load, resulting in an increase in response time, and in severe cases, causing the spatial data management system to crash. In this case, the scheduler can relieve the pressure on the original spatial data management process by scheduling and splitting the grid space, activating more spatial data management processes and assigning some users' operation requests to the newly activated spatial data management process, thereby improving the processing efficiency of each process and thus improving the stability and reliability of the data management system. When any grid space is split, the number of users in the split grid space is still greater than the preset threshold, the scheduler continues to split the split grid space through scheduling, and activates these spatial data management processes, and each spatial data management process manages one of the split grid spaces.
[0010] Furthermore, when there are several spatial data management processes that belong to the same divided grid space and the total amount of spatial data is less than a threshold, the scheduler sends a merge instruction to these spatial data management processes, and the merge instruction carries the unique identifier of the spatial data management process. The instruction is used to instruct these spatial data management processes to merge the corresponding grid spaces into one grid space, and designate one of the spatial data management processes to manage the merged grid space, and the remaining spatial data management processes release the management of the original grid space and switch to an inactivated state.
[0011] The above technical features should be understood as follows: after a grid space is divided, if the total number of spatial data of the spatial data management process corresponding to the divided grid space is less than the threshold, it means that only one spatial data management process is needed to process the operation requests of users in these grid spaces. If the spatial data management system continues to maintain additional spatial data management processes to handle the reduced load, it may lead to resource waste; in order to optimize resource usage, the scheduler dynamically adjusts resource allocation by sending a merge instruction to this group of spatial data management processes. This method of adjusting resources according to the number of users helps the spatial data management system to cope with different loads more effectively and ensures that the spatial data management system can provide high frame rate, high reliability and high flexibility spatial data management services. After a group of grid spaces are merged, if the total number of spatial data of the group of spatial data management processes is still less than the threshold, the scheduler schedules the group of spatial data management processes to continue merging, designates one of the spatial data management processes to manage the merged grid space, and the remaining spatial data management processes release the management of the original grid space and switch to an inactive state.
[0012] Furthermore, the activated spatial data management process receives an operation instruction sent by a client, wherein the client is a client to which a user belongs in the grid space, and the operation instruction includes a data update operation or a range query operation, wherein the data update operation is used to indicate an operation in which a user's location has changed, and the range query operation is used to query information of other users within a query range, and the query range is an area formed by extending outward from a specified distance with the user's location as the center point; the spatial data management process sends an update value obtained by the data update operation or a query result obtained by the range query operation to the client.
[0013] Furthermore, before receiving the operation instruction sent by the client, the spatial data management process has established a communication connection with the client, and the communication connection is used for data transmission between the client and the spatial data management process; when the user corresponding to the client moves from the original grid space to other grid spaces, the client disconnects the communication connection with the spatial data management process corresponding to the original grid space, thereby establishing a new communication connection with the spatial data management process corresponding to the other grid space.
[0014] The above technical features should be understood as follows: after crossing the grid space, the client switches the communication connection to the spatial data management process corresponding to the new grid space, ensuring the continuity of the user's use of the service and avoiding consequences such as interruptions or erroneous results.
[0015] Further, each grid space includes a plurality of unit spaces, each of which has respective spatial data, and the spatial data includes user data in the unit space; in the case of receiving a range query operation sent by a user through a client, the spatial data management process determines whether a user in the unit space specified by the range query operation is within a query range, wherein the unit space specified by the range query operation includes a unit space in which a portion of user data is within the query range and another portion of user data is not within the query range, or a unit space in which all user data is within the query range;
[0016] When the spatial data management process receives data update operation A sent by user A through the client and also receives data update operation B sent by user B through the client, the spatial data management process updates the data of user A and the data of user B in parallel, where user A is located in unit space A, user B is located in unit space B, and unit space A and unit space B belong to the same grid space.
[0017] The above technical features should be understood as follows: in terms of range query operations, when the grid space is not divided into unit spaces, the spatial data management process needs to make judgments in the entire grid space when performing range queries, so that each query needs to process a large amount of data, resulting in low query efficiency; if the grid space is divided into multiple unit spaces, the spatial data management process only needs to focus on the relevant unit spaces when performing range queries, which can reduce the amount of data processed and improve query efficiency. In addition, in terms of update operations, when the grid space is not divided into unit spaces, the spatial data management process needs to lock the entire grid space, and the spatial data management process can only process the update operation request of one user in the grid space at the same time, and the parallel processing capability is limited, resulting in low update efficiency; if the grid space is divided into multiple unit spaces, when receiving requests from users in different unit spaces, the spatial data management process can lock different unit spaces separately, thereby allowing data in different unit spaces to be updated in parallel, improving update efficiency.
[0018] The grid space can be any one of two-dimensional space, three-dimensional space, etc. The present invention can support various space types, and can select appropriate spatial coordinate systems and query methods according to the space type. This flexibility enables the spatial data management system to improve query accuracy and adapt to different scenarios, and has high applicability.
[0019] A spatial data management device, comprising:
[0020] Storage module, used to store user data in a certain area and process data update and range query requests of all users in a grid space;
[0021] The scheduling module is used to monitor the data distribution status in the grid space, send a segmentation instruction to the spatial data management process whose spatial data volume is greater than a threshold, and send a merge instruction to several spatial data management processes that belong to the same segmented grid space and whose total spatial data volume is less than a threshold;
[0022] The communication module is used to send and receive the splitting and merging instructions of the scheduler to the spatial data management process, send and receive the data update and range query requests of the client to the spatial data management process, and send and receive the return results of the data update and range query requests of the spatial data management process to the client.
[0023] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the above-mentioned spatial data management method.
[0024] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the spatial data management method is implemented.
[0025] The spatial data management method of the present invention includes distributed storage, distributed communication framework, and dynamic load balancing. By sharding all spatial data, spatially similar data are stored in the same spatial data management process. The spatial data management process only synchronizes data with other spatially similar spatial data management processes. The scheduler dynamically adjusts the grid space distribution according to the spatial data distribution. On the one hand, the present invention uses multiple nodes of the distributed system to share the load from the client, and can handle more user updates and range query requests; on the other hand, by dynamically adjusting the grid space, it can cope with extreme scenarios such as large-scale gathering of users, has stronger adaptability and a wider range of application scenarios, and improves resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a schematic diagram of the overall architecture of an embodiment of the present invention applied to a multi-person interaction system.
[0027] Figure 2 Schematic diagram of the flow of the spatial data management method in an embodiment of the present invention.
[0028] Figure 3 A schematic diagram of a spatial area maintained by a spatial data management process in an embodiment of the present invention.
[0029] Figure 4 Schematic diagram of the process of grid space splitting and merging in an embodiment of the present invention.
[0030] Figure 5 The figure is a flowchart of a method for initializing a multi-person interactive system according to an embodiment of the present invention.
[0031] Figure 6 The figure is a schematic diagram of the structure of an electronic device implemented according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to describe the present invention more specifically, the technical solution of the present invention is described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0033] like Figure 1 The figure shows a multi-person interactive system architecture applying the present invention, including a client 110, a spatial data management system 120 and a server cluster 130, wherein the client 110 and the spatial data management system 120 as well as the spatial data management system 120 and the server cluster 130 are connected via a network, which may be a wide area network or a local area network.
[0034] The client 110 is used to participate in online multi-person interactive applications, which may be online concerts, virtual shopping, multi-person games, etc. The client 110 may be software or an application running on a terminal device or computing device controlled by a user, such as a personal computer client, a World Wide Web (WWW) client accessed through a browser, or an application (APP) client running on a mobile terminal.
[0035] The spatial data management system 120 is used to manage spatial data in a continuous space where multi-person interactions are located, wherein the space is a virtual space provided by a multi-person interactive application, such as a game space in a multi-person game, a shopping environment in a virtual shopping mall, etc. The space is a two-dimensional space, a three-dimensional space, or even a higher-dimensional space, and the space includes multiple grid spaces, and the number of grid spaces can be multiple or dozens, hundreds, thousands, or even more. The shape of the grid space is a square or a cube, and each of the multiple grid spaces has its own spatial data. The spatial data is a collection of information about various elements in the virtual space provided by the multi-person interactive application, such as the position information and status information of players in a multi-person game, the position information and attribute information of objects in a multi-person game scene, etc.
[0036] One or more spatial data management processes in the activated state are run in the spatial data management system 120. The spatial data management process in the activated state is used to manage the spatial data of the corresponding grid space. The states of the spatial data management process include activated and inactivated. The inactivated state of the spatial data management process is used to indicate that the spatial data management process does not manage the grid space, and the activated state of the spatial data management process is used to indicate that the spatial data management process manages a grid space. Each spatial data management process in the activated state establishes a connection with its related spatial data management process for communication. Among them, the related spatial data management process refers to the spatial data management process that manages the adjacent grid space of the grid space managed by the current spatial data management process. The adjacent grid spaces of the grid space are not limited to those grid spaces that are in contact with the grid space on the boundary and share a part of the boundary; the grid spaces involved in the maintenance space area of the grid space are all regarded as the adjacent grid spaces of the grid space.
[0037] The spatial data management system 120 also includes a scheduler, which is a process used to monitor the status of each spatial data management process in the multiple spatial data management processes and monitor the user distribution of each grid space in the multiple grid spaces.
[0038] The spatial data management system 120 is deployed on a single computing device or a computing device cluster consisting of multiple computing devices, where the computing devices include bare metal servers (BMS), virtual machines, containers or edge computing devices. BMS refers to a general physical server, such as an ARM server or an X86 server; a virtual machine refers to a complete computer system with complete hardware system functions and running in a completely isolated environment, which is implemented by software simulation using the Network Functions Virtualization (NFV) technology; a container refers to a group of processes that are resource-constrained and isolated from each other; an edge computing device refers to a device that is closer to the data source and end user and has low latency and high bandwidth characteristics, such as smart routing, edge servers, etc.
[0039] The server cluster 130 is used to perform calculations and judgments based on the spatial data provided by the spatial data management system 120. Each server in the server cluster 130 can calculate the updated value of the spatial data after the data is updated based on the spatial data provided by the spatial data management system 120, and can also judge the spatial data provided by the spatial data management system 120 based on business logic, etc. Each server in the server cluster 130 can be a BMS, a virtual machine, a container, or an edge server. In actual applications, the server cluster can also be set within the spatial data management system 120.
[0040] like Figure 2 The figure shows a spatial data management method executed by the spatial data management system 120, which specifically includes the following steps:
[0041] S21: The client initiates an update request to the first spatial data management process.
[0042] The first spatial data management process manages the data in the first grid space to which the user data corresponding to the client belongs. The state of the first spatial data management process is activated. The first grid space includes multiple unit spaces, and each unit space has independent spatial data. The update request includes a user identifier (ID) and an update value. The update value is the data that causes the user's information to change after the user performs a data update operation. The number of parameters included in the update value is one or more, such as the user's latest location and the user's latest status.
[0043] In this embodiment, the process of searching for user information according to the data update operation instruction by the first space data management process is different from the prior art, specifically:
[0044] First, the first spatial data management process searches for the user's location in the location information table according to the user's ID in the data update instruction. The first spatial data management process stores a location information table, which records the location information of users whose locations in space belong to the first grid space. Each record in the location information table is stored in the form of "user ID: user's location", and the user's location is represented in the form of coordinates.
[0045] Then, the first spatial data management process determines the unit space to which the user belongs based on the user's position; the first spatial data management process divides the user's coordinates by the side length of the unit space and takes the integer part. According to the position and unit space mapping rule, the first spatial data management process obtains the identifier of the unit space to which the user belongs after the user performs the data update operation, and then determines the grid space to which the user belongs after the user performs the data update operation. Among them, the position and unit space mapping rule refers to the rule of converting the coordinates of the unit space obtained by dividing the user's position coordinates by the side length of the unit space and then rounding it to the identifier of the unit space. The position and unit space mapping rule is sent by the scheduler to the first spatial data management process after the scheduler establishes a connection with the first spatial data management process. The first spatial data management process has established a connection with the scheduler before initialization, and the identifier of the unit space is the unique identifier of the unit space.
[0046] Finally, in the unit space to which the user belongs, the first space data management process searches for the user's information according to the user's ID.
[0047] S22: The first spatial data management process forwards the update request to the second spatial data management process.
[0048] If the first spatial data management process determines that the update request is located in the spatial area maintained by the second spatial data management process, the first spatial data management process needs to forward the update request to the second spatial data management process so that the second spatial data management process synchronously updates the request.
[0049] by Figure 3 For example, the fifth spatial data management process in the fifth grid space manages the spatial data in the fifth grid space, and the status of the fifth spatial data management process is activated. The adjacent grid spaces of the fifth grid space include the first grid space, the second grid space, the third grid space, the fourth grid space, the sixth grid space, the seventh grid space, the eighth grid space, and the ninth grid space. Starting from the left boundary of the fifth grid, a query radius is extended outward to form a spatial region ( Figure 3The spatial area in the fourth grid is a part of the fourth grid space. Similarly, by taking the upper left corner, upper boundary, upper right corner, right boundary, lower left corner, lower boundary and lower right corner of the fifth grid as the starting position and expanding a query radius outward, the spatial area formed can be formed. Figure 3 The spatial area 1, spatial area 2, spatial area 3, spatial area 5, spatial area 6, spatial area 7 and spatial area 8 in the fifth spatial data management process. The spatial area maintained by the fifth spatial data management process includes the fifth grid space, spatial area 1, spatial area 2, spatial area 3, spatial area 4, spatial area 5, spatial area 6, spatial area 7 and spatial area 8. However, the fifth spatial data management process has modification authority and query authority for the spatial data in the fifth grid space, and only has query authority for the spatial data in spatial area 1, spatial area 2, spatial area 3, spatial area 4, spatial area 5, spatial area 6, spatial area 7 and spatial area 8. The range of the spatial area maintained by the spatial data management process can be expressed as follows: on the x-axis, the range satisfies the interval [grid space x-coordinate lower bound - query radius, grid space x-coordinate upper bound + query radius], and on the y-axis, the range satisfies the interval [grid space y-coordinate lower bound - query radius, grid space y-coordinate upper bound + query radius].
[0050] By extending the spatial area maintained by the activated spatial data management process to part of the spatial area within the adjacent grid space of the grid space managed by the activated spatial data management process, the amount of data transmitted between the activated spatial data management process and related spatial data management processes can be reduced, thereby reducing communication overhead, reducing network latency and saving bandwidth.
[0051] S23: The space data management process processes the update request and updates the new data into the corresponding unit space.
[0052] The process of the spatial data management process updating the data of the user in the unit space to which the user belongs based on the update value is as follows: first, the spatial data management process can determine the unit space to which the user belongs according to the method in S21 in which the first process determines the unit space to which the user belongs according to the user's position. Among them, the mapping rule between the position and the unit space is sent to the spatial data management process by the scheduler after the scheduler establishes a connection with the spatial data management process. Then, the spatial data management process searches for the user's data based on the user's ID; then, the spatial data management process locks the unit space and updates the update value to the user's data. Among them, the spatial data management process locks the unit space to ensure that the spatial data management process can only update the user's data, and cannot modify the data of other users in the unit space at the current moment, so as to ensure the consistency and security of the data.
[0053] By implementing the steps of processing update requests by the spatial data management process, the spatial data management process can be enabled to process range query requests from users in different unit spaces in parallel. For example, when the spatial data management process receives a first data update operation request sent by a first user through a first client and receives a second data update operation request sent by a second user through a second client, the spatial data management process can update the data of the first user in the first unit space and the data of the second user in the second unit space in parallel, wherein the first user is located in the first unit space, the second user is located in the second unit space, the first unit space and the second unit space are not the same unit space, and the first grid space includes the first unit space and the second unit space.
[0054] S24: The spatial data management process sends the update request result to the client.
[0055] S25: The client disconnects from the first spatial data management process and establishes a connection with the second spatial data management process.
[0056] After the client receives the update request result, it first determines whether the user's spatial position before and after the update is in the same grid space. The process of the client calculating the grid space to which the spatial position belongs is as follows: the client divides the user's coordinates by the side length of the grid space, then takes the integer part to obtain the coordinates of the grid space; according to the position and grid space mapping rule, the client obtains the identifier of the grid space to which the user belongs after the user performs the data update operation. Among them, the position and grid space mapping rule refers to the rule of converting the coordinates of the grid space obtained by dividing the user's position coordinates by the side length of the grid space and then rounding it to the integer to convert the grid space coordinates into the identifier of the grid space. The position and grid space mapping rule is sent to the client by the scheduler after the scheduler establishes a connection with the client.
[0057] For example, the user's position is (15, 25), the side length of the grid space is 10, 15 is divided by 10 and rounded to 1, 25 is divided by 10 and rounded to 2, and the obtained grid space coordinates (1, 2) are converted to the grid space label. For example, the grid space label may be "01-02".
[0058] If the client determines that the user space position before and after the update is not in the same grid space, and is located in the first grid space before the update and in the second grid space after the update, the client will disconnect from the first space data management process and establish a connection with the second space data management process.
[0059] S26: The client sends a range query request to the second spatial data management process, and the second spatial data management process sends a range query result to the client.
[0060] The spatial data management process will also receive range query operation instructions sent by the client. The range query operation is used to query the information of other users within the query range except the user who initiated the range query operation instruction. The range query operation instruction carries the user's ID. The difference between the process of the spatial data management process in the present application to search for information of other users except the user based on the user's ID and the prior art is that the spatial data management process in the present embodiment determines whether the user in the unit space specified by the range query operation is within the query range. Among them, the query range refers to the area formed by expanding outward by a specified distance with the user's location as the center point, and the spatial unit specified by the range query operation includes the unit space that overlaps with the query range.
[0061] In one implementation, first, the spatial data management process finds the location of the user based on the user ID; then, the spatial data management process determines the coordinates of the first location and the second location. In one implementation, the spatial data management process subtracts a query radius from the value of the user's location on the x-axis and a query radius from the value on the y-axis, thereby determining the coordinates of the first location, and adds a query radius to the value of the user's location on the x-axis and a query radius to the value on the y-axis, thereby determining the coordinates of the second location; then, the spatial data management process calculates the identifier of the unit space to which the first location belongs and the identifier of the unit space to which the second location belongs; then, the spatial data management process determines the identifier of the specified unit space. In one implementation, the spatial data management process calculates the coordinates of all unit spaces that are within the range of [x1, x2] and [y1, y2], converts the calculated coordinates into the identifier of the unit space, and thereby obtains the identifier of the specified unit space, where the coordinates of the unit space to which the first position belongs are (x1, y1), and the coordinates of the unit space to which the second position belongs are (x2, y2); finally, the spatial data management process searches for information about users within the query range in the specified unit space.
[0062] like Figure 4 As shown, the specific process of grid space splitting and merging in this embodiment is as follows:
[0063] S41: The scheduler determines that the total amount of user data in the first grid space exceeds a threshold, and sends a split instruction to the first space data management process and the inactivated space management process.
[0064] S42: The first space data management process divides the first space.
[0065] S43: The inactivated space data management process obtains part of the segmented space data from the first space management process.
[0066] S44: The inactivated spatial data management process changes its own state to activated and sends current state information to the scheduler.
[0067] When the scheduler detects that the number of users in the first grid space is greater than a preset threshold, the scheduler sends a split instruction to the first space data management process, the third space data management process, the fourth space data management process, and the fifth space data management process. The split instruction carries the identifier of the first grid space and the address of the first grid space. The third space data management process, the fourth space data management process, and the fifth space data management process are in an inactive state before the split, and the third space data management process, the fourth space data management process, and the fifth space data management process are in an activated state after the split. In one implementation, the scheduler selects one of the inactive processes from multiple inactive space data management processes as the third space data management process based on a common scheduling algorithm, and then sends a split instruction to the third space data management process; for example, the scheduling algorithm can adopt a scheduling algorithm with the longest waiting time. When the third space data management process, the fourth space data management process, and the fifth space data management process are activated, the first space data management process divides the first grid space into the third grid space, the fourth grid space, the fifth grid space, and the sixth grid space. The first space data management process manages the data of users in the third grid space, the third space data management process manages the data of users in the fourth grid space, the fourth space data management process manages the data of users in the fifth grid space, and the fifth space data management process manages the data of users in the sixth grid space. The corresponding clients are connected to the new space data management processes.
[0068] S45: The scheduler determines that the total amount of user data in the original first grid space is less than a threshold, and sends a merge instruction to the space management process in the original first grid space.
[0069] S46: The spatial data management process sends the data in the grid space to the first spatial data management process.
[0070] S47: The spatial data management process changes its own status to inactive and sends current status information to the scheduler.
[0071] After the scheduler wakes up the third space data management process, the fourth space data management process, and the fifth space data management process, if the scheduler detects that the number of users in the original first grid space is less than or equal to the preset threshold, the scheduler sends a merge instruction to the first space data management process, the third space data management process, the fourth space data management process, and the fifth space data management process, wherein the merge instruction carries the identifier of the first grid space and the address of the first space data management process. After receiving the merge instruction, the third space data management process, the fourth space data management process, and the fifth space data management process send the data in their respective grid spaces to the first space data management process, and then release the management of the corresponding grid space and enter the unactivated state; the first space data management process merges the four grid spaces into the first grid space, and manages the data of the users in the first grid space, and the corresponding client is connected to the first space data management process.
[0072] In summary, this embodiment describes in detail the process of implementing spatial data management when the operation instruction is a data update operation instruction, and describes the process of implementing spatial data management when the operation instruction is a range query operation instruction, and the scheduler monitors the number of users in multiple grid spaces in a continuous space in real time to maintain the stability of the spatial data management system. Through the spatial data management method of this embodiment, the resource utilization of the spatial data management system can be improved and the performance of the spatial data management system can be optimized.
[0073] Before the multi-person interactive system runs, the system needs to be initialized first, such as Figure 5 As shown, the process of the multi-person interactive system initialization method in this embodiment is as follows:
[0074] S51: Scheduler initialization.
[0075] Scheduler initialization includes setting the maximum query radius, setting the side length of the cell space, setting the side length of the grid space, and obtaining the Internet Protocol (IP) address and port number for providing services to the outside. Among them, the maximum query radius refers to the maximum allowed search radius of the process in the spatial data management system when performing range queries. The value of the maximum query radius can be determined based on a comprehensive consideration of factors such as application scenarios, user needs, distribution of spatial data, and system performance; the scheduler can obtain the IP address and port number for providing services to the outside through configuration files and network protocols (such as DHCP protocols).
[0076] S52: Initialization of spatial data management process.
[0077] When the spatial data management process is initialized, it first establishes a connection with the scheduler, sends status information to the scheduler, and enters the inactive state. When the scheduler specifies a grid space, the spatial data management process begins to manage the user data in the grid space and enters the activated state; or when the scheduler does not specify a grid space, the spatial data management process remains in the inactive state and waits for the scheduler to specify it.
[0078] It should be understood that the number of initialized spatial data management processes should be greater than or equal to the number of grid spaces in the space, and the spatial data management processes that are not activated after initialization can be used when the scheduler divides the grid space.
[0079] S53: Server initialization.
[0080] After the server cluster is initialized, it connects with the scheduler and spatial data management process.
[0081] S54: Client initialization.
[0082] When the client is initialized, it first establishes a connection with the scheduler to obtain the addresses of all spatial data management processes and their corresponding grid space identifiers, the user's initial position, the mapping rules between the position and the grid space, and the position of the grid space. Among them, the user's initial position can be based on specific scene settings. For example, in a multiplayer game scene, the user's initial position can be a fixed position, or users in the same camp can have the same initial position. The scheduler can obtain the user's initial position information from any server. Based on the user's initial position and the mapping rules between the position and the grid space, the client determines the grid space where the user is located, and establishes a connection with the corresponding spatial data management process.
[0083] In summary, the multi-person interaction system initialization in this embodiment includes scheduler initialization, process initialization, server initialization and first client initialization, which are tasks that must be completed before the multi-person interaction system is run to ensure that the multi-person interaction system can operate normally. Through these initialization steps, the multi-person interaction system can prepare various components and ensure that each part of the multi-person interaction system is in the correct state, thereby improving the stability and performance of the multi-person interaction system.
[0084] Accordingly, the present invention also provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to implement the above-mentioned spatial data management method. Figure 6 The figure shows a hardware structure of any electronic device with data processing capability in which the spatial data management system provided by the embodiment of the present invention is located. Figure 6In addition to the processor, memory, internal bus and network interface shown, the electronic device with data processing capability in which the system in the embodiment is located may also include other hardware according to the actual function of the electronic device, which will not be described in detail.
[0085] Accordingly, the present invention also provides a computer-readable storage medium on which computer instructions are stored, and when the instructions are executed by a processor, the spatial data management method as described above is implemented. The computer-readable storage medium can be an internal storage unit of the aforementioned electronic device with data processing capabilities, such as a hard disk or memory; or it can be other external storage devices, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), an SD card, a flash card (FlashCard), etc. equipped on the device. The computer-readable storage medium can also include both an internal storage unit of an electronic device with data processing capabilities and an external storage device, which is used to store computer programs and other programs and data required by the electronic device with data processing capabilities, and can also be used to temporarily store data that has been output or is to be output.
[0086] The above description of the embodiments is to facilitate the understanding and application of the present invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments. Improvements and modifications made by those skilled in the art to the present invention based on the disclosure of the present invention should be within the protection scope of the present invention.
Claims
1. A spatial data management method, applied to a spatial data management system, wherein the spatial data management system is used to manage spatial data in a continuous space, wherein the continuous space is divided into a plurality of grid spaces, each grid space having its own spatial data, and the spatial data management system comprises a scheduler and a series of spatial data management processes, wherein the states of the spatial data management processes are activated or inactivated, wherein the activated spatial data management process is used to manage the spatial data of the grid space, and the inactivated spatial data management process does not manage the spatial data; characterized in that: The spatial data management method comprises: When the number of users in any grid space is greater than the set threshold, the scheduler sends a split instruction to the spatial data management process corresponding to the grid space, and sends an activation request to several inactivated spatial data management processes at the same time. The activation request carries the unique identifier of the grid space, and manages the corresponding grid space by making these inactivated spatial data management processes activated. The spatial data management process that receives the segmentation instruction segments the grid space, and then manages the segmented grid space in conjunction with the newly activated spatial data management process; When there are several spatial data management processes that belong to the same divided grid space and the total amount of spatial data is less than the threshold, the scheduler sends a merge instruction to these spatial data management processes. The merge instruction carries the unique identifier of the spatial data management process. The instruction is used to instruct these spatial data management processes to merge the corresponding grid spaces into one grid space, and designate one of the spatial data management processes to manage the merged grid space. The remaining spatial data management processes release the management of the original grid space and switch to an inactivated state.
2. A spatial data management method according to claim 1, characterized in that: The activated spatial data management process receives an operation instruction sent by a client, the client being a client to which a user belongs in the grid space, the operation instruction including a data update operation or a range query operation, the data update operation being used to indicate an operation in which a user position changes, the range query operation being used to query information of other users within a query range, the query range being an area formed by extending a specified distance outward from a user position as a center point; The spatial data management process sends the updated value obtained by the data update operation or the query result obtained by the range query operation to the client.
3. A spatial data management method according to claim 2, characterized in that: Before receiving the operation instruction sent by the client, the spatial data management process has established a communication connection with the client, and the communication connection is used for data transmission between the client and the spatial data management process; when the user corresponding to the client moves from the original grid space to other grid spaces, the client disconnects the communication connection with the spatial data management process corresponding to the original grid space, and establishes a new communication connection with the spatial data management process corresponding to the other grid space.
4. A spatial data management method according to claim 1, characterized in that: Each grid space includes a plurality of unit spaces, each unit space having respective space data, and the space data includes user data in the unit space; In case of receiving a range query operation sent by a user through a client, the spatial data management process determines whether a user in a unit space specified by the range query operation is within a query range, wherein the unit space specified by the range query operation includes a unit space in which a portion of user data is within the query range and another portion of user data is not within the query range, or a unit space in which all user data is within the query range; When the spatial data management process receives data update operation A sent by user A through the client and also receives data update operation B sent by user B through the client, the spatial data management process updates the data of user A and the data of user B in parallel, where user A is located in unit space A, user B is located in unit space B, and unit space A and unit space B belong to the same grid space.
5. A spatial data management device, used to execute a spatial data management method as claimed in any one of claims 1 to 4, characterized in that: The spatial data management device comprises: Storage module, used to store user data in a certain area and process data update and range query requests of all users in a grid space; The scheduling module is used to monitor the data distribution status in the grid space, send a segmentation instruction to the spatial data management process whose spatial data volume is greater than a threshold, and send a merge instruction to several spatial data management processes that belong to the same segmented grid space and whose total spatial data volume is less than a threshold; The communication module is used to send and receive the splitting and merging instructions of the scheduler to the spatial data management process, send and receive the data update and range query requests of the client to the spatial data management process, and send and receive the return results of the data update and range query requests of the spatial data management process to the client.
6. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: The processor is used to execute the computer program to implement a spatial data management method as claimed in any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the spatial data management method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Parallel space topology analyzing method based on discrete grid
CN101515284A
Multilevel nested data transmission method and system matched with high-performance computer structure
CN104360962A