Numerical data variable-length coding storage method and device, equipment and medium

By separating the integer and fractional parts of numerical data, and combining padded truncation, digital-level compression mapping, and sign bit encoding, a variable-length storage sequence is generated. This solves the problems of floating-point type errors and storage waste of fixed-length fixed-point types, and achieves efficient and flexible numerical data storage.

CN121749993APending Publication Date: 2026-03-27JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In existing databases, the precision errors caused by floating-point type storage and the space waste caused by fixed-length fixed-point type storage make it difficult to find a balance between ensuring numerical accuracy and flexibility.

Method used

By splitting numerical data into integer and fractional parts, performing depadding, truncation, and bit-by-bit grouping mapping processes respectively, a variable-length storage sequence is generated. A sign mask and a first-byte bit flipping rule are then introduced to form the final variable-length storage sequence.

Benefits of technology

While ensuring numerical precision and sign consistency, we aim to reduce storage overhead, improve storage efficiency and space utilization, and maintain the compatibility of numerical sorting and comparison operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121749993A_ABST
    Figure CN121749993A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data storage, and discloses a numerical data variable-length coding storage method, device, equipment and medium, which comprises the following steps: converting target numerical data into fixed-length binary representation according to definition precision, executing filling removal interception processing on an integer part, executing digital-level packet compression coding on a decimal part, and performing variable-length coding on the target numerical data; and generating a variable-length binary sequence containing length information and symbol information, and writing the sequence into a storage medium to realize compact storage of numerical data. According to the method, redundant filling bytes are eliminated from an integer part, compressed encoding is performed on a decimal part according to effective digits, and unified processing of sign bits is combined, so that a storage space dynamically changes along with actual numerical digits on the premise of keeping numerical precision and analyzability, space waste of fixed-length numerical types is reduced, and the method is suitable for large-scale popularization and application. Meanwhile, the precision error of the floating-point number is avoided, and the storage efficiency and the data reliability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, in particular to a numerical data variable-length encoding storage method, device, equipment and medium. BACKGROUND

[0002] In a database system, numerical data with a decimal part is usually stored and processed by a floating-point type or a fixed-point type. Among them, the floating-point type represents numerical values in binary form, has a large numerical value representation range, but its underlying representation method determines that part of the decimal fraction cannot be accurately represented, and rounding errors are inevitable in data storage and operation. When such numerical values are frequently involved in calculation, comparison or sorting, the error may continue to accumulate, thereby affecting the determinacy and consistency of the results, and it is difficult to meet the application scenarios that require accurate expression and stable storage of numerical values.

[0003] In contrast, the fixed-point type can avoid the representation error problem common in the floating-point type by explicitly encoding decimal numbers, so it is widely used in scenarios that require strict maintenance of numerical accuracy. However, the existing fixed-point type usually adopts a fixed-length storage mechanism, that is, the maximum number of bits of the integer part and the decimal part is determined in the field definition stage, and all records are allocated the same length of storage space. This storage method does not distinguish the actual effective number of bits of the numerical value, and for numerical values with fewer integer bits or a large number of zero values at the end of the decimal part, the complete storage space is also occupied, resulting in low overall storage efficiency, especially in scenarios with a large number of numerical fields or large data sizes, the problem of space waste is more prominent.

[0004] In addition, the numerical representation method of fixed-length storage lacks flexibility in data organization. Since the sign information, integer part and decimal part of the numerical value are usually mixed in a fixed structure for processing, it is difficult to adopt differentiated processing strategies for different components when data compression, trimming or encoding is performed. The rigidity of this structure makes it impossible to make fine adjustments to the numerical value according to its actual characteristics when it is converted to the underlying binary form, thereby limiting the possibility of further reducing storage redundancy while ensuring the consistency of numerical semantics. SUMMARY

[0005] The main purpose of the present application is to provide a numerical data variable-length encoding storage method, device, equipment and storage medium, which aims to solve the technical problems that the existing database numerical storage method either produces precision errors due to floating-point representation, or causes storage space waste due to fixed-length fixed-point format, and it is difficult to realize efficient and variable-length storage according to the actual effective number of bits while ensuring decimal accuracy.

[0006] To achieve the above purpose, the present application provides a numerical data variable-length encoding storage method, comprising: acquire target numerical data to be stored, and convert the target numerical data into an intermediate fixed-length binary sequence containing an integer part data segment and a decimal part data segment according to a preset definition precision; analyze the intermediate fixed-length binary sequence to determine a positive and negative polarity attribute, and perform a de-padding and cutting process on the integer part data segment based on the positive and negative polarity attribute to generate valid integer binary data; analyze the decimal part data segment in the intermediate fixed-length binary sequence to acquire a valid digit sequence, and perform a bit grouping and mapping process on the valid digit sequence to generate valid decimal compressed data; generate a head description byte recording the length information of the valid integer binary data, and sequentially splice the head description byte, the valid integer binary data, and the valid decimal compressed data to generate a to-be-marked variable-length sequence; generate a full-bit symbol mask based on the positive and negative polarity attribute, perform a bit-by-bit logical XOR operation on all bytes of the to-be-marked variable-length sequence using the full-bit symbol mask, and perform a flip operation on the highest bit of the first byte after the operation to generate a final variable-length storage sequence; write the final variable-length storage sequence into a storage medium.

[0007] Further, to achieve the above object, the present application provides a numerical data variable-length encoding storage device, comprising: a fixed-length binary encoding module, configured to acquire target numerical data to be stored, and convert the target numerical data into an intermediate fixed-length binary sequence containing an integer part data segment and a decimal part data segment according to a preset definition precision; an integer de-padding and cutting module, configured to analyze the intermediate fixed-length binary sequence to determine a positive and negative polarity attribute, and perform a de-padding and cutting process on the integer part data segment based on the positive and negative polarity attribute to generate valid integer binary data; a decimal grouping and mapping compression module, configured to analyze the decimal part data segment in the intermediate fixed-length binary sequence to acquire a valid digit sequence, and perform a bit grouping and mapping process on the valid digit sequence to generate valid decimal compressed data; a head description splicing module, configured to generate a head description byte recording the length information of the valid integer binary data, and sequentially splice the head description byte, the valid integer binary data, and the valid decimal compressed data to generate a to-be-marked variable-length sequence; a global symbol mask processing module, configured to generate a full-bit symbol mask based on the positive and negative polarity attribute, perform a bit-by-bit logical XOR operation on all bytes of the to-be-marked variable-length sequence using the full-bit symbol mask, and perform a flip operation on the highest bit of the first byte after the operation to generate a final variable-length storage sequence; a storage medium writing module, configured to write the final variable-length storage sequence into a storage medium.

[0008] Further, to achieve the above object, the present application also provides a computer device, comprising a memory, a processor, and a numerical data variable-length encoding storage program stored in the memory and executable on the processor, and the numerical data variable-length encoding storage program implements the steps of the numerical data variable-length encoding storage method when executed by the processor.

[0009] Further, to achieve the above object, the present application also provides a computer readable storage medium, wherein the storage medium stores a numerical data variable-length encoding storage program, and the numerical data variable-length encoding storage program implements the steps of the numerical data variable-length encoding storage method when executed by a processor.

[0010] Beneficial effects: The present application relates to the technical field of data storage, and discloses a numerical data variable-length encoding storage method, device, equipment and medium, comprising: for numerical data to be stored, constructing a fixed-length binary representation comprising an integer part and a decimal part according to a preset definition precision, performing de-padding and cutting processing on the integer part to obtain effective integer binary data, performing digit-level analysis and bit-group mapping processing on the decimal part to generate compressed decimal data, combining integer length information to generate a header description byte and complete data splicing, introducing a symbol mask and a first byte bit flip rule to form a final variable-length storage sequence, and writing the sequence into a storage medium. The present application splits numerical data into an integer part and a decimal part for separate processing, utilizes de-padding and cutting, digit-level compression mapping and a symbol bit uniform encoding mechanism, so that the storage length dynamically changes with the actual numerical effective bit number, thereby reducing the storage overhead caused by invalid padding under the premise of ensuring numerical accuracy and symbol consistency, improving the storage efficiency and space utilization of numerical data in a database system, and maintaining good adaptability to numerical sorting and comparison operations. BRIEF DESCRIPTION OF DRAWINGS

[0011] The present application will be further described below with reference to the accompanying drawings and embodiments, wherein: Figure 1 An application environment diagram of the numerical data variable-length encoding storage method in an embodiment of the present application; Figure 2 A flow diagram of an embodiment of the numerical data variable-length encoding storage method of the present application; Figure 3 A functional module diagram of a preferred embodiment of the numerical data variable-length encoding storage device of the present application; Figure 4 A structure diagram of a computer device in an embodiment of the present application; Figure 5 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation

[0012] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.

[0013] The variable-length encoding and storage method for numerical data provided in this invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. The server can use the client to construct a fixed-length binary representation of the numerical data to be stored, containing an integer part and a fractional part, based on a preset precision. The integer part undergoes truncation and padding to obtain valid integer binary data, while the fractional part undergoes numeric-level parsing and bit-by-bit grouping mapping to generate compressed fractional data. Combined with the integer length information, a header description byte is generated and the data is concatenated. Based on this, a sign mask and a first-byte bit-flipping rule are introduced to form a final variable-length storage sequence, which is then written to the storage medium. This invention splits numerical data into integer and fractional parts for separate processing. Utilizing truncation and padding, numeric-level compression mapping, and a unified sign bit encoding mechanism, the storage length dynamically changes with the actual number of valid digits. This reduces storage overhead caused by invalid padding while maintaining numerical precision and sign consistency, improving storage efficiency and space utilization in the database system, and maintaining good adaptability to numerical sorting and comparison operations. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The present invention will now be described in detail through specific embodiments.

[0014] Please see Figure 2 , Figure 2 This is a flowchart illustrating an embodiment of the variable-length encoding and storage method for numerical data provided by the present invention. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0015] like Figure 2 As shown, the variable-length encoding and storage method for numerical data proposed in this invention includes the following steps: S10, acquire the target numerical data to be stored, and convert the target numerical data into an intermediate fixed-length binary sequence containing an integer part data segment and a fractional part data segment according to a preset defined precision. In this embodiment, the target numerical data to be stored is derived from a data write request or a calculation result, expressed in decimal form, which may contain both integer and decimal parts, and its value range and precision requirement are constrained by external data definition. The definition of precision is used to limit the maximum number of digits allowed for the integer part and the maximum number of digits allowed for the decimal part, which can be derived from field definition, data model constraint or runtime parameter configuration, to ensure that the value has a certain bit width boundary during conversion.

[0016] During processing, the target numerical data is first parsed for symbol and numerical structure, and the numerical representation is split into two logical regions: the integer part and the decimal part. The integer part is used to represent the order of magnitude of the value, and the decimal part is used to represent the fineness of the value. Both have different data organization methods in subsequent processing, so they are clearly distinguished at this stage. During the splitting process, the value is not rounded or precision compressed, but the decimal digit sequence is kept intact to ensure the consistency of the value semantics.

[0017] After splitting, the integer part and the decimal part are respectively aligned according to the defined precision. The purpose of bit alignment is to form a fixed-length data representation, so that subsequent processing can be operated within a known boundary. During the alignment process, the integer part reserves a fixed number of digit positions in the high bit direction, and the decimal part reserves a fixed number of digit positions in the low bit direction. When the actual number of digits is insufficient, the missing positions are filled with zeros to form a fixed-length decimal representation at the digit level.

[0018] After completing the alignment at the decimal level, the digit sequences of the integer part and the decimal part are converted into binary representations respectively. During the conversion process, a predetermined digit grouping rule is used to map multiple decimal digits into several binary bytes, so that each group of digits occupies a certain number of bytes in binary space. After the integer part and the decimal part are converted respectively, they are concatenated in the order of integer part first and decimal part second to form a continuous binary sequence.

[0019] To ensure that the generated result has a stable structure during storage and analysis, necessary zero bytes are added at the beginning and end of the concatenated binary sequence to make the total length of the sequence strictly correspond to the defined precision. Through the above processing, a fixed-length intermediate binary sequence is finally obtained, which contains both integer part data segment and decimal part data segment, and carries the numerical information and precision constraint information of the target value.

[0020] The embodiment completes the structured conversion based on the defined precision before the numerical value enters the storage process, so that the numerical value has a determined boundary and stable internal structure at the binary level, provides a consistent data basis for subsequent processing, avoids the increase in analysis complexity caused by uncertain numerical value length or precision difference, and provides predictable input conditions for subsequent compression and symbol processing.

[0021] S20, parsing the intermediate fixed-length binary sequence to determine the positive and negative polarity attribute, and performing a de-padding and cutting processing on the integer part data segment based on the positive and negative polarity attribute to generate valid integer binary data; In the embodiment, the intermediate fixed-length binary sequence is a unified length data representation formed under the constraint of a given precision, which contains symbol information, an integer part data segment, and padding bytes for alignment. The parsing of the sequence first needs to determine the positive and negative polarity attribute of the numerical value to avoid mistakenly regarding the sign extension bit or the padding bit as part of the valid numerical value in the subsequent integer data extraction process.

[0022] The positive and negative polarity attribute is obtained by reading the sign indication information in the starting byte of the intermediate fixed-length binary sequence. The sign indication information is located in the highest bit of the starting byte, and its value state is one-to-one corresponding to the positive and negative of the numerical value according to a preset sign determination rule. The rule is derived from the unified convention for the sign bit in fixed-length numerical value encoding, and can maintain consistent determination logic under different byte widths and different precision configurations.

[0023] After determining the positive and negative polarity attribute, a corresponding sign mask byte is generated according to the attribute. The bit width of the sign mask byte is consistent with the single-byte width of the integer part data segment, and the bit value is all set to one in the negative value case and all set to zero in the positive value case. The source of the mask is the unified processing method of the sign extension bit in the binary complement and inverse code processing, which is used to restore the true numerical form of the integer part without changing the data structure.

[0024] Subsequently, the integer part data segment is located from the intermediate fixed-length binary sequence. The data segment is a set of continuously arranged bytes, and its length is determined by the defined precision, but it may contain padding bytes introduced to meet the fixed-length requirement. By performing a bitwise logical exclusive OR operation between each byte in the integer part data segment and the sign mask byte, the complement form in the negative value case can be converted into a unified normalized integer byte sequence, while the data in the positive value case remains unchanged.

[0025] After obtaining the normalized integer byte sequence, the sequence is sequentially scanned from the starting position, and the padding bytes with a value of zero are identified and skipped. These padding bytes are introduced to meet the uniform byte width during the fixed-length encoding stage and do not carry actual numerical information. The first non-zero byte encountered during the scanning process is determined as a valid byte, and its position is used to define the starting boundary of the valid data of the integer part.

[0026] Starting from the valid byte, all bytes until the end of the normalized integer byte sequence are continuously extracted to form a byte set containing only actual numerical information. This byte set no longer contains redundant content for alignment or expansion, and constitutes valid integer binary data, providing a basic data source for subsequent variable-length organization.

[0027] The embodiment can strip the redundant bytes introduced by fixed-length encoding and retain only the integer data that actually participates in numerical representation, while maintaining consistent numerical semantics, by explicitly parsing the sign information in the fixed-length binary representation and performing sign attribute-based padding removal and cutting processing on the integer part. This provides an accurate and compact data basis for subsequent variable-length organization.

[0028] S30, parsing the decimal part data segment in the intermediate fixed-length binary sequence to obtain a valid number sequence, and performing bit grouping mapping processing on the valid number sequence to generate valid decimal compressed data; In this embodiment, the decimal part data segment in the intermediate fixed-length binary sequence is a fixed-length encoding result formed under the constraint of a pre-defined definition precision, which contains encoding information corresponding to valid numbers and padding encoding introduced to meet the fixed-length format. The purpose of parsing the decimal part data segment is to recover the set of decimal numbers that actually participate in numerical representation from the fixed-length expression, and further compress the set into a compact storage representation.

[0029] The parsing process first acts on the binary encoding structure of the decimal part data segment, decodes the byte content through the consistent encoding rule in the generation stage, and restores the binary value to a sequential decimal number stream. The decimal number stream represents each decimal digit in the decimal part in character level or numerical level, and the order is consistent with the decimal digit order of the original numerical value. Since zero-value padding related to precision alignment may be introduced at the end during the fixed-length encoding process, the restored number stream may contain redundant zero-value numbers that do not participate in actual numerical representation.

[0030] On this basis, the tail validity of the reduced digital stream is determined, the zero value digits which appear continuously and do not affect the expression of the value of the digits are identified and removed by continuously checking the value of the digits from the end, so as to form a valid digit sequence containing only the actual valid decimal places. The length of the valid digit sequence dynamically changes with the number of decimal places of the value, and is no longer constrained by the maximum number of bits in the preset defined precision.

[0031] For the obtained valid digit sequence, further bit grouping mapping processing is performed. The processing takes decimal digits as the basic unit, and combines two adjacent digits as a mapping unit according to the sequence order, so that the two decimal digits are mapped into one byte. When mapping, the earlier digit in the sequence is written into the high four bits of the byte, and the digit immediately following it is written into the low four bits of the byte, so as to realize compressed storage while keeping the order of the digits unchanged. When the length of the valid digit sequence is odd, the single digit at the end which does not participate in pairing forms a mapping unit alone, and the digit is written into the high four bits of the byte, and the low four bits are filled with zero values to complete byte alignment. All the bytes obtained by mapping are arranged in the order of the original valid digit sequence to form the valid decimal compressed data.

[0032] In this embodiment, by performing fixed-length decoding, valid digit identification and bit grouping mapping processing on the decimal part data segment, the storage length of the decimal part is directly related to the actual number of valid decimal places, avoiding the fixed space occupation caused by the preset precision, significantly compressing the storage size of the decimal part without changing the semantic expression of the value, and keeping the order of the digits and reversibility.

[0033] S40, generating a head description byte recording the length information of the valid integer binary data, and concatenating the head description byte, the valid integer binary data and the valid decimal compressed data in sequence to generate a to-be-labeled variable-length sequence; In this embodiment, after the integer part and the decimal part are respectively processed by variable-length processing, the two parts need to be organized into a continuous byte sequence which can be uniformly parsed and stored. Therefore, a head description byte is introduced to explicitly carry the length information of the valid integer binary data. The length information of the valid integer binary data indicates the number of bytes contained in the valid integer binary data. The length information is derived from the byte sequence obtained by performing de-padding and cutting on the integer part in the previous processing, and the value directly reflects the actual storage size of the integer part in the current value.

[0034] The head description byte is taken as an independent single-byte data unit, and its internal bits are divided into an information carrying area and a control reserved area. Length information is written into a predetermined bit area in the head description byte, so that the boundary position of subsequent valid integer binary data can be determined by parsing the byte without relying on external structures. The writing process does not involve re-encoding of the length value, but directly embeds the integer length value into the corresponding bits according to the bit mapping relationship, so as to reduce the complexity of additional processing.

[0035] After the construction of the head description byte is completed, the head description byte, valid integer binary data and valid decimal compressed data are spliced in a fixed order. This order keeps the head description byte at the starting position of the sequence, so that the length information can be obtained first when parsing, and then the valid integer binary data of the corresponding length is read continuously, and the remaining part naturally corresponds to the valid decimal compressed data. Through this splicing method, a continuous byte sequence with self-description of internal structure is formed, which has the basic conditions for subsequent unified processing and marking in structure.

[0036] The embodiment introduces a head description byte carrying length information before the integer part and the decimal part data, and splices the bytes in a fixed order, so that the generated byte sequence can accurately distinguish the data boundary between the integer part and the decimal part without relying on external metadata, thereby reducing the parsing complexity and reducing the additional structure overhead while keeping the data compact storage.

[0037] S50, generating a full-bit sign mask based on the positive and negative polarity attribute, performing a bitwise logical exclusive or operation on all bytes of the to-be-labeled variable-length sequence using the full-bit sign mask, and performing a flip operation on the highest bit of the first byte after the operation to generate a final variable-length storage sequence; In this embodiment, the positive and negative polarity attribute is derived from the previous parsing result, and is used to indicate the sign state of the target numerical data in the numerical semantics. The attribute does not directly participate in the calculation of the numerical content, but is used as a global control condition to determine the value mode of the subsequent byte-level logical operation. The full-bit sign mask constructed around the attribute is a byte-level control quantity, whose value is all zero or all one in the binary level, and is used to produce consistent effects on each bit in the logical operation.

[0038] The generation of the full-bit sign mask takes the positive and negative polarity attribute as input. When the attribute indicates a negative value, the full-bit sign mask is constructed as a byte with all bits being one. When the attribute indicates a positive value, the full-bit sign mask is constructed as a byte with all bits being zero. The mask does not carry length or position information, and its action range naturally extends to the entire to-be-labeled variable-length sequence through subsequent operations.

[0039] In the byte-level processing stage, each byte in the to-be-labeled variable-length sequence is subjected to a bitwise logical XOR operation with a full-bit symbol mask. This operation realizes the overall inversion of the original byte bit pattern in the negative value scenario and keeps the original bit pattern unchanged in the positive value scenario, thereby realizing the unified mapping of the symbol state. In this way, the numerical content and the symbol information are fused in the same byte stream without introducing additional identification bits or segment structures.

[0040] After completing the logical XOR operation of the full sequence, the obtained result constitutes a preliminary processing sequence. To ensure the consistency of the final byte sequence in the lexicographic order, comparison order, or storage order, the first byte of the preliminary processing sequence needs to be further modified. This modification is realized by performing an inversion operation on the highest bit of the first byte, which logically assumes the role of global sequence direction adjustment. The inversion operation only acts on a single bit and does not affect the values of the remaining bits, thereby introducing stable sorting control on the basis of symbol unified processing.

[0041] The first byte after the inversion of the highest bit of the first byte is recombined with the remaining bytes in the preliminary processing sequence that did not participate in the inversion to form the final variable-length storage sequence. This sequence has completed solidification in terms of byte structure, length information, and symbol semantics and can be directly used in subsequent storage or transmission scenarios.

[0042] The present embodiment performs unified bitwise logical processing on the entire byte sequence based on the positive and negative polarity attributes and introduces a highest bit inversion control in the first byte, which naturally integrates the symbol information into the internal variable-length byte sequence, avoids the space overhead caused by additional symbol fields, and ensures the consistency of the storage sequence in the comparison and sorting behavior under different symbol states, thereby improving the compactness and predictability of the storage structure.

[0043] S60, writing the final variable-length storage sequence into a storage medium.

[0044] In the present embodiment, the final variable-length storage sequence is the result after length encoding, symbol processing, and byte-level rearrangement, and its essence is a byte sequence that can be directly persisted. The processing target of writing this sequence into a storage medium is not to change the sequence content, but to determine the write boundary, write position, and write consistency, so that the byte sequence can be stably stored and maintain complete semantics when read later.

[0045] Before performing the writing, the final variable-length storage sequence needs to be subjected to byte length confirmation first, which is used to define the writing range and avoid out-of-bound writing or data truncation due to unclear length. This length value does not participate in sequence content calculation but is used as a write control parameter to constrain memory buffer allocation and selection of storage medium write units.

[0046] The write operation itself takes byte as the minimum transmission granularity, and writes the final variable-length storage sequence in its logical continuous order to the target storage area. The storage area can be a disk page, a non-volatile storage block or other storage unit with persistent capability. The byte order is not rearranged during the writing process to ensure that the symbol bit information of the first byte and the numerical information of the subsequent bytes remain consistent in physical storage.

[0047] After the writing is completed, a continuous variable-length recording area is formed at the corresponding position in the storage medium, and the start address and length information of the area can support subsequent accurate positioning and reconstruction reading of the numerical value. No additional padding bytes are introduced during the entire process, and the final variable-length storage sequence is not encoded again, thereby avoiding the destruction of the variable-length structure formed by the previous processing.

[0048] The embodiment directly writes the final variable-length storage sequence as a complete byte sequence to the storage medium, avoids the forced occupation of storage space by fixed-length fields, makes the numerical data consistent with its actual effective byte length at the physical storage level, and thus reduces storage redundancy. At the same time, the writing method maintains the consistency of the byte order and the semantic structure, and provides a stable foundation for subsequent fast positioning and analysis.

[0049] In one embodiment, the above step S10 includes: S101, obtaining target numerical data to be stored, and parsing a predefined definition precision to determine the total number of decimal digits allowed to be stored in the integer part and the decimal part of the target numerical data; S102, dividing the numerical sequence of the integer part and the numerical sequence of the decimal part of the target numerical data into a plurality of complete numerical groups according to each nine decimal digits as a group, and a remaining numerical group when the number of numerical digits cannot be divided by nine; S103, converting each complete numerical group into four bytes of binary code; S104, converting each remaining numerical group into binary code of corresponding byte length according to the number of digits contained in the remaining numerical group, wherein a remaining numerical group containing one to two digits is converted into one byte, a remaining numerical group containing three to four digits is converted into two bytes, a remaining numerical group containing five to six digits is converted into three bytes, and a remaining numerical group containing seven to nine digits is converted into four bytes; S105, splicing all converted binary codes in the order of the integer part first and the decimal part second, and filling zero value bytes in the vacancy at the beginning and the vacancy at the end of the spliced sequence to generate an original binary sequence; S106, detecting the positive or negative polarity attribute of the target numerical data, if negative, generating a full-one sign mask and performing bitwise logical XOR operation with the original binary sequence to generate an intermediate fixed-length binary sequence.

[0050] In the embodiment, obtaining the target numerical data to be stored is to obtain a numerical representation with an integer part and a decimal part from an upper-layer data write interface, a memory buffer, or a calculation result register. The numerical representation can be in the form of a string, an array of decimal digits, or a fixed-point object, as long as it can be split into an integer part digit sequence and a decimal part digit sequence. A predefined definition precision is used to constrain the total number of decimal digits allowed to be stored in the integer part and the decimal part, respectively. The source of the definition precision can be a database field definition, a type description of a calculation engine, or a precision parameter in an application-layer write protocol. The process of analyzing the definition precision involves two types of information: the total number of decimal digits allowed to be stored in the integer part, which is used to define the left padding boundary of the integer part digit sequence, and the total number of decimal digits allowed to be stored in the decimal part, which is used to define the right padding boundary of the decimal part digit sequence. After the analysis is completed, the target numerical data is normalized into two digit sequences: the integer part digit sequence arranged from high to low, and the decimal part digit sequence arranged from the first digit after the decimal point to the last digit. Missing digits are padded with zero values to match the allowed number of digits, thereby establishing a stable input for subsequent fixed-length mapping.

[0051] According to the division rule of every nine decimal digits as a group, the decimal digit sequence is mapped to a grouping structure with decimal as the core. The selection of nine-bit grouping makes the single group numerical range fall between 0 and 999,999,999, facilitating the establishment of a one-to-one correspondence with four-byte binary encoding and forming a compact integer representation on the binary side. The integer part digit sequence and the decimal part digit sequence perform the same grouping action, obtaining several complete digit groups and remaining digit groups. The complete digit group represents a grouping that contains exactly nine decimal digits, and the remaining digit group represents a tail-end grouping that has fewer than nine digits but still needs to be encoded. The existence position of the remaining digit group is near the low end in the integer part and near the end in the decimal part, to maintain the restorability of the numerical bit sequence within and between groups.

[0052] When converting each complete number group into four-byte binary code, the conversion object is the decimal value corresponding to the complete number group, and the conversion result is a four-byte sequence. The byte sequence of the four-byte sequence can be selected as high byte first or low byte first according to system convention, as long as it is consistent on both sides of reading and writing. The conversion action is essentially transforming the grouped value in the decimal base to binary representation, and the output is limited to fixed four bytes, so that the complete number group has a stable length boundary on the binary side, facilitating subsequent splicing into a fixed-length layout. For the remaining number group, according to the number of digits contained in the remaining number group, convert it into binary code of corresponding byte length to express the number of valid value bits without introducing invalid high bytes. One to two digits are mapped to one byte to cover the range of 0 to 99, three to four digits are mapped to two bytes to cover the range of 0 to 9999, five to six digits are mapped to three bytes to cover the range of 0 to 999999, and seven to nine digits are mapped to four bytes to cover the range of 0 to 999,999,999. This mapping binds the decimal digit number and the binary byte number, reducing the redundancy of the remaining number group on the binary side.

[0053] The converted binary codes are spliced in the order of integer part first and decimal part second to generate the original binary sequence. The purpose is to form a single-channel continuous byte sequence. The internal boundary of the continuous byte sequence is determined by the grouping rule, and the connection point of the integer part and the decimal part is determined by the defined precision, so that the subsequent processing can locate the integer part data segment and the decimal part data segment through fixed offset or length rule. The starting end vacancy and the ending end vacancy of the spliced sequence are filled with zero value bytes to unify different length inputs to a preset fixed length layout. The starting end vacancy usually corresponds to the leading vacancy generated when the integer part is insufficient in the high side, and the ending end vacancy usually corresponds to the tail vacancy generated when the decimal part is insufficient in the last side or the remaining number group is not full byte boundary. The zero value byte filling makes the original binary sequence meet the fixed length requirement in structure, while retaining the locatable integer part data segment and decimal part data segment.

[0054] The positive and negative polarity attribute of the target numerical data is detected, and an intermediate fixed-length binary sequence is generated to embed the sign information into the fixed-length representation according to a unified bit level rule. The source of the positive and negative polarity attribute can be the sign bit of the input numerical value, the string prefix, or the sign flag of the upper-layer type object, and the detection result only distinguishes between the positive polarity and the negative polarity. If it is negative, a full-one sign mask is generated and a bitwise logical XOR operation is performed on the original binary sequence. The bitwise logical XOR operation performs the same rule transformation on each bit of the original binary sequence, so that all bytes complete the bit level inversion at the same time, thereby mapping the negative value to a fixed-length binary representation that is distinguished from the positive value, while maintaining reversibility, because the same sign mask XOR again can restore the original binary sequence. If it is positive, the original binary sequence is determined as the intermediate fixed-length binary sequence, avoiding introducing additional bit transformation to the positive value, so that the positive value path remains a direct correspondence on the fixed-length representation. Through this sign processing, the intermediate fixed-length binary sequence is constrained in length by the defined precision, in sign by the positive and negative polarity attribute, and in content by the integer part data segment and the decimal part data segment, and can be stably parsed by the subsequent process.

[0055] The embodiment converts different numerical scales and different decimal bit representations into an intermediate fixed-length binary sequence with structure that can be positioned and sign that can be reversed, by defining decimal bit analysis under precision constraints, nine-bit grouping and variable-length byte mapping, continuous splicing of the integer part in front and the decimal part in back, zero-byte padding at the start and end, and bitwise logical XOR operation of the sign mask based on the positive and negative polarity attribute, reducing the positioning and conversion branches caused by inconsistent input forms, so that the subsequent processing can stably extract the integer part data segment and the decimal part data segment on the fixed structure boundary, and provide a consistent data entry for further length compression and sequence organization.

[0056] In one embodiment, the above step S20 comprises: S201, from the start byte of the intermediate fixed-length binary sequence, parse the sign indication information, determine the positive and negative polarity attribute based on the sign indication information, the sign indication information is the highest bit of the start byte, and the highest bit represents the positive and negative polarity attribute according to a predetermined sign determination rule; S202, generate a sign mask byte based on the positive and negative polarity attribute, wherein when the positive and negative polarity attribute is negative, the sign mask byte is a full-one byte, and when the positive and negative polarity attribute is positive, the sign mask byte is a full-zero byte; S203, locate the continuous byte segment representing the integer part data from the intermediate fixed-length binary sequence; S204, perform a bitwise logical XOR operation on each byte in the continuous byte segment and the sign mask byte to obtain a normalized integer byte sequence; S205, sequentially scanning from the start position of the normalized integer binary sequence, skipping the padding bytes with a value of zero, and locating to the first valid byte with a value not equal to zero; S206, continuously extracting all bytes from the start position of the valid byte to the end of the normalized integer binary sequence based on the extracted byte sequence to form the valid integer binary data.

[0057] In this embodiment, when extracting the sign indication information from the start byte of the intermediate fixed-length binary sequence, the highest bit of the start byte is taken as the sign indication information, and the highest bit is mapped to the positive and negative polarity attribute according to the preset sign determination rule. The preset sign determination rule is used to define the correspondence between the highest bit and the positive and negative polarity attribute, so that the subsequent processing can obtain the positive and negative polarity attribute based on the highest bit only without expanding the meaning of the remaining bits inside the byte, thereby providing a definite input for the value of the sign mask byte.

[0058] When generating the sign mask byte based on the positive and negative polarity attribute, the sign mask byte is a full one byte when the positive and negative polarity attribute is negative, and the sign mask byte is a full zero byte when the positive and negative polarity attribute is positive. The sign mask byte adopts a single-byte full-bit consistent form, which is convenient for performing byte-by-byte bitwise logical exclusive OR operation on the integer part data segment, so that the exclusive OR operation can directly reuse the byte stream processing instruction or batch processing interface in the implementation level, and the processing rule of each byte remains consistent, avoiding introducing different branch paths for different bytes.

[0059] When locating the integer part data segment from the intermediate fixed-length binary sequence, the fixed-length layout information corresponding to the defined precision is used to determine the continuous byte segment boundary of the integer part data segment in the intermediate fixed-length binary sequence, and a continuous byte segment representing the integer part data is obtained. The positioning result of the continuous byte segment is taken as the input boundary of the subsequent normalization processing, so that the normalized integer binary sequence only covers the integer part data segment, avoiding introducing the decimal part data segment or the non-integer load of the start byte into the normalized integer binary sequence, and further avoiding that the valid integer binary data contains bytes with non-integer semantics.

[0060] When performing bitwise logical exclusive OR operation on each byte in the continuous byte segment and the sign mask byte, the normalized integer binary sequence is generated byte by byte. When the positive and negative polarity attribute is positive, the sign mask byte is a full zero byte, and the exclusive OR operation keeps the byte value unchanged, so the normalized integer binary sequence is consistent with the continuous byte segment. When the positive and negative polarity attribute is negative, the sign mask byte is a full one byte, and the exclusive OR operation performs full-bit inversion on each byte. The normalized integer binary sequence is used to eliminate the global bit inversion effect caused by negative value coding, so that the subsequent de-padding and interception processing faces the byte sequence under the same semantic caliber, thereby making the de-padding and interception processing not change the determination condition due to the difference between the positive and negative polarity attributes.

[0061] When sequentially scanning from the start position of the normalized integer binary sequence, padding bytes are identified and skipped with a granularity of one byte until the first valid byte with a value other than zero is located. The padding bytes here are used to meet the fixed-length layout requirement of the intermediate fixed-length binary sequence, and their value of zero distinguishes them from valid bytes. The process of sequential scanning takes the first non-zero byte as the starting point of the valid byte, thereby obtaining the start position of the truncated and de-padding processing. For the case where the normalized integer binary sequence is entirely composed of zeros, if the sequential scanning fails to locate a valid byte, the valid integer binary data can be determined as a byte sequence with a length of zero or a byte sequence containing a single zero-value byte, and the specific form is determined by the subsequent length coding convention of the header description byte, so that the integer zero remains consistent in the variable-length expression.

[0062] When continuously extracting from the valid byte to the end of the normalized integer binary sequence, the extracted byte sequence directly constitutes the valid integer binary data. Continuous extraction ensures that the valid integer binary data remains in byte order and that the valid integer binary data only contains all the valid payload bytes from the valid byte to the end. After removing the leading padding bytes, the valid integer binary data corresponds to the true byte length of the integer part, facilitating subsequent splicing and analysis using length information, so that the valid integer binary data exhibits variable-length characteristics that change with the number of valid bytes under different numerical scales.

[0063] The present embodiment determines the positive and negative polarity attributes by the highest bit of the start byte and generates a sign mask byte, performs bitwise logical XOR operation on the integer part data segment to obtain the normalized integer binary sequence, and then skips the padding bytes with a value of zero based on the normalized integer binary sequence and continuously extracts from the first valid byte to form the valid integer binary data. This makes the integer part still adopt the same de-padding and truncation rule under different positive and negative polarity attributes, and removes the leading padding bytes from the integer payload, thereby reducing the redundant byte occupation of the integer part and providing stable input for subsequent variable-length splicing based on length information.

[0064] In one embodiment, the above step S30 includes: S301, decoding the fractional part data segment in the intermediate fixed-length binary sequence to restore the binary encoding of the fractional part data segment to an original number stream composed of decimal numbers; S302, detecting whether there is a continuous zero-value number at the end of the original number stream, and if so, removing the continuous zero-value numbers at the end of the original number stream to obtain an effective number sequence by truncation; S303, grouping the numbers in the valid number sequence two by two in order from front to back to form a plurality of number pairs, and if there is a remaining number that cannot be paired, regarding the remaining number as a single group; S304, encoding each of the number pairs as a complete data byte, wherein the first number of the number pair occupies the high four bits of the complete data byte, and the second number occupies the low four bits of the complete data byte; S305, if there is the single group, encoding the number in the single group into the high four bits of a partial padding byte, and setting the low four bits of the partial padding byte to zero; S306, splicing all the generated complete data bytes and partial padding bytes in the order of the numbers in the valid number sequence to generate valid decimal compression data.

[0065] In the embodiment, the decimal part data segment in the intermediate fixed-length binary sequence carries decimal part numerical information obtained under a preset defined precision constraint, and its external form is a byte sequence, and its internal semantics corresponds to the arrangement of numbers on the decimal fraction bit. The processing of decoding the decimal part data segment is essentially to restore the byte-level representation to a decimal number sequence according to the encoding rule of the decimal part data segment, so that the subsequent compression can be performed in the granularity of decimal numbers. When decoding, the byte boundary of the decimal part data segment is read, and the reverse conversion is performed for each encoding unit to output an original number stream composed of decimal numbers. The original number stream maintains the arrangement relationship consistent with the order of decimal bits, so that the order of numbers in the original number stream can directly correspond to the bit weight order of the decimal part from high to low.

[0066] The zero-value number at the end of the original number stream corresponds to the decimal bit padding or invalid placeholder bit at the end of the decimal part for alignment under the preset defined precision. This part of the number does not change the actual effective bit expression of the decimal part in the numerical sense, but significantly increases the number of subsequent encoding bytes. The processing of detecting whether there is a continuous zero-value number at the end of the original number stream is performed in a traversal direction from the end to the front, and whether the adjacent end numbers are zero-value numbers is continuously determined. Once a non-zero-value number is encountered, the traversal is stopped. The continuous zero-value numbers at the end of the original number stream are removed to obtain an effective number sequence, so that the effective number sequence only contains the actual effective decimal numbers of the decimal part, and the number of bytes generated by the subsequent bit grouping mapping processing is reduced from the source. If the original number stream is all zero-value numbers, the effective number sequence is an empty sequence. At this time, the valid decimal compression data can be empty or represented as zero length, so as to match the variable-length expression.

[0067] Before performing the bit grouping mapping processing on the valid number sequence, the numbers in the valid number sequence need to be grouped two by two in the order from front to back. The boundary of two-by-two grouping directly determines the relationship between the two decimal digits carried by each byte, so the grouping must keep the original order of the valid number sequence from being disturbed. After grouping, a number of number pairs are formed, each containing two adjacent decimal digits; when the length of the valid number sequence is odd, there is a remaining number that cannot be paired, which is kept as a separate group to keep the number sequence complete and not lose the last valid digit.

[0068] The processing of encoding each number pair as a complete data byte corresponds to the half-byte mapping method of BCD (Binary-Coded Decimal). A complete data byte is composed of high four bits and low four bits, the high four bits carry the first digit of the number pair, and the low four bits carry the second digit of the number pair. When mapping, first perform validity check on each decimal digit to make it fall within the value domain of 0 to 9, then convert the digit to four-bit representation and write it to the corresponding half-byte position, so that a complete data byte stably carries two decimal digits and maintains bit sequence consistency. This mapping method makes each decimal digit occupy a fixed four-bit space, avoiding the risk of decimal precision deviation caused by binary decimal approximation, and enabling the decoding end to recover the number pair according to a fixed rule.

[0069] When there is a separate group, the digit in the separate group is encoded into the high four bits of a partially filled byte, and the low four bits of the partially filled byte are set to zero, used to complete the alignment on the byte boundary and keep the last valid digit in the bit sequence position of the high four bits. The padding of the low four bits set to zero does not represent the addition of a valid decimal place, but a placeholder in the byte to make the encoding end and the decoding end have consistent processing rules for the separate group, so that the decoding end can identify that the byte contains only one valid digit and ignore the padding value of the low four bits when recovering the valid number sequence. This arrangement also keeps the order of the digits in the valid number sequence directly recoverable in the reading direction from high to low in the byte string, avoiding the risk of bit sequence misalignment caused by the last digit falling into the low four bits.

[0070] All the generated complete data bytes and partially filled bytes are spliced according to the order of the digits in the valid number sequence to obtain the valid decimal compressed data. When splicing, the bytes are appended in the order of the number pairs, and if there is a partially filled byte, it is appended at the end, so that the valid decimal compressed data corresponds to the order mapping relationship of the valid number sequence in the number sequence. This splicing result is used as the decimal side load input when constructing the subsequent variable-length sequence to be marked, which can independently realize the variable-length compression expression of the decimal part without changing the processing path of the integer part.

[0071] The embodiment decodes the decimal part data segment to obtain the original digital stream, removes the continuous zero value numbers at the end of the original digital stream to form the valid number sequence, groups the valid number sequence two by two, generates a complete data byte and a partial padding byte by mapping the high four bits and the low four bits, and splices the valid decimal compressed data in the number order. The decimal part is compressed to a half-byte level and the tail invalid placeholder is removed, the number of bytes of the valid decimal compressed data is reduced, the number order of the valid number sequence is reversible, the decimal part is written into the subsequent variable length sequence, and the storage compactness and the consistency of the decimal numerical expression are considered.

[0072] In one embodiment, the above step S40 comprises: S401, calculating the number of bytes contained in the valid integer binary data to obtain an integer length value; S402, generating a header description byte, setting the integer length value in a predetermined bit area of the header description byte, and the predetermined bit area being a bit area of the header description byte except the highest bit; S403, splicing the header description byte, the valid integer binary data and the valid decimal compressed data in sequence according to the arrangement order of the header description byte in front, the valid integer binary data in the middle and the valid decimal compressed data behind; S404, taking the complete data sequence formed after splicing as the variable length sequence to be marked.

[0073] In the embodiment, the valid integer binary data length information is used to describe the actual length of the valid integer binary data occupied at the byte level, and is derived from the output result after the de-padding and interception processing of the integer part data segment. The integer length value refers to the number of bytes contained in the valid integer binary data, and the calculation is based on the byte sequence length of the valid integer binary data. The calculation object is the valid integer binary data itself rather than the integer part data segment of the intermediate fixed length binary sequence, so that the length information is one-to-one corresponding to the byte boundary of the subsequent splicing. When implemented, the valid integer binary data can be read as a byte array or a continuous memory area to obtain the integer length value. Range check can be performed before writing to adapt to the bit width expression ability of the header description byte. For example, when the predetermined bit area is a bit area except the highest bit, the integer length value and the expressible range of the predetermined bit area establish a consistent constraint relationship, avoiding the analysis ambiguity caused by length value truncation.

[0074] The head description byte is used to carry valid integer binary data length information in a single byte, forming a self-describing entry of the to-be-labeled variable-length sequence. The predetermined bit region is the bit region of the head description byte except the highest bit, and the predetermined bit region corresponds to a continuous or addressable bit set for writing an integer length value; the highest bit is reserved as an independent bit region, so that the length information is written without bit field conflict with the highest bit. The implementation of setting the integer length value in the predetermined bit region can be completed by using a combination of bit masking and shifting, that is, the head description byte is cleared at the position corresponding to the predetermined bit region, and then the integer length value is written in alignment according to the starting bit offset of the predetermined bit region, so as to ensure that the bit distribution of the head description byte in the predetermined bit region is consistent with the binary representation of the integer length value. If the number of binary bits of the integer length value is less than the number of bits of the predetermined bit region, the high bits are padded with zeros, so as to maintain the reversible analysis under the same bit field rule.

[0075] The head description byte, the valid integer binary data, and the valid decimal compressed data are sequentially spliced to form a continuous complete data sequence in the byte sequence. The arrangement order is that the head description byte is in the front, the valid integer binary data is in the middle, and the valid decimal compressed data is in the back, so that the head description byte is located at the starting position of the to-be-labeled variable-length sequence, and the length information of the valid integer binary data can be obtained by reading the first byte at the analysis end, and then the integer length value is used to locate the boundary of the valid integer binary data from the subsequent byte stream, and the remaining byte segment is determined as the byte segment corresponding to the valid decimal compressed data. In the implementation, the total number of bytes of the complete data sequence can be calculated according to the integer length value and the byte length of the valid decimal compressed data, a continuous buffer area is allocated, the head description byte is written in the position with an offset of zero, the valid integer binary data is copied byte by byte to the position with an offset of one, and the valid decimal compressed data is copied byte by byte to the position with an offset of one plus the integer length value. The copying process maintains the byte sequence unchanged, so that the complete data sequence is strictly consistent with the splicing rule. The complete data sequence formed after splicing is defined as the to-be-labeled variable-length sequence.

[0076] In the embodiment, the integer length value of the valid integer binary data is calculated and written in the predetermined bit region of the head description byte, so that the to-be-labeled variable-length sequence carries the length information of the valid integer binary data in the first byte, and the analysis end can complete boundary positioning without traversing the valid integer binary data; and the head description byte, the valid integer binary data, and the valid decimal compressed data are sequentially spliced to form a continuous complete data sequence, so that the valid payloads of the integer and the decimal are stored in the form of a compact byte stream, thereby reducing the redundant occupation caused by fixed length reservation and reducing the calculation overhead of integer boundary identification.

[0077] In one embodiment, the above step S50 includes: S501, generating a full-bit sign mask according to the positive-negative polarity attribute, wherein when the positive-negative polarity attribute indicates a negative value, the full-bit sign mask is set as a byte with binary values all being one, and when the positive-negative polarity attribute indicates a positive value, the full-bit sign mask is set as a byte with binary values all being zero; S502, performing bitwise logical exclusive OR operation on each byte in the to-be-labeled variable-length sequence and the full-bit sign mask respectively to obtain a preliminary processing sequence; S503, obtaining a first byte of the preliminary processing sequence, performing a flip operation on the highest bit of the first byte to generate a modified first byte; S504, combining the modified first byte and the remaining bytes of the preliminary processing sequence except the first byte to generate a final variable-length storage sequence.

[0078] In the embodiment, the positive-negative polarity attribute is used to indicate the sign orientation of the target numerical data, and the value thereof is derived from the sign information analysis result of the intermediate fixed-length binary sequence. The full-bit sign mask is used to convert the sign orientation into a control quantity that can directly participate in byte-level logical operation. The full-bit is embodied as each bit of the mask taking the same polarity in a byte, and the specific byte value of the mask corresponds to the positive-negative polarity attribute one by one. When the positive-negative polarity attribute indicates a negative value, the full-bit sign mask is set as a byte with binary values all being one, and when the positive-negative polarity attribute indicates a positive value, the full-bit sign mask is set as a byte with binary values all being zero. To avoid introducing an extra field conflicting with the variable length target, the full-bit sign mask is not written into the to-be-labeled variable-length sequence alone, but participates in the sign processing of the to-be-labeled variable-length sequence as an input of bitwise logical exclusive OR operation.

[0079] The to-be-labeled variable-length sequence is formed by sequentially splicing a header description byte, valid integer binary data, and valid decimal compressed data, and the byte sequence remains unchanged after splicing. When performing bitwise logical exclusive OR operation on all bytes of the to-be-labeled variable-length sequence, each byte in the to-be-labeled variable-length sequence is traversed as a processing unit, and the byte is logically XORed with the full-bit sign mask bit by bit. The result byte of the XOR operation has the same byte position as the input byte, so that a preliminary processing sequence equal in length to the to-be-labeled variable-length sequence is obtained. The preliminary processing sequence is used to undertake subsequent flip operations. The preliminary processing sequence and the to-be-labeled variable-length sequence remain consistent in the number of bytes and the byte sequence, and only the bit value changes under the control of the full-bit sign mask. When the full-bit sign mask is a full-zero byte, the preliminary processing sequence is byte by byte identical to the to-be-labeled variable-length sequence. When the full-bit sign mask is a full-one byte, the preliminary processing sequence is byte by byte identical to the result of the to-be-labeled variable-length sequence after taking the inverse of each bit.

[0080] The flipping operation is performed on the highest bit of the first byte after the operation. The first byte refers to the first byte in the preliminary processing sequence, which corresponds to the head description byte in the variable-length sequence to be marked, so the flipping operation occurs at the head position where the length information is located, which is conducive to embedding additional distinguishing information related to the symbol without increasing the length of the sequence. The highest bit refers to the bit with the highest weight in the first byte, and the flipping operation is implemented by performing bit value inversion on this bit. For example, a byte with only the highest bit as one is used to perform bitwise logical XOR on the first byte, thereby obtaining the modified first byte. When the modified first byte is combined with the remaining bytes in the preliminary processing sequence except the first byte, the combination maintains the original order of the bytes, i.e., the modified first byte is placed at the starting position of the sequence, and the corresponding remaining bytes in the preliminary processing sequence are sequentially appended. The result of the combination is the final variable-length storage sequence. Since the final variable-length storage sequence maintains the same length as the variable-length sequence to be marked, the symbol embedding process does not introduce additional bytes. At the same time, the preliminary processing sequence and the modified first byte together form a reversible processing link, which facilitates subsequent reverse restoration according to the same rule.

[0081] In this embodiment, the full-bit symbol mask is generated by driving the positive and negative polarity attributes, and bitwise logical XOR operation is performed on all bytes of the variable-length sequence to be marked. Then, the flipping operation is performed on the highest bit of the first byte after the operation. The symbol information is integrated into the existing byte structure of the final variable-length storage sequence, without the need to add a symbol field or expand the sequence length, thereby completing the symbol processing while maintaining the byte length unchanged. At the same time, the preliminary processing sequence and the modified first byte form a clear bit-level processing relationship, so that the final variable-length storage sequence can still be generated and parsed according to a unified rule under different positive and negative orientations, reducing the coupling complexity between symbol processing and variable-length splicing.

[0082] In one embodiment, the above step S60 includes: S601, calculating the byte length of the final variable-length storage sequence to obtain a sequence length value; S602, verifying whether the sequence length value is less than or equal to a preset maximum allowed length; S603, if the sequence length value is less than or equal to the preset maximum allowed length, recording the sequence length value in a variable-length field length list of a target data row containing the final variable-length storage sequence, and updating the variable-length field count of the target data row; S604, allocating storage space for the target data row in the memory, the size of the storage space being determined based on the sum of the sequence length values of all variable-length fields in the target data row and the fixed size of the fixed-length field; S605, write the final variable-length storage sequence as the value of the corresponding data column into the allocated storage space at the offset address designated for the data column; S606, write the complete target data row containing the final variable-length storage sequence from the memory into the corresponding database page area in the storage medium.

[0083] In the embodiment, before the final variable-length storage sequence is written into the storage medium, the final variable-length storage sequence is subjected to byte-level metering to obtain a sequence length value, the metering object is limited to all the bytes contained in the final variable-length storage sequence, and the metering manner can adopt traversal accumulation or direct reading of the length field of the buffer to avoid length deviation caused by coding unit difference. Subsequently, length constraint verification is performed, the verification target is the size relationship between the sequence length value and a preset maximum allowed length, the maximum allowed length is used to limit the upper limit space that can be occupied by the variable-length field and matches the expressible range of the storage page structure, the in-row offset field width or the row record format; when the verification does not satisfy, an error processing procedure is triggered, the error processing procedure can include terminating the current writing, recycling the allocated row buffer, recording an exception code or returning a writing failure state, so as to block the super-long sequence from entering the subsequent persistent link. After the verification satisfies, the sequence length value is written into the variable-length field length list of the target data row and the variable-length field count of the target data row is synchronously updated, the variable-length field length list is used to save the length information of each variable-length field in the target data row, and the variable-length field count is used to identify the number of variable-length fields contained in the target data row, both of which together provide the in-row metadata basis for subsequent sequential parsing and offset positioning. Then, storage space is allocated in the memory for the target data row, the size of the storage space is determined by the sum of the sequence length values of all the variable-length fields in the target data row and the fixed size of the fixed-length field, wherein the fixed size of the fixed-length field corresponds to the byte set occupied by the fixed-length column in the target data row, and the sum of the sequence length values of all the variable-length fields corresponds to the total occupation of the variable-length area in the target data row; after the allocation is completed, the offset address of the data column in the target data row is determined, the offset address can be calculated from the starting address of the fixed-length area, the total length of the fixed-length area and the relative order of the data column in the variable-length field length list, so that the final variable-length storage sequence is written into the storage space at the offset address designated for the data column in a byte copy manner, and the byte order of the final variable-length storage sequence is kept unchanged during the writing to maintain the consistency of subsequent reading. Finally, the complete target data row containing the final variable-length storage sequence is written from the memory into the corresponding database page area in the storage medium, the database page area is used to carry the persistent layout of the target data row and forms a positioning relationship with the page number, the slot or the row offset table; the writing action can include serializing the target data row into the in-page record format, marking the page buffer as a dirty page and triggering the disk flushing, so that the final variable-length storage sequence enters the database page area in the storage medium along with the complete target data row, and the persistent landing on the disk is realized.

[0084] decimal(19, 9) is taken as an example, the precision is defined as decimal(19, 9), the total number of decimal digits allowed to be stored in the integer part is 10, and the total number of decimal digits allowed to be stored in the decimal part is 9. The target numerical data is split to obtain the integer part digit sequence 123 and the decimal part digit sequence 875. According to every nine decimal digits as a group, the integer part digit sequence is divided into one remaining digit group and one complete digit group according to 10-bit capacity, wherein the remaining digit group corresponds to the high-bit group, and one bit of the high-bit group is filled with zero to form the remaining digit group 0 because the actual integer bit number is insufficient; the complete digit group corresponds to the low-bit nine bits, and 000000123 is taken. The decimal part digit sequence forms a complete digit group according to 9-bit capacity, and 875 needs to be expanded to 875000000 to make up nine bits because the scale is 9. The complete digit group is converted into four bytes of binary code, the remaining digit group is converted into binary code of corresponding byte length according to the number of digits, and then the integer part 0 is encoded into 1 byte, 000000123 is encoded into 4 bytes, and 875000000 is encoded into 4 bytes. The integer part is in front and the decimal part is in back, and zero value bytes are filled in the starting end vacancy and the ending end vacancy to form the original binary sequence, and the length of the original binary sequence is 9 bytes. Then the positive and negative polarity attribute is detected as negative polarity, a full-one sign mask is generated and a bitwise logical exclusive or operation is performed with the original binary sequence to obtain an intermediate fixed-length binary sequence. At this time, the highest bit of the starting byte is 1 after the exclusive or operation, and the highest bit of the starting byte represents the negative polarity according to the preset sign determination rule, thereby providing a source of sign indication information for subsequent analysis.

[0085] The intermediate fixed-length binary sequence is analyzed, the sign indication information is extracted from the starting byte, the sign indication information takes the highest bit of the starting byte, and the positive and negative polarity attribute is determined as negative according to the preset sign determination rule. The sign mask byte is generated based on the positive and negative polarity attribute, and the negative polarity corresponds to the full-one byte. Then, the continuous byte segment representing the integer part data in the intermediate fixed-length binary sequence is located, and the continuous byte segment corresponds to the integer part data segment of the first 5 bytes. Each byte of the integer part data segment is subjected to a bitwise logical exclusive or operation with the sign mask byte to obtain a normalized integer byte sequence, so that the normalized integer byte sequence and the numerical value size establish a direct interceptable corresponding relationship. Then, the starting position of the normalized integer byte sequence is sequentially scanned, and the zero value filling bytes are skipped until the first non-zero value effective byte is located. For this example, the normalized integer byte sequence has continuous zero value filling in the high-bit group, and the non-zero byte corresponding to 123 appears at the end of the low-bit group, so the effective byte is located at the byte position carrying 123. From the effective byte, continuous extraction is performed to the end of the normalized integer byte sequence to form the effective integer binary data, so that the effective integer binary data only retains the necessary bytes of the numerical value to support subsequent variable-length splicing.

[0086] On the decimal processing side, the decimal part data segment of the intermediate fixed-length binary sequence is decoded to restore the original number stream composed of decimal numbers. Since the definition precision is decimal (19, 9), the original number stream corresponds to a nine-digit decimal field, which is 875000000 in this example. After decoding the decimal part data segment to obtain the original number stream, tail zero detection and removal processing are performed based on the original number stream to obtain the valid number sequence used for subsequent bit grouping mapping processing. It is detected whether there are consecutive zero-value numbers at the end of the original number stream, and if so, the consecutive zero-value numbers at the end of the original number stream are removed to obtain the valid number sequence 875. The valid number sequence is grouped into pairs from front to back, obtaining the number pair 8 and 7, and the remaining number 5 which cannot be paired as a separate group. The number pair is encoded as a complete data byte, with the high four bits written as 8 and the low four bits written as 7, obtaining a complete data byte 0x87; the separate group is encoded into the high four bits of a partially filled byte, with the high four bits written as 5 and the low four bits set to 0, obtaining a partially filled byte 0x50. The complete data byte and the partially filled byte are spliced in numerical order to obtain the valid decimal compressed data as 0x87, 0x50. Here, the grouping mapping result of the valid number sequence 875 is given as the valid decimal compressed data byte value, and the mapping link remains the two-by-two grouping and high-low four-bit writing rule.

[0087] Subsequently, a header description byte recording the length information of the valid integer binary data is generated. The number of bytes contained in the valid integer binary data is calculated to obtain the integer length value, which is 1 in this example. A header description byte is generated, and the integer length value is set in the predetermined bit area of the header description byte. The predetermined bit area is the bit area of the header description byte except the highest bit, so the header description byte before global symbol processing is represented as binary 00000001 in this example. Then, the header description byte is spliced in front, the valid integer binary data is in the middle, and the valid decimal compressed data is spliced in the back to form a complete data sequence and determine it as a variable-length sequence to be marked. The byte sequence of the variable-length sequence to be marked in this example is 0x01, 0x7B, 0x87, 0x50, where 0x7B is the byte representation of 123. The header description byte carries the integer length value at this stage, and the symbol-related processing is completed in the global symbol processing process performed on the variable-length sequence to be marked, thereby forming a continuous link with the subsequent bit logical XOR operation and highest bit flip operation.

[0088] The all-bit symbol mask is generated based on the positive and negative polarity attributes, and the negative value corresponds to a byte of binary value all being 1, i.e., 0xFF. Each byte in the to-be-labeled variable-length sequence is subjected to a bitwise logical exclusive OR operation with the all-bit symbol mask to obtain a preliminary processing sequence. In this example, the preliminary processing sequence is obtained by 0x01^0xFF, 0xFE, 0x7B^0xFF, 0x84, 0x87^0xFF, 0x78, and 0x50^0xFF, 0xAF, and thus the preliminary processing sequence is 0xFE, 0x84, 0x78, and 0xAF. The first byte 0xFE of the preliminary processing sequence is obtained, and a flip operation is performed on the highest bit of the first byte, which is equivalent to performing a bitwise logical exclusive OR operation on the first byte and 0x80 to obtain the modified first byte 0x7E. The modified first byte is combined with the remaining bytes of the preliminary processing sequence except the first byte to generate a final variable-length storage sequence. In this example, the final variable-length storage sequence is 0x7E, 0x84, 0x78, and 0xAF, which correspond to binary values of 01111110, 10000100, 01111000, and 10101111, respectively. The modified first byte 01111110 is obtained by performing a bitwise logical exclusive OR operation on all the bytes of the to-be-labeled variable-length sequence and then performing a flip operation on the highest bit of the first byte, and thus the symbol-related bit is not introduced in the head description byte generation stage, thereby being consistent with the claim link.

[0089] When the final variable-length storage sequence is written into the storage medium, the byte length of the final variable-length storage sequence is calculated to obtain a sequence length value, and in this example, the sequence length value is 4. It is verified whether the sequence length value is less than or equal to a preset maximum allowed length, and after the verification is passed, the sequence length value is recorded in the variable-length field length list of the target data row containing the final variable-length storage sequence, and the variable-length field count of the target data row is updated, so that the target data row can determine the variable-length field boundary according to the variable-length field length list. Subsequently, a storage space is allocated in the memory for the target data row, and the size of the storage space is determined based on the sum of the sequence length values of all the variable-length fields in the target data row and the fixed size of the fixed-length field, so that the target data row forms a continuous carrier. The final variable-length storage sequence is written into the storage space at the offset address specified for the data column, so that the variable-length content of the data column has a determined landing point in the target data row. Finally, the complete target data row containing the final variable-length storage sequence is written from the memory into the corresponding database page area of the storage medium, to realize persistent writing and keep the page-level organization consistent with subsequent retrieval consistency.

[0090] The embodiment performs byte length calculation and maximum allowed length check on the final variable length storage sequence, and the write exceeding the expressible range in the row is blocked in advance; the target data row obtains length metadata corresponding to the variable length field by writing the sequence length value into the variable length field length list of the target data row and updating the variable length field count, so that the data column offset address can be derived from the fixed size of the fixed length field and the variable length field length list; and the complete target data row forms a continuous byte layout which can directly fall into the database page area by allocating storage space in the memory according to the combined result of the fixed length area and the variable length area and writing the final variable length storage sequence at the offset address specified by the data column, so as to stably write the final variable length storage sequence into the storage medium and reduce the repeated overhead caused by row space waste and write failure.

[0091] In an embodiment, a numerical data variable length encoding storage device is provided, which corresponds to the numerical data variable length encoding storage method in the above embodiments. Referring to Figure 3 , Figure 3 The functional module schematic diagram of a preferred embodiment of the numerical data variable length encoding storage device of the present application is shown in the figure. The fixed length binary encoding module 10, the integer de-padding and intercepting module 20, the decimal grouping mapping and compressing module 30, the header description splicing module 40, the global symbol mask processing module 50 and the storage medium writing module 60. The detailed description of each functional module is as follows: The fixed length binary encoding module 10 is used to obtain the target numerical data to be stored, and convert the target numerical data into an intermediate fixed length binary sequence containing an integer part data segment and a decimal part data segment according to the predefined definition precision; The integer de-padding and intercepting module 20 is used to analyze the intermediate fixed length binary sequence to determine the positive and negative polarity attribute, and perform de-padding and intercepting processing on the integer part data segment based on the positive and negative polarity attribute to generate valid integer binary data; The decimal grouping mapping and compressing module 30 is used to analyze the decimal part data segment in the intermediate fixed length binary sequence to obtain a valid digit sequence, and perform bit grouping mapping processing on the valid digit sequence to generate valid decimal compressed data; The header description splicing module 40 is used to generate a header description byte recording the length information of the valid integer binary data, and splice the header description byte, the valid integer binary data and the valid decimal compressed data in sequence to generate a to-be-labeled variable length sequence; The global symbol mask processing module 50 is used to generate a full-bit symbol mask based on the positive and negative polarity attribute, perform bit-by-bit logical exclusive OR operation on all bytes of the to-be-labeled variable length sequence using the full-bit symbol mask, and perform a flip operation on the highest bit of the first byte after the operation to generate a final variable length storage sequence; The storage medium writing module 60 is configured to write the final variable-length storage sequence into a storage medium.

[0092] The specific definition of the numerical data variable-length encoding storage device can refer to the aforementioned definition of the numerical data variable-length encoding storage method, which will not be repeated here. Each module in the numerical data variable-length encoding storage device described above can be realized by software, hardware, and a combination thereof, in whole or in part. Each module described above can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so that the processor invokes and executes the operations corresponding to each module.

[0093] In one embodiment, a computer device is provided, which can be a server, and its internal structure diagram can be as shown in Figure 4 The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. The processor of the computer device is configured to provide determination and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is configured to communicate with an external client through a network connection. The computer program is executed by the processor to implement the functions or steps of a numerical data variable-length encoding storage method on the server side.

[0094] In one embodiment, a computer device is provided, which can be a client, and its internal structure diagram can be as shown in Figure 5 The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. The processor of the computer device is configured to provide determination and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is configured to communicate with an external server through a network connection. The computer program is executed by the processor to implement the functions or steps of a numerical data variable-length encoding storage method on the client side.

[0095] In one embodiment, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the following steps: obtaining target numerical data to be stored, and converting the target numerical data into an intermediate fixed-length binary sequence including an integer part data segment and a decimal part data segment according to a predefined definition precision; parsing the intermediate fixed-length binary sequence to determine a positive-negative polarity attribute, and performing a de-padding truncation process on the integer part data segment based on the positive-negative polarity attribute to generate valid integer binary data; parsing the decimal part data segment in the intermediate fixed-length binary sequence to obtain a valid digit sequence, and performing a bit grouping mapping process on the valid digit sequence to generate valid decimal compressed data; generating a head description byte recording the length information of the valid integer binary data, and concatenating the head description byte, the valid integer binary data, and the valid decimal compressed data in sequence to generate a to-be-marked variable-length sequence; generating a full-bit symbol mask based on the positive-negative polarity attribute, performing a bit-by-bit logical XOR operation on all bytes of the to-be-marked variable-length sequence using the full-bit symbol mask, and performing a flip operation on the highest bit of the first byte after the operation to generate a final variable-length storage sequence; writing the final variable-length storage sequence into a storage medium.

[0096] In one embodiment, a computer readable storage medium is provided, which can be non-volatile or volatile, and has stored thereon a computer program, which is executed by a processor to implement the following steps: obtaining target numerical data to be stored, and converting the target numerical data into an intermediate fixed-length binary sequence containing an integer part data segment and a decimal part data segment according to a predefined definition precision; parsing the intermediate fixed-length binary sequence to determine a positive-negative polarity attribute, and performing a de-padding truncation process on the integer part data segment based on the positive-negative polarity attribute to generate valid integer binary data; parsing the decimal part data segment in the intermediate fixed-length binary sequence to obtain a valid digit sequence, and performing a bit grouping mapping process on the valid digit sequence to generate valid decimal compressed data; generating a head description byte recording the length information of the valid integer binary data, and concatenating the head description byte, the valid integer binary data, and the valid decimal compressed data in sequence to generate a to-be-marked variable-length sequence; generating a full-bit symbol mask based on the positive-negative polarity attribute, performing a bit-by-bit logical XOR operation on all bytes of the to-be-marked variable-length sequence using the full-bit symbol mask, and performing a flip operation on the highest bit of the first byte after the operation to generate a final variable-length storage sequence; writing the final variable-length storage sequence into a storage medium.

[0097] It should be noted that the above-mentioned functions or steps that can be achieved by the computer readable storage medium or the computer device can correspond to the related description of the server side and the client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.

[0098] Those skilled in the art can understand that all or part of the processes in the foregoing method embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the foregoing method embodiments. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM) and memory bus dynamic RAM (RDRAM), etc.

[0099] It should be noted that if a non-company software tool or component appears in the embodiments of the present application, it is only used for example introduction and does not represent actual use. The above-described embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method for storing variable-length numerical data, characterized in that, Includes the following steps: Obtain the target numerical data to be stored, and convert the target numerical data into an intermediate fixed-length binary sequence containing integer part data segments and fractional part data segments according to a preset defined precision; The intermediate fixed-length binary sequence is parsed to determine the positive and negative polarity attributes, and the integer part of the data segment is subjected to de-padding and truncation processing based on the positive and negative polarity attributes to generate valid integer binary data; Parse the fractional part of the intermediate fixed-length binary sequence to obtain the effective digit sequence, and perform bit-by-bit grouping mapping on the effective digit sequence to generate effective fractional compressed data; Generate a header description byte that records the length information of the valid integer binary data, and then concatenate the header description byte, the valid integer binary data, and the valid decimal compressed data in sequence to generate a variable-length sequence to be marked; A full-bit sign mask is generated based on the positive and negative polarity attributes. The full-bit sign mask is used to perform a bitwise logical XOR operation on all bytes of the variable-length sequence to be marked, and the most significant bit of the first byte after the operation is flipped to generate the final variable-length storage sequence. The final variable-length storage sequence is written into the storage medium.

2. The variable-length encoding and storage method for numerical data as described in claim 1, characterized in that, Acquire the target numerical data to be stored, and convert the target numerical data into an intermediate fixed-length binary sequence containing integer and fractional data segments according to a preset precision, including: Obtain the target numerical data to be stored, and parse the preset defined precision to determine the total number of decimal digits allowed to be stored in the integer part and the fractional part of the target numerical data respectively; Based on a group of nine decimal digits, the integer part of the target numerical data and the fractional part of the numerical data are divided into several complete number groups, as well as the remaining number groups that exist when the number of digits cannot be divided by nine. Each complete set of numbers is converted into a four-byte binary code; Each remaining number group is converted into a binary code of corresponding byte length according to the number of digits contained in the remaining number group. The remaining number group containing one or two digits is converted into one byte, the remaining number group containing three or four digits is converted into two bytes, the remaining number group containing five or six digits is converted into three bytes, and the remaining number group containing seven or nine digits is converted into four bytes. All converted binary codes are concatenated in the order of integer part first and fractional part last, and zero-value bytes are filled at the beginning and end of the concatenated sequence to generate the original binary sequence. The positive or negative polarity attribute of the target numerical data is detected. If it is negative, a symbol mask of all ones is generated and a bitwise logical XOR operation is performed with the original binary sequence to generate an intermediate fixed-length binary sequence. If it is positive, the original binary sequence is determined as the intermediate fixed-length binary sequence.

3. The variable-length encoding and storage method for numerical data as described in claim 1, characterized in that, The intermediate fixed-length binary sequence is parsed to determine its positive or negative polarity attribute, and based on this attribute, the integer portion of the data segment is de-padded and truncated to generate valid integer binary data, including: The sign indication information is parsed from the starting byte of the intermediate fixed-length binary sequence, and the positive and negative polarity attributes are determined based on the sign indication information. The sign indication information is the highest bit of the starting byte, and the highest bit represents the positive and negative polarity attributes according to a preset sign determination rule. A symbol mask byte is generated based on the positive and negative polarity attributes, wherein when the positive and negative polarity attributes are negative, the symbol mask byte is all one bytes, and when the positive and negative polarity attributes are positive, the symbol mask byte is all zero bytes. Locate the consecutive byte segments representing the integer portion of the data from the intermediate fixed-length binary sequence; Perform a bitwise logical XOR operation between each byte in the continuous byte segment and the symbol mask byte to obtain a normalized integer byte sequence; Starting from the beginning of the normalized integer byte sequence, scan sequentially, skipping padding bytes with a value of zero, and locate the first valid byte with a non-zero value; Starting from the valid byte, all bytes are continuously extracted from the normalized integer byte sequence up to the end of the normalized integer byte sequence, and valid integer binary data is constructed based on the extracted byte sequence.

4. The variable-length encoding and storage method for numerical data as described in claim 1, characterized in that, Parsing the fractional portion of the intermediate fixed-length binary sequence to obtain a valid digit sequence, and performing bit-by-bit grouping mapping on the valid digit sequence to generate compressed valid fractional data, including: Decode the fractional data segment in the intermediate fixed-length binary sequence to restore the binary encoding of the fractional data segment to the original digital stream composed of decimal digits; Detect whether there are consecutive zero values ​​at the end of the original digital stream. If so, remove the consecutive zero values ​​at the end of the original digital stream to obtain a valid digital sequence. The numbers in the effective number sequence are grouped into pairs in order from front to back to form several number pairs. If there are any remaining numbers that cannot be paired, the remaining numbers are grouped as a separate group. Each of the number pairs is encoded into a complete data byte, wherein the first number of the number pair occupies the high four bits of the complete data byte and the second number occupies the low four bits of the complete data byte; If the separate group exists, the numbers in the separate group are encoded into the high four bits of a partial padding byte, and the low four bits of the partial padding byte are set to zero; All generated complete data bytes and partial padding bytes are concatenated according to the numerical order in the valid digit sequence to generate valid decimal compressed data.

5. The variable-length encoding and storage method for numerical data as described in claim 1, characterized in that, Generate a header description byte that records the length information of the valid integer binary data, and concatenate the header description byte, the valid integer binary data, and the valid decimal compressed data sequentially to generate a variable-length sequence to be marked, including: Calculate the number of bytes contained in the valid integer binary data to obtain the integer length value; Generate a header description byte, and set the integer length value in a predetermined bit area of ​​the header description byte, wherein the predetermined bit area is the bit area of ​​the header description byte excluding the most significant bit; The header description byte, the valid integer binary data, and the valid decimal compressed data are concatenated sequentially according to the following order: the header description byte first, the valid integer binary data in the middle, and the valid decimal compressed data last. The complete data sequence formed after splicing is used as the variable-length sequence to be labeled.

6. The variable-length encoding and storage method for numerical data as described in claim 1, characterized in that, A full-bit sign mask is generated based on the positive and negative polarity attributes. The full-bit sign mask is then used to perform a bitwise logical XOR operation on all bytes of the variable-length sequence to be marked. Finally, the most significant bit of the first byte after the operation is flipped to generate the final variable-length storage sequence, including: A full-bit sign mask is generated based on the positive and negative polarity attributes, wherein when the positive and negative polarity attributes indicate a negative value, the full-bit sign mask is set to a byte with all binary values ​​of one, and when the positive and negative polarity attributes indicate a positive value, the full-bit sign mask is set to a byte with all binary values ​​of zero. Perform a bitwise logical XOR operation between each byte of the variable-length sequence to be marked and the full-bit sign mask to obtain a preliminary processed sequence; Obtain the first byte of the preliminary processing sequence, and perform a flip operation on the most significant bit of the first byte to generate the corrected first byte; The corrected first byte is combined with the remaining bytes in the preliminary processing sequence other than the first byte to generate the final variable-length storage sequence.

7. The variable-length encoding and storage method for numerical data as described in claim 1, characterized in that, Writing the final variable-length storage sequence to the storage medium includes: Calculate the byte length of the final variable-length storage sequence to obtain the sequence length value; Verify whether the sequence length value is less than or equal to the preset maximum allowed length; If the sequence length value is less than or equal to the preset maximum allowed length, then the sequence length value is recorded in the variable length field length list of the target data row containing the final variable length storage sequence, and the variable length field count of the target data row is updated. Storage space is allocated in memory for the target data row, the size of which is determined based on the sum of the sequence length values ​​of all variable-length fields in the target data row and the fixed size of the fixed-length fields; The final variable-length storage sequence is used as the value of the corresponding data column and written into the allocated storage space at the offset address specified for the data column. The complete target data row containing the final variable-length storage sequence is written from memory to the corresponding database page area in the storage medium.

8. A variable-length encoded storage device for numerical data, characterized in that, The variable-length encoded storage device for numerical data includes: A fixed-length binary encoding module is used to acquire the target numerical data to be stored and convert the target numerical data into an intermediate fixed-length binary sequence containing an integer part data segment and a fractional part data segment according to a preset defined precision. The integer de-padding and truncation module is used to parse the intermediate fixed-length binary sequence to determine the positive and negative polarity attributes, and perform de-padding and truncation processing on the integer part data segment based on the positive and negative polarity attributes to generate valid integer binary data; The fractional grouping mapping compression module is used to parse the fractional part of the intermediate fixed-length binary sequence to obtain the effective number sequence, and to perform bit-by-bit grouping mapping processing on the effective number sequence to generate effective fractional compressed data. The header description concatenation module is used to generate a header description byte that records the length information of the effective integer binary data, and to concatenate the header description byte, the effective integer binary data, and the effective decimal compressed data in sequence to generate a variable-length sequence to be marked. The global symbol mask processing module is used to generate a full-bit symbol mask based on the positive and negative polarity attributes, perform a bitwise logical XOR operation on all bytes of the variable-length sequence to be marked using the full-bit symbol mask, and perform a flip operation on the most significant bit of the first byte after the operation to generate the final variable-length storage sequence. A storage medium writing module is used to write the final variable-length storage sequence into a storage medium.

9. A computer device, characterized in that, The computer device includes a memory, a processor, and a variable-length encoding storage program for numerical data stored in the memory and executable on the processor. When executed by the processor, the variable-length encoding storage program for numerical data implements the steps of the variable-length encoding storage method for numerical data as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The storage medium stores a variable-length encoding storage program for numerical data, which, when executed by a processor, implements the steps of the variable-length encoding storage method for numerical data as described in any one of claims 1-7.

Citation Information

Cited By

  • Serialization method, device and equipment of chip layout data and medium

    CN122160018A