METHOD OF OPTIMIZING AN N-GRAM MEMORY STRUCTURE

Abstract: By placing a low cardinality node (1084) or a leaf in a lower level (841), and a high cardinality node (620) or a leaf at a higher level (409), an optimal memory structure is automatically generated which yields the best compression within N-gram technology. After making an initial list of parallel streams or fields, the streams are ordered in accordance with increasing cardinality. Adjacent streams (fields), or nodes (L and LC), are paired (4383), and the children of the resulting node are eliminated from the list, while a new parent node (5432) is added to the list. The resulting new list (112) is re-arranged from right to left (817) as a function of increasing cardinality, and the pairing steps are repeated until a single root node remains for the final memory (8554).

Description: METHOD OF OPTIMIZING AN N-GRAM MEMORY STRUCTURE Field of the Invention This invention relates generally to data compression of the type wherein an input data body is converted into an ordered data structure and, in particular, to a method of analyzing the cardinality of the input data body for the purpose of optimizing the structure. Background of the Invention This invention resides in certain improvements to subject matter set forth in commonly assigned U.S. Patent Nos. 5,245,337 and 5,293, 164, both of which are entitled DATA COMPRESSION WITH PIPELINE PROCESSOR HAVING SEPARATE MEMORIES, and U.S. Patent No. 5,592,677, entitled METHOD OF STORING COMPRESSED DATA FOR ACCELERATED INTERROGATION. The first two patents describe a general system for implementing a loss-less compression technique with superior compression ratios. The method described there was fast and the storage scheme for the transformed data permitted efficient and fast searches to be performed. The effective search on the transfonned data was the subject of U.S. Patent No. 5.592.667, where queries could be solved on the compressed data itself. without the need to decompress the data first. The NGRAM transform is unique in that the data itself forms the index, and the high compression ratio means that input-output rates are no longer the bottle neck in solving queries. The raw input data consisting of M parallel streams, are basically transfonned into a multi-level n-ary memory structure (also called memory structures) as described in Patent Nos. 5,245,337 and 5,293, 164. The memory structure will have at most M leaf nodes, where a leaf node is defined as a node with no children. Each leaf node consists of the unique values that occur in that stream, along with a count of (he number of repeated occurrences of that value. The total number of unique values (also called memories) that occurs is defined as the cardinality of that node. Similarly, each non-leaf node of the memory structure, consisting of n children (leaf or non-leaf) nodes, stores the unique combination of the n events of its children. In other words, as the raw data stream progress from the bottom to the top of the memory structure, each leaf node conesponds to the unique values in the M streams and each n-ary node stores the various combinations of the n streams that are the children of that node. Clearly, when multiple streams of data have to be combined as described above to form an NGRAM hierarchical memory structure, the topology of the memory structure is not unique. It is therefore meaningful to talk about an optimum/best memory structure topology for the memory structure. In order to do that, an optimality criterion must be specified. The technique discussed in this submission will optimize the memory structures for maximum compression. Since non-terminal nodes with more than 2 children require a more complicated storage scheme, and because the storage scheme will have a direct impact on search times, the algorithm presented here considers the case of a strictly binary memory structure; i.e. n=2. Summary of the Invention The fundamental idea behind the optimization can be understood by interpreting the meaning of each non-tenninal node in the n-ary memory structure. In the case of a binaiy structure, each interior node of the NGRAM memory structure stores the unique combination of the joint events of its two children. Therefore, the size of an interior node is minimized when the number of unique combinations (patterns) of events that the node represents (by definition - the cardinality of the node) is minimized. Note that each terminal (leaf) node is already maximally compressed, since they represent unique occuπences of single (as opposed to binaiy events for non-tenninal nodes) events in the data stream. It follows that the entire memory structure has minimum size when the sum of the cardinalities of all the nodes in the memory structure is minimized. Note that it is possible to use other metrics according to the invention as an optimality criterion to produce (possibly) different tree structures. For instance, the entropy of the node can be used to minimize the size of the node, with the overall memory structure having minimum entropy. Correlation coefficients and mutual information may alternatively be utilized. The problem is complicated by the fact that in order to find the most compact representation of the memory structures, across all possible combinations of nodes, leads to combinatorial explosion. Hence, any naive search for the best structure fiom among all possible combinations requires an exhaustive consumption of computing resources. It is therefore unrealistic to expect such a naive search to find the optimal topology for anything other than small values of M. Thus, there is a need for an efficient technique that achieves this optimality while using reasonable computing resources. The present invention provides a method for automatically determining the optimum multi-level memoiy structure(s), to maximize compression, within an NGRAM environment. Using cardinality as the optimality criterion, the method places a low cardinality node or a leaf at lower levels, while placing a high cardinality node or a leaf at higher levels in the memory structure. The leaf nodes of the memoiy structure are first built by processing the raw data as described in U.S. Patent Nos. 5,245,337 and 5,293, 164. The streams which are to be optimized into a memoiy structure, are then placed in a list in order of increasing cardinality, fiom right to left (i.e. the smallest cardinalities are found at the right of the list). Beginning at the right, the first stream (field/node) is paired with a stream (field/node) on the immediate left with the next smallest cardinality to form a parent node. The children of the resulting parent node are eliminated fiom the list, while the new parent node is added to the list. The resulting new list is re-ananged fiom right to left as a function of increasing cardinality, and the pairing steps are repeated, recursively, fiom the right, until a single root node remains for the final structure or memoiy structure. Pattern optimization is perfoπned implicitly in the above pairing procedure in a sub-list while topology optimization is canned out by repeatedly ordering the modified lists fiom right to left with respect to increasing cardinality. In a prefeπ ed embodiment, optimized pairing is obtained by pairing the first leaf or node on the right with the one next to it on the left, with the result being paired with the next leaf or node on the left. The resulting two nodes are then compared and the process is repeated until first node exhibits reduced cardinality. This local optimization achieves the minimum variational difference between two neighboring nodes. A curve is made of cardinalities by pairing the right-end field or node in the list with each node or field on its left. In general, the curve has high cardinality on the left and low cardinality on the right, and has minimum cardinality in the neighborhood of the right end. Brief Description of the Drawings FIGURE 1 represents, in the fonn of a flowchart, the overall method of the invention; FIGURE 2 is an example of the invention using four fields and 8554 records; FIGURE 3A is a memoiy structure utilizing seven fields and 32,844 records: FIGURE 3B is a list of the cardinalities associated with the structure of Figure 3 A, indicating where node replacement has taken place according to the invention, FIGURE 4A is a is a memoiy structure utilizing seven fields and 32,844 records; and FIGURE 4B is a list of the cardinalities associated with the stπicture of Figure 4A. indicating where node replacement has taken place according to the invention. Detailed Description of the Invention As discussed above in the Background, the present invention builds upon N-gram compression techniques disclosed in commonly assigned U.S. Patent Nos. 5,245,337; 5,293, 164; and 5,592,667, the entire contents of each of which is incorporated herein by reference The variational problem for a discrete system, such as an NGRAM memoiy structure representing a database, reduces to finding an optimal structure in which the nodes of the memory structure have the fewest number of memories. This is equivalent to finding the local minimum of the memory structure function, which represents the parent node cardinality as a function of its children nodes. This can be done by setting the partial difference of the memoiy structure function with respect to each individual node equal to zero. Recognizing that the amount of computing resources (memory. CPU. and disk) used to build an NGRAM memoiy structure is proportional to the total cardinality of the memoiy structure, minimizing the cardinality of each node would also minimize the computing resources used. When the local minimum is not unique (two pairs yielding the same cardinality), the algorithm arbitrarily picks out the first pair that has that cardinality. This may lead to some sub-optimal structures because the cardinality at lower levels of the memoiy structures will affect the cardinality at higher levels, and consequently the entire memory structure itself. Note however that finding the optimum structure in this case would, in the limit, be equivalent to an exhaustive search, and veiy expensive, if not impossible, to obtain. The major concern for optimality in the case of database compression is to find an optimal NGRAM memoiy structure from among many possible combinations of patterns or memory structure topologies. For N parallel streams (fields or columns in a table), there are N- 1 nodes in an N-gram memory structure. And, at a given level in an N-gram memoiy structure, there are only n- 1 pattern combinations for the n nodes. The total number of pattern combinations is the multiple of the number of pattern combinations in all levels of the N-gram memoiy structure. For example, a symmetric N-gram memoiy stπicture consisting of 8 fields contains 7*5*3 = 105 total patterns. A symmetric memoiy structure of 16 fields contains 15* 13* 1 1 *9*7*5*3 = 2,027,025 patterns. If one wants to find a particular pattern among 2 million different combinations, and one wants to deteπnine a minimum total cardinality for any N-gram memory structure, one would use an infinite amount of CPU time during a naive exhaustive search for such pattern. The problem of finding the optimal N-gram memoiy structure becomes more complicated when different N-gram memoiy structure topologies are taken into account. In this case, for each pattern, there can be a number of possible topologies. In particular, when N is even, the number of possible topologies is exactly: n_{ 2N } =n_ l *n_{ 2N- I }+n_2*ιι_ { 2N-2 } +n_ 3*n_ ! 2N-3 j + ... + n_ { N ) *n_ { N } . where il l = 11 2 = n_3 = 1 , and N = 2,3.4,5.... Similarly, the number of possible topologies for 2N+1 (odd number of) fields is exactly: n_{2N+ 1 }=ιι_1 *n_{2N}+n_2*n_{2N- l }+ιι_3*n_{2N-2}+ ... + n_{N+ l } *ιι_{N} . For example, if N = 8. 9, and 10 fields, then there are. respectively. 24. 47. 103. distinct topologies. Tlie total number of possible N-gram memoiy stmctures is obtained by multiplying the total number of possible patterns by the total number of different topologies. Tlie present invention builds upon discrete N-gram compression technology. In one embodiment, the method places a low cardinality node or a leaf in a lower level, while placing a high cardinality node or a leaf at a higher level. Tl e procedure for finding the optimal structure is then as follows: 1. Make an initial list of parallel streams (fields); 2. Older the leaves of these streams fiom right to left according to increasing cardinality; 3. Beginning on the right, pair the first stream (field), or node, with a stream (field), or node, to its left; 4. Eliminate the children of this node from the list, and add the new parent node to the list; 5. Reanange the resultant new list fiom right to left by increasing cardinality; 6. Reapply the steps 3 and 4, recursively, until a single root node remains for the resulting memoiy stπicture. Pattern optimization is perfonned implicitly in the above optimization procedure in a sub-list while topology optimization is canned out by repeatedly ordering the modified lists right to left with respect to increasing cardinality. In step 3, the optimized pairing is obtained in the following way: Pair the first leaf or node on the right with the one next to it on the left. Pair the first leaf with the next leaf or node on the left. Compare the two nodes. Stop pairing if the first node has less cardinality or keep the second node and continue to step (b) otherwise. Tlie above local optimization achieves the minimum variational difference between two neighboring nodes. A curve is made of cardinalities by pairing the right-end field or node in the list with each node or field on its left. In general, the curve has high cardinality on the left and low cardinality on the right, and has minimum cardinality in the neighborhood of the right end. The above local optimization obtains this minimum cardinality in an efficient manner. Tlie entire procedure is depicted in Figure 1, wherein Cni is the cardinality of node n-i; del n 1, nj means delete nodes ni and nj fiom the list; add Ni means add a new parent mode, Ni, to the list; pair (ni,nj) -> Nij means pair two nodes n 1 and nj to fonn the parent node Nij. Reference will be made to the flow diagram of Figure 1 to illustrate examples of the method in use. Reference is made to Figure 2, which illustrates an example having four fields and 8554 records. Tlie fields are last name (L) having a cardinality of 1084; middle-name (M) having a cardinality of 841 ; zip-code (Z) having a cardinality of 620; and city (C) having a cardinality of 409. As shown in Step 1. the fields are first sorted in tenns of cardinality with the greatest cardinality on the left in accordance with block 104 in Figure 1. Next, the two rightmost nodes, Z and C, are paired, resulting in a cardinality ZC of 817 in accordance with block 106 of Figure 1. As i is not equal to m. a query is made at block 1 10: is 817 less than 841 , the cardinality of node M? Since the answer to this question is affinnative, the search for the first minimum node tenninates, and nodes Z and C are deleted and replaced with node ZC in accordance with block 1 1 1 of Figure 1. Tlie value of m is decremented, and since it is not yet less than 2, the nodes are again resorted in accordance with block 104 as shown in Step 2 of Figure 2, resulting in a sort. from left to right of 1084, 841 , and 817. Tlie process described above is repeated, that is, nodes M and ZC are paired. which exhibits a cardinality MZC of 5432, and this is compared to the cardinality of node L. However, in this case, as 5432 is not less than 1084, the procedure drops down to block 1 12 in Figure 1 , causing nodes L and ZC to be paired into node LZC having a cardinality of 4383. Now, in accordance with block 1 14, the cardinality of node MZC is compared to node LZC and, since 5432. the cardinality of node MZC. is not less than 4383, a query is made at decision block 1 16 as to whether or not i+ 1 is equal to m. In this case, the answer is true, such that, at block 1 17. node n (ZC) and node i+ 1 ( ) are deleted, and a new parent N li+ 1 is added, which has a cardinality of 8554. As this resulted fiom the pairing of the last two nodes, the procedure exits, and the cardinality 8554 is representative of the root of the resulting memory structure, as shown in Step 4. Now making reference to Figure 3, there is presented a somewhat more complex example involving seven fields and 32,844 records. Part A of the figure shows the memoiy structure resulting fiom the procedure depicted in the flowchart of Figure 1. In part B of Figure 3, the cardinalities associated with the pairing steps are shown, with a checkmark being used to show where a new parent node has been created as a result of the method. By following the procedure depicted in the flow diagram of Figure 1 , increasingly complex input streams may be accepted, as shown in Example 3 of Figure 4. COMPARISON TO HUFFMAN CODING This invention is similar, in spirit, to Huffman coding, though there exist fundamental differences. First, Huffman coding works a single infonnation source. That is the sum of cardinalities of all leaves is a constant while the sum of cardinalities of all single patterns or all single information sources is a variable. One symbol at a given time can only be one of the leaves in the case of single infonnation source. Second, with the Huffman coding for a single information source, all parent nodes have fixed probabilities once the two children's probabilities are known. Tlie probability of a given node is simply the sum of those of the two children. Therefore, it is trivial to sort nodes in tenus of probability since the parent node has static probability On the other hand, the cardinality of a given non-leaf node in an N-gram memoiy structure is dynamic and can be anything between the maximum cardinally of the two children and the multiple of the cardinalities of the two children. OPTTMALITY PROOF A proper theory to explain the method is the theory for multiple infonnation sources Given: c i < c j or c i - c_j < 0, and 1 i ' 1J or l_i - 1J -> O; assume H = - .. ->- c i 1 i -r- ... -i- c_j 1 i + ... 1 = minimum while H' = ... + cj 1 j + ... + c_j l_i + ... - minimum obtained by swapping i and j. Therefore, if the assumption above were time H - H or H - H' 0. Howevei, H - I-r = cj(M-IJ) + c (lj-l i) = (l_i-lj)(c_i-c j). Since 1 i - l_j 0 and c i - cj 0 as given, we obtain 11 - I I' -- 0. Hence, the assumption is wrong, c i is the cardinality of ith node and 1 i is the height of ith node. Tlie height here means the level difference between the root node as level 0 and a node in a given level. Since c i is the total number of unique patteπis at node i, c il-i is the total length to store c i unique patteπis in N-gram pattern . Q . representation or multiple infonnation representation. Consequently, FI is the total length to store all unique patteπis, or all single and multiple infonnation sources, in an N-gram memoiy stnicture, and it is the average height of the memoiy structure if unique patteπis are normalized. That claimed is:

Claims: 1. A method of organizing a multi-level memoiy stnicture having an upper root end with lower nodes and branches representative of parallel data fields to be compressed, the method comprising the steps of: eliminating the data fields at each lower branch or node, as the case may be. and replacing the parent node for that level with one of the lower branches or nodes in accordance with an optimality criterion; and repeating the above step until reaching the upper root end. 2. The method of claim 1, wherein the optimality criterion is entropy. 3. The method of claim 1, wherein the optimality criterion is based upon coπelation coefficients. 4. The method of claim 1 , wherein the optimality criterion is based upon mutual infonnation. 5. Tlie method of claim 1, wherein the optimality criterion is cardinality. 6. Tlie method of claim 5, further including the step of ordering the data fields as a function of increasing cardinality prior to the step of replacing the data fields each time the step is perfoimied. 7. The method of claim 1, wherein the multi-level memoiy structure is a binaiy tree structure, and wherein the data fields at each level are adjacent data fields. 8. A method of arranging an N-gram data structure to maximize the compression thereof, the method comprising the steps of: (a) receiving a set of parallel data fields to be compressed; (b) ordering the set as a function of increasing cardinality, if not already so ordered; (c) comparing adjacent fields of lowest cardinality to create a new parent node; (d) replacing the adjacent fields with the new parent node; and (e) repeating steps (b) through (d) until only a single node remains in the set. 9. Tlie method of claim 8, wherein step (c) further includes that steps of: (i) pairing the nodes of lowest cardinality; (ii) pairing the result of (i) with the node of next greater cardinality; (iii) comparing the results of (i) and (ii); and (iv) discontinue the process if the result of (i) has less cardinality than that of (ii), otherwise, retain the result of (ii). 10. A method of aπanging an N-gram data structure to maximize the compression thereof, the method comprising the steps of: (a) inputting m leaf nodes; (b) sorting the nodes in teπns of increasing cardinality as follows: Cn l < Cn2 < ... < Cnm where Cn I is the cardinality of node n- 1 ; (c) pairing nodes n 1 and ni to create a new parent node N li; (d) exiting if i = m; otherwise: (e) comparing the cardinality of node Nli with that of ni+1 and, if the cardinality of node N Ii is less than the cardinality of node ni+ 1 : (i) deleting nodes n 1 and ni, (ii) adding node N li to the structure, and (iii) decrementing in, and exiting if m < 2: otherwise: (iv) returning to step (b), above; otherwise: (f) pairing nodes n 1 and ni+ 1 to create a new parent node N 1 i+ 1 ; (g) comparing the cardinality of node N li with that of Ni-H and, if the cardinality of node N I i is less than the cardinality of node Ni+ 1. repeating steps (i) to (iii) above; otherwise. (h) ifi+1 is equal to m: (v) deleting nodes n 1 and ni+ 1 , (vi) adding node N li+ 1 to the stnicture, and (vii) returning to step (iii), above; otherwise: (i) comparing the cardinality of node Nli+ 1 with that of ni+2 and, if the cardinality of node N li+ 1 is less than the cardinality of node ni+2, repeating steps (v) to (vii) above, otherwise: (j) setting i=i+ 1 and returning to step (f), above.

Inventors: BUGAJSKI JOSEPH M, RAGHAVAN K R, ZHANG TAO, BUGAJSKI, JOSEPH, M., RAGHAVAN, K., R., ZHANG, TAO
Applicants: TRIADA LTD, TRIADA, LTD.
Application year: 1998
Main classification: G06F17
IPC codes: G06F17, H03M7