Trajectory data compression method and device, electronic equipment and storage medium
By dividing trajectory data into subsets and storing them as public and feature parts based on data type, and employing a specific compression algorithm, the problems of poor trajectory data compression performance and low query efficiency are solved, achieving efficient lossless compression and fine-grained querying.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-27
- Publication Date
- 2026-03-17
AI Technical Summary
Existing technologies have poor compression performance for trajectory data, making it impossible to efficiently query specific information. Furthermore, lossless compression cannot fully realize the potential of lossless compression of data content, and overall compression is not conducive to efficient querying.
The trajectory data is divided into different subsets according to its content. The data type of each subset is determined, and the data is divided into common part and feature part for storage according to the data type. Hardware-based floating-point compression algorithm, timestamp sequence difference compression, data dictionary and integer data compression methods are used to integrate the compressed subsets.
It realizes the maximum lossless compression potential of trajectory data, improves compression performance, and supports efficient and fine-grained query operations.
Smart Images

Figure CN114490546B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and in particular to a method, apparatus, electronic device, and storage medium for compressing trajectory data. Background Technology
[0002] With the advent of the big data era, data compression can alleviate the storage pressure on storage devices. Current technologies for compressing trajectory data generally involve lossless compression of the trajectory data as a whole.
[0003] In the process of realizing this invention, the inventors discovered that the prior art has at least the following technical problems: poor compression performance and inability to efficiently query specific information. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for compressing trajectory data, in order to solve the technical problems of poor compression performance of trajectory data and inability to efficiently query specific information.
[0005] In a first aspect, the present invention provides a method for compressing trajectory data, comprising: dividing the trajectory data to be compressed into different subsets according to the data content; determining the data type corresponding to the subsets, and determining the common data portion corresponding to all data in the subsets and the data feature portion corresponding to each data based on the data type, wherein the common data portion and the data feature portion corresponding to each data constitute a compressed subset; and integrating the various compressed subsets to obtain compressed trajectory data.
[0006] As an optional embodiment, the data content includes at least one of the following: spatial data, time data, and other data; the data type includes at least one of the following: floating-point type, long integer type, string type, and integer type.
[0007] As an optional embodiment, the spatial data is latitude and longitude data. The step of determining the data type corresponding to the subset and determining the common data part and the data feature part corresponding to each data in the subset based on the data type, wherein the common data part and the data feature part corresponding to each data constitute the compressed subset, includes: if the data type corresponding to the latitude and longitude data is determined to be floating point, then the common data part is determined to be the common value of all latitude and longitude data, and the data feature part is the XOR result of each latitude and longitude data and the common value; the leading zeros of the XOR result are folded, and the common value and the folded XOR result constitute the compressed subset.
[0008] As an optional embodiment, the time data is a timestamp sequence. The step of determining the data type corresponding to the subset and determining the common data portion and the data feature portion corresponding to each data in the subset based on the data type, wherein the common data portion and the data feature portion corresponding to each data constitute the compressed subset, includes: if the data type corresponding to the timestamp sequence is determined to be a long integer, then the common data portion is determined to be the starting timestamp of the timestamp sequence, and the data feature portion is a first difference, wherein the starting timestamp and the first difference constitute the compressed subset; wherein the first difference is the change value of the later timestamp relative to the earlier timestamp.
[0009] As an optional embodiment, the time data is a timestamp sequence. The step of determining the data type corresponding to the subset and determining the common data portion and the data feature portion corresponding to each data in the subset based on the data type, wherein the common data portion and the data feature portion corresponding to each data constitute the compressed subset, includes: if the data type corresponding to the timestamp sequence is determined to be a long integer, then the common data portion is determined to be the starting timestamp of the timestamp sequence, and the data feature portion is a second difference, wherein the starting timestamp and the second difference constitute the compressed subset; wherein the second difference is the change value of the next first difference relative to the previous first difference, and the first difference is the change value of the next timestamp relative to the previous timestamp.
[0010] As an optional embodiment, the method further includes: if it is determined that the data type corresponding to the subset is string, then according to a preset mapping relationship table, converting the string data in the subset into corresponding encoded data, wherein the preset mapping relationship table stores the mapping relationship between string data and encoded data, and the data type of the encoded data is integer; compressing the encoded data according to an integer data compression algorithm to obtain the compressed subset.
[0011] As an optional embodiment, the method further includes: if it is determined that the data type corresponding to the subset is integer, then compressing the data in the subset according to the integer data compression algorithm to obtain the compressed subset.
[0012] As an optional embodiment, the integer data compression algorithm includes: storing the binary data corresponding to the integer data according to a first part and a second part; wherein, the first part is the number of leading zeros in the binary data, and the second part is the valid information part in the binary data.
[0013] Secondly, the present invention provides a trajectory data compression device, comprising: a partitioning module for partitioning the trajectory data to be compressed into different subsets according to the data content; a determining module for determining the data type corresponding to the subsets, and determining the common data portion corresponding to all data in the subsets and the data feature portion corresponding to each data based on the data type, wherein the common data portion and the data feature portion corresponding to each data constitute the compressed subsets; and an integration module for integrating the various compressed subsets to obtain compressed trajectory data.
[0014] Thirdly, the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the steps of the trajectory data compression method described in any one of the first aspects when executing the program stored in the memory.
[0015] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the trajectory data compression method as described in any of the first aspects.
[0016] The trajectory data compression method, apparatus, electronic device, and storage medium provided in this invention divide the trajectory data to be compressed into different subsets according to the data content; determine the data type corresponding to each subset; and determine the common data portion and the data feature portion corresponding to each data in each subset based on the data type. The common data portion and the data feature portion corresponding to each data constitute the compressed subset; integrate the various compressed subsets to obtain the compressed trajectory data. That is, in this invention, the trajectory data to be compressed is first divided according to the data content, so that the data in each subset has a high degree of similarity. Then, the data type of each subset can be determined, and the data is divided into a common portion and a feature portion for storage according to the data type of the subset. This realizes the maximum lossless compression potential of different data types, improves compression performance, and also realizes efficient and fine-grained query operations on trajectory data. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A schematic diagram of a lossless trajectory data compression method provided by existing technology;
[0020] Figure 2 A flowchart illustrating a trajectory data compression method provided in an embodiment of the present invention;
[0021] Figure 3 A flowchart illustrating another method for compressing trajectory data provided in an embodiment of the present invention;
[0022] Figure 4 A model architecture diagram of a hardware-based floating-point compression algorithm provided for an embodiment of the present invention;
[0023] Figure 5 A schematic diagram of string data compression provided in an embodiment of the present invention;
[0024] Figure 6 This is a schematic diagram of a trajectory data compression method provided in an embodiment of the present invention;
[0025] Figure 7 This is a schematic diagram of the structure of a trajectory data compression device provided in an embodiment of the present invention;
[0026] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] With the advent of the big data era, cities generate massive amounts of trajectory data, including data on vehicles, people, and various devices. This trajectory data is not only enormous in volume, but each trajectory typically contains tens of thousands or even millions of coordinates, timestamps, and other information. Existing trajectory data compression strategies can be broadly categorized into lossy compression and lossless compression.
[0029] Lossy compression, under the premise that the error between the compressed trajectory and the original trajectory is within an acceptable range, excludes points that are spatially close in time and space without affecting the overall trend of the trajectory. It occupies less space by simplifying the data. This approach, under current technological conditions, sacrifices some data accuracy for smaller storage space. However, with the development of the smart city industry in recent years, the demand for trajectory data has become more diverse. A single trajectory often contains information beyond just coordinate points, and lossy compression leads to the loss of information in multiple dimensions. This makes this type of compression technology only suitable for tasks that focus solely on the shape and trend of the trajectory, and unsuitable for multi-purpose trajectory data mining tasks. Especially when real-time processing, analysis, and visualization of this trajectory data are required, efficient and lossless compression and storage of the trajectory data are necessary, along with efficient query operations.
[0030] Lossless compression, on the other hand, compresses the trajectory object and its associated information as a whole. This results in a larger file size and a relatively lower compression ratio, but it can retain 100% of the original information and supports specific data point queries. Commonly used lossless compression algorithms include Zip, Gzip, Zstd, and Kryo. This compression strategy typically converts the trajectory data into a byte array before finally storing it in a database. Figure 1 As shown, Figure 1 This diagram illustrates a lossless compression method for trajectory data provided by existing technology. Lossless compression suffers from the following problems: on the one hand, it cannot fully realize the maximum lossless compression potential of different data contents; on the other hand, overall lossless compression is not conducive to efficiently retrieving specific information.
[0031] To address the aforementioned technical problems, the technical concept of this invention is as follows: First, the trajectory data to be compressed is divided according to its content, so that the data in each subset has a high degree of similarity. Then, the data type of each subset can be determined, and the data is divided into a common part and a feature part for storage according to the data type of the subset.
[0032] Figure 2 This is a flowchart illustrating a trajectory data compression method provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the compression method for this trajectory data includes:
[0033] Step S101: Divide the trajectory data to be compressed into different subsets according to the data content.
[0034] Optionally, the data content includes at least one of the following: spatial data, temporal data, and other data. In this step, the trajectory data to be compressed can be divided into subsets corresponding to spatial data, temporal data, and other data content. The spatial data can be latitude and longitude data, the temporal data can be a timestamp sequence, and the other data can be attribute information of the trajectory data, etc.
[0035] It should be noted that the data in the subsets divided according to the data content usually have a high degree of similarity. For example, latitude and longitude data are a series of data with very small variations and the same data type, and timestamp series are a series of data with very small variations and the same data type. This also facilitates efficient and fine-grained querying of specific information later.
[0036] Step S102: Determine the data type corresponding to the subset, and determine the common data part and the data feature part corresponding to each data in the subset based on the data type. The common data part and the data feature part corresponding to each data constitute the compressed subset.
[0037] Optionally, the data type includes at least one of the following: floating-point, long integer, integer, and string. In this step, the data type corresponding to each subset is first determined. For example, if the spatial data is latitude and longitude data, the data type is usually determined to be floating-point; if the time data is a timestamp sequence, the data type is usually long integer. Then, based on the different data types, the common data portion corresponding to all data in the subset and the data feature portion corresponding to each data point are determined. For example, for floating-point latitude and longitude data, the common data portion of the subset is determined to be the common value of all latitude and longitude data, and the data feature portion is the XOR result of each latitude and longitude data point with the common value. The common value and the XOR result corresponding to each data point constitute the compressed subset. For long integer timestamp sequences, the common data portion of the subset is determined to be the starting timestamp, and the data feature portion is the difference between the subsequent timestamp and the previous timestamp. The starting timestamp and the difference corresponding to each data point constitute the compressed subset.
[0038] Step S103: Integrate the various compressed subsets to obtain compressed trajectory data.
[0039] Specifically, after taking the common part of the data and the data feature part corresponding to each data as a compressed subset, the compressed subset is integrated to obtain the compressed trajectory data.
[0040] The trajectory data compression method provided in this invention divides the trajectory data to be compressed into different subsets according to the data content; determines the data type corresponding to each subset; and determines the common data part and the data feature part corresponding to each data in each subset based on the data type. The common data part and the data feature part corresponding to each data constitute the compressed subset. The compressed subsets are then integrated to obtain the compressed trajectory data. In other words, in this invention, the trajectory data to be compressed is first divided according to the data content, so that the data in each subset has a high degree of similarity. Then, the data type of each subset can be determined, and the data is divided into a common part and a feature part for storage according to the data type of the subset. This realizes the maximum lossless compression potential of different data types, improves compression performance, and also enables efficient and fine-grained query operations on trajectory data.
[0041] Based on the above embodiments, Figure 3 This is a flowchart illustrating another method for compressing trajectory data provided in an embodiment of the present invention. The data content includes at least one of the following: spatial data, temporal data, and other data; the data type includes at least one of the following: floating-point, long integer, string, and integer. For example... Figure 3 As shown, the compression method for this trajectory data includes:
[0042] Step S201: Divide the trajectory data to be compressed into different subsets according to the data content.
[0043] If the spatial data is latitude and longitude data, then execute steps S202 and S203; if the time data is a timestamp sequence, then execute step S204.
[0044] Step S202: If it is determined that the data type corresponding to the latitude and longitude data is floating point, then the common part of the data is determined to be the common value of all latitude and longitude data, and the data feature part is the XOR result of each latitude and longitude data and the common value.
[0045] Step S203: Fold the leading zeros of the XOR result. The common value and the XOR result after folding constitute the compressed subset.
[0046] Step S204: If it is determined that the data type corresponding to the timestamp sequence is a long integer, then the common part of the data is determined to be the starting timestamp of the timestamp sequence, the data feature part is the first difference, and the starting timestamp and the first difference constitute the compressed subset.
[0047] The first difference is the change in the second timestamp relative to the first timestamp.
[0048] Step S205: Integrate the various compressed subsets to obtain compressed trajectory data.
[0049] The implementation methods of steps S201 and S205 in this embodiment are similar to those of steps S101 and S103 in the above embodiments, and will not be described again here.
[0050] The difference from the above embodiments is that this embodiment further defines the optimal compression method for each data type subset. In this embodiment, if the data type corresponding to the latitude and longitude data is determined to be floating-point, then the common part of the data is determined to be the common value of all latitude and longitude data, and the data feature part is the XOR result of each latitude and longitude data and the common value; the leading zeros of the XOR result are folded, and the common value and the folded XOR result constitute the compressed subset; if the data type corresponding to the timestamp sequence is determined to be long integer, then the common part of the data is determined to be the starting timestamp of the timestamp sequence, and the data feature part is the first difference, and the starting timestamp and the first difference constitute the compressed subset; wherein, the first difference is the change value of the later timestamp relative to the earlier timestamp.
[0051] Specifically, an indispensable part of trajectory data is the spatial point data, which is generally described by latitude and longitude data. Latitude and longitude data are usually decimals, collectively referred to as floating-point data types in computers. They are generally stored and defined using the IEEE 754 standard. Therefore, during the storage process, all bits of the binary number need to be stored. For example, for a double-precision floating-point number, 8 bytes (64 bits) are used for storage. However, in a trajectory scenario, the longitude range is -180° to 180°, and the latitude range is -90° to 90°. Compared to these entire ranges, the change in the trajectory's movement is very small; that is, the change in the floating-point data is also very small. For example, for trajectory points within the Sixth Ring Road of Beijing, the longitude ranges between 116.279512 and 116.499705, and the latitude ranges between 39.989051 and 39.834976. It can be seen that the range of variation of all longitude and latitude is very small. If we use the existing common floating-point data expression standard, all data bits need to be stored, resulting in a huge waste of space.
[0052] Therefore, in this embodiment, a hardware-based floating-point compression algorithm is used to compress latitude and longitude data. This compression algorithm can make full use of the characteristics of the central processing unit (CPU) in floating-point data processing, extract the common part of the floating-point data, and only store the characteristic part of each floating-point data, which greatly reduces the space occupation of the floating-point data.
[0053] Figure 4 A model architecture diagram of a hardware-based floating-point compression algorithm provided in an embodiment of the present invention is shown below. Figure 4 As shown, multiple latitude and longitude data are input into the model. First, a common value is determined based on these multiple latitude and longitude data as the predicted value, and this common value is stored as the basic floating-point data. Then, the multiple latitude and longitude data are XORed with the predicted value. This will turn many of the leading bits of the latitude and longitude data into zeros. The CPU can directly obtain the number of leading zeros, i.e., the number of leading zero bits. These bits are then folded. Finally, only the XORed and folded data needs to be stored, which greatly reduces the amount of data. This achieves compression and efficient storage of massive latitude and longitude data.
[0054] For example, if the input longitude data includes 117.11, 117.12, and 117.13, the common value is determined to be 117.1 (stored as basic floating-point data) and used as the predicted value. The first longitude data 117.11 is XORed with the predicted value to obtain 000.01, which is used as the change value 1. The second longitude data 117.12 is XORed with the predicted value to obtain 000.02, which is used as the change value 2, and so on, to obtain change values 3, 4, etc. Then, each change value is processed by a hash function to make the distribution of the change values more even, resulting in a hash table. Then, the basic floating-point data and the data in the hash table are processed by a prediction function, that is, the leading zeros of the above change values are folded to obtain difference values 0.01, 0.02, 0.03, etc., and the difference values are output as compressed data.
[0055] Using a hardware-based floating-point compression algorithm to compress latitude and longitude data significantly improves compression capabilities and speeds up compression. For example, for 1GB of data, the compression ratio can reach up to 1.7, and the compression speed is the fastest among similar algorithms (such as bzip2, gzip, and p7zip). The average compression time for the same amount of data can be reduced by more than 50% compared to similar algorithms.
[0056] Secondly, each trajectory point in the trajectory data has corresponding time data, which is crucial for describing trajectory information. However, this also presents the problem of excessive redundant storage. Typically, time data is stored as a timestamp, representing the time in milliseconds since January 1, 1970, 00:00:00—a very long integer. However, the time range of trajectory data is generally small. If the current storage method is followed, past time information will be redundantly stored, consuming a significant amount of space.
[0057] In this embodiment, instead of redundantly storing all the original millisecond time values, the minimum value in the timestamp sequence is stored separately as a common part of the data. The subsequent values only store the change value relative to the previous timestamp, i.e., the first difference delta. In this way, the time data of each line of trajectory point data only needs to store the change value, instead of storing the full time information, which can greatly reduce the actual amount of time data stored.
[0058] As an optional embodiment, the time data is a timestamp sequence, and step S102 includes: if it is determined that the data type corresponding to the timestamp sequence is a long integer, then the common part of the data is determined to be the starting timestamp of the timestamp sequence, the data feature part is the second difference, and the starting timestamp and the second difference constitute the compressed subset; wherein, the second difference is the change value of the next first difference relative to the previous first difference, and the first difference is the change value of the next timestamp relative to the previous timestamp.
[0059] Specifically, for timestamp sequences, the data feature part can also be the second difference delta-of-delta, that is, the data feature part corresponding to each data is the change value of the next delta relative to the previous delta.
[0060] Table 1 shows the storage space before and after timestamp sequence compression according to an embodiment of the present invention. As shown in Table 1, for a series of timestamps, if the traditional timestamp storage method is used, each data point requires 64 bits of storage space, totaling 512 bits of storage space to store all the time data in the table. In this embodiment, if the data feature is the first difference delta, then 155 bits of storage space are required; if the data feature is the second difference delta-of-delta, then only 103 bits of storage space are needed. Obviously, the timestamp sequence compression method provided in this embodiment will have a more significant improvement in storage space for the massive amount of trajectory data in real trajectory data scenarios.
[0061] Furthermore, as can be seen from Table 1, using delta-of-delta-based storage saves more storage space than using delta-based storage because the stored delta-of-delta may contain consecutive zeros, resulting in greater compression space.
[0062] Table 1
[0063] Unix timestamp delta delta-of-delta Number of bits after compression 1561889600000 0 0 64 1561889600010 10 10 9 1561889600010 0 -10 9 1561889600011 1 1 9 1561889600012 1 0 1 1561889600013 1 0 1 1561889600015 2 1 9 1561889600017 2 0 1
[0064] As an optional embodiment, the method further includes: if it is determined that the data type corresponding to the subset is string, then according to a preset mapping relationship table, converting the string data in the subset into corresponding encoded data, wherein the preset mapping relationship table stores the mapping relationship between string data and encoded data, and the data type of the encoded data is integer; compressing the encoded data according to an integer data compression algorithm to obtain the compressed subset.
[0065] Specifically, in trajectory data, spatial or temporal data can be of string type, or other data included in the trajectory data can also be of string type, such as information about provinces, cities, districts, and counties. Traditional storage methods store all string data, leading to the repeated storage of the same strings and wasting storage space.
[0066] Therefore, this embodiment employs a data dictionary approach, where string data, such as the names of provinces, cities, districts, and counties, are encoded (usually as integers) and stored in memory. Only the encoding and a mapping table between string data and its encoding need to be stored. This method significantly reduces the space occupied by string data. Furthermore, converting it to integer types like 1, 2, and 3 allows for compression using integer compression methods, further facilitating data storage.
[0067] Figure 5 This is a schematic diagram illustrating the compression of string data according to an embodiment of the present invention. Figure 5 As shown, Beijing, Shanghai, and Shanxi are mapped to integers 1, 2, and 3 respectively. If trajectory points 1, 2, 3, and 4 are in Beijing, only the corresponding code 1 needs to be stored. If trajectory points 5, 6, and 7 are in Shanghai, only the corresponding code 2 needs to be stored. If trajectory points 8, 9, 10, and 12 are in Shanxi, only the corresponding code 3 needs to be stored.
[0068] As an optional embodiment, if it is determined that the data type corresponding to the subset is integer, then the data in the subset is compressed according to the integer data compression algorithm to obtain the compressed subset.
[0069] Specifically, in trajectory data, the data types of spatial or temporal data may also be integers, or other data included in the trajectory data may correspond to integer data types. In such cases, they can be compressed and stored using integer data compression methods.
[0070] As an optional embodiment, the integer data compression algorithm includes: storing the binary data corresponding to the integer data according to a first part and a second part; wherein, the first part is the number of leading zeros in the binary data, and the second part is the valid information part in the binary data.
[0071] Specifically, in the underlying layers of a computer, integers are generally stored as binary data. For ease of storage and computation, these binary types and lengths are often fixed. For example, the Int type has a default length of 32 bits. Table 2 shows an example of binary storage for integer data provided in this embodiment of the invention. However, the problem with this storage method is that binary numbers often contain long, meaningless "0"s, resulting in wasted storage space.
[0072] Table 2
[0073] Original value Binary (Int type, 32 bits) 12 00000000000000000000000000001100 1000 00000000000000000000001111101000
[0074] Therefore, in this embodiment, the binary data is stored in two parts. The first part stores the number of leading zeros in the binary data, that is, the number of meaningless "0"s at the beginning of the number. The second part stores the valid information part of the binary data, thereby achieving compression of integer data.
[0075] To facilitate further understanding of this embodiment, Figure 6 This is a schematic diagram of a trajectory data compression method provided in an embodiment of the present invention, as shown below. Figure 6 As shown, the trajectory data to be compressed is processed by a data distributor to obtain floating-point latitude and longitude data, long integer timestamp sequences, string data, and integer data. For the floating-point latitude and longitude data, a hardware-based floating-point data compression method is used to obtain the corresponding compressed subset. For the long integer timestamp sequences, a delta-of-delta compression algorithm is used to obtain the corresponding compressed subset. For the string data, a data dictionary compression method is used to obtain the corresponding compressed subset. For the integer data, an integer data compression algorithm is used to obtain the corresponding compressed subset. Then, the compressed subsets are integrated by the data distributor to obtain the compressed trajectory data, which is then stored.
[0076] The trajectory data compression method provided in the embodiments of the present invention, if it is determined that the data type corresponding to the latitude and longitude data is floating point, then the common part of the data is determined to be the common value of all latitude and longitude data, and the data feature part is the XOR result of each latitude and longitude data and the common value; the leading zero bits of the XOR result are folded, and the common value and the folded XOR result constitute the compressed subset; if it is determined that the data type corresponding to the timestamp sequence is long integer, then the common part of the data is determined to be the starting timestamp of the timestamp sequence, and the data feature part is the first difference, and the starting timestamp and the first difference constitute the compressed subset; wherein, the first difference is the change value of the later timestamp relative to the earlier timestamp; that is, the embodiments of the present invention first determine the data types corresponding to the spatial data and the temporal data, and then use the optimal compression method for the data type for compression, thereby realizing the maximum lossless compression potential of different data types, improving compression performance, and also realizing efficient and fine-grained query operations on trajectory data.
[0077] Figure 7 This is a schematic diagram of the structure of a trajectory data compression device provided in an embodiment of the present invention, as shown below. Figure 7 As shown, the compression device for the trajectory data includes:
[0078] The segmentation module 10 is used to divide the trajectory data to be compressed into different subsets according to the data content; the determination module 20 is used to determine the data type corresponding to the subsets, and determine the common data part and the data feature part corresponding to each data in the subsets according to the data type, wherein the common data part and the data feature part corresponding to each data constitute the compressed subsets; the integration module 30 is used to integrate the various compressed subsets to obtain the compressed trajectory data.
[0079] As an optional embodiment of the present invention, the data content includes at least one of the following: spatial data, time data, and other data; the data type includes at least one of the following: floating-point type, long integer type, string type, and integer type.
[0080] As an optional embodiment of the present invention, the spatial data is latitude and longitude data, and the determining module 20 is specifically used for: if it is determined that the data type corresponding to the latitude and longitude data is floating point type, then the common part of the data is determined to be the common value of all latitude and longitude data, and the data feature part is the XOR result of each latitude and longitude data and the common value; the leading zero bits of the XOR result are folded, and the common value and the XOR result after folding constitute the compressed subset data.
[0081] As an optional embodiment of the present invention, the time data is a timestamp sequence, and the determining module 20 is specifically used to: if it is determined that the data type corresponding to the timestamp sequence is a long integer, then determine that the common part of the data is the starting timestamp of the timestamp sequence, the data feature part is a first difference, and the starting timestamp and the first difference constitute the compressed subset; wherein, the first difference is the change value of the later timestamp relative to the earlier timestamp.
[0082] As an optional embodiment of the present invention, the time data is a timestamp sequence, and the determining module 20 is specifically used to: if it is determined that the data type corresponding to the timestamp sequence is a long integer, then determine that the common part of the data is the starting timestamp of the timestamp sequence, the data feature part is the second difference, and the starting timestamp and the second difference constitute the compressed subset; wherein, the second difference is the change value of the next first difference relative to the previous first difference, and the first difference is the change value of the next timestamp relative to the previous timestamp.
[0083] As an optional embodiment of the present invention, the determining module 20 is further configured to: if it is determined that the data type corresponding to the subset is the string type, then convert the string type data in the subset into the corresponding encoded data according to the preset mapping relationship table, wherein the preset mapping relationship table stores the mapping relationship between string type data and encoded data, and the data type of the encoded data is integer; compress the encoded data according to the integer data compression algorithm to obtain the compressed subset.
[0084] As an optional embodiment of the present invention, the determining module 20 is further configured to: if it is determined that the data type corresponding to the subset is the integer, then compress the data in the subset according to the integer data compression algorithm to obtain the compressed subset.
[0085] As an optional embodiment of the present invention, the determining module 20 is further used to implement the integer data compression algorithm, which includes: storing the binary data corresponding to the integer data according to a first part and a second part; wherein, the first part is the number of leading zeros in the binary data, and the second part is the valid information part in the binary data.
[0086] The trajectory data compression device provided in this embodiment has a similar implementation principle and technical effect to the above embodiments, and will not be described again here.
[0087] The trajectory data compression device provided in this embodiment of the invention includes a partitioning module for dividing the trajectory data to be compressed into different subsets according to the data content; a determining module for determining the data type corresponding to each subset, and determining the common data portion and the data feature portion corresponding to each data in each subset based on the data type, wherein the common data portion and the data feature portion corresponding to each data constitute the compressed subset; and an integration module for integrating the various compressed subsets to obtain compressed trajectory data. In other words, in this embodiment of the invention, the trajectory data to be compressed is first divided according to the data content, making the data in each subset highly similar. Then, the data type of each subset can be determined, and the data is divided into a common portion and a feature portion for storage based on the data type of the subset. This achieves the maximum lossless compression potential for different data types, improves compression performance, and also enables efficient and fine-grained query operations on the trajectory data.
[0088] like Figure 8 As shown, this embodiment of the invention provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0089] Memory 113 is used to store computer programs;
[0090] In one embodiment of the present invention, when the processor 111 executes the program stored in the memory 113, it implements the steps of the trajectory data compression method provided in any of the foregoing method embodiments.
[0091] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the trajectory data compression method provided in any of the foregoing method embodiments.
[0092] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0093] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method of compressing trajectory data, characterized by, The method comprises the following steps: dividing trajectory data to be compressed into different sub-data sets according to data content, the data content comprising at least one of spatial data, time data, and other data; determining the data type corresponding to the sub-data set, and determining the data public part corresponding to all data in the sub-data set and the data characteristic part corresponding to each data according to the data type, the data public part and the data characteristic part corresponding to each data constituting the compressed sub-data set; integrating each compressed sub-data set to obtain compressed trajectory data; the spatial data is latitude and longitude data, the determination of the data type corresponding to the sub-data set, and the determination of the data public part corresponding to all latitude and longitude data and the data characteristic part corresponding to each latitude and longitude data according to the data type, the data public part and the data characteristic part corresponding to each data constituting the compressed sub-data set, comprising: if it is determined that the data type corresponding to the latitude and longitude data is a floating-point type, then determining that the data public part is a public value of all latitude and longitude data, and the data characteristic part is an exclusive-OR result of each latitude and longitude data and the public value; performing folding processing on the leading zero bits of the exclusive-OR result, and the public value and the exclusive-OR result after the folding processing constitute the compressed sub-data set.
2. The method of claim 1, wherein, The data type comprises at least one of a floating-point type, a long integer type, a string type, and an integer type.
3. The method of claim 2, wherein, The time data is a time stamp sequence, the determination of the data type corresponding to the sub-data set, and the determination of the data public part corresponding to all data in the sub-data set and the data characteristic part corresponding to each data according to the data type, the data public part and the data characteristic part corresponding to each data constituting the compressed sub-data set, comprising: if it is determined that the data type corresponding to the time stamp sequence is a long integer type, then determining that the data public part is a start time stamp of the time stamp sequence, and the data characteristic part is a first difference value, the start time stamp and the first difference value constituting the compressed sub-data set; wherein the first difference value is a change value of a subsequent time stamp relative to a previous time stamp.
4. The method of claim 2, wherein, The time data is a time stamp sequence, the determination of the data type corresponding to the sub-data set, and the determination of the data public part corresponding to all data in the sub-data set and the data characteristic part corresponding to each data according to the data type, the data public part and the data characteristic part corresponding to each data constituting the compressed sub-data set, comprising: if it is determined that the data type corresponding to the time stamp sequence is a long integer type, then determining that the data public part is a start time stamp of the time stamp sequence, and the data characteristic part is a second difference value, the start time stamp and the second difference value constituting the compressed sub-data set; wherein the second difference value is a change value of a subsequent first difference value relative to a previous first difference value, and the first difference value is a change value of a subsequent time stamp relative to a previous time stamp.
5. The method of claim 2, wherein, The method further comprises: If it is determined that the data type corresponding to the sub-data set is the string type, then the string type data in the sub-data set is converted into corresponding encoded data according to a preset mapping relationship table, wherein the mapping relationship table stores the mapping relationship between the string type data and the encoded data, and the data type of the encoded data is the integer type; The encoded data is compressed according to an integer type data compression algorithm, as a compressed sub-data set.
6. The method of claim 2, wherein, The method further comprises: If it is determined that the data type corresponding to the sub-data set is the integer type, then the data in the sub-data set is compressed according to an integer type data compression algorithm, as a compressed sub-data set.
7. The method according to claim 5 or 6, characterized in that, The integer type data compression algorithm comprises: The binary data corresponding to the integer type data is stored according to a first part and a second part; wherein the first part is the number of leading zero bits in the binary data, and the second part is the effective information part in the binary data.
8. A trajectory data compression apparatus characterized by comprising: Comprises: The division module is configured to divide the trajectory data to be compressed into different sub-data sets according to data content, wherein the data content comprises at least one of the following: spatial data, time data, and other data; The determination module is configured to determine the data type corresponding to the sub-data set, and determine the data public part corresponding to all data in the sub-data set and the data characteristic part corresponding to each data according to the data type, wherein the data public part and the data characteristic part corresponding to each data constitute a compressed sub-data set; The integration module is configured to integrate the compressed sub-data sets to obtain compressed trajectory data; The spatial data is latitude and longitude data, and the determination module is specifically configured to: If it is determined that the data type corresponding to the latitude and longitude data is the floating point type, then the data public part is determined to be the public value of all latitude and longitude data, and the data characteristic part is the exclusive or result of each latitude and longitude data and the public value; The leading zero bits of the exclusive or result are folded, and the public value and the folded exclusive or result constitute the compressed sub-data set.
9. An electronic device, comprising: The device comprises a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is configured to store a computer program; The processor is configured to execute the program stored in the memory, and implement the steps of the trajectory data compression method according to any one of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the trajectory data compression method according to any one of claims 1-7.
Citation Information
Patent Citations
Data storage method and device, and computer equipment
CN108233942A
Multi-channel compression method and device for data set and storage medium
CN111010189A
Time series data compression method, device and equipment
CN111181569A