A method and application for decompressing and compressing SAS data sets

By decompressing and compressing SAS data sets without relying on SAS software, the compatibility problem of SAS data sets is solved, and the independent operation and widespread application of the data sets are realized.

CN118523780BActive Publication Date: 2024-10-15杭州启维人工智能编译技术有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410986369.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-10-15
Estimated Expiration
2044-07-23

AI Technical Summary

Technical Problem

The closed nature and encryption of SAS data sets limit its compatibility with other data analysis platforms or software, hinder cross-platform data sharing and collaboration, and affect the flexibility of tool and platform selection for data scientists and analysts.

Method used

Provide a method and application that can decompress and compress SAS data sets without relying on SAS software, by reading file attribute information, identifying loop content, judging file format and compression identification, and applying sliding window compression algorithm and The idea of ​​run-length coding realizes the decompression and compression of SAS data sets.

Benefits of technology

It achieves independent decompression and compression of SAS data sets, enhances the independence and compatibility of data processing, enables users to operate SAS data without relying on specific software, and broadens the application scenarios and usage scope of SAS data sets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118523780B_ABST
    Figure CN118523780B_ABST
Patent Text Reader

Abstract

The present invention provides a method and application for decompressing or compressing a SAS data set, which reads file attribute information in a SAS data set, reads the number of loops in the SAS data set, and reads the text offset, loop length, and data identifier of all loops, and goes to a corresponding row of the corresponding SAS data set according to the text offset, selects bytes of the loop length in the corresponding row as loop content, and identifies file format content from the loop content, then locates data storage content and reads data from the data storage content according to the file format content; at the same time, the present invention compresses the SAS data set using binary compression and char compression methods to obtain a SAS data set that can be recognized by SAS software, and can decompress and compress the SAS data set without relying on SAS software.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data decompression and compression, and in particular to a method and application for decompressing and compressing a SAS data set, which can decompress and compress a data set generated by a SAS program to obtain a data set that can be read by the SAS program. Background Art

[0002] In the current field of big data processing, SAS (Statistical Analysis System), as a software system widely used in data analysis and report generation, plays a vital role. It not only supports complex data operations, statistical analysis and data mining functions, but also can efficiently process and store large data sets. However, its data format is not public and the content is encrypted. Therefore, the SAS data set generated by SAS software can only be read by SAS software. Although this design effectively protects the data from unauthorized access and tampering, it also brings a series of limitations.

[0003] Due to the closed format and encryption of SAS data sets, the compatibility of SAS data sets with other data analysis platforms or software systems is severely limited. In other words, applications or tools in non-SAS environments are usually unable to directly read and parse these data sets unless they are read through the interface provided by SAS or undergo a complex conversion process. This limitation not only hinders cross-platform data sharing and collaboration, but also affects the flexibility of data scientists and analysts in choosing tools and platforms.

[0004] Therefore, there is an urgent need for a method that can decompress and compress SAS data sets independently of SAS software to expand the compatibility of SAS data sets. Summary of the invention

[0005] The embodiment of the present application provides a method and application for decompressing and compressing a SAS data set, which can decompress and compress a SAS data set without relying on SAS software.

[0006] In a first aspect, an embodiment of the present application provides a method, the method comprising: S1: obtaining a SAS data set to be decompressed; S2: reading file attribute information in the SAS data set, wherein the file attribute information comprises a file header, file data information, file creation time, file modification time, file version and file page number; S3: reading the value of the 5th to 8th bytes of 00010010h of the SAS data set and subtracting 1 as the number of loops, sequentially taking each 12 consecutive bytes after the 8th byte of 00010010h as a loop until all loops of the number of loops are read, reading the text offset, loop length and data identifier of each loop, locating the bytes of the loop length in the corresponding row according to the text offset to the corresponding row of the corresponding SAS data set as the loop content, and identifying the file format content from the loop content; S4: judging the composition form of each page according to the number of file pages, judging whether it is compressed data according to the compression identifier of the information outline of the file format content, locating the data storage content after skipping the bytes of the set value from the 8th byte of 00010010h, and reading data from the data storage content according to the file format content of step S3.

[0007] In a second aspect, an embodiment of the present application provides a method for compressing a SAS data set, comprising the steps of: performing binary compression on the SAS data set obtained by decompressing the method for compressing a SAS data set mentioned in the first aspect: taking the position of the sliding window of the data to be compressed as the header, and taking the code value of each byte in the data to be compressed in the ASCII table in turn as the compression value, wherein when multiple consecutive identical bytes appear, the compression values ​​of the current multiple bytes are set according to the inverse of the first analytical formula, and when bytes of repeated fragments appear, the compression values ​​of the bytes of the repeated fragments are set according to the inverse of the second analytical formula.

[0008] In a third aspect, an embodiment of the present application provides a method for compressing a SAS data set, comprising the steps of: performing char compression on the SAS data set obtained by decompressing the method for compressing the SAS data set mentioned in the first aspect: compressing the SAS data set according to the inverse operation of the char decompression rule, wherein the char decompression rule is: obtaining the decompressed length of the data to be decompressed and decompressing each byte of the data to be decompressed in turn, splitting each byte into a high order and a low order, and obtaining the corresponding case according to the high order code, converting the byte into the number of cache bytes to be cached according to the case calculation rule, and storing the number of cache bytes in the cache area until the parsed length of the data to be decompressed reaches the decompression length.

[0009] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform any of the methods for decompressing a SAS data set or any of the methods for compressing a SAS data set.

[0010] The main contributions and innovations of the present invention are as follows:

[0011] The present invention can realize effective decompression and compression of SAS data sets in a completely independent SAS software environment, greatly enhancing the independence and compatibility of data processing, allowing users to operate SAS data without relying on specific software, and broadening the application scenarios and usage scope of SAS data sets.

[0012] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0014] Figure 1 This is a schematic diagram of parsing a hexadecimal SAS data set to obtain file attribute information.

[0015] Figure 2 It is a schematic diagram of parsing a SAS data set to obtain the number of loops and loops.

[0016] Figure 3 This is a schematic diagram of the outline of the information in the first cycle of reading.

[0017] Figure 4 This is a diagram for reading variable text in the fifth loop.

[0018] Figures 5 to 8 This is a code diagram of the char decompression rule.

[0019] Fig. 9 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0020] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0021] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments. Example

[0022] This solution provides a method for decompressing a SAS data set, including the following steps:

[0023] S1: Get the SAS data set to be decompressed;

[0024] In step S1, this solution can use ultraedit or other similar editors to open the SAS data set to be decompressed to obtain hexadecimal data, that is, the SAS data set to be decompressed is decompressed as hexadecimal data. In this mode, the binary structure of the SAS data set is presented in a hexadecimal numerical form that is easy to analyze.

[0025] In some embodiments, the solution is linked to a storage medium or a cloud storage service storing a SAS data set, and obtains the SAS data set to be decompressed therefrom.

[0026] S2: Read the file attribute information in the SAS data set, where the file attribute information includes the file header, file data information, file creation time, file modification time, file version, and file page number;

[0027] In step S2, by reading the file header and file version information in the file attribute information in the SAS data set, the system can determine the specific format and version of the SAS data set, which is a prerequisite for ensuring the correct execution of decompression and subsequent processing operations; reading the creation time and modification time of the file can help track the source of the SAS data set and ensure the integrity and credibility of the data; reading the number of file pages and file data information can help with the subsequent decompression of specific content.

[0028] Specifically, reading the file header in the SAS data set in step S2 includes the following steps: reading the SASFILE string of the 00000050h line in the SAS data set as the file header,

[0029] The SASFILE string is represented by 8 bytes of "53 41 53 20 46 49 4c 45". It should be noted that in the ASCII table, hexadecimal 0x53 represents the letter "S", 0x41 represents the letter "A", 0x20 represents the letter "F", 0x46 represents the letter "I", 0x4c represents the letter "L", and 0x45 represents the letter "E".

[0030] Reading the file data information in the SAS data set in step S2 includes the following steps: reading the value of the DATA string in the 00000090h row in the SAS data set as the file data information, wherein the DATA string is represented by 4 consecutive bytes that are not 0. In other words, reading the 00000090h row in the SAS data set as the DATA string.

[0031] Specifically, DATA is represented by "44 41 54 41". In the ASCII table, hexadecimal 0x44 represents the letter "D", 0x41 represents "A", and 0x54 represents the letter "T". Therefore, when the system recognizes "44 41 54 41", it believes that the DATA string has been read.

[0032] Reading the file creation time in the SAS data set in step S2 includes the following steps: reading the value of the file creation time string of the 000000a0h line in the SAS data set as the file creation time, wherein the file creation time string is represented by 8 consecutive bytes of the 9th to 16th bytes of the 000000a0h line.

[0033] Reading the file creation time in the SAS data set in step S2 includes the following steps: reading the value of the file modification time string of the 000000b0h line in the SAS data set as the file modification time, wherein the file modification time string is represented by 8 consecutive bytes of the 9th to 16th bytes of the 000000b0h line.

[0034] Reading the file version in the SAS data set in step S2 includes the following steps: reading the last 8 consecutive bytes of the 000000c0h line in the SAS data set, if the 8 consecutive bytes are all 00, the text version is version 1, otherwise it is version 2.

[0035] It should be noted that when the text version is identified as version 1, the values ​​of the 8th to 5th consecutive bytes from the bottom of the line 000000c0h are read as the file header size; when the text version is identified as version 2, the values ​​of the last 4 consecutive bytes from the bottom of the line 000000c0h are read as the file header size.

[0036] In addition, this solution reads the values ​​of the 8th to 5th consecutive bytes from the last line of 000000c0h as the text offset offset info, and reads the values ​​of the last 4 consecutive bytes from the last line of 000000c0h as the page size page size.

[0037] Reading the number of file pages in the SAS data set in step S2 includes the following steps: reading the value of the first 4 consecutive bytes of the 000000d0h line in the SAS data set as the number of file pages.

[0038] In addition, this solution reads the byte value according to the "reverse order between groups, positive order within the group" method. For example, if the byte is represented as: "0000 01 00", then according to the principle of reverse order of components, the actual byte is "00 01 00 00", and according to the principle of positive order within the group, the value of the continuous byte is recognized as 0x10000=65536 / 1024=64.

[0039] like Figure 1 As shown, Figure 1 0000050h indicates the file header, the highlighted area of ​​0000090h indicates the file data information, the highlighted area of ​​00000a0h indicates the file creation time, the highlighted area of ​​00000b0h indicates the file modification time, the first highlighted area of ​​00000c0h indicates the text offset, the second highlighted area of ​​00000c0h indicates the page size page_size, and the first 4-byte red area of ​​000000d0h indicates the number of file pages.

[0040] Step S3: read the values ​​of the 5th to 8th bytes of 00010010h of the SAS data set and subtract 1 as the number of loops, and then take each 12 consecutive bytes after the 8th byte of 00010010h as a loop until all loops are read, read the text offset, loop length and data identifier of each loop, and go to the corresponding row of the corresponding SAS data set according to the text offset, select the bytes of the loop length in the corresponding row as the loop content, and identify the file format content from the loop content.

[0041] Since the header file is represented before 00010000h of the SAS data set, and the first page is represented starting from 00010000h, that is, the file content is specifically stored after 00010000h, and the file content may have several loops, this solution reads the number of loops within 00010000h and identifies each loop to learn the specific format of the file.

[0042] like Figure 2 As shown, Figure 2 is a schematic diagram of reading the number of cycles and the cycles according to step S3, Figure 2 The 5th to 8th bytes represented by the dark highlighted font at 00010010h are used as the number of loops and the value obtained by reading is 0x12-1, which is 17. This means that the file content needs to be read through 17 loops, so the 17 light highlighted fonts with 12 bytes as a unit after reading the dark highlighted font are used as the loop.

[0043] At this time, the values ​​of the first 4 consecutive bytes in each cycle are read as the text offset info, the values ​​of the 5th to 8th consecutive bytes are used as the cycle length, and the values ​​of the last 4 consecutive bytes are used as the data identifier. More specifically, when the data identifier is 101, it means that the data in this row is not compressed, when the data identifier is 104, it means that the data in this row is compressed, and when the data identifier is 105, it means that the data in this row has been deleted.

[0044] In some embodiments, four bytes of the text offset are read in reverse order as a corresponding row of the corresponding SAS data set, and bytes of the loop length are read in the corresponding row as loop content.

[0045] Different loops represent different contents. The first loop records the general outline of information, the second loop contains indexes, the fourth loop records variable letters, the fifth loop records variable text, the sixth loop records variable data, and the loops after the eighth loop record variable information of the variable. It should be noted that this solution can obtain the number of loops, and the number of variables can be obtained based on the number of loops. The value of the number of loops minus 7 is taken as the total number of variables of the current variable.

[0046] Correspondingly, "identifying file format content in self-loop content" includes the steps of identifying information outline, index, variable letters, variable text, variable data and variable information.

[0047] Step S3 further includes "identifying the general outline of information", including the steps of: locating the general outline line according to the text offset of the first loop, identifying four consecutive F7 bytes in the general outline line as the start mark of the general outline of information, identifying the bytes of the loop length of the first loop after the start mark of the general outline of information as the loop content, wherein the values ​​of the 17th byte to the 20th byte after the start mark of the general outline of information are used as the total length of the variable, the values ​​of the 21st byte to the 24th byte after the start mark of the general outline of information are used as the number of data rows, and the values ​​of the 25th byte to the 28th byte after the start mark of the general outline of information are used as the number of data rows. As the number of deleted rows, the values ​​from the 29th byte to the 32nd byte after the start identifier of the information outline are used as the compression identifier, the values ​​from the 33rd byte to the 36th byte after the start identifier of the information outline are used as the number of variables on the first page, the values ​​from the 37th byte to the 40th byte after the start identifier of the information outline are used as the number of variables on other pages, the values ​​from the 49th byte to the 52nd byte after the start identifier of the information outline are used as the data page size, and the values ​​from the 57th byte to the 60th byte after the start identifier of the information outline are used as the total number of data observations on the first page, until the end identifier of the information outline is read.

[0048] It should be noted that each SAS data set has only one information outline. The information outline of the SAS data set is located by obtaining it in the first loop.

[0049] For example, if the four consecutive bytes corresponding to the text offset are "20 FE 00 00", the corresponding outline line is 0001fe20h, and "F7 F7 F7 F7" in the outline line indicates the start mark of the information outline. After the scheme locates the start mark of the information outline, it skips the 16 bytes after the start mark of the information outline, and reads the values ​​from the 17th byte to the 20th byte as the total length of the variable.

[0050] In some embodiments, the information outline end marker is "FF FF FF FF FF FF FF FF 00 00 00 0000 00 00 00", and when the information outline end marker is read, it means that the above content is the information outline.

[0051] In some embodiments, when the compression flag is 0, it indicates no compression, when the compression flag is 1, it indicates char compression, and when the compression flag is 2, it indicates binary compression.

[0052] In some embodiments, the information outline end marker is represented as “FF FF FF FF FF FF FF FF 00 0000 00 00 00 00 00”.

[0053] like Figure 3 As shown, Figure 3This is a schematic diagram of reading the information outline of the first loop. According to the text offset "20 FE 00 00" of the first loop, find F7 F7 F7 F7 (dark highlighted font area) of the outline line represented by line 0x1FE20 as the start mark of the information outline. The 4 bytes of the first highlighted font area of ​​line 0x0001fe30 are B0 00 00 00, that is, 176, indicating the total length of the variable size_obs = 176. The 4 bytes of the second highlighted font area are 05 00 00 00 means the number of data rows is 5. The 4 bytes in the third highlighted font area represent the number of deleted rows. The 4 bytes in the fourth highlighted font area represent whether it is compressed data. The 4 bytes in the fifth highlighted font area represent N_var_in_first_page: the number of variables in the first page. In this example, 0x0A means the number of variables in the first page is 10. The 4 bytes in the sixth highlighted font area represent n_var_left: the number of variables in other pages that are not in the first page. The 4 bytes in the seventh highlighted font area represent the page size of the data, page_size. 00 00 01 00 means the page size is 0x10000, i.e. 65536. The 8th light green 4 bytes represent n_obs_in_first_page. The information outline ends at FF FF FF FF FF FF FF FF 00 00 00 00 00 00 0000.

[0054] Step S3 further includes "identifying indexes", including the steps of: locating the index row according to the text offset of the second loop, identifying four consecutive F6 bytes in the index row as the index start identifier, identifying the bytes of the loop length of the second loop after the index start identifier as the loop content, wherein the values ​​of the 1st byte to the 4th byte after the index start identifier are used as the number of variables, and the values ​​of the 5th byte to the 8th byte after the index start identifier are used as the number of indexes.

[0055] For example, the "F6 F6 F6 F6" of the index row is identified as the index start marker, indicating that this part of the content is the index content. The text offset of the second loop is "14 FE 00 00", and the corresponding index row is 0001fe10h row. The loop length is "0C 00 00 00", which is 12 bytes. When the first byte to the fourth byte of the 0001fe10h row is read as "0A 00 00 00", it means that the corresponding number of variables is 10.

[0056] Step S3 further includes "identifying variable letters", including the steps of: locating the variable letter row according to the text offset of the fourth loop, identifying the bytes of the loop length of the fourth loop in the variable letter row as the loop content, and storing the variable letters of the data variables in the loop content into the buffer.

[0057] In some embodiments, the data variables include character-related variables and data column-related characters. When "FD FF FF FF" is recognized in the loop content, this part of the content is recognized as all character-related information, such as label, format, etc.; when "FE FB FF FF" is recognized in the loop content, this part of the content is recognized as information related to the data column.

[0058] Exemplarily, the fourth loop includes variable letters corresponding to variables such as label and format, and stores the read content in the buffer.

[0059] Step S3 further includes "identifying variable text", including the steps of: locating the variable text row according to the text offset of the fifth loop, identifying the bytes of the loop length of the fifth loop in the variable text row as the loop content, identifying the value of the first byte to the fourth byte after four consecutive FF bytes in the variable text row minus 8 as the variable text displacement length, the value of the ninth byte to the tenth byte represents the page where the displacement information of the variable text is located, the value of the eleventh byte to the twelfth byte represents the variable text offset, the value of the thirteenth byte to the fourteenth byte represents the variable text length, locating the variable text offset start mark of "FD FF FF FF" in the loop content according to the page where the displacement information is located, and locating the first byte after the number of bytes of the variable text offset interval with the variable text offset start mark as the variable text start byte, identifying the byte area consisting of the number of bytes of the continuous variable text length from the variable text start byte as the variable text, and identifying the value of the variable text as the name of the variable text. In this scheme, the information of all variables is read in sequence.

[0060] It should be noted that the loop content in the fifth loop is the text displacement part of the data variable name. By identifying the fifth loop, the variable text of the data variable can be obtained. The variable text displacement length indicates that the byte area composed of bytes with the length of the variable text displacement length after the byte is important information. The variable text start byte is determined according to the variable text offset start mark and the variable text offset obtained by identification, and then the length of the variable text is determined according to the continuous variable text length, and then the location of the variable text is determined. Example description: If there is a variable named "name", you need to find where "name" is in this loop content, and then find "name".

[0061] For example, Figure 4 As shown, Figure 4This is a schematic diagram of reading the variable text of the fifth loop. According to the text offset of the fifth loop: 80 FB 00 00, find the 0x1FB80 line and find the loop content with a length of 0x64 (i.e. 100 bytes). This part of the content is the text displacement part of the data variable name. The first 4 bytes of the highlighted font represent the displacement length, 0x58 (88) minus 8 = 80, that is, the length of the following important information is equal to 80; the first two bytes of the second 4 bytes of the highlighted font 00 00 represent the page number of the information, and the last two bytes 24 00 represent the variable text offset. The first two bytes of the third 4 bytes of the highlighted font 04 00 represent the length of the variable text; locate the variable text offset start mark of "FD FF FF FF", count the variable text offset 0x24 (i.e. 36) bytes after the variable text offset start mark, and the length of the variable text is 4 bytes, that is, the value of the area where the highlighted font of the 0x1fc00 line is located represents the name of the first variable, which is name.

[0062] Step S3 further includes "identifying variable data", including the steps of: locating the variable data row according to the text offset of the sixth loop, identifying the bytes of the loop length of the sixth loop in the variable data row as the loop content, identifying the values ​​of the first byte to the fourth byte after "FC FF FF FF" in the variable data row minus 8 as the variable data displacement length, the values ​​of the ninth byte to the twelfth byte represent the variable data offset, the values ​​of the thirteenth byte to the sixteenth byte represent the variable data length, and the nineteenth byte represents the data type.

[0063] It should be noted that the loop content in the sixth loop is the data displacement part of the variable data. By identifying the sixth loop, the variable data can be obtained. The variable data displacement length indicates that the byte area composed of bytes with a subsequent number length of the variable data displacement length is important information. Since each variable needs to be composed of 12 bytes, if there are 10 variables, the required length of the important information is 120.

[0064] In some embodiments, when the data type is 02, it indicates that the current data variable is a string, and when the data type is 01, it indicates that the current data variable is a number.

[0065] Step S3 further includes "identifying variable information", including the steps of: identifying each loop starting from the 8th loop to obtain variable information corresponding to each variable, wherein the text offset in each loop is identified to locate the variable information row, the byte corresponding to the loop length of each loop in the variable information row is identified as the loop content, "FE FBFF FF" in the variable information row is used as the variable information start identifier, the value of four consecutive bytes starting from the first "0A" byte after the variable information start identifier is identified as the format information of the variable, the value of four consecutive bytes starting from the second "0A" byte is used as the informat information of the variable, the value of the two bytes before the "2C" byte is used as the informat text position, the value of the two consecutive bytes starting from the "2C" byte is used as the offset of the informat, the value of the third byte and the fourth byte starting from the "2C" byte is used as the content length of the informat, the values ​​of the 6 consecutive bytes following the informat content length are respectively used as the text position, offset and length of the format, and the values ​​of the 6 consecutive bytes following the format length are respectively used as the text position, offset and length of the label.

[0066] Specifically, the values ​​of the first two consecutive bytes starting from the first "0A" byte are identified as the width of the variable format, and the values ​​of the last two consecutive bytes are identified as the precision of the variable format; the values ​​of the first two consecutive bytes starting from the second "0A" byte are identified as the width of the variable informat, and the values ​​of the last two consecutive bytes are identified as the precision of the variable informat. The values ​​of the 6 consecutive bytes following the content length of informat in units of 2 consecutive bytes are identified as the text position, offset, and length of format; the values ​​of the 6 consecutive bytes following the length of format in units of 2 consecutive bytes are identified as the text position, offset, and length of label.

[0067] It should be noted that when there are multiple variables in the SAS data set, there are multiple corresponding loops. Each loop starting from the 8th loop represents the variable information of a variable, wherein the variable information includes but is not limited to information such as format, informat, label, etc. In the embodiment of this scheme, there are 10 data variables in the SAS data set, namely name, id, alias_name, address, tel, class_code, start_date, end_date, date_today, date_today_sasdate, so there are 8 to 17 10 loops in total to obtain the variable information of each data variable respectively.

[0068] Step S4: Determine the composition of each page according to the number of file pages, and determine whether it is compressed data according to the compression identifier of the information outline of the file format content. If it is compressed data, skip the bytes of the set value from the 8th byte of 00010010h and locate the data storage content. If it is uncompressed data, locate the data storage content from the 8th byte of 00010010h, and read data from the data storage content according to the file format content of step S3.

[0069] The reason why this solution needs to first determine whether it is compressed data is that if the compressed data is larger than the data before compression, SAS will not compress it; therefore, if it is determined to be compressed data, it will be read according to the reading rules to find the offset; if it is not compressed, it will be read directly.

[0070] It should be noted that when the number of file pages is only 1, the current page is composed of a mixture of header fields and data, where the header field refers to non-content information such as file attribute information; when the number of file pages is greater than 1, a comparison is made based on the file data information and the data page size of each page of the file. If the file data information is the same as the data page size of each page of the file, the current page is composed of data only.

[0071] In some embodiments, whether the current data is compressed data is determined according to a compression identifier. If it is uncompressed data, the data length of each row of obs is the same.

[0072] When the compression flag of the current data is 2, it means that binary compression is used. The compressed data is parsed according to the ASCII table and the first parsing formula and the second parsing formula. If the first bit of the data is 0 or 1, the first parsing formula is used. If the first bit of the data is 2 or a number greater than 3, the second parsing formula is used. The first parsing formula is:

[0073] When the compressed value is represented as {0i C}, the parsing formula is {(0i+3) C}, where C represents the code value of the byte in the ASCII table;

[0074] When the compressed value is expressed as {1i jj C}, the parsing formula is {(jj*16+1i+3) C}, where C represents the code value of the byte in the ASCII table;

[0075] The second analytical formula is:

[0076] When the compressed value is represented as {2i jj kk}, the parsing formula is {count forward (jj*16+i+3) bits, read (kk+16) characters};

[0077] When the compressed value is represented as {ij kk (i>=3)}, the parsing formula is {count forward (kk*16+j+3) bits, read i characters, and repeat}".

[0078] When the compression flag of the current data is 1, it means that char compression is used, and the Char decompression rule is executed: the decompression length of the data to be decompressed and each byte of the data to be decompressed are obtained in turn, each byte is split into high and low bits, and the corresponding case is obtained according to the high-order code. The byte is converted into the number of cache bytes to be cached according to the case calculation rule, and the number of cache bytes is stored in the cache area until the parsed length of the data to be decompressed reaches the decompression length.

[0079] The specific char decompression rules are as follows Figures 5 to 8 As shown, the relationship between the corresponding case and calculation rules is as follows:

[0080] case 0x0F: If the high bit is 0xF, the low bit (lc) plus 2 determines the number of zeros to be filled. For example, 0xF4 will be decoded as 4+2=6 zeros.

[0081] case 0x0E: Similarly, fill with the specified number of space characters (ASCII code 0x20).

[0082] case 0x0D: fill with the specified number of '@' characters (ASCII code 0x40).

[0083] case 0x0C: Add 3 to the lower bit to get the total number of bytes, and the following byte is used as a fill character.

[0084] cases 0x0B, 0x0A, 0x09, 0x08: These cases use the high bit minus 0x80 plus 1 to determine the number of original data bytes that need to be copied, and then copy these bytes directly to the decoded buffer.

[0085] Cases 0x07, 0x06, 0x05: These cases calculate the length in a similar way, but the length calculation is more complicated, including multiplying the low bit by 256 (0x100) plus the value of the next byte plus an offset (17 or 18), and then filling with 0x00 (null), 0x20 (space), or 0x40 (@).

[0086] Case 0x04: Similar to the above three cases, but after decoding, the next byte is also used as a padding character.

[0087] Case 0x03, 0x02, 0x01: These cases use a similar length calculation, including subtracting 0x10 and multiplying by 0x188 (i.e. 392), then adding the value of the next element in the buf_obs array (using ++i first and then incrementing it), then checking whether the decompressed data will exceed the range of the buf_decode buffer, and using the memcpy function to copy the data in buf_obs to buf_decode.

[0088] Case 0x00: The method of calculating the length is different again, the low bit is multiplied by 256 plus the value of the next byte plus 64, and then the corresponding amount of original data is copied to the decoded buffer.

[0089] For example, take "F3 82 40 8F 40 40 04 61 60 A1 40 04 62 40 04 63" as the data to be decompressed, the first byte F3 is split into high-order hc="F" and low-order lc=3; according to the high-order code, the corresponding case is 0x0F, and according to the formula, n=lc+2=3+2=5 is calculated; that is, 5 bytes of 0x00 are added to the cache, and now the content of the cache is 00 00 00 00 00. Continue to read the next byte 82, split it into hc=8, lc=2; find the case as 0x08 and calculate; n=0x82-0x80+1=3; add the three bytes of data after 8F to the cache, that is, add 40 8F 40; now the content of the cache is 00 00 00 00 00 40 8F 40; continue to read the next byte 40; hc=4, lc=0, find case 0x04, n=0*0x100+04+18=22; ch is 0x61=letter a; write 22 a's into the buffer; the next byte 60, hc=6, lc=0, n=0*0x100+0xA1+17=178, write 178 0x20 (0x20 is a space) into the buffer; the above 3 bytes 04 61 60 are to parse out the 22 a's of the data, and the following 3 bytes 04 62 60 are to parse out the 22 b's of the data (because 0x61=a, 0x62=b), the principle is the same, until the parsed length reaches the length of the compressed data.

[0090] In some embodiments, if the position of the last byte after skipping the bytes of the set value from the 8th byte of 00010010h is within the 8 bytes of the row, the bytes of the set value are padded to the position of the last byte to the 8th byte of the row; and if the position of the last byte after skipping the bytes of the set value from the 8th byte of 00010010h is outside the 8 bytes of the row, the bytes of the set value are padded to the position of the last byte to the 16th byte of the row.

[0091] In some embodiments, in the step of "reading data from the data storage content according to the file format content of step S3", variable data is obtained by reading the data storage content line by line according to variable letters, variable text, and variable data, and data is read from the data storage content according to the variable information.

[0092] That is to say, according to the data displacement parsed from the file format content obtained by parsing step S3, this solution can know the displacement and length of which variable's data is in this row of data. After this row ends, the next row will follow immediately. The number of data rows of the first page must be collected before the page of pure data can be started. Example

[0093] This solution implements a method for decompressing a SAS data set through Example 1. Although the decompressed data can also be compressed using conventional compression methods, the compressed data cannot be read by SAS software. Therefore, this solution also designs a compression method for compressing a SAS data set so that it can be read by SAS software.

[0094] Specifically, the present solution provides a method for compressing a SAS data set, which compresses the SAS data set decompressed in the first embodiment. When a binary compression method is used, the steps are as follows:

[0095] The position of the sliding window of the data to be compressed is taken as the header, and the code value of each byte in the data to be compressed in the ASCII table is taken as the compression value in turn. When multiple consecutive identical bytes appear, the compression values ​​of the current multiple bytes are set according to the reverse deduction of the first analytical formula. When the bytes of the repeated fragment appear, the compression values ​​of the bytes of the repeated fragment are set according to the reverse deduction of the second analytical formula, wherein the first analytical formula is selected from the following:

[0096] When the compressed value is represented as {0i C}, the parsing formula is {(0i+3) C}, where C represents the code value of the byte in the ASCII table;

[0097] When the compressed value is expressed as {1i jj C}, the parsing formula is {(jj*16+1i+3) C}, where C represents the code value of the byte in the ASCII table;

[0098] The second analytical formula is selected from the following:

[0099] When the compressed value is represented as {2i jj kk}, the parsing formula is {count forward (jj*16+i+3) bits, read (kk+16) characters};

[0100] When the compressed value is represented as {ij kk (i>=3)}, the parsing formula is {count forward (kk*16+j+3) bits, read i characters, and repeat}".

[0101] This solution uses binary compression combined with sliding-window compression and run-length encoding to compress the data set, so that the compressed SAS data set is consistent with the file compressed by the SAS software, including but not limited to compression rate, completeness rate and other indicators.

[0102] For example, "string: HELLLLO 1993*SPC" is compressed into the following form according to the reverse decomposition of the first parsing formula: 0x00000207D783F89E 28 00 48 45 01 4c 4f 16 7b 20. 28 00 is the header marking the position of the sliding window, the code value of the letter H in the ASCII table is 48, the letter E is 45, the letter L is 4c, the letter O is 4f, and the space is 20. The original string becomes H, E, L*4, O, space*1993. According to the reverse decomposition of the first parsing formula (01+3=4 letters L), 01 4c, 16 7b 20 is obtained. According to 16*0x7b+0x16+3=16*123+22+3=1993 spaces, 16 7b 20 is obtained.

[0103] For example, the string: "abcdefghijklmnopqrstuvwxyzbcdefghijklmnopqrstuv" is compressed to: "00 00 61 62 63 64 65 66 67 68 ..abcdefgh;696a 6b 6c 6d 6e 6f 70 00 30 ijklmnop.0;

[0104] 71 72 73 74 75 76 77 78 79 7a qrstuvwxyz; 26 01 05 12 02 20", where 00 00 and 00 30 are headers, 61 / 62 / 63 / 64 / 65 / 66 / 67 / 68 / 69 / 70 / 71 / 72 / 73 / 74 / 75 / 76 / 77 / 78 / 79 / 7a represent numbers a to z respectively, and "26 01 05 " means counting forward 16*01+6+3, i.e. 25 bits, and reading 05+16, i.e. 21 bits, according to the second parsing formula, which means counting forward 25 bits and reading 21 characters for compression.

[0105] In other embodiments, when the char compression method is adopted, the steps are as follows:

[0106] Obtain a SAS data set to be compressed, and compress the SAS data set according to the inverse operation of the char decompression rule, wherein the char decompression rule is: sequentially obtain the decompressed length of the data to be decompressed and decompress each byte of the data to be decompressed, split each byte into a high bit and a low bit, and obtain the corresponding case according to the high bit code, convert the byte into the number of cache bytes to be cached according to the case calculation rule, and store the number of cache bytes into the cache area until the parsed length of the data to be decompressed reaches the decompression length. Example

[0107] This embodiment also provides an electronic device, referring to Fig. 9 , including a memory 304 and a processor 302, wherein the memory 304 stores a computer program, and the processor 302 is configured to run the computer program to execute the steps in any one of the above-mentioned methods for decompressing a SAS data set or the methods for compressing a SAS data set.

[0108] Specifically, the processor 302 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0109] The memory 304 may include a large capacity memory 304 for data or instructions. By way of example and not limitation, the memory 304 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 302.

[0110] The processor 302 reads and executes the computer program instructions stored in the memory 304 to implement any one of the methods for decompressing a SAS data set or the method for compressing a SAS data set in the above embodiments.

[0111] Optionally, the electronic device may further include a transmission device 306 and an input / output device 308 , wherein the transmission device 306 is connected to the processor 302 , and the input / output device 308 is connected to the processor 302 .

[0112] The input / output device 308 is used to input or output information. In this embodiment, the input information may be a SAS data set, etc., and the output information may be decompressed data, etc.

[0113] Optionally, in this embodiment, the processor 302 may be configured to perform the following steps through a computer program:

[0114] S1: Obtain a SAS data set to be decompressed; S2: Read file attribute information in the SAS data set, wherein the file attribute information includes a file header, file data information, file creation time, file modification time, file version, and file page number; S3: Read the value of the 5th to 8th bytes of 00010010h of the SAS data set and subtract 1 as the number of loops, and successively take each 12 consecutive bytes after the 8th byte of 00010010h as a loop until all loops of the number of loops are read, read the text offset, loop length, and data identifier of each loop, and select the bytes of the loop length in the corresponding row as the loop content according to the text offset to the corresponding row of the SAS data set, and identify the file format content from the loop content; S4: Determine the composition form of each page according to the number of file pages, determine whether it is compressed data according to the compression identifier of the information outline of the file format content, and locate the data storage content after skipping the bytes of the set value from the 8th byte of 00010010h, and read data from the data storage content according to the file format content of step S3.

[0115] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0116] In general, various embodiments may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that, as non-limiting examples, the boxes, devices, systems, techniques, or methods described herein may be implemented in hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.

[0117] Embodiments of the present invention can be implemented by computer software, which is executable by a data processor of a mobile device, such as in a processor entity, or implemented by hardware, or implemented by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets and / or macros can be stored in any device readable data storage medium, and they include program instructions for performing specific tasks. Computer program products can include one or more computer executable components configured to perform embodiments when the program is running. One or more computer executable components can be at least one software code or a part thereof. In addition, at this point, it should be noted that any box of the logic flow in the figure can represent a program step, or interconnected logic circuits, boxes and functions, or a combination of program steps and logic circuits, boxes and functions. Software can be stored in physical media such as memory chips or storage blocks implemented in processors, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and data variants thereof, CDs. Physical media are non-transient media.

[0118] Those skilled in the art should understand that the technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0119] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for decompressing a SAS data set, characterized in that: Includes steps: S1: Get the SAS data set to be decompressed; S2: Read the file attribute information in the SAS data set, where the file attribute information includes the file header, file data information, file creation time, file modification time, file version, and file page number; S3: read the values ​​of the 5th to 8th bytes of 00010010h of the SAS data set and subtract 1 as the number of loops, and then take each 12 consecutive bytes after the 8th byte of 00010010h as a loop until all loops are read, read the text offset, loop length and data identifier of each loop, and go to the corresponding row of the corresponding SAS data set according to the text offset, select the bytes of the loop length in the corresponding row as the loop content, and identify the file format content from the loop content; S4: judging the composition of each page according to the number of pages in the file, judging whether it is compressed data according to the compression mark of the information outline of the file format content, locating the data storage content after skipping the bytes of the set value from the 8th byte of 00010010h, and reading data from the data storage content according to the file format content of step S3; In step S2, the SASFILE string at line 00000050h in the SAS data set is read as the file header, where the SASFILE string consists of "53 41 53 20 46 49 4c 45"; read the value of the DATA string in the SAS data set 00000090h as the file data information, where the DATA string is represented by 4 consecutive bytes that are not 0; read the value of the file creation time string in the SAS data set 000000a0h as the file creation time, where the file creation time string is represented by 8 consecutive bytes from the 9th to the 16th bytes of the 000000a0h line; read the value of the file modification time string in the SAS data set 000000b0h as the file modification time, where the file modification time string is represented by 8 consecutive bytes from the 9th to the 16th bytes of the 000000b0h line; read the last 8 consecutive bytes in the SAS data set 000000c0h line, if all 8 consecutive bytes are 00, the text version is version 1, otherwise it is version 2; read the first 4 consecutive bytes in the SAS data set 000000d0h line as the file page number; "Identifying file format content in self-loop content" includes the steps of: identifying information outline, index, variable letter, variable text, variable data and variable information, wherein identifying "information outline" includes the steps of: locating the outline row according to the text offset of the first loop, identifying four consecutive F7 bytes in the outline row as the start mark of the information outline, identifying the bytes of the loop length of the first loop after the start mark of the information outline as the loop content, wherein the values ​​of the 17th byte to the 20th byte after the start mark of the information outline are used as the total length of the variable, the values ​​of the 21st byte to the 24th byte after the start mark of the information outline are used as the number of data rows, and the information The values ​​from the 25th byte to the 28th byte after the start of the general outline are used as the number of deleted rows, the values ​​from the 29th byte to the 32nd byte after the start of the general outline are used as the compression identifier, the values ​​from the 33rd byte to the 36th byte after the start of the general outline are used as the number of variables on the first page, the values ​​from the 37th byte to the 40th byte after the start of the general outline are used as the number of variables on other pages, the values ​​from the 49th byte to the 52nd byte after the start of the general outline are used as the data page size, and the values ​​from the 57th byte to the 60th byte after the start of the general outline are used as the total number of data observations on the first page, until the end of the general outline is read; "Identifying index" includes the steps of: locating the index row according to the text offset of the second loop, identifying four consecutive F6 bytes in the index row as the index start mark, identifying the bytes of the loop length of the second loop after the index start mark as the loop content, wherein the values ​​of the first byte to the fourth byte after the index start mark are used as the number of variables, and the values ​​of the fifth byte to the eighth byte after the index start mark are used as the number of indexes; "Identifying variable letters" includes the steps of: locating the variable letter row according to the text offset of the fourth loop, identifying the bytes of the loop length of the fourth loop in the variable letter row as the loop content, and storing the variable letters of the data variables in the loop content into the buffer; "Identifying variable data" includes the steps of: locating the variable data row according to the text offset of the sixth loop, identifying the bytes of the loop length of the sixth loop in the variable data row as the loop content, identifying "FC FF FF" in the variable data row. The value of the first byte to the fourth byte after "FF" minus 8 is used as the variable data displacement length, the value of the ninth byte to the twelfth byte represents the variable data offset, the value of the thirteenth byte to the sixteenth byte represents the variable data length, and the nineteenth byte represents the data type;"Recognizing variable text" includes the steps of: locating the variable text row according to the text offset of the fifth loop, identifying the bytes of the loop length of the fifth loop in the variable text row as the loop content, identifying the values ​​of the first byte to the fourth byte after four consecutive FF bytes in the variable text row minus 8 as the variable text displacement length, the values ​​of the ninth byte to the tenth byte represent the page where the displacement information of the variable text is located, the values ​​of the eleventh byte to the twelfth byte represent the variable text offset, the values ​​of the thirteenth byte to the fourteenth byte represent the variable text length, and locating "FD FF FF" in the loop content according to the page where the displacement information is located. FF" variable text offset start identifier, and locate the first byte after the number of bytes of the variable text offset interval with the variable text offset start identifier as the variable text start byte, identify the byte area consisting of the number of bytes of the continuous variable text length from the variable text start byte as the variable text, and identify the value of the variable text as the name of the variable text; "identify variable information" includes the steps of: identifying each loop from the 8th loop to obtain variable information corresponding to each variable, wherein the text offset in each loop is identified to locate the variable information line, and the bytes of the loop length of each loop in the variable information line are identified as the loop content, and the "FE FB FF" in the variable information line is used as the loop content. FF" is the variable information start mark. The values ​​of the four consecutive bytes starting from the first "0A" byte after the variable information start mark are used as the format information of the variable. The values ​​of the four consecutive bytes starting from the second "0A" byte are used as the informat information of the variable. The values ​​of the two bytes before the "2C" byte are used as the informat text position. The values ​​of the two consecutive bytes starting from the "2C" byte are used as the informat offset. The values ​​of the third and fourth bytes starting from the "2C" byte are used as the informat content length. The values ​​of the six consecutive bytes following the informat content length are used as the format text position, offset and length respectively. The values ​​of the six consecutive bytes following the format length are used as the label text position, offset and length respectively.

2. A method for compressing a SAS data set, characterized in that: Includes steps: The SAS data set obtained by decompressing the SAS data set according to claim 1 is subjected to binary compression: the position of the sliding window of the data to be compressed is taken as the header, and the code value of each byte in the data to be compressed in the ASCII table is taken in turn as the compression value, wherein when multiple consecutive identical bytes appear, the compression values ​​of the current multiple bytes are set according to the reverse deduction of the first analytical formula, and when the bytes of the repeated fragment appear, the compression values ​​of the bytes of the repeated fragment are set according to the reverse deduction of the second analytical formula.

3. A method for compressing a SAS data set, characterized in that: Includes steps: The SAS data set obtained by decompressing the method for decompressing a SAS data set according to claim 1 is subjected to char compression: the SAS data set is compressed according to the inverse operation of the char decompression rule, wherein the char decompression rule is: sequentially obtaining the decompressed length of the data to be decompressed and decompressing each byte of the data to be decompressed, splitting each byte into a high bit and a low bit, and obtaining the corresponding case according to the high bit code, converting the byte into the number of cache bytes to be cached according to the case calculation rule, and storing the number of cache bytes in the cache area until the parsed length of the data to be decompressed reaches the decompressed length.

4. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the method for decompressing a SAS data set according to claim 1 or the method for compressing a SAS data set according to any one of claim 2 and claim 3.

Citation Information

Patent Citations

  • Method for organizing and managing file content and metadata

    CN102693286A

  • Configuration-based Excel data analysis and storage method

    CN114116875A

  • Method and device for rapidly reading MIR information of stdf file compressed by gzip

    CN116226047A

  • System, Method and Structure for generating and using a compressed digital certificate

    US20030041110A1

  • Data file discovery, visualization, and importing

    US8862646B1