Data storage method and device, electronic equipment and medium
By dividing storage units in the storage area and determining the reserved index capacity, the problem that the storage system may enter read-only protection mode after power-off restart is solved, and effective storage of index information and efficient utilization of space are achieved.
Patent Information
- Application Number
- CN202311756921.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2025-06-20
AI Technical Summary
If the prior art suddenly fails to power and restarts during the storage process, the storage system may enter read-only protection mode, and the artificially determined fixed reserved index capacity cannot meet the actual storage needs, resulting in wasted space.
By dividing storage units in the target storage area, and accurately determining the reserved index capacity, including the reserved index area capacity and reserved index file capacity, ensure that the storage requirements of the index information are met without causing waste of space.
The reserved capacity of the index space is accurately determined based on actual needs, which not only meets the storage needs of index information, but also avoids space waste and improves the utilization and stability of the storage space.
Smart Images

Figure CN120179622A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data storage, and in particular, to a data storage method, apparatus, electronic device, and medium. Background Art
[0002] Currently, many electronic devices have a storage function. For example, intelligent image collectors have the function of storing videos and pictures. The storage function supports real-time writing, querying according to retrieval conditions, double-speed playback, and skip playback, etc. If the power is suddenly cut off and restarted during the storage process in some storage systems, the storage system may enter the read-only protection mode. To solve the above problems, storage units can be pre-created during formatting, a fixed size can be allocated for each data file, and the entire storage space can be fully occupied.
[0003] During the above pre-creation process, the index space for storing index information is created based on a fixed reserved capacity determined manually, and the fixed reserved capacity determined manually may not meet the actual storage requirements. Summary of the Invention
[0004] Embodiments of this application provide a data storage method, apparatus, electronic device, and medium to accurately and quantitatively determine the reserved index capacity, which can not only meet the storage requirements of index information but also avoid wasting space.
[0005] According to one aspect of this application, a data storage method is provided. The method includes:
[0006] Dividing storage units in a target storage area and determining the storage unit capacity;
[0007] Determining a reserved index capacity according to the target storage area capacity, the storage unit capacity, and the data information of target data; wherein, the reserved index capacity includes a reserved index area capacity and a reserved index file capacity; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments;
[0008] Dividing an index space in the target storage area according to the reserved index capacity to store the index information of the target data.
[0009] According to one aspect of this application, a data storage apparatus is provided. The apparatus includes:
[0010] A storage unit capacity determination module, configured to divide storage units in a target storage area and determine the storage unit capacity;
[0011] A reserved index capacity determination module, configured to determine a reserved index capacity according to a target storage area capacity, the storage unit capacity, and data information of target data; wherein the reserved index capacity includes a reserved index area capacity and a reserved index file capacity; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments;
[0012] An index space partitioning module, configured to partition an index space in the target storage area according to the reserved index capacity to store index information of the target data.
[0013] According to another aspect of the present application, there is provided an electronic device, which includes:
[0014] At least one processor; and
[0015] A memory connected to the at least one processor for data storage; wherein,
[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data storage method of any embodiment of the present application.
[0017] According to another aspect of the present application, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the data storage method of any embodiment of the present application when executed.
[0018] In the technical solution of the embodiment of the present application, storage units are partitioned in a target storage area, and the storage unit capacity is determined; according to the target storage area capacity, the storage unit capacity, and data information of target data, a reserved index capacity is determined; wherein the reserved index capacity includes a reserved index area capacity and a reserved index file capacity; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments; an index space is partitioned in the target storage area according to the reserved index capacity to store index information of the target data. The above solution can accurately and quantitatively determine the reserved capacity of the index space according to the target storage area capacity, the capacity of the partitioned storage units, and the data information of the target data, so that the reserved capacity can not only meet the storage requirements of the index information, but also avoid space waste.
[0019] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become easily understood through the following description. Description of the Drawings
[0020] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0021] Figure 1 is a flowchart of a data storage method provided in the first embodiment of the present application;
[0022] Figure 2 is a flowchart of a data storage method provided in the second embodiment of the present application;
[0023] Figure 3 is a flowchart of a data storage method provided in the third embodiment of the present application;
[0024] Figure 4 is a schematic structural diagram of a data storage device provided in the fourth embodiment of the present application;
[0025] Figure 5 is a schematic structural diagram of an electronic device provided in the fifth embodiment of the present application. Detailed implementation manners
[0026] In order to enable those skilled in the art to better understand the solutions of the present application, the following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0027] It should be noted that the terms "first", "second", "third", "fourth", "actual", "preset", etc. in the specification, claims and drawings of the present application are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily need to be limited to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0028] Embodiment 1
[0029] Figure 1 The flowchart of a data storage method provided in the first embodiment of the present application is applicable to the situation of determining the reserved storage space for index information. This method can be executed by a data storage device, which can be implemented in the form of hardware and / or software and can be configured in an electronic device. As Figure 1 shown, the method includes:
[0030] S110. Divide storage units in a target storage area and determine the storage unit capacity.
[0031] Among them, the target storage area can be the overall area for storing target data, such as a memory card in an electronic device. A storage unit can be an area for storing a data file, and the storage unit capacity is the capacity required to store a data file. Since the data volume of a data file is fixed, the storage unit capacity is fixed.
[0032] In the embodiment of the present application, pre-creation can be performed during the formatting of the storage system, and a fixed space size is allocated for each data file to store the data file, that is, storage units are divided from the target area to store the data file. One storage unit corresponds to storing one data file. The number of divided storage units can be determined according to the actual situation. For example, the maximum number of data files that can be stored in the target storage area can be initially calculated based on the target storage area capacity and the storage unit capacity, and the number of divided storage units is determined according to the maximum number. Since space also needs to be reserved for index information in the target storage area, the number of divided storage units is less than the maximum number.
[0033] S120. Determine the reserved index capacity according to the target storage area capacity, the storage unit capacity, and the data information of the target data.
[0034] Among them, the reserved index capacity includes the reserved index area capacity and the reserved index file capacity; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments. The target storage area capacity can be the overall available capacity in the target storage area. For example, it can be the inherent capacity of a memory card. The target data is the data that needs to be stored. For example, it can be videos, pictures, documents, etc. The target data is stored in the form of data files. The data information of the target data can be the information related to the target data. Taking the target data as a video as an example, the data information can include the I-frame group data volume, the I-frame group index information data volume, the continuous video segment data volume, the index information data volume of the continuous video segment, etc. The I-frame group data volume can also be calculated according to information such as the coding bit rate, the I-frame group data volume, and the frame rate in the data information. The reserved index capacity is the capacity reserved from the target storage area for storing index information, which can include the reserved index area capacity and the reserved index file capacity, and the reserved index capacity is greater than or equal to the sum of the reserved index area capacity and the reserved index file capacity. The reserved index area is used to store I-frame group information, and the reserved index file is used to store information such as the start and end times of continuous data segments of the target data and the files where they are located.
[0035] In the embodiment of the present application, after the storage unit is divided, the capacity required to store the target data can be determined according to the storage unit capacity and the data information of the target data. Subtracting the capacity required to store the target data from the target storage area capacity, the reserved index capacity is obtained. The reserved index capacity can also be determined according to the data volume of each index information and the number of index information to be stored. The number of index information to be stored can be calculated according to the target storage area capacity, the storage unit capacity, and the data information of the target data. The I-frame groups are stored in the reserved index area, and each I-frame group corresponds to an I-frame group index information. The number of I-frame group index information is the same as the number of I-frame groups. The reserved index area capacity is calculated based on this number of I-frame group index information, so that the space can be fully utilized. Similarly, the data segment index information is stored in the reserved index file, and each data segment corresponds to a data segment index information. The number of data segment index information is the same as the number of data segments. The reserved index file capacity is calculated based on this number of data segment index information, so that the space is fully utilized. The above solution calculates the space capacity for storing index information according to the space capacity for storing data, so that the two spaces are balanced and space waste is avoided.
[0036] S130. Divide an index space in the target storage area according to the reserved index capacity to store the index information of the target data.
[0037] Exemplarily, an index space is partitioned in the target storage area according to the reserved index capacity, and during the subsequent process of storing target data, the index data is stored in the index space. The capacity of the index space is quantitatively calculated according to the above embodiments. Through accurate calculation, the index space can not only meet the capacity requirements for storing index information, but also avoid waste caused by excessive reserved index space, thereby improving the storage space utilization rate and storage stability. In addition, when the capacity of the target storage area, the capacity of the storage unit, and the data information of the target data change, the reserved index capacity will also change adaptively, so as to adjust the size of the index space to adapt to the storage of the target data, solving the problem that the reserved index space capacity is single and fixed and cannot change adaptively, sometimes resulting in insufficient storage space and sometimes waste of storage space.
[0038] In the technical solution of the embodiment of the present application, storage units are partitioned in the target storage area, and the capacity of the storage unit is determined; according to the capacity of the target storage area, the capacity of the storage unit, and the data information of the target data, the reserved index capacity is determined; wherein, the reserved index capacity includes the reserved index area capacity and the reserved index file capacity; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments; an index space is partitioned in the target storage area according to the reserved index capacity to store the index information of the target data. The above solution can accurately and quantitatively determine the reserved capacity of the index space according to the capacity of the target storage area, the capacity of the partitioned storage unit, and the data information of the target data, so that the reserved capacity can not only meet the storage requirements of the index information, but also not cause space waste.
[0039] Embodiment 2
[0040] Figure 2 It is a flowchart of a data storage method provided in Embodiment 2 of the present application. The embodiment of the present application is optimized based on the above embodiment. For the solutions not described in detail in the embodiment of the present application, please refer to the above embodiment. The present application is applicable to the case where the target data is video. As Figure 2 shown, the method of the embodiment of the present application specifically includes the following steps:
[0041] S210. Partition storage units in the target storage area and determine the capacity of the storage unit.
[0042] S220. Determine the number of I-frame groups according to the capacity of the storage unit, the data volume of the I-frame group, and the data volume of the I-frame group index information.
[0043] In an embodiment of the present application, the storage unit includes a data area for storing target data and an index area for storing index information; the reserved index capacity includes the reserved index area capacity; the data information includes the I-frame group data volume and the I-frame group index information data volume. In the index area, the start time and offset position of each I-frame group can be recorded, which is convenient for quickly locking the specific position of the video frame according to the query time during retrieval.
[0044] Among them, the I-frame group is a picture group. When encoding a video, the image frames are divided into two types: I-frames and P-frames, or three types: I-frames, P-frames, and B-frames. I is an intra-coded frame, P is a forward-predicted frame, and B is a bidirectional interpolated frame. An I-frame group is composed of one I-frame and several P-frames and B-frames. The I-frame group data volume is the size of an I-frame group. The I-frame group index information data volume is the size of the index information corresponding to the I-frame group.
[0045] Exemplarily, the number of I-frame groups can be calculated based on the storage unit capacity, the I-frame group data volume, and the I-frame group index information data volume.
[0046] S230. Determine the reserved index area capacity according to the number of I-frame groups and the I-frame group index information data volume.
[0047] Exemplarily, each I-frame group corresponds to one I-frame group index information, which is used to record information such as the start time and offset of the I-frame group. Therefore, the number of I-frame groups is the same as the number of I-frame group index information. The I-frame group can determine the I-frame group index information data volume according to the amount of content recorded, and the I-frame group index information data volume is determined according to the number of bytes of the I-frame group index information. According to the I-frame group index information data volume and the number of I-frame groups, the capacity reserved for index information to record a data file can be determined, that is, the reserved index area capacity is determined.
[0048] Specifically, the reserved index area capacity = I-frame group index information data volume * number of I-frame groups. The number of I-frame groups = (storage unit capacity - reserved index area capacity) / I-frame group data volume. Among them, the I-frame group data volume = coding bit rate * I-frame group length / frame rate. The reserved index area capacity can be solved from the above relationships.
[0049] S240. Determine the number of data segments according to the total data volume of the data file and the data segment data volume; where the total data volume of the data file is represented by the target storage area data volume, the total reserved index area capacity, and the reserved index file capacity; the total reserved index area capacity is the product of the reserved index area capacity and the number of data files.
[0050] In an embodiment of the present application, the reserved index capacity includes the reserved index file capacity; the data file includes at least one data segment; the data information includes the data segment data volume and the data segment index information data volume.
[0051] Among them, the total data volume of the data file is the size of all data files, which is equal to the sum of the capacities of all storage units. The data volume of a data segment is the size of a data segment stored in the data file. The total capacity of the reserved index area is the sum of the capacities of the index areas in all storage units. Exemplarily, some data in the data file may be continuous and regarded as a data segment. For example, a continuous video segment in terms of time. The data segments may be discontinuous. For example, there is no time continuity between different video segments. The data file may include at least one data segment. If it is alarm storage, the data segment stores the data within a period of time before the alarm trigger time and the data within a period of time after the alarm trigger time. If it is continuous storage throughout the day, one data file is a complete data segment. The index file records information such as the start time and location of each data segment, which is used to query the data segment at a specific time and to query which data file the data segment is located on. The index information of a data segment is recorded by a piece of data segment index information, and the number of data segments is the same as the number of data segment index information. The reserved index file capacity is related to the number of data segments. When the data volume of the data segment index information is fixed, the reserved index file capacity is positively correlated with the number of data segments. First, the number of data segments can be determined according to the total data volume of the data file and the data volume of the data segment, and then the reserved index file capacity can be determined according to the number of data segments.
[0052] Specifically, the number of data segments = the total data volume of the data file / the data volume of the data segment. The data volume of the data segment = (video time before alarm + video time after alarm) * coding bit rate. The total data volume of the data file = the data volume of the target storage area - the reserved index file capacity - the total capacity of the reserved index area. The total capacity of the reserved index area = the capacity of the reserved index area * the number of data files. The number of data files = (the data volume of the target storage area - the reserved index file capacity) / the capacity of the storage unit. The capacity of the storage unit is equivalent to the data volume of one data file.
[0053] S250. Determine the reserved index file capacity according to the data volume of the data segment index information and the number of data segments.
[0054] Exemplarily, the reserved index file capacity = the data volume of the data segment index information * the number of data segments. In the case of continuous storage throughout the day, there is one data segment in one data file, and the number of data segments is the same as the number of data files. The reserved index file capacity can be obtained by solving according to the above formula.
[0055] The embodiment of the present application provides a data storage method. According to the storage unit capacity, the amount of I-frame group data, and the amount of I-frame group index information data, the number of I-frame groups is determined; according to the number of I-frame groups and the amount of I-frame group index information data, the capacity of the reserved index area is determined, so as to accurately calculate the capacity of the reserved index area quantitatively to meet the demand for the index information of the target data in the storage data area, and make the number of index information that the index area can accommodate match the number of target data that the data area can accommodate, avoiding waste of storage space. According to the total amount of data in the data file and the amount of data in the data segment, the number of data segments is determined; wherein, the total amount of data in the data file is represented by the amount of data in the target storage area, the total capacity of the reserved index area, and the capacity of the reserved index file; the total capacity of the reserved index area is the product of the capacity of the reserved index area and the number of data files; according to the amount of data segment index information and the number of data segments, the capacity of the reserved index file is determined, so as to accurately calculate the capacity of the reserved index file quantitatively, so that the index space can not only meet the storage of data segment index information, but also avoid space waste.
[0056] Embodiment III
[0057] Figure 3 The flowchart of a data storage method provided by Embodiment III of the present application. The embodiment of the present application is optimized based on the above embodiment, and the solutions not described in detail in the embodiment of the present application can be seen in the above embodiment. As Figure 3 shown, the method of the embodiment of the present application specifically includes the following steps:
[0058] S310. Divide storage units in the target storage area and determine the storage unit capacity.
[0059] S320. Determine the reserved index capacity according to the capacity of the target storage area, the storage unit capacity, and the data information of the target data. Wherein, the reserved index capacity includes the capacity of the reserved index area and the capacity of the reserved index file; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments.
[0060] S330. Divide an index space in the target storage area according to the reserved index capacity to store the index information of the target data.
[0061] S340. Store the target data in the data area of the storage unit and store the index information in the index area of the storage unit.
[0062] Exemplarily, the storage unit includes a data area and an index area. When storing the target data in the storage unit, store the target data in the data area and store the index information of the target data in the index area.
[0063] S350. Determine the encoding parameters of the data to be stored according to the remaining capacity of the data area and the remaining capacity of the index area.
[0064] Among them, the data to be stored is the data that has not been stored yet and needs to be stored subsequently. Exemplarily, during the process of storing target data, the amount of target data stored in the data area is counted, and according to the data area capacity and the amount of stored target data, the remaining capacity of the data area is calculated. The amount of index information stored in the index area is counted, and according to the index area capacity and the amount of stored data information, the remaining capacity of the index area is calculated. The encoding parameters of the data to be stored can be determined according to the remaining capacity in the data area and the remaining capacity in the index area, so as to adjust the number of target data units stored in the data area through the encoding parameters, so that the number of target data units stored in the data area is balanced with the number of index information stored in the index area, so as to improve the utilization rate of the storage space and avoid waste of idle space.
[0065] In the embodiment of the present application, determining the encoding parameters of the data to be stored according to the remaining capacity of the data area and the remaining capacity of the index area includes:
[0066] Determine the number of remaining I-frame groups that can be accommodated in the data area according to the remaining capacity in the data area and the I-frame group data volume;
[0067] Determine the number of remaining I-frame group index information that can be accommodated in the index area according to the remaining capacity in the index area and the I-frame group index information data volume;
[0068] Determine the encoding code rate of the data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area.
[0069] Exemplarily, for the case where the target data is a video, the number of I-frame groups is inversely proportional to the encoding code rate. The larger the encoding code rate, the fewer the number of I-frame groups, and the smaller the encoding code rate, the more the number of I-frame groups. The remaining capacity in the data area can be divided by the I-frame group data volume to determine the number of remaining I-frame groups that can be accommodated in the data area, and the remaining capacity in the index area can be divided by the I-frame group index information data volume to determine the number of remaining I-frame group index information that can be accommodated in the index area. When the number of remaining I-frame groups that can be accommodated in the data area is inconsistent with the number of remaining I-frame group index information that can be accommodated in the index area, by adjusting the encoding code rate of the data to be stored, the number of I-frame groups of the data to be stored is adjusted, so that the number of I-frame groups stored subsequently in the data area matches the number of I-frame group index information stored subsequently in the index area, maximizing the utilization of the storage space.
[0070] In an embodiment of the present application, determining the coding rate of the data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area includes:
[0071] If the number of remaining I-frame groups that can be accommodated in the data area is greater than the number of remaining I-frame group index information that can be accommodated in the index area, increase the coding rate of the data to be stored;
[0072] If the number of remaining I-frame groups that can be accommodated in the data area is less than the number of remaining I-frame group index information that can be accommodated in the index area, decrease the coding rate of the data to be stored.
[0073] Exemplarily, if the number of remaining I-frame groups that can be accommodated in the data area is greater than the number of remaining I-frame group index information that can be accommodated in the index area, increase the coding rate of the data to be stored to reduce the number of subsequent stored I-frame groups, so that the number of I-frame groups subsequently stored in the data area is the same as the number of I-frame group index information subsequently stored in the index area, and fully fill the data area and the index area. If the number of remaining I-frame groups that can be accommodated in the data area is less than the number of remaining I-frame group index information that can be accommodated in the index area, decrease the coding rate of the data to be stored to increase the number of subsequent stored I-frame groups, so that the number of I-frame groups subsequently stored in the data area is the same as the number of I-frame group index information subsequently stored in the index area, and fully fill the data area and the index area. If the number of remaining I-frame groups that can be accommodated in the data area is equal to the number of remaining I-frame group index information that can be accommodated in the index area, do not adjust the coding rate.
[0074] In an embodiment of the present application, determining the coding rate of the data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area includes:
[0075] Determine the quantity ratio between the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area;
[0076] Adjust the coding rate of the data to be stored based on the quantity ratio.
[0077] Exemplarily, the number of remaining I-frame groups that can be accommodated in the data area = data volume of the data to be stored / (original coding rate * I-frame group length / frame rate). The actual number of I-frame groups to be stored in the data area = the number of remaining I-frame group index information that can be accommodated in the index area = data volume of the data to be stored / (adjusted coding rate * I-frame group length / frame rate).
[0078]
[0079] Thus, it can be known that
[0080] After adjusting the coding rate accordingly, continue to store the data to be stored, so that the number of I-frame groups stored subsequently in the data area is the same as the number of I-frame group index information stored subsequently in the index area, fully filling the data area and the index area and avoiding waste of space.
[0081] An embodiment of the present application provides a data storage method, which stores target data in the data area of the storage unit and stores index information in the index area of the storage unit; determines the coding parameters of the data to be stored according to the remaining capacity of the data area and the remaining capacity of the index area, so as to accurately calculate the coding parameters when storing the data to be stored subsequently, so that the number of data units stored in the data area subsequently matches the number of index units stored in the index area, avoiding waste of space.
[0082] Embodiment 4
[0083] Figure 4 It is a schematic structural diagram of a data storage device provided in Embodiment 4 of the present application. This device can execute the data storage method provided in any embodiment of the present application, and has corresponding functional modules and beneficial effects for executing the method. As Figure 4 shown, the device includes:
[0084] A storage unit capacity determination module 410, configured to divide a storage unit in a target storage area and determine the storage unit capacity;
[0085] A reserved index capacity determination module 420, configured to determine a reserved index capacity according to the target storage area capacity, the storage unit capacity, and the data information of the target data; wherein, the reserved index capacity includes a reserved index area capacity and a reserved index file capacity; the number of I-frame group index information in the reserved index area is the same as the number of I-frame groups, and the number of data segment index information in the reserved index file is the same as the number of data segments;
[0086] An index space division module 430, configured to divide an index space in the target storage area according to the reserved index capacity to store the index information of the target data.
[0087] In an embodiment of the present application, the storage unit includes a data area for storing target data and an index area for storing index information; the reserved index capacity includes a reserved index area capacity; the data information includes the I-frame group data volume and the I-frame group index information data volume;
[0088] Correspondingly, the reserved index capacity determination module 420 includes:
[0089] An I-frame group number determination unit, configured to determine the number of I-frame groups according to the storage unit capacity, the I-frame group data volume, and the I-frame group index information data volume;
[0090] A reserved index area capacity determining unit, configured to determine the reserved index area capacity according to the number of I-frame groups and the data volume of the I-frame group index information.
[0091] In an embodiment of the present application, the reserved index capacity includes a reserved index file capacity; the data file includes at least one data segment; the data information includes the data volume of the data segment and the data volume of the data segment index information;
[0092] Correspondingly, the reserved index capacity determining module 420 includes:
[0093] Determine the number of data segments according to the total data volume of the data file and the data volume of the data segment; wherein, the total data volume of the data file is represented by the data volume of the target storage area, the total capacity of the reserved index area, and the reserved index file capacity; the total capacity of the reserved index area is the product of the reserved index area capacity and the number of data files;
[0094] Determine the reserved index file capacity according to the data volume of the data segment index information and the number of data segments.
[0095] In an embodiment of the present application, the device further includes:
[0096] A storage module, configured to store target data in the data area of the storage unit and store index information in the index area of the storage unit;
[0097] An encoding parameter determining module, configured to determine the encoding parameters of the data to be stored according to the remaining capacity of the data area and the remaining capacity of the index area.
[0098] In an embodiment of the present application, the encoding parameter determining module includes:
[0099] A data area accommodable quantity determining unit, configured to determine the number of remaining I-frame groups that can be accommodated in the data area according to the remaining capacity in the data area and the I-frame group data volume;
[0100] An index area accommodable quantity determining unit, configured to determine the number of remaining I-frame group index information that can be accommodated in the index area according to the remaining capacity in the index area and the I-frame group index information data volume;
[0101] An encoding code rate determining unit, configured to determine the encoding code rate of the data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area.
[0102] In an embodiment of the present application, the index area accommodable quantity determining unit is specifically configured to:
[0103] If the number of remaining I-frame groups that can be accommodated in the data area is greater than the number of remaining I-frame group index information that can be accommodated in the index area, increase the coding rate of the data to be stored;
[0104] If the number of remaining I-frame groups that can be accommodated in the data area is less than the number of remaining I-frame group index information that can be accommodated in the index area, decrease the coding rate of the data to be stored.
[0105] In the embodiment of the present application, the index area capacity determination unit is specifically configured to:
[0106] Determine the quantity ratio between the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area;
[0107] Adjust the coding rate of the data to be stored based on the quantity ratio.
[0108] A data storage device provided by an embodiment of the present application can execute a data storage method provided by any embodiment of the present application, and has corresponding functional modules and beneficial effects for executing the method.
[0109] Embodiment Five
[0110] Figure 5 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present application described and / or claimed herein.
[0111] As Figure 5 shown, the electronic device 10 includes at least one processor 11, and a memory data-storage connected to at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0112] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disc, etc.; and a data storage unit 19, such as a network card, a modem, a wireless data storage transceiver, etc. The data storage unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0113] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the data storage method.
[0114] In some embodiments, the data storage method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the data storage unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the data storage method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the data storage method by any other suitable means (e.g., by means of firmware).
[0115] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGA), application-specific integrated circuits (ASIC), application-specific standard products (ASSP), systems-on-a-chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: implemented in one or more computer programs, the one or more computer programs can be executed and / or interpreted on a programmable system including at least one programmable processor, the programmable processor can be a special or general-purpose programmable processor, can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0116] The computer program for implementing the method of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data storage device, such that when the computer program is executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0117] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0118] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0119] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other through digital data storage in any form or medium (e.g., a data storage network). Examples of data storage networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0120] The computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a data storage network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0121] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this application can be executed in parallel, sequentially, or in a different order, as long as the information desired by the technical solution of this application can be achieved, and this is not limited herein.
[0122] The above specific embodiments do not constitute a limitation on the protection scope of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principle of this application shall be included within the protection scope of this application.
Claims
1. A data storage method, characterized in that, The method includes: Dividing storage units in a target storage area and determining the storage unit capacity; Determining a reserved index capacity according to the target storage area capacity, the storage unit capacity, and the data information of target data; wherein, the reserved index capacity includes a reserved index area capacity and a reserved index file capacity; the number of I-frame group index information in the reserved index area is consistent with the number of I-frame groups, and the number of data segment index information in the reserved index file is consistent with the number of data segments; Dividing an index space in the target storage area according to the reserved index capacity to store the index information of the target data.
2. The method according to claim 1, characterized in that, The storage unit includes a data area for storing target data and an index area for storing index information; the data information includes the I-frame group data volume and the I-frame group index information data volume; Correspondingly, determining the reserved index capacity according to the data area capacity and the data information of target data includes: Determining the number of I-frame groups according to the storage unit capacity, the I-frame group data volume, and the I-frame group index information data volume; Determining the reserved index area capacity according to the number of I-frame groups and the I-frame group index information data volume.
3. The method according to claim 2, characterized in that, A data file includes at least one data segment; the data information includes the data segment data volume and the data segment index information data volume; Correspondingly, determining the reserved index capacity according to the data area capacity and the data information of target data includes: Determining the number of data segments according to the total data volume of the data file and the data segment data volume; wherein, the total data volume of the data file is represented by the target storage area data volume, the total reserved index area capacity, and the reserved index file capacity; the total reserved index area capacity is the product of the reserved index area capacity and the number of data files; Determining the reserved index file capacity according to the data segment index information data volume and the number of data segments.
4. The method according to claim 1, characterized in that, The method further includes: Storing target data in the data area of the storage unit and storing index information in the index area of the storage unit; Determining encoding parameters of data to be stored according to the remaining capacity of the data area and the remaining capacity of the index area.
5. The method according to claim 4, characterized in that, Determining the encoding code rate of data to be stored according to the remaining capacity of the data area and the remaining capacity of the index area includes: Determining the number of remaining I-frame groups that can be accommodated in the data area according to the remaining capacity in the data area and the I-frame group data volume; Determining the number of remaining I-frame group index information that can be accommodated in the index area according to the remaining capacity in the index area and the I-frame group index information data volume; Determining the encoding code rate of data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area.
6. The method according to claim 5, characterized in that, Determining the encoding code rate of data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area includes: If the number of remaining I-frame groups that can be accommodated in the data area is greater than the number of remaining I-frame group index information that can be accommodated in the index area, increasing the encoding code rate of data to be stored; If the number of remaining I-frame groups that can be accommodated in the data area is less than the number of remaining I-frame group index information that can be accommodated in the index area, the coding rate of the data to be stored is reduced.
7. The method according to claim 5, characterized in that, Determining the coding rate of the data to be stored according to the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area includes: Determining the quantitative ratio between the number of remaining I-frame groups that can be accommodated in the data area and the number of remaining I-frame group index information that can be accommodated in the index area; Adjusting the coding rate of the data to be stored based on the quantitative ratio.
8. A data storage device, characterized in that, The apparatus includes: A storage unit capacity determination module, configured to divide storage units in a target storage area and determine the storage unit capacity; A reserved index capacity determination module, configured to determine a reserved index capacity according to the target storage area capacity, the storage unit capacity, and the data information of the target data; wherein, the reserved index capacity includes a reserved index area capacity and a reserved index file capacity; the number of I-frame group index information in the reserved index area is consistent with the number of I-frame groups, and the number of data segment index information in the reserved index file is consistent with the number of data segments; An index space division module, configured to divide an index space in the target storage area according to the reserved index capacity to store the index information of the target data.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory data-storage connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data storage method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a processor to implement the data storage method according to any one of claims 1-7 when executed.