Data query method, device, system, electronic device and storage medium
By performing secondary sharding processing after receiving the server shard information, combining the sharding information of the server and the client, the problem of low reliability of data query results caused by changes in the number of clients is solved, and the further implementation High reliability and accuracy of data query.
Patent Information
- Application Number
- CN202011018899.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-24
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-09-24
AI Technical Summary
In the prior art, shard information is determined by the server based on the total shard number of fixed configurations, resulting in a low reliability of the data query results when the number of clients changes.
The client receives the first shard information sent by the server, and generates the second shard information based on the data query request and the total number of clients that execute the data query request. Combining the first shard information and the second shard information, data query results are obtained and output from the preset database.
Through the secondary sharding processing of the client, the number of clients that actually perform data query tasks is fully considered, which improves the reliability and accuracy of data query and reduces the network resource consumption between the client and the server.
Smart Images

Figure CN113760968B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data query method, device, system, electronic device and storage medium. Background Art
[0002] With the development of Internet technology and the continuous increase in information volume, how to achieve safe and efficient data query has become an urgent problem to be solved.
[0003] In the prior art, data query is generally implemented in a server-client mode, such as the server scheduling tasks, and the client executing specific tasks according to the server scheduling. For example, the server configures the task, such as the task name, execution cycle, and total number of shards, and shards the total number of shards according to a certain sharding strategy, and the client executes the data query operation corresponding to the sharding information based on the sharding information sharded by the server.
[0004] However, in the process of implementing the present application, the inventors discovered at least the following technical problems: the shard information is determined by the server based on a fixed configured total number of shards, while the number of clients may change, which may lead to low reliability of data query results. Summary of the invention
[0005] Embodiments of the present application provide a data query method, device, system, electronic device, and storage medium for solving the technical problem of low reliability of data query results.
[0006] In a first aspect, an embodiment of the present application provides a data query method, the method comprising:
[0007] Receive a data query request input by a user, and receive first shard information for the data query request sent by a server;
[0008] Generate second sharding information corresponding to the client according to the data query request and the total number of clients executing the data query request;
[0009] According to the first sharding information and the second sharding information, a data query result is obtained and output from a preset database.
[0010] In this embodiment, the client can perform sharding for data query requests (which can be understood as secondary sharding), and can combine the first sharding information sent by the server and the second sharding information generated by its own sharding to perform corresponding data query operations, which fully considers the number of clients that actually perform data query tasks, can improve the reliability and accuracy of data queries, and reduces the technical effect of network resource consumption between the client and the server.
[0011] In some embodiments, the data query request carries data information to be queried, and generating the second shard information according to the data query request and the total number of clients executing the data query request includes:
[0012] Generate a data query task according to the data information to be queried;
[0013] The data query data task is segmented according to the total number to generate second segmentation information.
[0014] In some embodiments, the data query task includes a field value, and generating the data query task according to the data information to be queried includes:
[0015] Determine the field name corresponding to the data query request according to the data information to be queried;
[0016] Generate the field value corresponding to the field name.
[0017] In some embodiments, the sharding the data query data task according to the total number to generate the second sharding information includes:
[0018] Slice the data query task according to the preset slicing strategy, the field value and the total number to generate the second slicing information;
[0019] The sharding strategy includes at least one of a random sharding method, an average sharding method and a remainder sharding method.
[0020] In some embodiments, the sharding strategy is the same as the sharding strategy generated by the server to generate the first sharding information according to the data query request.
[0021] In this embodiment, the client generates the second shard information by adopting the same allocation strategy as the server generates the first shard information, so that the first shard information and the second shard information can be made to have the same sharding method, thereby making the first shard information and the second shard information highly comparable, thereby achieving the technical effect of reliability and accuracy of data query.
[0022] In some embodiments, if the sharding strategy is the remainder sharding method, the data query task is sharded according to the remainder sharding method, the field value and the total number, and generating the second sharding information includes:
[0023] Perform modulo processing on the field value according to the total number to generate the second fragmentation information.
[0024] In some embodiments, acquiring and outputting data query results from a preset database according to the first sharding information and the second sharding information includes:
[0025] Determine common fragmentation information of the first fragmentation information and the second fragmentation information;
[0026] The data query result is obtained from the database and output according to the common sharding information.
[0027] In some embodiments, the first sharding information includes a set of first sharding items, the second sharding information includes a set of second sharding items, and determining the common sharding information of the first sharding information and the second sharding information includes:
[0028] Determine an intersection of the set of the first sharding items and the set of the second sharding items;
[0029] And, acquiring and outputting the data query result from the database according to the common shard information includes: acquiring and outputting the data query result from the database according to the shard items in the intersection.
[0030] In this embodiment, the client performs data query in the database according to the shard items in the intersection and generates data query results. The shard items in the intersection are determined based on the total number of clients that execute the data query task. Therefore, it is equivalent to determining part of the data query task that the client needs to execute based on the resources of the current client, thereby achieving the technical effect of integrity and comprehensiveness of the processing of data query tasks.
[0031] In a second aspect, an embodiment of the present application provides a client, the client comprising:
[0032] A receiving module, used to receive a data query request input by a user, and receive first shard information for the data query request sent by a server;
[0033] A generating module, configured to generate second sharding information corresponding to the client according to the data query request and the total number of clients executing the data query request;
[0034] An acquisition module, used for acquiring a data query result from a preset database according to the first sharding information and the second sharding information;
[0035] An output module is used to output the data query result.
[0036] In some embodiments, the data query request carries data information to be queried, and the generation module is used to generate a data query task according to the data information to be queried, and to slice the data query task according to the total quantity to generate second shard information.
[0037] In some embodiments, the generating module is used to perform sharding processing on the data query task according to a preset sharding strategy, the field value and the total number, and generate the second sharding information;
[0038] The sharding strategy includes at least one of a random sharding method, an average sharding method and a remainder sharding method.
[0039] In some embodiments, the sharding strategy is the same as the sharding strategy generated by the server to generate the first sharding information according to the data query request.
[0040] In some embodiments, if the sharding strategy is the remainder sharding method, the generation module is used to perform remainder processing on the field value according to the total number to generate the second sharding information.
[0041] In some embodiments, the acquisition module is used to determine common sharding information of the first sharding information and the second sharding information, and acquire the data query result from the database according to the common sharding information.
[0042] In some embodiments, the first shard information includes a set of first shard items, and the second shard information includes a set of second shard items. The acquisition module is used to determine the intersection of the set of the first shard items and the set of the second shard items, and to acquire the data query result from the database based on the shard items in the intersection.
[0043] In a third aspect, an embodiment of the present application provides a data query system, the system comprising:
[0044] The server is configured to generate and send first shard information to the client according to the received data query request:
[0045] A client as described in any of the above embodiments.
[0046] In a fourth aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0047] The memory is a memory for storing instructions executable by the processor;
[0048] When executing the instructions in the memory, the processor is configured to implement the method described in any one of the above embodiments.
[0049] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any of the above embodiments.
[0050] The embodiment of the present application provides a data query method, device, system, electronic device and storage medium, including: receiving a data query request input by a user, and receiving first sharding information for the data query request sent by a server, generating second sharding information corresponding to the client according to the data query request and the total number of clients executing the data query request, and obtaining and outputting data query results from a pre-set database according to the first sharding information and the second sharding information. In the related art, the server performs sharding on the data query task, sends the corresponding sharding information (i.e., the first sharding information in this embodiment) to the client, and the client performs the corresponding data query operation based on the sharding information (i.e., the first sharding information in this embodiment). In this embodiment, the client can perform sharding on the data query request (which can be understood as secondary sharding), and can perform the corresponding data query operation in combination with the first sharding information sent by the server and the second sharding information generated by its own sharding, which fully considers the number of clients actually executing the data query task, can improve the reliability and accuracy of the data query, and reduces the technical effect of network resource consumption between the client and the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0052] Figure 1 A schematic diagram of an application scenario of the data query method of an embodiment of the present application;
[0053] Figure 2 A flowchart of a data query method according to an embodiment of the present application;
[0054] Figure 3 A schematic diagram of a data query method according to another embodiment of the present application;
[0055] Figure 4 A schematic diagram of a data query method according to another embodiment of the present application;
[0056] Figure 5 A schematic diagram of a client of an embodiment of the present application;
[0057] Figure 6 A block diagram of an electronic device according to an embodiment of the present application.
[0058] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0060] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0061] See also Figure 1 , Figure 1 A schematic diagram of an application scenario of the data query method according to an embodiment of the present application.
[0062] like Figure 1 As shown, the application scenario includes a server 100 , a Zookeeper 200 and a client 300 .
[0063] The server 100 may configure the data query task, such as the data query task name, execution cycle, total number of shards, etc. The server 100 may be pre-set with a sharding strategy, and shard the data query task based on the sharding strategy and the total number of shards, generate sharding items, and send the sharding items to Zookeeper 200.
[0064] Specifically, a shard item can be understood as the shard content obtained by sharding the data query task by the server, that is, a certain part of the data query task that needs to be executed. In other words, the server can split a data query task into multiple small tasks so that each client can execute its corresponding small task respectively, thereby completing the entire data query task.
[0065] For example, the data query task is to traverse a table in the database, and Figure 1 As shown, there are 3 clients 300 in total and the total number of shards is 9. After the server shards the task of traversing the table, when the shard items are 0, 1, 2, 3, 4, 5, 6, 7 and 8 respectively, the traversal of the table is divided into 9 small tasks, and the 9 shard items are sent to Zookeeper 200, which distributes them to the 3 clients 300.
[0066] Among them, Zookeeper 200 is a reliable coordination system of a distributed system, and can be specifically a distributed, open source distributed application coordination service, and Zookeeper 200 can be integrated with the server 100.
[0067] In this embodiment, Zookeeper 200 may receive and store the sharding items sent by server 100 , and may send the sharding items to each client 300 .
[0068] The client 300 is used to obtain the sharding items from the Zookeeper 200, and traverse the contents of the tables corresponding to the respective sharding items from the database according to the sharding items.
[0069] It is worth noting that the above application scenarios are only used to illustrate the application scenarios to which the data query method of the embodiment of the present application may be applicable, and cannot be understood as limiting the application scenarios. Figure 1 Based on the application scenario shown in FIG. 1 , elements can be adaptively added, such as increasing the number of clients or adding new elements; Figure 1 Based on the information shown, adaptively reduce the elements, such as reducing the number of clients, etc.
[0070] It is understandable that the server can configure the data query task, such as the server configures the total number of shards of the data query task in the above embodiment. However, in actual application, the number of clients may change dynamically, such as a certain number of clients are added due to business needs; or a certain number of clients are reduced to save resources; or at least one client crashes, etc. When the number of clients changes, the shard items allocated to the client by the server cannot fully include the content of the data query task, which may lead to low reliability of the data query results.
[0071] After creative work, the inventor of this application obtained the inventive concept of this application: based on the sharding information of the first sharding received from the server (such as the sharding items in the above embodiment), the client performs a second sharding on the data query task, and determines the data query result based on the received sharding information and the sharding information obtained by its own sharding.
[0072] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0073] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a data query method, which is applied to a client, and the method can be applied to Figure 1 The application scenario shown in .
[0074] See also Figure 2 , Figure 2 A flowchart of a data query method according to an embodiment of the present application is shown in FIG.
[0075] like Figure 2 As shown, the method includes:
[0076] S101: receiving a data query request input by a user, and receiving first shard information for the data query request sent by a server.
[0077] Among them, the execution subject of the embodiment of the present application may be a data query device, and the data query device may specifically be a client, or may be a processor or a chip, etc.
[0078] For example, when the data query method of this embodiment is applied to Figure 1 In the application scenario shown in FIG. 1 , the data query device may be as follows: Figure 1 The client shown in .
[0079] The first sharding information may be used to represent the relevant information obtained by the server through sharding according to the data query request. For example, the first sharding information may include the sharding items as described in the above embodiments.
[0080] S102: Generate second shard information corresponding to the client according to the data query request and the total number of clients executing the data query request.
[0081] Similarly, the second sharding information can be used to represent the relevant information obtained by the client sharding the data query request, and the relevant information is for the client. For example, the second sharding information can include the sharding items described in the above embodiment.
[0082] That is, in this embodiment, the client can receive the first sharding information sent by the server on the one hand, and can also shard the data query request on the other hand, and specifically obtain the second sharding information based on the total number of clients executing the data query request.
[0083] It is worth noting that in this embodiment, when the client generates the second shard information corresponding to itself, it takes into account the total number of clients executing data query requests, thereby avoiding the problem of low integrity of completing data query requests caused by changes in the total number of clients executing data query requests in related technologies, and improving the technical effects of reliability, accuracy and comprehensiveness of data queries.
[0084] S103: Acquire and output data query results from a preset database according to the first shard information and the second shard information.
[0085] It is worth noting that in the present embodiment, the client obtains and outputs the data query result based on the first shard information and the second shard information. Compared with the related art, in which the data query result is obtained and output only based on the first shard information, since the second shard information in the present embodiment is determined by the client based on the total number of clients executing the data query request, it is possible to avoid the problem of low reliability of the data query result due to the fact that the number of clients participating in executing the data query request may be a changing number, thereby achieving the technical effect of improving the reliability of the data query result. Moreover, by generating the second shard information by the client, the network interaction between the client and the server can be reduced, thereby achieving the technical effect of saving network resources and improving data query efficiency.
[0086] Based on the above analysis, it can be seen that an embodiment of the present application provides a data query method that can be applied to a client, the method comprising: receiving a data query request input by a user, and receiving first sharding information for the data query request sent by a server, generating second sharding information corresponding to the client according to the data query request and the total number of clients that execute the data query request, and obtaining and outputting data query results from a pre-set database according to the first sharding information and the second sharding information. In the related art, the server performs sharding on the data query task, sends the corresponding sharding information (i.e., the first sharding information in this embodiment) to the client, and the client performs the corresponding data query operation based on the sharding information (i.e., the first sharding information in this embodiment). In this embodiment, the client can perform sharding on the data query request (which can be understood as secondary sharding), and can perform the corresponding data query operation in combination with the first sharding information sent by the server and the second sharding information generated by its own sharding, which fully considers the number of clients that actually execute the data query task, can improve the reliability and accuracy of the data query, and reduces the technical effect of network resource consumption between the client and the server.
[0087] In order to enable readers to have a more thorough understanding of the data query method provided by this application, Figure 3 The data query method of the present application is described in more detail from the perspective of the second shard information generated by the client. Figure 3 This is a flowchart of a data query method according to another embodiment of the present application.
[0088] like Figure 3 As shown, the method includes:
[0089] S201: receiving a data query request input by a user, and receiving first shard information for the data query request sent by a server, wherein the data query request carries data information to be queried.
[0090] Part of the description about S201 can be found in S101 and will not be repeated here.
[0091] In this embodiment, the data query request carries the data information that the user wants to query (i.e., the data information to be queried). The data information to be queried may be a table. For example, if the user wants to traverse a table in the database as described in the above embodiment, the data information to be queried may be the table; the data information to be queried may also be a document, etc., which are not listed here one by one.
[0092] S202: Generate a data query task according to the data information to be queried.
[0093] In a possible implementation, S202 may include:
[0094] S2021: Determine the field name corresponding to the data query request according to the data information to be queried.
[0095] When the client obtains the data information to be queried, it can determine the field corresponding to the data information to be queried, and determine the field name corresponding to the field, which is the field name corresponding to the data query request.
[0096] S2022: Generate a field value corresponding to the field name, wherein the data query task includes the field value.
[0097] The client may generate the field value corresponding to the field name based on the Java reflection technology, or may generate the field value of the field name based on the Object Graph Navigation Language (OGNL) technology.
[0098] S203: Slice the data query data task according to the total quantity to generate second slicing information.
[0099] In a possible implementation, S203 may include: performing sharding processing on the data query task according to a preset sharding strategy, field value, and total quantity, and generating second sharding information.
[0100] The sharding strategy includes at least one of a random sharding method, an average sharding method, and a remainder sharding method.
[0101] Taking the random sharding method as an example, the method for the client to generate the second sharding information is described as follows:
[0102] The field value is randomly fragmented according to the total number to obtain fragmentation information corresponding to each client, and the fragmentation information corresponding to the client is determined as the second fragmentation information.
[0103] For example, combining Figure 1 In the embodiment shown, the total number is 3, and the total number of shards can be determined according to the field value. For example, the field value can be determined as the total number of shards, or the total number of shards can be determined as a multiple of the total number according to the field value. If the total number of shards is 9, after the client adopts the random sharding method for sharding, the sharding information of one client is [0, 1, 4], the sharding information of another client is [2, 3, 5], and the sharding information of another client is [6, 7, 8]. If the sharding information corresponding to this client is [2, 3, 5], then [2, 3, 5] is the second sharding information.
[0104] Based on the above analysis, it can be known that the sharding strategy can also include an average sharding method. Taking the sharding strategy as an average sharding method as an example, the method for the client to generate the second sharding information is described as follows:
[0105] The field value is evenly sliced according to the total number to obtain the slice information corresponding to each client, and the slice information corresponding to the client is determined as the second slice information.
[0106] For example, combining Figure 1 In the embodiment shown, the total number is 3, and the total number of shards can be determined according to the field value. For example, the field value can be determined as the total number of shards, or the total number of shards can be determined as a multiple of the total number according to the field value. If the total number of shards is 9, after the client adopts the average sharding method for sharding, the sharding information of one client is [0, 1, 2], the sharding information of another client is [3, 4, 5], and the sharding information of another client is [6, 7, 8]. If the sharding information corresponding to this client is [3, 4, 5], then [3, 4, 5] is the second sharding information.
[0107] Based on the above analysis, it can be known that the sharding strategy can also include a remainder sharding method. Taking the remainder sharding method as an example, the method for the client to generate the second sharding information is described as follows:
[0108] The field value is modulo the total number to perform sharding to obtain sharding information corresponding to each client, and the sharding information corresponding to the client is determined as the second sharding information.
[0109] For example, combining Figure 1 In the embodiment shown, the total number is 3, and the total number of shards can be determined according to the field value. For example, the field value can be determined as the total number of shards, or the total number of shards can be determined as a multiple of the total number according to the field value. If the total number of shards is 9, after the client adopts the modulus sharding method for sharding (such as modulus 3), the sharding information of one client is [0, 3, 6], the sharding information of another client is [1, 4, 7], and the sharding information of another client is [2, 5, 8]. If the sharding information corresponding to this client is [1, 4, 7], then [1, 4, 7] is the second sharding information.
[0110] In a possible implementation, the fragmentation strategy adopted by the client is the same as the fragmentation strategy used by the server to generate the first fragmentation information.
[0111] Based on the above embodiments, it can be known that the first sharding information is generated by the server according to the sharding strategy pre-equipped by the server, and the second sharding information is generated by the client using at least one of the above three sharding strategies. The client generates the second sharding information by adopting the same allocation strategy as the server to generate the first sharding information, so that the first sharding information and the second sharding information can be the same sharding method, so that the first sharding information and the second sharding information can have a high comparability, thereby achieving the technical effect of reliability and accuracy of data query.
[0112] S204: Acquire and output data query results from a preset database according to the first shard information and the second shard information.
[0113] The description of S204 can be found in S103 and will not be repeated here.
[0114] In order to enable readers to have a more thorough understanding of the data query method provided by this application, Figure 4 The data query method of the present application is described in more detail from the perspective of the client generating a data query result based on the first shard information and the second shard information. Figure 4 This is a flowchart of a data query method according to another embodiment of the present application.
[0115] like Figure 4 As shown, the method includes:
[0116] S301: receiving a data query request input by a user, and receiving first shard information for the data query request sent by a server.
[0117] The description of S301 may refer to S101 or S201, which will not be repeated here.
[0118] S302: Generate second shard information corresponding to the client according to the data query request and the total number of clients executing the data query request.
[0119] The description of S302 may refer to S102, or refer to S202 to S203, which will not be repeated here.
[0120] S303: Determine the common fragmentation information of the first fragmentation information and the second fragmentation information.
[0121] In this step, the client determines the fragmentation information included in both the first fragmentation information and the second fragmentation information, and this part of the fragmentation information can be called common fragmentation information.
[0122] Combined with the above analysis, it can be seen that in a possible implementation scheme, the first sharding information may include multiple sharding items, and the second sharding information may include multiple sharding items, that is, the first sharding information includes a set of first sharding items, and the second sharding information includes a set of second sharding items. Then the common sharding information can be the intersection of the set of first sharding items and the set of second sharding items.
[0123] S304: Obtain and output data query results from the database according to the common sharding information.
[0124] In this step, on the premise that the client determines the intersection, the client can obtain and output the data query result from the database according to the shard items in the intersection.
[0125] It is worth explaining that, since the data query result is determined by the client based on the sharding items in the intersection, it is equivalent to the client comprehensively considering the sharding items provided by the server and the sharding items generated by itself, and the sharding items generated by itself are determined based on the client currently executing the data query task, which is equivalent to considering the total resource situation of the client executing the data query task. It can achieve full utilization of the resources of each client and improve the reliability and accuracy of data query.
[0126] According to another aspect of the embodiment of the present application, the embodiment of the present application further provides a client, the client is used to execute the following Figures 2 to 4 The data query method shown in any one of the embodiments.
[0127] See also Figure 5 , Figure 5 A schematic diagram of a client according to an embodiment of the present application.
[0128] like Figure 5 As shown, the client includes:
[0129] The receiving module 11 is used to receive a data query request input by a user, and receive first shard information for the data query request sent by a server;
[0130] A generating module 12, configured to generate second sharding information corresponding to the client according to the data query request and the total number of clients executing the data query request;
[0131] An acquisition module 13 is used to acquire a data query result from a preset database according to the first sharding information and the second sharding information;
[0132] The output module 14 is used to output the data query result.
[0133] In some embodiments, the data query request carries data information to be queried, and the generation module is used to generate a data query task according to the data information to be queried, and to slice the data query task according to the total quantity to generate second shard information.
[0134] In some embodiments, the generating module 12 is used to perform sharding processing on the data query task according to a preset sharding strategy, the field value and the total number, and generate the second sharding information;
[0135] The sharding strategy includes at least one of a random sharding method, an average sharding method and a remainder sharding method.
[0136] In some embodiments, the sharding strategy is the same as the sharding strategy generated by the server to generate the first sharding information according to the data query request.
[0137] In some embodiments, if the fragmentation strategy is the remainder fragmentation method, the generation module 12 is used to perform a remainder process on the field value according to the total number to generate the second fragmentation information.
[0138] In some embodiments, the acquisition module 13 is used to determine common sharding information of the first sharding information and the second sharding information, and acquire the data query result from the database according to the common sharding information.
[0139] In some embodiments, the first shard information includes a set of first shard items, and the second shard information includes a set of second shard items. The acquisition module 13 is used to determine the intersection of the set of the first shard items and the set of the second shard items, and obtain the data query result from the database according to the shard items in the intersection.
[0140] According to another aspect of the embodiment of the present application, the embodiment of the present application further provides a data query system, the system comprising:
[0141] The server is configured to generate and send first shard information to the client according to the received data query request:
[0142] A client as described in any of the above embodiments, Figure 5 The client shown.
[0143] According to another aspect of the embodiments of the present application, the embodiments of the present application further provide an electronic device, including: a memory, a processor;
[0144] Memory is a memory for storing processor executable instructions;
[0145] Wherein, when executing the instructions in the memory, the processor is configured to implement the method described in any of the above embodiments, such as implementing Figures 2 to 4 The data query method shown in any one of the embodiments.
[0146] See also Figure 6 , Figure 6 A block diagram of an electronic device according to an embodiment of the present application.
[0147] like Figure 6 As shown, electronic devices are intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or required herein.
[0148] like Figure 6 As shown, the electronic device includes: one or more processors 101, a memory 102, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 101 is taken as an example.
[0149] The memory 102 is a non-transient computer-readable storage medium provided in an embodiment of the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the data query method provided in an embodiment of the present application. The non-transient computer-readable storage medium of an embodiment of the present application stores computer instructions, which are used to enable a computer to perform the data query method provided in an embodiment of the present application.
[0150] The memory 102 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules in the embodiments of the present application. The processor 101 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 102, that is, implements the data query method in the above method embodiment.
[0151] The memory 102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 102 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 102 may optionally include a memory remotely arranged relative to the processor 101, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a Blockchain Service Network (BSN), a mobile communication network, and a combination thereof.
[0152] The electronic device may further include: an input device 103 and an output device 104. The processor 101, the memory 102, the input device 103 and the output device 104 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0153] The input device 103 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 104 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.
[0154] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0155] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0156] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0157] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a Block-chain-based Service Network (BSN), a wide area network (WAN), and the Internet.
[0158] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0159] Among them, computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of computer programs from one place to another. The storage medium can be any available medium that can be accessed by a general or special-purpose computer. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a user device. Of course, the processor and the storage medium can also be present in a communication device as discrete components.
[0160] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0161] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A data query method, characterized in that: Applied to a client, the method comprises: Receive a data query request input by a user, and receive first shard information for the data query request sent by a server; Generate second sharding information corresponding to the client according to the data query request and the total number of clients executing the data query request; Acquire and output data query results from a preset database according to the first sharding information and the second sharding information; The first sharding information includes a set of first sharding items, the second sharding information includes a set of second sharding items, and the acquiring and outputting of data query results from a preset database according to the first sharding information and the second sharding information includes: determining an intersection of the set of the first sharding items and the set of the second sharding items; The data query result is obtained from the database according to the shard items in the intersection and outputted.
2. The method according to claim 1, characterized in that: The data query request carries the data information to be queried, and the generating the second shard information according to the data query request and the total number of clients executing the data query request includes: Generate a data query task according to the data information to be queried; The data query data task is segmented according to the total number to generate second segmentation information.
3. The method according to claim 2, characterized in that The data query task includes a field value, and generating the data query task according to the data information to be queried includes: Determine the field name corresponding to the data query request according to the data information to be queried; Generate the field value corresponding to the field name.
4. The method according to claim 3, characterized in that The performing sharding processing on the data query data task according to the total quantity to generate second sharding information comprises: Slice the data query task according to the preset slicing strategy, the field value and the total number to generate the second slicing information; The sharding strategy includes at least one of a random sharding method, an average sharding method and a remainder sharding method.
5. The method according to claim 4, characterized in that The sharding strategy is the same as the sharding strategy generated by the server to generate the first sharding information according to the data query request.
6. The method according to claim 4, characterized in that If the sharding strategy is the remainder sharding method, sharding the data query task according to the remainder sharding method, the field value and the total number, and generating the second sharding information includes: Perform modulo processing on the field value according to the total number to generate the second fragmentation information.
7. A client, characterized in that: The client comprises: A receiving module, used to receive a data query request input by a user, and receive first shard information for the data query request sent by a server; A generating module, configured to generate second sharding information corresponding to the client according to the data query request and the total number of clients executing the data query request; An acquisition module, used for acquiring a data query result from a preset database according to the first sharding information and the second sharding information; An output module, used for outputting the data query result; The first sharding information includes a set of first sharding items, the second sharding information includes a set of second sharding items, and the output module is specifically used to: determine an intersection of the set of the first sharding items and the set of the second sharding items; The data query result is obtained from the database according to the shard items in the intersection and outputted.
8. A data query system, characterized in that: The system comprises: The server is configured to generate and send first shard information to the client according to the received data query request: The client as claimed in claim 7.
9. An electronic device, characterized in that: include: Memory, processor; The memory is a memory for storing instructions executable by the processor; When executing the instructions in the memory, the processor is configured to implement the method as claimed in any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Task scheduling method and device, storage medium and computer equipment
CN111338778A