Data storage method and device, medium and program product
By calculating the target difference sequence and merging and storing continuous identical elements, the problem of high occupancy of massive coordinate data storage space in the prior art is solved, and more efficient storage and reduced storage costs are achieved.
Patent Information
- Application Number
- CN202510089038.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-06-24
AI Technical Summary
In the prior art, the storage methods of massive coordinate data such as columnar storage or row storage lead to a high storage space occupancy rate.
By obtaining the target coordinate data set, calculating the target difference sequence, and merging and storing the same continuous elements, reducing the amount of stored data using at least two differential processing.
It effectively reduces the occupancy rate of storage space, reduces storage costs, and improves the efficiency of data storage.
Smart Images

Figure CN120196271A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage, and in particular, to a data storage method, device, medium, and program product. Background Art
[0002] To ensure the accuracy of maps, map producers will collect a large amount of coordinate data for map production and updating.
[0003] In related technologies, storage methods for a large amount of coordinate data include, for example, columnar storage or row storage, but the storage space occupancy rates of these storage methods are relatively high. Summary of the Invention
[0004] Embodiments of this application provide a data storage method, device, medium, and program product to achieve the effect of reducing the storage space occupancy rate.
[0005] In a first aspect, embodiments of this application provide a data storage method, including:
[0006] Obtain a target coordinate data set; wherein, the target coordinate data set includes a plurality of coordinate data based on a time sequence, and each coordinate data includes at least two-dimensional coordinate components;
[0007] Determine a target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set; wherein, an element in the target difference sequence indicates M difference results of at least two adjacent coordinate data in a corresponding dimension; M is an integer greater than or equal to 2;
[0008] If it is determined that there is a first target element in the target difference sequence, then store the first target element in a combined manner and store other elements in the target difference sequence; wherein, the first target element represents consecutive identical elements.
[0009] In a possible implementation manner, the determining the target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set includes:
[0010] Determine an initial difference sequence according to the at least two adjacent coordinate data; wherein, the initial difference sequence includes a plurality of initial differences, and the initial difference represents a difference between at least two adjacent coordinate data in a corresponding dimension;
[0011] Perform M - 1 difference processes on at least two adjacent initial differences in the initial difference sequence to obtain an initial target difference sequence of the target coordinate data set; wherein, each difference process is based on adjacent elements in a difference sequence obtained from the previous difference process;
[0012] Perform a conversion process on the initial target difference sequence of the target coordinate data set to obtain the target difference sequence of the target coordinate data set; wherein, the elements in the target difference sequence are positive numbers.
[0013] In a possible implementation manner, the step of, if it is determined that there is a first target element in the target difference sequence, then storing the first target element in a combined manner includes:
[0014] If it is determined that there is a first target element in the target difference sequence, then determine the number of encoding bits of the first target element and the repetition count of the first target element; wherein, the number of encoding bits of the first target element represents the sum of the number of encoding bits of all dimensions of the first target element.
[0015] According to the number of encoding bits of the first target element, determine the encoding type of the first target element and the number of bytes required for the first target element.
[0016] Store the encoding type of the first target element and the repetition count of the first target element into the bytes required for the first target element.
[0017] In a possible implementation manner, the step of determining that there is a first target element in the target difference sequence includes:
[0018] If it is determined that there are consecutive identical elements in the target difference sequence, then count the repetition times of all consecutive identical elements.
[0019] Use the element corresponding to the maximum value among the repetition times as the first target element.
[0020] In a possible implementation manner, the step of storing the encoding type of the first target element and the repetition count of the first target element into the bytes required for the first target element includes:
[0021] Store the first target element into the file header; and store the encoding type of the first target element and the repetition count of the first target element into the bytes required for the first target element.
[0022] In a possible implementation manner, the step of storing the encoding type of the first target element and the repetition count of the first target element into the bytes required for the first target element includes:
[0023] Store the encoding type of the first target element, the first target element, and the repetition count of the first target element into the bytes required for the first target element.
[0024] In a possible implementation, storing other elements in the target difference sequence includes:
[0025] For a second target element among the other elements, determining the number of encoding bits required for the second target element; wherein, the second target element represents an element other than the first element of the target difference sequence among the other elements;
[0026] According to the number of encoding bits required for the second target element, determining the encoding type of the second target element and the number of bytes required for the second target element;
[0027] Storing the encoding type of the second target element and the second target element into the number of bytes required for the second target element.
[0028] In a possible implementation, the number of encoding bits required for the second target element includes the sub-encoding bits of each dimension of the second target element; the determining the encoding type of the second target element according to the number of encoding bits required for the second target element includes:
[0029] If it is determined that the sub-encoding bits of the second target element are all less than or equal to a first threshold, then determining that the encoding type of the second target element is a first fixed-length encoding; wherein, the first fixed-length encoding corresponds to N bytes; N is a positive integer;
[0030] If it is determined that the sub-encoding bits of the second target element are all greater than the first threshold and less than a second threshold, then determining that the encoding type of the second target element is a second fixed-length encoding; wherein, the second fixed-length encoding corresponds to K bytes; K is a positive integer, and K is greater than N;
[0031] If it is determined that there are sub-encoding bits greater than or equal to the second threshold in the second target element, then determining that the encoding type of the second target element is a variable-length encoding.
[0032] In a second aspect, an embodiment of the present application provides a data storage device, including:
[0033] An acquisition module, configured to acquire a target coordinate data set; wherein, the target coordinate data set includes a plurality of coordinate data in time sequence, and each coordinate data includes coordinate components of at least two dimensions;
[0034] A determination module, configured to determine a target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set; wherein, an element in the target difference sequence indicates M difference results of at least two adjacent coordinate data in a corresponding dimension; M is an integer greater than or equal to 2;
[0035] A storage module, configured to, when determining that a first target element exists in the target difference sequence, merge and store the first target element and store other elements in the target difference sequence; wherein the first target element represents consecutive identical elements.
[0036] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0037] The memory stores computer-executable instructions;
[0038] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementation manners of the first aspect.
[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the above first aspect and / or various possible implementation manners of the first aspect.
[0040] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the above first aspect and / or various possible implementation manners of the first aspect.
[0041] The data storage method, device, medium, and program product provided by the embodiments of the present application are directed to a target coordinate data set including a plurality of coordinate data based on time sequence. Based on at least two difference results of at least two adjacent coordinate data, a target difference sequence is obtained, and when storing elements in the target difference sequence, consecutive identical first target elements in the target difference sequence are merged and stored. In this way, when storing the target coordinate data set, the method of at least two difference processes can reduce the amount of data to be stored, and the consecutive identical elements are merged and stored, further reducing the amount of data to be stored, thereby reducing the occupancy rate of the storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with the present application, and are used together with the description to explain the principles of the present application.
[0043] Figure 1 Schematic flowchart of the data storage method provided by the present application Figure 1 ;
[0044] Figure 2 Schematic flowchart of the data storage method provided by the present application Figure 2 ;
[0045] Figure 3A comparison schematic diagram of the storage space provided by this application;
[0046] Figure 4 A structural schematic diagram of the data storage device provided by this application;
[0047] Figure 5 A structural schematic diagram of the electronic device provided by this application.
[0048] Through the above-mentioned drawings, specific embodiments of this application have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of this application in any way, but to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. Detailed Description of the Specific Embodiments
[0049] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. On the contrary, they are merely examples of devices and methods consistent with some aspects of this application as detailed in the appended claims.
[0050] First, the terms involved in this application are explained:
[0051] Fixed-length coding: It means allocating a codeword with an equal-length bit for each coding symbol, that is, the length of the codeword is fixed.
[0052] Variable-length coding: It means that the converted binary length of the data is not fixed.
[0053] In the related art, for a large amount of coordinate data, the row-based storage or column-based storage method is usually adopted for data storage, but this method has a high occupancy rate of the storage space, thereby resulting in a high storage cost.
[0054] In view of this, this application provides a data storage method. When storing coordinate data based on the time sequence, the change value of the coordinate value can be stored, and the same data can be merged and stored to reduce the data volume, lower the occupancy rate of the storage space, and reduce the storage cost.
[0055] The execution subject of this application can be an electronic device with processing capabilities, such as a computer, a server, etc., and this application does not make any limitations here.
[0056] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below in conjunction with the accompanying drawings.
[0057] Figure 1 Flow schematic of the data storage method provided for this application Figure 1 , such as Figure 1 shown, this method includes:
[0058] S101. Obtain a target coordinate data set.
[0059] Exemplarily, the above target coordinate data set represents the coordinate data to be stored. It can be understood that the acquisition device installed on the vehicle can acquire a coordinate data at each preset time interval. Therefore, the above target coordinate data set includes multiple coordinate data based on the time sequence, and each coordinate data includes at least two-dimensional coordinate components. It should be noted that this application does not limit the dimension of the coordinate data. For example, it can be two-dimensional coordinates or three-dimensional coordinates.
[0060] In some possible implementation manners, the electronic device can directly communicate with the acquired vehicle to obtain the target coordinate data set; alternatively, the electronic device receives the target coordinate data set imported by an external device, and the external device can be, for example, a USB flash drive, etc.
[0061] S102. Determine a target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set.
[0062] Exemplarily, the elements in the above target difference sequence indicate the M - th difference results of at least two adjacent coordinate data in the corresponding dimension; M is an integer greater than or equal to 2. It should be noted that each difference process needs to be based on the previous difference sequence. For example, when M = 1, the difference process is performed on at least two adjacent coordinate data in the target coordinate data set to obtain the first difference result, and the first difference results can form the first difference sequence; when M = 2, the difference process is performed on at least two adjacent data in the first difference sequence to obtain the second difference result, and the second difference results can form the second difference sequence, and so on, to obtain the target difference sequence.
[0063] For example, the first element in the target difference sequence is the first coordinate data in the target coordinate dataset, and the second element is the difference between the first coordinate data and the second coordinate data in the corresponding dimension. When M = 2, starting from the third element, it is the difference between the differences of adjacent two coordinate data; when M = 3, the third element is the difference between the differences of adjacent two coordinate data, and starting from the fourth element, it is the third difference of adjacent two coordinate data, and so on. This application will not elaborate further here.
[0064] In some possible implementation manners, the electronic device may perform M - time difference processing on at least two adjacent coordinate data in the target coordinate dataset according to the preset value of M to obtain the target difference sequence.
[0065] S103. If it is determined that there is a first target element in the target difference sequence, then store the first target element in a combined manner and store the other elements in the target difference sequence.
[0066] Exemplarily, the above - mentioned first target element represents consecutive identical elements. The above - mentioned other elements represent the elements in the target difference sequence except the first target element. For example, the first element in the target difference sequence
[0067] In some possible implementation manners, all consecutive identical elements in the target difference sequence can be used as the first target element; alternatively, it can be to first determine the consecutive identical elements existing in the target difference sequence, and count the repetition times of all consecutive identical elements; use the element corresponding to the maximum value among the repetition times as the first target element.
[0068] In some possible implementation manners, when the electronic device stores the target difference sequence, it can first store the first element. For the next element, determine whether this element is a first target element. If it is a first target element, then store this consecutive identical element in a combined manner, that is, store it only once and record the repetition times. For example, it can store this element and the repetition times, and skip the consecutive identical elements, and perform a storage judgment on the next element of these elements; if not, it can be directly stored.
[0069] The data storage method provided by the embodiments of this application, for a target coordinate dataset including multiple coordinate data in chronological order, obtains a target difference sequence based on at least two difference results of at least two adjacent coordinate data, and when storing the elements in the target difference sequence, combines and stores the consecutive identical first target elements in the target difference sequence. By this means, when storing the target coordinate dataset, the method of at least two - time difference processing can reduce the amount of data to be stored, and combining and storing consecutive identical elements further reduces the amount of data to be stored, thereby reducing the occupancy rate of the storage space.
[0070] In the research, the inventors of the present application found that in the related art, the storage of coordinate data usually adopts a variable-length coding method, but this method requires additional fields to represent the length of the data, thereby increasing the occupancy rate of the storage space. Therefore, the data storage method provided in the present application can flexibly select the coding method in combination with different data lengths when storing the target difference sequence, reducing the occupancy rate of the storage space.
[0071] Figure 2 Schematic flow of the data storage method provided in the present application Figure 2 , as Figure 2 shown, on the basis of the Figure 1 embodiment, the data storage method will be described in detail. The method includes:
[0072] S201. Obtain a target coordinate data set.
[0073] It should be noted that this step is similar to the foregoing step S101 and will not be elaborated here.
[0074] S202. Determine an initial difference sequence according to at least two adjacent coordinate data.
[0075] Exemplarily, the above initial difference sequence includes a plurality of initial differences, and the initial difference represents the difference between at least two adjacent coordinate data in the corresponding dimension.
[0076] For example, the electronic device can traverse the coordinate data in the target coordinate data set to determine the initial difference between the i-th coordinate data and the (i + 1)-th coordinate data, and obtain the initial difference sequence, where i is an integer greater than or equal to 1.
[0077] S203. Perform M - 1 times of difference processing on at least two adjacent initial differences in the initial difference sequence to obtain an initial target difference sequence of the target coordinate data set.
[0078] Exemplarily, each difference processing is based on adjacent elements in the difference sequence obtained from the previous difference processing.
[0079] For example, when M = 2, the electronic device can traverse the initial differences in the initial difference sequence to determine the difference between the i-th initial difference and the (i + 1)-th initial difference, and obtain the initial target difference sequence, where i is an integer greater than or equal to 1. When M = 3, the electronic device can traverse the initial differences in the initial difference sequence to determine the difference between the i-th initial difference and the (i + 1)-th initial difference, and obtain the second difference sequence. Furthermore, the electronic device can traverse the data in the second difference sequence to determine the difference between the i-th data and the (i + 1)-th data, and obtain the initial target difference sequence. It should be noted that the principle is similar when M takes other values and will not be elaborated here.
[0080] S204. Perform a conversion process on the initial target difference sequence of the target coordinate dataset to obtain the target difference sequence of the target coordinate dataset.
[0081] Exemplarily, the elements in the above-mentioned target difference sequence are positive numbers. As mentioned above, the elements in the above-mentioned initial target difference sequence are the difference results obtained by performing M - 1 difference processes on two adjacent initial differences in the initial difference sequence. Therefore, this initial difference may be negative, that is, there is a sign bit with a negative sign, and this sign bit also needs to be stored additionally during the storage process. Therefore, in order to further reduce the amount of stored data, a conversion process can be performed on this initial target difference sequence to convert the elements in the initial target difference sequence into positive number forms to obtain the target difference sequence.
[0082] In some possible implementation manners, the electronic device can perform a rounding process on the elements in the initial target difference sequence, and then can use the Zigzag algorithm to convert the signed integer into an unsigned integer to obtain the target difference sequence.
[0083] In some possible implementation manners, since the elements in the initial target difference sequence are difference results, an offset can be preset to translate the range of the signed floating-point number to a range that can be represented by an unsigned number. For example, an offset can be selected such that all values after adding the offset are non-negative. In this way, the accuracy of the coordinate data can be guaranteed, and thus the accuracy of the data can be guaranteed.
[0084] S205. Store the first element in the target difference sequence.
[0085] As mentioned above, the first element in the target difference sequence is the first coordinate data in the target coordinate dataset, and this first element can be directly stored. For example, the number of bytes required for this first element can be directly determined, and this first element can be stored in the bytes required for this first element.
[0086] S206. Determine whether the next element in the target difference sequence is the first target element.
[0087] Exemplarily, taking M = 2 as an example, except for the first element in the target difference sequence, other elements are difference results. Therefore, starting from the second element, it is necessary to determine whether this element is the first target element. Regarding how to determine the first target element, reference can be made to the description in the foregoing step S103, which will not be elaborated here.
[0088] If so, it means that the next element is the first target element, and step S210 is executed; if not, it means that the next element is the second target element, and step S207 is executed.
[0089] S207. Determine the number of encoding bits required for the second target element among other elements.
[0090] Exemplarily, the above-mentioned second target element represents an element among other elements except the first element of the target difference sequence. The above-mentioned number of encoding bits represents the number of bits required to store the second target element. Optionally, as mentioned above, the coordinate data includes coordinate components in at least two dimensions. Therefore, the number of encoding bits required for the second target element includes the sub-encoding bits for each dimension of the second target element. In other words, for the data of each dimension, it is necessary to determine the sub-encoding bits required for the data of that dimension.
[0091] In some possible implementation manners, as mentioned above, the elements in the target difference sequence are positive numbers, that is, there is no sign bit. Therefore, for the second target element, the electronic device can determine the number of encoding bits required for the second target element according to the data type of the second target element. For example, if the second target element is an unsigned integer, the second target element can be first converted into binary, and then the number of encoding bits required for the second target element can be obtained. It should be noted that this application does not limit how to determine the encoding bits of an integer. If the second target element is an unsigned floating point number, the number of encoding bits required for the second target element can be preset, for example, 32 bits or 64 bits.
[0092] S208. Determine the encoding type of the second target element and the number of bytes required for the second target element according to the number of encoding bits required for the second target element.
[0093] Exemplarily, the above-mentioned encoding type represents an encoding method, and the encoding type can include, for example, fixed-length encoding or variable-length encoding. Among them, fixed-length encoding can include encoding methods with various byte lengths. For example, 1-byte fixed-length encoding or 3-byte fixed-length encoding. It should be noted that this application does not limit the specific encoding methods corresponding to the encoding type, as long as the encoding methods of this type can be implemented.
[0094] In some possible implementation manners, the electronic device can first determine whether the number of encoding bits required for the second target element can use the encoding type of the preset fixed-length encoding according to the number of encoding bits required for the second target element, and by using a combination of fixed-length encoding and variable-length encoding, the storage of additional fields can be reduced to reduce the occupancy rate of the storage space.
[0095] Exemplarily, the electronic device can preset two fixed-length encoding types, which are the first fixed-length encoding and the second fixed-length encoding respectively. Among them, the first fixed-length encoding corresponds to N bytes; N is a positive integer; the second fixed-length encoding corresponds to K bytes; K is a positive integer, and K is greater than N; for example, the first fixed-length encoding is 1-byte fixed-length encoding, and the second fixed-length encoding is 3-byte fixed-length encoding.
[0096] In this implementation, if it is determined that the sub - encoding bit lengths of the second target element are all less than or equal to the first threshold, it is determined that the encoding type of the second target element is the first fixed - length encoding, where the first threshold can be 3, for example; if it is determined that the sub - encoding bit lengths of the second target element are all greater than the first threshold and less than the second threshold, it is determined that the encoding type of the second target element is the second fixed - length encoding, where the second threshold can be 11, for example; if it is determined that there are sub - encoding bit lengths greater than or equal to the second threshold in the second target element, it is determined that the encoding type of the second target element is variable - length encoding.
[0097] It should be noted that the above is only an illustration of a fixed - length encoding type provided by this application. When specifically used, fixed - length encoding types with different byte lengths can be set according to actual needs. The principle is similar to the above method, and no further illustration will be given here.
[0098] In some possible implementation manners, after the electronic device determines the encoding type of the second target element, if it is a fixed - length encoding, the encoding type corresponds to the required number of bytes. If it is a variable - length encoding, the number of bytes required for the second target element can be directly determined according to the encoding bit length required for the second target element. This application does not limit how to determine the number of bytes based on the bit length here.
[0099] Through this step, when storing the target difference sequence, a mixed encoding method of fixed - length encoding and variable - length encoding can be used. According to the encoding bit length required for specific data, a suitable encoding type can be selected. Compared with only using variable - length encoding, not only can the overhead of additional fields be reduced, but also fixed - length encodings with multiple encoding lengths can allocate appropriate bytes according to the length of the data, avoiding redundancy and waste caused by only using one encoding length while the data lengths are inconsistent, saving storage costs. Moreover, using fixed - length encoding can improve the data reading speed and access efficiency when reading data, that is, it can improve the decoding rate.
[0100] S209. Store the encoding type of the second target element and the second target element into the bytes required for the second target element.
[0101] For example, if the bytes required for the second target element are 1 byte, the first two bits can be used to store the encoding type, and the last six bits can be used to store the second target element.
[0102] Through this step, the electronic device can store the multi - dimensional data of the second target element in the target difference sequence into the required bytes, which is convenient for data reading compared with separately storing data for different dimensions.
[0103] After executing this step, return to execute step S206.
[0104] S210. Determine the number of encoding bits of the first target element and the repetition count of the first target element.
[0105] Exemplarily, the number of encoding bits of the first target element represents the sum of the number of encoding bits of all dimensions of the first target element.
[0106] In some possible implementation manners, after the electronic device determines that the element is the first target element, it may determine the number of encoding bits of the first target element. For the manner of determining the number of encoding bits, reference may be made to the foregoing step S207, which will not be elaborated herein. Further, according to the fact that the element is the first target element, the repetition count of the first target element may be determined.
[0107] S211. Determine the encoding type of the first target element and the number of bytes required for the first target element according to the number of encoding bits of the first target element.
[0108] Exemplarily, the encoding type of the first target element represents the encoding manner of the first target element. For example, it may be a same-value encoding with multiple encoding lengths. The same-value encoding represents an encoding manner for identifying and classifying elements with the same value. For example, the encoding type may include 1-byte same-value encoding, 3-byte same-value encoding, etc. This application does not make a limitation here, and it may be specifically set according to actual requirements.
[0109] For example, the electronic device may determine the minimum encoding length corresponding to the number of encoding bits of the first target element based on the number of encoding bits of the first target element, that is, determine the encoding type of the first target element, and then determine the number of bytes required for the first target element.
[0110] S212. Store the encoding type of the first target element and the repetition count of the first target element into the number of bytes required for the first target element.
[0111] In some possible implementation manners, when the first target element is the element with the most repetition times, the electronic device stores the first target element into the file header; and stores the encoding type of the first target element and the repetition count of the first target element into the number of bytes required for the first target element. For example, taking the number of bytes required for the first target element being 1 byte as an example, the first two bits in this byte are the encoding type, and the last 6 bits are the repetition count.
[0112] In some possible implementation manners, when the first target element is a continuously identical element, the electronic device may store the encoding type of the first target element, the first target element, and the repetition count of the first target element into the bytes required for the first target element. For example, taking the bytes required for the first target element as 1 byte, the first two bits in the byte are the encoding type, and the last six bits are the repetition count and the first target element. By this means, as long as the elements are continuously identical, they can be merged and stored, further reducing the amount of stored data.
[0113] Through this step, for the continuously identical elements in the target difference sequence, they can be merged and stored in the form of same-value encoding, reducing the amount of stored data.
[0114] After this step, the continuously identical first target elements can be skipped, and for the next element of the continuously identical first target elements, step S206 is returned for execution until all elements in the target difference sequence are stored. Figure 3 A comparison schematic diagram of the storage space provided by this application is referred to Figure 3 It shows the comparison of the storage space sizes required by existing methods such as Parquet, Well-Known Binary (WKB), and Tiny Well-Known Binary (TinyWKB) and the data storage method provided by this application for the same coordinate data set. It can be clearly seen that the data storage method provided by this application can significantly reduce the occupancy rate of the storage space.
[0115] The data storage method provided by the embodiments of this application is directed to a target coordinate data set including a plurality of coordinate data based on time sequence. Based on at least two difference results of at least two adjacent coordinate data, an initial target difference sequence is obtained, and the initial target difference sequence is subjected to a conversion process to obtain a target difference sequence including unsigned data. And when storing the target difference sequence, for the continuously identical first target elements in the target difference sequence, a merged storage of same-value encoding can be performed, and for the second target element, a coding method combining fixed-length coding and variable-length coding can be adopted according to the actual data length for storage.
[0116] In this way, on the one hand, when storing the target coordinate data set, the method of using at least two difference processing can reduce the amount of data stored, and without storing the sign bit, further reducing the amount of data stored; on the other hand, when storing the target difference sequence, for consecutive identical elements in the target difference sequence, a same-value coding method with an appropriate coding length can be selected for combined storage, avoiding the redundancy of storing the same element multiple times. At the same time, for other elements, a combination of fixed-length coding and variable-length coding can be adopted, and an appropriate coding type can be selected based on each data length, avoiding the overhead of a large number of additional fields caused by only using variable-length coding, further reducing the amount of data stored, reducing the occupancy rate of the storage space, and reducing the storage cost.
[0117] Figure 4 FIG. is a schematic structural diagram of the data storage device provided by the present application, as Figure 4 shown, the data storage device 300 provided in this embodiment includes:
[0118] An acquisition module 301, configured to acquire a target coordinate data set; wherein, the target coordinate data set includes a plurality of coordinate data in chronological order, and each coordinate data includes coordinate components of at least two dimensions;
[0119] A determination module 302, configured to determine a target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set; wherein, an element in the target difference sequence indicates the M-th difference result of at least two adjacent coordinate data in the corresponding dimension; M is an integer greater than or equal to 2;
[0120] A storage module 303, configured to, if it is determined that there is a first target element in the target difference sequence, store the first target element in a combined manner and store other elements in the target difference sequence; wherein, the first target element represents consecutive identical elements.
[0121] In a possible implementation manner, the determination module 302 is specifically configured to:
[0122] Determine an initial difference sequence according to the at least two adjacent coordinate data; wherein, the initial difference sequence includes a plurality of initial differences, and the initial difference represents the difference between at least two adjacent coordinate data in the corresponding dimension;
[0123] Perform M - 1 times of difference processing on at least two adjacent initial differences in the initial difference sequence to obtain an initial target difference sequence of the target coordinate data set; wherein, each difference processing is performed based on adjacent elements in the difference sequence obtained from the previous difference processing;
[0124] Perform a conversion process on the initial target difference sequence of the target coordinate data set to obtain the target difference sequence of the target coordinate data set; wherein, the elements in the target difference sequence are positive numbers.
[0125] In a possible implementation manner, the storage module 303 is specifically configured to:
[0126] If it is determined that there is a first target element in the target difference sequence, determine the encoding bit number of the first target element and the repetition number of the first target element; wherein, the encoding bit number of the first target element represents the sum of the encoding bit numbers of all dimensions of the first target element.
[0127] According to the encoding bit number of the first target element, determine the encoding type of the first target element and the number of bytes required for the first target element.
[0128] Store the encoding type of the first target element and the repetition number of the first target element into the number of bytes required for the first target element.
[0129] In a possible implementation manner, the storage module 303 is specifically configured to:
[0130] If it is determined that there are consecutive identical elements in the target difference sequence, count the repetition times of all consecutive identical elements.
[0131] Use the element corresponding to the maximum value in the repetition times as the first target element.
[0132] In a possible implementation manner, the storage module 303 is specifically configured to:
[0133] Store the first target element into the file header; and store the encoding type of the first target element and the repetition number of the first target element into the number of bytes required for the first target element.
[0134] In a possible implementation manner, the storage module 303 is specifically configured to:
[0135] Store the encoding type of the first target element, the first target element, and the repetition number of the first target element into the number of bytes required for the first target element.
[0136] In a possible implementation manner, the storage module 303 is specifically configured to:
[0137] For a second target element among the other elements, determine the encoding bit number required for the second target element; wherein, the second target element represents an element other than the first element of the target difference sequence among the other elements.
[0138] Determine the encoding type of the second target element and the number of bytes required for the second target element according to the number of encoding bits required for the second target element;
[0139] Store the encoding type of the second target element and the second target element into the number of bytes required for the second target element.
[0140] In a possible implementation manner, the number of encoding bits required for the second target element includes the sub-encoding bits of each dimension of the second target element; the storage module 303 is specifically configured to:
[0141] If it is determined that the sub-encoding bits of the second target element are all less than or equal to the first threshold, then determine that the encoding type of the second target element is the first fixed-length encoding; wherein, the first fixed-length encoding corresponds to N bytes; N is a positive integer;
[0142] If it is determined that the sub-encoding bits of the second target element are all greater than the first threshold and less than the second threshold, then determine that the encoding type of the second target element is the second fixed-length encoding; wherein, the second fixed-length encoding corresponds to K bytes; K is a positive integer, and K is greater than N;
[0143] If it is determined that there are sub-encoding bits greater than or equal to the second threshold in the second target element, then determine that the encoding type of the second target element is variable-length encoding.
[0144] The data storage device provided in this embodiment can execute the method provided in the above method embodiment, and its implementation principle and technical effect are similar, and will not be elaborated here in this embodiment.
[0145] Figure 5 It is a schematic structural diagram of an electronic device provided in this application. As Figure 5 shown, the electronic device 400 provided in this embodiment includes: at least one processor 401 and a memory 402. Optionally, the device 400 further includes a communication component 403. Wherein, the processor 401, the memory 402, and the communication component 403 are connected through a bus 404.
[0146] In a specific implementation process, at least one processor 401 executes computer-executable instructions stored in the memory 402, so that at least one processor 401 executes the above method.
[0147] The specific implementation process of the processor 401 can refer to the above method embodiment, and its implementation principle and technical effect are similar, and will not be elaborated here in this embodiment.
[0148] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU for short), or may also be other general-purpose processors, digital signal processors (DSP for short), application specific integrated circuits (ASIC for short), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.
[0149] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0150] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, the buses in the drawings of this application are not limited to only one bus or one type of bus.
[0151] This application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0152] This application also provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the processor executes the computer-executable instructions, the above method is implemented.
[0153] The above-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk or an optical disk. The readable storage medium can be any available medium accessible by a general-purpose or special-purpose computer.
[0154] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in a device.
[0155] The division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Additionally, the couplings or direct couplings or communication connections shown or discussed between each other can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0156] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0158] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.
[0159] Those of ordinary skill in the art can understand that all or part of the steps to implement the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: various media such as ROM, RAM, magnetic disk or optical disc that can store program codes.
[0160] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses, or adaptations of the present invention, which follow the general principles of the present invention and include known common knowledge or conventional technical means in the technical field not disclosed in the present invention. It is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.
Claims
1. A data storage method, characterized in that: include: Acquire a target coordinate data set; wherein the target coordinate data set includes a plurality of time-sequentially based coordinate data, each of which includes coordinate components of at least two dimensions; Determine a target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set; wherein the elements in the target difference sequence indicate M times difference results of at least two adjacent coordinate data in corresponding dimensions; M is an integer greater than or equal to 2; If it is determined that there is a first target element in the target difference sequence, the first target element is combined and stored, and other elements in the target difference sequence are stored; wherein the first target element represents consecutive identical elements.
2. The method according to claim 1, characterized in that The step of determining a target difference sequence of the target coordinate data set according to at least two adjacent coordinate data in the target coordinate data set includes: Determine an initial difference sequence according to the at least two adjacent coordinate data; wherein the initial difference sequence includes a plurality of initial difference values, and the initial difference value represents a difference between the at least two adjacent coordinate data in a corresponding dimension; Performing M-1 difference processing on at least two adjacent initial difference values in the initial difference value sequence to obtain an initial target difference value sequence of the target coordinate data set; wherein each difference processing is performed based on adjacent elements in the difference value sequence obtained by the previous difference processing; The initial target difference sequence of the target coordinate data set is converted to obtain a target difference sequence of the target coordinate data set; wherein the elements in the target difference sequence are positive numbers.
3. The method according to claim 1, characterized in that If it is determined that the first target element exists in the target difference sequence, merging and storing the first target element comprises: If it is determined that the first target element exists in the target difference sequence, the number of encoding bits of the first target element and the number of repetitions of the first target element are determined; wherein the number of encoding bits of the first target element represents the sum of the encoding bits of all dimensions of the first target element; Determining, according to the number of encoding bits of the first target element, an encoding type of the first target element and the number of bytes required for the first target element; The encoding type of the first target element and the number of repetitions of the first target element are stored in the bytes required by the first target element.
4. The method according to claim 3, characterized in that The determining whether the first target element exists in the target difference sequence includes: If it is determined that there are consecutive identical elements in the target difference sequence, then the number of repetitions of all consecutive identical elements is counted; The element corresponding to the maximum value of the repetition times is taken as the first target element.
5. The method according to claim 4, characterized in that The storing the encoding type of the first target element and the number of repetitions of the first target element into bytes required by the first target element includes: The first target element is stored in a file header; and the encoding type of the first target element and the number of repetitions of the first target element are stored in bytes required by the first target element.
6. The method according to claim 3, characterized in that The storing the encoding type of the first target element and the number of repetitions of the first target element into bytes required by the first target element includes: The encoding type of the first target element, the first target element, and the number of repetitions of the first target element are stored in bytes required for the first target element.
7. The method according to any one of claims 1 to 6, characterized in that: The storing of other elements in the target difference sequence includes: For a second target element among the other elements, determining the number of encoding bits required for the second target element; wherein the second target element represents an element among the other elements except the first element of the target difference sequence; Determining, according to the number of encoding bits required for the second target element, an encoding type of the second target element and the number of bytes required for the second target element; The encoding type of the second target element and the second target element are stored in the bytes required by the second target element.
8. The method according to claim 7, characterized in that The number of encoding bits required for the second target element includes the number of sub-encoding bits of each dimension of the second target element; and determining the encoding type of the second target element according to the number of encoding bits required for the second target element includes: If it is determined that the number of sub-coding bits of the second target element is less than or equal to the first threshold, the encoding type of the second target element is determined to be a first fixed-length code; wherein the first fixed-length code corresponds to N bytes; N is a positive integer; If it is determined that the number of sub-code bits of the second target element is greater than the first threshold and less than the second threshold, the encoding type of the second target element is determined to be a second fixed-length code; wherein the second fixed-length code corresponds to K bytes; K is a positive integer, and K is greater than N; If it is determined that the number of sub-coding bits in the second target element is greater than or equal to the second threshold, the encoding type of the second target element is determined to be variable-length encoding.
9. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 8.
10. A computer-readable storage medium / computer program product, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor; and / or, The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.