Method and system for searching compressed data

Abstract: A method and system for searching a compressed document while a plurality of character strings stored in the compressed document are stored in a compressed code. A query request is received, the query request is converted into the compressed code, and the converted query request is compared with the compressed codes stored in the compressed document. The initiator of the query request is then informed about the results of the comparison.

Description: Technical Field This invention relates generally to a computer method and system for searching data in a computer. Background of the Invention The electronic collection and storage of information presents problems in many environments. For example, when data is downloaded from an information service to a remote computer, vast amounts of data are transferred in a short interval. The remote computer typically stores this data in a computer memory for later processing. To reduce the amount of data transferred by the information service, the amount of data stored by the remote computer, and the time required for transmission of the data, the information service typically compresses the data before transmitting the data to the remote computer. Compression methods generally fall into two categories: fixed length compression methods and variable length compression methods. Fixed length compression methods represent each symbol by the same number of bits. For example, the LZ 78 type of Ziv-Lempel coding is a fixed length compression method. Variable length compression methods represent each symbol by a varying number of bits. Variable length compression methods typically assign shorter codes to more frequently used symbols. For example, the well-known Morse code is a variable length compression method. Existing systems convert the compressed code representing the data back into its uncompressed form and then process the uncompressed data if it is desired to search through the data. Searching through uncompressed data is known from "The Art of Computer Programming - Volume 3/Sorting and Searching" by Donald E.Knuth (ISBN 0-201-03803-X). This requires a time consuming decompression step. It would be desirable to have a search method which allows for the more efficient searching of data that has been compressed. Summary of the Invention The present invention provides a method and system for searching a compressed document as defined in claims 1 and 2. Brief Description of the Drawings Figure 1 is a block diagram of a system embodying the present invention for searching for character strings in a compressed document while the character strings are stored in a compressed code. Figure 2 is a block diagram of a sample document. Figure 3 is a block diagram of the uncompressed codes of the sample document. Figure 4 is a block diagram of a query request displayed on a display device for the system of Figure 1. Figure 5 is a block diagram of the character string parsed from the query request. Figure 6 is a block diagram of a variable length compressed code for the system of Figure 1. Figure 7A is a block diagram of a dictionary with variable length compressed codes for a host computer of the system of Figure 1. Figure 7B is a block diagram of a dictionary with variable length compressed codes for a remote computer of the system of Figure 1. Figure 8 is a block diagram of a compressed document of the variable length compressed codes as it is stored in the memory of the system of Figure 1. Figure 9 is a block diagram of variable length compressed codes representing the character string from the query request. Figures 10, 11, 12, and 13 are block diagrams illustrating searching for the query request in the variable length compressed code. Detailed Description of the Invention As shown in Figure 1, the present invention is embodied in a computer system 100 and a method executed in the computer system which converts character strings in an uncompressed document 101 from an uncompressed code to a compressed code, stores the character strings in their compressed code in a compressed document 103 in response to a user request, and searches for character strings in the compressed document 103 while the character strings remain stored in their compressed code. The System: The computer system 100 comprises a host computer keyboard 105, a host computer mouse 107, a host computer 109, a remote computer keyboard 111, a remote computer mouse 113, a remote computer 115, and a communications channel 117 to transmit data between the host computer 109 and the remote computer 115. In the host computer 109, documents can be stored in their uncompressed form and then when requested by the remote computer 115, the documents can be compressed and transmitted via the communications channel 117 to the remote computer 115. At the remote computer 115 the documents need not be uncompressed before a query can be processed against the documents. The host computer 109 further includes a central processing unit 119, an input/output unit 121, and a host computer memory 123. In addition, the host computer memory 123 stores a dictionary 125, the uncompressed document 101, a parser 127, when executing on the central processing unit 119, a compression engine 129, and the compressed document 103. The parser 127 retrieves character strings from the uncompressed document 101. The retrieved character strings from the uncompressed document 101 are in the uncompressed code. A typical uncompressed code is the ASCII code which represents each character as an 8 bit string of zeros and ones. The compression engine 129, when executing on the central processing unit 119, converts the uncompressed character string to a compressed character string using the dictionary 125. In an embodiment, the compressed character string is represented as a variable length compressed code. The compression engine 129, when executing on the central processing unit 119, then stores the compressed character string in the compressed document 103. An example of the general operation of the computer system 100 (Figure 1) will illustrate how the present invention searches for character strings in the compressed document 149 on the remote computer 115 while the character strings are stored in the compressed code of the present invention. An embodiment of the present invention converts character strings in an uncompressed document 101 from an uncompressed code to a variable length compressed code, stores the character strings in their variable length compressed code in a compressed document 103, and searches for character strings in the compressed document 103 while the character strings remain in their variable length compressed code. Figure 6 shows the preferred variable length compressed code of the present invention which includes a length indicator 2601 and a compressed code 2603. The length indicator 2601 indicates the number of bits in the compressed code 2603. For example, the length indicator 2601 shown in Figure 6 contains a binary number equivalent to the decimal value three, indicating that the compressed code 2603 illustrated in Figure 6 is three bits in length. Specific Example For Embodiment Using Variable Length Compressed Codes: A specific example using Figures 2-3, 4-5, and 6-13 will help illustrate the preferred method and system for searching variable length compressed codes of the compressed document 103. Typically, a user of the remote computer 115 inputs a request to transfer the uncompressed document 101 from the host computer 109 to the remote computer 115. Figure 2 shows the uncompressed document 101 displayed on the host computer display device 163. Figure 3 shows the uncompressed document 101 as it is stored in the host computer memory 123. In response to the transfer request, the host computer 109 invokes the compression engine 129 which converts the uncompressed document 101 to the compressed document 103 containing variable length compressed codes. To convert the uncompressed document 101 into the compressed document 103, the compression engine 129 invokes the parser 127 which parses uncompressed character strings stored in the uncompressed document 101 and sends the parsed character strings back to the compression engine 129. The compression engine 129 receives from the parser 127 the parsed character string in its uncompressed code. Then the compression engine 129 finds a match for the uncompressed code in the dictionary 125 (Figure 2A) and retrieves from the dictionary 125 a variable length compressed code associated with the matched uncompressed code. Finally, the compression engine 129 stores the retrieved variable length compressed code from the dictionary 125 in the compressed document 103. After every character string from the uncompressed document 101 has been converted to the variable length compressed code of the present invention and stored in the compressed document 103, the host computer 109 transfers the compressed document 103 from the host computer 109, over the communications channel 117, to the remote computer 115 where it is stored as the compressed document 149. Figure 8 shows the compressed document 149 as it is stored in the remote computer memory 143. A user of the remote computer 115 typically inputs a query in order to retrieve information about the compressed document 149. Figure 4 illustrates a typical query request 165 which was entered on the remote computer keyboard 111 and later stored in the remote computer memory 143. The query request 165 asks "what documents contain the word 'ready'?" In response to receiving the query request 165, the remote computer 115 invokes the query engine 147. The query engine 147 retrieves the word to search for from the query request 165; in this case the query engine 147 retrieves the word "ready" from the query request 165 (see Figure 5). Next, the query engine 147 invokes the convert program 161 which converts the word "ready" to the variable length compressed code of the present invention. The convert program 161 searches the dictionary 145 to see if there is a match with the word "ready". When the convert program 161 determines that the dictionary 145 does not contain the word "ready", it searches the dictionary 145 for the first two characters from the word "ready", i.e., the character string "re". When the convert program 161 determines that the character string "re" is stored in the pairs section 153 of the dictionary 145, it retrieves the compressed code 0110000010 associated with the character string "re". The convert program 161 then stores the retrieved compressed code in the remote computer memory 143 (see Figure 9). Next, the convert program 161 removes the first two unprocessed characters from the word "ready", i.e., the character string "ad". When the convert program 161 determines that the character string "ad" is stored in the pairs section 153 of the dictionary 145, it returns the compressed code 10100000000010 associated with the character string "ad". The convert program 161 then stores the retrieved compressed code in the remote computer memory 143 (see Figure 9). Finally, the convert program 161 determines that only one unprocessed character remains from the word "ready" , i.e., the character "y". The convert program 161 retrieves the compressed code 1111000000000000100 stored in the ASCII section 155 of the dictionary 145. The convert program 161 then stores the retrieved compressed code in the remote computer memory 143 (see Figure 9). Upon completion of the conversion of the word "ready" to the variable length compressed code of the present invention, the query engine 147 invokes the search program 159 which searches the compressed document 149 for occurrences or compressed codes representing the word "ready". The search program 159 first retrieves the compressed code for the character string "re" (Figure 9). Then the search program 159 determines the length of the compressed code 2901 for the character string "re", from the value of the length indicator 2903 for the character string "re". In this case the length indicator 2903 indicates that the compressed code 2901 is 6-bits in length. The search program 159 then sets an indicator named Match-ptr to the first variable length compressed code in the compressed document 149 (see Figure 10). By determining the length of the compressed code 2901, the search program 159 need only compare the compressed code 2901 against compressed codes in the compressed document 149 with identical lengths. The search program 159 then compares the value of the length indicator 3001 for the character string "Firstcap" with the value of the length indicator 2903 for the character string "re". Because the value of the length indicator 2903 is equal to six and the value of the length indicator 3001 is equal to twelve, the search program 159 determines that the compressed code 2901 is not a match for the compressed code 3003. Therefore, the search program 159 increments Match-ptr and compares the length indicator 2903 of the character string "re" with the length indicators of the character strings pointed to by Match-ptr, until a match is found. Figure 11 illustrates the position of Match-ptr within the compressed document 149 when a match with the length indicator 2903 for the character string "re" occurs. The search program 159 then compares the compressed code 2901 for the character string "re" with the compressed code 3103 for the character string pointed to by Match-ptr, and determines that a match is found. Now that a match for character string "re" has been found, the search program 159 proceeds to determine if the next two variable length compressed codes stored in the compressed document 149 match the character string "ad" and the character string "y", respectively. The search program 159 increments Match-ptr and compares the length indicator 2905 (Figure 9) for the character string "ad" with the length indicator 3201 (Figure 12) for the character string pointed to by Match-ptr. Because the value of the length indicator 2905 equals the value of the length indicator 3201, the search program 159 compares the compressed code 2907 of the character string "ad" with the compressed code 3203 for the character string pointed to by Match-ptr. Because a match occurs between the compressed codes, the search program 159 increments Match-ptr and compares the length indicator 2909 of the character string "y" with the length indicator 3301 for the character string pointed to by Match-ptr (Figure 13). Because the value of the length indicator 2909 for the character string "y" equals the value of the length indicator 3301 for the character string pointed to by Match-ptr, the search program 159 compares the compressed code 2911 for the character string "y" with the compressed code 3303 for the character string pointed to by Match-ptr. Because a match occurs, the query engine 147 informs the initiator of the request that the compressed document 149 contains the word "ready". Those of ordinary skill in the art will understand that other system architectures can be used to implement the method of the present invention described above, including, but not limited to, astand alone computer which compresses an uncompressed document and which performs a search on the compressed document. Those of ordinary skill in the art will also understand that the method and apparatus of the present invention can be used in conjunction with other compression methods. It will be appreciated that, although a specific embodiment of the invention has been described herein for purposes of illustration, various modifications may be made without departing from the scope of the invention. Accordingly, the invention is not limited except as by the appended claims.

Claims: An apparatus for searching a compressed document comprised of a plurality of variable length compressed codes which represent an uncompressed document, each variable length compressed code having a length indicator which indicates the length of the variable length compressed code, the apparatus comprising: means for receiving a query request in an uncompressed code; means for converting the query request from the uncompressed code into a converted query request of one of the plurality of variable length compressed codes; means for determining the length of the converted query request; means for comparing the converted query request with the variable length compressed codes of the compressed document, to determine if variable length compressed codes of the compressed document match the converted query request, wherein the converted query request is only compared with those variable length compressed codes whose length is equal to the length of the converted query request, and means for responding to the determination that there is a match between the variable length compressed codes of the document and the converted query request. A method for searching a compressed document comprised of a plurality of variable length compressed codes which represent an uncompressed document, each variable length compressed code having a length indicator which indicates the length of the variable length compressed code, the method comprising the steps of: receiving a query request in an uncompressed code; converting the query request from the uncompressed code into a converted query request of one of the plurality of variable length compressed codes; means for determining the length of the converted query request; comparing the converted query request with the variable length compressed codes of the compressed document, to determine which variable length compressed codes of the compressed document match the converted query request, wherein the converted query request is only compared with those variable length compressed codes whose length is equal to the length of the converted query request; and responding to the determination that there is a match between the variable length compressed codes of the compressed document and the converted query request.

Inventors: ELLER MARLIN JAY, ELLER, MARLIN JAY
Applicants: MICROSOFT CORP, MICROSOFT CORPORATION
Application year: 1994
Main classification: G06F17
IPC codes: G06F17, H03M7