A data encoding method, operation method, device, equipment and medium
By converting fixed-point data into integer data and separating symbols from absolute values for encoding, the problem of low spatial compression rate in traditional methods is solved, and more efficient data encoding is achieved, reducing spatial redundancy.
Patent Information
- Application Number
- CN202410922385.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2025-05-20
- Estimated Expiration
- 2044-07-10
AI Technical Summary
In the process of data encoding, traditional methods lead to lower spatial compression rates, especially when user-defined accuracy far exceeds the accuracy of actually stored data.
By converting the fixed-point data to be encoded into integer data, splitting it into symbols and absolute values, and encode the symbols and absolute values respectively based on the preset encoding method to form symbol vectors and absolute values vectors, and finally mapping them to form the encoding result.
This method effectively avoids symbol encoding placeholding, improves the compression rate of absolute value encoding, thereby reducing spatial redundancy and improving spatial compression rate.
Smart Images

Figure CN118921067B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data encoding, and particularly to a data encoding method, an operation method, a device, a device and a medium. Background Art
[0002] Fixed-point numbers are data types in the Structured Query Language database standard. In the field of columnar databases, in order to optimize the encoding method of fixed-point number types, various encoding schemes have been proposed in the industry. The mainstream encoding scheme is: according to the precision defined by the fixed-point number, use a fixed-length integer for storage. However, this leads to a problem that when the precision defined by the user far exceeds the precision of the actually stored data, the traditional method will have more space redundancy, resulting in a low space compression rate. Therefore, in the process of data encoding, how to improve the space compression rate has become an urgent problem to be solved. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a data encoding method, an operation method, a device, a device and a medium to solve the problem of low space compression rate in the process of data encoding.
[0004] In a first aspect, an embodiment of the present invention provides a data encoding method, and the data encoding method includes:
[0005] Obtain the fixed-point number data to be encoded;
[0006] Convert the fixed-point number data to be encoded into integer data, and determine the sign and absolute value of the integer data;
[0007] Based on a preset encoding method, encode the sign to obtain a sign vector of the sign, and encode the absolute value to obtain an absolute value vector of the absolute value;
[0008] Map the sign vector and the absolute value vector to form an encoding result of the fixed-point number data to be encoded.
[0009] In a second aspect, an embodiment of the present invention provides an operation method for encoded data, and the operation method includes:
[0010] Obtain the data to be operated, and use the data to be operated as the fixed-point number data to be encoded;
[0011] Use the data encoding method described in the first aspect to encode the data to be operated to obtain an encoding result of the data to be operated;
[0012] According to the sign vector and the absolute value vector in the encoding result of the data to be operated, use a bit operator matching the preset encoding method to operate on the sign vector and the absolute value vector of the data to be operated to obtain an operation result.
[0013] In a third aspect, an embodiment of the present invention provides a data encoding device, which includes:
[0014] A first acquisition module, configured to acquire fixed-point number data to be encoded;
[0015] A conversion module, configured to convert the fixed-point number data to be encoded into integer data, and determine the sign and absolute value of the integer data;
[0016] A first encoding module, configured to encode the sign based on a preset encoding method to obtain a sign vector of the sign, and encode the absolute value to obtain an absolute value vector of the absolute value;
[0017] A mapping module, configured to map the sign vector and the absolute value vector to form an encoding result of the fixed-point number data to be encoded.
[0018] In a fourth aspect, an embodiment of the present invention provides an arithmetic device for encoded data, and the device method includes:
[0019] A second acquisition module, configured to acquire data to be operated, and use the data to be operated as fixed-point number data to be encoded;
[0020] A second encoding module, configured to perform data encoding on the data to be operated by using the data encoding method described in the first aspect to obtain an encoding result of the data to be operated;
[0021] An arithmetic module, configured to perform an operation on the sign vector and the absolute value vector of the data to be operated by using a bit operator matching the preset encoding method according to the sign vector and the absolute value vector in the encoding result of the data to be operated to obtain an operation result.
[0022] In a fifth aspect, an embodiment of the present invention provides a computer device, which is characterized in that the computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the data encoding method described in the first aspect and the arithmetic method described in the second aspect are implemented.
[0023] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the data encoding method described in the first aspect and the arithmetic method described in the second aspect are implemented.
[0024] The beneficial effects of the present invention compared with the prior art are:
[0025] Obtain the fixed-point number data to be encoded, convert the fixed-point number data to be encoded into integer data, determine the sign and absolute value of the integer data, encode the sign based on a preset encoding method to obtain the sign vector of the sign, encode the absolute value to obtain the absolute value vector of the absolute value, and map the sign vector and the absolute value vector to form the encoding result of the fixed-point number data to be encoded. In this application, the fixed-point number data to be encoded is converted into integer data, and the integer data is split into a sign and an absolute value, so as to facilitate the separate processing of the sign and the absolute value. When storing in a fixed-length integer, it avoids the occupancy of the sign encoding in the encoding of the fixed-point number data to be encoded, facilitates the compression of the absolute value encoding, thereby reducing spatial redundancy and improving the spatial compression ratio. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments of the present invention. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0027] Figure 1 is a flowchart of a data encoding method provided by an embodiment of the present invention;
[0028] Figure 2 is a flowchart of an operation method for encoding data provided by an embodiment of the present invention;
[0029] Figure 3 is a structural diagram of a data encoding device provided by an embodiment of the present invention;
[0030] Figure 4 is a structural diagram of an operation device for encoding data provided by an embodiment of the present invention;
[0031] Figure 5 is a structural diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0032] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the protection scope of the present invention.
[0033] In the following description, specific details such as specific system architectures, technologies, etc. are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present invention. However, those skilled in the art should clearly understand that the present invention can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from obstructing the description of the present invention.
[0034] It should be understood that when used in the specification and claims of the present invention, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0035] It should also be understood that the term "and / or" used in the specification and claims of the present invention refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0036] As used in the specification and claims of the present invention, the term "if" can be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "if determined" or "if detecting [the described condition or event]" can be interpreted as meaning "once determined" or "in response to determining" or "once detecting [the described condition or event]" or "in response to detecting [the described condition or event]" depending on the context.
[0037] In addition, in the description of the specification and claims of the present invention, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0038] The reference to "one embodiment" or "some embodiments" etc. described in the specification of the present invention means that a specific feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of the present invention. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "comprising", "including", "having", and their variants all mean "including but not limited to", unless otherwise specifically emphasized in another way.
[0039] It should be understood that the magnitudes of the sequence numbers of the steps in the following embodiments do not imply the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0040] To illustrate the technical solution of the present invention, the following specific embodiments are used for illustration.
[0041] A data encoding method provided by an embodiment of the present invention is shown in Figure 1 , which is a schematic flowchart of a data encoding method provided by an embodiment of the present invention. As Figure 1 shown, the data encoding method may include the following steps.
[0042] S101: Obtain the fixed-point number data to be encoded.
[0043] In step S101, the fixed-point number data to be encoded is obtained, where the fixed-point number data to be encoded is data with a known number of digits and precision.
[0044] In this embodiment, the fixed-point number data to be encoded is obtained. For example, the fixed-point number data to be encoded may be data represented in the fixed-point number representation. The number of decimal places of the fixed-point number is fixed with the data precision. For example, the fixed-point number data Decimal(5, 2), (5, 2) indicates that the data precision of the fixed-point number data to be encoded is 5 digits, and the number of digits after the decimal point is 2 digits. Therefore, Decimal(5, 2) can represent any data between 000.01 and 999.99.
[0045] S102: Convert the fixed-point number data to be encoded into integer data, and determine the sign and absolute value of the integer data.
[0046] In step S102, the fixed-point number data to be encoded is converted into integer data, where the integer data is the data after removing the decimal point, and the sign and absolute value of the integer data are determined. Among them, the sign of the integer data includes a positive sign and a negative sign, and the absolute value of the integer data is related to the number of digits after the decimal point.
[0047] In this embodiment, the fixed-point number data to be encoded is converted into integer data, and the sign and absolute value of the integer data are determined. For example, if the fixed-point number data to be encoded is number(3,2), that is, the total number of digits of the data is 3, and the number of digits after the decimal point is 2. If the input is 3.1, it is represented as 3.10 after the fixed-point number data; if the fixed-point number data to be encoded is number(5,2), that is, the total number of digits of the data is 5, and the number of digits after the decimal point is 2. When the input is 3.1, it is represented as 003.10 after the fixed-point number data. The fixed-point number data to be encoded is converted into integer data, that is, the data after the decimal point is removed. For example, if it is represented as 003.10 after the fixed-point number data, it is converted into integer data 00310.
[0048] Determine the sign and absolute value of the integer data. For example, if the integer data is 310, the sign of the corresponding integer data is a positive sign, and the absolute value is 310. If the integer data is -310, the sign of the corresponding integer data is a negative sign, and the absolute value is 310.
[0049] It should be noted that after the fixed-point number data to be encoded is converted into integer data, if the first non-zero digit from left to right of the integer data is not the first digit from left to right of the data, the 0s before the corresponding first non-zero digit can be removed. For example, if the integer data is 00310, the 0s before 3 can be removed, and the integer data can be written as 310.
[0050] S103: Based on a preset encoding method, encode the sign to obtain the sign vector of the sign, and encode the absolute value to obtain the absolute value vector of the absolute value.
[0051] In step S103, based on a preset encoding method, encode the sign to obtain the sign vector of the sign, and encode the absolute value to obtain the absolute value vector of the absolute value. Among them, the preset encoding method is to encode the integer data into a preset data type, such as a binary type or a hexadecimal type. Encoding the sign and encoding the absolute value means encoding the sign and the absolute value into the corresponding type.
[0052] In this embodiment, based on a preset encoding method, encode the sign to obtain the sign vector of the sign, and encode the absolute value to obtain the absolute value vector of the absolute value. Among them, when encoding the sign, the corresponding sign is represented as a value in the type corresponding to the preset encoding method. For example, if the preset encoding method is binary encoding, when encoding the sign, the corresponding sign is encoded as the corresponding 0 or 1 value. If the preset encoding method is hexadecimal encoding, the corresponding sign is encoded as any value included in the corresponding hexadecimal, and the corresponding value is used as the sign vector. Encoding the absolute value means converting the corresponding absolute value into a value of the type corresponding to the preset encoding method as the absolute value vector.
[0053] In this embodiment, the sign and the absolute value are encoded respectively, so that the sign vector of the encoding result of the sign and the absolute value vector of the encoding result of the absolute value can be stored separately, which is convenient for subsequent compression of the vectors.
[0054] For example, if the preset encoding method is a binary encoding method, based on the preset encoding method, the sign is encoded, that is, the corresponding positive sign and negative sign are encoded into different vectors, that is, the corresponding positive sign and negative sign are encoded as 0 or 1. For example, if the positive sign is encoded as 1, that is, the sign vector is 1, then the corresponding negative sign is encoded as 0, and the sign vector is 0. If the positive sign is encoded as 0, that is, the sign vector is 0, then the corresponding negative sign is encoded as 1, and the sign vector is 1. The absolute value is encoded to obtain the absolute value vector of the absolute value, where encoding the absolute value means converting the corresponding absolute value into binary. For example, when the absolute value is 310, the corresponding binary is 100110110, that is, the corresponding absolute value vector is 100110110. If the sign vector of the positive sign is 1, the encoding result after encoding the integer data 310 is that the sign vector is 1 and the absolute value vector is 100110110.
[0055] It should be noted that if the fixed-point data to be encoded is in a group of multiple, and the precision of the fixed-point data in this group is equal, the sign vectors in the data in this group can be stored in the same vector, and the absolute value vectors can be stored in the same vector at the same time. For example, after converting multiple fixed-point data to be encoded into integer data, they are 310, -123, 234, -132. If the sign vector of the positive sign is encoded as 1 and the sign vector of the negative sign is encoded as 0, the encoding results of 310, -123, 234, -132 are that the sign vector is (1, 0, 1, 0) and the absolute value vector is (100110110, 1111011, 11101010, 10000100). When the fixed-point data to be encoded is in a group of multiple and the precision of the fixed-point data in this group is equal, the corresponding sign vector and absolute value vector can be stored separately, that is, store (1, 0, 1, 0) and (100110110, 1111011, 11101010, 10000100) separately.
[0056] In this embodiment, the sign and the absolute value in the integer data are encoded separately to prevent the sign vector from occupying the high-order encoding position when the sign and the absolute value are encoded in a single vector, which may cause the encoding vector of the corresponding absolute value to be unable to be compressed and thus occupy a large amount of memory. For example, if an integer storage with 64-bit is used, the encoding vector of the integer data needs to be converted to 64 bits. The first bit from left to right is the sign vector of the sign encoding. However, in this embodiment, the sign and the absolute value are encoded separately, and the sign vector does not occupy the bits of the absolute value vector. The 0s to the left of the first non-zero bit in the absolute value vector can be removed, saving storage space. For example, if an integer storage with 64-bit is used, the absolute value vector of the integer data 310 after absolute value encoding is 00...0000100110110, a total of 64 bits. After the sign vector does not occupy the corresponding bits, the absolute value vector 00...0000100110110 can be converted to 100110110. Counting one bit in the sign vector, the total is 10 bits, that is, converting 64 bits to 10 bits, improving the space compression ratio.
[0057] Optionally, encoding the sign to obtain the sign vector of the sign includes:
[0058] Judging the type of the sign;
[0059] If the type of the sign is a positive sign, encode the sign as a first value;
[0060] If the type of the sign is a negative sign, encode the sign as a second value.
[0061] In this embodiment, the corresponding preset encoding method is a binary encoding method, that is, the corresponding sign vector is 0 or 1. When encoding the sign of the integer data, first judge the type of the sign. If the type of the sign is a positive sign, encode the sign as a first value, where the first value is 1 or 0. If the type of the sign is a negative sign, encode the sign as a second value, where the second value is 1 or 0. It should be noted that the first value and the second value are not equal. If the first value is 1, the second value is 0. If the first value is 0, the second value is 1.
[0062] It should be noted that in this embodiment, if the type of the sign is a positive sign, the sign is encoded as 0. If the type of the sign is a negative sign, the sign is encoded as 1.
[0063] Optionally, encoding the absolute value to obtain the absolute value vector of the absolute value includes:
[0064] Convert the absolute value to binary data and judge the number of bits of the binary data;
[0065] If the number of bits of the binary data is greater than the preset value, then according to the preset value, the binary data is split into a first vector and a second vector, and based on the first vector and the second vector, an absolute value vector of the absolute value is determined;
[0066] If the number of bits of the binary data is not greater than the preset value, then the binary data is determined as the absolute value vector of the absolute value.
[0067] In this embodiment, the absolute value is encoded to obtain the absolute value vector of the absolute value, that is, the corresponding absolute value is converted into binary data. Among them, the binary data is binary data with all bits being valid bits, that is, the highest bit data in the binary data is non-zero data. After being converted into binary data, the number of bits of the binary data is judged. If the number of bits of the binary data is greater than the preset value, then according to the preset value, the binary data is split into a first vector and a second vector. Among them, the preset value can be the storage bit numbers of databases such as 32, 64, 128, and 256. The first vector and the second vector are vectors composed of the data after the binary data is split. For example, if the preset value is 64, when the number of bits of the binary data is greater than 64, the binary data is divided into a first vector and a second vector, and based on the first vector and the second vector, the absolute value vector of the absolute value is determined. Among them, the first vector can be a vector composed of the values in the number of bits higher than 64 in the binary data, that is, a vector composed of the values starting from the 65th bit from right to left, or it can be a vector composed of the corresponding values in the number of bits not greater than 64 in the lower bits, that is, a vector composed of the values from the 1st bit to the 64th bit from right to left. If the first vector is a vector composed of the values in the number of bits higher than 64 in the binary data, then the second vector is a vector composed of the corresponding values in the number of bits not greater than 64 in the lower bits. If the first vector is a vector composed of the corresponding values in the number of bits not greater than 64 in the lower bits, then the second vector is a vector composed of the values in the number of bits higher than 64.
[0068] If the number of bits of the binary data is not greater than the preset value, then the binary data is determined as the absolute value vector of the absolute value. For example, if the binary data is 100101, then the corresponding absolute value vector is 100101.
[0069] Optionally, splitting the binary data into a first vector and a second vector according to the preset value includes:
[0070] Count the number of bits of the binary data from right to left, and divide the binary data into a first part of data with the number of bits greater than the preset value and a second part of data with the number of bits not greater than the preset value;
[0071] Take the first part of data as the first vector and the second part of data as the second vector.
[0072] In this embodiment, the number of bits of the binary data is counted from right to left. The binary data is divided into a first part of data with the number of bits greater than a preset value and a second part of data with the number of bits not greater than the preset value. The first part of data is used as the first vector, and the second part of data is used as the second vector. That is, the vector composed of the values in the bits of the high bits greater than the preset value is used as the first vector, and the vector composed of the corresponding values in the bits of the low bits not greater than the preset value is used as the second vector. For example, if the preset value is 8, the number of bits of the binary data is counted from right to left. The first part of data with the number of bits of the binary data greater than 8 is used as the first vector, and the first part of data with the number of bits not greater than 8 is used as the second vector. For example, if the binary data is 10010010001, then 100 is used as the first vector, and 10010001 is used as the second vector.
[0073] It should be noted that if the first value of the highest bit in the second vector is 0, the corresponding 0 cannot be omitted.
[0074] S104: Map the symbol vector and the absolute value vector to form the encoding result of the fixed-point data to be encoded.
[0075] In step S104, according to the symbol vector and the absolute value vector, determine the encoding result of the fixed-point data to be encoded.
[0076] In this embodiment, the encoding result of the fixed-point data to be encoded includes two parts, namely the symbol vector and the absolute value vector. For example, if the symbol vector is 0 and the absolute value vector is 100110110, the corresponding encoding result is [(0),(100110110)].
[0077] Obtain the fixed-point data to be encoded, convert the fixed-point data to be encoded into integer data, determine the sign and absolute value of the integer data, encode the sign based on a preset encoding method to obtain the symbol vector of the sign, encode the absolute value to obtain the absolute value vector of the absolute value, and map the symbol vector and the absolute value vector to form the encoding result of the fixed-point data to be encoded. In this application, the fixed-point data to be encoded is converted into integer data, and the integer data is split into a sign and an absolute value, so as to facilitate separate processing of the sign and the absolute value. When storing in a fixed-length integer, it avoids the occupancy of the sign encoding in the encoding of the fixed-point data to be encoded, facilitates the compression of the absolute value encoding, thereby reducing the space redundancy and improving the space compression ratio.
[0078] See Figure 2 , which is a schematic flowchart of an operation method for encoding data provided by an embodiment of the present invention. As Figure 2 shown, the operation method for encoding data may include the following steps.
[0079] S201: Obtain the data to be operated on, and use the data to be operated on as the fixed-point data to be encoded;
[0080] S202: Use the above data encoding method to encode the data to be operated on, and obtain the encoding result of the data to be operated on;
[0081] S203: According to the sign vector and absolute value vector in the encoding result of the data to be operated on, use bitwise operators matching the preset encoding method to operate on the sign vector and absolute value vector of the data to be operated on, and obtain the operation result.
[0082] In this embodiment, the data to be operated on is obtained, and the data to be operated on is used as the fixed-point data to be encoded. The above data encoding method is used to encode the data to be operated on, and the encoding result of the data to be operated on is obtained. According to the sign vector and the absolute value vector in the encoding result of the data to be operated on, bitwise operators matching the preset encoding method are used to operate on the sign vector and the absolute value vector of the data to be operated on, and the operation result is obtained. For example, the data to be operated on is fixed-point data defined as (10, 2), which is (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79, 250929.78). Calculate the numbers in (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79) that are less than 250929.78. Encode the signs of (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79) to obtain the corresponding sign vector P1 = (0, 0, 1, 0, 1, 0, 1, 0). Encode the sign of 250929.78 to obtain the corresponding sign vector P2 = (0). Among them, the sign corresponding to the positive sign is encoded as 0, and the sign corresponding to the negative sign is encoded as 1. Perform an exclusive OR operation on the sign vectors to obtain the sign operation result P = (0, 0, 1, 0, 1, 0, 1, 0). Then convert the data to be operated on into integer data, compare the absolute values in the integer data, compare the magnitudes of the absolute values, and obtain the absolute value operation result Q = (0, 0, 0, 1, 0, 0, 0, 0). Among them, the comparison result of the absolute value of the number less than 250929.78 is marked as 1, and the comparison result of the absolute value of the number greater than or equal to 250929.78 is marked as 0, that is, if the comparison result is true, it is marked as 1, and if the comparison result is false, it is marked as 0. Finally, perform a bitwise operation on the sign operation result and the absolute value operation result. Among them, the bitwise operation formula is P|(~P&Q), and the operation result is (0, 0, 1, 1, 1, 0, 1, 0). Among them, 0 is the operation result of (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79) not less than 250929.78, and 1 is the operation result of less than 250929.78, that is, -787201.33, 29680.79, -577549.14, -8515271.80 are less than 250929.78.
[0083] In another embodiment, the data to be operated on is fixed-point data defined as (10, 2), which is (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79, 250929.78). Calculate the numbers in (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79) that are less than 250929.78. Perform sign encoding on (916280.93, 250929.78, -787201.33, 29680.79, -577549.14, 754211.56, -8515271.80, 98640593.79) to obtain the corresponding sign vector P1 = (1, 1, 0, 1, 0, 1, 0, 1). Perform sign encoding on 250929.78 to obtain the corresponding sign vector P2 = (1). Among them, the sign corresponding to the positive sign is encoded as 1, and the sign corresponding to the negative sign is encoded as 0. Perform an AND operation on the sign vectors to obtain the sign operation result P = (0, 0, 1, 0, 1, 0, 1, 0). Then convert the data to be operated on into integer data, compare the absolute values in the integer data, compare the magnitudes of the absolute values, and obtain the absolute value operation result Q = (0, 0, 0, 1, 0, 0, 0, 0). Among them, the comparison result of the number with an absolute value less than 250929.78 is marked as 1, and the comparison result of the number with an absolute value greater than or equal to 250929.78 is marked as 0, that is, if the comparison result is true, it is marked as 1, and if the comparison result is false, it is marked as 0. Finally, perform a bit operation on the sign operation result and the absolute value operation result. Among them, the bit operation formula is P|(~P&Q), and the operation result is (0, 0, 1, 1, 1, 0, 1, 0). Among them, 0 is the operation result of (916280.93, 250929.78, -787201.33, 29680.79,
[0084] -577549.14, 754211.56, -8515271.80, 98640593.79) that are not less than 250929.78, and 1 is the operation result of those less than 250929.78, that is, -787201.33, 29680.79, -577549.14, -8515271.80 are less than 250929.78.
[0085] See Figure 3 , Figure 3The following is a structural block diagram of a data encoding device provided by an embodiment of the present invention. For the sake of convenience of description, only the parts related to the embodiments of the present invention are shown. Refer to Figure 3 , the data encoding device 30 includes: a first acquisition module 31, a conversion module 32, a first encoding module 33, and a mapping module 34.
[0086] The first acquisition module 31 is used to acquire the fixed-point number data to be encoded.
[0087] The conversion module 32 is used to convert the fixed-point number data to be encoded into integer data, and determine the sign and absolute value of the integer data.
[0088] The first encoding module 33 is used to encode the sign based on a preset encoding method to obtain a sign vector of the sign, and encode the absolute value to obtain an absolute value vector of the absolute value.
[0089] The mapping module 34 is used to map the sign vector and the absolute value vector to form an encoding result of the fixed-point number data to be encoded.
[0090] Optionally, the above first encoding module 33 includes:
[0091] A judgment unit is used to judge the type of the sign.
[0092] The first encoding unit is used to encode the sign as a first value if the type of the sign is a positive sign.
[0093] The second encoding unit is used to encode the sign as a second value if the type of the sign is a negative sign.
[0094] Optionally, the above first encoding module 33 includes:
[0095] A conversion unit is used to convert the absolute value into binary data and judge the number of bits of the binary data.
[0096] The first judgment unit is used to, if the number of bits of the binary data is greater than a preset value, split the binary data into a first vector and a second vector according to the preset value, and determine the absolute value vector of the absolute value according to the first vector and the second vector.
[0097] The second judgment unit is used to, if the number of bits of the binary data is not greater than the preset value, determine the binary data as the absolute value vector of the absolute value.
[0098] Optionally, the above first judgment unit includes:
[0099] A sub-division unit is used to count the number of bits of the binary data from right to left, and divide the binary data into a first part of data with the number of bits greater than the preset value and a second part of data with the number of bits not greater than the preset value.
[0100] A determining subunit is configured to use the first part of data as a first vector and the second part of data as a second vector.
[0101] See Figure 4 , Figure 4 FIG. is a structural block diagram of an arithmetic device for encoding data according to an embodiment of the present invention. For the sake of convenience of description, only the parts related to the embodiments of the present invention are shown. See Figure 4 , the arithmetic device 40 for encoding data includes:
[0102] A second acquisition module 41 is configured to acquire data to be operated on and use the data to be operated on as data of a fixed-point number to be encoded.
[0103] A second encoding module 42 is configured to encode the data to be operated on by using the above data encoding method to obtain an encoding result of the data to be operated on.
[0104] An arithmetic module 43 is configured to perform an operation on the sign vector and the absolute value vector of the data to be operated on by using a bit operator matching a preset encoding method according to the sign vector and the absolute value vector in the encoding result of the data to be operated on to obtain an operation result.
[0105] It should be noted that for the information interaction, execution process, etc. between the above modules, since they are based on the same concept as the method embodiments of the present invention, the specific functions and the technical effects brought thereby can be specifically referred to the method embodiment part, and will not be elaborated herein.
[0106] Figure 5 FIG. is a schematic structural diagram of a computer device according to an embodiment of the present invention. As Figure 5 shown, the computer device of this embodiment includes: at least one processor ( Figure 5 only one is shown in ), a memory, and a computer program stored in the memory and executable on at least one processor. When the processor executes the computer program, it implements the above-mentioned various data encoding methods and the steps in the arithmetic method embodiments.
[0107] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that Figure 5 is only an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the figure, or combine some components, or different components. For example, it may also include a network interface, etc.
[0108] The so-called processor may be a CPU, and the processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0109] The memory includes a readable storage medium, internal memory, etc. Among them, the internal memory may be the memory of the computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be the hard disk of the computer device, and in some other embodiments, it may also be an external storage device of the computer device. For example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Further, the memory may also include both the internal storage unit of the computer device and the external storage device. The memory is used to store the operating system, application programs, boot loaders, data, and other programs, such as the program code of the computer program. The memory may also be used to temporarily store the data that has been output or will be output.
[0110] Those skilled in the art can clearly understand that, for the convenience and conciseness of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above-mentioned functions can be allocated to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present invention. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the foregoing method embodiment and will not be elaborated here. If the integrated unit 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 such an understanding, to implement all or part of the processes in the above-mentioned method embodiment of the present invention, a computer program can be used to instruct the relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0111] To implement all or part of the processes in the above-mentioned method embodiment of the present invention, it can also be completed by a computer program product. When the computer program product runs on a computer device, it enables the computer device to execute and implement the steps in the above-mentioned method embodiment.
[0112] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0113] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present invention.
[0114] In the embodiments provided by the present invention, it should be understood that the disclosed device / computer equipment and method can be implemented in other ways. For example, the device / computer equipment embodiments described above are merely illustrative. For example, the division of modules or 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. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0115] The units described as separate components may or may not be physically separated. The components displayed 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.
[0116] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features. And these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A data encoding method, characterized in that: The data encoding method comprises: Get the fixed-point data to be encoded; Converting the fixed-point data to be encoded into integer data, and determining the sign and absolute value of the integer data; Encoding the symbol based on a preset encoding method to obtain a symbol vector of the symbol; Convert the absolute value into binary data, and determine the number of bits of the binary data; If the number of bits of the binary data is greater than a preset value, splitting the binary data into a first vector and a second vector according to the preset value, and determining an absolute value vector of the absolute value according to the first vector and the second vector; If the number of bits of the binary data is not greater than the preset value, determining the binary data as an absolute value vector of the absolute value; Mapping the sign vector and the absolute value vector to form an encoding result of the fixed-point number data to be encoded; Acquire data to be calculated, and use the data to be calculated as fixed-point number data to be encoded; Using the above-mentioned data encoding method to encode the data to be operated, to obtain the encoding result of the data to be operated; According to the sign vector and the absolute value vector in the encoding result of the data to be operated, a bit operation is performed on the sign vector to obtain a sign operation result, and then the data to be operated is converted into integer data, and the absolute values in the integer data are compared, and the absolute value operation result is obtained. If the comparison result is true, it is marked as 1, if the comparison result is false, it is marked as 0, and finally the sign operation result and the absolute value operation result are bit-operated to obtain the operation result.
2. The data encoding method according to claim 1, characterized in that: The encoding of the symbol to obtain a symbol vector of the symbol includes: Determining the type of the symbol; If the type of the sign is a positive sign, encoding the sign as a first numerical value; If the type of the sign is a negative sign, the sign is encoded as a second value.
3. The data encoding method according to claim 1, characterized in that: The step of splitting the binary data into a first vector and a second vector according to the preset value includes: Counting the number of bits of the binary data from right to left, dividing the binary data into a first part of data having a number of bits greater than the preset value and a second part of data having a number of bits not greater than the preset value; The first part of data is used as a first vector, and the second part of data is used as a second vector.
4. A data encoding device, characterized in that: The data encoding device comprises: A first acquisition module, used for acquiring fixed-point number data to be encoded; A conversion module, used for converting the fixed-point data to be encoded into integer data, and determining the sign and absolute value of the integer data; A first encoding module, used to encode the symbol based on a preset encoding method to obtain a symbol vector of the symbol, convert the absolute value into binary data, and determine the number of bits of the binary data; If the number of bits of the binary data is greater than a preset value, splitting the binary data into a first vector and a second vector according to the preset value, and determining an absolute value vector of the absolute value according to the first vector and the second vector; If the number of bits of the binary data is not greater than the preset value, determining the binary data as an absolute value vector of the absolute value; A mapping module, used for mapping the symbol vector and the absolute value vector to form an encoding result of the fixed-point number data to be encoded; A second acquisition module is used to acquire data to be calculated, and use the data to be calculated as fixed-point data to be encoded; A second encoding module, configured to use the data encoding method according to any one of claims 1 to 3 to perform data encoding on the data to be operated, to obtain an encoding result of the data to be operated; The operation module is used to perform bit operation on the symbol vector according to the symbol vector and the absolute value vector in the encoding result of the data to be operated to obtain the symbol operation result, and then convert the data to be operated into integer data, compare the absolute values in the integer data, compare the absolute values, and obtain the absolute value operation result. If the comparison result is true, it is marked as 1, if the comparison result is false, it is marked as 0, and finally the symbol operation result and the absolute value operation result are bitwise operated to obtain the operation result.
5. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the data encoding method according to any one of claims 1 to 3 when executing the computer program.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the data encoding method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Method and apparatus for encoding / decoding vector as well as flow medium player
CN101304254A
Compression method and device for time sequence data of Internet of Vehicles and electronic equipment
CN114759929A
Fixed-point data compression and decompression method, device and equipment for communication system
CN115175248A