Data reading method and device, electronic equipment, storage medium and program product
By determining the cursor table row set in the database and determining the target interval based on user requests, the problem of redefining cursors in the prior art increases the complexity of code is solved, and the convenience of data acquisition and user experience are improved.
Patent Information
- Application Number
- CN202510072320.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-16
AI Technical Summary
In the prior art, when users temporarily need to obtain part of the data in the database table, they need to redefine the cursor, which increases the code complexity, makes it difficult for clients to obtain data in a timely manner, and reduces the convenience of data acquisition and user experience.
By obtaining the cursor parameter value, initial parameter value, step size parameter value and direction parameter value in the data read request sent by the user, the corresponding cursor table row set in the database is determined, and the target position corresponding to the initial parameter value is determined within the valid interval, and the target interval is determined based on the position and direction parameter value and step size parameter value, so that the data in the target interval is returned to the user.
It realizes the timely response to user temporary needs while reducing the complexity of code during the development process, improving the convenience of data acquisition and user experience, and meeting the user's need to read specified step size data from designated locations in the specified direction.
Smart Images

Figure CN120011435A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to computer technology, and in particular to a data reading method, device, electronic device, storage medium and program product. Background Art
[0002] During the development process, the client needs to perform IO (Input / Output) interaction with the server to request resource data on the server. However, too many interactions can easily reduce database performance and increase the response time of data requests.
[0003] In order to reduce the number of IO interactions between the client and the server, the prior art defines a cursor in a stored procedure in advance, so that when requesting to obtain data resources, the defined cursor is moved to a specified starting point by calling the stored procedure, thereby obtaining the requested data from the client from the specified starting point.
[0004] However, when a user temporarily needs to obtain part of the data in the cursor, the existing technology needs to redefine a new cursor, which increases the complexity of the code, makes it difficult for the client to obtain data in time, reduces the convenience of data acquisition, and reduces the user experience. Summary of the invention
[0005] The embodiments of the present application provide a data reading method, device, electronic device, storage medium and program product, so as to achieve the effect of reducing the code complexity in the development process, improving the convenience of data acquisition and enhancing the user experience while timely responding to the temporary needs of users.
[0006] In a first aspect, an embodiment of the present application provides a data reading method, comprising:
[0007] Obtaining a data read request sent by the user end, the data read request includes a cursor parameter value, an initial parameter value, a step parameter value, and a direction parameter value, and the cursor parameter value is used to determine a corresponding cursor table row set in the database;
[0008] Determine whether the initial parameter value is within the valid interval, which is an interval greater than 0 and not exceeding the total number of rows in the cursor table row set; if it is within the valid interval, determine the target position corresponding to the initial parameter value in the cursor table row set; based on the target position, determine the target interval corresponding to the data read request according to the direction parameter value and the step parameter value, and return the data in the target interval to the user end.
[0009] Optionally, determining a target position corresponding to the initial parameter value in the cursor table row set specifically includes:
[0010] The cursor table row set is split in half to obtain the partition corresponding to the initial parameter value, and then determine whether the number of rows indicated by the partition is consistent with the initial parameter value;
[0011] When it is determined that the position corresponding to the partition is consistent with the number of rows corresponding to the initial parameter value, the position corresponding to the partition is determined to be the target position; otherwise, the partition corresponding to the initial parameter value is updated.
[0012] Optionally, based on the target position, determining a target interval corresponding to the data read request according to a direction parameter value and a step parameter value specifically includes:
[0013] When the target position is not at the last row of the cursor table row set and the direction parameter value is positive, determine that the target position is the starting row number of the target interval, and determine whether the sum of the initial parameter value and the step parameter value is less than the total number of rows;
[0014] When it is less than the total number of rows, the end number of rows of the target interval is determined to be the sum of the initial parameter value and the step parameter value; otherwise, the end number of rows of the target interval is determined to be the last row of the cursor table row set.
[0015] Optionally, when the target position is not at the last row of the cursor table row set and the direction parameter value is reverse, determine that the target position is the starting row number of the target interval, and determine whether the step parameter value is less than the initial parameter value;
[0016] When it is less than the initial parameter value, the end row number of the target interval is determined to be the difference between the initial parameter value and the step parameter value; otherwise, the end row number of the target interval is determined to be the first row of the cursor table row set.
[0017] Optionally, when the target position is at the last row of the cursor table row set and the direction parameter value is reverse, the starting row number of the target interval is determined to be the last row of the cursor table row set, and whether the step parameter value is less than the total number of rows of the cursor table row set;
[0018] When the number of rows is less than the total number of rows in the cursor table row set, the end number of rows in the target interval is determined to be the difference between the total number of rows in the cursor table row set and the step parameter value; otherwise, the end number of rows in the target interval is determined to be the same as the start number of rows, which is the last row of the cursor table row set.
[0019] Optionally, when the target position is at the last row of the cursor table row set and the direction parameter value is positive, an exception message is generated and returned to the user end.
[0020] In a second aspect, an embodiment of the present application provides a data reading device, including:
[0021] An acquisition module is used to acquire a data read request sent by a user end, wherein the data read request includes a cursor parameter value, an initial parameter value, a step parameter value, and a direction parameter value, and the cursor parameter value is used to determine a corresponding cursor table row set in a database;
[0022] A processing module is used to determine whether the initial parameter value is within a valid interval, where the valid interval is an interval greater than 0 and not exceeding the total number of rows in the cursor table row set; if it is within the valid interval, a target position corresponding to the initial parameter value is determined in the cursor table row set; based on the target position, a target interval corresponding to the data read request is determined according to the direction parameter value and the step parameter value, and the data in the target interval is returned to the user end.
[0023] Optionally, the processing module is further used to perform a halving process on the row set of the cursor table to obtain a partition corresponding to the initial parameter value, and determine whether the number of rows indicated by the partition is consistent with the initial parameter value;
[0024] When it is determined that the position corresponding to the partition is consistent with the number of rows corresponding to the initial parameter value, the position corresponding to the partition is determined to be the target position; otherwise, the partition corresponding to the initial parameter value is updated.
[0025] Optionally, the processing module is further used to determine that the target position is the starting row number of the target interval, and determine whether the sum of the initial parameter value and the step parameter value is less than the total number of rows when the target position is not at the last row of the cursor table row set and the direction parameter value is positive;
[0026] When it is less than the total number of rows, the end number of rows of the target interval is determined to be the sum of the initial parameter value and the step parameter value; otherwise, the end number of rows of the target interval is determined to be the last row of the cursor table row set.
[0027] Optionally, the processing module is further used to determine that the target position is the starting row number of the target interval, and determine whether the step parameter value is less than the initial parameter value when the target position is not at the last row of the cursor table row set and the direction parameter value is reverse;
[0028] When it is less than the initial parameter value, the end row number of the target interval is determined to be the difference between the initial parameter value and the step parameter value; otherwise, the end row number of the target interval is determined to be the first row of the cursor table row set.
[0029] Optionally, the processing module is further used to determine that the starting row number of the target interval is the last row of the cursor table row set when the target position is at the last row of the cursor table row set and the direction parameter value is reverse, and determine whether the step parameter value is less than the total number of rows of the cursor table row set;
[0030] When the number of rows is less than the total number of rows in the cursor table row set, the end number of rows in the target interval is determined to be the difference between the total number of rows in the cursor table row set and the step parameter value; otherwise, the end number of rows in the target interval is determined to be the same as the start number of rows, which is the last row of the cursor table row set.
[0031] Optionally, the processing module is further configured to generate exception information and return it to the user end when the target position is at the last row of the cursor table row set and the direction parameter value is positive.
[0032] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0033] Memory stores computer-executable instructions;
[0034] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0035] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0036] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0037] The data reading method, device, electronic device, storage medium and program product provided by the embodiments of the present application obtain the data reading request sent by the user end through the server end, determine the cursor table row set corresponding to the cursor parameter value in the database according to the cursor parameter value indicated by the data reading request, and determine whether the initial parameter value indicated by the data reading request is within a valid interval greater than 0 and not exceeding the total number of rows in the cursor table row set based on the cursor table row set. If it is determined to be within the valid interval, the target position corresponding to the initial parameter value is determined in the cursor table row set, and then the target interval is determined based on the target position and the step parameter value and direction parameter value indicated by the data reading request, so as to return the data within the target interval to the user end. The present application returns the specified position from the current cursor table row set to the client end, and reads the data of the specified step length according to the specified direction, which meets the timely response to the user's temporary needs. At the same time, it reduces the code complexity in the development process, improves the convenience of data acquisition, expands the application scenarios, and enhances the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0039] Figure 1 A schematic diagram of an application scenario of the data reading method provided in this application;
[0040] Figure 2 Schematic diagram of the data reading method provided in this application Figure 1 ;
[0041] Figure 3 A schematic diagram of the structure of the cursor table row set provided for this application;
[0042] Figure 4 A schematic diagram of the process flow of the forward data reading method provided in this application;
[0043] Figure 5 A schematic diagram of the process of the reverse data reading method provided in this application;
[0044] Figure 6 Schematic diagram of the data reading method provided in this application Figure 2 ;
[0045] Figure 7 Schematic diagram of the data reading method provided in this application Figure 3 ;
[0046] Figure 8 A schematic diagram of the structure of the data reading device provided by this application;
[0047] Fig. 9 A schematic diagram of the structure of the electronic device provided in this application.
[0048] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0049] 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 implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0050] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0051] Figure 1 A schematic diagram of an application scenario of the data reading method provided in this application, such as Figure 1As shown, during the development process, the client needs to perform IO interaction with the server, and sends a read request to the server so that the server reads relevant data in the database according to the read request and obtains response data corresponding to the read request.
[0052] Due to the excessive number of interactions between the client and the server, it is easy to reduce the database performance and cause the response time to increase. The existing technology pre-defines the cursor in the stored procedure, so that when data needs to be obtained, the user sends the target cursor information to the server, so that the server can traverse the pre-defined database table by calling the stored procedure corresponding to the target cursor information, and feed back the traversed and read data to the client.
[0053] However, when users need to obtain part of the data in the database table, the existing technology needs to redefine the corresponding cursor in the storage process according to the current needs, which increases the complexity and time cost of code development, reduces the data response rate and data reading convenience, and is difficult to meet the reading needs of multiple scenarios, which reduces the user experience. In addition, if all the database tables corresponding to the cursors of some data are returned to the client, it is easy to transmit a large amount of useless data, thereby increasing the time cost of data reading, reducing the acquisition efficiency, and reducing system performance.
[0054] The data reading method provided by the present application determines the cursor parameter value, initial parameter value, step parameter value and direction parameter value in the data reading request sent by the user end through the server end, obtains the corresponding cursor table row set in the database according to the cursor parameter value, and when it is determined that the initial parameter value is within a valid interval greater than 0 and not exceeding the total number of rows in the cursor table row set, the obtained cursor table row set is halved, and when the position of the partition corresponding to the initial parameter value in the above cursor table row set is consistent with the number of rows indicated by the initial parameter value, the target position is obtained, and according to the result of determining whether the target position is at the last row of the cursor table row set and the direction parameter value, the target interval corresponding to the step parameter value is determined, and the data corresponding to the target interval is fed back to the user end, so as to meet the user's needs of reading data of a specified step length from a specified position in a specified direction, expand the application scenarios of the data reading method, reduce the complexity of code development, improve the convenience and efficiency of data reading, and enhance the user experience.
[0055] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0056] Figure 2 Schematic diagram of the data reading method provided in this application Figure 1 ,like Figure 2As shown, the method includes:
[0057] S201: Obtain a data reading request sent by a user terminal.
[0058] More specifically, a data read request sent by the user end is obtained, the data read request including a cursor parameter value, an initial parameter value, a step parameter value and a direction parameter value, and the cursor parameter value is used to determine a corresponding cursor table row set in a database.
[0059] Exemplarily, the cursor parameter value is a parameter value corresponding to a cursor pre-defined in a stored procedure. Based on the cursor parameter value, the corresponding stored procedure is called to obtain a cursor table row set after traversing the data corresponding to the cursor parameter value.
[0060] Optionally, the cursor parameter value, initial parameter value, step parameter value and direction parameter value are input from different interfaces on the user end.
[0061] In a possible embodiment, Figure 3 As shown, the cursor table row set includes a number column, a name column, and a data column. The number column includes number 1, number 2, number 3, ... number n, number n+1, where n is a positive integer. The name column includes name 1, name 2, name 3, ... name n, name n+1, and the data column includes data 1, data 2, data 3, ... data n, data n+1. The initial parameter value is used to indicate the starting point of the data that the user needs to read, the step parameter value is used to indicate the number of data that the user needs to read, and the direction parameter value (not in Figure 3 ) is used to indicate the direction of traversing the data from the starting point, including forward and reverse directions, wherein the forward direction is the direction of increasing numbers and the reverse direction is the direction of decreasing numbers.
[0062] S202: Determine whether the initial parameter value is within a valid range.
[0063] More specifically, it is determined whether the initial parameter value is within a valid interval, where the valid interval is an interval that is greater than 0 and does not exceed the total number of rows in the cursor table row set.
[0064] For example, Figure 3 For the cursor table row set shown, when n is 203, it is determined that the total number of rows corresponding to the cursor table row set is 204 rows. If the initial parameter value is 3, it is determined that the initial parameter value is greater than 0 and does not exceed the total number of rows in the cursor table row set, and the initial parameter value is within the valid range.
[0065] Exemplarily, based on the total number of rows corresponding to the cursor table row set of 204 rows, if the initial parameter value is 205, it is determined that the initial parameter value exceeds the total number of rows in the cursor table row set, and it is obtained that the initial parameter value is not within the valid range.
[0066] S203: If it is within the valid range, determine the target position corresponding to the initial parameter value; based on the target position, determine the target range according to the direction parameter value and the step parameter value, and return the data within the target range to the user end.
[0067] More specifically, if it is within the valid interval, the target position corresponding to the initial parameter value is determined in the cursor table row set; based on the target position, the target interval corresponding to the data read request is determined according to the direction parameter value and the step parameter value, and the data in the target interval is returned to the user end.
[0068] Optionally, if it is determined that the initial parameter value is not within the valid range, an exception message is generated and returned to the user end.
[0069] Optionally, determining a target position corresponding to the initial parameter value in the cursor table row set specifically includes: halving the cursor table row set to obtain a partition corresponding to the initial parameter value, and determining whether the number of rows indicated by the partition is consistent with the initial parameter value; when it is determined that the position corresponding to the partition is consistent with the number of rows corresponding to the initial parameter value, determining the position corresponding to the partition as the target position; otherwise, updating the partition corresponding to the initial parameter value.
[0070] For example, for a halving process of a cursor table row set with a total of 10 rows, if the initial parameter value is greater than 1 and less than half of the total number of rows in the cursor table row set, the starting row number of the target interval is determined to be 1, and the ending row number is the middle position of the cursor table row set (row 5). If the initial parameter value is greater than 1 and greater than half of the total number of rows in the cursor table row set, the starting row number of the target interval is determined to be the middle position of the cursor table row set (row 5), and the ending row number is the last row of the cursor table row set. Repeat the above steps, and when the obtained interval is consistent with the initial parameter value, the target interval is obtained.
[0071] For example, if the initial parameter value is 1, the first row of the cursor table row set is determined as the target position. If the initial parameter value is half of the total number of rows in the cursor table row set, that is, 5, the middle position of the cursor table row set (the fifth row) is determined as the target position. If the initial parameter value is 10, which corresponds to the total number of rows in the cursor table row set, the tenth row of the cursor table row set is determined as the target position.
[0072] In a possible embodiment, if the total number of rows in the cursor table row set is 10 and the initial parameter value is 2, the cursor table row set is subjected to the first halving process, that is, , the initial parameter value 2 is obtained in the upper half of the cursor table row set, which is numbered 1 to 5. By performing a second halving process on the upper half of the partition, that is, , and rounded up, the second upper partition corresponding to the initial parameter value 2 is numbered 1 to 3. By performing the third halving process on the second upper partition, that is, , and rounded up to get the third upper partition corresponding to the initial parameter value 2 as number 1 to number 2. At this time, it is determined that number 2 of the third upper partition is consistent with the value of the initial parameter value 2, and number 2 in the third upper partition is determined to be the target position. This embodiment obtains the position corresponding to the initial parameter value specified in the cursor table row set by halving the cursor table row set, thereby locating the position of the specified starting point in the cursor table row set and improving the efficiency of locating the starting point, thereby further improving the efficiency and accuracy of data reading.
[0073] Optionally, based on the target position, the target interval corresponding to the data read request is determined according to the direction parameter value and the step parameter value, specifically including: when the target position is not at the last row of the cursor table row set and the direction parameter value is positive, the target position is determined to be the starting row number of the target interval, and it is determined whether the sum of the initial parameter value and the step parameter value is less than the total number of rows; when it is less than the total number of rows, the end row number of the target interval is determined to be the sum of the initial parameter value and the step parameter value; otherwise, the end row number of the target interval is determined to be the last row of the cursor table row set.
[0074] In a possible embodiment, Figure 4 As shown, the server sends the cursor parameter value to the database and obtains the corresponding cursor table row set. The total number of rows in the cursor table row set is 204. When the target position is determined to be the 3rd row (not the last row) of the cursor table row set, the step parameter value is 200, and the direction parameter value is positive, the starting row number is determined to be the 3rd row, and the sum of the initial parameter value and the step parameter value is determined to be 203, which is less than the last row 204, that is, the ending row number is the 203rd row. The data from the 3rd to the 203rd row is read to the user end.
[0075] Exemplarily, if the step parameter value is 202, the sum of the initial parameter value and the step parameter value is determined to be 205, which is greater than the last row 204, that is, the end row number is the last row 204. The data from the 3rd row to the 204th row is read to the user end.
[0076] This embodiment determines the target position in the cursor table row set and the direction parameter value and step parameter value indicated by the data reading request, and determines the starting row number and the ending row number of the corresponding target interval when the starting position is not the last row of the cursor table row set and the direction parameter value is positive, thereby obtaining the response data corresponding to the data reading request, meeting the user's demand for reading the specified step data in the specified position in the forward direction, expanding the application scenarios of the data reading method, improving the convenience and reading rate of data reading, and enhancing the user experience.
[0077] Optionally, when the target position is not at the last row of the cursor table row set and the direction parameter value is reverse, the target position is determined to be the starting row number of the target interval, and it is determined whether the step parameter value is less than the initial parameter value; when it is less than the initial parameter value, the ending row number of the target interval is determined to be the difference between the initial parameter value and the step parameter value; otherwise, the ending row number of the target interval is determined to be the first row of the cursor table row set.
[0078] In a possible embodiment, Figure 5 As shown, the server sends the cursor parameter value to the database and obtains the corresponding cursor table row set, which has a total of 104 rows. When the target position is determined to be the 103rd row (not the last row) of the cursor table row set, the step parameter value is 100, and the direction parameter value is reverse, it is determined that the initial parameter value 103 is greater than the step parameter value 100, and the end row number is the difference between the initial parameter value 103 and the step parameter value 100, that is, the end row number is row 3. The data from row 103 to row 3 is read to the user end.
[0079] For example, if the total number of rows in the cursor table row set is 104 and the step parameter value is 105, it is determined that the initial parameter value 103 is less than the step parameter value 105, that is, the end row number is the first row of the cursor table row set. The data from row 103 to row 1 is read to the user end.
[0080] When it is determined that the starting position is not the last row of the cursor table row set and the direction parameter value is reverse, this embodiment determines the starting row number and the ending row number of the corresponding target interval, thereby obtaining response data corresponding to the data reading request, meeting the user's demand for reverse reading of specified step data at a specified position, expanding the application scenarios of the data reading method, improving the convenience and reading rate of data reading, and enhancing the user experience.
[0081] Optionally, when the target position is at the last row of the cursor table row set and the direction parameter value is reverse, the starting row number of the target interval is determined to be the last row of the cursor table row set, and it is determined whether the step parameter value is less than the total number of rows of the cursor table row set; when it is determined to be less than the total number of rows of the cursor table row set, the ending row number of the target interval is determined to be the difference between the total number of rows of the cursor table row set and the step parameter value; otherwise, the ending row number of the target interval is determined to be consistent with the starting row number, which is the last row of the cursor table row set.
[0082] Optionally, when the target position is at the last row of the cursor table row set and the direction parameter value is positive, an exception message is generated and returned to the user end.
[0083] In this embodiment, when the starting position is the last row of the cursor table row set, the starting row number and the ending row number of the corresponding target interval are determined for the forward reading scenario and the reverse reading scenario respectively, so as to obtain response data corresponding to the data reading request in different scenarios, thereby expanding the application scenarios of the data reading method, improving the convenience and reading rate of data reading, enhancing the user experience, and outputting abnormal information to prompt the user when the parameter value indicated by the data reading request exceeds the range of the current cursor table row set, so that the user can correct the parameter value in time, thereby improving the reliability of data reading.
[0084] Optionally, when the direction parameter value is forward, when there are table num rows of data in the cursor table row set, the data read request starts from the kth row and reads m rows of data in a forward direction. At this time, determine whether the kth row is the last row of the cursor table row set. When the kth row is the last row of the cursor table row set and the step length m is greater than 0, an exception message is generated and output to the client, and the exception message is used to indicate that the current data read request cannot read the data normally. When k is greater than table num rows, an exception message is generated and output to the client. When the sum of the kth row and the step length m is less than table num rows, the data between the kth row and the k+mth row of the cursor table row set is returned. When the sum of the kth row and the step length m is greater than table num rows, the data between the kth row and the last row of the cursor table row set is returned.
[0085] Optionally, when the direction parameter value is reverse, when there are table num rows of data in the cursor table row set, the data read request starts from the kth row in reverse order to read m rows of data. At this time, determine whether the kth row is the last row of the cursor table row set. When the kth row is the last row of the cursor table row set and the step length m does not exceed table num rows, start reading m rows of data (i.e., number k to number km) from the kth row in reverse order. When the kth row is not the first row in the cursor table row set and the kth row is less than the step length m, start reading from the kth row in reverse order to the first row of the cursor table row set (i.e., number k to number 1). When the kth row is the first row in the cursor table row set and the kth row is less than the step length m, start reading from the kth row in reverse order to the first row of the cursor table row set (i.e., number k to number 1). When the kth row is the first row in the cursor table row set and the step length is 0, generate an exception message and output it to the client.
[0086] The data reading method provided in the embodiment of the present application, after obtaining a cursor table row set according to a cursor parameter value, determines whether the received initial parameter value is within a valid interval based on the obtained cursor table row set, and when it is determined to be within the valid interval, determines the target position corresponding to the initial parameter value in the cursor table row set, and determines the target interval based on the direction parameter value, the step parameter value and the target position, so as to reduce the number of interactions between the user end and the server end, and effectively read the data of the specified step length in the specified direction from any specified position other than the last row in the cursor table row set, increase the application scenarios of the data reading method, improve the convenience of data reading and the response rate of data reading, meet the data reading needs of users in multiple complex scenarios, and enhance the user experience.
[0087] Optionally, the embodiment of the present application can determine the corresponding combination schemes under different application scenarios as the values of the cursor parameter value, the initial parameter value, the step parameter value and the direction parameter value change, and determine the corresponding reading strategy for the current combination scheme to obtain the response data under the corresponding scenario of the current combination scheme. The embodiment of the present application also generates abnormal information for abnormal combination schemes, and outputs it to the user end to indicate that the input parameters are incorrect, thereby improving the robustness of data reading. Wherein, the above-mentioned reading strategy refers to the reading method corresponding to different combination schemes.
[0088] In one possible embodiment, Figure 6 Schematic diagram of the data reading method provided in this application Figure 2 ,like Figure 6 As shown, in this embodiment Figure 2 Based on the embodiment, after obtaining the cursor table row set corresponding to the cursor parameter value, the reading strategy in different scenarios in the data reading method is described in detail, and the method includes:
[0089] S601: Determine an initial parameter value, a step parameter value, and a direction parameter value indicated by a data read request.
[0090] More specifically, the initial parameter value, step parameter value and direction parameter value indicated by the data read request are determined by the server.
[0091] S602: Determine whether the initial parameter value is within a valid range.
[0092] More specifically, it is determined whether the initial parameter value is greater than 0 and does not exceed the total number of rows in the cursor table row set.
[0093] Optionally, when it is determined that the data is not within the valid interval, step S603 is performed. When it is determined that the data is within the valid interval, step S604 is performed.
[0094] S603: If it is determined that the initial parameter value is not within the valid range, output abnormal information.
[0095] More specifically, if it is determined that the initial parameter value is less than 0, abnormal information is output.
[0096] Optionally, if it is determined that the initial parameter value is greater than the total number of rows in the cursor table row set, an exception message is output.
[0097] S604: If it is determined that the initial parameter value is within the valid range, determine whether the initial parameter value is the last row of the cursor table row set.
[0098] More specifically, if it is determined that the initial parameter value is the last row of the cursor table row set, step S605 is executed, and if it is determined that the initial parameter value is not the last row of the cursor table row set, step S608 is executed.
[0099] S605: If it is the last row, determine whether the direction parameter value is positive.
[0100] More specifically, if it is determined that the initial parameter value is the last row of the cursor table row set, it is determined whether the direction parameter value is forward, and if it is determined that the direction parameter value is forward, step S603 is executed, and if it is determined that the direction parameter value is reverse, step S606 is executed.
[0101] S606: If it is determined that the direction parameter value is reverse, determine that the starting row number of the target interval is the last row of the cursor table row set.
[0102] S607: Determine whether the step size parameter value is less than the total number of rows in the cursor table row set.
[0103] More specifically, when it is determined that the step parameter value is less than the total number of rows in the cursor table row set, step S612 is executed, and when it is determined that the step parameter value is not less than the total number of rows in the cursor table row set, step S613 is executed.
[0104] S608: If it is not the last row, determine the starting row number of the target interval as the target position corresponding to the initial value, and determine whether the direction parameter value is positive.
[0105] More specifically, if it is determined that the initial parameter value is not the last row of the cursor table row set, the starting row number of the target interval is determined to be the target position corresponding to the initial parameter value, and it is determined whether the direction parameter value is positive. In this step, if the direction parameter value is determined to be positive, step S609 is executed, and if the direction parameter value is determined to be reverse, step S610 is executed.
[0106] S609: When the direction parameter value is determined to be forward, determine whether the sum of the step parameter value and the initial parameter value is less than the total number of rows in the cursor table row set.
[0107] More specifically, based on the positive direction parameter value, when it is determined that the sum of the step parameter value and the initial parameter value is less than the total number of rows in the cursor table row set, step S613 is executed; when it is determined that the sum of the step parameter value and the initial parameter value is not less than the total number of rows in the cursor table row set, step S614 is executed.
[0108] S610: When it is determined that the direction parameter value is reverse, determine whether the step parameter value is smaller than the initial parameter value.
[0109] More specifically, based on the reverse direction parameter value, when it is determined that the step parameter value is less than the initial parameter value, step S615 is executed; when it is determined that the step parameter value is not less than the initial parameter value, step S616 is executed.
[0110] S611. When it is determined that the step parameter value is less than the total number of rows in the cursor table row set, the end number of rows in the target interval is determined to be the difference between the total number of rows in the cursor table row set and the step parameter value.
[0111] More specifically, step S611 is a reading strategy in a scenario where the direction parameter value is reverse and the step parameter value is less than the total number of rows in the cursor table row set.
[0112] S612: When it is determined that the step size parameter value is not less than the total number of rows in the cursor table row set, the end row number of the target interval is determined to be the first row in the cursor table row set.
[0113] More specifically, step S612 is a reading strategy in a scenario where the direction parameter value is reverse and the step parameter value is not less than the total number of rows in the cursor table row set.
[0114] S613: When it is determined that the sum of the step parameter value and the initial parameter value is less than the total number of rows in the cursor table row set, the end number of rows in the target interval is determined to be the sum of the initial parameter value and the step parameter value.
[0115] More specifically, step S613 is a reading strategy in a scenario where the direction parameter value is positive and the sum of the step parameter value and the initial parameter value is determined to be less than the total number of rows in the cursor table row set.
[0116] S614. When it is determined that the sum of the step parameter value and the initial parameter value is not less than the total number of rows in the cursor table row set, the end row number of the target interval is determined to be the last row in the cursor table row set.
[0117] More specifically, step S614 is a reading strategy in a scenario where the direction parameter value is positive and the sum of the step parameter value and the initial parameter value is determined to be not less than the total number of rows in the cursor table row set.
[0118] S615. When it is determined that the step parameter value is less than the initial parameter value, the number of ending rows of the target interval is determined to be the difference between the initial parameter value and the step parameter value.
[0119] More specifically, step S615 is a reading strategy in a scenario where the direction parameter value is reverse and the step parameter value is smaller than the initial parameter value.
[0120] S616. When it is determined that the step parameter value is not less than the initial parameter value, the end row number of the target interval is determined to be the first row of the cursor table row set.
[0121] More specifically, step S616 is a reading strategy in a scenario where the direction parameter value is reverse and the step parameter value is not less than the initial parameter value.
[0122] Figure 7 Schematic diagram of the data reading method provided in this application Figure 3 ,like Figure 7 As shown, in this embodiment Figure 2 Based on the embodiment, the data reading method is described in detail, and the method includes: the user inputs a cursor parameter value, an initial parameter value, a step parameter value, and a direction parameter value to the user end, so that the user end generates a data reading request and sends it to the server end. After receiving the data reading request, the server end determines the corresponding cursor table row set according to the cursor parameter value indicated by the data reading request, and determines the total number of rows corresponding to the cursor table row set, which is 204 rows. Among them, the initial parameter value indicated by the data reading request is 3, the step parameter value is 200, and the direction parameter value is positive.
[0123] Optionally, based on the cursor table row set, determine that the initial parameter value 3 is within the valid range, and repeatedly halve the cursor table row set until the number of rows indicated by the partition corresponding to the obtained initial parameter value 3 is consistent with the initial parameter value. At this time, the number of rows with consistent indications is the target position, that is, the third row of the cursor table row set.
[0124] Optionally, it is determined that the sum of the step parameter value 200 and the initial parameter value 3 is less than the total number of rows of the cursor table row set 204, that is, the end number of rows of the target interval is determined to be the sum of the initial parameter value and the step parameter value (the 203rd row of the cursor table row set), and the start number of rows is the target position corresponding to the initial parameter value (the 3rd row of the cursor table row set). The data from the 3rd row to the 203rd row of the cursor table row set is read to the user end.
[0125] The data reading method provided in the embodiment of the present application is based on the cursor table row set corresponding to the cursor parameter value, and analyzes the initial parameter value, step parameter value and direction parameter value indicated by the data reading request sent by the user end to obtain the data within the target interval required by the user in the current scenario, so as to meet the data reading requirements of the specified position, specified direction and specified step size in the cursor table row set, solves the complexity and response delay of the whole table reading in the prior art, improves the convenience of data reading, avoids unnecessary resource consumption, and enhances the user experience.
[0126] Figure 8A schematic diagram of the structure of the data reading device provided in this application, such as Figure 8 As shown, the data reading device 80 provided in this embodiment includes:
[0127] The acquisition module 801 is used to acquire a data read request sent by a user terminal, wherein the data read request includes a cursor parameter value, an initial parameter value, a step parameter value, and a direction parameter value, and the cursor parameter value is used to determine a corresponding cursor table row set in a database;
[0128] Processing module 802 is used to determine whether the initial parameter value is within a valid interval, where the valid interval is an interval greater than 0 and not exceeding the total number of rows in the cursor table row set; if it is within the valid interval, the target position corresponding to the initial parameter value is determined in the cursor table row set; based on the target position, the target interval corresponding to the data read request is determined according to the direction parameter value and the step parameter value, and the data in the target interval is returned to the user end.
[0129] Optionally, the processing module 802 is further used to perform a halving process on the row set of the cursor table to obtain a partition corresponding to the initial parameter value, and determine whether the number of rows indicated by the partition is consistent with the initial parameter value;
[0130] When it is determined that the position corresponding to the partition is consistent with the number of rows corresponding to the initial parameter value, the position corresponding to the partition is determined to be the target position; otherwise, the partition corresponding to the initial parameter value is updated.
[0131] Optionally, the processing module 802 is further configured to determine, when the target position is not at the last row of the row set of the cursor table and the direction parameter value is positive, determine that the target position is the starting row number of the target interval, and determine whether the sum of the initial parameter value and the step parameter value is less than the total number of rows;
[0132] When it is less than the total number of rows, the end number of rows of the target interval is determined to be the sum of the initial parameter value and the step parameter value; otherwise, the end number of rows of the target interval is determined to be the last row of the cursor table row set.
[0133] Optionally, the processing module 802 is further configured to determine that the target position is the starting row number of the target interval, and determine whether the step parameter value is less than the initial parameter value when the target position is not at the last row of the cursor table row set and the direction parameter value is reverse;
[0134] When it is less than the initial parameter value, the end row number of the target interval is determined to be the difference between the initial parameter value and the step parameter value; otherwise, the end row number of the target interval is determined to be the first row of the cursor table row set.
[0135] Optionally, the processing module 802 is further configured to determine, when the target position is at the last row of the cursor table row set and the direction parameter value is reverse, that the starting row number of the target interval is the last row of the cursor table row set, and determine whether the step parameter value is less than the total number of rows of the cursor table row set;
[0136] When the number of rows is less than the total number of rows in the cursor table row set, the end number of rows in the target interval is determined to be the difference between the total number of rows in the cursor table row set and the step parameter value; otherwise, the end number of rows in the target interval is determined to be the same as the start number of rows, which is the last row of the cursor table row set.
[0137] Optionally, the processing module 802 is further configured to generate an exception message and return it to the user end when the target position is at the last row of the cursor table row set and the direction parameter value is positive.
[0138] The data reading device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0139] Fig. 9 This is a schematic diagram of the structure of the electronic device provided in this application. Fig. 9 As shown, the electronic device 90 provided in this embodiment includes: at least one processor 901 and a memory 902. Optionally, the device 90 further includes a communication component 903. The processor 901, the memory 902 and the communication component 903 are connected via a bus 904.
[0140] In a specific implementation process, at least one processor 901 executes the computer execution instructions stored in the memory 902, so that at least one processor 901 executes the above method.
[0141] The specific implementation process of the processor 901 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0142] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly implemented as a hardware processor, or can be implemented by a combination of hardware and software modules in the processor.
[0143] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0144] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0145] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0146] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0147] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0148] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0149] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0152] If the function is implemented in the form of 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 the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0153] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0154] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A data reading method, characterized in that: include: Obtaining a data read request sent by a user terminal, wherein the data read request includes a cursor parameter value, an initial parameter value, a step parameter value, and a direction parameter value, wherein the cursor parameter value is used to determine a corresponding cursor table row set in a database; Determine whether the initial parameter value is within a valid interval, where the valid interval is an interval greater than 0 and not exceeding the total number of rows in the cursor table row set; If it is within the valid interval, the target position corresponding to the initial parameter value is determined in the cursor table row set; based on the target position, the target interval corresponding to the data read request is determined according to the direction parameter value and the step parameter value, and the data in the target interval is returned to the user end.
2. The method according to claim 1, characterized in that Determining the target position corresponding to the initial parameter value in the cursor table row set specifically includes: Performing a halving process on the row set of the cursor table to obtain a partition corresponding to the initial parameter value, and determining whether the number of rows indicated by the partition is consistent with the initial parameter value; When it is determined that the position corresponding to the partition is consistent with the number of rows corresponding to the initial parameter value, the position corresponding to the partition is determined to be the target position; otherwise, the partition corresponding to the initial parameter value is updated.
3. The method according to claim 2, characterized in that Based on the target position, determining the target interval corresponding to the data read request according to the direction parameter value and the step parameter value specifically includes: When the target position is not at the last row of the row set of the cursor table and the direction parameter value is positive, determining that the target position is the starting row number of the target interval, and determining whether the sum of the initial parameter value and the step parameter value is less than the total number of rows; When it is less than the total number of rows, the end number of rows of the target interval is determined to be the sum of the initial parameter value and the step parameter value; otherwise, the end number of rows of the target interval is determined to be the last row of the cursor table row set.
4. The method according to claim 3, characterized in that Also includes: When the target position is not at the last row of the row set of the cursor table and the direction parameter value is reverse, determining that the target position is the starting row number of the target interval, and determining whether the step parameter value is less than the initial parameter value; When it is less than the initial parameter value, the end row number of the target interval is determined to be the difference between the initial parameter value and the step parameter value; otherwise, the end row number of the target interval is determined to be the first row of the cursor table row set.
5. The method according to claim 3, characterized in that: Also includes: When the target position is at the last row of the row set of the cursor table and the direction parameter value is reverse, determining that the starting row number of the target interval is the last row of the row set of the cursor table, and determining whether the step parameter value is less than the total number of rows of the row set of the cursor table; When it is determined that the total number of rows is less than the row set of the cursor table, the end row number of the target interval is determined to be the difference between the total number of rows of the cursor table and the step parameter value; otherwise, the end row number of the target interval is determined to be consistent with the start row number, which is the last row of the row set of the cursor table.
6. The method according to claim 3, characterized in that Also includes: When the target position is at the last row of the cursor table row set and the direction parameter value is positive, an exception message is generated and returned to the user end.
7. A data reading device, characterized in that: include: An acquisition module, used to acquire a data read request sent by a user terminal, wherein the data read request includes a cursor parameter value, an initial parameter value, a step parameter value, and a direction parameter value, and the cursor parameter value is used to determine a corresponding cursor table row set in a database; A processing module, used to determine whether the initial parameter value is within a valid interval, where the valid interval is an interval greater than 0 and not exceeding the total number of rows in the cursor table row set; If it is within the valid interval, the target position corresponding to the initial parameter value is determined in the cursor table row set; based on the target position, the target interval corresponding to the data read request is determined according to the direction parameter value and the step parameter value, and the data in the target interval is returned to the user end.
8. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.