HBase-based data paging query method and device, and electronic equipment

By determining the interval number and order between the starting page and the target page in HBase, and traversing the data pages to obtain the upper and lower page boundaries of the result page, the problem of low efficiency in HBase pagination queries is solved, achieving efficient pagination queries and result page data control.

CN116881283BActive Publication Date: 2026-01-27CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310858485.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-12
Publication Date
2026-01-27
Estimated Expiration
2043-07-12

AI Technical Summary

Technical Problem

HBase's pagination query function is inefficient, and the data in the query result page can easily exceed the page size, affecting the query effect.

Method used

By obtaining the query range of the data pages, the starting page and target page of the query are determined, the number of interval pages and the query order are calculated, the data pages are traversed to obtain the upper and lower page boundaries of the result pages, and the data query results are generated. It supports forward or backward pagination and page skipping queries.

Benefits of technology

It improves the efficiency of HBase pagination queries, ensures that the data in the query result page does not exceed the page size, and reduces the size of the query data when approaching the target page.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116881283B_ABST
    Figure CN116881283B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a kind of based on HBase's data paging query method and device, electronic equipment, belong to artificial intelligence technical field.The method comprises: obtaining the query range of data page;According to query range, determine query starting page and query target page;According to query starting page and query target page, the interval page number and query order between query starting page and query target page are calculated;According to interval page number and query order, data page is traversed, and the data page obtained by query is regarded as result page, to obtain the upper and lower page boundary of result page;Based on result page and the upper and lower page boundary of result page, generate data query result, based on this, when the nearby page of query target page, using the upper and lower boundary values returned by result page and page code, can effectively reduce the query data scale when obtaining adjacent target page, to improve HBase paging query efficiency, and the result page data returned by query will not exceed page size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a data pagination query method and apparatus, and electronic device based on HBase. Background Technology

[0002] HBase is an important member of the Apache Hadoop ecosystem. It supports massive data storage, high-speed data read and write, and has good scalability, making it one of the most widely used NoSQL databases. HBase supports multi-condition queries, but compared with traditional databases, it is still less flexible and feature-rich, especially in terms of pagination query functionality.

[0003] Currently, common pagination functionality involves directly traversing from the first page to the target page. Each query requires starting from the beginning, resulting in significant redundant computation and low efficiency. Furthermore, existing technologies, such as PageFilter, implement a filter interface that restricts query results to a specific page size. If the number of rows passed to the filter exceeds the given page size, the returned result page will exceed the page size, thus affecting the implementation of pagination queries. Summary of the Invention

[0004] The main objective of this application is to propose a data pagination query method, apparatus, and electronic device based on HBase, which can improve pagination query efficiency and ensure that the data returned by the query does not exceed the page size.

[0005] To achieve the above objectives, a first aspect of this application proposes a data pagination query method based on HBase, the method comprising:

[0006] Get the query range of the data page;

[0007] The query start page and query target page are determined based on the query scope;

[0008] Calculate the number of pages between the query start page and the query target page, and the query order;

[0009] The data pages are traversed according to the interval page number and the query order, and the data pages obtained by the query are used as result pages to obtain the upper and lower page boundaries of the result pages;

[0010] Data query results are generated based on the result page and the page boundaries above and below the result page.

[0011] In some embodiments, the query range for obtaining the data page includes:

[0012] The data pages are scanned using an HBase scanner;

[0013] Obtain the constraints for the data page query input by the user;

[0014] Boundary processing is applied to the constraints to obtain the query range of the data page.

[0015] In some embodiments, the step of traversing the data pages according to the interval page number and the query order to obtain the data query results of the result page includes:

[0016] The query direction identifier is determined according to the query order. The direction identifier includes a forward identifier and a reverse identifier. The forward identifier is used to identify the forward query order, and the reverse identifier is used to identify the reverse query order.

[0017] The data pages are traversed according to the direction identifier to obtain the data query results of the result page, wherein the number of traversals is equal to the number of page intervals.

[0018] In some embodiments, traversing the data pages according to the direction identifier to obtain the data query results of the result page includes:

[0019] Determine the starting row key of the query start page and the ending row key of the query target page;

[0020] When the direction identifier is a positive identifier, the data pages are traversed from the starting row key of the query start page to the ending row key of the query target page;

[0021] When the direction identifier is reversed, the data pages are traversed from the end row key of the target page to the start row key of the starting page.

[0022] In some embodiments, when the direction identifier is a positive identifier, traversing the data pages from the start row key of the query start page to the end row key of the query target page includes:

[0023] Retrieve the last row key string of the dictionary in ascending order from the current data page being traversed;

[0024] The starting line key for the next page is obtained by replacing the last character of the line key string with a character whose ASCII code is increased by 1.

[0025] Based on the next page start row key, traverse the data pages one by one from the start row key of the query start page to the end row key of the query target page.

[0026] In some embodiments, when the direction identifier is a reverse identifier, traversing the data pages from the end row key of the query target page to the start row key of the query start page includes:

[0027] Get the last row key string of the dictionary in reverse order in the current page traversal;

[0028] The character obtained by subtracting 1 from the last character of the line key string is the starting line key of the next page;

[0029] Based on the next page start row key, traverse the data pages one by one from the end row key of the target page to the start row key of the starting page.

[0030] In some embodiments, the method further includes:

[0031] Sort the result pages in ascending dictionary order;

[0032] Obtain the row key identifier of the result page, the upper and lower page boundaries of the result page, the data of the current page of the result page, and the page number identifier of the result page to generate data query results;

[0033] The data query results are returned to the calling client so that the calling client can perform data pagination queries based on the data query results.

[0034] To achieve the above objectives, a second aspect of this application provides a data pagination query apparatus based on HBase, the apparatus comprising:

[0035] The retrieval module is used to retrieve the query range of a data page;

[0036] The determination module is used to determine the query start page and query target page based on the query range;

[0037] The calculation module is used to calculate the number of pages between the query start page and the query target page and the query order based on the query start page and the query target page;

[0038] The traversal module is used to traverse the data pages according to the interval page number and the query order, and take the queried data pages as result pages to obtain the upper and lower page boundaries of the result pages;

[0039] The generation module is used to generate data query results based on the result page and the upper and lower page boundaries of the result page.

[0040] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.

[0041] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.

[0042] This application proposes a data pagination query method, apparatus, and electronic device based on HBase, which obtains the query range of data pages; determines the query start page and query target page based on the query range; calculates the interval number of pages and query order between the query start page and query target page based on the query start page and query target page; traverses the data pages according to the interval number of pages and query order, and uses the queried data pages as result pages to obtain the result pages and the upper and lower page boundaries of the result pages; and generates data query results based on the result pages and the upper and lower page boundaries of the result pages. Based on this, this application determines the query start page and query target page according to the query range of the acquired data pages, thereby calculating the number of pages between the query start page and the query target page and the query order. Then, by traversing the data pages according to the number of pages between the query start page and the query order, the result page and the upper and lower page boundaries of the result page can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping query functions, and effectively reduce the query data scale when obtaining adjacent target pages, thereby improving the efficiency of HBase pagination query, and the data of the result page returned by the query will not exceed the page size. Attached Figure Description

[0043] Figure 1 This is a flowchart of the HBase-based data pagination query method provided in the embodiments of this application;

[0044] Figure 2 yes Figure 1 The flowchart of step S101 in the text;

[0045] Figure 3 yes Figure 1 The flowchart of step S104 in the process;

[0046] Figure 4 yes Figure 3 The flowchart of step S302 in the text;

[0047] Figure 5 yes Figure 4 The flowchart of step S402 in the document;

[0048] Figure 6 yes Figure 4 The flowchart of step S403 in the process;

[0049] Figure 7This is a flowchart of steps S701 to S704 in the embodiments of this application;

[0050] Figure 8 This is a flowchart of a data pagination query method based on HBase provided in another embodiment of this application;

[0051] Figure 9 This is a schematic diagram of the structure of the HBase-based data pagination query device provided in the embodiments of this application;

[0052] Figure 10 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0054] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0056] First, let's analyze some of the terms used in this application:

[0057] Artificial intelligence (AI) is a new branch of computer science that studies, develops, and applies theories, methods, technologies, and systems to simulate, extend, and expand human intelligence. It aims to understand the essence of intelligence and produce intelligent machines that can react in a way similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thought. Furthermore, AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to achieve optimal results.

[0058] HBase is a distributed, column-oriented, open-source database. The technology originates from Fay Chang's Google paper, "Bigtable: A Distributed Storage System for Structured Data." Just as Bigtable utilizes the distributed data storage provided by the Google File System, HBase offers similar capabilities on top of Hadoop. HBase is a sub-project of the Apache Hadoop project. Unlike typical relational databases, HBase is suitable for storing unstructured data.

[0059] Apache Hadoop is a framework for running applications on large clusters built from general-purpose hardware. It implements the Map / Reduce programming paradigm, where computational tasks are broken down into smaller chunks and run multiple times across different nodes. In addition, it provides a distributed file system (HDFS) where data is stored on compute nodes to provide extremely high aggregate bandwidth across data centers.

[0060] NoSQL: A general term for non-relational databases. With the rise of Web 2.0 websites, traditional relational databases have become increasingly inadequate in handling these websites, especially large-scale and high-concurrency dynamic SNS-type websites, encountering many insurmountable problems. Non-relational databases, due to their inherent characteristics, have experienced rapid development. NoSQL databases were created to address the challenges posed by large-scale datasets with diverse data types, particularly the difficulties of big data applications.

[0061] RowKey: In HBase, a RowKey uniquely identifies a row record. When querying in HBase, there are several ways to use it: using the `get` method, specifying the RowKey to retrieve a unique record; or using the `scan` method, setting the `startRowKey` and `endRowKey` parameters for range matching; or using a full table scan, which directly scans all rows in the entire table.

[0062] Paging is a memory management technique in operating systems that allows a computer's main memory to access data stored in secondary storage. The operating system partitions data in secondary storage (usually a disk) into fixed-size blocks called "pages." When not needed, pages are moved from main memory (usually RAM) to secondary storage; when needed, the data is retrieved and loaded back into main memory. Compared to segmentation, paging allows memory to store data in non-contiguous blocks to maintain the order of the file system. A page is the smallest unit of data transfer between disk and RAM.

[0063] Lexicographical order: In mathematics, dictionary or lexicographical order (also known as word order, alphabetical order, or alphabetical order) is a method of arranging words in alphabetical order. This generalization primarily refers to defining the overall order of the sequence of elements (often called words in computer science) of an ordered, fully ordered set (often called the alphabet). For permutations of the numbers 1, 2, 3...n, the order of different permutations is determined by comparing the corresponding numbers one by one from left to right. For example, for the permutations of the five numbers 12354 and 12345, permutation 12345 comes first, and permutation 12354 comes last. According to this rule, the earliest permutation of the five numbers is 12345, and the latest is 54321.

[0064] Based on this, embodiments of this application provide a data pagination query method, apparatus, and electronic device based on HBase. The method involves: obtaining the query range of a data page; determining the query start page and query target page based on the query range; calculating the interval number of pages and the query order between the query start page and the query target page based on the query start page and the query target page; traversing the data pages according to the interval number of pages and the query order; using the queried data pages as result pages to obtain the result pages and their upper and lower page boundaries; and generating data query results based on the result pages and their upper and lower page boundaries. Based on this, this application determines the query start page and query target page according to the query range of the acquired data pages, thereby calculating the number of pages between the query start page and the query target page and the query order. Then, by traversing the data pages according to the number of pages between the query start page and the query order, the result page and the upper and lower page boundaries of the result page can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping query functions, and effectively reduce the query data scale when obtaining adjacent target pages, thereby improving the efficiency of HBase pagination query, and the data of the result page returned by the query will not exceed the page size.

[0065] The data pagination query method, apparatus, and electronic device based on HBase provided in this application are specifically described through the following embodiments. First, the data pagination query method based on HBase in this application is described.

[0066] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.

[0067] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0068] The HBase-based data pagination query method provided in this application relates to the field of artificial intelligence technology. This HBase-based data pagination query method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the HBase-based data pagination query method, but is not limited to the above forms.

[0069] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0070] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.

[0071] Figure 1 This is an optional flowchart of the HBase-based data pagination query method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S101 to S105.

[0072] Step S101: Obtain the query range of the data page;

[0073] Step S102: Determine the starting page and target page of the query based on the query range;

[0074] Step S103: Calculate the number of pages between the query start page and the query target page and the query order based on the query start page and the query target page;

[0075] Step S104: Traverse the data pages according to the interval page number and query order, and take the data pages obtained by the query as result pages to obtain the result pages and the upper and lower page boundaries of the result pages;

[0076] Step S105: Generate data query results based on the result page and the upper and lower page boundaries of the result page.

[0077] In step S101 of some embodiments, the data page can be scanned using an HBase scanner to obtain the user-input constraints for querying the data page, and boundary processing can be performed on the constraints to obtain the query range of the data page. For the HBase scanner, HBASE_CLIENT.newScanner in version org.hbase:asynchbase:1.8.2 can be used to implement a simple range query function.

[0078] In step S102 of some embodiments, the query start page and query target page are determined based on the query range of the data pages. The query start page is the data page from which the query begins, and the query target page is the data page to be queried. Data pages between the query start page and the query target page fall within the scope of this query.

[0079] In step S103 of some embodiments, the interval page number and query order between the query start page and the query target page are calculated based on the query start page and the query target page. For example, the interval page number intervalPageIndex can be calculated based on the query start page index startPageIndex and the query target page index queryPageIndex. It is also checked whether there is a reverse query flag reverseFlag. A forward query is a sequential query starting from the start row key startRowKey and proceeding to the end row key endRowKey. A reverse query is a reverse query starting from the end row key endRowKey and proceeding back to the start row key startRowKey. Here, the start row key startRowKey and end row key endRowKey support fuzzy matching. Based on the constraints and the forward and reverse flags, the interval page number intervalPageIndex traversal query is performed. Each traversal query requires updating the start row key startRowKey, while the end row key endRowKey remains unchanged, temporarily identified as the next page start row key nextPageStartRowKey. For forward queries, the nextPageStartRowKey is calculated by retrieving the rowKey string, which is the last row key of the dictionary in the current traversal of the page, and replacing the last character of the rowKey string with a character whose ASCII code is increased by 1. For reverse queries, the nextPageStartRowKey is calculated by retrieving the rowKey string, which is the last row key of the dictionary in the current traversal of the page, and decreasing the last character of the rowKey string by 1.

[0080] In step S104 of some embodiments, data pages are traversed according to the interval page number and query order, and the queried data pages are used as result pages to obtain the result pages and their upper and lower page boundaries. After retrieving the corresponding page data, if it is a reverse query, the query results need to be sorted in ascending lexicographical order. Then, the minimum and maximum lexicographical row keys in the page data are obtained respectively. The last character of the minimum lexicographical row key string (rowKey) is subtracted by 1 to obtain the maximum boundary of the previous page (prePageEndRowKey); the last character of the maximum lexicographical row key string (rowKey) is incremented by 1 to obtain the minimum boundary of the next page (nextPageStartRowKey).

[0081] In step S105 of some embodiments, data query results are generated based on the result page and the page boundaries before and after the result page. The row key ID of the result page, the maximum boundary prePageEndRowKey of the previous page of the result page, the minimum boundary nextPageStartRowKey of the next page of the result page, the data retrieved on this page, and the result page identifier pageIndex are returned to the calling client.

[0082] To address the scenario where web front-end users need to click to query target pages and nearby pages, this application proposes an HBase pagination query solution. When querying nearby pages of a target page, it utilizes the upper and lower boundary values ​​and page number returned by the target page to support forward or backward pagination and page skipping queries. This effectively reduces the query data size when retrieving adjacent pages, improves HBase's pagination and page skipping query capabilities, and ensures that the returned result page data does not exceed the page size. Furthermore, if the target page does not exist, it will also return the last retrieved data page and page number to the caller, facilitating the caller to re-evaluate and correct pagination parameters.

[0083] Steps S101 to S105 as shown in the embodiments of this application involve: obtaining the query range of the data page; determining the query start page and query target page based on the query range; calculating the interval page number and query order between the query start page and query target page based on the query start page and query target page; traversing the data page according to the interval page number and query order; using the queried data page as the result page to obtain the result page and the upper and lower page boundaries of the result page; and generating the data query result based on the result page and the upper and lower page boundaries of the result page. Based on this, this application determines the query start page and query target page according to the query range of the acquired data pages, thereby calculating the number of pages between the query start page and the query target page and the query order. Then, by traversing the data pages according to the number of pages between the query start page and the query order, the result page and the upper and lower page boundaries of the result page can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping query functions, and effectively reduce the query data scale when obtaining adjacent target pages, thereby improving the efficiency of HBase pagination query, and the data of the result page returned by the query will not exceed the page size.

[0084] Please see Figure 2 In some embodiments, step S101 may include, but is not limited to, steps S201 to S203:

[0085] Step S201: Scan the data pages using the HBase scanner;

[0086] Step S202: Obtain the constraints for the data page query input by the user;

[0087] Step S203: Perform boundary processing on the constraints to obtain the query range of the data page.

[0088] In some embodiments, HBase can use the HBase Scanner when scanning data. The scanner is obtained by calling `getScanner(scan)`. The scanner can be configured with scan start and end points and constraints to query data pages. It's important to note that HBase's data organization is the cornerstone of its high-performance insertion and retrieval. Logically, HBase rows are sorted in ascending lexicographical order by the row key (RowKey). The RowKey is analogous to a primary key in a relational database like MySQL; it is unique, non-null, and acts as a primary key index during queries and insertions.

[0089] In some embodiments, users can input constraints according to the actual needs of the data page query, but appropriate boundary handling is required for the constraints. The constraints are constraints on various parameters of the queried data page. For example, the specific constraints are as follows:

[0090] *Parameter table @param table: Not null.

[0091] *Identifier @param id: Not null, rowKey or a common prefix of rowKey.

[0092] *Starting row key @param startRowKey: Not null. For a forward lookup, startRowKey = startRowKey (minimum value); for a reverse lookup, startRowKey = startRowKey + '~' (maximum value).

[0093] *End row key @param endRowKey: endRowKey can be null or not null. If null, the search proceeds lexicographically forward from startRowKey (endRowKey = '~') or backward (endRowKey = '*'); if not null, the search proceeds lexicographically forward from startRowKey up to endRowKey = endRowKey + '~', or backward up to endRowKey.

[0094] *Parameter family @param family: When null, the default is 'data'.

[0095] * Qualifier list @param qualifierList: If null, it will search all qualifiers by default.

[0096] *Page size @param pageSize: When null or <= 0, set to the default value of 10.

[0097] *Starting Page Index @param startPageIndex: Indicates the page number from which the query begins, as bound to startRowKey in the previously returned HBasePageData. If null or <= 0, the default value of 0 is used, meaning the query starts from the page preceding the first page (page 0 if it doesn't exist).

[0098] *Query page index @param queryPageIndex: When null or <= 0, set to the default value of 1, indicating that the query starts from the first page.

[0099] By applying the above constraints to the boundary conditions, the query range of the data page can be obtained.

[0100] Please see Figure 3 In some embodiments, step S104 may include, but is not limited to, steps S301 to S302:

[0101] Step S301: Determine the query direction identifier according to the query order. The direction identifier includes a forward identifier and a reverse identifier. The forward identifier is used to identify the forward query order, and the reverse identifier is used to identify the reverse query order.

[0102] Step S302: Traverse the data pages according to the direction identifier to query the result page, the maximum boundary of the previous page of the result page, and the minimum boundary of the next page of the result page, wherein the number of traversals is equal to the number of page intervals.

[0103] In some embodiments, the query order includes a forward query order and a reverse query order. In the case of a forward query, the query direction identifier is a forward identifier, which is used to identify the forward query order; in the case of a reverse query, the query direction identifier is a reverse identifier, which is used to identify the reverse query order. Data pages are traversed according to the direction identifier. In a forward query, the query proceeds sequentially from the start row key `startRowKey` to the end row key `endRowKey`. In a reverse query, the query proceeds in reverse order from the end row key `endRowKey` to the start row key `startRowKey`. Based on the constraints and the forward and reverse identifiers, the query is performed at intervals of `intervalPageIndex` times. After retrieving the corresponding page data, if it is a reverse query, the results need to be sorted lexicographically in ascending order, and then the minimum and maximum lexicographical row keys `rowKey` of the page data are obtained. The last character of the minimum lexicographical row key string `rowKey` is decremented by 1 to obtain the maximum boundary of the previous page `prePageEndRowKey`; the last character of the maximum lexicographical row Key string is incremented by 1 to obtain the minimum boundary of the next page `nextPageStartRowKey`. The maximum boundary of the previous page is the boundary of the last line of the previous page, and the minimum boundary of the next page is the boundary of the first line of the next page.

[0104] Please see Figure 4 In some embodiments, step S302 may include, but is not limited to, steps S401 to S403:

[0105] Step S401: Determine the starting row key of the query start page and the ending row key of the query target page;

[0106] Step S402: When the direction indicator is positive, traverse the data pages from the starting row key of the query start page to the ending row key of the query target page.

[0107] Step S403: When the direction indicator is reversed, traverse the data pages from the end row key of the target page to the start row key of the starting page.

[0108] In some embodiments, the interval page number `intervalPageIndex` can be calculated based on the two parameters: the starting page index `startPageIndex` and the target page index `queryPageIndex`. It also checks for a reverse query flag `reverseFlag`. A forward query proceeds sequentially from the starting row key `startRowKey` to the ending row key `endRowKey`. A reverse query proceeds backwards from the ending row key `endRowKey` back to the starting row key `startRowKey`. Fuzzy matching is supported for the starting and ending row keys `startRowKey`. Based on the constraints and the forward / reverse flags, the interval page number `intervalPageIndex` traversal queries are performed. Each traversal query requires updating the starting row key `startRowKey`, while the ending row key `endRowKey` remains unchanged; it is temporarily marked as the next page's starting row key `nextPageStartRowKey`.

[0109] Please see Figure 5 In some embodiments, step S402 may include, but is not limited to, steps S501 to S503:

[0110] Step S501: Obtain the last row key string of the dictionary's ascending row data in this traversal of the data page;

[0111] Step S502: Replace the last character of the line key string with a character whose ASCII code is increased by 1 to obtain the starting line key of the next page;

[0112] Step S503: Traverse the data pages one by one from the starting row key of the query start page to the ending row key of the query target page, based on the starting row key of the next page.

[0113] In some embodiments, the last row key string of the dictionary's ascending row data in the current traversal of the data page is obtained. For forward queries, the next page start row key (nextPageStartRowKey) is calculated by obtaining the last row key string (rowKey) of the dictionary's ascending row data in the current traversal of the page, and replacing the last character of the row key string with a character whose ASCII code is increased by 1. Based on the next page start row key, the data pages are traversed page by page from the start row key of the query starting page to the end row key of the query target page.

[0114] Please see Figure 6 In some embodiments, step S403 may include, but is not limited to, steps S601 to S603:

[0115] Step S601: Obtain the last row key string of the dictionary in reverse order in this page traversal;

[0116] Step S602: Subtract 1 from the last character of the line key string to obtain the starting line key of the next page;

[0117] Step S603: Traverse the data pages one by one from the end row key of the target page to the start row key of the starting page, based on the start row key of the next page.

[0118] In some embodiments of this application, the last row key string of the dictionary's reverse-order row data in the current traversal page is obtained. For reverse queries, the next page start row key (nextPageStartRowKey) is calculated by obtaining the last row key string (rowKey) of the dictionary's reverse-order row data in the current traversal page and decrementing the last character of the row key string by 1. Based on the next page start row key, the data pages are traversed page by page from the end row key of the target query page to the start row key of the query starting page.

[0119] Please see Figure 7 In some embodiments, the method may also include, but is not limited to, steps S701 to S703:

[0120] Step S701: Sort the result page in ascending dictionary order;

[0121] Step S702: Obtain the row key identifier of the result page, the upper and lower page boundaries of the result page, the data of the current page of the result page, and the page number identifier of the result page to generate data query results;

[0122] Step S703: Return the data query results to the calling end so that the calling end can perform data pagination query based on the data query results.

[0123] In some embodiments of this application, after retrieving the corresponding page data, if it is a reverse query, the retrieved results need to be sorted lexicographically in ascending order. Then, the minimum lexicographical index `rowKey` and the maximum lexicographical index `rowKey` of the page data are obtained respectively. The last character of the minimum lexicographical index `rowKey` string is subtracted by 1 to obtain the maximum boundary `prePageEndRowKey` of the previous page; the last character of the maximum lexicographical index `rowKey` string is incremented by 1 to obtain the minimum boundary `nextPageStartRowKey` of the next page. The row key `id`, the maximum boundary `prePageEndRowKey` of the previous page, the minimum boundary `nextPageStartRowKey` of the next page, the retrieved page data, and the result page identifier `pageIndex` are returned to the calling client. If the target page cannot be found, the maximum page that can be retrieved is returned to the calling client to inform the calling client that the target page queried according to the constraints does not exist and to reset the constraints. The calling end can determine whether the target page has been found based on the returned results. Then, near the returned result page, it can perform a forward or backward page jump query based on the current page number of the result page, the maximum boundary `prePageEndRowKey` of the previous page, and the minimum boundary `nextPageStartRowKey` of the next page, avoiding having to start querying the target page near the result page from scratch. Based on this, for the scenario of clicking to query the target page and nearby pages on the web front-end, this application proposes an HBase-based pagination query method. When querying nearby pages of the target page, it utilizes the upper and lower boundary values ​​and page number returned by the target page to support forward or backward pagination and page jump queries. This effectively reduces the query data size when retrieving adjacent pages, improves the pagination and page jump query functionality of HBase, and ensures that the returned result page data does not exceed the page size. Furthermore, if the target page does not exist, it will also return the last retrieved data page and its page number to the caller, facilitating the caller to re-evaluate and correct the pagination parameters.

[0124] The HBase-based data pagination query method of this application is further described below with reference to the accompanying drawings and specific embodiments.

[0125] Please see Figure 8 For HBase scanners, you can use HBASE_CLIENT.newScanner from version org.hbase:asynchbase:1.8.2 to implement a simple range query function. The user inputs constraints, and appropriate boundary handling is applied to these constraints. The specific constraints are as follows:

[0126] *Parameter table @param table: Not null.

[0127] *Identifier @param id: Not null, rowKey or a common prefix of rowKey.

[0128] *Starting row key @param startRowKey: Not null. For a forward lookup, startRowKey = startRowKey (minimum value); for a reverse lookup, startRowKey = startRowKey + '~' (maximum value).

[0129] *End row key @param endRowKey: endRowKey can be null or not null. If null, the search proceeds lexicographically forward from startRowKey (endRowKey = '~') or backward (endRowKey = '*'); if not null, the search proceeds lexicographically forward from startRowKey up to endRowKey = endRowKey + '~', or backward up to endRowKey.

[0130] *Parameter family @param family: When null, the default is 'data'.

[0131] * Qualifier list @param qualifierList: If null, it will search all qualifiers by default.

[0132] *Page size @param pageSize: When null or <= 0, set to the default value of 10.

[0133] *Starting Page Index @param startPageIndex: Indicates the page number from which the query begins, as bound to startRowKey in the previously returned HBasePageData. If null or <= 0, the default value of 0 is used, meaning the query starts from the page preceding the first page (page 0 if it doesn't exist).

[0134] *Query page index @param queryPageIndex: When null or <= 0, set to the default value of 1, indicating that the query starts from the first page.

[0135] The interval page number `intervalPageIndex` is calculated based on the two parameters: the starting page index `startPageIndex` and the target page index `queryPageIndex`. It also checks for a reverse query flag `reverseFlag`. A forward query proceeds sequentially from the starting row key `startRowKey` to the ending row key `endRowKey`. A reverse query starts from the ending row key `endRowKey` and proceeds backwards to the starting row key `startRowKey`. Fuzzy matching is supported for the starting and ending row keys `startRowKey`. Based on the constraints and the forward / reverse flags, the interval page number `intervalPageIndex` times is used for each traversal query. Each traversal query updates the starting row key `startRowKey`, while the ending row key `endRowKey` remains unchanged; it is temporarily marked as the starting row key of the next page, `nextPageStartRowKey`. For forward queries, the nextPageStartRowKey is calculated by retrieving the rowKey string, which is the last row key of the dictionary in the current traversal of the page, and replacing the last character of the rowKey string with a character whose ASCII code is increased by 1. For reverse queries, the nextPageStartRowKey is calculated by retrieving the rowKey string, which is the last row key of the dictionary in the current traversal of the page, and decreasing the last character of the rowKey string by 1.

[0136] After retrieving the corresponding page data, if it's a reverse query, the results need to be sorted lexicographically in ascending order. Then, obtain the minimum lexicographical index `rowKey` and the maximum lexicographical index `rowKey` for that page. Subtract 1 from the last character of the minimum lexicographical index `rowKey` string to get the maximum boundary `prePageEndRowKey` of the previous page; increment 1 from the last character of the maximum lexicographical index `rowKey` string to get the minimum boundary `nextPageStartRowKey` of the next page. Return the row key `id`, the maximum boundary `prePageEndRowKey` of the previous page, the minimum boundary `nextPageStartRowKey` of the next page, the retrieved data for this page, and the result page identifier `pageIndex` to the caller. If the target page cannot be found, return the maximum retrieval page to the caller to inform them that the target page for the query according to the constraints does not exist and to reset the constraints. The calling client can determine whether the target page has been found based on the returned results. Then, near the returned result page, it can perform a forward or backward page jump query based on the current page number, the maximum boundary of the previous page (prePageEndRowKey), and the minimum boundary of the next page (nextPageStartRowKey), avoiding having to start searching for the target page near the result page from scratch. Because it utilizes the upper and lower boundary values ​​and page number returned by the target page when querying pages near the target page, it supports forward or backward pagination and page jump queries, effectively reducing the query data size when retrieving adjacent pages, improving HBase's pagination and page jump query capabilities, and ensuring that the returned result page data does not exceed the page size. Furthermore, if the target page does not exist, it will also return the last retrieved data page and its page number to the caller, allowing the caller to re-evaluate and correct the pagination parameters.

[0137] This application obtains the query range of data pages; determines the starting page and target page based on the query range; calculates the number of pages between the starting page and target page and the query order based on the starting page and target page; traverses the data pages according to the number of pages between the starting page and the query order, and uses the queried data pages as result pages to obtain the result pages and their upper and lower page boundaries; and generates data query results based on the result pages and their upper and lower page boundaries. Based on this, this application determines the starting page and target page based on the obtained query range of data pages, thereby calculating the number of pages between the starting page and target page and the query order. Then, by traversing the data pages according to the number of pages between the starting page and the query order, the result pages and their upper and lower page boundaries can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping functions, effectively reducing the query data scale when obtaining nearby target pages, thereby improving HBase pagination query efficiency, and the data returned by the query will not exceed the page size.

[0138] Please see Figure 9 This application also provides an HBase-based data pagination query device, which can implement the above-mentioned HBase-based data pagination query method. The device includes:

[0139] Module 910 is used to obtain the query range of the data page;

[0140] Module 920 is used to determine the starting page and target page of the query based on the query range.

[0141] Calculation module 930 is used to calculate the number of pages between the query start page and the query target page and the query order based on the query start page and the query target page;

[0142] The traversal module 940 is used to traverse the data pages according to the interval page number and the query order, and use the data pages obtained by the query as result pages to obtain the result pages and the upper and lower page boundaries of the result pages;

[0143] The generation module 950 is used to generate data query results based on the result page and the upper and lower page boundaries of the result page.

[0144] In some embodiments of this application, the acquisition module 910 acquires the query range of the data page; the determination module 920 determines the query start page and query target page based on the query range; the calculation module 930 calculates the number of pages between the query start page and the query target page and the query order based on the query start page and the query target page; the traversal module 940 traverses the data page according to the number of pages between the pages and the query order, and takes the queried data page as the result page to obtain the result page and the upper and lower page boundaries of the result page; the generation module 950 generates the data query result based on the result page and the upper and lower page boundaries of the result page.

[0145] In some embodiments of this application, the acquisition module 910 can scan the data pages using an HBase scanner to obtain the user-input constraints for querying the data pages, perform boundary processing on the constraints, and obtain the query range of the data pages. The HBaseScanner can be obtained using HBASE_CLIENT.newScanner in version org.hbase:asynchbase:1.8.2 to implement a simple range query function.

[0146] In some embodiments of this application, the determining module 920 determines the query start page and query target page based on the query range of the data pages. The query start page is the data page from which the query begins, and the query target page is the data page to be queried. Data pages between the query start page and the query target page fall within the scope of this query.

[0147] In some embodiments of this application, the calculation module 930 calculates the interval page number and query order between the query start page and the query target page based on the query start page and the query target page. For example, the interval page number intervalPageIndex can be calculated based on two parameters: the query start page index startPageIndex and the query target page index queryPageIndex. It also detects whether there is a reverse query flag reverseFlag. A forward query is a sequential query starting from the start row key startRowKey and proceeding to the end row key endRowKey. A reverse query is a reverse query starting from the end row key endRowKey and proceeding back to the start row key startRowKey. Here, the start row key startRowKey and end row key endRowKey support fuzzy matching. Based on the constraints and the forward and reverse flags, the interval page number intervalPageIndex traversal query is performed. Each traversal query requires updating the start row key startRowKey, while the end row key endRowKey remains unchanged, temporarily identified as the next page start row key nextPageStartRowKey. For forward queries, the nextPageStartRowKey is calculated by retrieving the rowKey string, which is the last row key of the dictionary in the current traversal of the page, and replacing the last character of the rowKey string with a character whose ASCII code is increased by 1. For reverse queries, the nextPageStartRowKey is calculated by retrieving the rowKey string, which is the last row key of the dictionary in the current traversal of the page, and decreasing the last character of the rowKey string by 1.

[0148] In some embodiments of this application, the traversal module 940 traverses the data pages according to the interval page number and the query order, and uses the queried data pages as result pages to obtain the result pages and their upper and lower page boundaries. After retrieving the corresponding page data, if it is a reverse query, the query results need to be sorted in ascending lexicographical order. Then, the minimum and maximum lexicographical row keys (rowKey and rowKey) of the page data are obtained respectively. The last character of the minimum lexicographical row key string (rowKey) is subtracted by 1 to obtain the maximum boundary of the previous page (prePageEndRowKey); the last character of the maximum lexicographical row Key string (rowKey) is incremented by 1 to obtain the minimum boundary of the next page (nextPageStartRowKey).

[0149] In some embodiments of this application, the generation module 950 generates data query results based on the result page and the page boundaries before and after the result page. It then returns the row key ID of the result page, the maximum boundary prePageEndRowKey of the previous page, the minimum boundary nextPageStartRowKey of the next page, the retrieved data for the current page, and the result page identifier pageIndex to the calling client.

[0150] The HBase-based data pagination query apparatus of this application embodiment includes: an acquisition module 910 acquiring the query range of data pages; a determination module 920 determining the query start page and query target page based on the query range; a calculation module 930 calculating the interval number of pages and the query order between the query start page and the query target page based on the query start page and the query target page; a traversal module 940 traversing the data pages based on the interval number of pages and the query order, taking the queried data pages as result pages to obtain the result pages and the upper and lower page boundaries of the result pages; and a generation module 950 generating data query results based on the result pages and the upper and lower page boundaries of the result pages. Based on this, this application determines the query start page and query target page according to the query range of the acquired data pages, thereby calculating the number of pages between the query start page and the query target page and the query order. Then, by traversing the data pages according to the number of pages between the query start page and the query order, the result page and the upper and lower page boundaries of the result page can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping query functions, and effectively reduce the query data scale when obtaining adjacent target pages, thereby improving the efficiency of HBase pagination query, and the data of the result page returned by the query will not exceed the page size.

[0151] The specific implementation of this HBase-based data pagination query device is basically the same as the specific implementation of the HBase-based data pagination query method described above, and will not be repeated here.

[0152] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described HBase-based data pagination query method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0153] Please see Figure 10 , Figure 10 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:

[0154] The processor 1001 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0155] The memory 1002 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 1002 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1002 and is called and executed by the processor 1001 using the HBase-based data paging query method of this application embodiment. Specifically, the method involves: obtaining the query range of the data pages; determining the query start page and query target page based on the query range; calculating the interval page number and query order between the query start page and query target page based on the query start page and query target page; traversing the data pages according to the interval page number and query order; using the queried data pages as result pages to obtain the result pages and their upper and lower page boundaries; and generating data query results based on the result pages and their upper and lower page boundaries. Based on this, this application determines the query start page and query target page according to the query range of the acquired data pages, thereby calculating the number of pages between the query start page and the query target page and the query order. Then, by traversing the data pages according to the number of pages between the query start page and the query order, the result page and the upper and lower page boundaries of the result page can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping query functions, and effectively reduce the query data scale when obtaining adjacent target pages, thereby improving the efficiency of HBase pagination query, and the data of the result page returned by the query will not exceed the page size.

[0156] Input / output interface 1003 is used to implement information input and output.

[0157] The communication interface 1004 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0158] The bus transmits information between various components of the device (e.g., processor 1001, memory 1002, input / output interface 1003, and communication interface 1004).

[0159] The processor 1001, memory 1002, input / output interface 1003 and communication interface 1004 are connected to each other within the device via a bus.

[0160] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described HBase-based data pagination query method.

[0161] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0162] The data pagination query method, device, electronic device, and storage medium based on HBase provided in this application embodiment obtain the query range of data pages; determine the query start page and query target page based on the query range; calculate the interval number of pages and query order between the query start page and query target page based on the query start page and query target page; traverse the data pages according to the interval number of pages and query order, and use the queried data pages as result pages to obtain the result pages and the upper and lower page boundaries of the result pages; and generate data query results based on the result pages and the upper and lower page boundaries of the result pages. Based on this, this application determines the query start page and query target page according to the query range of the acquired data pages, thereby calculating the number of pages between the query start page and the query target page and the query order. Then, by traversing the data pages according to the number of pages between the query start page and the query order, the result page and the upper and lower page boundaries of the result page can be obtained to obtain the data query results. When querying pages near the target page, the upper and lower boundary values ​​and page numbers returned by the result page are used to support forward or backward pagination and page skipping query functions, and effectively reduce the query data scale when obtaining adjacent target pages, thereby improving the efficiency of HBase pagination query, and the data of the result page returned by the query will not exceed the page size.

[0163] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable programs, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable programs, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0164] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0165] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0166] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0167] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0168] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0169] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0170] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0171] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0172] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0173] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0174] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A data pagination query method based on HBase, characterized in that, The method includes: Get the query range of the data page; The query start page and query target page are determined based on the query scope; Calculate the number of pages between the query start page and the query target page, and the query order; Traversing the data pages according to the specified page interval and query order, and using the retrieved data pages as result pages to obtain the upper and lower page boundaries of the result pages, includes: determining a query direction identifier according to the query order; traversing the data pages according to the direction identifier to retrieve the result pages, including: determining the starting row key of the query start page and the ending row key of the query target page; if the direction identifier is a positive identifier, traversing the data pages from the starting row key of the query start page to the ending row key of the query target page, including: obtaining the last row key string of the dictionary ascending row data in this traversal of the data pages; and determining the last row key string of the dictionary ascending row data in this traversal of the result pages. A character is replaced with its ASCII code plus 1 to obtain the starting line key of the next page; the data pages are traversed page by page from the starting line key of the query start page to the ending line key of the query target page according to the starting line key of the next page; when the direction indicator is reversed, the data pages are traversed from the ending line key of the query target page to the starting line key of the query start page, including: obtaining the last line key string of the dictionary reverse-order row data in the traversed page; the character whose last character of the line key string is minus 1 is obtained to obtain the starting line key of the next page; the data pages are traversed page by page from the ending line key of the query target page to the starting line key of the query start page according to the starting line key of the next page; Data query results are generated based on the result page and the page boundaries above and below the result page.

2. The method according to claim 1, characterized in that, The query range for obtaining the data page includes: The data pages are scanned using an HBase scanner; Obtain the constraints for the data page query input by the user; Boundary processing is applied to the constraints to obtain the query range of the data page.

3. The method according to claim 1, characterized in that, The step of traversing the data pages according to the interval page number and the query order, and taking the queried data pages as result pages to obtain the upper and lower page boundaries of the result pages includes: The query direction identifier is determined according to the query order. The direction identifier includes a forward identifier and a reverse identifier. The forward identifier is used to identify the forward query order, and the reverse identifier is used to identify the reverse query order. The data pages are traversed according to the direction identifier to query the result page, the maximum boundary of the previous page of the result page, and the minimum boundary of the next page of the result page, wherein the number of traversals is equal to the number of page intervals.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Sort the result pages in ascending dictionary order; Obtain the row key identifier of the result page, the upper and lower page boundaries of the result page, the data of the current page of the result page, and the page number identifier of the result page to generate data query results; The data query results are returned to the calling client so that the calling client can perform data pagination queries based on the data query results.

5. A data pagination query device based on HBase, the device being used to implement the data pagination query method based on HBase according to any one of claims 1 to 4, characterized in that, The device includes: The retrieval module is used to retrieve the query range of a data page; The determination module is used to determine the query start page and query target page based on the query range; The calculation module is used to calculate the number of pages between the query start page and the query target page and the query order based on the query start page and the query target page; The traversal module is used to traverse the data pages according to the interval page number and the query order, and take the queried data pages as result pages to obtain the upper and lower page boundaries of the result pages; The generation module is used to generate data query results based on the result page and the upper and lower page boundaries of the result page.

6. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the HBase-based data pagination query method according to any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the HBase-based data pagination query method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Data paging query method based on HBase

    CN110955680A

  • Paging query method and device based on user characteristics

    CN114385691A