Data query method and device, electronic equipment and storage medium
By using a dual data source approach—a static database and a remote dictionary server database—on the cloud platform, the problem of memory consumption during data queries was solved, thus improving the performance and efficiency of the cloud platform.
Patent Information
- Application Number
- CN202311234922.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-09-22
AI Technical Summary
In existing technologies, when a cloud platform performs data queries, if the sorting field is a monitoring data field, it will cause the full data push to consume a large amount of memory, affecting the platform's performance.
A dual-data source approach is adopted, which obtains the object identifier set through a static database and a remote dictionary server database, and determines the target data based on the matching results, thereby reducing memory usage.
It effectively reduces the resource consumption of the cloud platform, improves data query efficiency and performance, and reduces the memory resource consumption rate.
Smart Images

Figure CN117251471B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data management, and particularly relates to a data query method and device, electronic equipment and a storage medium. BACKGROUND
[0002] A cloud platform is a platform providing cloud computing services. Users can perform various operations on a management page, including querying resources.
[0003] In related technologies, when the cloud platform obtains relevant data according to a resource query request of a user, if a sorting field in a query statement constructed is a monitoring data field, full data needs to be obtained according to the monitoring data field, and then the full data is pushed to the user.
[0004] However, if the data amount of the full data is too large, the data query process will occupy a large amount of memory, and then the performance of the cloud platform is affected. SUMMARY
[0005] Therefore, the present application provides a data query method and device, electronic equipment and a storage medium to solve the problem that data query affects the performance of the cloud platform.
[0006] In a first aspect, the present application provides a data query method, which comprises the following steps:
[0007] receiving a resource query request, the resource query request being used to request sorting display of a target resource to be queried;
[0008] constructing a first query statement, the first query statement being used to obtain target data corresponding to the target resource, and the first query statement comprising a sorting field;
[0009] if the sorting field corresponds to a monitoring data field, the first query statement is changed to a second query statement, the second query statement being used to obtain object identifiers of a full query object of the target resource;
[0010] obtaining the object identifiers of the full query object from a static database to obtain a first object identifier set;
[0011] obtaining a second object identifier set of the target resource from a remote dictionary server database;
[0012] determining and pushing the target data based on a matching result of the first object identifier set and the second object identifier set, so as to respond to the resource query request.
[0013] Beneficial effects: can determine the target data finally used for pushing based on the matching result of the double data sources, thereby helping to reduce the resource occupation of the cloud platform, and can effectively improve the performance of the cloud platform.
[0014] In an optional implementation, the object identifiers of the full-quantity query objects are obtained from the static database to obtain a first object identifier set, including:
[0015] In the static database, a plurality of first target query objects corresponding to the target resource are identified, and the plurality of first target query objects are full-quantity query objects.
[0016] Through the preset correspondence between the plurality of query objects and the object identifiers, a first target object identifier corresponding to each first target query object is determined respectively to obtain the first object identifier set.
[0017] In an optional implementation, a second object identifier set of the target resource is obtained from a remote dictionary server database, including:
[0018] In the remote dictionary server database, a plurality of second target query objects included in the target resource are determined.
[0019] The monitoring data values of each second target query object are determined respectively.
[0020] According to the size of each monitoring data value, the target object identifiers of each second target query object are sorted in a specified order to obtain the second object identifier set.
[0021] In an optional implementation, the target data is determined based on the matching result of the first object identifier set and the second object identifier set, including:
[0022] If the plurality of first object identifiers in the first object identifier set are the same as the plurality of second object identifiers in the second object identifier set, the data corresponding to each second object identifier is taken as the target data.
[0023] If the plurality of first object identifiers in the first object identifier set are different from the plurality of second object identifiers in the second object identifier set, each second object identifier is matched with the plurality of first object identifiers according to the order of each second object identifier in the second object identifier set.
[0024] Based on the matching result of each second object identifier, a third object identifier that is the same as the plurality of first object identifiers is extracted from the plurality of second object identifiers to obtain a first identifier sequence.
[0025] It is judged whether there is a fourth object identifier in the plurality of first object identifiers that is not included in the second object identifier set.
[0026] If the fourth object identifier exists, the fourth object identifier is added to the first identifier sequence in a specified order to obtain a second identifier sequence;
[0027] The target query object corresponding to each object identifier in the second identifier sequence is taken as the target data, and the object identifier includes the third object identifier or the fourth object identifier.
[0028] Beneficial effects: the push order of the target data can be directly determined, and the occupancy rate of the memory resource can be effectively saved.
[0029] In an optional implementation, the fourth object identifier is added to the first identifier sequence in a specified order to obtain a second identifier sequence, including:
[0030] If the specified order is ascending order, the fourth object identifier is added to the head of the first identifier sequence to obtain the second identifier sequence;
[0031] If the specified order is descending order, the fourth object identifier is added to the tail of the first identifier sequence to obtain the second identifier sequence.
[0032] In an optional implementation, the resource query request further includes a data paging request, and the target data is pushed, including:
[0033] According to the data paging request, the number of data pages to be requested and the maximum number of data included in each page are determined;
[0034] Based on the number of data pages and the maximum number of data, the target data is pushed in pages.
[0035] Beneficial effects: the data range and data order required for the query can be determined by using the query result characteristics of the double data source, and then the target data of a specific type can be obtained after merging and paging, which can effectively improve the data query efficiency, save the memory resource occupancy, and thus help to improve the cloud platform performance.
[0036] In an optional implementation, the method further includes:
[0037] If the class corresponding to the sorting field is a static data field, the target data corresponding to the target resource is obtained from a static database.
[0038] Beneficial effects: the target data can be obtained in a targeted manner according to the class corresponding to the sorting field, and thus the target data acquisition method is more flexible, which is more helpful to reduce the storage memory occupied by the cloud platform when pushing the target data, and thus helps to enhance the cloud platform performance and improve the response efficiency.
[0039] Secondly, the present invention provides a data query device, the device comprising:
[0040] The receiving module is used to receive resource query requests, which are used to request the sorting and display of the target resources to be queried.
[0041] The construction module is used to construct the first query statement, which is used to obtain the target data corresponding to the target resource. The first query statement includes a sorting field.
[0042] The update module is used to change the first query statement to the second query statement if the class corresponding to the sorting field is a monitoring data field. The second query statement is used to obtain the object identifier of the full query object of the target resource.
[0043] The first acquisition module is used to obtain the object identifiers of all query objects from the static database to obtain the first object identifier set;
[0044] The second acquisition module is used to acquire the second set of object identifiers of the target resource from the remote dictionary server database;
[0045] The execution module is used to determine and push target data based on the matching results of the first set of object identifiers and the second set of object identifiers in response to resource query requests.
[0046] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the data query method described in the first aspect or any corresponding embodiment thereof.
[0047] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the data query method described in the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0048] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0049] Figure 1 This is a flowchart illustrating a data query method according to an embodiment of the present invention;
[0050] Figure 2This is a flowchart illustrating another data query method according to an embodiment of the present invention;
[0051] Figure 3 This is a data schematic diagram of the first object identifier set according to an embodiment of the present invention;
[0052] Figure 4 This is a data schematic diagram of the second object identifier set according to an embodiment of the present invention;
[0053] Figure 5 This is a data schematic diagram of the second identifier sequence according to an embodiment of the present invention;
[0054] Figure 6 This is a flowchart illustrating another data query method according to an embodiment of the present invention;
[0055] Figure 7 This is a structural block diagram of a data query device according to an embodiment of the present invention;
[0056] Figure 8 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] In related technologies, when a cloud platform obtains relevant data based on a user's resource query request, if the sorting field in the constructed query statement is a monitoring data field, then it needs to obtain all the data according to that monitoring data field and then push it all to the user.
[0059] However, if the total amount of data is too large when using this method to push data, it will consume a lot of memory during the data query process, thus affecting the performance of the cloud platform.
[0060] In view of this, this embodiment of the invention provides a data query method, comprising: receiving a resource query request, the resource query request being used to request the sorting and display of a target resource to be queried; constructing a first query statement, the first query statement being used to obtain target data corresponding to the target resource, the first query statement including a sorting field; if the class corresponding to the sorting field is a monitoring data field, then changing the first query statement to a second query statement, the second query statement being used to obtain object identifiers of all query objects of the target resource; obtaining object identifiers of all query objects from a static database to obtain a first object identifier set; obtaining a second object identifier set of the target resource from a remote dictionary server database; and determining and pushing target data based on the matching result of the first object identifier set and the second object identifier set to respond to the resource query request. Through the data query method provided by this invention, when the sorting field included in the first query statement is identified as a monitoring data field, the object identifier set corresponding to the target resource can be determined from both the static database and the remote dictionary server database, and then the final target data to be pushed can be determined based on the matching result of the two data sources, thereby helping to reduce the resource consumption of the cloud platform and effectively improving the performance of the cloud platform.
[0061] According to an embodiment of the present invention, a data query method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0062] This embodiment provides a data query method that can be used on a cloud platform. Figure 1 This is a flowchart of a data query method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0063] Step S101: Receive resource query request.
[0064] In this embodiment of the invention, a resource query request is used to request the sorting and display of the target resources to be queried. The resource query request can be triggered by a user browsing the cloud platform resource management interface.
[0065] Step S102: Construct the first query statement.
[0066] In this embodiment of the invention, a first query statement is used to obtain target data corresponding to the target resource. The first query statement includes a sorting field. This sorting field is used to restrict the target data to be sorted according to a specified sorting rule, so that when the target data is subsequently pushed, it can meet the user's usage needs. The specified sorting rule can be a sorting rule determined based on the user's usage habits, a default sorting rule of the cloud platform, or a sorting rule specified by the user when triggering a resource query request.
[0067] By constructing the first query statement, the cloud platform can perform targeted queries on the target data.
[0068] Step S103: If the class corresponding to the sorting field is a monitoring data field, then change the first query statement to the second query statement.
[0069] In this embodiment of the invention, if the class corresponding to the sorting field is a monitoring data field, then the target data corresponding to the target resource includes dynamic monitoring data. Therefore, to save memory resources occupied when querying target data, the first query statement is changed to a second query statement to reduce the amount of data filtered. The second query statement is used to obtain the object identifier of the full query object of the target resource.
[0070] Step S104: Obtain the object identifiers of all queried objects from the static database to obtain the first set of object identifiers.
[0071] In this embodiment of the invention, the object data in the static database can reflect the most accurate resource situation on the cloud platform. Therefore, the object identifiers of all query objects can be obtained through the static database, thereby obtaining a first set of object identifiers, and the scope of the target data can be clearly obtained through the first set of object identifiers.
[0072] Step S105: Obtain the second set of object identifiers for the target resource from the remote dictionary server database.
[0073] In this embodiment of the invention, the monitoring data for a certain resource type is maintained in the remote dictionary server (Redis) database using the zset data type (ordered set). Therefore, obtaining the second object identifier set of the target resource from the remote dictionary server database allows for a quick determination of the order in which the second object identifiers are pushed to the data. Here, the second object identifier refers to the object identifier of the second target query object corresponding to the target resource, stored in the remote dictionary server.
[0074] Step S106: Based on the matching results of the first object identifier set and the second object identifier set, determine and push the target data to respond to the resource query request.
[0075] In this embodiment of the invention, matching the second set of object identifiers with the first set of object identifiers can determine whether the monitoring data value of the second target query object stored in the remote dictionary server database is valid data. Then, based on the matching result of the first set of object identifiers and the second set of object identifiers, the target data is determined and pushed. This can ensure the validity of the target data push, and there is no need to sort it manually, which can effectively reduce the occupation of memory resources, thereby helping to improve query efficiency, improve the response performance of the cloud platform, and improve the user experience.
[0076] The data query method provided in this embodiment can determine the final target data to be pushed based on the matching results of dual data sources, thereby helping to reduce the resource consumption of the cloud platform and effectively improve the performance of the cloud platform.
[0077] This embodiment provides a data query method that can be used on the aforementioned cloud platform. Figure 2 This is a flowchart of a data query method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0078] Step S201: Receive a resource query request. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0079] Step S202: Construct the first query statement. See details below. Figure 1 Step S102 of the illustrated embodiment will not be described again here.
[0080] Step S203: If the class corresponding to the sorting field is a monitoring data field, then change the first query statement to the second query statement. For details, please refer to [link to relevant documentation]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0081] Step S204: Obtain the object identifiers of all queried objects from the static database to obtain the first set of object identifiers.
[0082] Specifically, step S204 includes:
[0083] Step S2041: In the static database, identify multiple first target query objects corresponding to the target resource;
[0084] Step S2042: By using the pre-defined correspondence between multiple query objects and object identifiers, determine the first target object identifier corresponding to each first target query object, and obtain the first object identifier set.
[0085] Specifically, since the object data in the static database can reflect the most accurate resource situation on the cloud platform, in order to facilitate the determination of the full query objects involved in the target resource, multiple first target query objects corresponding to the target resource are determined in the static database. Then, based on the pre-set correspondence between multiple query objects and object identifiers, the first target object identifier corresponding to each first target query object is determined, thereby obtaining the first object identifier set. The scope of the target data can be clearly obtained through the first object identifier set. Among them, the multiple first target query objects are the full query objects of the target resource.
[0086] Step S205: Obtain the second set of object identifiers for the target resource from the remote dictionary server database.
[0087] Specifically, step S205 includes:
[0088] Step S2051: In the remote dictionary server database, determine the multiple second target query objects included in the target resource;
[0089] Step S2052: Determine the monitoring data value for each second target query object;
[0090] Step S2053: Based on the size of each monitoring data value, sort the target object identifiers of each second target query object in a specified order to obtain the second object identifier set.
[0091] Specifically, the Remote Dictionary Server (Redis) database uses a key-value structure to store data. The key is a string, while the value can be of various data types, such as strings, lists, hashes, sets, and sorted sets. Regardless of the data type, each object is associated with a unique key. Therefore, to improve the response efficiency of the cloud platform, multiple secondary target query objects included in the target resource can be determined from the remote dictionary server database. These secondary target query objects can be understood as the full set of query objects related to the target resource in the remote dictionary server. Since the storage order of these secondary target query objects in the remote dictionary server database may not be contiguous, and the data objects are sorted according to their corresponding monitoring data scores, the push order of each secondary target query object is determined by identifying the monitoring data value of each object. Then, based on the size of each monitoring data value, the secondary target object identifiers of each secondary target query object are sorted in a specified order to obtain a set of secondary object identifiers. This allows subsequent data to be pushed sequentially, facilitating targeted queries by users. The specified order can be either sorting the second target object identifiers according to the monitoring data values in descending order, or sorting the second target object identifiers according to the monitoring data values in ascending order.
[0092] Step S206: Determine the target data based on the matching results of the first object identifier set and the second object identifier set.
[0093] Specifically, step S206 includes:
[0094] Step a1: If multiple first object identifiers in the first object identifier set are the same as multiple second object identifiers in the second object identifier set, then the data corresponding to each second object identifier is taken as the target data.
[0095] Step a2: If multiple first object identifiers in the first object identifier set are different from multiple second object identifiers in the second object identifier set, then each second object identifier is matched with multiple first object identifiers according to the order of the second object identifiers in the second object identifier set.
[0096] Step a3: Based on the matching results of each second object identifier, extract the third object identifier that is the same as the first object identifier from the multiple second object identifiers to obtain the first identifier sequence;
[0097] Step a4: Determine whether there exists a fourth object identifier among the multiple first object identifiers that is not included in the second object identifier set;
[0098] Step a5: If a fourth object identifier exists, add the fourth object identifier to the first identifier sequence in the specified order to obtain the second identifier sequence;
[0099] Step a6: Take the target query object corresponding to each object identifier in the second identifier sequence as the target data.
[0100] Specifically, because the monitoring data stored in the remote dictionary server database is refreshed according to a specified time period, there is a certain delay compared to the data stored in the static database, which may lead to differences between the second object identifier set and the first object identifier set. Therefore, to avoid pushing invalid monitoring data, the second object identifier set is matched with the first object identifier set. If multiple first object identifiers in the first object identifier set are the same as multiple second object identifiers in the second object identifier set, the data corresponding to each second object identifier is taken as the target data. If multiple first object identifiers in the first object identifier set are different from multiple second object identifiers in the second object identifier set, it indicates that there are redundant second object identifiers in the second object identifier set. Therefore, according to the order of each second object identifier in the second object identifier set, each second object identifier is matched with multiple first object identifiers to determine whether the second target query object corresponding to the current second object identifier has been removed. Third object identifiers that are the same as multiple first object identifiers among multiple second object identifiers are extracted separately according to the original specified order to form a new ordered sequence, which is the first identifier sequence. It is then determined whether there is a fourth object identifier among the multiple first object identifiers that is not included in the second object identifier set. The fourth object identifier can be understood as the object identifier of the newly added target query object corresponding to the target resource. If a fourth object identifier exists, it indicates that the monitoring data corresponding to the target resource stored in the remote dictionary server database has not yet been updated. Therefore, to ensure the integrity of data push, the fourth object identifier is added to the first identifier sequence in a specified order, thus obtaining the second identifier sequence. The target query objects corresponding to each object identifier in the second identifier sequence are then used as target data for subsequent targeted pushes. The object identifier includes either the third or fourth object identifier.
[0101] In one example, if the specified order is ascending, the fourth object identifier is added to the head of the first identifier sequence to obtain the second identifier sequence; if the specified order is descending, the fourth object identifier is added to the tail of the first identifier sequence to obtain the second identifier sequence.
[0102] For example: the obtained first set of object identifiers can be as follows Figure 3 As shown, A, D, V, C, F, E, and K represent different first object identifiers. The order of A, D, V, C, F, E, and K in the first object identifier set is random. The resulting second object identifier set can be obtained as follows: Figure 4 As shown, A, B, C, D, E, F, G, H, and I represent different second object identifiers, arranged in ascending order according to their corresponding monitoring data values. The object identifier corresponding to the target query object is unique. Therefore, if the same object identifier appears in both the first and second object identifier sets, it can be considered the object identifier of the same target query object. Thus, by matching the second and first object identifier sets, it can be determined that B, G, H, and I have been removed. Therefore, A, C, D, E, and F are extracted from the second object identifier set to form a new ordered sequence, resulting in the first identifier sequence. V and K in the first object identifier set are newly added fourth object identifiers. Since the monitoring data values corresponding to V and K stored in the remote dictionary server database are defaulted to 0, V and K are placed at the beginning of the first identifier sequence, thus forming... Figure 5 The second identifier sequence shown can be ordered from top to bottom as follows: V, K, A, C, D, E, F.
[0103] If the specified sequence is in descending order, the sorting result of the object identifiers in the second identifier sequence from top to bottom can be as follows: F, E, D, C, A, V, K.
[0104] Step S207: Push the target data in response to the resource query request.
[0105] In some optional implementations, the resource query request may further include a data pagination request, and step S207 above includes:
[0106] Step S2071: Based on the data paging request, determine the number of data pages to be requested and the maximum number of data pages included in each page.
[0107] In this embodiment of the invention, the resource query request also includes a pagination request, indicating that pagination is required when pushing target data. Therefore, based on the received data pagination request, the number of data pages to be requested and the maximum amount of data included in each page are determined in order to determine the required number of pages and the amount of data pushed per page.
[0108] Step S2072: Push the target data in pages based on the number of data pages and the maximum number of data pages.
[0109] In an embodiment of the present invention, the total number of pages required for pushing and displaying target data can be determined by the data paging quantity PageIndex. The maximum quantity of data displayed on each page can be determined by the maximum data quantity MaxSize. Therefore, paging and pushing can be performed in the following manner:
[0110] Determine the total data quantity C.length in the target data. Define the starting position StartIndex (an integer) and the ending position EndIndex (an integer) of the current page, as well as the current page data result set Results.
[0111] Determine whether the pushing order of the target data is ascending or descending.
[0112] If it is ascending, the values corresponding to StartIndex and EndIndex are determined using the following formula:
[0113] StartIndex = (PageIndex - 1) * MaxSize, EndIndex = StartIndex + MaxSize - 1. If EndIndex > C.length - 1, then EndIndex takes the value of C.length - 1. If EndIndex ≤ C.length - 1, then EndIndex = StartIndex + MaxSize - 1.
[0114] For example: If PageIndex is 2, MaxSize is 3, and C.length is 7, then StartIndex = (2 - 1) * 3 = 3, EndIndex = 3 + 3 - 1 = 5, C.length - 1 = 7 - 1 = 6, and EndIndex < C.length - 1. Therefore, it can be finally determined that StartIndex takes the value of 3 and EndIndex takes the value of 5.
[0115] Another example: If PageIndex is 3, MaxSize is 3, and C.length is 7, then StartIndex = (3 - 1) * 3 = 6, EndIndex = 6 + 4 - 1 = 9, C.length - 1 = 7 - 1 = 6, and EndIndex > C.length - 1. Therefore, it can be finally determined that StartIndex takes the value of 6 and EndIndex takes the value of 6.
[0116] If it is descending, the values corresponding to StartIndex and EndIndex are determined using the following formula:
[0117] StartIndex=(PageIndex-1)*MaxSize-C.length+1, EndIndex=StartIndex+MaxSize-1. If EndIndex>0, the value of EndIndex is 0. If EndIndex≤0, then EndIndex==StartIndex+MaxSize-1.
[0118] For example: if PageIndex is 2, MaxSize is 3, and C.length is 7, then StartIndex = (2-1)*3-7+1 = -3, EndIndex = -3+3-1 = -1, and EndIndex < 0. Therefore, we can finally determine that StartIndex is -3 and EndIndex is -1.
[0119] For example, if PageIndex is 2, MaxSize is 4, and C.length is 7, then StartIndex = (2-1)*3-7+1 = -3, and EndIndex = -3+4-1 = 0. Therefore, we can finally determine that StartIndex is -3 and EndIndex is 0.
[0120] During the process of pushing target data, the count starts from StartIndex and increments by 1 with each execution until it is equal to EndIndex. The execution content is to take the data of C[|StartIndex|] (|StartIndex| is its absolute value) and add it to the current page's data result set Results.
[0121] In some optional implementation scenarios, if the target data is a sequence of second identifiers, then the target data to be displayed on the current page is obtained according to the specified order corresponding to the second identifier sequence. For example: if the specified order is ascending, then combined with... Figure 5 The second identifier sequence shown indicates that the target data pushed to the current page is the data in the static database corresponding to C, D, and E. If the specified order is descending, then the target data pushed to the current page is the data in the static database corresponding to E, D, and C.
[0122] In another alternative implementation scenario, if the end position of the last page does not reach the defined EndIndex, it can be achieved by filling in other data to reach the EndIndex.
[0123] The data query method provided in this embodiment can utilize the query result characteristics of dual data sources to determine the range and order of the data to be queried, and then obtain the target data of a specific type after merging, and push it in pages, which can effectively improve data query efficiency, save memory resources, and thus help improve the performance of the cloud platform.
[0124] This embodiment provides a data query method that can be used on the aforementioned cloud platform. Figure 6 This is a flowchart of a data query method according to an embodiment of the present invention, such as... Figure 6 As shown, the process includes the following steps:
[0125] Step S601: Receive resource query request.
[0126] Step S602: Construct the first query statement.
[0127] Step S603: If the class corresponding to the sorting field is a static data field, then retrieve the target data corresponding to the target resource from the static database.
[0128] In this embodiment of the invention, if the class corresponding to the sorting field is a static data field, the target data corresponding to the target resource is obtained from the static database, thereby helping to reduce the memory pressure of the cloud platform.
[0129] Step S604: If the class corresponding to the sorting field is a monitoring data field, then change the first query statement to the second query statement.
[0130] Step S605: Obtain the object identifiers of all queried objects from the static database to obtain the first set of object identifiers.
[0131] Step S606: Obtain the second set of object identifiers for the target resource from the remote dictionary server database.
[0132] Step S607: Based on the matching results of the first object identifier set and the second object identifier set, determine and push the target data to respond to the resource query request.
[0133] The data query method provided in this embodiment can obtain target data in a targeted manner according to the class corresponding to the sorting field, thereby making the acquisition of target data more flexible and helping to reduce the storage memory occupied by the cloud platform when pushing target data, thus helping to enhance the performance of the cloud platform and improve response efficiency.
[0134] In some optional implementation scenarios, when a user triggers a query request for the display list of target resources while browsing the cloud platform resource management page, a resource query request is generated and received to request the sorting and display of the target resources to be queried. A first query statement is constructed, and it is identified whether the class corresponding to the sorting field in the first query statement is a monitoring data field. If the class corresponding to the sorting field is a static resource field, the target data is obtained from the static resource database. However, if the class corresponding to the sorting field is a monitoring data field, the first query statement is changed to a second query statement to obtain the object identifiers of all query objects of the target resources as the target data. The object identifiers of all query objects are obtained from the static database to obtain a first set of object identifiers. A second set of object identifiers of the target resources is obtained from the remote dictionary server database. The second set of object identifiers is matched with the first set of object identifiers to determine the second object identifier of the removed target resources and the newly added fourth object identifier. The third object identifier, common to both the second and first sets of object identifiers, is extracted in a specified order to obtain a first identifier sequence. The newly added fourth identifier is added to the first identifier sequence according to its corresponding monitoring data value in the specified order from the remote dictionary server database, thus obtaining a second identifier sequence. Based on the pagination request in the resource query request, the second identifier sequence is paginated, and then the pagination results are pushed out in pages, thereby improving query efficiency and helping to improve the response performance of the cloud platform.
[0135] This embodiment also provides a data query device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0136] This embodiment provides a data query device, such as... Figure 7 As shown, it includes:
[0137] The receiving module 701 is used to receive resource query requests, which are used to request the sorting and display of the target resources to be queried.
[0138] Module 702 is used to construct a first query statement, which is used to obtain the target data corresponding to the target resource. The first query statement includes a sorting field.
[0139] The update module 703 is used to change the first query statement to the second query statement if the class corresponding to the sorting field is a monitoring data field. The second query statement is used to obtain the object identifier of the full query object of the target resource.
[0140] The first acquisition module 704 is used to obtain the object identifiers of all query objects from the static database to obtain the first object identifier set;
[0141] The second acquisition module 705 is used to acquire the second set of object identifiers of the target resource from the remote dictionary server database;
[0142] The execution module 706 is used to determine and push target data based on the matching results of the first set of object identifiers and the second set of object identifiers in response to the resource query request.
[0143] In some alternative implementations, the first acquisition module 704 includes:
[0144] The first determining unit is used to identify multiple first target query objects corresponding to the target resource in the static database, wherein the multiple first target query objects are full query objects;
[0145] The first acquisition unit is used to determine the first target object identifier corresponding to each first target query object by using the pre-set correspondence between multiple query objects and object identifiers, thereby obtaining the first object identifier set.
[0146] In some alternative implementations, the second acquisition module 705 includes:
[0147] The second determining unit is used to determine, in the remote dictionary server database, multiple second target query objects included in the target resource;
[0148] The third determining unit is used to determine the monitoring data value of each second target query object;
[0149] The sorting unit is used to sort the target object identifiers of each second target query object in a specified order according to the size of each monitoring data value, so as to obtain the second object identifier set.
[0150] In some alternative implementations, execution module 706 includes:
[0151] The first execution unit is configured to, if multiple first object identifiers in the first object identifier set are the same as multiple second object identifiers in the second object identifier set, use the data corresponding to each second object identifier as the target data.
[0152] The second execution unit is used to match each second object identifier with the multiple first object identifiers according to the order of the second object identifiers in the second object identifier set if the multiple first object identifiers in the first object identifier set are different from the multiple second object identifiers in the second object identifier set.
[0153] The third execution unit is used to extract the third object identifier that is the same as the first object identifier from the multiple second object identifiers based on the matching results of each second object identifier, so as to obtain the first identifier sequence;
[0154] The judgment unit is used to determine whether there is a fourth object identifier among the multiple first object identifiers that is not included in the set of second object identifiers;
[0155] The fourth execution unit is used to add the fourth object identifier to the first identifier sequence in a specified order if a fourth object identifier exists, so as to obtain the second identifier sequence.
[0156] The fifth execution unit is used to take the target query object corresponding to each object identifier in the second identifier sequence as the target data, and the object identifier includes the third object identifier or the fourth object identifier.
[0157] In some alternative implementations, the fourth execution unit includes:
[0158] The first addition unit is used to add the fourth object identifier to the head of the first identifier sequence if the specified order is ascending, so as to obtain the second identifier sequence.
[0159] The second addition unit is used to add the fourth object identifier to the end of the first identifier sequence if the specified order is descending, so as to obtain the second identifier sequence.
[0160] In some optional implementations, the resource query request may also include a data pagination request, and the execution module may also include:
[0161] The fourth determining unit is used to determine the number of data pages to be requested and the maximum number of data pages included in each page based on the data paging request.
[0162] The push unit is used to push target data in pages based on the number of data pages and the maximum number of data pages.
[0163] In some alternative embodiments, the apparatus further includes:
[0164] The third acquisition module is used to retrieve the target data corresponding to the target resource from the static database if the class corresponding to the sorting field is a static data field.
[0165] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0166] In this embodiment, the data query device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0167] This invention also provides an electronic device having the above-described features. Figure 7 The data query device shown.
[0168] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of the present invention, such as... Figure 8 As shown, the electronic device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise as required. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 8 Take a processor 10 as an example.
[0169] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0170] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.
[0171] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0172] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0173] The electronic device also includes an input device 30 and an output device 40. The processor 10, memory 20, input device 30, and output device 40 can be connected via a bus or other means. Figure 8 Taking the example of a connection between China and Israel via a bus.
[0174] Input device 30 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 40 may include display devices, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors). The aforementioned display devices include, but are not limited to, liquid crystal displays, light-emitting diodes, displays, and plasma displays. In some alternative embodiments, the display device may be a touch screen.
[0175] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0176] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A data query method, characterized in that, The method includes: Receive a resource query request, which is used to request the target resource to be queried to be sorted and displayed. Construct a first query statement, which is used to obtain the target data corresponding to the target resource, and the first query statement includes a sorting field; If the class corresponding to the sorting field is a monitoring data field, then the first query statement is changed to a second query statement, which is used to obtain the object identifier of the full query object of the target resource; The object identifiers of the full query objects are obtained from the static database to obtain the first set of object identifiers; Retrieve the second set of object identifiers corresponding to the target resource from the remote dictionary server database; Based on the matching results of the first set of object identifiers and the second set of object identifiers, the target data is determined and pushed in response to the resource query request; The step of determining the target data based on the matching results of the first object identifier set and the second object identifier set includes: If multiple first object identifiers in the first object identifier set are the same as multiple second object identifiers in the second object identifier set, then the data corresponding to each second object identifier is taken as the target data. If multiple first object identifiers in the first object identifier set are different from multiple second object identifiers in the second object identifier set, then each second object identifier is matched with the multiple first object identifiers according to the order of the second object identifiers in the second object identifier set. Based on the matching results of each second object identifier, a third object identifier that is the same as the multiple first object identifiers is extracted from the multiple second object identifiers to obtain a first identifier sequence; Determine whether a fourth object identifier, which is not included in the second set of object identifiers, exists among the plurality of first object identifiers; If the fourth object identifier exists, the fourth object identifier is added to the first identifier sequence in a specified order to obtain the second identifier sequence; The target query object corresponding to each object identifier in the second identifier sequence is used as the target data, and the object identifier includes the third object identifier or the fourth object identifier.
2. The method according to claim 1, characterized in that, The first set of object identifiers is obtained by retrieving the object identifiers of the full query objects from the static database, including: In the static database, multiple first target query objects corresponding to the target resource are identified, and the multiple first target query objects are the full query objects; By establishing a pre-defined correspondence between multiple query objects and object identifiers, the first target object identifier corresponding to each first target query object is determined, thus obtaining the first object identifier set.
3. The method according to claim 2, characterized in that, The step of obtaining the second set of object identifiers corresponding to the target resource from the remote dictionary server database includes: In the remote dictionary server database, multiple second target query objects are identified as included in the target resource; Determine the monitoring data value for each second target query object; Based on the magnitude of each monitoring data value, the target object identifiers of each second target query object are sorted in a specified order to obtain the second object identifier set.
4. The method according to claim 1, characterized in that, The step of adding the fourth object identifier to the first identifier sequence in the specified order to obtain the second identifier sequence includes: If the specified order is ascending, then the fourth object identifier is added to the head of the first identifier sequence to obtain the second identifier sequence; If the specified order is descending, the fourth object identifier is added to the end of the first identifier sequence to obtain the second identifier sequence.
5. The method according to any one of claims 1 to 4, characterized in that, The resource query request also includes a data pagination request, and the pushing of the target data includes: Based on the data pagination request, determine the number of data pages to be requested and the maximum number of data pages included in each page; Based on the number of data pages and the maximum number of data pages, the target data is pushed out in pages.
6. The method according to claim 1, characterized in that, The method further includes: If the sorting field corresponds to a static data field, then the target data corresponding to the target resource is obtained from the static database.
7. A data query device, characterized in that, The device includes: The receiving module is used to receive resource query requests, which are used to request the sorting and display of the target resources to be queried. The construction module is used to construct a first query statement, which is used to obtain target data corresponding to the target resource. The first query statement includes a sorting field. The update module is used to change the first query statement to a second query statement if the class corresponding to the sorting field is a monitoring data field. The second query statement is used to obtain the object identifier of the full query object of the target resource. The first acquisition module is used to obtain the object identifiers of the full query objects from the static database to obtain a first set of object identifiers; The second acquisition module is used to acquire a second set of object identifiers corresponding to the target resource from a remote dictionary server database; An execution module is used to determine and push the target data based on the matching result of the first set of object identifiers and the second set of object identifiers in response to the resource query request; The execution module includes: The first execution unit is configured to, if multiple first object identifiers in the first object identifier set are the same as multiple second object identifiers in the second object identifier set, use the data corresponding to each second object identifier as the target data. The second execution unit is used to match each second object identifier with the multiple first object identifiers according to the order of the second object identifiers in the second object identifier set if the multiple first object identifiers in the first object identifier set are different from the multiple second object identifiers in the second object identifier set. The third execution unit is used to extract the third object identifier that is the same as the first object identifier from the multiple second object identifiers based on the matching results of each second object identifier, so as to obtain the first identifier sequence; The judgment unit is used to determine whether there is a fourth object identifier among the multiple first object identifiers that is not included in the set of second object identifiers; The fourth execution unit is used to add the fourth object identifier to the first identifier sequence in a specified order if a fourth object identifier exists, so as to obtain the second identifier sequence. The fifth execution unit is used to take the target query object corresponding to each object identifier in the second identifier sequence as the target data, and the object identifier includes the third object identifier or the fourth object identifier.
8. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the data query method of any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the data query method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Apparatus and method for generating queries and reports
US20080082494A1
Systems and methods for data retrieval
US20220207033A1