Service data storage method and apparatus, computer device, and storage medium
By obtaining the initial index sequence in heap storage technology and determining the storage method based on the length of sub-data, the problem of low resource utilization in traditional heap storage technology is solved and more efficient data storage is achieved.
Patent Information
- Application Number
- PCT/CN2023/129235
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-14
- Filing Date
- 2023-11-02
- Publication Date
- 2024-09-19
AI Technical Summary
Traditional heap storage technology has low resource utilization when storing massive amounts of variable-length data, resulting in resource waste and low efficiency.
By obtaining the initial index sequence of the target business data, the storage method of the sub-data is determined. If the data length is less than or equal to the index space length, it is written directly into the index space. If the data length exceeds, it is written into the heap space and the pointer is recorded. The index sequence is updated to Improve resource utilization.
It effectively improves resource utilization, avoids unnecessary resource allocation, and improves the flexibility and efficiency of data storage.
Smart Images

Figure CN2023129235_19092024_PF_FP_ABST
Abstract
Description
Business data storage method, device, computer equipment and storage medium
[0001] Related applications
[0002] This application claims priority to Chinese patent application number 2023103111471, filed on March 14, 2023, entitled “Business data storage method, device, computer equipment and storage medium,” the entire text of which is hereby incorporated by reference. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to a business data storage method, apparatus, computer equipment, storage medium, and computer program product. Background Art
[0004] With the development of data storage technology, heap storage technology has emerged. It stores massive amounts of data of different lengths in a heap and records the index corresponding to each data. The index stores the pointer corresponding to the data in the heap. The value of the data can be obtained by accessing the heap through the pointer.
[0005] However, using traditional heap storage technology and blindly storing data in the heap will lead to low resource utilization.
[0006] Summary of the Invention
[0007] This application provides a business data storage method. The method includes:
[0008] Obtain the initial index sequence corresponding to the target business data;
[0009] Determine target sub-data from each sub-business data included in the target business data, and use the index space corresponding to the target sub-data in the initial index sequence as the target index space;
[0010] When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is written into the target index space to obtain the target index sequence;
[0011] When the target data length corresponding to the target sub-data is greater than the space data length of the target index space, the target sub-data is written into the target heap space corresponding to the target business data, the target pointer corresponding to the target sub-data is obtained, and the target pointer is written into the target index space to obtain the target index sequence.
[0012] The present application also provides a business data storage device. The device includes:
[0013] An index sequence acquisition module is used to obtain the initial index sequence corresponding to the target business data;
[0014] a target sub-data determining module, configured to determine target sub-data from each sub-business data contained in the target business data, and use the index space corresponding to the target sub-data in the initial index sequence as the target index space;
[0015] A target sub-data storage module is configured to write the target sub-data into the target index space to obtain a target index sequence when the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space;
[0016] The target sub-data storage module is also used to write the target sub-data into the target heap space corresponding to the target business data when the target data length corresponding to the target sub-data is greater than the space data length of the target index space, obtain the target pointer corresponding to the target sub-data, write the target pointer into the target index space, and obtain the target index sequence.
[0017] A computer device includes a memory and a processor, wherein the memory stores a computer program and the processor implements the steps of the above-mentioned business data storage method when executing the computer program.
[0018] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned business data storage method when executed by a processor.
[0019] A computer program product includes a computer program, which implements the steps of the above-mentioned business data storage method when executed by a processor.
[0020] The details of one or more embodiments of the present application are set forth in the following drawings and description. Other features, objects, and advantages of the present application will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the conventional technology, the following briefly introduces the drawings required for use in the embodiments or the conventional technology descriptions. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the disclosed drawings without any creative work.
[0022] FIG1 is a diagram illustrating an application environment of a business data storage method according to an embodiment;
[0023] FIG2 is a schematic diagram of a process flow of a method for storing business data in one embodiment;
[0024] FIG3 is a schematic diagram of a process for determining the length of spatial data in one embodiment;
[0025] FIG4 is a schematic diagram of business data storage in one embodiment;
[0026] FIG5 is a schematic diagram of business data storage in another embodiment;
[0027] FIG6 is a structural block diagram of a service data storage device according to an embodiment;
[0028] FIG7 is a structural block diagram of a service data storage device in another embodiment;
[0029] FIG8 is a diagram showing the internal structure of a computer device according to one embodiment;
[0030] FIG9 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0032] The business data storage method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart TVs, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers. The terminal 102 and the server 104 can be directly or indirectly connected through wired or wireless communication, and this application does not limit this.
[0033] Both the terminal and the server can be used independently to execute the business data storage method provided in the embodiments of the present application.
[0034] For example, the terminal obtains the initial index sequence corresponding to the target business data. The terminal determines the target sub-data from the various sub-business data contained in the target business data, and uses the index space corresponding to the target sub-data in the initial index sequence as the target index space. When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the terminal writes the target sub-data into the target index space to obtain the target index sequence. When the target data length corresponding to the target sub-data is greater than the spatial data length of the target index space, the terminal writes the target sub-data into the target heap space corresponding to the target business data, obtains the target pointer corresponding to the target sub-data, writes the target pointer into the target index space, and obtains the target index sequence.
[0035] The terminal and the server can also be used together to execute the business data storage method provided in the embodiments of the present application.
[0036] For example, the terminal sends a business data storage request carrying the target business data identifier to the server, and the server obtains the initial index sequence corresponding to the target business data based on the target business data identifier. The server determines the target sub-data from the various sub-business data contained in the target business data, and uses the index space corresponding to the target sub-data in the initial index sequence as the target index space. When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the server writes the target sub-data into the target index space to obtain the target index sequence. When the target data length corresponding to the target sub-data is greater than the spatial data length of the target index space, the server writes the target sub-data into the target heap space corresponding to the target business data, obtains the target pointer corresponding to the target sub-data, writes the target pointer into the target index space, and obtains the target index sequence. The server returns the business data storage result to the terminal.
[0037] In one embodiment, as shown in FIG2 , a method for storing business data is provided. This method is described using a computer device as an example. The computer device may be a terminal or a server. The method may be executed independently by the terminal or server itself, or may be implemented through interaction between the terminal and the server. The method for storing business data includes the following steps:
[0038] Step S202: Acquire an initial index sequence corresponding to the target business data.
[0039] Business data refers to a business object containing a large amount of sub-business data to be stored. For example, a business object could be an information registration form, where the data in the cells is the sub-business data; a business object could be a document, where the individual data to be stored is the sub-business data; and so on. Target business data refers to the business data that requires data storage. An index sequence is a sequence consisting of the index spaces corresponding to each sub-business data in the target business data. An initial index sequence refers to the index sequence corresponding to the target business data before the target sub-data is stored.
[0040] Exemplarily, when using a heap storage solution to store target business data, first, a corresponding storage space is allocated for the target sub-data in the heap, and then the target sub-data is written into the corresponding storage space in the heap, and the pointer corresponding to the storage space is written into the target index space corresponding to the target business data in the initial index sequence. However, when the target business data contains a large amount of sub-business data of variable length, that is, the data length of the sub-business data is not fixed, and there is a large amount of sub-business data whose data length is less than or equal to the index space length, blindly storing the sub-business data in the heap will cause a waste of resources. Therefore, when performing a storage operation on the target business data, the computer device first obtains the initial index sequence corresponding to the target business data, and then compares the spatial data length of the target index space in the initial index sequence with the target data length of the target sub-data to determine the storage method corresponding to the target sub-data, so that the target sub-data can be stored in the corresponding storage method.
[0041] Step S204 : determining target sub-data from the sub-business data included in the target business data, and using the index space corresponding to the target sub-data in the initial index sequence as the target index space.
[0042] Among them, the target sub-data refers to the sub-business data determined from the various sub-business data contained in the target business data and requiring data storage operations. The index space refers to the storage space used to store pointers corresponding to the sub-business data or directly store the sub-business data. When performing data queries, when the data stored in the index space is a pointer, the corresponding sub-business data can be read in the heap through the pointer stored in the index space. When the data stored in the index space is sub-business data, the sub-business data can be read directly in the index space. The target index space refers to the index space corresponding to the target sub-data.
[0043] Exemplarily, when the target business data has a corresponding sub-business data storage sequence, the computer device determines the target sub-data from each sub-business data contained in the target business data according to the sub-business data storage sequence. When the target business data does not have a corresponding sub-business data storage sequence, any sub-business data from each sub-business data to be stored contained in the target business data is used as the target sub-data. Furthermore, an index space corresponding to the target sub-data is determined in the initial index sequence, and this index space is used as the target index space corresponding to the target sub-data.
[0044] Step S206 : When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is written into the target index space to obtain a target index sequence.
[0045] The target data length refers to the data length of the target sub-data. For example, when the target sub-data is character data, the target data length is 1 byte; when the target sub-data is integer data, the target data length is 4 bytes. The space data length refers to the size of the storage space occupied by the index space. For example, the space data length of the target index space can be 4 bytes, 8 bytes, etc. The target index sequence refers to the index sequence obtained after performing a storage operation on the target sub-data, that is, after updating the target index space in the initial index sequence based on the target sub-data.
[0046] Exemplarily, the target data length of the target sub-data is compared with the spatial data length of the target index space. If the target data length is less than or equal to the spatial data length of the target index space, the target sub-data is directly written into the target index space to obtain an updated target index sequence. The target sub-data is then determined within each sub-business data contained within the target business data, and the process returns to the step of obtaining the initial index sequence corresponding to the target business data until all sub-business data contained within the target business data have been written into the corresponding storage space.
[0047] In one embodiment, the security level corresponding to the target sub-data is obtained. If the target data length of the target sub-data is less than or equal to the space data length and the security level of the target sub-data is less than a preset security level, the target sub-data is stored in the target index space. If the security level of the target sub-data is greater than or equal to the preset level, the target sub-data is stored in the target heap space corresponding to the target business data. A corresponding security level is set for each sub-business data contained in the target business data, and the corresponding storage method is determined based on the security level and data length corresponding to each sub-business data. This improves resource utilization while ensuring data storage security.
[0048] In one embodiment, the access level corresponding to the target sub-data is obtained. The access level is used to characterize the frequency with which the target sub-data is accessed. If the target sub-data is data that needs to be accessed frequently, the access level corresponding to the target sub-data is higher. The security level corresponding to the target sub-data is obtained. When the target data length of the target sub-data is less than or equal to the space data length, and the access level corresponding to the target sub-data is greater than or equal to the preset access level, the target sub-data is stored in the target index space, thereby improving the query speed and improving resource utilization. When the target data length of the target sub-data is less than or equal to the space data length, the access level corresponding to the target sub-data is less than the preset access level, and the security level corresponding to the target sub-data is greater than or equal to the preset security level, the target sub-data is stored in the target heap space, thereby improving the security of the target sub-data. When the target data length of the target sub-data is less than or equal to the space data length, the security level corresponding to the target sub-data is less than the preset security level, and the access level corresponding to the target sub-data is less than the preset access level, the target sub-data is stored in the target index space, thereby improving the query speed and improving resource utilization. Corresponding security levels and access levels are set for each sub-business data contained in the target business data, and the corresponding storage method is determined according to the security level, access level and data length corresponding to different sub-business data. In this way, the security needs and access needs corresponding to different sub-business data are comprehensively considered during data storage, effectively improving the flexibility of data storage.
[0049] Step S208, when the target data length corresponding to the target sub-data is greater than the space data length of the target index space, the target sub-data is written into the target heap space corresponding to the target business data, and the target pointer corresponding to the target sub-data is obtained. The target pointer is written into the target index space to obtain the target index sequence.
[0050] The target heap space refers to the heap storage space allocated for the target business data. The target pointer refers to the first address of the storage space corresponding to the target sub-data in the target heap space. For example, if the target sub-data is the first sub-data stored in the target heap space, the target pointer corresponding to the target sub-data is 0. If the data length of the target sub-data is 4 bytes, the target pointer corresponding to the second sub-data stored in the target heap space is 4.
[0051] Exemplarily, the target data length of the target sub-data and the spatial data length of the target index space are compared. When the target data length is greater than the spatial data length of the target index space, the computer device allocates corresponding storage space for the target sub-data in the heap as the target heap space corresponding to the target sub-data. The target sub-data is written into the target heap space, and the target pointer corresponding to the target heap space is written into the target index space to obtain a target index sequence. The target sub-data is continuously determined in each sub-business data contained in the target business data, and the step of obtaining the initial index sequence corresponding to the target business data is returned to and executed until all sub-business data contained in the target business data are written into the corresponding storage space.
[0052] In the above-mentioned business data storage method, by obtaining the initial index sequence corresponding to the target business data, and determining the target sub-data from the various sub-business data contained in the target business data, the index space corresponding to the target sub-data in the initial index sequence is used as the target index space. When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is written into the target index space to obtain a target index sequence. When the target data length corresponding to the target sub-data is greater than the spatial data length of the target index space, the target sub-data is written into the target heap space corresponding to the target business data to obtain a target pointer corresponding to the target sub-data, and the target pointer is written into the target index space to obtain a target index sequence. In this way, when the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is directly written into the target index space without allocating corresponding heap space for the target sub-data, which can avoid opening up unnecessary resource space and effectively improve resource utilization.
[0053] In one embodiment, the business data storage method further includes:
[0054] The data length corresponding to each sub-business data is counted to obtain the estimated data length corresponding to the target business data; and the spatial data length is determined based on the estimated data length.
[0055] The estimated data length refers to the length of the storage space required to store each sub-business data included in the target business data.
[0056] Exemplarily, the computer device counts the data lengths corresponding to the sub-business data contained in the target business data, calculates the sum of the data lengths corresponding to the sub-business data, and obtains the estimated data length corresponding to the target business data. The spatial data length corresponding to the index space is calculated based on the estimated data length. For example, the spatial data length corresponding to the index space of the target business data is usually 4 bytes or 8 bytes. When the spatial data length is 4 bytes, the corresponding maximum addressing range is 2 31-1, when the space data length is 8 bytes, the corresponding maximum addressing range is 2 63 -1, if the expected data length is 2 30 Bytes, the space data length can be set to 4 bytes. If the expected data length is 2 40 When the space data length is 8 bytes, the space data length can be set to 8 bytes.
[0057] In one embodiment, the computer device determines the length of each candidate data corresponding to the index space based on the expected data length. The candidate data length refers to the length of each candidate space data corresponding to the index space. The maximum addressing range corresponding to the candidate data length is greater than the expected data length, and the maximum value of the candidate data length is 8 bytes. In order to improve resource utilization, the minimum value among the candidate data lengths is used as the space data length. For example, when the expected data length is 2 30 Bytes, the lengths of candidate data corresponding to the index space are 4 bytes, 5 bytes, 6 bytes, 7 bytes and 8 bytes respectively, and the space data length is set to 4 bytes; when the expected data length is 2 50 Bytes, the lengths of the candidate data corresponding to the index space are 7 bytes and 8 bytes respectively, and the space data length is set to 7 bytes.
[0058] In one embodiment, the space data length corresponding to the target business data can be manually set. Specifically, the space data length required for the target business data is determined by judging the business type to which the target business data belongs. For example, when the maximum storage space size required for the business type to which the target business data belongs is less than 2 31 -1 byte, the space data length corresponding to the target business data can be manually set to 4 bytes; when the maximum storage space required by the business type to which the target business data belongs is greater than 2 31 -1 byte, the spatial data length corresponding to the target business data can be manually set to 8 bytes; and so on.
[0059] In the above embodiment, the expected data length corresponding to the target business data is determined by counting the data lengths corresponding to each sub-business data, and the spatial data length corresponding to the index space is determined based on the expected data length, which can effectively save the storage resources of the computer equipment and improve resource utilization.
[0060] In one embodiment, as shown in FIG3 , determining the spatial data length based on the expected data length includes:
[0061] Step S302 , performing binary conversion on the estimated data length to obtain a conversion result, and obtaining the initial data length based on the conversion result.
[0062] Step S304: Obtain the reference data length, and determine the extended length range based on the reference data length and the initial data length.
[0063] Step S306 , among the sub-service data corresponding to the target service data, the sub-service data whose statistical data length is within the extended length range is counted to obtain the extended sub-data volume.
[0064] Step S308: Count the sub-business data included in the target business data to obtain the target sub-data volume.
[0065] Step S310 : When the ratio between the expanded sub-data size and the target sub-data size is greater than a preset ratio, the initial data length is updated based on the reference data length to obtain the spatial data length.
[0066] The conversion result refers to the result obtained by converting the expected data length into binary.
[0067] The initial data length refers to the initial spatial data length corresponding to the index space determined based on the expected data length. The reference data length refers to the data length used to extend the initial data length. The reference data length is greater than or equal to the initial data length. For example, the reference data length can usually be set to 8 bytes. The extended length range refers to the data length range determined by the initial data length and the reference data length. The initial data length is the lower limit of the extended length range, and the reference data length is the upper limit of the extended length range. The extended length range includes the reference data length. For example, when the initial data length is 2 bytes and the reference data length is 4 bytes, the extended length range is (2,4]. The extended sub-data volume refers to the number of sub-business data whose data length is within the extended length range. The target sub-data volume refers to the number of sub-business data contained in the target business data.
[0068] Exemplarily, the expected data length is converted into binary to obtain a conversion result, and the initial data length corresponding to the index space is determined based on the number of bits of the conversion result. For example, when the expected data length is 255 bytes, the conversion result obtained by converting 255 into binary is 1111 1111, and the number of bits corresponding to the conversion result is 8 bits. Therefore, the initial data length should be greater than or equal to 1 byte. For example, the initial data length can be set to 1 byte or 2 bytes. The reference data length is obtained. When the initial data length is less than the reference data length, the extended length range is determined based on the initial data length and the reference data length. Among the various sub-business data included in the target business data, the statistical data length of each sub-business data within the extended length range is counted to obtain the extended sub-data volume. The statistical data of each sub-business data included in the target business data is obtained to obtain the target sub-data volume. The ratio between the extended sub-data volume and the target sub-data volume is calculated. When the ratio is greater than or equal to the preset ratio, the initial data length is updated with the reference data length to obtain the space data length. For example, the preset ratio can be set to 0.5, that is, when the data length of 50% or more of the sub-business data in the target business data is within the extended length range, the initial data length is updated with the reference data length. For example, when the reference data length is 8 bytes and the initial data length is 4 bytes, the initial data length is updated to 8 bytes.
[0069] In the above embodiment, the amount of sub-data to be expanded is determined by counting sub-service data within the extended length range. When the ratio of the amount of sub-data to be expanded to the target sub-data amount exceeds a preset threshold, it indicates that a large amount of sub-service data with shorter data lengths still needs to be stored in the heap space. At this point, the initial data length is updated based on the reference data length, allowing all sub-service data within the extended length range to be directly written into the index space, further improving resource utilization.
[0070] In one embodiment, the business data storage method further includes:
[0071] In the target index sequence, based on the storage mode corresponding to the target sub-data, the target flag bit corresponding to the target index space is updated; the storage mode includes heap space storage and index space storage, and the target flag bit is used to represent the storage mode corresponding to the target sub-data.
[0072] Among them, the mark bit refers to the storage space in the index sequence used to record the storage method corresponding to each sub-data. For example, as shown in Figure 4, the mark bit can be located before the index space and occupy 1 byte. When the mark bit corresponding to the sub-data is 1, it indicates that the storage method corresponding to the sub-data is index space storage, that is, pointer space storage. When the mark bit corresponding to the sub-data is 0, it indicates that the storage method corresponding to the sub-data is heap space storage, that is, heap storage. The target mark bit refers to the mark bit corresponding to the target sub-data in the target index sequence. Heap space storage refers to allocating corresponding storage space for the sub-data in the heap as the heap space corresponding to the sub-data, and storing the sub-data in the heap space. Index space storage refers to storing the sub-data directly in the corresponding index space.
[0073] Exemplarily, the computer device updates the target flag bit corresponding to the target index space based on the storage mode corresponding to the target sub-data. For example, it may be specified that when the storage mode corresponding to the target sub-data is index space storage, the target flag bit corresponding to the target sub-data is set to 1, and when the storage mode corresponding to the target sub-data is heap space storage, the target flag bit corresponding to the target sub-data is set to 0.
[0074] In one embodiment, the target flag bit corresponding to the target index space may be stored outside the target index sequence. For example, a flag bit sequence may be established, and the flag bits corresponding to each index space may be stored in the flag bit sequence.
[0075] In the above embodiment, based on the storage method corresponding to the target sub-data, the target flag bit corresponding to the target sub-data is updated, so that when performing data query, the storage method corresponding to the target sub-data can be determined according to the target flag bit, and then the target sub-data can be queried from the corresponding storage space based on the storage method corresponding to the target sub-data, thereby ensuring the reliability of data query.
[0076] In one embodiment, the business data storage method further includes:
[0077] Obtain a sub-data query request, wherein the sub-data query request carries a data identifier corresponding to the sub-data to be queried; based on the data identifier, obtain a current index sequence corresponding to the business data to which the sub-data to be queried belongs; based on the data identifier, determine the index space to be queried corresponding to the sub-data to be queried in the current index sequence; based on the to-be-queried flag bit corresponding to the index space to be queried, determine the storage method corresponding to the sub-data to be queried; based on the storage method corresponding to the sub-data to be queried, read the sub-data to be queried from the corresponding storage space, and return the sub-data to be queried to the querying party corresponding to the sub-data query request.
[0078] Among them, the sub-data query request refers to the query request corresponding to the sub-data to be queried in the target business data. The sub-data to be queried refers to the sub-business data queried by the sub-data query request. The data identifier refers to the identifier corresponding to the sub-data to be queried, which can indicate the current index sequence corresponding to the sub-data to be queried, and the index space to be queried corresponding to the sub-data to be queried in the current index sequence. The current index sequence refers to the index sequence corresponding to the business data to which the sub-data to be queried belongs. The index space to be queried refers to the index space corresponding to the sub-data to be queried in the current index sequence. The mark bit to be queried refers to the mark bit of the index space to be queried corresponding to the sub-data to be queried. The query party corresponding to the sub-data query request refers to the computer device that issues the sub-data query request, and the query party can be a terminal or a server.
[0079] Exemplarily, the computer device receives a sub-data query request sent by a querying party and, based on the data identifier carried in the sub-data query request, searches the current index sequence corresponding to the business data to which the sub-data to be queried belongs. The computer device then uses the data identifier to determine the to-be-queried index space corresponding to the sub-data to be queried within the current index sequence. Based on the to-be-queried flag corresponding to the to-be-queried index space, the computer device determines the storage method corresponding to the sub-data to be queried. Furthermore, based on the storage method corresponding to the sub-data to be queried and the to-be-queried index space, the computer device determines the storage space corresponding to the sub-data to be queried, reads the sub-data to be queried from the corresponding storage space, and returns the retrieved sub-data to the querying party corresponding to the sub-data query request.
[0080] In the above embodiment, the sub-data query request carries the data identifier corresponding to the sub-data to be queried, and the index space to be queried corresponding to the sub-data to be queried is determined based on the data identifier, and then the storage method corresponding to the sub-data to be queried is determined based on the to-be-queried mark bit corresponding to the index space, and then the sub-data to be queried is read from the corresponding storage space based on the storage method corresponding to the sub-data to be queried, which can ensure the reliability of the data query.
[0081] In one embodiment, based on the storage mode corresponding to the sub-data to be queried, reading the sub-data to be queried from the corresponding storage space includes:
[0082] When the storage method corresponding to the sub-data to be queried is heap space storage, based on the pointer stored in the index space to be queried, the storage space to be queried in the corresponding heap space to be queried of the sub-data to be queried is determined, and the sub-data to be queried is read from the storage space to be queried; when the storage method corresponding to the sub-data to be queried is index space storage, the sub-data to be queried is read from the index space to be queried.
[0083] The heap space to be queried refers to the heap storage space allocated for the target business data to which the sub-data to be queried belongs. The storage space to be queried refers to the storage space in the heap space to be queried that stores the sub-data to be queried.
[0084] Exemplarily, when the storage method corresponding to the sub-data to be queried is heap space storage, a pointer corresponding to the sub-data to be queried is obtained from the index space to be queried. Using this pointer, the storage space corresponding to the sub-data to be queried is determined within the heap space to be queried corresponding to the sub-data to be queried, and the sub-data to be queried is read from the storage space to be queried. When the storage method corresponding to the sub-data to be queried is index space storage, the sub-data to be queried is read from the index space to be queried corresponding to the sub-data to be queried.
[0085] In the above embodiment, when the storage method corresponding to the sub-data to be queried is index space storage, the sub-data to be queried is read directly from the index space to be queried corresponding to the sub-business data to be queried, thereby reducing the time overhead of locating the storage space to be queried corresponding to the sub-data to be queried based on the pointer and improving the efficiency of data query.
[0086] In one embodiment, the target business data is a target table, and the target sub-data is target cell data.
[0087] The target table refers to the table where data needs to be stored, and the target table contains a large amount of cell data of indeterminate length. The target cell data refers to the data stored in the cells of the target table.
[0088] In a specific embodiment, the business data storage method of the present application can be applied to data stored in a table. The business data storage method includes the following steps:
[0089] 1. Get the index sequence corresponding to the target table
[0090] The computer device obtains an initial index sequence corresponding to the target table and obtains the spatial data length of the index space in the initial index sequence.
[0091] 2. Determine the target cell data and target index space
[0092] The computer device determines target cell data from each cell data contained in the target table, and uses the index space corresponding to the target cell data in the initial index sequence as the target index space.
[0093] 3. Store target cell data
[0094] As shown in Figure 5, when the data length corresponding to the target cell data is less than or equal to the spatial data length of the index space, the target cell data is written to the target index space, i.e., stored in the pointer space, and the flag bit corresponding to the target index space is updated to obtain the target index sequence. When the data length corresponding to the target cell data is greater than the spatial data length of the index space, the target cell data and the corresponding data length are written to the target heap space corresponding to the target table to obtain the target pointer corresponding to the target cell data. The target pointer is then written to the target index space to obtain the target index sequence.
[0095] In the above embodiment, when a large amount of cell data with a data length less than or equal to the index space length exists in the target table, such cell data is directly stored in the corresponding index space, fully utilizing the index space, and a flag is used to indicate whether the data is stored directly in the index space or in the heap. This can greatly improve resource utilization and reduce resource waste. Furthermore, storing cell data at the index reduces the need for pointer-based storage space lookups when querying data, i.e., reduces the time overhead of locating the corresponding storage space for the cell data in the heap based on the pointer, thereby improving data reading performance and making the program more efficient.
[0096] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0097] Based on the same inventive concept, embodiments of the present application also provide a business data storage device for implementing the aforementioned business data storage method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more business data storage device embodiments provided below can be found in the aforementioned limitations of the business data storage method and will not be further elaborated here.
[0098] In one embodiment, as shown in FIG6 , a business data storage device is provided, including: an index sequence acquisition module 602 , a target sub-data determination module 604 , and a target sub-data storage module 606 , wherein:
[0099] The target sub-data determining module is used to determine the target sub-data from the various sub-business data included in the target business data, and use the index space corresponding to the target sub-data in the initial index sequence as the target index space.
[0100] The target sub-data storage module is used to write the target sub-data into the target index space to obtain the target index sequence when the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space.
[0101] The target sub-data storage module is also used to write the target sub-data into the target heap space corresponding to the target business data when the target data length corresponding to the target sub-data is greater than the space data length of the target index space, obtain the target pointer corresponding to the target sub-data, write the target pointer into the target index space, and obtain the target index sequence.
[0102] The above-mentioned business data storage device obtains the initial index sequence corresponding to the target business data, determines the target sub-data from the various sub-business data contained in the target business data, and uses the index space corresponding to the target sub-data in the initial index sequence as the target index space. When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is written into the target index space to obtain a target index sequence. When the target data length corresponding to the target sub-data is greater than the spatial data length of the target index space, the target sub-data is written into the target heap space corresponding to the target business data to obtain a target pointer corresponding to the target sub-data, and the target pointer is written into the target index space to obtain a target index sequence. In this way, when the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is directly written into the target index space without allocating corresponding heap space for the target sub-data, which can avoid opening up unnecessary resource space and effectively improve resource utilization.
[0103] In one embodiment, as shown in FIG7 , the service data storage device further includes:
[0104] The spatial data length determination module 702 is used to count the data lengths corresponding to each sub-service data to obtain the estimated data length corresponding to the target service data; and determine the spatial data length based on the estimated data length.
[0105] The target flag bit update module 704 is used to update the target flag bit corresponding to the target index space in the target index sequence based on the storage method corresponding to the target sub-data; the storage method includes heap space storage and index space storage, and the target flag bit is used to represent the storage method corresponding to the target sub-data.
[0106] The query request response module 706 is used to obtain a sub-data query request, wherein the sub-data query request carries a data identifier corresponding to the sub-data to be queried; based on the data identifier, obtain the current index sequence corresponding to the business data to which the sub-data to be queried belongs; based on the data identifier, determine the index space to be queried corresponding to the sub-data to be queried in the current index sequence; based on the to-be-queried flag bit corresponding to the index space to be queried, determine the storage method corresponding to the sub-data to be queried; based on the storage method corresponding to the sub-data to be queried, read the sub-data to be queried from the corresponding storage space, and return the sub-data to be queried to the query party corresponding to the sub-data query request.
[0107] In one embodiment, the spatial data length determination module 702 is further configured to:
[0108] Perform binary conversion on the expected data length to obtain a conversion result, and obtain the initial data length based on the conversion result; obtain the reference data length, and determine the extended length range based on the reference data length and the initial data length; among the sub-business data corresponding to the target business data, count the sub-business data whose statistical length is within the extended length range to obtain the extended sub-data volume; count the sub-business data included in the target business data to obtain the target sub-data volume; when the ratio between the extended sub-data volume and the target sub-data volume is greater than the preset ratio, update the initial data length based on the reference data length to obtain the spatial data length.
[0109] In one embodiment, the query request response module 706 is further configured to:
[0110] When the storage method corresponding to the sub-data to be queried is heap space storage, based on the pointer stored in the index space to be queried, the storage space to be queried in the corresponding heap space to be queried of the sub-data to be queried is determined, and the sub-data to be queried is read from the storage space to be queried; when the storage method corresponding to the sub-data to be queried is index space storage, the sub-data to be queried is read from the index space to be queried.
[0111] Each module in the above-mentioned business data storage device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor of the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0112] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in Figure 8. The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, memory, and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data such as an initial index sequence and target sub-data. The I / O interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a business data storage method is implemented.
[0113] In one embodiment, a computer device is provided, which may be a terminal. Its internal structure diagram may be shown in Figure 9. The computer device includes a processor, memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals via wired or wireless communication, where the wireless communication may be achieved via Wi-Fi, a mobile cellular network, NFC (near-field communication), or other technologies. When executed by the processor, the computer program implements a method for storing business data. The display unit of the computer device is used to produce a visually visible image and may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse.
[0114] Those skilled in the art will understand that the structures shown in Figures 8 and 9 are merely block diagrams of partial structures related to the solution of the present application, and do not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figures, or combine certain components, or have a different component arrangement.
[0115] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0117] In one embodiment, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of each of the above-described method embodiments.
[0118] 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, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0119] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0120] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0121] The above-mentioned embodiments only express several implementation methods of the present application. The description is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present application. It should be pointed out that for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present application, and these all fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the appended claims.
Claims
1. A method for storing business data, the method comprising: Obtain the initial index sequence corresponding to the target business data; Determine target sub-data from each sub-service data included in the target service data, and use the index space corresponding to the target sub-data in the initial index sequence as the target index space; When the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space, the target sub-data is written into the target index space to obtain a target index sequence; as well as When the target data length corresponding to the target sub-data is greater than the space data length of the target index space, the target sub-data is written into the target heap space corresponding to the target business data, and the target pointer corresponding to the target sub-data is obtained. The target pointer is written into the target index space to obtain a target index sequence.
2. The method according to claim 1, wherein: The method further comprises: Counting the data lengths corresponding to the sub-service data to obtain the estimated data length corresponding to the target service data; and The spatial data length is determined based on the expected data length.
3. The method according to claim 2, wherein: The determining the spatial data length based on the expected data length comprises: Performing binary conversion on the estimated data length to obtain a conversion result, and obtaining an initial data length based on the conversion result; Acquire a reference data length, and determine an extended length range based on the reference data length and the initial data length; In the sub-service data corresponding to the target service data, the sub-service data whose statistical data length is within the extended length range is counted to obtain the extended sub-data volume; Counting the sub-service data included in the target service data to obtain a target sub-data volume; and When the ratio between the extended sub-data amount and the target sub-data amount is greater than a preset ratio, the initial data length is updated based on the reference data length to obtain the spatial data length.
4. The method according to claim 1, wherein: The method further comprises: In the target index sequence, based on the storage method corresponding to the target sub-data, the target mark bit corresponding to the target index space is updated; the storage method includes heap space storage and index space storage, and the target mark bit is used to characterize the storage method corresponding to the target sub-data.
5. The method according to claim 1, wherein: The method further comprises: Obtaining a sub-data query request, wherein the sub-data query request carries a data identifier corresponding to the sub-data to be queried; Based on the data identifier, obtaining a current index sequence corresponding to the business data to which the sub-data to be queried belongs; Based on the data identifier, determining the to-be-queried index space corresponding to the to-be-queried sub-data in the current index sequence; Determining a storage mode corresponding to the sub-data to be queried based on the to-be-queried mark corresponding to the to-be-queried index space; and Based on the storage mode corresponding to the sub-data to be queried, the sub-data to be queried is read from the corresponding storage space, and the sub-data to be queried is returned to the querying party corresponding to the sub-data query request.
6. The method according to claim 5, wherein: The reading the sub-data to be queried from the corresponding storage space based on the storage mode corresponding to the sub-data to be queried includes: When the storage mode corresponding to the sub-data to be queried is heap space storage, determining the storage space to be queried of the sub-data to be queried in the corresponding heap space to be queried based on the pointer stored in the index space to be queried, and reading the sub-data to be queried from the storage space to be queried; and When the storage mode corresponding to the sub-data to be queried is index space storage, the sub-data to be queried is read from the index space to be queried.
7. The method according to any one of claims 1 to 6, wherein: The target business data is a target table, and the target sub-data is target cell data.
8. A business data storage device, the device comprising: An index sequence acquisition module is used to acquire an initial index sequence corresponding to target business data; A target sub-data determination module, configured to determine target sub-data from each sub-service data included in the target service data, and use the index space corresponding to the target sub-data in the initial index sequence as the target index space; A target sub-data storage module, configured to write the target sub-data into the target index space to obtain a target index sequence when the target data length corresponding to the target sub-data is less than or equal to the spatial data length of the target index space; The target sub-data storage module is also used to write the target sub-data into the target heap space corresponding to the target business data when the target data length corresponding to the target sub-data is greater than the space data length of the target index space, obtain the target pointer corresponding to the target sub-data, write the target pointer into the target index space, and obtain the target index sequence.
9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data structure of mapping file
CN101441638A
Data storage method and device
CN103678160A
Method for storing and reading altitude data of terrain
CN103678657A
Data processing method and device and electronic equipment
CN112286725A
Business data storage method and device, computer equipment and storage medium
CN116185305A
Cited By
Baselevel data service method and system based on cloud computing
CN119376634A
