Data coding method and related equipment

By using an independent encoding method based on a boundary ratio table, the problem of low encoding efficiency in existing technologies is solved, achieving efficient data compression and simplifying the encoding process, thereby improving data storage efficiency.

CN121939983APending Publication Date: 2026-04-28HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
Filing Date
2024-10-25
Publication Date
2026-04-28

Smart Images

  • Figure CN121939983A_ABST
    Figure CN121939983A_ABST
Patent Text Reader

Abstract

The invention provides a data coding method and related equipment, which are used for improving data coding efficiency. The method includes obtaining a first value and a first coding interval of the first value. A demarcation proportion table is obtained, the demarcation proportion table comprises the corresponding relation between the bit width of the numerical value and a demarcation point, the demarcation point indicates the reduction proportion of the coding interval in a default proportion mode, and the default proportion mode indicates the default relation between the number of bits with the value being 0 and the number of bits with the value being 1 in the numerical value. And according to the first coding interval and the boundary proportion table, coding the first numerical value to obtain a first coding value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and in particular to data encoding methods and related equipment. Background Technology

[0002] With the rapid development of internet technology and the increasing prevalence of data-intensive applications, encoding and compressing large amounts of data can reduce the need for physical storage and improve the efficiency of data access and processing. Choosing the right data encoding method is crucial for optimizing data storage efficiency and query performance.

[0003] In related technical solutions, differential encoding is used, which encodes the first data and then encodes the difference between subsequent data and the previous value. In this approach, the encoding depends on the difference between the current data and the previous data, resulting in low encoding efficiency. Summary of the Invention

[0004] This application provides a data encoding method and related equipment to improve data encoding efficiency.

[0005] Firstly, this application provides a data encoding method, including:

[0006] The server obtains a first numerical value and its first encoding interval. The first encoding interval can also be understood as the interval containing the first encoded value obtained by encoding the first numerical value. The server also obtains a boundary ratio table, which includes the correspondence between the bit width of the numerical value and the boundary points. The boundary points indicate the reduction ratio of the encoding interval under the default ratio mode. The bit width of the numerical value refers to the number of bits in the binary form of the numerical value. The default ratio mode indicates the default relationship between the number of bits with a value of 0 and the number of bits with a value of 1. The default ratio mode can be either a situation where the number of bits with a value of 0 is greater than the number of bits with a value of 1, or vice versa, depending on the needs of the actual application; no specific limitation is made here. Non-default ratio modes indicate the opposite relationship to the default ratio mode. Therefore, based on the boundary ratio table, the boundary points corresponding to numerical values ​​under non-default ratio modes can also be obtained. Furthermore, the boundary ratio table can be stored locally on the server or on other devices accessible to the server; no specific limitation is made here. The server encodes the first numerical value based on the first encoding interval and the boundary ratio table to obtain the first encoded value.

[0007] In this application, the server encodes the first numerical value based on the first encoding interval and boundary ratio table, without depending on other numerical values. In other words, the first numerical value is independently encoded and not associated with other values. Therefore, encoding the first numerical value does not require waiting for other numerical values ​​to be encoded, thus improving encoding efficiency. Furthermore, the data encoding method provided in this application does not consider whether the currently encoded value has already been encoded. That is, the data encoding method provided in this application can be used in conjunction with other encoding methods; that is, for values ​​that have already been encoded, the data encoding method provided in this application can re-encode them, thereby improving the data compression rate.

[0008] In some optional implementations of the first aspect, the process of the server encoding the first numerical value according to the first encoding interval and the boundary ratio table may include: firstly, determining the boundary point of the first numerical value based on the bit width of the first numerical value, the ratio mode of the first numerical value, and the boundary ratio table. That is, the server queries the boundary point corresponding to the bit width of the first numerical value from the boundary ratio table. If the ratio mode of the first numerical value is the default ratio mode, then the boundary point corresponding to the bit width of the first numerical value in the boundary ratio table is the boundary point of the first numerical value. If the ratio mode of the first numerical value is not the default ratio mode, then the server processes the boundary point corresponding to the bit width of the first numerical value in the boundary ratio table to obtain the boundary point of the first numerical value. Here, the bit width of the first numerical value refers to the bit width of the column in which the first numerical value is located, and the bit width of the column is the same as the bit width of the largest numerical value in that column. The server reads all bits of the first numerical value sequentially, starting from the first bit. The first bit can be either the highest bit or the lowest bit of the first numerical value. Based on the value of the currently read bit and its corresponding boundary point, the current encoding interval is reduced until all bits of the first value have been read, resulting in a second encoding interval. The encoding interval for the first bit is the first encoding interval, and the boundary point corresponding to the first bit is the boundary point of the first value. In other words, the server updates the encoding interval each time it reads a bit of the first value, until all bits of the first value have been read. This first encoding interval is reduced multiple times to obtain the second encoding interval. The boundary point corresponding to the currently read bit is either the boundary point of the first value or an update of the boundary point corresponding to the previously read bit. The server then determines the first encoded value from the second encoding interval.

[0009] In this application, each time the server reads a bit of the first numerical value, it reduces the encoding interval once based on the value of the currently read bit and the corresponding boundary point, thereby obtaining the first encoded value. This can also be understood as mapping the first numerical value to a unique interval for encoding, achieving lossless encoding and improving the reliability of data encoding. Furthermore, the boundary point corresponding to the currently read bit can have multiple possibilities, enriching the implementation methods and application scenarios of the technical solution in this application. In the scheme where the boundary point corresponding to the currently read bit is the same as the boundary point of the first numerical value, it means that during the encoding process of the first numerical value, there is no need to update the boundary point, simplifying the encoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit in the first numerical value, it means that the boundary point is updated once for each bit read, making the updated boundary point more consistent with the current encoding state, further improving the numerical compression rate.

[0010] In some optional implementations of the first aspect, the process of the server encoding the first value according to the first encoding interval and the boundary ratio table may include: firstly, determining the boundary point of the first value based on the bit width of the first value, the proportional mode of the first value, and the boundary ratio table; secondly, reading all bits of the first value sequentially, starting from the first bit, where the first bit is either the highest or lowest bit of the first value; and thirdly, reducing the current encoding interval based on the value of the currently read bit and the boundary point corresponding to the currently read bit, to obtain the updated encoding interval. Here, the encoding interval of the first bit is the first encoding interval, the boundary point corresponding to the first bit is the boundary point of the first value, the boundary point corresponding to the currently read bit is the boundary point of the first value, or it is obtained by updating the boundary point corresponding to the previously read bit. Obtaining the updated encoding interval also yields the endpoints of the updated encoding interval, namely the first endpoint and the second endpoint, where the first endpoint is smaller than the second endpoint. If the highest byte values ​​at the endpoints of the updated encoding interval are the same, the server processes the updated encoding interval to obtain the encoding interval corresponding to the next bit after the currently read bit, and reads the next bit. If the highest byte values ​​at the endpoints of the updated encoding interval are different, the next bit is read, and the encoding interval for the next bit is the updated encoding interval. This process continues until all bits of the first value have been read, resulting in the second encoding interval. The first encoded value may then be contained within the second encoding interval. Alternatively, the first encoded value may consist of a high byte and a low byte, where the high byte includes the highest byte with the same value at the endpoints of the encoding interval, and the low byte is contained within the second encoding interval.

[0011] In this application, the encoding interval in which the first encoded value is located can be multiple, which enriches the implementation methods and application scenarios of the technical solution of this application.

[0012] In some optional implementations of the first aspect, where the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit, the server can also update the boundary point corresponding to the previously read bit before reducing the current encoding interval. Specifically, the server adjusts the boundary point corresponding to the previously read bit up or down by a preset ratio based on the value of the currently read bit and / or the values ​​of the bits already read in the first value to obtain the boundary point corresponding to the currently read bit.

[0013] In this application, there are multiple possibilities for the server to update the boundary point corresponding to the last read bit in the first value, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0014] In some optional implementations of the first aspect, the process of encoding the first numerical value according to the first encoding interval and the boundary ratio table may further include: the server dividing the first numerical value into multiple numerical segments, each segment having the same bit width. The bit width of each numerical segment refers to the number of bits in the binary numerical segment. It is understood that if the binary first numerical value cannot be evenly divided into multiple numerical segments, the highest bit of the first numerical value can be padded with 0s so that the bit width of the padded first numerical value can be evenly divided. The server determines the boundary point of each numerical segment based on the bit width of the first numerical value, the ratio mode of each numerical segment, and the boundary ratio table. If the ratio mode of a numerical segment is the default ratio mode, then the boundary point corresponding to the bit width of the first numerical value in the boundary ratio table is the boundary point of that numerical segment. If the ratio mode of a numerical segment is not the default ratio mode, then the server processes the boundary point corresponding to the bit width of the first numerical value in the boundary ratio table to obtain the boundary point of that numerical segment. Here, the bit width of the first numerical value is the bit width of the binary first numerical value evenly divided into multiple numerical segments. The server starts reading all bits of the first value sequentially, beginning with the first bit. The first bit is either the most significant or the least significant bit. Based on the value of the currently read bit and its corresponding boundary point, the server reduces the current encoding interval until all bits of the first value have been read, resulting in a second encoding interval. The encoding interval for the first bit is the first encoding interval, and the boundary point corresponding to the first read bit within a value segment is the boundary point of that segment. The boundary point corresponding to the currently read bit is either the boundary point of the value segment containing the currently read bit, or it is obtained by updating the boundary point corresponding to the previously read bit within the value segment containing the currently read bit. The server then determines the first encoded value from the second encoding interval.

[0015] In this application, the server can segment the first numerical value. During the encoding process, the boundary points of each numerical segment are independent of each other. That is, the boundary point corresponding to a bit in one numerical segment does not affect the boundary point corresponding to a bit in another numerical segment. Therefore, the boundary point used to encode each numerical segment is more suitable for each numerical segment, further improving the numerical compression ratio. In addition, this application does not limit the number of numerical segments. The more numerical segments there are, the more refined the encoding of the first numerical value. The fewer numerical segments there are, the simpler the encoding process. Furthermore, there are multiple possibilities for the boundary point corresponding to the currently read bit, enriching the implementation methods and application scenarios of the technical solution of this application. In the scheme where the boundary point corresponding to the currently read bit is the same as the boundary point of the target numerical segment, it means that during the encoding process of a numerical segment, it is not necessary to update the boundary point, simplifying the encoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the boundary point corresponding to the currently read bit is updated to the boundary point corresponding to the previously read bit of the target numerical segment, it is shown that the boundary points of each numerical segment are independent of each other. The boundary points used to encode each numerical segment are more in line with the encoding state of each numerical segment, which further improves the numerical compression rate.

[0016] In some optional implementations of the first aspect, the process of the server encoding the first numerical value according to the first encoding interval and the boundary ratio table may include: dividing the first numerical value into multiple numerical segments, each with the same bit width; determining the boundary point of each numerical segment according to the bit width of the first numerical value, the ratio pattern of each numerical segment, and the boundary ratio table; sequentially reading all bits of the first numerical value starting from the first bit, where the first bit is either the highest or lowest bit of the first numerical value; reducing the current encoding interval according to the value of the currently read bit and the boundary point corresponding to the currently read bit to obtain the updated encoding interval. Here, the encoding interval of the first bit is the first encoding interval, the boundary point corresponding to the first read bit in a numerical segment is the boundary point of the numerical segment, and the boundary point corresponding to the currently read bit is the boundary point of the numerical segment in which the currently read bit is located, or it is obtained by updating the boundary point corresponding to the previously read bit in the numerical segment in which the currently read bit is located. Obtaining the updated encoding interval also yields the endpoints of the updated encoding interval, namely the first endpoint and the second endpoint, where the first endpoint is smaller than the second endpoint. If the highest byte values ​​at the endpoints of the updated encoding interval are the same, the server processes the updated encoding interval to obtain the encoding interval corresponding to the next bit after the currently read bit, and reads the next bit. If the highest byte values ​​at the endpoints of the updated encoding interval are different, the next bit is read, and the encoding interval for the next bit is the updated encoding interval. This process continues until all bits of the first value have been read, resulting in the second encoding interval. The first encoded value may then be contained within the second encoding interval. Alternatively, the first encoded value may consist of a high byte and a low byte, where the high byte includes the highest byte with the same value at the endpoints of the encoding interval, and the low byte is contained within the second encoding interval.

[0017] In some optional implementations of the first aspect, where the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit in the target numerical segment, the server also needs to update the boundary point before reducing the current encoding interval. Specifically, the server updates the boundary point corresponding to the previously read bit in the numerical segment containing the currently read bit based on the value of the currently read bit and / or the values ​​of the bits already read in the numerical segment containing the currently read bit, thus obtaining the boundary point corresponding to the currently read bit.

[0018] In this application, there are multiple possibilities for the server to update the boundary point corresponding to the last read bit in the target value segment, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0019] In some alternative implementations of the first aspect, after obtaining the first encoded value, the server further compresses the first encoded value to obtain a first compressed result. The number of bytes in the first compressed result is less than the number of bytes in the first value.

[0020] In this application, the number of bytes in the first compression result is less than the number of bytes in the first value, which saves data storage space and reduces the occupation of storage resources.

[0021] Secondly, this application provides a data encoding method, including:

[0022] The server obtains a first numerical value and a pre-built table. The pre-built table includes at least one first data pair, each of which includes a numerical value and its corresponding encoded value. The pre-built table can be stored locally on the server or on other devices connected to the server; this is not limited here. In a scheme where at least one first data pair in the pre-built table includes the first numerical value, the server determines the encoded value corresponding to the first numerical value from the pre-built table as the first encoded value. In a scheme where at least one data pair in the pre-built table does not include the first numerical value, the server obtains a first encoding interval and a boundary ratio table. The first encoding interval is the interval containing the first encoded value obtained by encoding the first numerical value. The boundary ratio table includes the correspondence between the bit width of the numerical value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the numerical value. The default ratio mode can be either where the number of bits with a value of 0 is greater than the number of bits with a value of 1, or vice versa, depending on the needs of the actual application; this is not limited here. The non-default scaling mode indicates the opposite relationship to the default scaling mode. Therefore, based on the boundary scaling table, the boundary point corresponding to the value in the non-default scaling mode can also be obtained. Furthermore, the boundary scaling table can be stored locally on the server or on another device accessible to the server; this is not limited here. The server encodes the first value based on the first encoding interval and the boundary scaling table to obtain the first encoded value.

[0023] In this application, when the server obtains a pre-built table and encodes the first value, if the first value is included in the pre-built table, the server can directly query the pre-built table to obtain the corresponding first encoded value, simplifying the encoding process, saving computing resources, and improving encoding efficiency. If the first value is not included in the pre-built table, the encoding can be performed based on the first encoded interval and boundary ratio table of the first value, without depending on other values. In other words, the first value is not associated with other values ​​and is encoded independently. Therefore, encoding the first value does not need to wait for other values ​​to be encoded before proceeding, thereby improving encoding efficiency. Furthermore, the data encoding method provided in this application does not consider whether the currently encoded value has already been encoded. That is, the data encoding method provided in this application can be used in conjunction with other encoding methods; that is, for values ​​that have already been encoded, the data encoding method provided in this application can be used again to encode them, thereby improving the data compression rate.

[0024] In some optional implementations of the second aspect, the bit width of each encoded value in the first data pair is less than or equal to a bit width threshold. The bit width of the encoded value refers to the number of bits in the binary form of the encoded value. It can be understood that the larger the bit width threshold, the more first data pairs there are, and the greater the probability that the server can directly obtain the encoded value by querying the pre-built table. The smaller the bit width threshold, the fewer first data pairs there are, and the smaller the storage space occupied by the pre-built table. Therefore, by adjusting the bit width threshold, computing resources and storage resources can be adjusted, and a suitable bit width threshold can balance these two resources.

[0025] The second aspect also provides some optional implementation methods, which are similar to any possible implementation method of the first aspect mentioned above, as detailed above, and will not be repeated here.

[0026] Thirdly, this application provides a data decoding method, including:

[0027] The server obtains the second encoded value, the bit width of the corresponding second numerical value, and the first decoding interval. The second encoded value is contained within the first decoding interval. The bit width of the second numerical value refers to the number of bits in its binary form. The server obtains a boundary ratio table, which includes the correspondence between the bit width of the numerical value and the boundary points. The boundary points indicate the reduction ratio of the decoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1. The default ratio mode can be either where the number of bits with a value of 0 is greater than the number of bits with a value of 1, or vice versa, depending on the actual application needs; no specific limitation is made here. Non-default ratio modes indicate the opposite size relationship to the default ratio mode. Therefore, based on the boundary ratio table, the boundary points corresponding to numerical values ​​under non-default ratio modes can also be obtained. Furthermore, the boundary ratio table can be stored locally on the server or on other devices accessible to the server; no specific limitation is made here. The server decodes the second encoded value based on the bit width of the second value, the first decoding interval, and the boundary ratio table to obtain the second value.

[0028] In this application, the server decodes the second encoded value based on its bit width, the first decoding interval, and the boundary ratio table, without depending on other values. In other words, the second encoded value is decoded independently, without being associated with other encoded values. Therefore, decoding the second encoded value does not require waiting for other encoded values ​​to be decoded, thus improving decoding efficiency.

[0029] In some optional implementations of the third aspect, the second encoded value is decoded according to the bit width of the second value, the first decoding interval, and the boundary ratio table to obtain the second value. This includes: the server obtaining the current boundary point according to the bit width of the second value and the boundary ratio table; the current boundary point corresponds to the first boundary point of the bit width of the second value in the boundary ratio table, or it is obtained by updating the previous boundary point, with the first boundary point being the first boundary point. The server divides the current decoding interval into a second decoding interval and a third decoding interval according to the current boundary point. The second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode. The current decoding interval is obtained by updating the previous decoding interval, with the first decoding interval being the first decoding interval. If the second encoded value is contained within the second decoding interval, the currently decoded bit value is determined to be the first value, corresponding to the default ratio mode. If the second encoded value is contained within the third decoding interval, the currently decoded bit value is determined to be the second value, corresponding to the non-default ratio mode. This process continues until the bit width of the second value is decoded, obtaining the second value. The first decoded bit value is the highest or lowest bit value of the second value. It is understandable that if the first bit encoded during encoding is the most significant bit of the value, then the first bit decoded during decoding will also be the most significant bit of the value. Conversely, if the first bit encoded during encoding is the least significant bit of the value, then the first bit decoded during decoding will also be the least significant bit of the value.

[0030] In this application, the server determines the value of the currently decoded bit by determining the decoding interval where the second encoded value is located. This value corresponds to the proportional pattern of the decoding interval and matches the encoding process. Based on the foregoing explanation, the encoding process maps a value to a unique interval. Therefore, the decoding process can also achieve lossless decoding by restoring the encoding interval where the encoded value is located, thereby improving the reliability of data decoding. Furthermore, the current boundary point has multiple possibilities, enriching the implementation methods and application scenarios of the technical solution in this application. In the scheme where the current boundary point is the first boundary point, it means that during the decoding of the second encoded value, it is not necessary to update the boundary point, simplifying the decoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the current boundary point is obtained by updating the previous boundary point, it means that the boundary point is updated once for each decoded bit, making the updated boundary point more consistent with the current decoding state, further improving the decoding accuracy.

[0031] In some optional implementations of the third aspect, in the scheme where the current boundary point is obtained by updating the previous boundary point, before dividing the current decoding interval into the second decoding interval and the third decoding interval based on the current boundary point, the server also adjusts the previous boundary point up or down by a preset ratio based on the value of the currently decoded bit and / or the value of the already decoded bit to obtain the current boundary point.

[0032] In this application, there are multiple ways for the server to update the previous boundary point to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0033] In some optional implementations of the third aspect, before decoding the second encoded value, the server also obtains segmentation information of the second value. This segmentation information indicates that the second value comprises multiple segments, each with the same bit width. The bit width of each segment refers to the number of bits in the binary representation of the segment. The server's decoding process for the second encoded value includes: obtaining the current boundary point based on the bit width of the second value and a boundary ratio table. This current boundary point is the same as the first boundary point corresponding to the bit width of the second value in the boundary ratio table, or it is obtained by updating the previous boundary point in the target segment where the currently decoded bit is located. The first boundary point of the target segment is the first boundary point. In other words, the boundary points of each segment are independent; decoding one segment does not affect the boundary points of other segments. Based on the current boundary point, the current decoding interval is divided into a second decoding interval and a third decoding interval. The second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode. The current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval. If the second encoded value is contained within the second decoding interval, then the currently decoded bit is determined to be the first value. If the second encoded value is contained within the third decoding interval, then the currently decoded bit is determined to be the second value. This process continues until the bit width of the second value is reached, at which point the first decoded bit is determined to be either the highest or lowest bit of the second value.

[0034] In this application, in schemes where the second value comprises multiple value segments, the boundary points used in the decoding process can be varied, enriching the implementation methods and application scenarios of the technical solution. Furthermore, if the current boundary point is obtained by updating the previous boundary point in the target value segment, the boundary points of each value segment are independent of each other. Decoding the boundary points used for each value segment better suits the situation of each segment, further improving the reliability of the value decoding.

[0035] In some optional implementations of the third aspect, if the current boundary point is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located, then before dividing the current decoding interval into the second decoding interval and the third decoding interval based on the current boundary point, the server also adjusts the previous boundary point in the target value segment up or down by a preset ratio based on the value of the currently decoded bit in the target value segment and / or the value of the already decoded bit in the target value segment to obtain the current boundary point.

[0036] In this application, there are multiple ways for the server to update the previous boundary point in the target value segment to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0037] In some optional implementations of the third aspect, during the decoding process, if the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are different, then the next decoding interval is determined to be the encoding interval containing the second encoded value. If the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are the same, then the encoding interval containing the second encoded value is processed to obtain the next decoding interval. The endpoints of the decoding interval include the third endpoint and the fourth endpoint, where the third endpoint is less than the fourth endpoint. The aforementioned decoding interval containing the second encoded value is either the second decoding interval or the third decoding interval.

[0038] In this application, the server can update the decoding interval in multiple ways, enriching the implementation methods and application scenarios of the technical solution and further enhancing its flexibility. Furthermore, the update of the decoding interval matches the aforementioned update of the encoding interval, enabling the encoding process to be restored, ensuring that the decoded value is consistent with the value before encoding, thus improving the reliability of the decoding.

[0039] Fourthly, this application provides a data decoding method, characterized in that it includes:

[0040] The server obtains a second encoded value and a pre-built table. The pre-built table includes a first data pair and a second data pair. The first data pair includes an encoded value with a bit width less than the bit width threshold and its corresponding numerical value. The second data pair includes an encoded prefix and its corresponding decoding state. The bit width of the encoded prefix is ​​not less than the bit width threshold, and the decoding state includes the numerical value corresponding to the encoded prefix. The pre-built table can be stored locally on the server or on other devices accessible to the server; this is not limited here. In the scheme where the bit width of the second encoded value is less than or equal to the bit width threshold, the server determines the numerical value corresponding to the second encoded value from the pre-built table. In the scheme where the bit width of the second encoded value is greater than the bit width threshold, the server obtains the bit width of the second numerical value and decodes the second encoded value according to the encoded prefix, the bit width of the second numerical value, and the pre-built table to obtain the second numerical value. The bit width threshold is the bit width threshold for binary data, and its size can be determined according to the needs of the actual application; this is not limited here.

[0041] In this application, the server compares the bit width of the second encoded value with a bit width threshold, and different comparison results correspond to different decoding methods. If the bit width of the second encoded value is less than or equal to the bit width threshold, the server can directly obtain the second numerical value corresponding to the second encoded value from the pre-built table, accelerating the decoding process and improving decoding efficiency. If the bit width of the second encoded value is greater than the bit width threshold, the decoding of the second encoded value is completed based on the encoding prefix of the second encoded value, the bit width of the second numerical value, and the pre-built table. It does not depend on other numerical values; that is, the second encoded value is not associated with other numerical values ​​and is decoded independently. Therefore, decoding the second numerical value does not need to wait for other encoded values ​​to be decoded before proceeding, thereby improving decoding efficiency.

[0042] In some optional implementations of the fourth aspect, the decoding state also includes a first decoding interval and a dividing point. The second encoded value is contained within the first decoding interval. The dividing point indicates the reduction ratio of the decoding interval under the default scaling mode. The default scaling mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value. The server determines the second value based on the encoding prefix of the second encoded value, the bit width of the second value, and the pre-built table, including: taking the value corresponding to the encoding prefix of the second encoded value as the third value, where the third value is a part of the second value. The server then divides the current decoding interval into a second decoding interval and a third decoding interval based on the current dividing point. The second decoding interval corresponds to the default scaling mode, and the third decoding interval corresponds to the non-default scaling mode. The current decoding interval is obtained by updating the previous decoding interval, with the first decoding interval being the first decoding interval. The current dividing point is either the second dividing point corresponding to the encoding prefix of the second encoded value, or it is obtained by updating the previous dividing point, with the first dividing point being the second dividing point. If the second encoded value is contained within the second decoding interval, then the value of the currently decoded bit is determined to be the first value, which corresponds to the default scaling mode. If the second encoded value is contained within the third decoding interval, then the value of the currently decoded bit is determined to be the second value, which corresponds to the non-default scaling mode. The server obtains the fourth value after decoding up to the bit width of the second value. The last decoded bit is either the highest or lowest bit of the second value. The fourth value is also a part of the second value. The server determines the second value based on the third and fourth values.

[0043] In this application, the server determines the value of the currently decoded bit by determining the decoding interval where the second encoded value is located. This value corresponds to the proportional pattern of the decoding interval and matches the encoding process. Based on the foregoing explanation, the encoding process maps a value to a unique interval. Therefore, the decoding process can also achieve lossless decoding by restoring the encoding interval where the encoded value is located, thereby improving the reliability of data decoding. Furthermore, there are multiple possibilities for the current boundary point, enriching the implementation methods and application scenarios of the technical solution in this application. In the scheme where the current boundary point is the same as the second boundary point, it means that the boundary point does not need to be updated during the decoding of the second encoded value, simplifying the decoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the current boundary point is obtained by updating the previous boundary point, it means that the boundary point is updated once for each decoded bit, making the updated boundary point more consistent with the current decoding state, further improving the decoding accuracy.

[0044] In some optional implementations of the fourth aspect, if the current boundary point is obtained by updating the previous boundary point, then before dividing the current decoding interval into the second decoding interval and the third decoding interval according to the current boundary point, the server also adjusts the previous boundary point up or down by a preset ratio according to the value of the currently decoded bit and / or the value of the already decoded bit to obtain the current boundary point.

[0045] In this application, there are multiple ways for the server to update the previous boundary point to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0046] In some optional implementations of the fourth aspect, the decoding state also includes a first decoding interval and a delimiter. The second encoded value is contained within the first decoding interval. The delimiter indicates the reduction ratio of the decoding interval in the default scaling mode. The default scaling mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value. Before decoding the second encoded value, the server also obtains the segmentation information of the second value. The segmentation information indicates that the second value includes multiple value segments, each with the same bit width. The bit width of each value segment refers to the number of bits in the binary form of the value segment.

[0047] The server's decoding process for the second encoded value includes: using the value corresponding to the encoded prefix of the second encoded value as the third value; dividing the current decoding interval into a second decoding interval and a third decoding interval based on the current boundary point; the second decoding interval corresponds to the default scaling mode, and the third decoding interval corresponds to the non-default scaling mode; the current decoding interval is obtained by updating the previous decoding interval, with the first decoding interval being the first decoding interval; the current boundary point is either the second boundary point corresponding to the encoded prefix of the second encoded value, or it is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located, with the first boundary point of the target value segment being the second boundary point; if the second encoded value is contained within the second decoding interval, the value of the currently decoded bit is determined to be the first value; if the second encoded value is contained within the third decoding interval, the value of the currently decoded bit is determined to be the second value; this process continues until the bit width of the second value is reached, resulting in the fourth value; the last decoded bit is taken as the value of the highest or lowest bit of the second value; and the second value is determined based on the third and fourth values.

[0048] In this application, in schemes where the second value comprises multiple value segments, the boundary points used in the decoding process can be varied, enriching the implementation methods and application scenarios of the technical solution. Furthermore, if the current boundary point is obtained by updating the previous boundary point in the target value segment, the boundary points of each value segment are independent of each other. Decoding the boundary points used for each value segment better suits the situation of each segment, further improving the reliability of the value decoding.

[0049] In some optional implementations of the fourth aspect, if the current boundary point is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located, then before dividing the current decoding interval into the second decoding interval and the third decoding interval based on the current boundary point, the server also adjusts the previous boundary point in the target value segment up or down by a preset ratio based on the value of the currently decoded bit in the target value segment and / or the value of the already decoded bit in the target value segment to obtain the current boundary point.

[0050] In this application, there are multiple ways for the server to update the previous boundary point in the target value segment to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0051] In some optional implementations of the fourth aspect, during the decoding process, if the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are different, then the next decoding interval is determined to be the decoding interval containing the second encoded value. If the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are the same, then the decoding interval containing the second encoded value is processed to obtain the next decoding interval. Here, the endpoints of the decoding interval include the third endpoint and the fourth endpoint, where the third endpoint is less than the fourth endpoint. The decoding interval containing the second encoded value is either the second decoding interval or the third decoding interval.

[0052] In this application, the server can update the decoding interval in multiple ways, enriching the implementation methods and application scenarios of the technical solution and further enhancing its flexibility. Furthermore, the update of the decoding interval matches the aforementioned update of the encoding interval, enabling the encoding process to be restored, ensuring that the decoded value is consistent with the value before encoding, thus improving the reliability of the decoding.

[0053] Fifthly, this application provides a data encoding apparatus, including an acquisition unit and a processing unit.

[0054] The acquisition unit is used to acquire a first numerical value and a first encoding interval of the first numerical value. The acquisition unit is also used to acquire a boundary ratio table, which includes the correspondence between the bit width of the numerical value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the numerical value.

[0055] The processing unit is used to encode the first numerical value according to the first encoding interval and the boundary ratio table to obtain the first encoded value.

[0056] The data encoding device shown in the fifth aspect is used to perform the method shown in the first aspect or any possible implementation of the first aspect, and its beneficial effects are similar to those of the first aspect or any possible implementation of the first aspect, and will not be repeated here.

[0057] Sixthly, this application provides a data encoding apparatus, including an acquisition unit and a processing unit.

[0058] The acquisition unit is used to acquire a first value and a pre-built table. The pre-built table includes at least one first data pair, and each first data pair includes a value and a corresponding encoded value.

[0059] If at least one first data pair in the pre-built table includes a first value, then the processing unit is used to determine from the pre-built table that the encoded value corresponding to the first value is the first encoded value.

[0060] If at least one data pair in the pre-built table does not include the first value, the acquisition unit is further used to acquire the first encoding interval and the boundary ratio table. The first encoding interval is the interval in which the first encoded value obtained by encoding the first value is located. The boundary ratio table includes the correspondence between the bit width of the value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0061] The processing unit is also used to encode the first numerical value according to the first encoding interval and the boundary ratio table to obtain the first encoded value.

[0062] The data encoding device shown in the sixth aspect is used to perform the method shown in the second aspect or any possible implementation of the second aspect, and its beneficial effects are similar to those of the second aspect or any possible implementation of the second aspect, and will not be repeated here.

[0063] In a seventh aspect, this application provides a data decoding apparatus, including an acquisition unit and a processing unit.

[0064] The acquisition unit is used to acquire a second encoded value, the bit width of the corresponding second numerical value, and a first decoding interval, wherein the second encoded value is contained within the first decoding interval. It also acquires a boundary ratio table, which includes the correspondence between the bit width of the numerical value and boundary points. The boundary points indicate the reduction ratio of the decoding interval under the default ratio mode, and the default ratio mode indicates the default relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the numerical value.

[0065] The processing unit is used to decode the second encoded value according to the bit width of the second value, the first decoding interval, and the boundary ratio table to obtain the second value.

[0066] The data processing apparatus shown in the seventh aspect is used to execute the method shown in the third aspect or any possible implementation of the third aspect, and its beneficial effects are similar to those of the third aspect or any possible implementation of the third aspect, and will not be repeated here.

[0067] Eighthly, this application provides a data decoding apparatus, characterized in that it includes an acquisition unit and a processing unit.

[0068] The acquisition unit is used to acquire a second encoded value and a pre-built table. The pre-built table includes a first data pair and a second data pair. The first data pair includes an encoded value with a bit width less than a bit width threshold and a corresponding numerical value. The second data pair includes an encoded prefix and a corresponding decoding state. The bit width of the encoded prefix is ​​not less than the bit width threshold. The decoding state includes the numerical value corresponding to the encoded prefix.

[0069] The processing unit is configured to determine the value corresponding to the second encoded value from a pre-built table if the bit width of the second encoded value is less than or equal to the bit width threshold.

[0070] The processing unit is further configured to, if the bit width of the second encoded value is greater than the bit width threshold, obtain the bit width of the second numerical value, and determine the second numerical value based on the encoding prefix of the second encoded value, the bit width of the second numerical value, and the pre-built table.

[0071] The data processing apparatus shown in the eighth aspect is used to execute the method shown in the fourth aspect or any possible implementation of the fourth aspect, and its beneficial effects are similar to those of the fourth aspect or any possible implementation of the fourth aspect, and will not be repeated here.

[0072] Ninthly, this application provides a computing device cluster including at least one computing device, each computing device including a processor and a memory. The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to enable the computing device cluster to implement the methods shown in the first aspect, any possible implementation of the first aspect, the second aspect, any possible implementation of the second aspect, the third aspect, any possible implementation of the third aspect, the fourth aspect, or any possible implementation of the fourth aspect.

[0073] In a tenth aspect, this application provides a computer-readable storage medium storing instructions that, when executed on a processor or by a cluster of computing devices, implement the methods shown in the first aspect, any possible implementation of the first aspect, the second aspect, any possible implementation of the second aspect, the third aspect, any possible implementation of the third aspect, the fourth aspect, or any possible implementation of the fourth aspect.

[0074] In the eleventh aspect, this application provides a computer program product that, when executed on a processor or run by a cluster of computing devices, implements the methods shown in the first aspect, any possible implementation of the first aspect, the second aspect, any possible implementation of the second aspect, the third aspect, any possible implementation of the third aspect, the fourth aspect, or any possible implementation of the fourth aspect.

[0075] The beneficial effects shown in any of the ninth to eleventh aspects are similar to those of the aforementioned first aspect, any possible implementation of the first aspect, the second aspect, any possible implementation of the second aspect, the third aspect, or any possible implementation of the third aspect, the fourth aspect, or any possible implementation of the fourth aspect, and will not be elaborated here. Attached Figure Description

[0076] Figure 1 This is a schematic diagram of the system architecture provided for an embodiment of this application;

[0077] Figure 2 A flowchart illustrating the data encoding method provided in this application embodiment;

[0078] Figure 3 Another flowchart illustrating the data encoding method provided in the embodiments of this application;

[0079] Figure 4 Another flowchart illustrating the data encoding method provided in the embodiments of this application;

[0080] Figure 5A schematic diagram illustrating the desired boundary ratio provided in the embodiments of this application;

[0081] Figure 6 Another flowchart illustrating the data encoding method provided in the embodiments of this application;

[0082] Figure 7 Another flowchart illustrating the data decoding method provided in this application embodiment;

[0083] Figure 8 Another flowchart illustrating the data decoding method provided in this application embodiment;

[0084] Figure 9 Another flowchart illustrating the data decoding method provided in this application embodiment;

[0085] Figure 10 A schematic diagram of the structure of the data encoding device provided in the embodiments of this application;

[0086] Figure 11 A schematic diagram of the data decoding apparatus provided in the embodiments of this application;

[0087] Figure 12 A schematic diagram of the structure of a computing device provided in an embodiment of this application;

[0088] Figure 13 A schematic diagram of the structure of a computing device cluster provided in an embodiment of this application;

[0089] Figure 14 This is another schematic diagram of the computing device cluster provided in an embodiment of this application. Detailed Implementation

[0090] This application provides a data encoding method and related equipment to improve data encoding efficiency.

[0091] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0092] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of units is not necessarily limited to those units, but may include other units not explicitly listed or inherent to those processes, methods, products, or apparatuses. Additionally, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can be expressed as: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0093] First, please refer to Figure 1 , Figure 1 This is a schematic diagram of the system architecture provided for an embodiment of this application.

[0094] like Figure 1 As shown, terminal device 101 establishes a communication connection with server 103 through network device 102. Terminal device 101 can also access data managed by server 103, including data stored locally on server 103 or data stored on other devices connected to server 103. Optionally, server 103 can also store a database or connect to an external database, allowing terminal device 101 to access data in the database. In other words, the data managed by server 103 may or may not be data from a database; the specifics are not limited here.

[0095] Terminal device 101 accesses data, including performing read data operations and / or write data operations. Read data operations can be understood as data query operations, while write data operations include adding data, modifying data, etc. In this embodiment, the data managed by server 103 includes encoded data. Therefore, in the scenario where terminal device 101 performs a read data operation, server 103 decodes the encoded data and returns the decoded data to terminal device 101. In the scenario where terminal device 103 performs a write data operation, server 103 obtains the data input by terminal 103, encodes the data, and then stores the encoded data locally or remotely. In other words, in this embodiment, server 103 performs data encoding and / or data decoding operations; the specific implementation process will be described in detail later and will not be repeated here.

[0096] It is important to note that terminal equipment, also known as user equipment (UE), mobile station (MS), mobile terminal (MT), etc., refers to devices that include wireless communication and / or sensing functions (providing voice or data connectivity to users). Examples include handheld devices with wireless connectivity or in-vehicle devices. Currently, some examples of terminal devices include: mobile phones, tablets, laptops, PDAs, drones, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in vehicle-to-everything (V2X) communication, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, and wireless terminals in smart homes. For example, wireless terminals in the Internet of Vehicles (IoV) can be in-vehicle devices, vehicle equipment, in-vehicle modules, vehicles, etc. Wireless terminals in industrial control can be cameras, robots, etc. Wireless terminals in smart homes can be televisions, air conditioners, robot vacuums, speakers, set-top boxes, etc. In this application embodiment, the type of terminal device is not limited, and the system architecture provided in this application embodiment can include a greater number of terminal devices.

[0097] It should be noted that network device 102 is a device that connects terminal device 101 and server 103. The connection between network device 102 and terminal device 101 can be wired or wireless; the connection between network device 102 and server 103 can also be wired or wireless, and no specific limitation is made here. This application embodiment also does not limit the type and number of network devices 102; they can be routers, switches, etc., used to connect terminal device 101 and server 103, and no specific limitation is made here.

[0098] It should also be noted that the type of server 103 is not limited in this application embodiment. It can be a cloud server or a traditional server. No specific limitation is made here.

[0099] Please refer to the following. Figure 2 , Figure 2 A flowchart illustrating the data encoding method provided in this application embodiment includes:

[0100] 201. Obtain the first value and the first encoding interval of the first value.

[0101] The server establishes a communication connection with the terminal device and receives a write data request sent by the terminal device. The write data request carries a first value, instructing the server to write the first value. After obtaining the first value, the server can encode the first value and store the first encoded value corresponding to the first value.

[0102] The server can also obtain the first encoding interval of the first value, which is the initial encoding interval of the first value. Value encoding can be understood as mapping the value to a unique encoding interval. In the method provided in this application embodiment, the encoding interval is updated as bits are read, and the first encoding interval is the initial encoding interval.

[0103] 202. Obtain the boundary ratio table. The boundary ratio table includes the correspondence between the bit width of the value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval in the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0104] The bit width of a numerical value refers to the number of bits in the binary representation of that value. For example, the binary representation of the value 67 is 1000011, and its bit width is 7. It's important to note that in database scenarios, the bit width of the first numerical value refers to the bit width of the column containing that value; the column's bit width is the same as the bit width of the largest value in that column.

[0105] The dividing point reflects the reduction ratio of the encoding interval, that is, the degree of reduction to be achieved during the reduction process. In other words, logically, the dividing point ranges from [0, 1). For example, assuming the dividing point is 0.3, it means that in the default scaling mode, the current encoding interval will be reduced by 0.3.

[0106] The default scaling mode includes either Mode 1 or Mode 2. Mode 1 means that the number of bits with a value of 0 is greater than the number of bits with a value of 1. Mode 2 means that the number of bits with a value of 1 is greater than the number of bits with a value of 0. For example, if the default scaling mode is Mode 1, then the non-default scaling mode is Mode 2. It should be noted that if the number of bits with a value of 0 is equal to the number of bits with a value of 1, then the scaling mode of that value can be considered either the aforementioned default scaling mode or a non-default scaling mode.

[0107] In addition, the boundary ratio table can be stored locally on the server or on other devices that the server can access; there are no specific restrictions here.

[0108] For example, a portion of the boundary ratio table can be shown in Table 1 below:

[0109] Table 1

[0110] Bit width 9 10 11 12 13 14 15 Boundary point 1218 972 809 686 604 522 481

[0111] In the embodiment shown in Table 1, the range of the dividing point is mapped to [0, 4096), and the default scaling mode is the first mode, meaning that the number of bits with a value of 0 is greater than the number of bits with a value of 1. When the bit width of the value is 9, the corresponding dividing scaling point is 1218. If the scaling mode of the value is the default scaling mode, then the reduction ratio of the encoding interval indicated by the dividing point is 1218 / 4096. If the scaling mode of the value is a non-default scaling mode, then the reduction ratio of the encoding interval indicated by the dividing point is 1-1218 / 4096.

[0112] It should be noted that, logically, the range of the dividing point is [0, 1). Table 1 above maps the range of values ​​of the dividing point to [0, 4096), which avoids processing decimals during the encoding process and simplifies the encoding process. In practical applications, the range of values ​​of the dividing point can also be mapped to other ranges, and the larger the range, the higher the precision of the encoding interval and the higher the compression rate of the numerical value.

[0113] It should also be noted that Table 1 above only describes the boundary ratio table in tabular form. In practical applications, other forms can be used to store the correspondence between the bit width and the boundary point indicated by the boundary ratio, such as key-value pairs, functions, etc., which are not limited here.

[0114] 203. Encode the first numerical value according to the first coding interval and the boundary ratio table to obtain the first coded value.

[0115] After obtaining the first encoding interval and the boundary ratio table, the server encodes the first numerical value to obtain the first encoded value. In the actual encoding process, the server can use several methods: it can segment the first numerical value and encode each segment sequentially; or it can not segment the first numerical value and encode each bit sequentially. The possible implementation methods are explained below.

[0116] (1.1) The server does not use the encoding scheme for the first numerical segment.

[0117] In this scheme, the server analyzes a first numerical value to obtain its bit width and proportional mode. The bit width of the first numerical value refers to the number of bits in its binary form. The proportional mode indicates the relationship between the number of bits with different values ​​in the first numerical value; that is, the relationship between the number of bits with a value of 0 and the number of bits with a value of 1. For simplicity, in subsequent embodiments, the first mode will be used as the default proportional mode, and the second mode as a non-default proportional mode. In other words, the default proportional mode means that the number of bits with a value of 0 is greater than the number of bits with a value of 1, and the non-default proportional mode means that the number of bits with a value of 1 is greater than the number of bits with a value of 0.

[0118] Optionally, in the batch data write operation scheme, the bit width of the first value is the same as the bit width of the largest value in the column containing the first value. That is, if the first binary value does not require this many bits to represent, the high bits of the first value are padded with 0s, so that the bit width of the padded first value is the same as the bit width of the largest value in the column containing it.

[0119] For example, suppose the first value is 300, its binary form is 100101100, which includes 9 bits, or a bit width of 9. The largest value in the column containing the first value is 65500, its binary form is 1111110111101000, which includes 16 bits. Therefore, the encoded first value is actually 0000000100101100, also including 16 bits. Of these 16 bits, 12 are 0 and 4 are 1, so the scaling mode for this value is the first mode.

[0120] For example, suppose the first value is 65123, whose binary form is 1111111001100011, including 16 bits. The largest value in the column containing the first value is 65500, whose binary form is 1111110111101000, also including 16 bits, the same bit width as the first value. Since the first value has 11 bits of value 1, which is greater than the number of bits of value 0, the scaling mode of the first value is the second mode.

[0121] After obtaining the bit width and scaling mode of the first value, the server queries the boundary scaling table to determine the boundary point of the first value. Taking Table 1 above as an example, assuming the bit width of the first value is 9 and the scaling mode of the first value is the default scaling mode, then the boundary point of the first value is 1218.

[0122] The server reads all bits of the first numerical value sequentially, starting from the first bit. The first bit is either the most significant bit or the least significant bit of the first numerical value. In the scheme where the first bit is the most significant bit, the first numerical value can be considered as being encoded from high to low. Therefore, during decoding, the decoding result is also arranged in order from high to low bits. Conversely, in the scheme where the first bit is the least significant bit, the first numerical value can be considered as being encoded from low to high. Therefore, during decoding, the decoding result is also arranged in order from low to high bits.

[0123] The server updates the encoding interval for each bit read. Specifically, based on the value of the currently read bit and its corresponding boundary point, the server updates the current encoding interval until all bits of the first value have been read, resulting in the second encoding interval. The encoding interval for the first bit is the first encoding interval, and the boundary point corresponding to the first bit is the boundary point of the first value. Alternatively, the boundary point corresponding to the currently read bit can be obtained by updating the boundary point corresponding to the previously read bit.

[0124] Once the server obtains the second encoding interval, it can determine the first encoding value from within that interval. The first encoding value is any value contained within the second encoding interval. In other words, the server randomly selects any value from the second encoding interval as the first encoding value.

[0125] Furthermore, updating the current encoding interval is essentially reducing it. The value of the currently read bit indicates the direction of reduction, and the boundary point of the currently read bit indicates the reduction ratio. By continuously reducing the encoding interval until all bits of the first value have been read, the first value is uniquely mapped to a single encoding interval. This achieves lossless encoding of the first value, improving the reliability of data encoding.

[0126] For example, the endpoints of the encoding interval are defined as x1 and x2, where x1 < x2. The default scaling mode is defined as the first mode, which is a mode that favors bits with a value of 0; in other words, the default scaling mode means that the number of bits with a value of 0 is greater than the number of bits with a value of 1. Additionally, the default boundary scaling mode is defined as the boundary point / the range of values ​​for the boundary point. Taking Table 1 as an example, the default boundary scaling mode is the boundary point / 4096.

[0127] In a scheme where the currently read bit value is 0, updating the current encoding interval means keeping x2 unchanged and updating x1 to xmid. In a scheme where the currently read bit value is 1, updating the current encoding interval means keeping x1 unchanged and updating x2 to xmid. Here, xmid can have several possible values.

[0128] Optionally, xmid satisfies: xmid = x1 + (x2 - x1) × default boundary ratio, where default boundary ratio = boundary point / 4096.

[0129] Optionally, xmid satisfies: xmid = x2 - (x2 - x1) × non-default boundary ratio, non-default boundary ratio = 1 - boundary point / 4096.

[0130] For example, in combination Figure 3 The process of reducing the coding interval is explained further. Please refer to [link / reference]. Figure 3 , Figure 3 This is a flowchart illustrating the data encoding method provided in an embodiment of this application.

[0131] like Figure 3 As shown, assuming the default dividing ratio is 1 / 5, encoding interval 1 is the first encoding interval, that is, encoding interval 1 is the initial encoding interval for reading the first bit of the first value.

[0132] If the server reads a bit with a value of 0, then the encoding interval 1 is updated, meaning x2 remains unchanged and x1 is updated to x3. The updated encoding interval is encoding interval 2, with its endpoints being x3 and x2. x3 satisfies either x3 = x1 + (x2 - x1) × 1 / 5 or x3 = x2 - (x2 - x1) × 4 / 5.

[0133] Next, the second bit is read, and its value is 1. Then, the encoding interval 2 is updated, meaning x3 remains unchanged, and x2 is updated to x4. The updated encoding interval is encoding interval 3, with endpoints x3 and x4. x4 satisfies: x4 = x3 + (x2 - x3) × 1 / 5, or x4 = x2 - (x2 - x3) × 4 / 5.

[0134] In the aforementioned embodiment, the server randomly selects a value from the second encoding interval as the first encoding value. In practical applications, during the process of continuously reducing the current encoding interval to obtain the first encoding value, the server can also perform different operations based on the different values ​​of the endpoints of the updated encoding interval. In other words, the server can also obtain the first encoding value through other methods, which are described below:

[0135] The server first determines the boundary point of the first value based on its bit width, proportional mode, and boundary ratio table. Starting from the first bit of the first value, it sequentially reads all bits of the first value, with the first bit being either the highest or lowest bit. Then, based on the value of the currently read bit and its corresponding boundary point, it reduces the current encoding interval to obtain the updated encoding interval. Specifically, the encoding interval for the first bit is the first encoding interval, and the boundary point corresponding to the first bit is the boundary point of the first value. Alternatively, the boundary point corresponding to the currently read bit can be updated from the boundary point corresponding to the previously read bit.

[0136] If the highest byte values ​​of the endpoints of the updated encoding interval are the same, then the endpoints of the updated encoding interval are processed to obtain the encoding interval corresponding to the next bit of the currently read bit, and the next bit is read. If the highest byte values ​​of the endpoints of the updated encoding interval are different, then the next bit is read, and the encoding interval of the next bit is the updated encoding interval. Starting from the first bit read, the server continuously reduces the encoding interval until all bits of the first value have been read, obtaining the second encoding interval of the first value.

[0137] In a scheme where the highest byte at the endpoints of the updated encoding range has the same value, the server's processing operations on the endpoints of the updated encoding range include: performing a left shift operation on the endpoints of the updated encoding range, removing the highest byte with the same value, and supplementing the lowest byte with a value to ensure that the bit width of the endpoints of the encoding range is the same before and after processing.

[0138] For example, x1 and x2 represent endpoints, where x1 < x2. Optionally, the endpoints of the processed encoding interval obtained after the left shift operation satisfy: x1 = x1 << 8, x1 = (x1 << 8) + 255. That is, the processed encoding interval endpoint x1 is obtained by shifting the updated encoding interval one byte to the left and padding the end byte with 0. The processed encoding interval endpoint x1 is obtained by shifting the updated encoding interval one byte to the left and padding the end byte with 255 (binary 11111111).

[0139] It is understandable that when processing the highest byte with the same value, the value supplemented to the lowest byte can be other values, not limited to 0 and 255 in the previous example. The larger the difference between the endpoints of the processed encoding range, the larger the range of the processed encoding range, the higher the encoding precision, and the better the encoding effect that can be achieved.

[0140] In schemes where the highest byte at the endpoint of the updated encoding interval has a different value, the server directly reads the next bit and updates the encoding interval again based on the value of the next bit and the next boundary point, which means reducing the encoding interval again.

[0141] Starting with the first bit read, the server continuously reduces the encoding interval until all bits of the first value have been read, thus obtaining the ending encoding interval for the first value. Based on the foregoing explanation, during the encoding process, the encoding interval may be continuously reduced, or the endpoints of the encoding interval may be removed in addition to reduction. Therefore, the first encoded value can have multiple possibilities.

[0142] Optionally, the first encoded value is contained within the second encoded interval. That is, during the encoding process, the highest byte of the endpoint of each updated encoded interval has a different value, and the updated encoded interval is not processed again. "The first encoded value is contained within the second encoded interval" means that the first encoded value is any value within the second encoded interval.

[0143] Optionally, the first encoded value includes a high byte and a low byte. The high byte includes the highest byte with the same value at the endpoints of the encoded interval, and the low byte is contained within the second encoded interval. That is, during the encoding process, if the highest byte at the endpoints of the updated encoded interval has the same value, the encoded interval is processed again. During this second processing, the highest byte with the same value that was removed is used as the high byte of the first encoded value. Alternatively, the removal operation can be understood as outputting the highest byte with the same value to the encoding result. In this scheme, the highest bytes with the same value are removed based on the order in which the encoded intervals are updated. That is, the first highest byte with the same value removed is used as the highest byte of the first encoded value. The second highest byte with the same value removed is used as the second highest byte of the first encoded value. In this scheme, the second encoded interval is obtained after all bits of the first value have been read. A value is randomly selected from the second encoded interval as the low byte of the first encoded value. Finally, the high byte and the low byte of the first encoded value are combined to obtain the first encoded value.

[0144] In this application embodiment, the encoding interval containing the first encoded value can have multiple possibilities, enriching the implementation methods and application scenarios of the technical solution of this application. During the encoding process, in cases where the highest byte values ​​of the endpoints of the updated encoding interval are the same, the server can first output the highest byte with the same value to the encoding result, simplifying the encoding process.

[0145] In “(1.1) Encoding Scheme Where the Server Does Not Segment the First Value,” the server reduces the current encoding interval based on the value of the currently read bit and the corresponding boundary point. The preceding text briefly described that the boundary point corresponding to the currently read bit is related to the boundary point of the first value; this relationship can have several possibilities:

[0146] Optionally, the boundary point corresponding to the currently read bit is the boundary point of the first value. That is, during the encoding process, the same boundary point is used each time the encoding interval is reduced. This boundary point is obtained by looking up the boundary ratio table based on the bit width and ratio pattern of the first value.

[0147] Optionally, the boundary point corresponding to the currently read bit is updated from the boundary point corresponding to the previously read bit, and the boundary point corresponding to the first bit is the boundary point of the first value. That is, during the encoding process, the boundary point is updated every time a bit is read. The boundary point used for each reduction of the encoding interval may not be the same. When reading the first bit, the boundary point used is the aforementioned boundary point of the first value; when reading the second bit, the boundary point used is updated from the boundary point of the first value.

[0148] In this application's embodiments, the first boundary point can have multiple possibilities, enriching the implementation methods and application scenarios of the technical solution. In the scheme where the first boundary point is the same as the boundary point of the first numerical value, it means that during the encoding process of the first numerical value, there is no need to update the boundary point, simplifying the encoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit in the first numerical value, it means that the boundary point is updated once for each bit read, making the updated boundary point more consistent with the current encoding state, further improving the numerical compression rate.

[0149] In a scheme where the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit, the server must update the boundary point before reducing the current encoding interval to obtain the boundary point corresponding to the currently read bit. There are several possible ways to update the boundary point, which are explained below:

[0150] Optionally, the server can adjust the boundary point corresponding to the previously read bit by a preset ratio based on the value of the currently read bit, thus obtaining the boundary point corresponding to the currently read bit. If the value of the currently read bit corresponds to the ratio pattern of the first value, the server increases the boundary point corresponding to the previously read bit. If the value of the currently read bit does not correspond to the ratio pattern of the first value, the server decreases the boundary point corresponding to the previously read bit.

[0151] Specifically, increasing the threshold corresponding to the previously read bit by a preset percentage can be understood as raising the threshold corresponding to the previously read bit. Conversely, decreasing the threshold corresponding to the previously read bit by a preset percentage can be understood as decreasing the threshold corresponding to the previously read bit.

[0152] In this context, "the currently read bit value corresponding to the proportion of the first value" means that the currently read bit value has a higher number of identical bits in the first value. "The currently read bit value not corresponding to the proportion of the first value" means that the currently read bit value has a lower number of identical bits in the first value. It should be noted that if the number of different bits in the first value is the same, then regardless of whether the currently read bit value is 0 or 1, it can be considered that the currently read bit value either corresponds to or does not correspond to the proportion of the first value.

[0153] For example, if the currently read bit is 1, and the number of bits with a value of 1 in the first value is greater than the number of bits with a value of 0, then the value of the currently read bit corresponds to the proportional pattern of the first value. As another example, if the currently read bit is 1, and the number of bits with a value of 0 in the first value is greater than the number of bits with a value of 1, then the value of the currently read bit does not correspond to the proportional pattern of the first value. Similarly, if the currently read bit is 1, and the number of bits with a value of 0 in the first value is equal to the number of bits with a value of 1, then the value of the currently read bit may or may not correspond to the proportional pattern of the first value.

[0154] For example, consider the boundary ratio table shown in Table 1 above. Assume the bit width of the first value is 15, and the ratio mode for the first value is the default ratio mode. Then, the boundary point corresponding to the first bit in the first value is 481. If the second bit read in the first value is 1, the server will decrease the boundary point corresponding to the first bit, that is, decrease it by 481, to obtain the boundary point corresponding to the second bit. If the second bit read in the first value is 0, the server will increase the boundary point corresponding to the first bit, that is, increase it by 481, to obtain the boundary point corresponding to the second bit.

[0155] Optionally, the server can adjust the boundary point corresponding to the previously read bit by a preset ratio based on the values ​​of the bits already read in the first value, to obtain the boundary point corresponding to the currently read bit. If the value of the already read bit corresponds to the ratio pattern of the first value, the server increases the boundary point corresponding to the previously read bit. If the value of the already read bit does not correspond to the ratio pattern of the first value, the server decreases the boundary point corresponding to the previously read bit.

[0156] The "proportional pattern of read bit values ​​corresponding to the first value" means that the value with more identical bits among the read bits is greater than the value with more identical bits among the first value. The "proportional pattern of read bit values ​​not corresponding to the first value" means that the value with more identical bits among the read bits is less than the value with fewer identical bits among the first value. It should be noted that if the number of different bits among the read bits is the same, it can be considered that the read bit values ​​correspond to the first value, or that they do not correspond to the first value.

[0157] For example, if the read bit value is 1110, and the number of bits with a 1 in the first value is greater than the number of bits with a 0, then the value of the read bit value corresponds to the scaling pattern of the first value. As another example, if the read bit value is 1110, and the number of bits with a 0 in the first value is greater than the number of bits with a 1, then the value of the read bit value does not correspond to the scaling pattern of the first value. As yet another example, if the read bit value is 1100, then the value of the read bit value can, or does not, correspond to the scaling pattern of the first value.

[0158] For example, consider the boundary ratio table shown in Table 1 above. Assume the bit width of the first value is 15, the ratio mode is the default ratio mode, and the boundary point corresponding to the first bit of the first value is 481. When reading the second bit of the first value, the bits already read are the first bit of the first value. If the first bit is 1, the server will decrease the boundary point corresponding to the first bit, that is, decrease it by 481, to obtain the boundary point corresponding to the second bit. If the first bit is 0, the server will increase the boundary point corresponding to the first bit, that is, increase it by 481, to obtain the boundary point corresponding to the second bit. When reading the third bit of the first value, the bits already read are the first two bits of the first value.

[0159] Optionally, the server can adjust the boundary point corresponding to the previously read bit by a preset ratio based on the value of the currently read bit and the values ​​of the bits already read in the first value, thus obtaining the boundary point corresponding to the currently read bit. If the value of the currently read bit and the values ​​of the previously read bits correspond to the ratio pattern of the first value, then the server increases the boundary point corresponding to the previously read bit. If the value of the currently read bit and the values ​​of the previously read bits do not correspond to the ratio pattern of the first value, then the server decreases the boundary point corresponding to the previously read bit. The specific implementation process is similar to the previous "updating the boundary point corresponding to the previously read bit based on the values ​​of the bits already read in the first value," and will not be repeated here.

[0160] In this embodiment, there are multiple possibilities for the server to update the boundary point corresponding to the last read bit in the first value, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0161] (1.2) The encoding scheme of the server for the first numerical segment.

[0162] In this scheme, the server divides the first value into multiple segments, each with the same bit width. The number of segments and the bit width of each segment can be set based on the needs of the actual application; no specific limit is imposed here. It is understandable that if the first value in binary form cannot be evenly divided into multiple segments, the most significant bit of the first value can be padded with 0s, allowing the padded first value to be evenly divided.

[0163] The server also obtains the scaling mode for each value segment, which indicates the relationship between the number of bits with different values ​​in the segment. That is, the relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the segment. This includes either the aforementioned default scaling mode or a non-default scaling mode. If the number of bits with different values ​​in a value segment is the same, then the scaling mode for that segment can be either the default scaling mode or a non-default scaling mode.

[0164] For example, taking the default scaling mode as the first mode and the first value as 4043 as an example. The first binary value is 111111000010. If the first value is divided into three segments, these three segments are 1111, 1100, and 0010. Among them, the scaling mode of the first segment is a non-default scaling mode, the scaling mode of the second segment can be either the default scaling mode or a non-default scaling mode, and the scaling mode of the third segment is the default scaling mode.

[0165] After obtaining the bit width of the first value, the scaling mode of each value, and the boundary scaling table, the server determines the boundary point of each value segment based on this. Taking the boundary scaling table as shown in Table 1 above, and the first value including the value segments 1111, 1100, and 0010 as an example, the bit width of the first value is 12. The scaling mode of the first value segment is a non-default scaling mode, and the boundary point of the first value segment is 4095-686=3409. The scaling modes of the second and third value segments are both the default scaling mode, so the boundary point of the second and third value segments is 686.

[0166] The server starts reading all bits of the first value sequentially, beginning with the first bit. The first bit is either the highest or lowest bit of the first value. The server reduces the encoding interval each time a bit is read. Specifically, based on the value of the currently read bit and its corresponding boundary point, the server reduces the current encoding interval until all bits of the first value have been read, resulting in a second encoding interval. The encoding interval for the first bit is the first encoding interval. The boundary point corresponding to the first read bit in each value segment is the boundary point of that segment. The boundary point corresponding to the currently read bit is either the boundary point of the target value segment containing that bit, or it is obtained by updating the previous boundary point in the target value segment.

[0167] Once the server obtains the second encoding interval, it can determine the first encoding value from within that interval. The first encoding value is any value contained within the second encoding interval. In other words, the server randomly selects a value from the second encoding interval as the first encoding value. In schemes where the first value is divided into multiple segments, the principle behind the server reducing the encoding interval is the same as described above. Figure 3 The embodiments shown are similar and will not be described again here.

[0168] In this embodiment, the server can segment the first numerical value. During the encoding process, the boundary points of each numerical segment are independent of each other. That is, the boundary point corresponding to a bit in one numerical segment does not affect the boundary point corresponding to a bit in another numerical segment. Therefore, the boundary points used to encode each numerical segment are more suitable for each segment, further improving the numerical compression rate. In addition, this application does not limit the number of numerical segments. The more numerical segments there are, the more refined the encoding of the first numerical value. The fewer numerical segments there are, the simpler the encoding process.

[0169] In some alternative implementations, in the numerical segmentation scheme, the server can perform different operations based on the different values ​​of the endpoints of the updated encoding interval during the process of reducing the encoding interval. In other words, the server can also obtain the first encoded value through other means, which will be described below:

[0170] The server divides the first numerical value into multiple segments, each with the same bit width. Based on the bit width of the first numerical value, the proportional pattern of each segment, and the boundary ratio table, the boundary point of each segment is determined. Starting from the first bit of the first numerical value, all bits of the first numerical value are read sequentially, with the first bit being either the highest or lowest bit. Based on the value of the currently read bit and its corresponding boundary point, the current encoding interval is reduced to obtain the updated encoding interval. Specifically, the encoding interval for the first bit is the first encoding interval; the boundary point corresponding to the first read bit within a numerical segment is the boundary point of that segment; and the boundary point corresponding to the currently read bit is either the boundary point of the numerical segment containing the currently read bit, or it is obtained by updating the boundary point corresponding to the previously read bit within the numerical segment containing the currently read bit.

[0171] If the highest byte values ​​of the endpoints of the updated encoding interval are the same, then the endpoints of the updated encoding interval are processed to obtain the encoding interval corresponding to the next bit of the currently read bit, and the next bit is read. If the highest byte values ​​of the endpoints of the updated encoding interval are different, then the next bit is read, and the encoding interval of the next bit is the updated encoding interval. This process continues until all bits of the first value have been read, resulting in the second encoding interval for the first value. The first encoded value is then contained within the second encoding interval. Alternatively, the first encoded value includes a high byte and a low byte, where the high byte includes the highest byte with the same value at the endpoints of the encoding interval, and the low byte is contained within the second encoding interval. The specific implementation process of this method has been described in the foregoing embodiments and will not be repeated here.

[0172] In general, the coding scheme for the first numerical segmentation is roughly as follows: Figure 4 As shown. Please refer to [the original text]. Figure 4 , Figure 4 A flowchart illustrating the data encoding method provided as an example in this application.

[0173] After obtaining the first value, the server divides it into multiple value segments. The server can also obtain the first encoding interval and the boundary ratio table of the first value. This application embodiment does not limit the execution order in which the server obtains the first encoding interval and the boundary ratio table; it can obtain the first encoding interval first, or the boundary ratio table first, or both simultaneously. No specific limitation is made here.

[0174] Based on the bit width of the first value and the proportional pattern of each value segment, the server queries the boundary ratio table to determine the proportional pattern of each value segment. Then, it processes each value segment sequentially, finally obtaining the first encoded value. Processing each value segment sequentially means processing the multiple value segments included in the first value, starting from the first bit read. For each value segment, the processing includes determining the segment's boundary point and, when reading the bits within the segment sequentially, reducing the encoding interval based on the segment's boundary point. The specific implementation process is as described in the previous explanation and will not be repeated here.

[0175] In "(1.2) Server Encoding Scheme for the First Numerical Segment", the server updates the current encoding interval based on the value of the currently read bit and the corresponding boundary point. The preceding text briefly described that the boundary point corresponding to the currently read bit is related to the boundary point of the target numerical segment where the currently read bit is located; this relationship can have several possibilities:

[0176] Optionally, the boundary point corresponding to the currently read bit is the boundary point of the target value segment. That is, during the encoding process, for bits in the same value segment, the same boundary point is used each time the encoding interval is reduced.

[0177] Optionally, the boundary point corresponding to the currently read bit is obtained by adjusting the boundary point corresponding to the previously read bit in the target value segment by a preset ratio, and the boundary point corresponding to the first read bit in the target value segment is the boundary point of the target value segment. That is, during the encoding process, the boundary point is updated every time a bit is read. The boundary point used for each update of the encoding interval may not be the same. When reading the first bit of the target value segment, the boundary point used is the boundary point of the target value segment; when reading the second bit in the target value segment, the boundary point used is the updated boundary point of the target value segment. The target value segment is any value segment included in the first value.

[0178] Specifically, increasing the threshold corresponding to the last read bit in the target value segment by a preset percentage can be understood as increasing the threshold of the last read bit in the target value segment. Conversely, decreasing the threshold corresponding to the last read bit in the target value segment by a preset percentage can be understood as decreasing the threshold of the last read bit in the target value segment.

[0179] For example, taking the boundary ratio table as shown in Table 1 above, the first value includes the numerical segments 1111, 1100, and 0010. The bit width of the first value is 12. Both the first and second numerical segments use the default ratio mode, and the boundary point is 4095-686=3409. When reading bits in the first numerical segment, the first boundary point is 3410, and the second boundary point is obtained by updating 3410. When reading bits in the second numerical segment, the first boundary point used is still 3410, instead of updating the boundary point corresponding to the last bit in the first numerical segment.

[0180] In this application, the boundary point corresponding to the currently read bit can have multiple possibilities, enriching the implementation methods and application scenarios of the technical solution. In the scheme where the boundary point corresponding to the currently read bit is the same as the boundary point of the target numerical segment, it means that during the encoding process of a numerical segment, there is no need to update the boundary point, simplifying the encoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit of the target numerical segment, it indicates that the boundary points of each numerical segment are independent of each other, and the boundary points used to encode each numerical segment are more consistent with the encoding state of each numerical segment, further improving the numerical compression rate.

[0181] In the scheme where the second boundary point is updated based on the boundary point corresponding to the previously read bit in the target value segment, the server must update the boundary point before updating the current encoding interval to obtain the boundary point corresponding to the currently read bit. There are several possible update methods, which are explained below:

[0182] Optionally, the server can adjust the boundary point corresponding to the previously read bit in the target value segment by a preset ratio, based on the value of the currently read bit. If the value of the currently read bit corresponds to the proportional pattern of the target value segment, the server increases the boundary point corresponding to the previously read bit in the target value segment. If the value of the currently read bit does not correspond to the proportional pattern of the target value segment, the server decreases the boundary point corresponding to the previously read bit in the target value segment.

[0183] Optionally, the server can adjust the boundary point corresponding to the previously read bit in the target value segment by a preset ratio, based on the values ​​of the bits already read in the target value segment, to obtain the boundary point corresponding to the currently read bit. If the values ​​of the already read bits correspond to the proportional pattern of the target value segment, the server increases the boundary point corresponding to the previously read bit in the target value segment. If the values ​​of the already read bits do not correspond to the proportional pattern of the target value segment, the server decreases the boundary point corresponding to the previously read bit in the target value segment.

[0184] Optionally, the server can adjust the boundary point corresponding to the previously read bit in the target value segment by a preset ratio based on the value of the currently read bit and the values ​​of the bits already read in the target value segment, thus obtaining the boundary point corresponding to the currently read bit. If the value of the currently read bit and the values ​​of the bits already read in the target value segment correspond to the proportional pattern of the target value segment, then the server increases the boundary point corresponding to the previously read bit in the target value segment. If the value of the currently read bit and the values ​​of the bits already read in the target value segment do not correspond to the proportional pattern of the target value segment, then the server decreases the boundary point corresponding to the previously read bit in the target value segment.

[0185] In the aforementioned scheme of obtaining the boundary point corresponding to the currently read bit from the boundary point of the previously read bit in the target value segment, the boundary point of the target value segment is the boundary point of the first read bit in the target value segment. Furthermore, the implementation principle of this scheme is similar to the previously described scheme of "obtaining the boundary point corresponding to the currently read bit from the boundary point of the previously read bit in the first value segment," as shown above, and will not be repeated here.

[0186] In this application embodiment, there are multiple possibilities for the server to update the boundary point corresponding to the last read bit in the target value segment, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0187] It should be noted that in the embodiments of this application, regardless of whether the number of bits with different values ​​in the first numerical value is the same, or whether the number of bits with different values ​​in the numerical segment is the same, the scaling mode can be considered as either the default scaling mode or a non-default scaling mode. To maintain encoding consistency, a unified standard definition is used throughout the encoding process of a numerical value. That is, all are considered to be either the default scaling mode or a non-default scaling mode.

[0188] Similarly, in the scheme for updating the boundary point, if the number of different bits in the values ​​of the bits already read in the first numerical segment, the value of the currently read bit, the values ​​of the bits already read in the target numerical segment, and the values ​​of the bits already read in the target numerical segment is the same, then the aforementioned values ​​can be considered to correspond to the proportional pattern of the first numerical value, or not to the proportional pattern of the first numerical value. To maintain encoding consistency, a unified standard definition is used throughout the encoding process of a numerical value.

[0189] In summary, in this embodiment, the server encodes the first numerical value based on the first encoding interval and boundary ratio table of the first numerical value, without depending on other numerical values. That is, the first numerical value is not associated with other numerical values ​​and is encoded independently. Therefore, encoding the first numerical value does not require waiting for other numerical values ​​to be encoded before encoding, thus improving encoding efficiency. Furthermore, the data encoding method provided in this application does not consider whether the currently encoded numerical value has already been encoded. Therefore, the data encoding method provided in this application can be used in conjunction with traditional encoding methods; that is, numerical values ​​encoded by traditional encoding methods can be re-encoded by the data encoding method provided in this application, thereby improving the data compression rate.

[0190] For example, taking the encoding scheme for the first numerical segment as an example, and with specific examples, the data encoding method provided in the embodiments of this application will be described. Assume the first numerical value is 32275, its binary representation is 111111000010011, and assume the first encoding interval is [0, 2...]. 32 -1).

[0191] The first numerical value has a bit width of 15. It is divided into three segments: the first segment, the middle segment, and the last segment, each with a bit width of 5. The first and last segments use a non-default scaling mode, while the middle segment uses the default scaling mode.

[0192] The binary representation of the first segment is 10011. Based on the non-default scaling mode and the first numerical bit width of 15, referring to the scaling table shown in Table 1 above, the scaling point of the first segment is found to be 4095-481=3614. Then, the code is read from the low bits to the high bits, and xmid is obtained based on the scaling point corresponding to the currently read bit. This xmid is then combined with the value of the currently read bit to update the encoding interval. For example, if the first read bit is 1, the code is calculated as 0+(2...). 32-1)×3614 / 4096=3789553663.12, rounding it to the nearest integer gives xmid=3789553663. The first encoding interval is updated to [0, 3789553663). Since the first bit read corresponds to the proportional pattern of the first segment, the first boundary point is increased by 3614 to obtain the second boundary point. For example, the second boundary point is 3662. Similarly, the second bit read is 1, so xmid=3388023807 is calculated. The encoding interval is updated to [0, 3388023807), and the previous boundary point is increased by 3662 to obtain a new boundary point of 3701. The boundary points obtained from each update do not need to be output.

[0193] The middle segment, represented by binary 10000, is processed similarly to the first segment. First, based on the default scaling mode and the first bit width of 15, the segment's dividing point is found to be 481, which is also the first dividing point of the middle segment, according to the dividing scaling table shown in Table 1. Then, the segment is read from low to high bits, and the current encoding interval is updated based on the value of the currently read bit and its dividing point. When the 5th bit is read as 1, and the encoding interval is updated, the resulting encoding interval is [3423481568, 3425422052]. At this point, the highest byte at each end of the encoding interval is the same, 0xc7, which is output to the encoding result. The encoding interval is then processed again to obtain the processed encoding interval. The reprocessing procedure has been explained previously and will not be repeated here. 0xc7 is used for clarity, representing the highest byte with the same value in hexadecimal.

[0194] The processing mechanism for the tail segment is similar to that for the head and middle segments, and will not be repeated here. After reading all bits of the first value, the last byte of the encoded result is 0x7e. In this embodiment, the encoding length is not stored in the encoding, so data of other attributes in the value may be read during decoding. To ensure correct decoding, the low byte of the first encoded value is a value selected in the second encoding interval to ensure that decoding is not affected. In this example, the encoded result of the value 32275 is 2 bytes: 0xc77e.

[0195] It should be noted that the embodiments of this application do not limit the value range of the first encoding interval, and the aforementioned example of [0, 2] is not limited to the range of values ​​of the first encoding interval. 32 -1) This is merely an illustration. In practical applications, the range of the first coding interval can also be other ranges. The larger the range of the first coding interval, the higher the coding precision and the better the coding effect.

[0196] It should be noted that the embodiments in this application are not limited to the foregoing. Figure 2In the embodiment shown, the execution order of steps 202 and 203 can be either step 202 first, step 203 first, or both steps 202 and 203 can be executed simultaneously. No specific limit is imposed here.

[0197] It should also be noted that the first value is an integer. In practical applications, the value requested by the terminal may include an integer part and a decimal part. In this case, the server will identify the integer part and the decimal part. For the decimal part, it stores its depth, weight, and integer value. This means that during the encoding process, the server can convert the decimal part into integer form for encoding.

[0198] In some optional implementations, after obtaining the first encoded value, the server compresses the first encoded value to obtain a first compressed result. The number of bytes in the first compressed result is less than the number of bytes in the first value, thereby saving data storage space and reducing the occupation of storage resources.

[0199] In this embodiment, the boundary points in the boundary ratio table are calculated with the goal of saving at least 1 byte of storage space. For example, a 9-bit value occupies 2 bytes, and the aim is to compress the 9-bit value to less than 8 bits. Based on information entropy, the inequality is satisfied:

[0200]

[0201] Here, p1 represents the proportion of bits with a value of 1 in the numerical value. Based on the same principle, the dividing points corresponding to more bit widths can be obtained. For an example, please refer to [link to example]. Figure 5 , Figure 5 This is a schematic diagram of the desired boundary ratio provided in the embodiments of this application.

[0202] like Figure 5 As shown, taking the default boundary ratio as an example of a default ratio mode with more bits and a bit value of 0, the expected boundary ratio is 0.3 for a bit width of 9. This 0.3 corresponds to a non-default ratio mode. Therefore, in the boundary ratio table, the default boundary ratio indicated by the boundary point corresponding to a bit width of 9 is less than 0.3. In the boundary ratio table shown in Table 1 above, the default boundary ratio corresponding to a bit width of 9 is 1218 / 4096 < 0.3.

[0203] It should be noted that in the aforementioned scheme for updating boundary points, the boundary ratio corresponding to the updated boundary point should also meet the expected boundary ratio. In this embodiment, the boundary ratio table can be calculated and determined by the server or calculated by other devices; no specific limitation is made here.

[0204] The preceding text described a data encoding scheme. In this embodiment, the server can also encode the first value in other ways, as illustrated below with reference to the schematic diagram. Please refer to... Figure 6 , Figure 6 A flowchart illustrating the data encoding method provided in this application embodiment includes:

[0205] 601. Get the first value.

[0206] The specific implementation is similar to obtaining the first value in step 201 above, as detailed above, and will not be repeated here.

[0207] 602. Obtain a pre-built table, which includes at least one first data pair, each first data pair including a value and the corresponding encoded value.

[0208] The bit width of each encoded value in the first data pair is less than or equal to the bit width threshold. The bit width of the encoded value refers to the bit width when the encoded value is in binary. It can be understood that a larger bit width threshold results in a larger number of first data pairs, while a smaller bit width threshold results in a smaller number of first data pairs and a smaller storage space occupied by the pre-built table. Therefore, by adjusting the bit width threshold, the balance between computing and storage resources can be achieved; a suitable bit width threshold can balance these two resources.

[0209] The pre-built table can be stored locally on the server or on other devices accessible to the server. Furthermore, the first data pair can be calculated by the server or by other devices; this is not specifically limited here. In the scheme where the server calculates the first data pair, it can be understood that during the encoding process, the server stores the encoded value (smaller than the bit width threshold) and its corresponding value as the first data pair. This pair can be stored locally or on a remote device. In other words, the number of first data pairs included in the pre-built table can vary depending on the server's encoding process. The server's encoding scheme for values ​​is as described above and will not be repeated here.

[0210] 603. Determine whether at least one first data pair includes a first value. If yes, proceed to step 604; otherwise, proceed to step 605.

[0211] After obtaining the first numerical value and the pre-built table, the server determines whether the first data pair included in the pre-built table contains the first numerical value. If it does, the server can directly obtain the first encoded value by querying the pre-built table. If it does not, the server encodes the first numerical value to obtain the first encoded value.

[0212] 604. Determine the encoded value corresponding to the first numerical value as the first encoded value.

[0213] In a scheme where at least one first data pair includes a first value, the server determines that the encoded value corresponding to the first value is the first encoded value.

[0214] 605. Obtain the first encoding interval of the first value.

[0215] 606. Obtain the boundary scale table, which includes the correspondence between the bit width of the values ​​and the boundary points.

[0216] The dividing point indicates the reduction ratio of the encoding interval corresponding to the value in the default scaling mode, and the default scaling mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0217] 607. Encode the first numerical value according to the first coding interval and the boundary ratio table to obtain the first coded value.

[0218] Steps 605 to 607 are similar to the pinching techniques described in steps 201 to 203 above, as detailed above, and will not be repeated here.

[0219] In this embodiment, when the server obtains a pre-built table and encodes the first value, if the first value is included in the pre-built table, the server can directly query the pre-built table to obtain the first encoded value corresponding to the first value, simplifying the encoding process, saving computing resources, and improving encoding efficiency. If the first value is not included in the pre-built table, the encoding can be performed based on the first encoding interval and boundary ratio table of the first value, without depending on other values. That is, the first value is not associated with other values ​​and is encoded independently. Therefore, encoding the first value does not need to wait for other values ​​to be encoded before proceeding, thereby improving encoding efficiency. In addition, the data encoding method provided in this application does not concern itself with whether the currently encoded value has already been encoded. Therefore, the data encoding method provided in this application can be used in conjunction with other encoding methods. That is, for values ​​that have already been encoded, the data encoding method provided in this application can re-encode them, thereby improving the data compression rate.

[0220] The preceding text introduced the data encoding scheme provided in the embodiments of this application. In these embodiments, the server can also perform decoding operations. The relevant technical solutions for data decoding are described below; please refer to [link / reference]. Figure 7 , Figure 7 A flowchart illustrating the data decoding method provided in this application embodiment includes:

[0221] 701. Obtain the second encoded value, the bit width of the second numerical value corresponding to the second encoded value, and the first decoding interval, wherein the second encoded value is contained in the first decoding interval.

[0222] The server establishes a communication connection with the terminal device, receives a read data request sent by the terminal device, and the read data request indicates that a second value should be read. The server stores the second encoded value corresponding to the second value. Upon receiving the read data request, the server decodes the second encoded value and returns the decoded second value to the terminal device. In some optional implementations, the server first decompresses the data indicated by the read data request to obtain the second encoded value, and then decodes the second encoded value.

[0223] The server obtains the bit width of the second value to determine the number of bits needed to decode the second value into binary form, thus determining when to end the decoding process. The first decoding interval obtained by the server includes the second encoded value, and the first decoding interval is consistent with the first encoding interval used when encoding the second value.

[0224] 702. Obtain the boundary ratio table. The boundary ratio table includes the correspondence between bit width and boundary point. The boundary point indicates the reduction ratio of the decoding interval in the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1.

[0225] The server can also obtain a boundary ratio table. The content of this table is similar to that described earlier, except that during decoding, the reduction ratio indicated by the boundary point is the reduction ratio of the decoding interval. Furthermore, the default ratio mode defined in the decoding process is consistent with the default ratio mode defined in the encoding process to ensure the accuracy of the decoding result.

[0226] 703. Based on the bit width of the second value, the first decoding interval, and the boundary ratio table, decode the second encoded value to obtain the second value.

[0227] During the encoding of the second value, it may be done in segments or without segments. Consequently, there are also multiple possibilities during the decoding of the second encoded value, which will be explained below.

[0228] (1.3) The server does not decode the second numerical segment.

[0229] The server obtains the current boundary point based on the bit width of the second value and the boundary ratio table. The current boundary point is either the first boundary point corresponding to the bit width of the second value in the boundary ratio table, or it is obtained by updating the previous boundary point; the first boundary point is the first boundary point. Based on the current boundary point, the current decoding interval is divided into a second decoding interval and a third decoding interval. The second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode. The current decoding interval is obtained by updating the previous decoding interval; the first decoding interval is the first decoding interval.

[0230] Then, based on the relationship between the second encoded value and the second and third decoding intervals, the value of the currently decoded bit is determined. If the second encoded value is contained within the second decoding interval, the server determines that the currently decoded bit value is the first value, which corresponds to the default scaling mode. If the second encoded value is contained within the third decoding interval, the server determines that the currently decoded bit value is the second value, which corresponds to the non-default scaling mode.

[0231] For example, suppose the default scaling mode means that the number of bits with a value of 0 is greater than the number of bits with a value of 1. Then, the first value is 0, and the second value is 1. In a scheme where the second encoded value is contained within the second decoding interval, the currently decoded bit has a value of 0; in a scheme where the second encoded value is contained within the third code interval, the currently decoded bit has a value of 1. That is to say, the value of the currently decoded bit is the value corresponding to the decoding interval containing the second encoded value.

[0232] The server continuously reduces the encoding interval until it decodes to the bit width of the second value, thus obtaining the second value. The first decoded bit is either the highest or lowest bit of the second value. It's important to note that the order of the decoded bits is consistent with the order of the encoded bits, ensuring a correspondence between the encoding and decoding processes and guaranteeing the accuracy of the decoding result. In other words, in the scheme where the first bit is the highest bit of the first value, the first value can be considered to be encoded from high to low. Therefore, during decoding, the decoding result is also arranged in order from high to low bits. Similarly, in the scheme where the first bit is the lowest bit of the first value, the first value can be considered to be encoded from low to high. Therefore, during decoding, the decoding result is also arranged in order from low to high bits.

[0233] In this embodiment, the server decodes the second encoded value based on its bit width, the first decoding interval, and the boundary ratio table, without relying on other values. In other words, the second encoded value is decoded independently, without being associated with other encoded values. Therefore, decoding the second encoded value does not require waiting for other encoded values ​​to be decoded, thus improving decoding efficiency. Furthermore, the server determines the value of the currently decoded bit by determining the decoding interval containing the second encoded value. This value corresponds to the ratio pattern of the decoding interval and matches the encoding process. As explained above, the encoding process maps a value to a unique interval. Therefore, the decoding process, by restoring the encoding interval containing the encoded value, can also achieve lossless decoding, thereby improving the reliability of data decoding.

[0234] In this embodiment, the current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval. That is, during the decoding process, the server can determine the next decoding interval based on the relationship between the second encoded value and the second and third decoding intervals.

[0235] In some optional implementations, the server determines the decoding interval containing the second encoded value as the next decoding interval. The decoding interval containing the second encoded value is either the aforementioned second decoding interval or the third decoding interval. In other words, the next decoding interval is the decoding interval containing the second encoded value.

[0236] In some optional implementations, the server can further process the decoding interval containing the second encoded value based on the values ​​of the endpoints of the decoding interval containing the second encoded value to obtain the next decoding interval. Specifically, if the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are different, then the server determines the next decoding interval to be the decoding interval containing the second encoded value. If the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are the same, then the server processes the decoding interval containing the second encoded value to obtain the next decoding interval. The decoding interval containing the second encoded value can be either the second decoding interval or the third decoding interval.

[0237] The server processes the decoding interval containing the second encoded value to obtain the next decoding interval. This includes: left-shifting the endpoints of the decoding interval containing the second encoded value, removing the highest byte with the same value, and supplementing the lowest byte with a value to ensure that the bit width of the endpoints of the decoding intervals before and after processing is the same. The implementation principle is similar to the server's processing operation on the endpoints of the updated encoding interval in the previous section on "the scheme where the highest byte of the endpoints of the updated encoding interval has the same value," as explained in the previous section, and will not be repeated here.

[0238] In this embodiment, the server can update the decoding interval in multiple ways, enriching the implementation methods and application scenarios of the technical solution and further enhancing its flexibility. Furthermore, the update of the decoding interval matches the aforementioned update of the encoding interval, enabling the encoding process to be restored, ensuring that the decoded value is consistent with the value before encoding, thus improving the reliability of the decoding.

[0239] It's important to note that the server's mechanism for reducing the decoding interval during decoding is consistent with the mechanism for reducing the encoding interval during encoding. In other words, if the encoding interval endpoints with the same highest byte value were not processed during encoding, then the decoding interval endpoints with the same highest byte value will also not be processed during decoding. Conversely, if the encoding interval endpoints with the same highest byte value were processed during encoding, then the decoding interval endpoints with the same highest byte value will also be processed during decoding.

[0240] In “(1.3) Server-side Decoding Scheme for the Second Value Without Segmentation”, the server divides the current decoding interval into a second decoding interval and a third decoding interval based on the current boundary point, thereby determining the value of the currently decoded bit and the next decoding interval. The preceding text briefly described that the current boundary point is related to the first boundary point corresponding to the bit width of the second value in the boundary ratio table.

[0241] Optionally, if the current dividing point is the first dividing point, it means that during the decoding process, the dividing point used to divide the current decoding interval into the second decoding interval and the third decoding interval is the same dividing point.

[0242] Optionally, if the current boundary point is obtained by updating the previous boundary point, that is, during the decoding process, the boundary point is updated once for each bit decoded. The boundary point used for each update of the decoding interval may not be the same. When decoding the first bit, the boundary point used is the aforementioned first boundary point; when decoding the second bit, the boundary point used is obtained by updating the first boundary point.

[0243] In this application's embodiments, the current boundary point can have multiple possibilities, enriching the implementation methods and application scenarios of the technical solution. In the scenario where the current boundary point is the same as the first boundary point, it means that during the decoding of the second encoded value, there is no need to update the boundary point, simplifying the decoding process, saving the amount of data to be processed, and conserving computing resources. In the scenario where the current boundary point is obtained by updating the previous boundary point, it means that the boundary point is updated once for each bit decoded, making the updated boundary point more consistent with the current decoding state, further improving the decoding accuracy.

[0244] In a scheme where the current boundary point is obtained by updating the previous boundary point, the server must update the boundary point before updating the current decoding interval to obtain the current boundary point. There are several possible ways to update, which are explained below:

[0245] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the value of the currently decoded bit to obtain the current cutoff point. If the value of the currently decoded bit corresponds to the ratio pattern of the second value, the server increases the previous cutoff point. If the value of the currently decoded bit does not correspond to the ratio pattern of the second value, the server decreases the previous cutoff point.

[0246] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the values ​​of the decoded bits to obtain the current cutoff point. If the values ​​of the decoded bits correspond to the ratio pattern of the second value, the server increases the previous cutoff point. If the values ​​of the decoded bits do not correspond to the ratio pattern of the second value, the server decreases the previous cutoff point.

[0247] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the value of the currently decoded bit and the values ​​of the already decoded bits to obtain the current cutoff point. If the value of the currently decoded bit and the value of the already decoded bits correspond to the ratio pattern of the second value, then the server increases the previous cutoff point. If the value of the currently decoded bit and the value of the already decoded bits do not correspond to the ratio pattern of the first value, then the server decreases the previous cutoff point.

[0248] The aforementioned decoding process, in which "the current boundary point is obtained by updating the previous boundary point," is similar in principle to the encoding process described earlier, in which "the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit." Please refer to the relevant explanations above; they will not be repeated here.

[0249] It should also be noted that the adjustment ratio of the dividing point during the decoding process should be consistent with the adjustment ratio of the dividing point during the encoding process, so as to ensure the accuracy of decoding.

[0250] In this application embodiment, there are multiple possibilities for the server to update the previous boundary point to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0251] (1.4) Server decoding scheme for the second numerical segment.

[0252] In this scheme, the server also obtains segmentation information of the second value, indicating that the second value comprises multiple value segments, each with the same bit width. Based on the bit width of the second value and a segmentation ratio table, the server obtains the current segmentation point. This current segmentation point is the same as the first segmentation point corresponding to the bit width of the second value in the segmentation ratio table, or it is obtained by updating the previous segmentation point in the target value segment where the currently decoded bit is located. The first segmentation point of the target value segment is the first segmentation point. Based on the current segmentation point, the current decoding interval is divided into a second decoding interval and a third decoding interval. The second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode. The current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval.

[0253] Then, based on the relationship between the second encoded value and the second and third decoding intervals, the value of the currently decoded bit is determined. If the second encoded value is contained within the second decoding interval, the currently decoded bit is determined to be the first value, corresponding to the default scaling mode. If the second encoded value is contained within the third decoding interval, the currently decoded bit is determined to be the second value, corresponding to the non-default scaling mode. This process continues until the bit width of the second value is reached, obtaining the second value. The first decoded bit is the value of either the highest or lowest bit of the second value. The specific implementation process is similar to the previous related explanations and will not be repeated here.

[0254] In some optional implementations, the server can further process the decoding interval containing the second encoded value based on the values ​​of the endpoints of the decoding interval containing the second encoded value to obtain the next decoding interval. Specifically, if the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are different, then the server determines the next decoding interval to be the decoding interval containing the second encoded value. If the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are the same, then the server processes the decoding interval containing the second encoded value to obtain the next decoding interval. The decoding interval containing the second encoded value can be either the second decoding interval or the third decoding interval.

[0255] The server processes the decoding interval containing the second encoded value to obtain the next decoding interval. This includes: left-shifting the endpoints of the decoding interval containing the second encoded value, removing the highest byte with the same value, and supplementing the lowest byte with a value to ensure that the bit width of the endpoints of the decoding intervals before and after processing is the same. The implementation principle is similar to the server's processing operation on the endpoints of the updated encoding interval in the previous section on "the scheme where the highest byte of the endpoints of the updated encoding interval has the same value," as explained in the previous section, and will not be repeated here.

[0256] In “(1.4) Server Decoding Scheme for Second Numerical Segments”, the server divides the current decoding interval into a second decoding interval and a third decoding interval based on the current dividing point, thereby determining the value of the currently decoded bit and the next decoding interval. The preceding text briefly described that the current dividing point is related to the first dividing point corresponding to the bit width of the second numerical value in the dividing ratio table. This relationship includes:

[0257] Optionally, if the current dividing point is the first dividing point, it means that during the decoding process, the dividing point used to divide the current decoding interval into the second decoding interval and the third decoding interval is the same dividing point.

[0258] Optionally, if the current boundary point is obtained by updating the previous boundary point in the target value segment, and the first boundary point of the target value segment is the first boundary point. That is, during the decoding process, the boundary point is updated once for each decoded bit. The boundary point used for each update of the decoding interval may not be the same. When decoding the first bit in the target value segment, the boundary point used is the aforementioned first boundary point; when decoding the second bit in the target value segment, the boundary point used is obtained by updating the first boundary point. In this scheme, the first boundary point corresponding to the bit width of the second value in the boundary ratio table can be considered the boundary point when decoding the first bit of each value segment.

[0259] In this embodiment of the application, in a scheme where the second value includes multiple value segments, the boundary points used in the decoding process can be varied, enriching the implementation methods and application scenarios of the technical solution of this application. Furthermore, if the current boundary point is obtained by updating the previous boundary point in the target value segment, the boundary points of each value segment are independent of each other. Decoding the boundary points used for each value segment better suits the situation of each value segment, further improving the reliability of the value decoding.

[0260] In a scheme where the current boundary point is obtained by updating the previous boundary point in the target value segment, the server must update the boundary point before updating the current decoding interval to obtain the current boundary point. There are several possible ways to update the boundary point, which are explained below:

[0261] Optionally, the server can adjust the previous boundary point in the target value segment up or down by a preset ratio based on the value of the currently decoded bit, thus obtaining the current boundary point. If the value of the currently decoded bit corresponds to the ratio pattern of the second value, the server increases the previous boundary point. If the value of the currently decoded bit does not correspond to the ratio pattern of the second value, the server decreases the previous boundary point.

[0262] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the values ​​of the already decoded bits in the target value segment to obtain the current cutoff point. If the values ​​of the already decoded bits in the target value segment correspond to the ratio pattern of the second value, then the server increases the previous cutoff point. If the values ​​of the already decoded bits in the target value segment do not correspond to the ratio pattern of the second value, then the server decreases the previous cutoff point.

[0263] For example, using the boundary ratio table shown in Table 1 above, assume the second value has a bit width of 12 and is divided into three segments. If the ratio mode of the second value is not the default ratio mode, then the first boundary point is 4095-686=3409. The server decodes the first 4 bits with a ratio of 1111, and the currently decoded bit is the 5th bit. Based on the segmentation information of the second value, each segment of the second value includes 4 bits, so the boundary point used for decoding the 5th bit is the aforementioned first boundary point 3409, not the boundary point obtained by updating the boundary point of decoding the 4th bit. That is to say, the boundary point when decoding the first bit of each segment is the first boundary point.

[0264] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the value of the currently decoded bit and the values ​​of the already decoded bits in the target value segment to obtain the current cutoff point. If the value of the currently decoded bit and the values ​​of the already decoded bits in the target value segment correspond to the ratio pattern of the second value, then the server increases the previous cutoff point. If the value of the currently decoded bit and the values ​​of the already decoded bits in the target value segment do not correspond to the ratio pattern of the first value, then the server decreases the previous cutoff point.

[0265] The aforementioned decoding process, in which "the current boundary point is obtained by updating the previous boundary point in the target value segment," is similar in principle to the encoding process described earlier, in which "the first boundary point is obtained by updating the boundary point corresponding to the previous bit read in the target value segment." Please refer to the relevant explanations above, which will not be repeated here.

[0266] It should be noted that the proportion of the boundary point adjustment during the decoding process should be consistent with the proportion of the boundary point adjustment during the encoding process to ensure the accuracy of decoding.

[0267] In this application embodiment, there are multiple possibilities for the server to update the previous boundary point in the target value segment to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0268] In general, the decoding scheme for the second numerical segment on the server follows a similar process. Figure 8 As shown. Please refer to [the original text]. Figure 8 , Figure 8 A flowchart illustrating the data decoding method provided as an example in this application.

[0269] The server acquires a first decoding interval, a second encoded value, segmentation information of the second value, a scaling mode of the second value, and a scaling table. The segmentation information of the second value includes the bit width of the second value and the number of segments comprising the second value. Alternatively, it includes the bit width of the second value and the bit width of each segment. This application embodiment does not limit the order in which the server acquires the aforementioned parameters.

[0270] The server determines the bit width and ratio pattern of the second numerical value, queries the boundary ratio table, and identifies the first boundary point of the second numerical value. Each numerical segment is processed sequentially to obtain the final second numerical value. Sequentially decoding each numerical segment means identifying the first boundary point of the segment, which is designated as the first boundary point. Then, the bits within each numerical segment are decoded sequentially, updating the decoding interval. The specific implementation process is as described in the preceding explanation and will not be repeated here.

[0271] For example, taking the decoding scheme for the second numerical segment as an example, and with specific examples, the data decoding method provided in the embodiments of this application will be described. Assume the second encoded value x is 3346923520, and the first decoding interval is [0, 2...]. 32 -1). The second value has a bit width of 15, including three segments: the first segment, the middle segment, and the last segment. Part of the boundary ratio table is shown in Table 2 below:

[0272] Table 2

[0273] Bit width 9 10 11 12 13 14 15 Boundary point 2877 3123 3286 3409 3491 3573 3614

[0274] Decoding the first segment begins by determining the first boundary point of the segment, which is 3614. When decoding the first bit, xmid is calculated to be 3789553663. Since x is within the decoding interval [x1, xmid], the first decoded bit is 1. Where x1 = 0. The first decoded bit is output, and the first decoding interval [0, 2...] is... 32 -1) is updated to [0, xmid), and the first boundary point is updated.

[0275] During the update of the decoding interval, if the highest byte values ​​of the endpoints x1 and x2 of the decoding interval are the same, the highest byte of the endpoint can be removed by a left shift operation, and the lowest byte can be padded. If the highest byte values ​​of x1 and x2 are different, this operation is not performed, and the decoding of the next bit continues.

[0276] For the processing of the middle and end segments, we follow the same process as for the first segment. In the last loop of processing the middle segment, we obtain x1 as 3346911966, x2 as 3349181358, and x as 3346923520. At this point, the high-order bytes of x1 and x2 are equal, so we update x1 to 2110971392 and x2 to 2691935999. This continues until the number of decoded bits reaches the bit width of the second value, at which point the original value 32275 is recovered from the compressed encoding.

[0277] In some possible implementations, there may be situations where the second encoded value is not included in the current decoding range because the decoding process has not yet reached the bit width of the second value. In this case, it means that the decoding process has failed, and the server can issue an alarm or return a data read failure notification to the terminal. The server can issue alarms by sending reminders to administrators or other maintenance personnel via email, SMS, etc., and the specific method is not limited here.

[0278] exist Figure 7 and Figure 8 The description of the illustrated embodiments introduces a data decoding scheme. In this application embodiment, the server can also decode the data in other ways, which will be explained below with reference to the schematic diagrams. Please refer to... Figure 9 , Figure 9 A flowchart illustrating the data decoding method provided in this application embodiment includes:

[0279] 901. Obtain the second encoded value.

[0280] Step 901 is similar to the process of obtaining the second encoded value in step 701 above. Please refer to the relevant explanation above, and it will not be repeated here.

[0281] 902. Obtain the pre-built table, which includes the first data pair and the second data pair.

[0282] The first data pair includes an encoded value with a bit width less than the bit width threshold and its corresponding numerical value. The second data pair includes an encoded prefix and its corresponding decoding state. The bit width of the encoded prefix is ​​not less than the bit width threshold, and the decoding state includes the numerical value corresponding to the encoded prefix.

[0283] 903. The server determines whether the bit width of the second encoded value is less than or equal to the bit width threshold. If yes, proceed to step 904; otherwise, proceed to step 905.

[0284] The bit width threshold can be set according to the needs of the actual application. It's understandable that a larger bit width threshold results in more first data pairs, increasing the likelihood that the server will directly obtain the decoding result from the pre-built table. Conversely, a smaller bit width threshold results in fewer first data pairs, reducing the storage space occupied by the pre-built table. Therefore, adjusting the bit width threshold can balance computing and storage resources; a suitable bit width threshold can achieve a balance between these two resources.

[0285] Optionally, the bit width threshold can be set to 2 bytes. Considering that data is often stored in lengths of 1 byte, 2 bytes, 4 bytes, and 8 bytes, setting the bit width threshold to 2 bytes can further reduce the storage space occupied by the encoded result and also improve the speedup of the decoding process.

[0286] For example, part of the content of the pre-built table can be shown in Table 3 below:

[0287] Table 3

[0288] The first two bytes of the encoding Numerical / Decoding Status 0x36 32287 0x79 23586 0xdc4a 29717 0xa3ef 7183 0xb70f Decode interval 1, boundary point ratio1, and value y1 0xef73 Decode interval 2, boundary point ratio2, and value y2

[0289] As shown in Table 3, the first two bytes of the encoding are represented in hexadecimal. Each of the first four rows of data can be considered as the first data pair mentioned above. Each of the last two rows of data can be considered as the second data pair mentioned above.

[0290] Optionally, the state of the sub-table corresponding to the first data pair can be marked as the end state. When the second encoded value is included in the first data pair, the server directly obtains the corresponding value as the decoding result.

[0291] 904. Determine the value corresponding to the second encoded value from the pre-built table as the second value corresponding to the second encoded value.

[0292] In schemes where the bit width of the second encoded value is less than or equal to the bit width threshold, the server directly queries the pre-built table to find the encoded value that is the same as the second encoded value. Then, the value corresponding to this encoded value in the pre-built table is used as the decoding result. For example, in the embodiment shown in Table 3 above, if the hexadecimal of the second encoded value is 0x36, then the server queries the pre-built table to determine that the second value is 32287.

[0293] 905. Obtain the bit width of the second value, and determine the second value based on the encoding prefix of the second encoded value, the bit width of the second value, and the pre-built table.

[0294] If the bit width of the second encoded value is greater than the bit width threshold, the server retrieves the decoding status of the second encoded value and the bit width of the second value from a pre-built table to determine the second value. Specifically, the decoding status of the second encoded value includes not only the value corresponding to the prefix of the second encoded value, but also the first decoding interval and the boundary point.

[0295] The first decoding interval refers to the decoding interval corresponding to the encoded prefix of the second encoded value in the pre-built table. It is the decoding interval after the third value has been decoded from the second encoded value. The first decoding interval includes the second encoded value. The delimiter indicates the reduction ratio of the decoding interval in the default scaling mode, which indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0296] During the encoding of the second value, it may be done in segments or without segments. Consequently, there are also multiple possibilities during the decoding of the second encoded value, which will be explained below.

[0297] (1.5) The server does not decode the second numerical segment.

[0298] The server divides the current decoding interval into a second decoding interval and a third decoding interval based on the current boundary point. The second decoding interval corresponds to the default scaling mode, and the third decoding interval corresponds to the non-default scaling mode. The current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval. The current boundary point is either the second boundary point corresponding to the encoding prefix of the second encoded value, or it is obtained by updating the previous boundary point, and the first boundary point is the second boundary point.

[0299] Then, based on the relationship between the second encoded value and the second and third decoding intervals, the value of the currently decoded bit is determined. If the second encoded value is contained within the second decoding interval, the server determines the value of the currently decoded bit to be the first value, which corresponds to the default scaling mode. If the second encoded value is contained within the third decoding interval, the server determines the value of the currently decoded bit to be the second value, which corresponds to the non-default scaling mode.

[0300] The server continuously narrows the encoding interval until it decodes to the bit width of the second value, obtaining the fourth value. The last decoded bit is either the highest or lowest bit of the second value. Additionally, the server uses the value corresponding to the encoded prefix of the second value as the third value. Finally, the server determines the second value based on the third and fourth values. Specifically, this can be achieved by concatenating the third and fourth values.

[0301] The third and fourth values ​​are arranged sequentially. If the last decoded bit is the highest bit of the second value, then the high-order bits of the second value are the fourth value, and the low-order bits are the third value. If the last decoded bit is the lowest bit of the second value, then the high-order bits of the second value are the third value, and the low-order bits are the fourth value.

[0302] In this embodiment, the server compares the bit width of the second encoded value with a bit width threshold, and different comparison results correspond to different decoding methods. If the bit width of the second encoded value is less than or equal to the bit width threshold, the server can directly obtain the second value corresponding to the second encoded value from the pre-built table, accelerating the decoding process and improving decoding efficiency. If the bit width of the second encoded value is greater than the bit width threshold, the decoding of the second encoded value is completed according to the encoding prefix of the second encoded value, the bit width of the second value, and the pre-built table. It does not depend on other values; that is, the second encoded value is not associated with other values ​​and is decoded independently. Therefore, decoding the second value does not need to wait for other encoded values ​​to be decoded before proceeding, thereby improving decoding efficiency. Furthermore, the server determines the value of the currently decoded bit by determining the decoding interval where the second encoded value is located. This value corresponds to the proportional pattern of the decoding interval and matches the encoding process. Based on the foregoing description, the encoding process maps values ​​to a unique interval. Therefore, the decoding process can also achieve lossless decoding by restoring the encoding interval where the encoded value is located, thereby improving the reliability of data decoding.

[0303] In this embodiment, during the decoding process to obtain the fourth value, the current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval. That is, during the decoding process, the server can determine the next decoding interval based on the relationship between the second encoded value and the second and third decoding intervals.

[0304] In some optional implementations, the server determines the decoding interval containing the second encoded value as the next decoding interval. The decoding interval containing the second encoded value is either the aforementioned second decoding interval or the third decoding interval. In other words, the next decoding interval is the decoding interval containing the second encoded value.

[0305] In some optional implementations, the server can further process the decoding interval containing the second encoded value based on the values ​​of the endpoints of the decoding interval containing the second encoded value to obtain the next decoded value. Specifically, if the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are different, then the server determines the next decoding interval to be the decoding interval containing the second encoded value. If the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are the same, then the server processes the decoding interval containing the second encoded value to obtain the next decoding interval. The decoding interval containing the second encoded value can be either the second decoding interval or the third decoding interval.

[0306] The server processes the decoding interval containing the second encoded value to obtain the next decoding interval. This includes: left-shifting the endpoints of the decoding interval containing the second encoded value, removing the highest byte with the same value, and supplementing the lowest byte with a value to ensure that the bit width of the endpoints of the decoding intervals before and after processing is the same. The implementation principle is similar to the server's processing operation on the endpoints of the updated encoding interval in the previous section on "the scheme where the highest byte of the endpoints of the updated encoding interval has the same value," as explained in the previous section, and will not be repeated here.

[0307] In this application, the server can update the decoding interval in multiple ways, enriching the implementation methods and application scenarios of the technical solution and further enhancing its flexibility. Furthermore, the update of the decoding interval matches the aforementioned update of the encoding interval, enabling the encoding process to be restored, ensuring that the decoded value is consistent with the value before encoding, thus improving the reliability of the decoding.

[0308] It's important to note that the server's mechanism for reducing the decoding interval during decoding is consistent with the mechanism for reducing the encoding interval during encoding. In other words, if the encoding interval endpoints with the same highest byte value were not processed during encoding, then the decoding interval endpoints with the same highest byte value will also not be processed during decoding. Conversely, if the encoding interval endpoints with the same highest byte value were processed during encoding, then the decoding interval endpoints with the same highest byte value will also be processed during decoding.

[0309] In “(1.5) Decoding Scheme Where the Server Does Not Segment the Second Value,” the server divides the current decoding interval into a second decoding interval and a third decoding interval based on the current dividing point, thereby determining the value of the currently decoded bit and the next decoding interval. The preceding text briefly described that the current dividing point is related to the second dividing point corresponding to the encoding prefix of the second encoded value.

[0310] Optionally, if the current dividing point is the second dividing point, it means that during the decoding process, the dividing point used to divide the current decoding interval into the second decoding interval and the third decoding interval each time is the same dividing point.

[0311] Optionally, if the current boundary point is obtained by updating the previous boundary point, that is, during the decoding process, the boundary point is updated once for each bit decoded. The boundary point used for each update of the decoding interval may not be the same. When decoding the first bit, the boundary point used is the aforementioned second boundary point; when decoding the second bit, the boundary point used is obtained by updating the second boundary point.

[0312] In this application, the current boundary point can have multiple possibilities, enriching the implementation methods and application scenarios of the technical solution. In the scheme where the current boundary point is the same as the second boundary point, it means that during the decoding of the second encoded value, there is no need to update the boundary point, simplifying the decoding process, saving the amount of data to be processed, and conserving computing resources. In the scheme where the current boundary point is obtained by updating the previous boundary point, it means that the boundary point is updated once for each bit decoded, making the updated boundary point more consistent with the current decoding state, further improving the decoding accuracy.

[0313] In a scheme where the current boundary point is obtained by updating the previous boundary point, the server must update the boundary point before updating the current decoding interval to obtain the current boundary point. There are several possible ways to update, which are explained below:

[0314] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the value of the currently decoded bit to obtain the current cutoff point. If the value of the currently decoded bit corresponds to the ratio pattern of the second value, the server increases the previous cutoff point. If the value of the currently decoded bit does not correspond to the ratio pattern of the second value, the server decreases the previous cutoff point.

[0315] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the values ​​of the decoded bits to obtain the current cutoff point. If the values ​​of the decoded bits correspond to the ratio pattern of the second value, the server increases the previous cutoff point. If the values ​​of the decoded bits do not correspond to the ratio pattern of the second value, the server decreases the previous cutoff point.

[0316] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the value of the currently decoded bit and the values ​​of the already decoded bits to obtain the current cutoff point. If the value of the currently decoded bit and the value of the already decoded bits correspond to the ratio pattern of the second value, then the server increases the previous cutoff point. If the value of the currently decoded bit and the value of the already decoded bits do not correspond to the ratio pattern of the first value, then the server decreases the previous cutoff point.

[0317] The aforementioned decoding process, where "the current boundary point is obtained by updating the previous boundary point," is similar in principle to the encoding process described earlier, where "the first boundary point is obtained by updating the boundary point corresponding to the previously read bit." Please refer to the relevant explanations above; they will not be repeated here. It should also be noted that the adjustment ratio of the boundary point during decoding should be consistent with the adjustment ratio during encoding to ensure decoding accuracy.

[0318] In this application, there are multiple ways for the server to update the previous boundary point to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0319] (1.6) Server decoding scheme for the second numerical segment.

[0320] In this scheme, the server also obtains segmentation information of the second value, indicating that the second value comprises multiple value segments, each with the same bit width. The process by which the server determines the second value based on the encoding prefix of the second encoded value, the bit width of the second value, and a pre-built table includes:

[0321] The value corresponding to the encoding prefix of the second encoded value is used as the third value. Based on the current boundary point, the current decoding interval is divided into a second decoding interval and a third decoding interval. The second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode. The current decoding interval is obtained by updating the previous decoding interval. The first decoding interval is the first decoding interval. The current boundary point is the second boundary point corresponding to the encoding prefix of the second encoded value, or it is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located. The first boundary point of the target value segment is the second boundary point.

[0322] If the second encoded value is contained within the second decoding interval, the value of the currently decoded bit is determined to be the first value. If the second encoded value is contained within the third decoding interval, the value of the currently decoded bit is determined to be the second value. This process continues until the bit width of the second value is reached, resulting in the fourth value. The last decoded bit is determined to be either the highest or lowest bit of the second value. Based on the third and fourth values, the second value is determined.

[0323] The specific implementation process is similar to the previous explanation of "(1.5) Decoding scheme for server not segmenting the second value", please refer to the previous explanation, and will not be repeated here.

[0324] It should be noted that in “(1.6) Decoding Scheme of the Server for the Second Numerical Segment”, the current boundary point is related to the second boundary point corresponding to the encoding prefix of the second encoded value, including: the current boundary point is the second boundary point. Alternatively, the current boundary point is obtained by updating the previous boundary point in the target numerical segment where the currently decoded bit is located, and the second boundary point is the first boundary point of each numerical segment.

[0325] Optionally, if the current dividing point is the first dividing point, it means that during the decoding process, the dividing point used to divide the current decoding interval into the second decoding interval and the third decoding interval is the same dividing point.

[0326] Optionally, if the current boundary point is obtained by updating the previous boundary point in the target value segment, that is, during the decoding process, the boundary point is updated once for each bit decoded. The boundary point used for each update of the decoding interval may not be the same. When decoding the first bit in the target value segment, the boundary point used is the aforementioned second boundary point; when decoding the second bit in the target value segment, the boundary point used is obtained by updating the second boundary point. In this scheme, the second boundary point corresponding to the bit width of the second value in the boundary ratio table can be considered as the boundary point when decoding the first bit of each value segment.

[0327] In this application, in schemes where the second value comprises multiple value segments, the boundary points used in the decoding process can be varied, enriching the implementation methods and application scenarios of the technical solution. Furthermore, if the current boundary point is obtained by updating the previous boundary point in the target value segment, the boundary points of each value segment are independent of each other. Decoding the boundary points used for each value segment better suits the situation of each segment, further improving the reliability of the value decoding.

[0328] In a scheme where the current boundary point is obtained by updating the previous boundary point in the target value segment, the server must update the boundary point before updating the current decoding interval to obtain the current boundary point. There are several possible ways to update the boundary point, which are explained below:

[0329] Optionally, the server can adjust the previous boundary point in the target value segment up or down by a preset ratio based on the value of the currently decoded bit, thus obtaining the current boundary point. If the value of the currently decoded bit corresponds to the ratio pattern of the second value, the server increases the previous boundary point. If the value of the currently decoded bit does not correspond to the ratio pattern of the second value, the server decreases the previous boundary point.

[0330] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the values ​​of the already decoded bits in the target value segment to obtain the current cutoff point. If the values ​​of the already decoded bits in the target value segment correspond to the ratio pattern of the second value, then the server increases the previous cutoff point. If the values ​​of the already decoded bits in the target value segment do not correspond to the ratio pattern of the second value, then the server decreases the previous cutoff point.

[0331] Optionally, the server can adjust the previous cutoff point up or down by a preset ratio based on the value of the currently decoded bit and the values ​​of the already decoded bits in the target value segment to obtain the current cutoff point. If the value of the currently decoded bit and the values ​​of the already decoded bits in the target value segment correspond to the ratio pattern of the second value, then the server increases the previous cutoff point. If the value of the currently decoded bit and the values ​​of the already decoded bits in the target value segment do not correspond to the ratio pattern of the first value, then the server decreases the previous cutoff point.

[0332] The aforementioned decoding process, in which "the current boundary point is obtained by updating the previous boundary point in the target value segment," is similar in principle to the encoding process described earlier, in which "the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previous read bit in the target value segment." Please refer to the relevant explanations above, which will not be repeated here.

[0333] It should also be noted that the adjustment ratio of the dividing point during the decoding process should be consistent with the adjustment ratio of the dividing point during the encoding process, so as to ensure the accuracy of decoding.

[0334] In this application, there are multiple ways for the server to update the previous boundary point in the target value segment to obtain the current boundary point, which enriches the implementation methods and application scenarios of the technical solution of this application and improves the flexibility of the technical solution of this application.

[0335] It should be noted that the pre-built table can be stored locally on the server or on other devices accessible to the server; the pre-built table can be calculated by the server or by other devices, without specific limitations here. If the data pairs in the pre-built table are calculated by the server, it can be understood that during the encoding process, the server stores the encoded values ​​smaller than the bit width threshold and their corresponding values ​​as the first data pair. The encoded prefixes and decoding states of the encoded values ​​greater than or equal to the bit width threshold obtained during the encoding process are stored as the second data pair, which can be stored locally or on a remote device. In other words, the number of data pairs included in the pre-built table can change as the server's encoding process progresses.

[0336] Please see Figure 10 , Figure 10 This is a schematic diagram of the structure of the data encoding device provided in an embodiment of this application. Figure 10 As shown, the data encoding device 1000 includes an acquisition unit 1001 and a processing unit 1002.

[0337] In some alternative implementations, the data encoding device is used to implement the aforementioned Figures 1 to 5 In any of the embodiments shown, the server performs a data encoding operation, including:

[0338] Acquisition unit 1001 is used to acquire a first value and a first encoding interval of the first value. It acquires a boundary ratio table, which includes the correspondence between the bit width of the value and the boundary points. The boundary points indicate the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0339] The processing unit 1002 is used to encode the first numerical value according to the first encoding interval and the boundary ratio table to obtain the first encoded value.

[0340] In addition, the data encoding device can also achieve the aforementioned Figure 1 or Figure 6 In the illustrated embodiment, the server performs data encoding operations, including:

[0341] The acquisition unit 1001 is used to acquire a first value and a pre-built table. The pre-built table includes at least one first data pair, and each first data pair contains a value and a corresponding encoded value.

[0342] If at least one first data pair in the pre-built table includes a first value, then the processing unit 1002 is used to determine from the pre-built table that the encoded value corresponding to the first value is the first encoded value.

[0343] If at least one data pair in the pre-built table does not include the first numerical value, then the acquisition unit 1001 is further configured to acquire the first encoding interval and the boundary ratio table. The first encoding interval is the interval in which the first encoded value obtained by encoding the first numerical value is located. The boundary ratio table includes the correspondence between the bit width of the numerical value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the numerical value. The processing unit 1002 is further configured to encode the first numerical value according to the first encoding interval and the boundary ratio table to obtain the first encoded value.

[0344] Each unit in data encoding 1000 is also used to perform the operations shown in the following optional implementation:

[0345] In some optional implementations, the processing unit 1002 is specifically configured to: determine the boundary point of the first value based on the bit width of the first value, the scaling mode of the first value, and the boundary scaling table; starting from the first bit of the first value, sequentially read all bits of the first value, where the first bit is either the highest or lowest bit of the first value; based on the value of the currently read bit and the boundary point corresponding to the currently read bit, reduce the current encoding interval until all bits of the first value have been read, obtaining a second encoding interval. Here, the encoding interval of the first bit is the first encoding interval, and the boundary point corresponding to the first bit is the boundary point of the first value. The boundary point corresponding to the currently read bit is either the boundary point of the first value or an update of the boundary point corresponding to the previously read bit. Determine the first encoded value from the second encoding interval.

[0346] In some optional implementations, the processing unit 1002 is specifically used for:

[0347] Based on the bit width, scaling mode, and boundary scaling table of the first numerical value, determine the boundary point of the first numerical value. Starting from the first bit of the first numerical value, read all bits of the first numerical value sequentially, with the first bit being either the highest or lowest bit. Based on the value of the currently read bit and the boundary point corresponding to the currently read bit, reduce the current encoding interval to obtain the updated encoding interval. The encoding interval of the first bit is the first encoding interval, and the boundary point corresponding to the first bit is the boundary point of the first numerical value. The boundary point corresponding to the currently read bit is either the boundary point of the first numerical value or an update of the boundary point corresponding to the previously read bit. Determine the first encoded value from the second encoding interval. If the highest byte values ​​of the endpoints of the updated encoding interval are the same, process the updated encoding interval to obtain the encoding interval corresponding to the next bit of the currently read bit, and read the next bit. If the highest byte values ​​of the endpoints of the updated encoding interval are different, read the next bit, and the encoding interval of the next bit is the updated encoding interval. Continue reading all bits of the first numerical value to obtain the second encoding interval. Therefore, the first encoded value may be contained within the second encoded interval. Alternatively, the first encoded value may consist of a high byte and a low byte, where the high byte includes the highest byte with the same value at the endpoints of the encoded interval, and the low byte is contained within the second encoded interval.

[0348] In some optional implementations, if the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit, the processing unit 1002 is further configured to: adjust the boundary point corresponding to the previously read bit by a preset ratio up or down according to the value of the currently read bit and / or the value of the bits already read in the first value, so as to obtain the boundary point corresponding to the currently read bit.

[0349] In some optional implementations, the processing unit 1002 is specifically configured to: divide a first value into multiple value segments, each with the same bit width; determine the boundary point of each value segment based on the bit width of the first value, the scaling mode of each value segment, and a scaling table; sequentially read all bits of the first value, starting from the first bit, where the first bit is either the highest or lowest bit of the first value; reduce the current encoding interval based on the value of the currently read bit and the boundary point corresponding to the currently read bit, until all bits of the first value have been read, resulting in a second encoding interval. The encoding interval of the first bit is the first encoding interval, and the boundary point corresponding to the first read bit of each value segment is the boundary point of each value segment. The boundary point corresponding to the currently read bit is the boundary point of the target value segment where the currently read bit is located, or it is obtained by updating the boundary point corresponding to the previously read bit in the target value segment. Determine a first encoded value from the second encoding interval.

[0350] In some optional implementations, the processing unit 1002 is specifically used for:

[0351] The first numerical value is divided into multiple segments, each with the same bit width. Based on the bit width of the first numerical value, the scaling mode of each segment, and the scaling table, the boundary point of each segment is determined. Starting from the first bit of the first numerical value, all bits of the first numerical value are read sequentially, with the first bit being either the highest or lowest bit. Based on the value of the currently read bit and its corresponding boundary point, the current encoding interval is reduced to obtain the updated encoding interval. Specifically, the encoding interval for the first bit is the first encoding interval, the boundary point corresponding to the first read bit in a segment is the boundary point of that segment, and the boundary point corresponding to the currently read bit is the boundary point of the segment containing the currently read bit, or it is obtained by updating the boundary point corresponding to the previously read bit in the segment containing the currently read bit. If the highest byte values ​​of the endpoints of the updated encoding interval are the same, the endpoints of the updated encoding interval are processed to obtain the encoding interval corresponding to the next bit of the currently read bit, and the next bit is read. If the highest byte values ​​at the endpoints of the updated encoding interval are different, the next bit is read, and the encoding interval for the next bit becomes the updated encoding interval. This process continues until all bits of the first value have been read, resulting in the second encoding interval. The first encoded value may be contained within the second encoding interval. Alternatively, the first encoded value may consist of a high byte and a low byte, where the high byte includes the highest byte with the same value at the endpoints of the encoding interval, and the low byte is contained within the second encoding interval.

[0352] In some optional implementations, if the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit in the target value segment, the processing unit 1002 is further configured to: adjust the boundary point corresponding to the previously read bit in the target value segment up or down by a preset ratio according to the value of the currently read bit and / or the value of the bits already read in the target value segment, so as to obtain the boundary point corresponding to the bit of the currently read data.

[0353] In some optional implementations, the processing unit 1002 is further configured to: compress the first encoded value to obtain a first compressed result, wherein the number of bytes in the first compressed result is less than the number of bytes in the first value.

[0354] In the aforementioned optional embodiments, the data encoding device is used to implement the data encoding method provided in the embodiments of this application. The specific implementation process is detailed above and will not be repeated here.

[0355] Please see Figure 11 , Figure 11 This is a schematic diagram of the data decoding device provided in an embodiment of this application. Figure 11 As shown, the data decoding device 1100 includes an acquisition unit 1101 and a processing unit 1102.

[0356] In this embodiment, the data decoding device can implement the aforementioned... Figure 1 , Figure 7 or Figure 8 In this embodiment, the server performs a data decoding operation, including:

[0357] In some optional implementations, the acquisition unit 1101 is used to acquire a second encoded value, the bit width of a second numerical value corresponding to the second encoded value, and a first decoding interval, wherein the second encoded value is included in the first decoding interval. A boundary ratio table is acquired, which includes the correspondence between the bit width of the numerical value and boundary points. The boundary points indicate the reduction ratio of the decoding interval under the default ratio mode, and the default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the numerical value.

[0358] The processing unit 1102 is used to decode the second encoded value according to the bit width of the second value, the first decoding interval and the boundary ratio table to obtain the second value.

[0359] In some optional implementations, the processing unit 1102 is specifically configured to: obtain the current boundary point according to the bit width of the second value and the boundary ratio table, wherein the current boundary point is the first boundary point corresponding to the bit width of the second value in the boundary ratio table, or is obtained by updating the previous boundary point, and the first boundary point is the first boundary point. Based on the current boundary point, divide the current decoding interval into a second decoding interval and a third decoding interval, wherein the second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode, and the current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval. If the second encoded value is contained in the second decoding interval, then the bit value of the currently decoded bit is determined to be the first value. If the second encoded value is contained in the third decoding interval, then the bit value of the currently decoded bit is determined to be the second value. This process continues until the bit width of the second value is decoded to obtain the second value, wherein the first decoded bit is the value of the highest or lowest bit of the second value.

[0360] In some optional implementations, if the current boundary point is obtained by updating the previous boundary point, the processing unit 1102 is further configured to: adjust the previous boundary point up or down by a preset ratio according to the value of the currently decoded bit and / or the value of the already decoded bit, to obtain the current boundary point.

[0361] In some optional implementations, the acquisition unit 1101 is further configured to acquire segmentation information of the second value, wherein the segmentation information indicates that the second value includes multiple value segments, each value segment having the same bit width.

[0362] Processing unit 1102 is specifically used for: obtaining the current boundary point according to the bit width and boundary ratio table of the second value. The current boundary point is the same as the first boundary point corresponding to the bit width of the second value in the boundary ratio table, or it is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located. The first boundary point of the target value segment is the first boundary point. Based on the current boundary point, the current decoding interval is divided into a second decoding interval and a third decoding interval. The second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode. The current decoding interval is obtained by updating the previous decoding interval, and the first decoding interval is the first decoding interval. If the second encoded value is contained in the second decoding interval, the value of the currently decoded bit is determined to be the first value. If the second encoded value is contained in the third decoding interval, the value of the currently decoded bit is determined to be the second value. This process continues until the bit width of the second value is decoded to obtain the second value. The value of the first decoded bit is the value of the highest or lowest bit of the second value.

[0363] In some optional implementations, if the current boundary point is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located, the processing unit 1102 is further configured to: adjust the previous boundary point in the target value segment up or down by a preset ratio according to the value of the currently decoded bit in the target value segment, and / or the value of the already decoded bit in the target value segment, to obtain the current boundary point.

[0364] In some optional embodiments, the processing unit 1102 is further configured to: if the highest byte values ​​of the endpoints of the decoding intervals containing the second encoded value are different, then determine the next decoding interval as the encoding interval containing the second encoded value. If the highest byte values ​​of the endpoints of the decoding intervals containing the second encoded value are the same, then process the encoding interval containing the second encoded value to obtain the next decoding interval. The decoding interval containing the second encoded value is either the second decoding interval or the third decoding interval.

[0365] For details on the implementation process of the aforementioned embodiments, please refer to the preceding text. Figure 1 , Figure 7 or Figure 8 The relevant descriptions of the embodiments shown will not be repeated here.

[0366] In this embodiment, the data decoding device can also implement the aforementioned Figure 1 ,or Figure 9 In the illustrated embodiment, the server performs a data decoding operation, including:

[0367] In some optional implementations, the acquisition unit 1101 is used to acquire a second encoded value and a pre-built table. The pre-built table includes a first data pair and a second data pair. The first data pair includes an encoded value with a bit width less than a bit width threshold and a corresponding numerical value. The second data pair includes an encoded prefix and a corresponding decoding state. The bit width of the encoded prefix is ​​not less than the bit width threshold. The decoding state includes the numerical value corresponding to the encoded prefix.

[0368] The processing unit 1102 is configured to, if the bit width of the second encoded value is less than or equal to a bit width threshold, determine the value corresponding to the second encoded value from a pre-built table as the second value corresponding to the second encoded value. If the bit width of the second encoded value is greater than the bit width threshold, obtain the bit width of the second value, and determine the second value according to the encoding prefix of the second encoded value, the bit width of the second value, and the pre-built table.

[0369] In some optional implementations, the decoding state further includes a first decoding interval and a dividing point, the second encoded value is contained in the first decoding interval, the dividing point indicates the reduction ratio of the decoding interval in the default scaling mode, and the default scaling mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0370] Processing unit 1102 is specifically used for: taking the value corresponding to the encoding prefix of the second encoded value as the third value; dividing the current decoding interval into a second decoding interval and a third decoding interval based on the current boundary point; the second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode; the current decoding interval is obtained by updating the previous decoding interval, with the first decoding interval being the first decoding interval; the current boundary point is the second boundary point corresponding to the encoding prefix of the second encoded value, or it is obtained by updating the previous boundary point, with the first boundary point being the second boundary point; if the second encoded value is contained in the second decoding interval, then the value of the currently decoded bit is determined to be the first value; if the second encoded value is contained in the third decoding interval, then the value of the currently decoded bit is determined to be the second value; continuing until the bit width of the second value is decoded to obtain the fourth value, with the last decoded bit being the value of the highest or lowest bit of the second value; and determining the second value based on the third and fourth values.

[0371] In some optional implementations, if the current boundary point is obtained by updating the previous boundary point, the processing unit 1102 is further configured to: adjust the previous boundary point up or down by a preset ratio according to the value of the currently decoded bit and / or the value of the already decoded bit, to obtain the current boundary point.

[0372] In some optional implementations, the decoding state further includes a first decoding interval and a dividing point, the second encoded value is contained in the first decoding interval, the dividing point indicates the reduction ratio of the decoding interval in the default scaling mode, and the default scaling mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value.

[0373] The acquisition unit 1101 is also used to acquire segmentation information of the second value, the segmentation information indicating that the second value includes multiple value segments, each value segment having the same bit width.

[0374] Processing unit 1102 is specifically used for: taking the value corresponding to the encoding prefix of the second encoded value as the third value; dividing the current decoding interval into a second decoding interval and a third decoding interval based on the current boundary point; the second decoding interval corresponds to the default ratio mode, and the third decoding interval corresponds to the non-default ratio mode; the current decoding interval is obtained by updating the previous decoding interval, with the first decoding interval being the first decoding interval; the current boundary point is either the second boundary point corresponding to the encoding prefix of the second encoded value, or it is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located, with the first boundary point of the target value segment being the second boundary point; if the second encoded value is contained in the second decoding interval, then the value of the currently decoded bit is determined to be the first value; if the second encoded value is contained in the third decoding interval, then the value of the currently decoded bit is determined to be the second value; continuing until the bit width of the second value is decoded to obtain the fourth value, with the last decoded bit being the value of the highest or lowest bit of the second value; and determining the second value based on the third and fourth values.

[0375] In some optional implementations, if the current boundary point is obtained by updating the previous boundary point in the target value segment where the currently decoded bit is located, the processing unit 1102 is further configured to: adjust the previous boundary point in the target value segment up or down by a preset ratio according to the value of the currently decoded bit in the target value segment and / or the value of the already decoded bit in the target value segment to obtain the current boundary point.

[0376] In some optional implementations, the processing unit 1102 is further configured to determine the next decoding interval as the decoding interval containing the second encoded value if the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are different. If the highest byte values ​​of the endpoints of the decoding interval containing the second encoded value are the same, the processing unit 1102 is configured to process the decoding interval containing the second encoded value to obtain the next decoding interval.

[0377] The decoding interval containing the second encoded value is either the second decoding interval or the third decoding interval.

[0378] For details on the implementation process of the aforementioned embodiments, please refer to the preceding text. Figure 1 ,or Figure 9 The relevant descriptions of the embodiments shown will not be repeated here.

[0379] It should be noted that the aforementioned acquisition unit 1001, processing unit 1002, acquisition unit 1101, and processing unit 1102 can all be implemented in software or in hardware. For example, the implementation of processing unit 1002 will be described below. Similarly, the implementation of acquisition unit 1001, acquisition unit 1101, and processing unit 1102 can refer to the implementation of processing unit 1002.

[0380] As an example of a software functional unit, processing unit 1002 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, processing unit 1002 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0381] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0382] As an example of a hardware functional unit, the processing unit 1002 may include at least one computing device, such as a server. Alternatively, the processing unit 1002 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0383] The processing unit 1002 includes multiple computing devices that can be distributed in the same region or in different regions. Similarly, the processing unit 1002 can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the processing unit 1002 can be distributed in the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0384] It should be noted that the data encoding device 1000 achieves all its functions by implementing different steps in the data encoding method through the acquisition unit 1001 and the processing unit 1002. The data encoding device 1000 is used for the aforementioned... Figures 1 to 6 The operations performed by the server in the illustrated embodiment are to implement the data encoding method provided in the embodiments of this application, and will not be described in detail here.

[0385] It should be noted that the data encoding device 1100 achieves all its functions by implementing different steps in the data decoding method through the acquisition unit 1101 and the processing unit 1102. The data encoding device 1100 is used for the aforementioned... Figure 1 , Figures 7 to 9 The operations performed by the server in the illustrated embodiment are to implement the data decoding method provided in the embodiments of this application, and will not be described in detail here.

[0386] The computing device provided in the embodiments of this application will be described below. Please refer to [link / reference]. Figure 12 , Figure 12 This is a schematic diagram of a computing device provided in an embodiment of this application. The computer device 1200 includes a processor 1201, a memory 1202, a communication interface 1203, and a bus 1204. The processor 1201, memory 1202, and communication interface 1203 communicate via the bus 1204, or they can communicate via other means such as wireless transmission.

[0387] Processor 1201 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0388] The communication interface 1202 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 1200 and other devices or communication networks.

[0389] Bus 1203 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 12 The bus 1203 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 1203 may include a path for transmitting information between various components of the computing device 1200 (e.g., memory 1204, processor 1201, communication interface 1202).

[0390] The memory 1204 may include volatile memory, such as random access memory (RAM). The memory 1204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0391] The memory 1204 stores executable program code, and the processor 1201 executes the executable program code to implement the aforementioned functions. Figure 10 or Figure 11 The functions of the acquisition unit and processing unit are shown.

[0392] Optionally, the processor 1201 executes executable program code to implement the aforementioned Figure 10 The functions of the acquisition unit 1001 and the processing unit 1002 in the illustrated embodiment are used to implement the data encoding method. That is, the memory 1204 stores instructions for executing the data encoding method.

[0393] Optionally, the processor 1201 executes executable program code to implement the aforementioned Figure 10 The functions of the acquisition unit 1101 and the processing unit 1102 in the illustrated embodiment are used to implement the data decoding method. That is, the memory 1204 stores instructions for executing the data decoding method.

[0394] It should also be noted that this application does not limit the number of processors and memory in the computing device 1200.

[0395] This application also provides a computing device cluster, which includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some alternative implementations, the computing device can also be a desktop computer, a laptop computer, or a smartphone, or other terminal device.

[0396] Please see Figure 13 , Figure 13 This is a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application.

[0397] like Figure 13 As shown, the computing device cluster includes at least one computing device 1200. The memory 1204 of one or more computing devices 1200 in the computing device cluster may store the same instructions for executing the data encoding method or data decoding method provided in the embodiments of this application.

[0398] In some possible implementations, the memory 1204 of one or more computing devices 1200 in the computing device cluster may also store partial instructions for executing data encoding or data decoding methods. In other words, a combination of one or more computing devices 1204 can jointly execute instructions for executing data encoding or data decoding methods.

[0399] It should be noted that the memory 1204 in different computing devices 1200 within the computing device cluster can store different instructions, which are used to execute parts of the functions of the data encoding device or the data decoding device, respectively. That is, the instructions stored in the memory 1204 of different computing devices 1200 can implement the functions of one or more units of the acquisition unit 1001 and the processing unit 1002. Alternatively, the instructions stored in the memory 1204 of different computing devices 1200 can implement the functions of one or more units of the acquisition unit 1101 and the processing unit 1102.

[0400] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 14 One possible implementation is shown. For example... Figure 14 As shown, two computing devices 1200A and 1200B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this possible implementation, the memory 1204 in computing device 1200A stores instructions for executing the functions of the acquisition unit. Simultaneously, the memory 1204 in computing device 1200B stores instructions for executing the functions of the processing unit.

[0401] Figure 14 The connection method between the computing device clusters shown can be based on the data encoding or data decoding method provided in this application, in which the processing operation and the operation other than the processing operation are executed separately. That is, the function of the acquisition unit is assigned to the computing device 1200A and the function of the processing unit is assigned to the computing device 1200B.

[0402] It should be noted that if the instructions stored in the memory 1204 of the computing device 1200A are instructions for executing the function of the acquisition unit 1001, then the instructions stored in the memory 1204 of the computing device 1200B are instructions for executing the function of the processing unit 1002, so as to implement the data encoding method provided in this application.

[0403] If the instructions stored in the memory 1204 of the computing device 1200A are instructions for executing the function of the acquisition unit 1101, then the instructions stored in the memory 1204 of the computing device 1200B are instructions for executing the function of the processing unit 1102, so as to implement the data decoding method provided in this application.

[0404] It should be understood that Figure 14 The functions of the computing device 1200A shown can also be performed by multiple computing devices 1200. Similarly, the functions of the computing device 1200B can also be performed by multiple computing devices 1200.

[0405] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computer device, it causes the at least one computer device to perform the aforementioned data encoding method or data decoding method.

[0406] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to perform the aforementioned data encoding method or data decoding method.

[0407] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0408] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.

Claims

1. A data encoding method, characterized in that, include: Obtain the first value and the first encoding interval of the first value; Obtain the boundary ratio table, which includes the correspondence between the bit width of the value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1 in the value. The first numerical value is encoded according to the first encoding interval and the boundary ratio table to obtain the first encoded value.

2. The method according to claim 1, characterized in that, The step of encoding the first numerical value according to the first encoding interval and the boundary ratio table to obtain the first encoded value includes: The boundary point of the first value is determined based on the bit width of the first value, the scaling mode of the first value, and the boundary scaling table. Starting from the first bit of the first value, all bits of the first value are read sequentially, where the first bit is either the highest bit or the lowest bit of the first value; Based on the value of the currently read bit and the boundary point corresponding to the currently read bit, the current encoding interval is reduced until all bits of the first value are read, resulting in a second encoding interval; wherein, the encoding interval of the first bit is the first encoding interval, the boundary point corresponding to the first bit is the boundary point of the first value, the boundary point corresponding to the currently read bit is the boundary point of the first value, or it is obtained by updating the boundary point corresponding to the previously read bit; The first coded value is determined from the second coded interval.

3. The method according to claim 2, characterized in that, If the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit, then before reducing the current encoding interval, the method further includes: Based on the value of the currently read bit and / or the values ​​of the bits already read in the first value, the boundary point corresponding to the previously read bit is adjusted up or down by a preset ratio to obtain the boundary point corresponding to the currently read bit.

4. The method according to claim 1, characterized in that, The step of encoding the first numerical value according to the first encoding interval and the boundary ratio table to obtain the first encoded value includes: The first value is divided into multiple value segments, each with the same bit width; The boundary point of each value segment is determined based on the bit width of the first value, the scaling mode of each value segment, and the scaling table. Starting from the first bit of the first value, all bits of the first value are read sequentially, where the first bit is either the highest bit or the lowest bit of the first value; Based on the value of the currently read bit and the boundary point corresponding to the currently read bit, the current encoding interval is reduced until all bits of the first value are read, resulting in a second encoding interval; wherein, the encoding interval of the first bit is the first encoding interval, the boundary point corresponding to the first read bit in each value segment is the boundary point of each value segment, and the boundary point corresponding to the currently read bit is the boundary point of the target value segment where the currently read bit is located, or it is obtained by updating the boundary point corresponding to the previously read bit in the target value segment; The first coded value is determined from the second coded interval.

5. The method according to claim 4, characterized in that, If the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit in the target value segment, then before reducing the current encoding interval, the method further includes: Based on the value of the currently read bit and / or the values ​​of the bits already read in the target value segment, the boundary point corresponding to the previously read bit in the target value segment is adjusted up or down by a preset ratio to obtain the boundary point corresponding to the currently read bit.

6. A data encoding device, characterized in that, The device includes: An acquisition unit is used to acquire a first value and a first encoding interval of the first value; The acquisition unit is also used to acquire a boundary ratio table, which includes the correspondence between the bit width of the value and the boundary point. The boundary point indicates the reduction ratio of the encoding interval under the default ratio mode. The default ratio mode indicates the default size relationship between the number of bits with a value of 0 and the number of bits with a value of 1. The processing unit is configured to encode the first numerical value according to the first encoding interval and the boundary ratio table to obtain a first encoded value.

7. The apparatus according to claim 6, characterized in that, The processing unit is specifically used for: The boundary point of the first value is determined based on the bit width of the first value, the scaling mode of the first value, and the boundary scaling table. Starting from the first bit of the first value, all bits of the first value are read sequentially, where the first bit is either the highest bit or the lowest bit of the first value; Based on the value of the currently read bit and the boundary point corresponding to the currently read bit, the current encoding interval is reduced until all bits of the first value are read, resulting in a second encoding interval; wherein, the encoding interval of the first bit is the first encoding interval, the boundary point corresponding to the first bit is the boundary point of the first value, the boundary point corresponding to the currently read bit is the boundary point of the first value, or it is obtained by updating the boundary point corresponding to the previously read bit; The first coded value is determined from the second coded interval.

8. The apparatus according to claim 7, characterized in that, If the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit, then the processing unit is specifically used for: Based on the value of the currently read bit and / or the values ​​of the bits already read in the first value, the boundary point corresponding to the previously read bit is adjusted up or down by a preset ratio to obtain the boundary point corresponding to the currently read bit.

9. The apparatus according to claim 6, characterized in that, The processing unit is specifically used for: The first value is divided into multiple value segments, each with the same bit width; The boundary point of each value segment is determined based on the bit width of the first value, the scaling mode of each value segment, and the scaling table. Starting from the first bit of the first value, all bits of the first value are read sequentially, where the first bit is either the highest bit or the lowest bit of the first value; Based on the value of the currently read bit and the boundary point corresponding to the currently read bit, the current encoding interval is reduced until all bits of the first value are read, resulting in a second encoding interval; wherein, the encoding interval of the first bit is the first encoding interval, the boundary point corresponding to the first read bit in each value segment is the boundary point of each value segment, and the boundary point corresponding to the currently read bit is the boundary point of the target value segment where the currently read bit is located, or it is obtained by updating the boundary point corresponding to the previously read bit in the target value segment; The first coded value is determined from the second coded interval.

10. The apparatus according to claim 9, characterized in that, If the boundary point corresponding to the currently read bit is obtained by updating the boundary point corresponding to the previously read bit in the target value segment, then the processing unit is specifically used for: Based on the value of the currently read bit and / or the values ​​of the bits already read in the target value segment, the boundary point corresponding to the previously read bit in the target value segment is adjusted up or down by a preset ratio to obtain the boundary point corresponding to the currently read bit.

11. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method as described in any one of claims 1 to 5.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a processor, cause the method of any one of claims 1 to 5 to be implemented.

13. A computer program product, characterized in that, When the computer program product is executed on a computing device, the method of any one of claims 1 to 5 is implemented.