A data storage method, a retrieval method, a processing method, and an apparatus.
By using array and next array data storage methods in remote method calls, combined with storage pointers and call pointers, the performance bottleneck under high concurrency is solved, achieving efficient resource utilization and data processing.
Patent Information
- Application Number
- CN202310324838.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2043-03-29
AI Technical Summary
In existing remote method invocation, intermediate containers such as arrays and linked lists suffer from performance bottlenecks and low scalability under high concurrency, resulting in low resource utilization.
A data storage method is adopted, which uses a pre-set array and the next array, storage pointers and call pointers, combined with sequential encoding and remainder judgment, to achieve continuous data storage and non-blocking communication, avoiding dynamic expansion.
It improves the system's data processing capabilities and resource utilization, especially in scenarios with many asynchronous requirements, by reducing thread switching and improving the system's processing capacity.
Smart Images

Figure CN116431222B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data storage, and in particular to a data storage method, a retrieval method, and a data container. Background Technology
[0002] When making remote method calls, asynchronous processing is a relatively effective way to optimize performance. Asynchronous processing always involves an intermediate container to store the response results of the remote call. The consumer retrieves the response results from the intermediate container according to a certain strategy for subsequent processing. Common intermediate containers include arrays or linked lists, but they all face problems such as low performance and low scalability.
[0003] Arrays need to be expanded and shrunk after reaching a certain size. In high-concurrency situations, messages can easily accumulate, forcing arrays to be expanded frequently. Array expansion also means that elements will be copied, which can easily become a performance bottleneck if there are many elements. Linked lists do not need to deal with the expansion and shrinking problem. The time complexity of insertion and deletion at the head and tail of a linked list is O(1), and the performance is also very good. However, the performance of linked lists is not high when running on actual machines. Linked lists cannot be stored contiguously, so they cannot hit cache lines continuously, which will cause data to be swapped in and out of the high-speed buffer frequently. Therefore, the actual running performance will be significantly different from the expected performance.
[0004] Therefore, there is an urgent need for a data storage method that can improve the system's data processing capabilities and increase resource utilization. Summary of the Invention
[0005] The purpose of this embodiment is to provide a data storage method, a calling method, and a data container to improve the system's data processing capabilities and increase resource utilization.
[0006] To achieve the above objectives, one embodiment of this paper provides a data storage method, including: pre-setting an array containing a predetermined number of elements, the elements being numbered sequentially; setting a storage pointer, the storage pointer pointing to the current element being stored in the array; the storage method includes:
[0007] Receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0008] Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number;
[0009] Determine whether the element in the array whose index is remainder is empty;
[0010] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0011] If not, then allocate a new array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed.
[0012] Preferably, the step of opening the next array further includes:
[0013] The elements in the next array are numbered sequentially, and the next array contains a set number of elements;
[0014] Determine whether the element numbered as remainder in the next array is empty;
[0015] If so, the current data is stored in the next array to the element with the same number as the current element pointed to by the storage pointer, and the storage pointer is moved to the element with the remainder number in the next array.
[0016] Preferably, the array also includes a record element;
[0017] When the next array is allocated, the address of the element with the smallest number in the next array is stored in the record element.
[0018] On the other hand, this embodiment provides a data retrieval method, including: pre-setting an array containing a predetermined number of elements and a next array, wherein the array and the next array are numbered sequentially; setting a retrieval pointer, wherein the retrieval pointer points to the target element in the array that is being retrievald; the retrieval method includes:
[0019] Determine whether the target element pointed to by the call pointer has been marked;
[0020] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0021] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0022] The call pointer moves to the next element.
[0023] Preferably, moving the call pointer to the next element further includes:
[0024] The data stored in the element pointed to by the call pointer or the target element is used as the current data;
[0025] Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number;
[0026] The call pointer points to the element in the array or the next array whose number is the remainder.
[0027] Preferably, the array further includes a record element, which stores the address of the smallest element in the next array.
[0028] On another front, this embodiment provides a data processing method, including: pre-setting an array containing a predetermined number of elements, the elements being numbered sequentially; setting a storage pointer and a call pointer, the storage pointer pointing to the current element being stored in the array, and the call pointer pointing to the target element being called in the array; the processing method includes:
[0029] Receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0030] Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number;
[0031] Determine whether the element in the array whose index is remainder is empty;
[0032] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0033] If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed;
[0034] Determine whether the target element pointed to by the call pointer has been marked;
[0035] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0036] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0037] The call pointer moves to the next element.
[0038] On the other hand, this embodiment provides a data storage device, including: a pre-set array containing a predetermined number of elements, the elements being numbered sequentially; and a storage pointer pointing to the current element being stored in the array; the storage device includes:
[0039] A receiving module is used to receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0040] The calculation module is used to calculate the remainder between the sequential code corresponding to the next data of the current data and the set number;
[0041] The first judgment module is used to determine whether the element numbered as remainder in the array is empty;
[0042] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0043] If not, then allocate a new array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed.
[0044] In another aspect, this embodiment also provides a data retrieval device, including: pre-setting an array containing a predetermined number of elements and a next array, wherein the array and the next array are numbered sequentially; setting a retrieval pointer, wherein the retrieval pointer points to the target element in the array that is being retrieved; the retrieval device includes:
[0045] The second judgment module is used to determine whether the target element pointed to by the call pointer has been marked;
[0046] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0047] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0048] A move module is used to move the call pointer to the next element.
[0049] In another aspect, this embodiment also provides a data processing apparatus, comprising: a pre-set array containing a predetermined number of elements, the elements being numbered sequentially; a storage pointer and a call pointer, the storage pointer pointing to the current element being stored in the array, and the call pointer pointing to the target element being called in the array; the processing apparatus includes:
[0050] A receiving module is used to receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0051] The calculation module is used to calculate the remainder between the sequential code corresponding to the next data of the current data and the set number;
[0052] The first judgment module is used to determine whether the element numbered as remainder in the array is empty;
[0053] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0054] If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed;
[0055] The second judgment module is used to determine whether the target element pointed to by the call pointer has been marked;
[0056] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0057] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0058] A move module is used to move the call pointer to the next element.
[0059] In another aspect, embodiments of this document also provide a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the computer program, when executed by the processor, performs instructions of any of the methods described above.
[0060] In another aspect, embodiments of this document also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor of a computer device, performs instructions according to any one of the methods described above.
[0061] As can be seen from the technical solutions provided in the embodiments of this paper, the storage method described herein combines the advantages of both arrays and linked lists. It possesses the unlimited size and no need for dynamic expansion of linked lists, while the contiguous address space of arrays facilitates continuous cache line hits. Using the method of the embodiments of this paper, asynchronous non-blocking communication can be easily achieved, greatly enhancing the ability to develop distributed application systems. Especially in scenarios with many asynchronous requirements, it allows request sending logic and result processing logic to be distributed across different threads, handling more transactions with fewer threads, thereby improving system processing capacity and resource utilization.
[0062] To make the above and other objects, features and advantages of this document more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0063] To more clearly illustrate the technical solutions in the embodiments or prior art described herein, the accompanying drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this article. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0064] Figure 1 A schematic diagram of the storage structure obtained using the data storage method provided in the embodiments of this article is shown;
[0065] Figure 2 A flowchart illustrating a data storage method provided in an embodiment of this document is shown.
[0066] Figures 3A-3D A schematic diagram illustrating the intermediate process of storage using the storage method provided in the embodiments of this article is shown;
[0067] Figure 4 This document illustrates a flowchart of the process following the allocation of the next array, as provided in the embodiments herein.
[0068] Figure 5 A flowchart illustrating a data retrieval method provided in the embodiments of this article is shown;
[0069] Figure 6 This document illustrates a flowchart of the call pointer moving to the next element, as provided in the embodiments herein.
[0070] Figure 7 This document shows a schematic diagram of the module structure of a data storage device provided in an embodiment.
[0071] Figure 8 This document shows a schematic diagram of the module structure of a data retrieval device provided in an embodiment of the invention;
[0072] Figure 9 A schematic diagram of the structure of the computer device provided in the embodiments of this article is shown.
[0073] Explanation of symbols in the attached drawings:
[0074] 100. Receiver module;
[0075] 200. Calculation module;
[0076] 300. First Judgment Module;
[0077] 400. Second Judgment Module;
[0078] 500. Mobile module;
[0079] 902. Computer equipment;
[0080] 904, Processor;
[0081] 906. Memory;
[0082] 908. Drive mechanism;
[0083] 910. Input / Output Module;
[0084] 912. Input devices;
[0085] 914. Output devices;
[0086] 916. Presentation equipment;
[0087] 918. Graphical User Interface;
[0088] 920. Network interface;
[0089] 922. Communication link;
[0090] 924. Communication bus. Detailed Implementation
[0091] The technical solutions in the embodiments described below will be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments described herein, and not all of the embodiments. Based on the embodiments described herein, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this document.
[0092] Arrays need to be expanded and shrunk after reaching a certain size. In high-concurrency situations, messages can easily accumulate, forcing arrays to be expanded frequently. Array expansion also means that elements will be copied, which can easily become a performance bottleneck if there are many elements. Linked lists do not need to deal with the expansion and shrinking problem. The time complexity of insertion and deletion at the head and tail of a linked list is O(1), and the performance is also very good. However, the performance of linked lists is not high when running on actual machines. Linked lists cannot be stored contiguously, so they cannot hit cache lines continuously, which will cause data to be swapped in and out of the high-speed buffer frequently. Therefore, the actual running performance will be significantly different from the expected performance.
[0093] To address the aforementioned issues, this embodiment provides a data storage method. Figure 2 This is a flowchart illustrating a data storage method provided in the embodiments of this document. This specification provides the operational steps of the method described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only possible execution order. In actual system or device products, the methods shown in the embodiments or drawings can be executed sequentially or in parallel.
[0094] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings herein 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 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 a non-exclusive inclusion; for example, a process, method, apparatus, product, or device 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 devices.
[0095] Reference Figure 2 This embodiment provides a data storage method, including: pre-setting an array containing a predetermined number of elements, the elements being numbered sequentially; setting a storage pointer, the storage pointer pointing to the current element being stored in the array; the storage method includes:
[0096] S101: Receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0097] S102: Calculate the remainder between the sequential code corresponding to the next data of the current data and the set number;
[0098] S103: Determine whether the element numbered as remainder in the array is empty;
[0099] S104: If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element with the remainder number;
[0100] S105: If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed.
[0101] The specific number of elements in the array can be determined based on the actual working conditions, referring to... Figure 1 For example, array 'a' is a pre-defined array with a set number of 4 elements, namely a[0], a[1], a[2], and a[3], numbered 0, 1, 2, and 3 respectively. Initially, all elements are empty, and the storage pointer points to the current element being stored. Initially, it should point to a[0]. Figure 1 As shown, the storage pointer starts from the initial state a[0] and has now been stored up to element b[2].
[0102] Figure 1In an element, the sequential code 0 means that the data stored in that element has a sequential code of 0. The meaning of the sequential code in other elements is the same as that of sequential code 0, and will not be repeated here. The sequential code corresponding to the current data to be stored refers to the order of the current data among all the received data. For example, if the received data to be stored is "2543", "1458", and "8751" in sequence, then the sequential code of "2543" is 0, the sequential code of "1458" is 1, and the sequential code of "8751" is 2.
[0103] To better study the storage method presented in this paper, refer to... Figure 3A Now, suppose we pre-set an array 'a', initially all elements of array 'a' are empty, and the storage pointer points to 'a[0]'. The current data is "2543", and the next data is "1458", with the next data's sequence code being 1. At this point, we need to calculate the remainder between 1 and 4, which is 1 / 4. The remainder is 1. We then determine if the element numbered 1 is empty. Since 'a[1]' is indeed empty, we store the current data "2543" into 'a[0]'. (Refer to...) Figure 3B The storage pointer moves to the element numbered 1, that is, to a[1].
[0104] Each time a piece of current data to be stored is received, steps S101-S105 above will be executed, referring to... Figure 3C Suppose the storage pointer moves to element a[3] with number 3, and the sequential code of the current data to be stored is 3. At this time, 4 / 4 is calculated and the remainder is 0. It is determined whether element with number 0 is empty. However, "2543" has already been stored in a[0], so it is not empty. Then, the next array b is allocated and a[3] is marked to indicate that array a has completed data storage. The specific marking method can be to store an identifier in a[3] or other marking methods. This paper does not limit this.
[0105] Based on the storage method described in this paper, the use of traditional data structures such as arrays and linked lists can be avoided, thus circumventing the performance problems of traditional data structures while simultaneously integrating their advantages. For example, although arrays are contiguous storage structures, they require expansion and contraction after reaching a certain size, and messages can easily accumulate under high concurrency. Linked lists handle expansion and contraction differently; the time complexity for insertion and deletion at the head and tail is O(1), but linked lists are not contiguous storage, resulting in poor actual performance. The storage method in this paper combines the advantages of both arrays and linked lists, possessing the infinite size and no need for dynamic expansion of linked lists, and the contiguous address space of arrays, which facilitates continuous cache line hits. Using the method in the embodiments of this paper, asynchronous non-blocking communication can be easily achieved, greatly enhancing the ability to develop distributed application systems. Especially in scenarios with many asynchronous requirements, the request sending logic and result processing logic can be distributed across different threads, using fewer threads to handle more transactions, thereby improving the system's processing capacity and resource utilization. Using the storage method described in this paper, there is no need to recalculate the position of data in the next array; the position of the corresponding next array can be directly found, which is convenient and fast.
[0106] In the embodiments described herein, reference is made to Figure 4 The process of allocating the next array, followed by:
[0107] S201: Number the elements in the next array sequentially, wherein the next array contains a set number of elements;
[0108] S202: Determine whether the element numbered as remainder in the next array is empty;
[0109] S203: If so, store the current data in the next array to the element with the same number as the current element pointed to by the storage pointer, and move the storage pointer to the element with the remainder number in the next array;
[0110] S203: If not, stop execution.
[0111] Reference Figure 3C The next array b is the same as array a. The number of elements in the next array b is set to 4, that is, b[0], b[1], b[2], b[3], numbered 0, 1, 2, 3 respectively. Initially, all elements are empty. According to the calculation above, the remainder is 0 at this time. It is determined whether the element numbered 0 in the next array b is empty. At this time, b[0] is indeed empty. The current element pointed to by the storage pointer is element a[3], numbered 3. Refer to Figure 3D The current data is stored in the element numbered 3 in the next array b, that is, the current data is stored in b[3]. At this time, the storage pointer moves to the element numbered 0 in the next array b, that is, it moves to the position b[0].
[0112] Since the next array b is a newly created array, the element numbered as remainder in the next array is set to empty. If it is not empty, it means that there is an error in the execution of the logic, so the execution is stopped and the corresponding error correction is performed.
[0113] Since array a has already been stored, upon receiving subsequent data to be stored, the current data is stored in the next array b according to steps S101-S105 above. The next array b serves as the array in steps S101-S105. If the next array b is fully stored, then the next array c is allocated...
[0114] It should be noted that each array has a unique corresponding next array. To ensure continuity between arrays, a record element is also set in the array. When a next array is created, the address of the smallest element in the next array is stored in the record element. The record element is not included in the data storage elements mentioned above, is not within the set number, and is only used to record the address of the smallest element in the next array, that is, the starting address of the next array, so that the arrays form a serpentine chain structure.
[0115] Based on the above data storage method, referring to Figure 5 This embodiment also discloses a data retrieval method, including: pre-setting an array containing a predetermined number of elements and a next array, wherein the array and the next array are numbered sequentially; setting a retrieval pointer, wherein the retrieval pointer points to the target element in the array that is being retrievald; the retrieval method includes:
[0116] S301: Determine whether the target element pointed to by the call pointer has been marked;
[0117] S302: If so, the call pointer moves to the element in the next array whose number matches the target element, and retrieves the data stored in the element pointed to by the call pointer;
[0118] S303: If not, retrieve the data stored in the target element pointed to by the call pointer;
[0119] S304: The call pointer moves to the next element.
[0120] Generally, data is stored in the order a[0], a[1], a[2], a[3], and similarly, it is called in the order a[0], a[1], a[2], a[3]. The application of this calling method assumes that the array and the next array have both completed data storage using the storage method described above or other similar methods. In this case, it is necessary to call the data stored in the array or the next array.
[0121] In the initial state, the pointer points to a[0], which is the target element. It is determined whether a[0] is marked. If it is not marked, the data stored in a[0] can be directly retrieved, and the pointer moves to the next element. If the pointer points to a[3], which is the target element, it is determined whether a[3] is marked. If it is marked, the pointer moves to the next element in the array whose number matches the target element, i.e., moves to b[3]. The data stored in b[3] is retrieved, and the pointer moves to the next element.
[0122] In the embodiments described herein, reference is made to Figure 6 The process of moving the call pointer to the next element further includes:
[0123] S401: Use the data stored in the element pointed to by the call pointer or the target element as the current data;
[0124] S402: Calculate the remainder between the sequential code corresponding to the next data of the current data and the set number;
[0125] S403: The call pointer points to the element numbered as remainder in the array or the next array.
[0126] Based on the two different situations analyzed above, when the target element pointed to by the call pointer is a[0], the data stored in a[0] is the current data. According to the process of analyzing a data storage method in the previous text, the sequential code corresponding to the data stored in a[0] is 0, the sequential code of the next data is 1, the number is set to 4, the remainder of 1 / 4 is 1, and the call pointer moves to the element with the number 1 in array a, that is, a[1].
[0127] When the element pointed to by the call pointer is b[3], the data stored in b[3] is the current data. According to the analysis of a data storage method in the previous text, the sequential code of the data stored in b[3] is 3, the sequential code of the next data is 4, the number is set to 4, the remainder of 4 / 4 is 0, and the call pointer moves to the element with the number 0 of the next array b, that is, the position of b[0].
[0128] In the current embodiment, the array further includes a record element, which stores the address of the smallest element in the next array. This record element is not included in the elements used for data retrieval and is not within the set number. The record element is only used to record the address of the smallest element in the next array, i.e., the starting address of the next array, thus forming a serpentine chain structure between the arrays.
[0129] Based on the data storage method and data retrieval method described above, this embodiment also provides a data processing method, including: pre-setting an array containing a predetermined number of elements, the elements being numbered sequentially; setting a storage pointer and a retrieval pointer, the storage pointer pointing to the current element being stored in the array, and the retrieval pointer pointing to the target element being retrieved in the array; the processing method includes:
[0130] Receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0131] Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number;
[0132] Determine whether the element in the array whose index is remainder is empty;
[0133] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0134] If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed;
[0135] Determine whether the target element pointed to by the call pointer has been marked;
[0136] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0137] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0138] The call pointer moves to the next element.
[0139] The processing method described in this paper can significantly reduce the performance loss caused by inconsistent processing rates between upstream and downstream processes in asynchronous remote communication, especially in scenarios with limited thread resources. By providing different storage containers for different threads, thread switching can be avoided, thereby improving system processing capacity, handling more transactions with fewer threads, and improving resource utilization.
[0140] Based on the data storage method described above, this embodiment also provides a data storage device. The device may include a system (including a distributed system), software (application), module, component, server, client, etc., using the method described in this embodiment, combined with necessary hardware implementation. Based on the same innovative concept, the devices in one or more embodiments provided in this embodiment are as described in the following embodiments. Since the implementation schemes and methods for solving the problem by the devices are similar, the implementation of the specific devices in this embodiment can refer to the implementation of the foregoing method, and repeated details will not be repeated. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0141] Specifically, Figure 7 This is a schematic diagram of the module structure of one embodiment of a data storage device provided in this article, with reference to... Figure 7 As shown in the embodiments herein, a data storage device includes: a pre-set array containing a predetermined number of elements, the elements being numbered sequentially; a storage pointer being set, the storage pointer pointing to the current element being stored in the array; the storage device includes:
[0142] The receiving module 100 is used to receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0143] The calculation module 200 is used to calculate the remainder between the sequential code corresponding to the next data of the current data and the set number;
[0144] The first judgment module 300 is used to determine whether the element numbered as remainder in the array is empty;
[0145] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0146] If not, then allocate a new array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed.
[0147] Reference Figure 8 Based on the data retrieval method described above, this embodiment also provides a data retrieval device, comprising: pre-setting an array containing a predetermined number of elements and a next array, wherein the array and the next array are numbered sequentially; setting a retrieval pointer, wherein the retrieval pointer points to the target element in the array that is being retrievald; the retrieval device includes:
[0148] The second judgment module 400 is used to determine whether the target element pointed to by the call pointer is marked;
[0149] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0150] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0151] The move module 500 is used to move the call pointer to the next element.
[0152] Based on the data processing method described above, this embodiment also provides a data processing apparatus, comprising: a pre-set array containing a predetermined number of elements, the elements being numbered sequentially; a storage pointer and a call pointer, the storage pointer pointing to the current element being stored in the array, and the call pointer pointing to the target element being called in the array; the processing apparatus includes:
[0153] A receiving module is used to receive the current data to be stored and obtain the sequence code corresponding to the current data;
[0154] The calculation module is used to calculate the remainder between the sequential code corresponding to the next data of the current data and the set number;
[0155] The first judgment module is used to determine whether the element numbered as remainder in the array is empty;
[0156] If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder;
[0157] If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed;
[0158] The second judgment module is used to determine whether the target element pointed to by the call pointer has been marked;
[0159] If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved.
[0160] If not, then retrieve the data stored in the target element pointed to by the call pointer;
[0161] A move module is used to move the call pointer to the next element.
[0162] Reference Figure 9As shown, based on the storage method, retrieval method, or processing method described above, one embodiment of this document also provides a computer device 902, wherein the above-described method operates on the computer device 902. The computer device 902 may include one or more processors 904, such as one or more central processing units (CPUs) or graphics processing units (GPUs), each processing unit implementing one or more hardware threads. The computer device 902 may also include any memory 906 for storing any kind of information such as code, settings, data, etc. In one specific embodiment, a computer program is stored on the memory 906 and can run on the processor 904. When the computer program is run by the processor 904, it can execute instructions according to the above-described method. Non-limitingly, for example, the memory 906 may include any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory can use any technology to store information. Further, any memory can provide volatile or non-volatile retention of information. Further, any memory can represent a fixed or removable component of the computer device 902. In one scenario, when processor 904 executes associated instructions stored in any memory or combination of memories, computer device 902 can perform any operation of the associated instructions. Computer device 902 also includes one or more drive mechanisms 908 for interacting with any memory, such as hard disk drive mechanisms, optical disk drive mechanisms, etc.
[0163] Computer device 902 may also include an input / output module 910 (I / O) for receiving various inputs (via input device 912) and providing various outputs (via output device 914). A specific output mechanism may include a presentation device 916 and an associated graphical user interface 918 (GUI). In other embodiments, the input / output module 910 (I / O), input device 912, and output device 914 may be omitted, and the device may function solely as a computer device within a network. Computer device 902 may also include one or more network interfaces 920 for exchanging data with other devices via one or more communication links 922. One or more communication buses 924 couple the components described above together.
[0164] Communication link 922 can be implemented in any way, such as via a local area network (LAN), a wide area network (WAN) (e.g., the Internet), a point-to-point connection, or any combination thereof. Communication link 922 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.
[0165] Corresponding to Figure 2 , Figures 4-6In addition to the methods described above, this embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the above-described methods.
[0166] This embodiment also provides a computer-readable instruction, wherein when a processor executes the instruction, the program therein causes the processor to perform the following: Figure 2 , Figures 4-6 The method shown.
[0167] It should be understood that in the various embodiments of this document, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this document.
[0168] It should also be understood that, in the embodiments herein, the term "and / or" is merely a description of the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following associated objects have an "or" relationship.
[0169] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this document.
[0170] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0171] In the embodiments provided herein, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units 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 couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, devices, or units, or they may be electrical, mechanical, or other forms of connection.
[0172] The units described 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 the embodiments described herein, depending on actual needs.
[0173] Furthermore, the functional units in the various embodiments of this document 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.
[0174] 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 paper, 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 several 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 described in the various embodiments of this paper. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0175] This document uses specific embodiments to illustrate the principles and implementation methods of this document. The descriptions of the embodiments above are only for the purpose of helping to understand the methods and core ideas of this document. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this document. Therefore, the content of this specification should not be construed as a limitation of this document.
Claims
1. A data storage method, characterized in that, include: An array containing a predetermined number of elements is pre-set, the elements are numbered sequentially, and a storage pointer is set to point to the current element being stored in the array; The storage method includes: Receive the current data to be stored and obtain the sequence code corresponding to the current data; Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number; Determine whether the element in the array whose index is remainder is empty; If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder; If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed; The process of allocating the next array also includes: The elements in the next array are numbered sequentially, and the next array contains a set number of elements; Determine whether the element numbered as remainder in the next array is empty; If so, the current data is stored in the next array to the element with the same number as the current element pointed to by the storage pointer, and the storage pointer is moved to the element with the remainder number in the next array.
2. The data storage method according to claim 1, characterized in that, The array also contains one record element; When the next array is allocated, the address of the element with the smallest number in the next array is stored in the record element.
3. A data retrieval method, characterized in that, include: A pre-defined array and a next array, each containing a predetermined number of elements, are provided. These arrays are numbered sequentially. A call pointer is set, pointing to the target element in the array from which the call is being performed. The calling method includes: Determine whether the target element pointed to by the call pointer has been marked; If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved. If not, then retrieve the data stored in the target element pointed to by the call pointer; The call pointer moves to the next element; The process of moving the call pointer to the next element further includes: The data stored in the element pointed to by the call pointer or the target element is used as the current data; Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number; The call pointer points to the element in the array or the next array whose number is the remainder.
4. The data retrieval method according to claim 3, characterized in that, The array also includes a record element, which stores the address of the smallest element in the next array.
5. A data processing method, characterized in that, include: An array containing a predetermined number of elements is pre-set, the elements being numbered sequentially. A storage pointer and a call pointer are set, the storage pointer pointing to the current element being stored in the array, and the call pointer pointing to the target element being called in the array. The processing method includes: Receive the current data to be stored and obtain the sequence code corresponding to the current data; Calculate the remainder between the sequential code of the next data corresponding to the current data and the set number; Determine whether the element in the array whose index is remainder is empty; If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder; If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed; Determine whether the target element pointed to by the call pointer has been marked; If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved. If not, then retrieve the data stored in the target element pointed to by the call pointer; The call pointer moves to the next element.
6. A data storage device, characterized in that, include: An array containing a predetermined number of elements is pre-set, the elements are numbered sequentially, and a storage pointer is set to point to the current element being stored in the array; The storage device includes: A receiving module is used to receive the current data to be stored and obtain the sequence code corresponding to the current data; The calculation module is used to calculate the remainder between the sequential code corresponding to the next data of the current data and the set number; The first judgment module is used to determine whether the element numbered as remainder in the array is empty; If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder; If not, then a new array is created, and the current element pointed to by the storage pointer is marked to indicate that the data storage of the array has been completed; the creation of the new array further includes: numbering the elements in the new array sequentially, the new array containing a set number of elements; determining whether the element numbered as a remainder in the new array is empty; if so, the current data is stored in the new array in the element with the same number as the current element pointed to by the storage pointer, and the storage pointer is moved to the element numbered as a remainder in the new array.
7. A data retrieval device, characterized in that, include: An array and a next array containing a predetermined number of elements are pre-set, the array and the next array are numbered sequentially, and a call pointer is set, the call pointer pointing to the target element in the array that is being called; The calling device includes: The second judgment module is used to determine whether the target element pointed to by the call pointer has been marked; If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved. If not, then retrieve the data stored in the target element pointed to by the call pointer; A movement module is used to move the call pointer to the next element; the movement of the call pointer to the next element further includes: taking the data stored in the element or target element pointed to by the call pointer as the current data; calculating the remainder between the sequential code corresponding to the next data of the current data and the set number; the call pointer points to the element in the array or the next array whose number is the remainder.
8. A data processing apparatus, characterized in that, include: An array containing a predetermined number of elements is pre-set, the elements being numbered sequentially. A storage pointer and a call pointer are set, the storage pointer pointing to the current element being stored in the array, and the call pointer pointing to the target element being called in the array. The processing device includes: A receiving module is used to receive the current data to be stored and obtain the sequence code corresponding to the current data; The calculation module is used to calculate the remainder between the sequential code corresponding to the next data of the current data and the set number; The first judgment module is used to determine whether the element numbered as remainder in the array is empty; If so, the current data is stored in the current element pointed to by the storage pointer, and the storage pointer is moved to the element whose number is the remainder; If not, then allocate the next array and mark the current element pointed to by the storage pointer to indicate that the data storage of the array has been completed; The second judgment module is used to determine whether the target element pointed to by the call pointer has been marked; If so, the pointer is moved to the element in the next array whose number matches the target element, and the data stored in the element pointed to by the pointer is retrieved. If not, then retrieve the data stored in the target element pointed to by the call pointer; A move module is used to move the call pointer to the next element.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, When the computer program is run by the processor, it executes the instructions of the method according to any one of claims 1-5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is run by the processor of the computer device, it executes the instructions of the method according to any one of claims 1-5.
Citation Information
Patent Citations
Data packet processing method and device
CN106789917A
Data processing method and device, computer readable storage medium and electronic equipment
CN112463214A
