Data processing method and apparatus
By using metadata information to determine indexes and directly query related data in the database, the problem of low database query efficiency in cloud storage services is solved, fast query and load balancing are achieved, and user experience and data query efficiency are improved.
Patent Information
- Application Number
- PCT/CN2023/136251
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-09
- Filing Date
- 2023-12-04
- Publication Date
- 2024-09-12
AI Technical Summary
In cloud storage services, database query efficiency is low, resulting in long data query times and unable to meet users' fast query needs.
By receiving the query request, the metadata information is used to determine the index corresponding to the query request, thereby directly querying the data associated with the index from the database, avoiding traversing all data, and improving query efficiency. This method includes using multiple indexes in the database, each index is associated with data in multiple fields, and querying multiple tables separately through multiple threads to achieve load balancing and fast querying.
It significantly improves the efficiency of data query, narrows the query scope, reduces the processing capacity of the data processing device, improves the user experience, and is suitable for massive data query scenarios.
Smart Images

Figure CN2023136251_12092024_PF_FP_ABST
Abstract
Description
Data processing method and device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on March 9, 2023, with application number 202310226588.1 and application name “A Data Processing Method and Device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The embodiments of the present application relate to the field of big data technology, and in particular to a data processing method and device. Background Art
[0004] To meet users' rapidly growing data storage needs, cloud storage services have emerged. With cloud storage services, users can use their devices to write data to a storage system hosted by the service provider. This storage system can store data in the form of a database. When a user needs to access data, they can send a query request to the storage system through their device. After receiving the query request, the storage system retrieves the requested data from the database.
[0005] Currently, storage systems need to traverse the data in the database according to the query request to obtain the data that meets the query request. Traversing the database takes a long time, resulting in low data query efficiency.
[0006] Summary of the Invention
[0007] The embodiments of the present application provide a data processing method and apparatus for improving the efficiency of querying data.
[0008] In the first aspect, an embodiment of the present application provides a data processing method, which can be executed by a data processing device. The data processing device can be implemented by one or more computing devices, or the data processing device can be implemented by a software or hardware module in a computing device. The embodiment of the present application does not limit the implementation form of the data processing device. The method includes: a data processing device receives a query request, the query request indicates at least one field to which the data to be queried belongs; based on metadata information, determines at least one index corresponding to the query request, the metadata information indicates the relationship between the index and the data corresponding to multiple fields, the multiple fields including the at least one field; from a database, queries N groups of data associated with the at least one index, the database includes multiple indexes, and at least one group of data corresponding to the multiple fields associated with each index in the multiple indexes, the multiple indexes are arranged in order in the database, and N is a positive integer; sends a query result, the query result indicates the N groups of data.
[0009] In an embodiment of the present application, the data processing device determines at least one index corresponding to the query request. This at least one index effectively defines the search scope, allowing the data corresponding to the at least one index to be directly determined from the database. This eliminates the need to traverse all data in the database one by one, improving the efficiency of data querying. Furthermore, the data processing device can more quickly provide query results, which improves the user experience.
[0010] In one possible embodiment, the database includes a first table and a second table, the first table and the second table are used to store the multiple indexes and at least one set of data corresponding to the multiple fields associated with each index in the multiple indexes, and the amount of data in the first table is smaller than the amount of data in the second table; querying N sets of data associated with the at least one index from the database includes: querying a set of data associated with each index in the at least one index from the first table, obtaining a total of K sets of data, where K is a positive integer; querying a set of data that is the same as each set of data in the K sets of data from the second table, obtaining a total of L sets of data, where L is a non-negative integer, and the N sets of data include the K sets of data and the L sets of data.
[0011] In the above embodiment, the data processing device can first query K groups of data corresponding to at least one index from a table with a small amount of data (such as the first table), and then, based on these K groups of data, query the table with a larger amount of data (such as the second table) for data identical to each group of data in the K groups of data. On the one hand, the small amount of data in the first table allows for rapid querying of the K groups of data, which is beneficial for improving data query efficiency. On the other hand, after obtaining the K groups of data from the first table, the data processing device can quickly obtain L groups of data based on these K groups of data, thereby achieving joint access to multiple tables, which is also beneficial for improving data query efficiency.
[0012] In one possible embodiment, the data processing device includes a first thread and a second thread, the first thread being used to query a group of data associated with each index in the at least one index from the first table; and query a group of data identical to each group of data in the K groups of data from the second table, including: sending the K groups of data to the second thread through the first thread; and querying a group of data identical to each group of data in the K groups of data from the second table through the second thread.
[0013] In the above embodiment, the data processing device can use multiple threads to query data from multiple tables respectively. These multiple threads can share the processing load of the query data, which is conducive to load balancing of these multiple threads and improving the efficiency of data query.
[0014] In one possible implementation, before determining at least one index corresponding to the query request based on the metadata information, the method further includes: receiving the multiple indexes from the source device, and at least one set of data corresponding to the multiple fields associated with each index in the multiple indexes; extracting the relationship between the multiple indexes and the at least one set of data corresponding to the multiple fields, obtaining the metadata information, and storing the metadata information.
[0015] In the above embodiment, the data processing device can automatically identify the relationship between multiple indexes and at least one set of data corresponding to multiple fields to obtain metadata information, providing a way for the data processing device to determine metadata information.
[0016] In one possible embodiment, the data processing device includes at least one interface, one of which supports a communication protocol; receiving the multiple indexes, and at least one set of data corresponding to the multiple fields associated with each index in the multiple indexes, including: determining a target interface that matches the communication protocol of the source device or data storage device from the at least one interface; and receiving the multiple indexes corresponding to the multiple fields, and at least one set of data corresponding to the multiple fields associated with each index in the multiple indexes from the source device or data storage device through the target interface.
[0017] In a possible implementation, the query request includes a multi-level query request, and each level of query request in the multi-level query request indicates some fields in the at least one field; the metadata information indicates the relationship between each level of index in the multi-level index and the data corresponding to some fields in the multiple fields, and each level of query request in the multi-level query request corresponds to a first-level index in the multi-level index; according to the metadata information, determining at least one index corresponding to the query request includes: determining the value range of the first-level index corresponding to each level of query request in the multi-level query request according to the relationship between each level of index in the multi-level index and some fields in the multiple fields, and obtaining the value range of the multi-level index in total, wherein the at least one index is the intersection of the value ranges of the multi-level index.
[0018] In the above embodiment, scenarios in which multi-level query requests are made to query data can be supported. In other words, the above embodiment can support more data query scenarios, making the above embodiment more applicable.
[0019] In a possible implementation, the query request at each level also indicates a value range of the data corresponding to some fields in the at least one field; determining the value range of the first-level index corresponding to each level query request in the multi-level query request includes: determining the value range of the first-level index corresponding to each level query request based on the value range of the data corresponding to each field in some fields in the at least one field indicated by the query request at each level.
[0020] In the above embodiment, each level of query request also indicates the value range of the data corresponding to the corresponding field. The data processing device can directly determine the value range of the first-level index corresponding to the query request at that level based on the value range of the data indicated by the query request at that level, thereby providing a method for determining the value range of each level of index, and the method for determining the value range of each level of index is relatively simple.
[0021] In a second aspect, an embodiment of the present application provides a data processing device, which may be the data processing device in the first aspect, or may implement the same functions as the data processing device in the first aspect. The data processing device includes corresponding means or modules for executing the first aspect or any possible implementation method. For example, the data processing device includes a query request parsing module (sometimes also referred to as a query request parsing unit), and a data query module (sometimes also referred to as a data query unit). Optionally, the data processing device also includes a metadata storage module (also referred to as a metadata storage unit).
[0022] Exemplarily, the query request parsing module is used to receive a query request, the query request indicating at least one field to which the data to be queried belongs, and determining at least one index corresponding to the query request based on metadata information, the metadata information indicating the relationship between the index and the data corresponding to multiple fields, the multiple fields including the at least one field; the data query module is used to query N groups of data associated with the at least one index from a database, the database including multiple indexes, and at least one group of data corresponding to the multiple fields associated with each index in the multiple indexes, the multiple indexes being arranged in order in the database, and N being a positive integer; the query request parsing module is also used to send a query result, the query result indicating the N groups of data.
[0023] Optionally, the data processing device further includes other components, such as an antenna, an input / output module, an interface, etc. These components may be hardware, software, or a combination of software and hardware.
[0024] In a third aspect, an embodiment of the present application provides a computing device comprising: a processor and a memory; the memory is used to store one or more computer programs, the one or more computer programs comprising computer instructions, and when the processor executes the computer instructions, the method described in the first aspect and any one of any possible implementations is executed.
[0025] In a fourth aspect, an embodiment of the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method described in the first aspect and any possible implementation.
[0026] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which is used to store computer programs or instructions. When the computer-readable storage medium is executed, it implements the method described in the first aspect and any possible implementation method.
[0027] In a sixth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, implements the method described in the first aspect and any one of any possible implementations.
[0028] Regarding the beneficial effects of the second to sixth aspects, reference can be made to the beneficial effects discussed in the first aspect and will not be listed here. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] FIG1 is a schematic diagram of a scenario applicable to the implementation of this application;
[0030] FIG2 is a schematic diagram of a table;
[0031] FIG3 is a schematic diagram of a data processing method provided in an embodiment of the present application;
[0032] FIG4 is a schematic diagram of target data provided in an embodiment of the present application;
[0033] FIG5 is a schematic diagram of a method for determining at least one index provided in an embodiment of the present application;
[0034] FIG6 is a schematic diagram of data included in a database provided in an embodiment of the present application;
[0035] FIG7 is a schematic diagram of a method for determining N groups of data provided by an embodiment of the present application;
[0036] FIG8 is a schematic diagram of a process of querying data in a combined table according to an embodiment of the present application;
[0037] FIG9 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;
[0038] FIG10 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0039] FIG11 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0041] Below, some of the terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.
[0042] 1. A terminal device is a device with wireless transceiver capabilities, which can be a fixed device, mobile device, handheld device, wearable device, vehicle-mounted device, or a wireless device built into any of the above devices (e.g., a communication module or chip system, etc.). The terminal device is used to connect people, objects, machines, etc. and can be widely used in various scenarios, including but not limited to the following scenarios: cellular communications, device-to-device communications (D2D), vehicle-to-everything (V2X), machine-to-machine / machine-type communications (M2M / MTC), Internet of Things (IoT), virtual reality (VR), augmented reality (AR), industrial control, self-driving, remote medical, smart grid, smart furniture, smart office, smart wearable, smart transportation, smart city, drones, robots, and other scenarios. The terminal device may sometimes be referred to as user equipment (UE), terminal, access station, UE station, remote station, wireless communication device, or user device, etc.
[0043] 2. Computing device refers to a device with computing capabilities, such as a terminal device or server. A server is generally used to provide services to users. For example, a server can provide storage services and / or computing services to users.
[0044] In the embodiments of the present application, the number of nouns, unless otherwise specified, means "singular noun or plural noun", that is, "one or more". "At least one" means one or more, and "plural" means two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. For example, A / B means: A or B. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c means: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0045] Please refer to Figure 1, which is a schematic diagram of a scenario applicable to an embodiment of the present application. As shown in Figure 1, the scenario includes a source device, a first terminal device, a data processing device, and a data storage device. The data processing device and the data storage device can constitute a data storage system. The first terminal device can correspond to a first user. In other words, the first user can operate the first terminal device. The source device corresponds to a second user. In other words, the second user can operate the source device. The source device can be implemented by a computing device. The data storage device can be a data storage device with a centralized architecture or a data storage device with a distributed architecture, and the embodiments of the present application do not specifically limit this.
[0046] The data processing device can communicate with the first terminal device and the data storage device respectively. The communication can be, for example, wired communication or wireless communication. The data processing device can also be called an engine, and the engine can include a structured query language (SQL) engine.
[0047] For example, if a second user wishes to write data (e.g., source data), the source device may generate a write request based on the second user's operation. This write request is used to request writing the source data. The source device may send this write request to the data processing device. The data processing device may be configured to process this write request, which is used to request writing the source data. After receiving the write request, the data processing device may write the source data into the data processing device.
[0048] A first user desires to query pending data. Based on the first user's operation, the first terminal device may generate a query request for the pending data. The query request is used to request the pending data. The first terminal device may send the query request to a data processing device. The data processing device processes the query request. The query request is used to request the pending data. Based on the query request, the data processing device queries data from a database in the data storage device and sends the resulting data to the first terminal device.
[0049] Optionally, the first terminal device may be running an application that generates a query request based on the first user's operation and sends the query request to the data processing device. Examples of the application include an application pre-installed on the first terminal device, a sub-application embedded in a third-party application installed on the first terminal device, a mini-program, or a webpage. After the data processing device obtains data through the query, the first terminal device may send the obtained data to the application.
[0050] In FIG1 , the source device and the first terminal device are taken as different devices for example. In fact, the source device and the first terminal device may be the same device, and this embodiment of the present application does not limit this.
[0051] In one possible embodiment, the data processing device and the data storage device may be implemented by different devices, respectively. Exemplarily, the data processing device may be implemented by one or more computing devices, or may be implemented by a software module or hardware module in one or more computing devices. The data processing device may be implemented by one or more storage devices, or may be implemented by a software module or hardware module in one or more storage devices. A storage device refers to a device with storage capacity, including but not limited to a hard disk, a magnetic disk, or a solid state disk (SSD). The data processing device is implemented by a computing device cluster, and the data storage device is implemented by another computing device cluster. A computing device cluster, for example, includes one or more servers.
[0052] In another possible implementation, the data processing device and the data storage device may be implemented by the same computing device or computing device cluster. For example, the data processing device and the data storage device are both software modules in the same computing device.
[0053] Optionally, the scenario may also include a second terminal device. The second terminal device corresponds to an administrator. In other words, the administrator can operate the second terminal device. For example, the administrator can access the data processing device through the second terminal device and update information in the data processing device.
[0054] The following takes the scenario shown in FIG. 1 as an example, and takes the database in the data storage device including the table shown in FIG. 2 , and the table is identified as t1 as an example, to introduce the current data query process.
[0055] As shown in FIG2 , the table includes multiple fields (such as row key, building code (building_code), house code (house_code), floor code (floor_code), name (name), age (age), job (job) and gender (sex) in FIG2 ), as well as data corresponding to each of the multiple fields. A piece of data corresponding to each of the multiple fields can be regarded as a value of each field.
[0056] The following example uses a query request of: select * from t1 where building_code='123' and house_code=11, and uses a data processing device to query data from the table shown in FIG. 2 .
[0057] After receiving the query request from the first terminal device, the data processing device may sequentially traverse each row of data in the table shown in FIG. 2 , based on the query request. Specifically, the data processing device may first traverse the table to see if the building_code in the second row is 123 and the house_code in the second row is 11; traverse the table to see if the building_code in the third row is 123 and the house_code in the third row is 11; traverse the table to see if the building_code in the fourth row is 123 and the house_code in the fourth row is 12. This process continues in this order until the data processing device has traversed each row of data in the table, ultimately filtering out data from FIG. 2 that meets the query request and obtaining the query result. The query result is represented by the two rows of data indicated by the dashed boxes in FIG. 2 (one row indicates row index 123-11-1, building code 123, house code 11, and floor code 1; the other row indicates row index 123-11-2, building code 123, house code 11, and floor code 2). After obtaining the query result, the data processing device can send the query result to the first terminal device. Therefore, in the current data query method, the data processing device must traverse all the data in the data storage device, which makes the query efficiency of the data processing device low. Furthermore, if the data processing device stores more data, the query efficiency will be further reduced.
[0058] In view of this, embodiments of the present application provide a data processing method. In this method, after receiving a query request, at least one index corresponding to the query request can be determined, which is equivalent to determining the data range corresponding to the query. Because the indexes in the database are arranged in an orderly manner, data associated with the at least one index can be quickly retrieved from the database. This eliminates the need to traverse all data in the data storage device, narrowing the scope of the query data without affecting the accuracy of the query results, thereby improving the efficiency of data queries.
[0059] The following describes the method provided by the embodiments of the present application in conjunction with the accompanying drawings. In the accompanying drawings corresponding to the various embodiments of the present application, all steps represented by dotted lines are optional steps. The data processing device involved in the various embodiments of the present application is, for example, the data processing device involved in Figure 1, the data storage device is, for example, the data storage device involved in Figure 1, the source device is, for example, the source device involved in Figure 1, the first terminal device is, for example, the first terminal device involved in Figure 1, and the second terminal device is, for example, the second terminal device involved in Figure 1.
[0060] Please refer to Figure 3, which is a flow chart of a data processing method provided in an embodiment of the present application. The method includes the following steps.
[0061] S301: A first terminal device sends a query request to a data processing apparatus. Correspondingly, the data processing apparatus receives the query request from the first terminal device.
[0062] The query request is used to indicate at least one field to which the data to be queried belongs. In other words, the query request is used to request a query for the data corresponding to the at least one field, or it can be understood that the query request is used to request a query for the data corresponding to the at least one field. Optionally, the query request may include a query statement, which is used to indicate the at least one field. The query statement is written in SQL. In this case, the query statement may also be referred to as an SQL statement.
[0063] For example, a query request includes a query statement, which is: building_code and house_code. This query request is equivalent to indicating the two fields building_code and house_code. It can be further understood that this query request is used to query the data corresponding to these two fields.
[0064] Optionally, the query request may further indicate a value range for the data corresponding to each of some or all of the at least one field. If the query request includes a query statement, the query statement may indicate the at least one field and may further indicate a value range for the data corresponding to each of some or all of the at least one field.
[0065] For example, a query request includes the query statement: building_code = 123 and house_code = 11. The query statement indicates the two fields, building_code and house_code, and also indicates the value ranges of the data corresponding to these two fields. The value range of the data corresponding to the building_code field is equal to 123, and the value range of the data corresponding to the house_code field is equal to 11.
[0066] The query request can be a primary query request or a multi-level query request, which are described below.
[0067] A1. The query request is a first-level query request.
[0068] The first-level query request indicates at least one field. Optionally, the first-level query request may further indicate a value range of data corresponding to each field in part or all of the at least one field.
[0069] A2. The query request is a multi-level query request.
[0070] A multi-level query request is equivalent to jointly (or jointly) indicating at least one field. For example, each query request at each level in the multi-level query request indicates a portion of at least one field. Optionally, each query request at each level in the multi-level query request may also indicate a value range for each field in the portion of at least one field.
[0071] Optionally, each query request in a multi-level query request may include a query statement. In this case, the query statement in each query request in the multi-level query request may indicate a portion of at least one field and may also indicate a value range for data corresponding to each of the portions of the at least one field.
[0072] S302: The data processing device determines at least one index corresponding to the query request according to the metadata information.
[0073] The metadata information indicates the relationship between the index and the data corresponding to the multiple fields. In other words, the index is related to the data corresponding to the multiple fields. The information about the relationship between the index and the data corresponding to the multiple fields can also be called index information. The metadata information can be further understood as indicating the rules for generating indexes for the data corresponding to the multiple fields. In other words, if the data processing device determines a set of data corresponding to the multiple fields, then it can determine the index corresponding to the set of data based on the set of data and the metadata information. The index can be understood as being used to indicate at least one set of data corresponding to the multiple fields. For example, the metadata information may indicate that the index is obtained by sequentially connecting the data corresponding to the multiple fields with delimiters. Alternatively, the metadata information may indicate that the index is obtained by sequentially arranging the data corresponding to the multiple fields.
[0074] Since the index in the embodiment of the present application is related to the data corresponding to multiple fields, the index in the embodiment of the present application can also be called a composite index. Depending on the format of the at least one set of data indicated by the index, the index can be divided into a row index or a column index. A row index means that each set of data in the at least one set of data indicated by the index is in the form of a row. A column index means that each set of data in the at least one set of data indicated by the index is in the form of a column.
[0075] The index can be a primary index or a multi-level index. If the index is a multi-level index, the metadata information can indicate information about the multi-level index. The information about each level index in the multi-level index is used to indicate the relationship between each level index and the data corresponding to some of the multiple fields. Optionally, if the query request includes a multi-level query request, each level query request in the multi-level query request can correspond to information about a primary index in the multi-level index.
[0076] For example, a multi-level index includes a first-level index and a second-level index, where the first-level index indicates that data corresponding to multiple fields are sequentially connected by separators. Alternatively, the metadata information may indicate that the index is obtained by sequentially arranging data corresponding to multiple fields.
[0077] In addition to indicating the relationship between the index and the data corresponding to multiple fields, the metadata information may also indicate one or more of the identification of the data source, the level of the index, the type of the data source, the data volume of the table, and the identification of the table.
[0078] The data source identifier indicates the source of the data, for example, the address of the source device to which the data can be written. The table data volume refers to the amount of data contained in the table. The data source type indicates the type of source device. The table identifier indicates the identifier of the table containing the data.
[0079] For example, please refer to Table 1 below, which is an example of metadata information provided in an embodiment of the present application.
[0080] Table 1
[0081] As shown in Table 1 above, the metadata information indicates that the identifier of the data source is 12, the type of the data source is A, the identifier of the table is 2341, the first-level index information indicates that the first-level index is composed of the data corresponding to the three fields of building_code, house_code and floor_code connected by a delimiter, and the second-level index information indicates that the second-level index is composed of the data corresponding to the four fields of name, age, job and sex connected by a delimiter.
[0082] Before the data processing device executes S302, the data processing device may obtain and pre-store metadata information. The following describes how the data processing device obtains metadata information.
[0083] Method 1: The data processing device obtains metadata information according to the administrator's input.
[0084] Exemplarily, for example, the source device sends a write request to the data processing device, and the write request is used to request the writing of multiple indexes, and at least one set of data corresponding to multiple fields associated with each index in the multiple indexes. To simplify the description, the embodiment of the present application refers to these multiple indexes, and at least one set of data corresponding to multiple fields associated with each index in the multiple indexes as target data. Alternatively, the data processing device has written the target data into the database. In either case, the administrator can access the target data through the second terminal device. In this way, the administrator can determine the relationship between the index and the data corresponding to the multiple fields based on the target data to obtain metadata information. The administrator can enter the metadata information in the second terminal device, and the second terminal device sends the metadata information to the data processing device. In this way, it is equivalent to the data processing device obtaining the metadata information. In the embodiment of the present application, the data processing device obtaining the metadata information of the target data is used as an example for introduction.
[0085] In one possible embodiment, the data processing device may include at least one interface, and each of the at least one interface supports a communication protocol. When the data processing device receives a write request from a source device, it can determine a target interface that matches the communication protocol of the source device, and receive the write request from the source device through the target interface, which is equivalent to receiving the target data. At least one interface can be used to support at least one of the Java Database Connectivity (JDBC) protocol, the Hypertext Transfer Protocol (HTTP), and the Hypertext Transfer Protocol Secure (HTTPS). In this embodiment, the data processing device can select the corresponding interface according to the actual situation of the source device, so that the data processing device can communicate smoothly with different devices.
[0086] Method 2: The data processing device may extract the relationship between multiple indexes and at least one set of data corresponding to multiple fields associated with each of the multiple indexes to obtain metadata information.
[0087] Exemplarily, the data processing device may analyze, based on the target data, the relationship between multiple indexes and at least one set of data corresponding to multiple fields associated with each of the multiple indexes, thereby obtaining metadata information. For example, the data processing device may include a trained model, and the data processing device may input the target data into the model, and output, through the model, information about the relationship between the multiple indexes and at least one set of data corresponding to multiple fields associated with each of the multiple indexes.
[0088] The data processing device may receive the target data from the source device, or may read the target data from a database in the data storage device. The manner in which the data processing device reads the target data from the data storage device can be referred to as the method for the data processing device to obtain the content of the write request from the source device, and will not be further described here.
[0089] Optionally, the data processing device may also write the target data into a database.
[0090] In the embodiments of the present application, the order in which the data processing device acquires metadata information and writes the target data into the database can be arbitrary and is not limited in this embodiment. For example, the data processing device may acquire metadata information and then write the target data into the database; alternatively, the data processing device may acquire metadata information and write the target data into the database simultaneously; alternatively, the data processing device may write the target data into the database and then acquire metadata information for the target data.
[0091] Please refer to Figure 4, which is a schematic diagram of target data provided in an embodiment of the present application. In Figure 4, the target data is shown in a table. As shown in Figure 4, the target data includes multiple fields and data corresponding to the multiple fields. These multiple fields are the row index (rowkey), building code (building_code), house code (house_code) and floor code (floor_code) in Figure 4. The data corresponding to the multiple fields include the first to sixth groups of data as shown in Figure 4.
[0092] The first group of data indicates that the row index is 123-11-1, the building code is 123, the house code is 11, and the floor code is 1; the second group of data indicates that the row index is 123-11-2, the building code is 123, the house code is 11, and the floor code is 2; the third group of data indicates that the row index is 123-12-1, the building code is 123, the house code is 12, and the floor code is 1; the fourth group of data indicates that the row index is 123-12-2, the building code is 123, the house code is 12, and the floor code is 2; the fifth group of data indicates that the row index is 124-11-1, the building code is 124, the house code is 11, and the floor code is 1; the sixth group of data indicates that the row index is 125-12-1, the building code is 125, the house code is 12, and the floor code is 1.
[0093] For example, the data processing device can analyze the multiple fields and the first set of data in the table shown in FIG4 to determine that the row index in the first set of data is actually formed by the data corresponding to the three fields building_code, house_code, and floor_code, which are sequentially connected by delimiters. Accordingly, the data processing device can obtain metadata information indicating that the row index is formed by the data corresponding to the three fields building_code, house_code, and floor_code, which are sequentially connected by delimiters.
[0094] The content of the query request is different, so the way in which the data processing device determines at least one index corresponding to the query request is also different, which are explained below respectively.
[0095] Case 1: The query request is a first-level query request, and the query request indicates at least one field.
[0096] The data processing device may determine an index corresponding to the at least one field based on the metadata information and the at least one field, that is, obtain at least one index. The at least one index is also the index corresponding to the query request.
[0097] Case 2: The query request is a first-level query request, and the query request indicates at least one field and a value range of data corresponding to each field in the at least one field.
[0098] The data processing device may determine a value range of an index corresponding to each field in the at least one field based on the metadata information and a value range of the data corresponding to each field in the at least one field. The data processing device may use the intersection of the value ranges of the indexes corresponding to each field in the at least one field as the at least one index.
[0099] For example, a database includes the data shown in FIG4 , and an index is obtained by sequentially concatenating data corresponding to multiple fields. For example, at least one field includes building_code and house_code. A query request indicates building_code=123 and house_code=11, and the query request indicates at least one field including building_code and house_code. The data processing device can determine the value range of the index corresponding to each of the at least one field. Specifically, the value range of the index corresponding to building_code=123 should be an index that begins with 123, and the value range of the index corresponding to house_code=11 should include indexes from 11 to 12 (excluding 12). Therefore, it can be determined that at least one index should be an index that includes 123 and 11, that is, the at least one index is 123-11-1 and 123-11-2 shown in FIG4 .
[0100] Case 3: The query request is a multi-level query request, and the query request indicates at least one field.
[0101] The data processing device may determine the index corresponding to each level of the multi-level query request based on the metadata information and a portion of at least one field indicated by each level of the multi-level query request. The data processing device may determine the intersection of the indexes corresponding to each level of the multi-level query request as at least one index. The data processing device may determine the multi-level query request from the query request based on the metadata information.
[0102] Case 4: The query request is a multi-level query request, and the query request indicates at least one field and a value range of each field in the at least one field.
[0103] The data processing device may determine the value range of the first-level index corresponding to each level of the multi-level query request based on the value range corresponding to a portion of the at least one field indicated by each level of the query request, and may cumulatively obtain the value ranges of the multi-level indexes. The data processing device may determine the intersection of the value ranges of the multi-level indexes as at least one index.
[0104] Of course, if the query request directly includes an index, the data processing device can directly use the index to query the data corresponding to the index.
[0105] Please refer to FIG5 , which is a schematic diagram of a method for determining at least one index provided in an embodiment of the present application.
[0106] S501: The data processing device determines the n-th level index.
[0107] The n-th level index is one of the multi-level indexes, n is a positive integer, and the maximum value of n is the number of the multi-level indexes. Exemplarily, the data processing device determines the n-th level index based on the metadata information.
[0108] S502: The data processing device determines the i-th field in the n-th level index.
[0109] The i-th field is one of the fields in the plurality of fields associated with the n-th level index. i is a positive integer.
[0110] S503: The data processing apparatus determines whether there is a value range of data corresponding to the i-th field in the j-th level query request corresponding to the n-th level index.
[0111] If the value range of the data corresponding to the i-th field exists in the j-th level query request corresponding to the n-th level index, the data processing device executes S504, i.e., determines the value range of the index corresponding to the i-th field based on the value range of the data corresponding to the i-th field. If the value range of the data corresponding to the i-th field does not exist in the j-th level query request corresponding to the n-th level index, the data processing device may execute S505, i.e., determine whether all fields corresponding to the n-th level index have been traversed.
[0112] If the data processing device determines that all fields corresponding to the n-th level index have not been traversed, the value of i may be increased (indicated by i+ in FIG5 ), and step S502 may be continued for the increased i. If the data processing device determines that all fields corresponding to the n-th level index have been traversed, step S506 may be executed to determine whether the multi-level index has been traversed.
[0113] If it is determined that the multi-level index has not been traversed completely, the value of n is increased (indicated by n+ in FIG. 5 ), and step S501 is performed for the increased n. If it is determined that the multi-level index has been traversed completely, the data processing device may perform S507, i.e., determine at least one index based on the value range corresponding to each level index in the multi-level index.
[0114] For example, please refer to Figure 6, which is a schematic diagram of the data included in a database provided in an embodiment of the present application. As shown in Figure 6, Figure 6 illustrates an example of a table in the form of the data included in the database. As shown in Figure 6, the database includes multiple fields and data corresponding to multiple fields. These multiple fields are row index 1 (rowkey1), building code (building_code), house code (house_code) and floor code (floor_code), name (name), category (class), row index 2 (rowkey2), business 1 (business1), business 2 (business2) and business 3 (business3) in Figure 6. Row index 1 can be regarded as a first-level index, and row index 2 can be regarded as a second-level index. The data corresponding to multiple fields include the first to sixth groups of data as shown in Figure 6.
[0115] The first group of data indicates that row index 1 is 123-11-1, building code is 123, house code is 11, floor code is 1, row index 2 is 60-135-120, business 1 is 60, business 2 is 135, and business 3 is 120; the second group of data indicates that row index 1 is 123-11-2, building code is 123, house code is 11, floor code is 2, row index 2 is 75-123-134, business 1 is 75, business 2 is 123, and business 3 is 134; the third group of data indicates that row index 1 is 123-12-1, building code is 123, house code is 12, floor code is 1, row index 2 is 80-132-137, business 1 is 80, business 2 is 132, and business 3 is 137; the fourth group of data indicates that According to the indication, row index 1 is 123-12-2, building code is 123, house code is 12, floor code is 2, row index 2 is 90-156-134, business 1 is 90, business 2 is 156, and business 3 is 134; the fifth group of data indicates that row index 1 is 124-11-1, building code is 124, house code is 11, and floor code is 1, row index 2 is 100-158-123, business 1 is 100, business 2 is 158, and business 3 is 123; the sixth group of data indicates that row index 1 is 125-12-1, building code is 125, house code is 12, floor code is 1, row index 2 is 110-132-124, business 1 is 110, business 2 is 132, and business 3 is 124.
[0116] Assuming the database includes the data shown in FIG6 , an index is obtained by sequentially concatenating data corresponding to multiple fields. For example, a query request includes a multi-level query, and the multi-level query request indicates class<3 and businmess1<80. The first-level query request may be class<3, and the second-level query request may be businmess1<80.
[0117] The data processing device can determine the value range of the index corresponding to the first-level query request. Specifically, the value range of the index corresponding to class < 3 is the index corresponding to class in row index 1 with a value less than 5, and the value range of the index corresponding to businmess1 < 80 is the index corresponding to businmess1 in row index 2 with a value less than 80. The data processing device can determine at least one index as an index corresponding to class in row index 1 with a value less than 5, and an index corresponding to businmess1 in row index 2 with a value less than 80, specifically including 123-11-1 and 60-135-120 in row index 1 in Figure 6, and 60-135-120 and 75-123-134 in row index 2.
[0118] S303: The data processing device searches for N groups of data corresponding to at least one index, where N is a positive integer.
[0119] After the data processing device determines at least one index, it can query the database for N sets of data corresponding to the at least one index. When the number of tables included in the database is different, the data processing device determines N sets of data in different ways, which are explained below.
[0120] 1. The number of tables included in the database is 1.
[0121] The data processing device can directly determine a group of data corresponding to each index in the at least one index from the table, and obtain N groups of data in total.
[0122] 2. The number of tables included in the database is greater than 1.
[0123] In a possible implementation, the data processing device may determine a group of data corresponding to each index in the at least one index from a plurality of tables included in the database, and obtain N groups of data in total.
[0124] In another possible embodiment, the data processing device may determine a table with the smallest amount of data from multiple tables (the first table is used as an example in the embodiment of the present application), determine a group of data corresponding to each index in the at least one index, and obtain K groups of data in total, where K is a positive integer. Based on these K groups of data, the data processing device then searches for L groups of data that are identical to each group of data in the K groups of data from other tables (tables in the multiple tables other than the first table), thereby obtaining N groups of data, that is, the N groups of data include K groups of data and L groups of data. L is a non-negative integer. Tables in the multiple tables other than the first table, for example, include the second table.
[0125] In this embodiment, the data processing device can query data from a table with a larger amount of data based on the query results of a table with a smaller amount of data, which is equivalent to querying multiple tables together. In this way, the data processing device can query data in a table with a larger amount of data with the help of the query results from the table with a smaller amount of data, thereby improving the efficiency of querying data.
[0126] Alternatively, the data processing device may include multiple threads, each of which is used to query data from one of the multiple tables. Alternatively, each of the multiple threads may correspond to one of the multiple tables. In this way, the data processing device may query data through multiple threads, thereby improving the efficiency of data query.
[0127] Before the data processing device queries L groups of data identical to the K groups of data from tables other than the first table among the multiple tables, the thread corresponding to the first table (such as the first thread) can send the K groups of data to other threads, so that the other threads can query data identical to the K groups of data from other tables.
[0128] The following describes a process for the data processing device to determine N sets of data from the first and second tables, using an example in which multiple tables include a first table and a second table, a data processing device includes a first thread and a second thread, the first thread is used to query data from the first table, and the second thread is used to query data from the second table, and the amount of data in the first table is smaller than the amount of data in the second table. Please refer to Figure 7, which is a schematic diagram of a method for determining N sets of data provided in an embodiment of the present application.
[0129] S701: A first thread determines K groups of data corresponding to at least one index from a first table.
[0130] S702: The first thread sends K groups of data to the second thread. Correspondingly, the second thread receives the K groups of data from the first thread.
[0131] S703: The second thread determines, from the second table, a group of data that is identical to each group of data in the K groups of data, to obtain L groups of data.
[0132] In this way, the data processing device can obtain K groups of data from the first thread and L groups of data from the second thread, thus obtaining N groups of data.
[0133] For example, the first table is the table shown in FIG4 , the second table is the table shown in FIG6 , and at least one index includes 123-11-1 and 123-11-2. Please refer to FIG8 , which is a schematic diagram of a process for querying data in a joint table provided in an embodiment of the present application. The data processing device may determine that the amount of data in the first table is smaller, so the data processing device may query the first table through a first thread for K groups of data that meet at least one index, including the first group of data and the second group of data in the first table. The first thread may send the K groups of data to the second thread. The data processing device may query the second table through a second thread for L groups of data that are the same as the K groups of data, and these L groups of data include the first group of data and the second group of data in the second table.
[0134] Assume that the first table contains 10,000 rows of data and the second table contains 100 million rows of data. According to the solution of the embodiment of the present application, after obtaining the first and second sets of data from the first table, the data processing device can directly scan the first and second sets of data from the second table. This is equivalent to the data processing device only scanning two rows of data. This can reduce the amount of data that the data processing device needs to scan, thereby improving the efficiency of the data processing device in querying data from the second table, thereby improving the overall efficiency of data querying.
[0135] S304: The data processing device sends the query result to the first terminal device. Correspondingly, the first terminal device receives the query request from the data processing device.
[0136] After the data processing apparatus obtains N sets of data, it may send a query request to the first terminal device, where the query request is used to indicate the N sets of data.
[0137] In an embodiment of the present application, the data processing device can determine at least one index corresponding to the query request based on the query request, which is equivalent to the data processing device being able to perceive the relationship between the query request and the index. In this way, the data processing device can subsequently directly query data based on the at least one index without having to traverse all the data in the database to determine the data that meets the query request, reducing the search range of the data processing device for querying data, which is conducive to improving the efficiency of the data processing device in querying data, thereby improving the efficiency of the data processing device in querying data, and thus helping to more quickly feedback the queried data to the user and improve the user experience. In addition, in an embodiment of the present application, the data processing device can also query data by combining multiple tables in the database, rather than performing an independent query process on each table, which is also conducive to improving the efficiency of querying data. The method in the embodiment of the present application is applicable to scenarios where massive data is queried. In this scenario, the method in the embodiment of the present application applied can greatly narrow the scope of search data, reduce the processing load of the data processing device, and greatly improve data query efficiency.
[0138] The present application provides a data processing device. This data processing device can be used to implement the functions of any of the data processing devices described above, and accordingly, can also perform the steps performed by the data processing devices described above. Please refer to Figure 9, which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application.
[0139] As shown in FIG9 , the data processing device 900 includes a query request parsing module 901 and a data query module 902 . Optionally, the data processing device 900 further includes a metadata storage module 903 .
[0140] Query request parsing module 901, data query module 902, and metadata storage module 903 can all be implemented via software or hardware. For example, the implementation of query request parsing module 901 will be described below using query request parsing module 901 as an example. Similarly, the implementation of data query module 902 and metadata storage module 903 can refer to the implementation of query request parsing module 901.
[0141] As an example of a software functional unit, the query request parsing module 901 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the query request parsing module 901 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.
[0142] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0143] As an example of a hardware functional unit, query request parsing module 901 may include at least one computing device, such as a server. Alternatively, query request parsing module 901 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0144] The multiple computing devices included in the query request parsing module 901 can be distributed in the same region or in different regions. The multiple computing devices included in the query request parsing module 901 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the query request parsing module 901 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.
[0145] Exemplarily, the query request parsing module 901 may be used to execute steps S301 , S302 , and S304 , and the data query module 902 may be used to execute step S303 .
[0146] Optionally, the metadata storage module 903 is used to obtain and store metadata information. The specific content of each step and the content of the metadata information can be referred to above and will not be listed here.
[0147] An embodiment of the present application provides a computing device. Please refer to Figure 10, which is a structural diagram of a computing device 1000 provided in an embodiment of the present application. As shown in Figure 10, the computing device 1000 includes a processor 1001 and a memory 1002. The processor 1001 and the memory 1002 can be coupled or integrated, or the processor 1001 and the memory 1002 can be relatively independently provided. Optionally, the computing device 1000 also includes a communication interface 1003. The communication interface 1003 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to realize communication between the computing device 1000 and other devices or a communication network.
[0148] The processor 1001, the memory 1002, and the communication interface 1003 can communicate with each other via the bus 1004. The computing device 1000 can be a server or a terminal device. It should be understood that the embodiment of the present application does not limit the number of processors 1001 and memories 1002 in the computing device 1000.
[0149] Bus 1004 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG10 illustrates a single bus line, but this does not imply a single bus or type of bus. Bus 1004 may include a path for transmitting information between various components of computing device 1000 (e.g., processor 1001, memory 1002, and communication interface 1003).
[0150] The processor 1001 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0151] The memory 1002 may include volatile memory, such as random access memory (RAM). The memory 1002 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0152] Memory 1002 stores executable program code. Processor 1001 executes this executable program code to implement the functions of query request parsing module 901, data query module 902, and metadata storage module 903 shown in FIG9 , thereby implementing any of the data processing methods described above. Specifically, memory 1002 stores instructions for executing any of the data processing methods. The functions of query request parsing module 901, data query module 902, and metadata storage module 903 can be found in the discussion of FIG9 .
[0153] Alternatively, the memory 1002 stores executable code, and the processor 1001 executes the executable code to respectively implement the functions of the aforementioned computing device, thereby implementing any of the aforementioned data processing methods. That is, the memory 1002 stores instructions for executing any of the aforementioned data processing methods.
[0154] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. Each of the at least one computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0155] Please refer to Figure 11, which is a structural diagram of a computing device cluster provided in an embodiment of the present application. As shown in Figure 11, the computing device cluster includes at least one computing device 1100. Each computing device 1100 in the computing device cluster may include a processor 1101 and a memory 1102. Optionally, each computing device 1100 in the computing device cluster also includes a communication interface 1103. The processor 1101, the memory 1102 and the communication interface 1103 can be connected via a bus 1104. Among them, the implementation method of the processor 1101 can refer to the content of the processor 1001 in Figure 10 above, the implementation method of the memory 1102 can refer to the content of the memory 1002 in Figure 10 above, the implementation method of the communication interface 1103 can refer to the content of the communication interface 1003 in Figure 10 above, and the implementation method of the bus 1104 can also refer to the content of the bus 1004 in Figure 10 above.
[0156] In one possible implementation, the memory 1102 in each computing device 1100 in the computing device cluster may store the same instructions for executing any of the aforementioned data processing methods.
[0157] In another possible implementation, the memory 1102 of at least one computing device 1100 in the computing device cluster may also store partial instructions for executing any of the aforementioned data processing methods. In other words, the combination of at least one computing device 1100 can collectively execute instructions for executing any of the aforementioned data processing methods.
[0158] Optionally, the memory 1102 in different computing devices 1100 in the computing device cluster may store different instructions, each for executing a portion of the functions of the data processing apparatus 900 in FIG9 . That is, the instructions stored in the memory 1102 in different computing devices 1100 may implement the functions of one or more of the query request parsing module 901, data query module 902, and metadata storage module 903 in FIG9 . The functions of the query request parsing module 901, data query module 902, and metadata storage module 903 may refer to the discussion above regarding FIG9 .
[0159] In some possible implementations, at least one computing device 1100 in a computing device cluster may be connected via a network. The network may be a wide area network (WAN), a local area network (LAN), or the like. Specifically, the network is connected via a communication interface 1103 in each computing device 1100. In this type of possible implementation, at least one computing device 1100 in the computing device cluster may collectively execute any of the aforementioned data processing methods.
[0160] An embodiment of the present application provides a chip system, comprising: a processor and an interface, wherein the processor is configured to call and execute instructions from the interface, and when the processor executes the instructions, any of the above-mentioned data processing methods is implemented.
[0161] An embodiment of the present application provides a computer-readable storage medium for storing a computer program or instruction, which, when executed, implements any of the above-mentioned data processing methods. The computer-readable storage medium may be any available medium that a computing device can store or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive).
[0162] The present application provides a computer program product comprising instructions, which, when executed on a computer, implements any of the aforementioned data processing methods. The computer program product may be software or a program product comprising instructions that can be executed on a computing device or stored in any available medium.
[0163] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, a register, a hard disk, a mobile hard disk, a CD-ROM or any other form of storage medium well known in the art. 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 base station or a terminal. Of course, the processor and the storage medium can also exist in a base station or a terminal as discrete components.
[0164] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are performed in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, or other programmable device. The computer program or instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions may be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; an optical medium, such as a digital video disk; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium may be a volatile or nonvolatile storage medium, or may include both volatile and nonvolatile types of storage media.
[0165] In the various embodiments of the present application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced by each other. The technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.
[0166] It is understood that the various numbers used in the embodiments of this application are merely for ease of description and are not intended to limit the scope of the embodiments of this application. The order of the sequence numbers of the above-mentioned processes does not necessarily imply a specific order of execution; the order of execution of the processes should be determined by their functions and inherent logic.
Claims
1. A data processing method, It is characterized in that Applied to a data processing device, the method comprises: receiving a query request, wherein the query request indicates at least one field to which the data to be queried belongs; Determining, according to metadata information, at least one index corresponding to the query request, the metadata information indicating a relationship between the index and data corresponding to a plurality of fields, the plurality of fields including the at least one field; Querying N groups of data associated with the at least one index from a database, wherein the database includes multiple indexes and at least one group of data corresponding to the multiple fields associated with each of the multiple indexes, wherein the multiple indexes are arranged in order in the database, and N is a positive integer; A query result is sent, where the query result indicates the N groups of data.
2. The method according to claim 1, It is characterized in that The database includes a first table and a second table, the first table and the second table are used to store the multiple indexes and at least one set of data corresponding to the multiple fields associated with each index in the multiple indexes, and the amount of data in the first table is smaller than the amount of data in the second table; Querying N sets of data associated with the at least one index from a database, including: Querying a set of data associated with each index in the at least one index from the first table, obtaining K sets of data in total, where K is a positive integer; From the second table, a group of data identical to each group of data in the K groups of data is searched to obtain L groups of data in total, where L is a non-negative integer, and the N groups of data include the K groups of data and the L groups of data.
3. The method according to claim 2, It is characterized in that The data processing device includes a first thread and a second thread, the first thread being used to query a set of data associated with each index of the at least one index from the first table; Querying a group of data that is the same as each group of data in the K groups of data from the second table, including: Sending the K groups of data to the second thread through the first thread; A group of data identical to each group of data in the K groups of data is queried from the second table through the second thread.
4. The method according to any one of claims 1 to 3, It is characterized in that Before determining at least one index corresponding to the query request according to the metadata information, the method further includes: Receive the multiple indexes and at least one set of data corresponding to the multiple fields associated with each of the multiple indexes; The relationship between the multiple indexes and at least one set of data corresponding to the multiple fields is extracted to obtain the metadata information, and the metadata information is stored.
5. The method according to any one of claims 1 to 4, It is characterized in that The query request includes a multi-level query request, each level of the query request in the multi-level query request indicates a part of the at least one field; the metadata information indicates a relationship between each level of index in the multi-level index and data corresponding to the part of the multiple fields, each level of the query request in the multi-level query request corresponds to a level one index in the multi-level index; Determining at least one index corresponding to the query request according to the metadata information includes: According to the relationship between each level of index in the multi-level index and some of the multiple fields, the value range of the first-level index corresponding to each level of query request in the multi-level query request is determined, and the value range of the multi-level index is obtained in total, wherein the at least one index is the intersection of the value ranges of the multi-level index.
6. The method according to claim 5, It is characterized in that The query request at each level further indicates a value range of data corresponding to some fields in the at least one field; Determining a value range of a primary index corresponding to each level of query request in the multi-level query request includes: The value range of the primary index corresponding to the each-level query request is determined according to the value range of the data corresponding to each field in some fields of the at least one field indicated by the each-level query request.
7. A data processing device, It is characterized in that include: a query request parsing module, configured to receive a query request, the query request indicating at least one field to which the data to be queried belongs, and determine at least one index corresponding to the query request according to metadata information, the metadata information indicating a relationship between the index and data corresponding to a plurality of fields, the plurality of fields including the at least one field; A data query module, configured to query N groups of data associated with the at least one index from a database, wherein the database includes a plurality of indexes and at least one group of data corresponding to the plurality of fields associated with each of the plurality of indexes, wherein the plurality of indexes are arranged in order in the database, and N is a positive integer; The query request parsing module is further used to send a query result, where the query result indicates the N groups of data.
8. The device according to claim 7, It is characterized in that The database includes a first table and a second table, the first table and the second table are used to store the multiple indexes and at least one set of data corresponding to the multiple fields associated with each index in the multiple indexes, and the amount of data in the first table is less than the amount of data in the second table; the data query module is specifically used to: Querying a set of data associated with each index in the at least one index from the first table, obtaining K sets of data in total, where K is a positive integer; From the second table, a group of data identical to each group of data in the K groups of data is searched to obtain L groups of data in total, where L is a non-negative integer, and the N groups of data include the K groups of data and the L groups of data.
9. The device according to claim 8, It is characterized in that The data query module is specifically used for: By means of the first thread, querying a set of data associated with each index of the at least one index from the first table to obtain the K sets of data, and sending the K sets of data to the second thread; A group of data identical to each group of data in the K groups of data is queried from the second table through the second thread.
10. The device according to any one of claims 7 to 9, It is characterized in that The device further comprises a metadata storage module, wherein the metadata storage module is used for: Receive the multiple indexes and at least one set of data corresponding to the multiple fields associated with each of the multiple indexes; The relationship between the multiple indexes and at least one set of data corresponding to the multiple fields is extracted to obtain the metadata information, and the metadata information is stored.
11. The device according to any one of claims 7 to 10, It is characterized in that The query request includes a multi-level query request, each level of the query request in the multi-level query request indicates a part of the at least one field; the metadata information indicates a relationship between each level of index in the multi-level index and data corresponding to the part of the multiple fields, each level of the query request in the multi-level query request corresponds to a level one index in the multi-level index; the query request parsing module is specifically used to: According to the relationship between each level of index in the multi-level index and some of the multiple fields, the value range of the first-level index corresponding to each level of query request in the multi-level query request is determined, and the value range of the multi-level index is obtained in total, wherein the at least one index is the intersection of the value ranges of the multi-level index.
12. The device according to claim 11, It is characterized in that The query request at each level further indicates a value range of data corresponding to some fields in the at least one field; the query request parsing module is specifically used to: The value range of the primary index corresponding to the each-level query request is determined according to the value range of the data corresponding to each field in some fields of the at least one field indicated by the each-level query request.
13. A computing device, It is characterized in that include: Processor and memory; The memory is used to store one or more computer programs, and the one or more computer programs include computer execution instructions. When the computing device is running, the processor executes the one or more computer programs stored in the memory, so that the computing device performs the method according to any one of claims 1 to 6.
14. A computing device, It is characterized in that include: Processor and memory; The memory is used to store one or more computer programs, wherein the one or more computer programs include computer instructions. When the processor executes the computer instructions, the method according to any one of claims 1 to 6 is executed.
15. A computing device cluster, It is characterized in that comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 6.
16. A computer-readable storage medium, It is characterized in that The storage medium stores a computer program or instruction. When the computer program or instruction is executed by the communication device, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data processing method and device
CN118656367A
Database index creation method and device
CN107016018A
Data query method, nonvolatile storage medium and electronic equipment
CN113312313A
Data query method and device, equipment and storage medium
CN113821533A
Database query method and related device
CN114764406A
