Data query method, device, equipment and storage medium
By introducing the paging query method in the Hbase database, M rows of data are obtained and query parameters are updated, which solves the problem of slow response speed for massive data queries and improves query efficiency and response speed.
Patent Information
- Application Number
- CN202011063233.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-30
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2040-09-30
AI Technical Summary
In Hbase database, the response speed is slow when querying massive data, resulting in inefficient query.
By introducing the paging query method, M rows of data are obtained according to the target query instruction and the preset number of rows N, M is less than or equal to N+1, and the query parameters are updated to support the page turning query function.
It improves the query response speed, improves the efficiency of paging queries, and supports page turning and page jump query functions.
Smart Images

Figure CN112182040B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data query method, device, equipment and storage medium. Background Art
[0002] Hbase is a distributed, column-oriented, non-relational open source database. HBase stores data in the form of tables. Tables consist of rows and columns, and columns are divided into several column families. Hbase stores ROWKEY-value pairs. ROWKEY is the primary key used to retrieve Hbase. ROWKEY can be any string. When storing, data is sorted and stored according to the byte order of ROWKEY.
[0003] In the related art, when querying Hbase data, a single ROWKEY or a range of ROWKEY can be used for querying. However, for the massive amount of data queried, it takes a long time to return the massive amount of data to the user for display, resulting in a slow query response speed. Summary of the invention
[0004] The present application provides a data query method, apparatus, device and storage medium to implement paging query and improve query response speed.
[0005] In a first aspect, the present application provides a data query method, comprising:
[0006] Get the target query instruction;
[0007] According to the target query instruction, the preset number of rows N and the query parameters, M rows of data are obtained, wherein M is less than or equal to N+1, and M and N are integers greater than or equal to zero respectively; the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a corresponding relationship between at least one query page and its respective next page;
[0008] The query parameters are updated according to the target query instruction and the M rows of data.
[0009] In a second aspect, the present application provides a data query device, comprising:
[0010] An acquisition module, used to acquire a target query instruction;
[0011] The acquisition module is further used to acquire M rows of data according to the target query instruction, a preset number of rows N and query parameters, wherein M is less than or equal to N+1, and M and N are integers greater than or equal to zero respectively; the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a corresponding relationship between at least one query page and its respective next page;
[0012] A processing module is used to update the query parameters according to the target query instruction and the M rows of data.
[0013] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any one of the methods described in the first aspect.
[0014] In a fourth aspect, an embodiment of the present application provides an electronic device, including:
[0015] Processor; and
[0016] A memory, configured to store executable instructions of the processor;
[0017] The processor is configured to perform the method according to any one of the first aspects by executing the executable instructions.
[0018] The data query method, apparatus, device and storage medium provided in the embodiments of the present application obtain M rows of data according to the target query instruction, the preset number of rows N and the query parameters, where M is less than or equal to N+1, and N is the number of rows of each query page. Each query instruction returns M rows of data, and the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a corresponding relationship between at least one query page and its respective next page. The paging query efficiency is high, and for massive data, the query response speed can be improved. The query parameters are updated according to the target query instruction and the M rows of data to support the page turning query function. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] Figure 1 A schematic diagram of the system architecture provided for an embodiment of the present application;
[0021] Figure 2 A schematic diagram of Hbase query provided in an embodiment of the present application;
[0022] Figure 3 It is a flow chart of an embodiment of a data query method provided by the present application;
[0023] Figure 4 It is a flowchart of another embodiment of the data query method provided by the present application;
[0024] Figure 5 It is a structural diagram of an embodiment of a data query device provided by the present application;
[0025] Figure 6 It is a schematic diagram of the structure of an electronic device embodiment provided by the present application.
[0026] 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
[0027] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0028] The terms "including" and "having" and any variations thereof in the specification and claims of the present application and the drawings 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 limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0029] First, some vocabulary and application scenarios involved in the embodiments of the present application are introduced.
[0030] Pagination query: It is a technology that displays all the queried data to the user in segments. The user does not see all the data each time, but only a part of it. If the content they want is not found in it, the user can change the visible content by specifying the page number or turning the page until they find the content they want.
[0031] ROWKEY: Similar to the primary key in a traditional relational database, it serves as the unique index of a row in an HBase database.
[0032] Figure 1 This is a schematic diagram of the system architecture provided in the embodiment of the present application. Figure 1As shown, the system architecture of the embodiment of the present application may include but is not limited to: an electronic device 11 and a server 12. The electronic device is, for example, an Hbase client device.
[0033] The electronic device 11 and the server 12 may be connected via a network.
[0034] The server may be one or more servers, or a distributed cluster system consisting of multiple servers.
[0035] Hbase relies on the distributed system architecture Hadoop. Hbase cluster system generally includes Hadoop, ZooKeeper and Hbase and other related processes. Hadoop is responsible for the underlying storage, while ZooKeeper, as a service coordinator, is responsible for managing the corresponding metadata information in Hbase, and Hbase is the read-write medium and data parsing service. Figure 2 The following is a typical Hbase database query flow chart. New read and write operations generally include three Remote Procedure Call Protocol (RPC) requests. First, ZooKeeper is requested to find the HRegion server address information where the meta table is located based on table, get, and scan, and the corresponding address information is cached. Then, the corresponding meta table information is read from the corresponding server based on the Region server address information where the meta table is located in the previous step, and cached locally. Finally, the Region server address of the data to be queried is located through the meta table information and the request parameter ROWKEY, and an RPC request is sent to read the data on the Region server and the result is returned. This completes a read and write operation.
[0036] Hbase database generally uses ROWKEY or startrow and endrow, combined with certain filters, to perform a large number of read operations. If the span of startrow and endrow is relatively large and the queried data is very large (such as transaction details in the financial industry), there will be performance bottlenecks, and in serious cases, it will cause risks such as downtime.
[0037] During the research, the inventor found that if all the queried data is read out at once and then returned in pages in the memory, paging display can be achieved, but on the one hand, it affects the performance of the device and is inefficient, and it cannot be achieved if the amount of queried data is large.
[0038] The method of the embodiment of the present application introduces paging query in the Hbase database, and obtains M rows of data by querying at one time according to the query parameters. The paging query has high efficiency and can improve the query response speed. Different query pages can be distinguished by the identifier of the first row of data in each page. After the query, the query parameters need to be updated to support query functions such as up and down page turning and page jumping, thereby realizing a solution for paging query of massive data in the HBase database.
[0039] It should be noted that the query method of the embodiment of the present application is not limited to the HBase database, but is also applicable to other databases.
[0040] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0041] Figure 3 1 is a flow chart of an embodiment of a data query method provided by the present application. Figure 3 As shown, the method provided in this embodiment includes:
[0042] Step 101: Get a target query instruction.
[0043] Specifically, when performing a paging query on an Hbase database, an Hbase client device sends a target query instruction to a server, and the server obtains the target query instruction and queries data according to the target query instruction.
[0044] The target query instruction is any one of the following: first query instruction, previous page query instruction, next page query instruction, jump page query.
[0045] If it is the first query instruction, the target query instruction may also indicate the range of the query data and the preset number of rows N for each page, such as STARTROW and ENDROW.
[0046] If it is a previous page query instruction, a next page query instruction or a page jump query, the target query instruction may also indicate an identifier of the query page.
[0047] Step 102: Obtain M rows of data according to the target query instruction, the preset number of rows N and the query parameters, where M is less than or equal to N+1, and M and N are integers greater than or equal to zero respectively; the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a correspondence between at least one query page and its respective next page.
[0048] Specifically, according to the target query instruction, the preset number of rows N and the query parameters, the query page to be queried is determined, for example, the identifier of the current query page to be queried is determined, for example, including at least one of the following: the page number of the query page, the identifier of the starting row of the query page (such as the starting row number, the primary key ROWKEY of the starting row, etc.).
[0049] Get M rows of data starting from the start row of the query page, where M ranges from 0 to N+1.
[0050] The preset number of rows N may be a preset number of rows per page, or may be indicated in the target query instruction.
[0051] The query parameter is used to find the identifier of the starting row of the current query page when performing paging query, especially for page turning settings, such as previous page, next page, and page skip query.
[0052] In one embodiment, the query parameter includes at least one of the following parameters:
[0053] The identifier of the previous page, such as the first identifier of the first row of data on the previous page;
[0054] The identifier of the next page, such as the second identifier of the first row of data in the next page;
[0055] A corresponding relationship between at least one query page and a respective next page.
[0056] Among them, the association relationship between the current query page and the next page can be set in the query parameters, that is, the correspondence between the first row of data of two adjacent pages. In one embodiment, for any query page, the correspondence includes: the identifier of the query page, and the correspondence between the identifier of the next page of the query page, for example, through the correspondence between the second identifier of the first row of data in the next page of the current query page and the identifier of the first row of data in the current query page.
[0057] In one embodiment, the correspondence between multiple query pages may form a correspondence set, and may also be stored in a table format.
[0058] The corresponding relationship in the query parameter can be used to determine where the first row of data of the previous page and the next page of two adjacent pages is located, as shown in Table 1, for example.
[0059] Table 1
[0060]
[0061] In Table 1, for example, the preset number of rows of the query page is 20.
[0062] In other embodiments, the previous page mark and the next page mark may also use other marks, and the embodiments of the present application are not limited to this.
[0063] In other embodiments, the corresponding relationship may also be reflected, for example, by the corresponding relationship between the identifier of the last row of data in the query page and the identifier of the last row of data in the next page of the query page, which is not limited in the embodiments of the present application.
[0064] For example, the target query instruction is the first query, the value of the query parameter is empty, and M rows of data are obtained starting from the starting row of the query page (that is, the set STARTROW), where the range of M is 0-N+1.
[0065] The target query instruction is the next page query, and the value of the query parameter is not empty. According to the query parameter, it can be determined that the starting row of the query page is, for example, row 21, and M rows of data are obtained starting from row 21.
[0066] The target query instruction is a previous page query, and the value of the query parameter is not empty. According to the query parameter, the starting row of the query page can be determined to be, for example, row 1, and M rows of data are obtained starting from row 1.
[0067] The target query instruction is a page jump query, and the value of the query parameter is not empty. For example, the query page is page 3. According to the query parameter, it can be determined that the starting row of the query page is, for example, row 61, and M rows of data are obtained starting from row 61.
[0068] Optionally, the acquired data may also be displayed. If M is N+1, the first N rows of data among the M rows of data are displayed. If M is less than N+1, M rows of data are displayed.
[0069] Step 103: Update query parameters according to the target query instruction and M rows of data.
[0070] Specifically, assuming that M rows of data are N+1 rows of data, the extra last row is the first row of data on the next page, and the second identifier of the first row of data on the next page is updated, that is, the second identifier is the identifier of the last row of data in the M rows of data. Otherwise, if M is less than N+1, it means that there is no next page of data, and the identifier of the first row of data on the next page is empty.
[0071] Establish a correspondence between the next page of the query page and the query page. For example, establish a correspondence between the second identifier of the first row of data in the next page of the query page and the identifier of the first row of data in the query page (i.e., the identifier of the first row of data in M rows), and update the correspondence of the query page.
[0072] According to the identifier of the first row of data in the query page, the first identifier of the first row of data in the corresponding previous page is searched in the corresponding relationship.
[0073] Exemplarily, if the target query instruction is the first query instruction, the first query instruction also indicates STARTROW and ENDROW, where STARTROW and ENDROW represent the range of ROWKEY lexicographic order, and M rows of data are obtained starting from STARTROW, where M ranges from 0-N+1, and N is 20, for example.
[0074] If M is less than N+1, it means there is no next page of data;
[0075] If M is equal to N+1, the identifier of the last row in the M rows of data (such as the primary key ROWKEY) is used as the second identifier NEXT_PAGE_START_ROWKEY of the first row of data in the next page.
[0076] If there is no previous page in the first query, the first identifier PRE_PAGE_START_ROWKEY of the first row of data in the previous page is empty, that is, the first identifier is empty.
[0077] Set the corresponding relationship: the second identifier of the first row of data in the next page of the current query page, and the identifier of the first row of data in the current query page, that is, the corresponding relationship between the identifier of the first row of M rows of data.
[0078] Table 2
[0079]
[0080] If the target query instruction is the next page query instruction, the previous return result includes PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY (the identifier of the first row of data). Assume that PRE_PAGE_START_ROWKEY is empty, NEXT_PAGE_START_ROWKEY is the identifier of the last row of data in M rows of data, for example, the ROWKEY of the 21st row of data, and set the identifier CURSOR_ROWKEY of the start row of the current query page to NEXT_PAGE_START_ROWKEY.
[0081] The starting row number of this query page is the row number corresponding to CURSOR_ROWKEY, that is, the row number corresponding to NEXT_PAGE_START_ROWKEY.
[0082] Get M rows of data starting from the starting row number 21, for example, get rows 21 to 41 of data.
[0083] If M is less than N+1, it means there is no next page of data;
[0084] If M is equal to N+1, the identifier (ROWKEY) of the last row in the M rows of data is used as the second identifier of the first row of data in the next page.
[0085] According to the identifier of the first row of data in the current query page, query the stored corresponding relationship to obtain the first identifier of the first row of data in the previous page of the query page;
[0086] For example, the identifier of the first row of data in the current query page is the identifier of the 21st row of data, and when querying Table 2, the identifier of the first row of data in the previous page is the identifier of the 1st row of data.
[0087] Generate a new correspondence between the identifier of the first row of data in the next page of the query page (i.e., the identifier of the 41st row of data) and the identifier of the first row of data in the query page (i.e., the identifier of the 21st row of data), and save it in the table to obtain the following Table 3:
[0088] Table 3
[0089]
[0090] If the target query instruction is the previous page query instruction, the previous return result includes PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY (the identifier of the 21st row of data). Assume that PRE_PAGE_START_ROWKEY is the identifier of the 1st row of data, NEXT_PAGE_START_ROWKEY is the identifier of the last row of data in M rows of data, for example, the ROWKEY of the 41st row of data, and set CURSOR_ROWKEY to PRE_PAGE_START_ROWKEY.
[0091] The starting row number of this query page is the row number corresponding to PRE_PAGE_START_ROWKEY, row 1.
[0092] Get M rows of data starting from the starting row number, for example, get rows 1 to 21 of data.
[0093] If M is less than N+1, it means there is no next page of data;
[0094] If M is equal to N+1, the identifier (ROWKEY) of the last row in the M rows of data is used as the second identifier of the first row of data in the next page. For example, the identifier of the 21st row is used as the second identifier of the first row of data in the next page.
[0095] According to the identifier of the first row of data in the current query page, query the stored corresponding relationship set, that is, take the current query page as the next page, find the identifier of the previous page of the next page, and obtain the first identifier of the first row of data in the previous page of the query page;
[0096] For example, the identifier of the first row of data in the current query page is the identifier of the 1st row of data, and the corresponding relationship is queried to find that the first identifier of the first row of data in the previous page is empty.
[0097] Generate a new correspondence between the second identifier of the first row of data in the next page of the query page (ie, the identifier of the 21st row of data) and the identifier of the first row of data in the query page (ie, the identifier of the 1st row of data), and update Table 3. At this time, the data in Table 3 remains unchanged.
[0098] Among them, according to the above Tables 2 and 3, it can be queried: the corresponding relationship between the identifier of the query page and the first row of data of the current query page, for example, the identifier of the first row of data on the 2nd page is the identifier of the 21st row of data.
[0099] The method of this embodiment obtains M rows of data according to the target query instruction, the preset number of rows N and the query parameters, where M is less than or equal to N+1, and N is the number of rows of each query page. Each query instruction returns M rows of data, and the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a corresponding relationship between at least one query page and its respective next page. The paging query efficiency is high, and for massive data, the query response speed can be improved. The query parameters are updated according to the target query instruction and the M rows of data to support the page turning query function.
[0100] In one embodiment, the corresponding relationship is represented by a key-value pair, the key of the key-value pair is: the second identifier of the first row of data in the next page of the query page, and the value of the key-value pair is: the identifier of the first row of data in the query page.
[0101] The key-value pairs may be stored in a table format, such as in a query table.
[0102] Table 4
[0103]
[0104]
[0105] If M is N+1, when the key-value pair of the query parameter is updated, a correspondence is established between the second identifier of the first row of data in the next page of the query page (i.e., the identifier of the last row of data in M rows) and the identifier of the first row of data in the query page (i.e., the identifier of the first row of data in M rows), that is, as a key-value pair, the key-value pair corresponding to the query page in the query table is updated.
[0106] According to the identifier of the first row of data in the query page, the identifier of the first row of data in the corresponding previous page is searched in the query table; that is, the identifier of the first row of data in the query page is used as the key of the key-value pair to query the value of the key-value pair as the first identifier of the first row of data in the previous page.
[0107] Exemplarily, if the target query instruction is the first query instruction, the first query instruction also indicates STARTROW and ENDROW, where STARTROW and ENDROW represent the range of ROWKEY lexicographic order, and M rows of data are obtained starting from STARTROW, where M ranges from 0-N+1, and N is 20, for example.
[0108] If M is less than N+1, it means there is no next page of data;
[0109] If M is equal to N+1, the identifier of the last row in the M rows of data (such as the primary key ROWKEY) is used as the second identifier NEXT_PAGE_START_ROWKEY of the first row of data in the next page.
[0110] If there is no previous page in the first query, the first identifier PRE_PAGE_START_ROWKEY of the first row of data in the previous page is empty.
[0111] Set a key-value pair: the key of the key-value pair is: the second identifier of the first row of data in the next page of the current query page, and the value of the key-value pair is: the identifier of the first row of data in the current query page, that is, the identifier of the first row in the M rows of data.
[0112] Table 5
[0113]
[0114] If the target query instruction is the next page query instruction, the previous return result includes PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY (the identifier of the first row of data). Assume that PRE_PAGE_START_ROWKEY is empty, NEXT_PAGE_START_ROWKEY is the identifier of the last row of data in M rows of data, for example, the ROWKEY of the 21st row of data, and set the identifier CURSOR_ROWKEY of the start row of the current query page to NEXT_PAGE_START_ROWKEY.
[0115] The starting row number of this query page is the row number corresponding to CURSOR_ROWKEY, that is, the row number corresponding to NEXT_PAGE_START_ROWKEY.
[0116] Get M rows of data starting from the starting row number 21, for example, get rows 21 to 41 of data.
[0117] If M is less than N+1, it means there is no next page of data;
[0118] If M is equal to N+1, the identifier (ROWKEY) of the last row in the M rows of data is used as the second identifier of the first row of data in the next page.
[0119] According to the identifier of the first row of data in the current query page, query the stored key-value pairs to obtain the first identifier of the first row of data in the previous page of the query page;
[0120] For example, the identifier of the first row of data in the current query page is the identifier of the 21st row of data, and Table 5 is queried to obtain that the first identifier of the first row of data in the previous page is the identifier of the 1st row of data.
[0121] Generate a new key-value pair, the key of which is: the second identifier of the first row of data in the next page of the query page (i.e., the identifier of the 41st row of data), and the value of which is: the identifier of the first row of data in the query page (i.e., the identifier of the 21st row of data), and save it in the table to obtain the following Table 6:
[0122] Table 6
[0123]
[0124] If the target query instruction is the previous page query instruction, the previous return result includes PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY (the identifier of the 21st row of data). Assuming that PRE_PAGE_START_ROWKEY is the identifier of the 1st row of data and NEXT_PAGE_START_ROWKEY is the identifier of the last row of data in M rows of data, for example, the ROWKEY of the 41st row of data, set CURSOR_ROWKEY to PRE_PAGE_START_ROWKEY.
[0125] The starting row number of this query page is the row number corresponding to PRE_PAGE_START_ROWKEY, row 1.
[0126] Get M rows of data starting from the starting row number, for example, get rows 1 to 21 of data.
[0127] If M is less than N+1, it means there is no next page of data;
[0128] If M is equal to N+1, the identifier (ROWKEY) of the last row in the M rows of data is used as the second identifier of the first row of data in the next page. For example, the identifier of the 21st row is used as the second identifier of the first row of data in the next page.
[0129] According to the identifier of the first row of data in the current query page, that is, using the identifier of the first row of data in the current query page as a key, query the stored key-value pairs to obtain the first identifier of the first row of data in the previous page of the query page;
[0130] For example, the identifier of the first row of data in the current query page is the identifier of the 1st row of data, and the key-value pair table is queried to obtain that the first identifier of the first row of data in the previous page is empty.
[0131] Generate a new key-value pair, the key of which is: the identifier of the first row of data in the next page of the query page (i.e. the identifier of the 21st row of data), and the value of which is: the identifier of the first row of data in the query page (i.e. the identifier of the 1st row of data), and update Table 6. At this time, the data in Table 6 remains unchanged.
[0132] In one embodiment, step 102 may be implemented as follows:
[0133] Determine the identifier of the starting row according to the target query instruction and the query parameter;
[0134] The M rows of data are acquired according to the identifier of the starting row and the preset number of rows N.
[0135] Specifically, when obtaining M rows of data, it is necessary to first determine the position of the starting row of the current query page, that is, determine the identifier of the starting row, such as the starting row number or the primary key ROWKEY of the starting row.
[0136] For example, if the target query instruction is the first query instruction, the starting row is determined according to the STARTROW indicated by the target query instruction.
[0137] In one embodiment, if the target query instruction is a previous page query instruction, a next page query instruction, or a page jump query instruction, the identifier of the start row may be determined in the following manner:
[0138] According to the target query instruction, determine the target parameter in the query parameter;
[0139] Identifies the target parameter as the starting row identifier.
[0140] Specifically, according to the target query instruction, the target parameter is determined from at least one parameter included in the query parameters:
[0141] The first identifier of the first row of data on the previous page;
[0142] The second identifier of the first row of data in the next page;
[0143] At least one query page corresponds to a key-value pair, one key-value pair corresponds to one query page, the key of a key-value pair is: the second identifier of the first row of data in the next page of the query page corresponding to the key-value pair, and the value of a key-value pair is: the identifier of the first row of data in the query page corresponding to the key-value pair.
[0144] If the target query instruction is a previous page query instruction, the starting row of the current query page is the first row of data in the previous page, that is, the target parameter is determined to be the first identifier, and the first identifier is used as the identifier of the starting row to find the starting row;
[0145] If the target query instruction is a next page query instruction, the starting row of the current query page is the first row of data in the next page, that is, the target parameter is determined to be the second identifier, and the second identifier is used as the identifier of the starting row to find the starting row;
[0146] If the target query instruction is a page jump query instruction, the identifier of the current query page is determined according to the page jump query instruction, such as the page number of the current query page, and the identifier of the first row of data in the current query page is searched in the query table according to the page number of the current query page. That is, the target parameter is the identifier of the first row of data in the current query page, and the starting row is found according to the identifier of the first row of data.
[0147] For example, if the target query instruction is a previous page query instruction, and the previous query was page 2, then the previous page is page 1, and the starting row of the current query page 1 is the first row of data in the previous page returned by the previous query, that is, row 1. The target parameter is the identifier of row 1, and the starting row of the current query page is row 1.
[0148] If the target query instruction is a next page query instruction, and the previous query was page 2, then the next page is page 3. The starting row of the current query page 3 is the first row of data in the next page returned by the previous query, that is, row 61. The target parameter is the identifier of row 61, and the starting row of the current query page is row 61.
[0149] If the target query instruction is a page jump query instruction, the identifier of the current query page is determined according to the page jump query instruction. For example, if the page number of the current query page is 2, the identifier of the first row of data in the current query page is searched in the query table (Table 7) according to the page number of the current query page. The identifier is the identifier of the 21st row of data, that is, the target parameter is the identifier of the 21st row of data, and the starting row of the current query page is the 21st row.
[0150] Table 7
[0151]
[0152] Further, starting from the starting row, a preset number of N+1 rows of data are queried.
[0153] In the above implementation, the identifier of the starting row is determined according to the target query instruction and query parameters, and M rows of data are obtained, where M is less than or equal to N+1, and N is the preset number of rows, that is, the number of rows of each query page. Each query instruction returns M rows of data, and different query pages are distinguished by the identifier of the first row of data in each page. The paging query is more efficient, and for massive data, the query response speed can be improved. The query parameters are updated according to the target query instruction and M rows of data to support page turning and page jump query functions.
[0154] In one embodiment, updating the query parameters can be implemented in the following manner:
[0155] Update the corresponding relationship according to M rows of data;
[0156] Update the second identifier according to the size of M and the identifier of the last row of data in the M rows of data;
[0157] Using the identifier of the first row of data in the M rows of data as the key, query the target value in the corresponding relationship, and update the first identifier to the target value.
[0158] If M is equal to N+1, the second identifier is updated to the identifier of the last row of data in the M rows of data; or,
[0159] If M is less than N+1, the second flag is updated to empty.
[0160] In one embodiment, updating the corresponding relationship set means updating the key-value pair corresponding to the query page in the query table.
[0161] Specifically, assuming that M rows of data are N+1 rows of data, the extra last row is the first row of data of the next page, and the identifier of the first row of data in the next page is updated, that is, the second identifier is the identifier of the last row of data in the M rows of data, otherwise if M is less than N+1, it means that there is no next page of data, and the identifier of the first row of data in the next page is empty. For example, as shown in Table 7, assuming that the current query page is page 2, rows 21-41 of data are obtained, and the identifier of the first row of data in the next page is updated to the identifier of the 41st row of data.
[0162] The second identifier of the first row of data in the next page of the query page is established in a corresponding relationship with the identifier of the first row of data in the query page (i.e., the identifier of the first row of data in the M rows), that is, as a key-value pair, the key-value pair corresponding to the query page in the query table is updated. For example, assuming that the current query page is page 2, the second identifier of the first row of data in the next page is the identifier of the 41st row of data as the key of the key-value pair, and the identifier of the first row of data in the current query page and the identifier of the 21st row of data are used as the values of the key-value pair to update the query table.
[0163] According to the identifier of the first row of data in the query page, the identifier of the first row of data in the corresponding previous page is searched in the query table; that is, the identifier of the first row of data in the query page is used as the key of the key-value pair, and the value of the key-value pair is queried as the first identifier of the first row of data in the previous page. Assuming that the current query page is page 2, the 21st to 41st rows of data are obtained. Using the identifier of the first row of data in the current query page and the identifier of the 21st row of data as the key, the corresponding target value is searched in the query table, for example, the identifier of the 1st row of data is used as the first identifier.
[0164] In the above implementation, query parameters are updated according to the target query instruction and M rows of data, and different query pages are distinguished by the identifier of the first row of data in each page. The paging query efficiency is high. Moreover, according to the correspondence between the identifiers of the first row of data of adjacent pages included in the query parameters, the first identifier of the first row of data in the previous page and the second identifier of the first row of data in the next page, it is possible to support up and down page turning and page jump query functions, which can improve the query response speed for massive data.
[0165] In one embodiment, as shown in Table 8 below, the target query instruction may further include an identifier SERACH_ID of the query session. For example, this query session is to query startrow-endrow (such as 1-4000) rows of data, perform paging query, and set pagesize, that is, N to 20. When performing paging query, the identifier SERACH_ID of the query session of each page query instruction is the same.
[0166] In the query table, the key of the key-value pair can be obtained according to the identifier of the query session and the second identifier of the first row of data in the next page of the current query page.
[0167] The query session maintenance function can be implemented through the identifier of the query session.
[0168] The target query instruction may further include: a paging cursor CURSOR_ROWKEY, that is, an identifier of a starting row of each query page.
[0169] Table 8
[0170]
[0171] As shown in Table 9 below, the output parameters returned by each query include: the first identifier PRE_PAGE_START_ROWKEY of the first row of data in the previous page, the second identifier NEXT_PAGE_START_ROWKEY of the first row of data in the next page, and the paging cursor CURSOR_ROWKEY.
[0172] If you want to query the previous page: set CURSOR_ROWKEY = PRE_PAGE_START_ROWKEY returned last time;
[0173] Next page query: Set CURSOR_ROWKEY = NEXT_PAGE_START_ROWKEY returned last time.
[0174] Table 9 Output parameters
[0175]
[0176] In one embodiment, if Figure 4 As shown, for the first query:
[0177] Input parameters: Since this is the first query, the input parameter SERACH_ID can be empty, and CURSOR_ROWKEY can also be empty, but the STARTROW and ENDROW of the query range can remain set normally.
[0178] 1. First determine whether the current CURSOR_ROWKEY is empty. If it is empty, continue. Otherwise, set CURSOR_ROWKEY to STARTROW.
[0179] 2. According to the set pagesize (that is, the preset number of rows N), the number of rows returned by the query is set to pagesize+1 in order to obtain the ROWKEY of the next page (that is, NEXT_PAGE_START_ROWKEY).
[0180] 3. According to step 2, query the data of the page and count the total number of rows M returned.
[0181] 4. Determine whether the total number of rows M returned by the request in step 3 is greater than the pagesize of the request parameter. If so, it means that there is more data to follow. Otherwise, there is no subsequent data after the query is requested, and the result can be directly encapsulated and returned.
[0182] 5. If step 4 determines that the current request has subsequent steps, set the current request return parameter NEXT_PAGE_START_ROWKEY to the identifier of the last row of data queried in step 3, and remove the last row of data from the returned result. The last row of data is only for the convenience of counting whether there is subsequent data.
[0183] 6. Determine again whether the CURSOR_ROWKEY in the input parameter is empty. Since this is the first query, enter the first query branch.
[0184] 7. Determine again whether NEXT_PAGE_START_ROWKEY is empty. Since NEXT_PAGE_START_ROWKEY is set as the identifier of the last row of data if there is subsequent data in step 5, NEXT_PAGE_START_ROWKEY is not empty, and go directly to step 8.
[0185] 8. Because it is the first query, the corresponding first SEARCH_ID is generated, and the PRE_PAGE_START_ROWKEY returned by this request is set to empty (because it is the first time, there is no previous page), and SEARCH_ID|NEXT_PAGE_START_ROWKEY is used as ROWKEY. The value of the PRE_PAGE_START_ROWKEY column is: the identifier of the first row of data on the current page, which is written into the query table search_page_info. The search_page_info table is prepared to query the ROWKEY of the first row of data on the previous page when the query is performed next time.
[0186] 9. Combined with steps 5 and 8, the corresponding parameters PRE_PAGE_START_ROWKEY are returned as empty, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY. The CURSOR_ROWKEY returned by this request can be the identifier of the first row of data of the current query page, the identifier of the first row of data in the first page.
[0187] For the previous page query:
[0188] Input parameters: Since this is not the first query, the previous return result includes PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY. Since this is the previous page query, set the CURSOR_ROWKEY of this request to PRE_PAGE_START_ROWKEY, but keep the STARTROW and ENDROW of the query range as normal.
[0189] 1. Determine whether CURSOR_ROWKEY is empty. Since CURSOR_ROWKEY is not empty in this query, set the starting row of the query page STARTROW = CURSOR_ROWKEY.
[0190] 2. According to the set pagesize, the number of rows returned by the query is set to pagesize+1 in order to obtain the ROWKEY of the next page (NEXT_PAGE_START_ROWKEY).
[0191] 3. According to step 2, query the data of the previous page and count the total number of rows M returned.
[0192] 4. Determine whether the total number of rows M returned by the request in step 3 is greater than the pagesize of the request parameter. If so, it means that there is more data to follow. Otherwise, there is no subsequent data after the current query request, and the result can be directly packaged and returned.
[0193] 5. If step 4 determines that the current request has subsequent steps, set the current request return parameter NEXT_PAGE_START_ROWKEY to the identifier of the last row of data queried in step 3, and remove the last row of data from the returned result.
[0194] 6. Determine again whether the CURSOR_ROWKEY in the input parameter is empty and enter the non-first query branch.
[0195] 7. Determine again whether NEXT_PAGE_START_ROWKEY is empty. Since NEXT_PAGE_START_ROWKEY is set if there is subsequent data in step 5, NEXT_PAGE_START_ROWKEY is not empty, and go directly to step 8.
[0196] 8. Because this is not the first query, the search_page_info table is queried to obtain the target value based on SEARCH_ID|CURSOR_ROWKEY (that is, the identifier of the first row of data on the current page) as ROWKEY.
[0197] 9. According to step 8, determine whether the target value is empty. If it is not empty, go to step 10; otherwise, go to step 11. At this time, the returned PRE_PAGE_START_ROWKEY value is empty.
[0198] 10. Assign the target value to the PRE_PAGE_START_ROWKEY value returned by the current request.
[0199] 11. Check whether NEXT_PAGE_START_ROWKEY is empty. If it is empty, return directly. Otherwise, continue to the next step 12.
[0200] 12. Set ROWKEY: SEARCH_ID | NEXT_PAGE_START_ROWKEY; the value of the PRE_PAGE_START_ROWKEY column is: CURSOR_ROWKEY (that is, the identifier of the first row of data in the current page), that is, the identifier of the first row of data in the next page of the current query page is written as a key-value pair into the search_page_info table for use in the next query.
[0201] 13. Combined with steps 5 and 10, the corresponding parameters PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and cursor CURSOR_ROWKEY are returned. The CURSOR_ROWKEY returned by this request is the identifier of the first row of data on the current query page.
[0202] For the next page query:
[0203] Input parameters: Since this is not the first query, the previous return result includes PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY, so set the CURSOR_ROWKEY of this request to NEXT_PAGE_START_ROWKEY, but keep the query range STARTROW and ENDROW as normal. Since the logic of the previous page query is the same as that of the next page query, you only need to pay attention to the assignment of CURSOR_ROWKEY when requesting parameters. The specific process steps are as follows (same as the previous page query):
[0204] 1. Determine whether CURSOR_ROWKEY is empty. Since CURSOR_ROWKEY is not empty in this query, set the starting row STARTROW = CURSOR_ROWKEY.
[0205] 2. According to the set pagesize, the number of rows returned by the query is set to pagesize+1 in order to obtain the ROWKEY of the next page (NEXT_PAGE_START_ROWKEY).
[0206] 3. According to step 2, query the data of the current page and count the total number of rows M returned.
[0207] 4. Determine whether the total number of rows M returned by the request in step 3 is greater than the pagesize of the request parameter. If so, it means that there is more data to follow. Otherwise, there is no subsequent data after the query is requested, and the result can be directly encapsulated and returned.
[0208] 5. If step 4 determines that the current request has subsequent steps, set the current request return parameter NEXT_PAGE_START_ROWKEY to the identifier of the last row of data queried in step 3, and remove the last row of data from the returned result.
[0209] 6. Determine again whether the CURSOR_ROWKEY in the input parameter is empty. If not, enter the non-first query branch.
[0210] 7. Determine again whether NEXT_PAGE_START_ROWKEY is empty. Since NEXT_PAGE_START_ROWKEY is set if there is subsequent data in step 5, NEXT_PAGE_START_ROWKEY is not empty, and go directly to step 8.
[0211] 8. Because this is not the first query, use SEARCH_ID|CURSOR_ROWKEY as ROWKEY to query search_page_info to get the target value.
[0212] 9. According to step 8, determine whether the target value is empty. If it is not empty, go to step 10, otherwise go to step 11.
[0213] 10. Assign the target value to the PRE_PAGE_START_ROWKEY value returned by the current request, that is, use the target value as the identifier of the first row of data in the previous page.
[0214] 11. Check whether NEXT_PAGE_START_ROWKEY is empty. If it is empty, return directly. Otherwise, continue to the next step 12.
[0215] 12. Set ROWKEY: SEARCH_ID|NEXT_PAGE_START_ROWKEY, the value of the PRE_PAGE_START_ROWKEY column is: CURSOR_ROWKEY, and write it into the search_page_info table, that is, the identifier of the first row of data in the next page of the current query page and the identifier of the first row of data in the current query page are written as a key-value pair into the search_page_info table for use in the next query.
[0216] 13. Combined with steps 5 and 10, the corresponding parameters PRE_PAGE_START_ROWKEY, NEXT_PAGE_START_ROWKEY and CURSOR_ROWKEY are returned. The CURSOR_ROWKEY returned by this request is the identifier of the first row of data on the current query page.
[0217] For page-skipping query: you can find the ROWKEY (i.e. CURSOR_ROWKEY) of the first row of data corresponding to the query page from the search_page_info table. If you need to query by page, you can directly assign the ROWKEY of the first row of data corresponding to the page number to CURSOR_ROWKEY and perform the query.
[0218] In this embodiment, paging query is introduced in the Hbase database, M rows of data are obtained through one query, and the query parameters are updated according to the target query instruction and the M rows of data. Different query pages are distinguished by the identifier of the first row of data in each page. The paging query efficiency is high, and according to the correspondence between the identifiers of the first row of data of adjacent pages included in the query parameters, the first identifier of the first row of data in the previous page and the second identifier of the first row of data in the next page, it can support up and down page turning and page jump query functions, which can improve the query response speed for massive data.
[0219] Figure 5 This is a structural diagram of an embodiment of a data query device provided by the present application, such as Figure 5 As shown, the data query device of this embodiment includes:
[0220] An acquisition module 110 is used to acquire a target query instruction;
[0221] The acquisition module 110 is further configured to acquire M rows of data according to the target query instruction, a preset number of rows N, and query parameters, wherein M is less than or equal to N+1, and M and N are integers greater than or equal to zero; the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a correspondence between at least one query page and its respective next page;
[0222] The processing module 111 is used to update the query parameters according to the target query instruction and the M rows of data.
[0223] In a possible implementation, for any of the query pages, the corresponding relationship includes: a corresponding relationship between an identifier of a first row of data in the query page and a second identifier of a first row of data in a next page of the query page.
[0224] In a possible implementation, the correspondence is represented by a key-value pair, the key of the key-value pair is: the second identifier of the first row of data in the next page of the query page, and the value of the key-value pair is: the identifier of the first row of data in the query page.
[0225] In a possible implementation, the acquisition module 110 is specifically configured to:
[0226] Determine the identifier of the starting row according to the target query instruction and the query parameter;
[0227] The M rows of data are acquired according to the identifier of the starting row and the preset number of rows N.
[0228] In a possible implementation, the target query instruction is a previous page query instruction, a next page query instruction, or a page jump query instruction; the acquisition module 110 is specifically used to:
[0229] According to the target query instruction, determining a target parameter in the query parameters;
[0230] The target parameter is determined as an identifier of a starting row.
[0231] In a possible implementation, the acquisition module 110 is specifically configured to:
[0232] If the type of the target query instruction is a previous page query instruction, the target parameter is the first identifier; or,
[0233] If the type of the target query instruction is a next page query instruction, the target parameter is the second identifier;
[0234] If the type of the target query instruction is a page jump query instruction, the target parameter is an identifier of the first row of data in the query page.
[0235] In a possible implementation, the processing module 111 is specifically configured to:
[0236] According to the M rows of data, updating the corresponding relationship;
[0237] Update the second identifier according to the size of M and the identifier of the last row of data in the M rows of data;
[0238] Using the identifier of the first row of data in the M rows of data as a key, querying the target value in the corresponding relationship, and updating the first identifier to the target value.
[0239] In a possible implementation, the processing module 111 is specifically configured to:
[0240] If the M is equal to the N+1, then the second identifier is updated to the identifier of the last row of data in the M rows of data; or,
[0241] If the M is less than the N+1, the second flag is updated to empty.
[0242] The device of this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0243] Figure 6 The structure diagram of the electronic device embodiment provided in this application is as follows: Figure 6 As shown, the electronic device includes:
[0244] A processor 210 , and a memory 211 for storing executable instructions of the processor 210 .
[0245] Optionally, it may also include: a communication interface 212 for implementing communication with other devices.
[0246] The above components may communicate via one or more buses.
[0247] Among them, the processor 210 is configured to execute the corresponding method in the aforementioned method embodiment by executing the executable instructions. The specific implementation process can be found in the aforementioned method embodiment and will not be repeated here.
[0248] A computer-readable storage medium is also provided in an embodiment of the present application, on which a computer program is stored. When the computer program is executed by a processor, the corresponding method in the aforementioned method embodiment is implemented. The specific implementation process can be found in the aforementioned method embodiment. The implementation principle and technical effects are similar and will not be repeated here.
[0249] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0250] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data query method, characterized in that: include: Get the target query instruction; According to the target query instruction, the preset number of rows N and the query parameters, M rows of data are obtained, wherein M is less than or equal to N+1, and M and N are integers greater than or equal to zero respectively; the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a corresponding relationship between at least one query page and its respective next page; the preset number of rows N includes a preset number of rows of each page; According to the target query instruction and the M rows of data, the query parameters are updated, specifically: according to the M rows of data, the corresponding relationship is updated; according to the size of M and the identifier of the last row of data in the M rows of data, the second identifier is updated; using the identifier of the first row of data in the M rows of data as a key, the target value is searched in the corresponding relationship, and the first identifier is updated to the target value; Wherein, for any of the query pages, the corresponding relationship includes: a corresponding relationship between an identifier of the first row of data in the query page and a second identifier of the first row of data in a next page of the query page; The corresponding relationship is represented by a key-value pair, the key of the key-value pair is: the second identifier of the first row of data in the next page of the query page, and the value of the key-value pair is: the identifier of the first row of data in the query page; Wherein, the method further comprises: Display the acquired data. If M is N+1, display the first N rows of data among the M rows of data. If M is less than N+1, display M rows of data. Wherein, for the first query, the input parameter SERACH_ID is empty, CURSOR_ROWKEY is empty, STARTROW and ENDROW remain in normal settings, and the method further includes: Determine whether the current CURSOR_ROWKEY is empty. If it is empty, continue. Otherwise, set CURSOR_ROWKEY to STARTROW. The number of rows returned by the query is set to N+1 according to the preset number of rows N, so as to obtain the ROWKEY of the next page, which is recorded as NEXT_PAGE_START_ROWKEY, query the data of the page, and count the total number of rows returned M; Determine whether the total number of rows M returned by the request is greater than the request parameter N. If not, directly encapsulate the result and return it. If so, set the NEXT_PAGE_START_ROWKEY parameter returned by the current request to the identifier of the last row of the queried data, and remove the last row of data from the returned result. The last row of data is only for the convenience of counting whether there is subsequent data. Determine again whether the CURSOR_ROWKEY in the input parameter is empty, enter the branch of the first query, determine again whether NEXT_PAGE_START_ROWKEY is empty, set NEXT_PAGE_START_ROWKEY as the identifier of the last row of data, generate the corresponding first SEARCH_ID, set the PRE_PAGE_START_ROWKEY returned by the request to empty, use SEARCH_ID|NEXT_PAGE_START_ROWKEY as ROWKEY, and the value of the PRE_PAGE_START_ROWKEY column is: the identifier of the first row of data on the current page, which is written to the query table search_page_info. The search_page_info table is used to prepare for the next query to query the ROWKEY of the first row of data on the previous page.
2. The method according to claim 1, characterized in that According to the target query instruction and query parameters, M rows of data are obtained, including: Determine the identifier of the starting row according to the target query instruction and the query parameter; The M rows of data are acquired according to the identifier of the starting row and the preset number of rows N.
3. The method according to claim 2, characterized in that The target query instruction is a previous page query instruction, a next page query instruction or a page jump query instruction; Determining the identifier of the starting row according to the target query instruction includes: According to the target query instruction, determining a target parameter in the query parameters; The target parameter is determined as an identifier of a starting row.
4. The method according to claim 3, characterized in that: Determining a target parameter in the query parameter according to the target query instruction includes: If the type of the target query instruction is a previous page query instruction, the target parameter is the first identifier; or, If the type of the target query instruction is a next page query instruction, the target parameter is the second identifier; If the type of the target query instruction is a page jump query instruction, the target parameter is an identifier of the first row of data in the query page.
5. The method according to claim 1, characterized in that Updating the second identifier according to the size of M and the identifier of the next row of data in the M rows of data includes: If the M is equal to the N+1, then the second identifier is updated to the identifier of the last row of data in the M rows of data; or, If the M is less than the N+1, the second flag is updated to empty.
6. A data query device, characterized in that: include: An acquisition module, used to acquire a target query instruction; The acquisition module is further used to acquire M rows of data according to the target query instruction, the preset number of rows N and the query parameters, wherein M is less than or equal to N+1, and M and N are integers greater than or equal to zero respectively; the query parameters include: a first identifier of the first row of data in the previous page, a second identifier of the first row of data in the next page, and a corresponding relationship between at least one query page and its respective next page; the preset number of rows N includes a preset number of rows of each page; a processing module, configured to update the query parameter according to the target query instruction and the M rows of data, specifically: updating the corresponding relationship according to the M rows of data; updating the second identifier according to the size of M and the identifier of the last row of data in the M rows of data; using the identifier of the first row of data in the M rows of data as a key, querying a target value in the corresponding relationship, and updating the first identifier to the target value; Wherein, for any of the query pages, the corresponding relationship includes: a corresponding relationship between an identifier of the first row of data in the query page and a second identifier of the first row of data in a next page of the query page; The corresponding relationship is represented by a key-value pair, the key of the key-value pair is: the second identifier of the first row of data in the next page of the query page, and the value of the key-value pair is: the identifier of the first row of data in the query page; The device is also specifically used for: Display the acquired data. If M is N+1, display the first N rows of data among the M rows of data. If M is less than N+1, display M rows of data. Wherein, for the first query, the input parameter SERACH_ID is empty, CURSOR_ROWKEY is empty, STARTROW and ENDROW remain in normal settings, and the device is further specifically used for: Determine whether the current CURSOR_ROWKEY is empty. If it is empty, continue. Otherwise, set CURSOR_ROWKEY to STARTROW. The number of rows returned by the query is set to N+1 according to the preset number of rows N, so as to obtain the ROWKEY of the next page, which is recorded as NEXT_PAGE_START_ROWKEY, query the data of the page, and count the total number of rows returned M; Determine whether the total number of rows M returned by the request is greater than the request parameter N. If not, directly encapsulate the result and return it. If so, set the NEXT_PAGE_START_ROWKEY parameter returned by the current request to the identifier of the last row of the queried data, and remove the last row of data from the returned result. The last row of data is only for the convenience of counting whether there is subsequent data. Determine again whether the CURSOR_ROWKEY in the input parameter is empty, enter the branch of the first query, determine again whether NEXT_PAGE_START_ROWKEY is empty, set NEXT_PAGE_START_ROWKEY as the identifier of the last row of data, generate the corresponding first SEARCH_ID, set the PRE_PAGE_START_ROWKEY returned by the request to empty, use SEARCH_ID|NEXT_PAGE_START_ROWKEY as ROWKEY, and the value of the PRE_PAGE_START_ROWKEY column is: the identifier of the first row of data on the current page, which is written to the query table search_page_info. The search_page_info table is used to prepare for the next query to query the ROWKEY of the first row of data on the previous page.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 6 by executing the executable instructions.
Citation Information
Patent Citations
Data paging inquiry method based on descending order storage
CN105045932A
HBase row paging method, server and computer readable storage medium
CN107943981A