A method and device for constructing a large data linked list with self-verification function
By using memory inductive sorting and fingerprint functions to calculate ascending and descending suffix fingerprint values when building a large data linked list, and integrating the verification process, the problem of low verification efficiency of large data linked lists in the existing technology is solved, and efficient linked list construction and verification are achieved. .
Patent Information
- Application Number
- CN202410036277.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-01-10
AI Technical Summary
Existing suffix linked list correctness verification technology is not suitable for large data, especially due to frequent random read operations on external memory, resulting in low computational efficiency.
In the process of building a large data linked list, the string is read from right to left, divided into logical blocks, and the memory inductive sorting and fingerprint functions are used to calculate the ascending and descending suffix fingerprint values. The verification process is integrated to generate the final linked list and verify it. its correctness.
It improves the computational efficiency of correctness verification of large data linked lists, reduces the time overhead of independent verification, and is suitable for large data scenarios.
Smart Images

Figure CN117971826B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and a device for constructing a large data linked list with a self-contained verification function. Background Art
[0002] Suffix lists are singly linked lists formed by linking sorted suffixes according to their positions. They are mainly used in the field of data compression. Given a string T of length n, its corresponding suffix list ψ(T) is an integer array of length n+1. The first element ψ[0] is the head of the list, pointing to the smallest suffix of T. Other elements point to the next suffix position with a greater lexicographic order than the current suffix. The entire suffix list can be traversed based on ψ[0]. The correctness of the suffix list of large data directly determines the correctness and efficiency of the compression process. Therefore, verifying the correctness of the suffix list of large data is an indispensable step in large data compression.
[0003] Existing suffix list correctness verification technology is mainly aimed at small data, including two methods: (1) traversing the entire linked list in memory and comparing the size relationship of adjacent suffixes one by one; (2) integrating correctness verification into the linked list construction process, and performing calculation and verification simultaneously. However, for large data that exceeds the device memory, the string T and its linked list are both stored in the external memory, and the above two methods are not applicable. In theory, the adjacent suffixes in the suffix linked list can be read from the string T according to the suffix linked list pointing relationship, and compared character by character, but this method requires a large number of random read operations to the external memory. Especially for large data, random read operations to the external memory will take a lot of time and have low computational efficiency. Summary of the invention
[0004] In view of the problems of the prior art, the present invention provides a method and a device for constructing a large data linked list with a self-contained verification function. During the construction of the large data linked list, the correctness of the linked list is verified at the same time, and the verification result is given while the linked list is generated. There is no need to perform correctness verification separately, thereby improving the computational efficiency of correctness verification of the large data linked list.
[0005] In order to achieve the above object, the present invention provides the following technical solutions: On the one hand, the present invention provides a method for constructing a large data linked list with a self-contained verification function, comprising:
[0006] Read the string T from the external memory from right to left, retrieve the position where the S* type character appears by comparing the lexicographic order of adjacent characters, and logically divide the string T into multiple blocks based on the device memory size and using the S* type character as a delimiter;
[0007] Scan the string T, count the number of elements in each suffix bucket, and divide the suffix bucket into different suffix bucket blocks according to the device memory size. Each block can be sorted in the memory; the suffix bucket block is composed of continuous suffix buckets, and the data blocks are stored in the external memory; the suffix bucket is composed of suffixes with the same first letter in the suffix array;
[0008] Recursively calculate the order of S* type suffixes of string T by using external memory block inductive sorting, and use fingerprint function to iteratively calculate fingerprint values fp1 and fp2 of ascending and descending S* type suffixes;
[0009] According to the ordered S* type suffixes, the predecessor characters of the L type and S type suffixes of each block of the string T are calculated, and the predecessor characters of the L type and S type suffixes of each block of the string T are sequentially saved in the L and S type predecessor blocks corresponding to each block of the string T; the L and S type predecessor blocks are composed of the predecessor characters of the L and S type suffixes, and are respectively saved in the data blocks of the external memory;
[0010] Traverse the S* type suffix and L type predecessor blocks, use the mini-heap, use the first character of the suffix and the sequence number as the sorting key, sort the L type suffix into the L type suffix bucket block to which it belongs, and save the L* type suffix sequence to external memory;
[0011] Traverse the L* type suffixes and S type predecessor blocks in descending order, use a max-heap, use the first character of the suffix and the sequence number as the sorting key, sort the S type suffixes into the S type suffix bucket block to which they belong, and use the fingerprint function to iteratively calculate the fingerprint value fp3 of the descending S* type suffixes;
[0012] Adopt multi-way merge sort, obtain the order of each suffix from L and S type suffix bucket blocks in lexicographic order, and calculate the pointer domain of the suffix and the suffix linked list block to which it belongs according to the position information of the adjacent suffixes, then sort the suffix linked list blocks according to the position, merge the suffix linked list blocks, and generate the final linked list. During this period, use the fingerprint function to iteratively calculate the fingerprint value fp4 of the ascending S* type suffix;
[0013] Compare the ascending and descending fingerprint values of the S* type suffixes, and give the correctness verification result of the final generated suffix list.
[0014] On the other hand, the present invention also provides a device for constructing a large data linked list with a self-verification function, including: a string preprocessing module, which divides a string T into multiple blocks and divides a suffix bucket into multiple suffix bucket blocks; an S* type suffix sorting module, which sorts the S* type suffixes of the string T and calculates the fingerprint values of the ascending and descending S* type suffixes; a suffix predecessor character calculation module, which is used to calculate the L and S type suffix predecessor characters of each block of the string T, and save them to the corresponding predecessor blocks in the external memory; L type suffix sorting module module, calculates the order of L type suffixes according to the order of S* type suffixes, and saves the L* type suffixes to external memory; S type suffix sorting module, calculates the order of S type suffixes according to the order of L* type suffixes, and calculates the fingerprint values of descending S* type suffixes; suffix linking module, links the suffixes in the L and S type suffix bucket blocks to generate the final suffix linked list, and calculates the fingerprint values of ascending S* type suffixes; verification module, verifies the correctness of the suffix linked list by comparing the fingerprint values of ascending and descending S* type suffixes.
[0015] On the other hand, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements a method for constructing a large data linked list with a self-verification function as described in the first aspect above.
[0016] Compared with the prior art, the present invention has the following beneficial effects:
[0017] The electronic device proposed in the present invention first sorts the S* type suffixes, calculates their ascending and descending fingerprint values, then derives the order of the L and S type suffixes according to the S* type suffixes, merges the two to generate a final linked list, during which the fingerprint values of the ascending and descending S* type suffixes are calculated, and finally the correctness of the linked list is verified by comparing the similarities and differences of the fingerprint values. In the application scenario of calculating the LZ77 factor decomposition of large data, a method for constructing a large data linked list with a self-contained verification function proposed in this embodiment can be adopted, and the correctness verification is integrated into the linked list construction process, without the need for independent verification, which significantly reduces the time overhead of correctness verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 It is a schematic diagram of the storage structure of the suffix array and suffix linked list of the string T provided in the embodiment of the present application;
[0020] Figure 2 It is a schematic diagram of the suffix bucket and suffix bucket block structure of the string T provided in an embodiment of the present application;
[0021] Figure 3 is a schematic diagram of the suffix linked list block structure of the string T provided in an embodiment of the present application;
[0022] Figure 4 It is a flow chart of a method for constructing a large data linked list with a self-verification function provided in an embodiment of the present application;
[0023] Figure 5 It is a schematic diagram of the structure of a device for constructing a large data linked list with a self-verification function provided in an embodiment of the present application;
[0024] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0026] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0027] First, the technical terms that may be used in the embodiments of the present application are uniformly described here.
[0028] String T: consists of n characters, that is, T[1,n] = T[1]T[2]...T[n], where T[n] = '$' is the only minimum character; the substring T[i,n] starting from position i represents the suffix of T starting from i, and is represented by suf(T,i).
[0029] Character and suffix type: including L type and S type. If character T[i]>T[i+1], or T[i]==T[i+1] and T[i+1] is of L type, then T[i] is of L type, otherwise it is of S type. If T[i] is of L type and T[i-1] is of S type, then T[i] is of L* type; if T[i] is of S type and T[i-1] is of L type, then T[i] is of S* type; L* and S* types are subtypes of L and S types respectively. The type of a suffix is the same as the type of the first character of the suffix.
[0030] S*-type substring: It refers to the substring intercepted between two adjacent S*-type characters in string T, including the S*-type characters at the beginning and the end. In an S*-type substring, the substring composed of S*-type characters from one character (except the first character) to the end is called the L- and S-type substring, and its type is the same as the type of the first character of the substring.
[0031] Suffix array SA(T): An integer array of the same length as T, which stores the starting positions of ascending suffixes from left to right.
[0032] Suffix linked list ψ(T): An integer array of length n + 1, where ψ[0] is the head of the linked list, pointing to the smallest suffix of T. If i ≠ n, then ψ[SA[i]] = SA[i + 1]; otherwise, ψ[SA[n]] = 0, that is, the largest suffix suf(T, SA[n]) points to the head of the linked list ψ[0].
[0033] Predecessor character of suffix: The predecessor character of suf(T, i) in T is T[i - 1], and its type is the same as the type of T[i - 1].
[0034] Suffix bucket and suffix bucket block: The suffixes with the same first character in SA(T) form a suffix bucket, and multiple consecutive suffix buckets form a suffix bucket block; in the same suffix bucket, the left side is the L-type suffix bucket, and the right side is the S-type suffix bucket.
[0035] Suffix linked list block: The integer array of the suffix linked list ψ(T) is sliced into multiple blocks of fixed length.
[0036] Karp-Rabin fingerprint function: It calculates the fingerprint value of a string or sequence. The fingerprint value of any length substring or sequence can be calculated iteratively using formulas (1-1) to (1-3). FP(a, b) represents the fingerprint value of the substring or sequence from element a to b. The parameters δ and L are both prime numbers and δ < L. In particular, the larger δ and L are, the lower the error probability. The specific calculation formulas are as follows, where seq is the substring or sequence to be calculated, and seq[p] represents its p-th element.
[0037] FP(0, -1]) = 0 (1-1)
[0038] FP(0, p) = FP(0, p - 1) * δ + Seq[p] mod L (1-2)
[0039] FP(p, q) = FP(0, q) - FP(0, p - 1) * δ q-p+1 mod L (1-3)
[0040] Taking the string T[1, 12] = "hhaappyyaap$" as an example, the above terms are explained as follows:
[0041] See Figure 1 , showing the character types of the string T and the storage structures of SA(T) and ψ(T).
[0042] Figure 1 The third line of... shows the character types of T. For example, the lexicographical order of T
[11] = 'p' is greater than that of T
[12] = '$', so T
[11] is of type L. Since T
[10] is of type S, T
[11] is of type L*. T
[09] = 'a' is the same as T
[10] = 'a', and T
[10] is of type S, so T
[09] is also of type S. Since T
[08] is of type L, T
[09] is of type S*. The string T contains two S* type substrings T[03,09] and T[09,12]; in T[03,09], T[06,09] and T[07,09] are S and L type substrings respectively.
[0043] Figure 1 The fourth line of... shows the storage structure of SA(T), an integer array of length 12. For 1 ≤ i < j ≤ 12, the lexicographical order of suf(T, SA[i]) is smaller than that of suf(T, SA[j]). For example, the lexicographical order of suf(T, SA[2] = 09) is smaller than that of suf(T, SA
[12] = 07), that is, the lexicographical order of the suffix T[09,12] = 'aap$' is smaller than that of the suffix T[07,12] = 'yyaap$'.
[0044] Figure 1 The fifth line of... shows the storage structure of ψ(T). ψ[0] is the head of the linked list, pointing to the smallest suffix suf(T, SA
[01] = 12) of T. ψ[SA
[01] = 12] points to the suffix suf(T, SA
[02] = 09), ψ[SA
[02] = 09] points to the suffix suf(T, SA
[03] = 03), ψ[SA
[03] = 03] points to the suffix suf(T, SA
[04] = 11), and so on until ψ[SA
[12] = 07], which points to the head of the linked list.
[0045] See Figure 2 , showing the storage structures of the suffix buckets and suffix bucket blocks of the string T.
[0046] Figure 2 The third line shows the composition of the suffix buckets of SA(T). SA(T) consists of 5 suffix buckets, namely the '$' suffix bucket located at SA
[01] , the 'a' suffix bucket located at SA[02,05], the 'h' suffix bucket located at SA[06,07], the 'p' suffix bucket located at SA[08,10], and the 'y' suffix bucket located at SA[11,12]; in the 'p' suffix bucket, SA
[08] and SA[09,10] are the L and S type suffix buckets of 'p' respectively.
[0047] Figure 2 The 4th row shows the suffix bucket block of SA(T). SA(T) consists of two suffix bucket blocks, namely the suffix bucket block located at SA[01,05], which consists of suffix buckets of '$' and 'a', and the suffix bucket block located at SA[06,12], which consists of suffix buckets of 'h', 'p', and 'y'.
[0048] join Figure 3 , shows the storage structure of dividing the suffix linked list ψ(T) of string T into multiple suffix linked list blocks. The third line divides the ψ(T) array into linked list blocks of length 3. ψ[01,03], ψ[04,06], ψ[07,09] and ψ[10,12] are the 0th to 3rd suffix linked list blocks of ψ(T) respectively.
[0049] The specific calculation framework of the embodiment of the present application is: first, calculate the order of the S* type suffixes of the string T, and calculate the fingerprint values of the ascending and descending S* type suffixes at the same time; then, according to the order of the S* type suffixes, calculate the order of the L type and S type suffixes, and calculate the fingerprints of the descending S* type suffixes at the same time; finally, calculate the link information of the L and S type suffixes, merge the two types of suffixes to generate a final linked list, calculate the fingerprint value of the ascending S* type suffix, and give the final verification result by comparing the ascending and descending fingerprint values.
[0050] The technical solution of the present application is described below through specific embodiments.
[0051] Reference Figure 4 , shows a schematic flow chart of steps of a method for constructing a large data linked list with a self-verification function provided in an embodiment of the present application, which may specifically include the following steps:
[0052] S401, read the string T from the external memory from right to left, compare the lexicographic order of adjacent characters, retrieve S* type characters, and logically divide the string T into multiple blocks using the S* type characters according to the memory size;
[0053] In an embodiment of the present application, the block size of the string T is determined according to the memory size of the device, and the specific block principle is: each block can be summarized and sorted in the device memory, unless the block is composed of an S* type substring that exceeds the memory size.
[0054] In an embodiment of the present application, the step of logically dividing the string T into multiple blocks includes: (1) determining whether the character currently read is of the S* type, if not, reading the next character, otherwise proceeding to the next step; (2) calculating the length of the S* type substring starting from the current S* type character, if the current block length plus the current S* type substring length exceeds the device memory, the current block is a new block of the string T, otherwise the current block should include the current S* type substring, and the above steps are continued until the reading process is completed.
[0055] S402, scan the string T, calculate the number of elements in each suffix bucket, and combine the suffix buckets into multiple suffix bucket blocks according to the device memory size;
[0056] In the embodiment of the present application, the step of combining the suffix buckets into a suffix bucket block includes: (1) reading the string T once, and using an integer array with a length of 256 to count the number of elements in each suffix bucket; (2) accumulating the number of elements in each suffix bucket from left to right. If the size of the current suffix bucket block plus the current suffix bucket exceeds the device memory size, the current suffix bucket block is a new suffix bucket block. Otherwise, the current suffix bucket block should include the current suffix bucket, and accumulation continues to the right until the suffix bucket ends.
[0057] In the embodiment of the present application, the purpose of dividing the string T into multiple blocks and dividing the suffix bucket into multiple suffix bucket blocks is mainly to simulate memory inductive sorting to achieve external memory block inductive sorting of large data.
[0058] S403, recursively call the external memory block inductive sorting to sort the S* type suffixes, traverse the S* type suffixes in ascending and descending order respectively, and use the fingerprint function to iteratively calculate the ascending and descending fingerprint values thereof;
[0059] In an embodiment of the present application, the step of recursively calling the external memory block inductive sorting to sort the S* type suffixes includes: (1) Problem contraction stage: Scan the string T, retrieve the S* type substrings, sort and name the S* type substrings using the external memory block inductive sorting method, and generate a new string T1; (2) Recursive judgment stage: If the characters of T1 are not unique, execute recursion; (3) Inductive solution stage: According to the already ordered S* type suffixes, use the external memory block inductive sorting method to sort the L and S type suffixes in turn. When the recursive process is executed to the inductive solution stage of the 0th level, the ascending or descending S* type suffix sequence of the string T can be calculated based on the suffix array SA(T1) of the string T1.
[0060] In an embodiment of the present application, the step of inductive sorting of the external memory blocks includes: (1) dividing the string T into multiple blocks and dividing the suffix array SA(T) into multiple suffix bucket blocks; (2) calculating the L and S type predecessor blocks corresponding to each block of the string T; (3) using a mini-heap according to each L type suffix bucket block and predecessor block, using the first character of the suffix and the sequence number as the sorting key, and sorting the L type suffixes into the corresponding L type suffix bucket block; (4) using a max-heap according to each S type suffix bucket block and predecessor block, using the first character of the suffix and the sequence number as the sorting key, and sorting the S type suffixes into the corresponding S type suffix bucket block; (5) using a multi-way merge sort, and obtaining each suffix from the L and S type suffix bucket blocks one by one in ascending or descending order.
[0061] In an embodiment of the present application, the process of calculating the ascending or descending S* type suffix fingerprint value is: traversing the S* type suffix in ascending and descending order, and using the Karp-Rabin fingerprint function formulas (1-1) to (1-3) to iteratively calculate the fingerprint values fp1 and fp2 of the ascending and descending S* type suffixes.
[0062] S404, according to the ordered S* type suffix, sequentially calculate the L and S type predecessor blocks corresponding to each block of the string T;
[0063] In the embodiment of the present application, the specific process of calculating the L and S type predecessor blocks of each block of the string T is to perform the following steps on each block of the string T in turn: (1) i Read into memory, using T i Initialize the S type suffix bucket with the ascending S* type suffix of the block; (2) traverse each suffix bucket from left to right, and use the memory inductive sorting method to sort the L type predecessors of the traversed suffixes to the current block T i The corresponding L-type predecessor block; (3) traverse each suffix bucket from right to left, and use the memory inductive sorting method to sort the S-type predecessors of the traversed suffixes into the current block T. i The corresponding S-type predecessor block.
[0064] S405, traverse the S* type suffixes and L type predecessor blocks, sort the L type suffixes into corresponding L type suffix bucket blocks, and save the L* type suffixes in ascending order to external memory;
[0065] In the embodiment of the present application, the process of sorting the L-type suffixes into the corresponding L-type suffix bucket blocks is to use the small top heap HP1, use the first character of the suffix and the sequence number as the sorting key, read the top suffix of the heap in sequence, and write it to the corresponding L-type suffix bucket block. The specific steps are as follows: (1) Initialize HP1 to be empty, the sequence number id = 0, read the current smallest L-type suffix bucket block into the memory array Y, whose elements are two-tuples<chr,pos> , chr and pos represent the first character and position of the suffix respectively, and Y is sorted in stable ascending order; (2) traverse the suffix buckets of array Y and S* type suffix in ascending order. For the same suffix bucket, the traversal order is S* type suffix, array Y and HP1. For the currently traversed suffix e=<chr,pos> Perform the following operations: Calculate whether the predecessor of e is of type L. If so, read the predecessor character chr0 from the predecessor block corresponding to e. If the predecessor belongs to the current suffix bucket block, replace the predecessor tuple e0=<chr0,pos-1,id++> Push e0 into HP1, otherwise write e0 to its corresponding L-type suffix bucket block; if the predecessor of e is of type S, append e to the end of the L*-type suffix sequence LStar; (3) Continue to execute the above steps for the next L-type suffix bucket block until all L-type bucket blocks have been traversed.
[0066] S406, traverse the L* type suffix sequence LStar and the S type predecessor block in descending order, sort the S type suffixes into the corresponding S type suffix bucket blocks, and calculate the fingerprint value fp3 of the descending S* type suffix;
[0067] In the embodiment of the present application, the process of sorting the S-type suffixes into the corresponding S-type suffix bucket blocks is to use the large top heap HP2, use the first character of the suffix and the sequence number as the sorting key, read the top suffix of the heap in sequence, and write it to the corresponding S-type suffix bucket block. The specific steps are as follows: (1) Initialize HP2 to be empty, the sequence number id = n, read the current largest S-type suffix bucket block into the memory array Y, whose elements are two-tuples<chr,pos> , sort Y in stable descending order; (2) traverse the array Y and each suffix bucket of the L* type suffix sequence LStar in descending order. For the same suffix bucket, the traversal order is array Y, LStar and HP2. For the currently traversed suffix e=<chr,pos> Perform the following operations: Calculate whether the predecessor of e is of type S. If so, read the predecessor character chr0 from the predecessor block corresponding to e. If the predecessor belongs to the current suffix bucket block, replace the predecessor tuple e0=<chr0,pos-1,n--> Push it into HP2, otherwise write e0 to its corresponding S-type suffix bucket block; if the predecessor of e is of type L, use the Karp-Rabin fingerprint function formulas (1-1) to (1-3) to iteratively calculate the fingerprint value fp3 of the descending S* type suffix; (3) Continue to perform the above steps on the next S-type suffix bucket block until all S-type bucket blocks are traversed.
[0068] S407, taking each suffix from the L and S type suffix bucket blocks in lexicographic order, calculating its link information, generating a final linked list, and calculating the fingerprint value fp4 of the ascending S* type suffix during this process;
[0069] In the embodiment of the present application, the specific steps of generating the final linked list are as follows: (1) using multi-way merge sorting, each suffix is taken out from the L-type suffix bucket block and the S-type suffix bucket block in lexicographic order; (2) according to the order relationship of the two adjacent suffixes, the pointer domain of the suffix is calculated, and according to the position of the suffix, the suffix is sorted to the suffix linked list block to which it belongs; (3) if the current suffix is of S* type, the fingerprint value fp4 of the ascending S* type suffix is iteratively calculated using the Karp-Rabin fingerprint function formulas (1-1) to (1-3); (4) the suffixes in the suffix linked list block are sorted by position, and the suffix linked list blocks are merged from left to right to generate the final linked list.
[0070] In the embodiment of the present application, the calculation process of the suffix pointer field and the suffix linked list block is as follows: Assume that the length of the suffix linked list block is K, e1, e2 and e3 are three suffixes taken out in sequence, when e2 is taken, the pointer field of e1 is set to e2.pos, and the tuple of e1 is constructed<e1.pos,e2.pos> , and save it to the e1.pos / Kth suffix linked list block, where e1.pos and e2.pos are the positions of e1 and e2 respectively; when e3 is obtained, the pointer field and suffix linked list block of e2 are calculated; and so on, until the last suffix is obtained, its pointer field is set to 0, that is, pointing to the head of the linked list.
[0071] S408. Compare the fingerprint values of the ascending and descending S* type suffixes in steps S403, S406 and S407 to verify the correctness of the final linked list.
[0072] In the embodiment of the present application, the process of verifying the correctness of the final linked list is as follows: if the fingerprint value fp1 in step S403 is the same as the fingerprint value fp4 in step S408, and the fingerprint value fp2 in step S403 is the same as the fingerprint value fp3 in step S407, then the final linked list is correct, otherwise it is wrong.
[0073] Reference Figure 5 , shows a schematic diagram of the structure of a device for constructing a large data linked list with a self-verification function provided in an embodiment of the present application, which may specifically include the following modules:
[0074] The string preprocessing module 501 is used to read the string T from the external memory of the electronic device from left to right, retrieve the S* type character by comparing the dictionary order of adjacent characters, and divide the string T into multiple blocks using the S* type character according to the size of the device memory; at the same time, count the size of each suffix bucket of the string T, and divide the suffix bucket into multiple suffix bucket blocks according to the size of the device memory;
[0075] The S* type suffix sorting module 502 is used to recursively use the external memory block induction sorting method to sort the S* type suffixes of the string T, traverse the S* type suffixes in ascending and descending order, and use the Karp-Rabin fingerprint function to iteratively calculate the fingerprint values of the ascending and descending S* type suffixes;
[0076] The suffix predecessor character calculation module 503 is used to read each block of the string T into the memory in sequence, and calculate the L and S type predecessor blocks corresponding to each block of the string T using the memory inductive sorting method;
[0077] The L-type suffix sorting module 504 calculates the L-type suffix bucket block of the string T according to the S*-type suffix and the L-type predecessor block using the external memory block induction sorting method, and writes the L*-type suffix to the external memory;
[0078] The S-type suffix sorting module 505 calculates the S-type suffix bucket blocks of the string T according to the L*-type suffix and the S-type predecessor blocks using the external memory block induction sorting method, and uses the Karp-Rabin fingerprint function to iteratively calculate the fingerprint values of the descending S*-type suffixes;
[0079] The suffix link module 506 uses an external memory multi-way merge sort to obtain each suffix from the L and S type suffix bucket blocks in lexicographic order, calculates the link information of each suffix, sorts each suffix into the suffix linked list block to which it belongs, sorts and merges each linked list block to generate a final linked list, and uses the Karp-Rabin fingerprint function to iteratively calculate the fingerprint value of the ascending S* type suffix;
[0080] Verification module 507 compares the fingerprint values of the ascending and descending S* type suffixes in modules 502, 505 and 506 to see if they are the same, and gives a verification result of the final linked list.
[0081] Reference Figure 6 The embodiment of the present application also discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements a method for constructing a large data linked list with a self-verification function as described in the aforementioned embodiments.
[0082] The electronic device 600 may be the electronic device in the above-mentioned embodiments, and the electronic device may be a computing device such as a desktop computer, a cloud server, etc. The electronic device 600 may include, but is not limited to, a processor 610 and a memory 620. Those skilled in the art will understand that Figure 6 It is only an example of the electronic device 600 and does not constitute a limitation of the electronic device 600. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 600 may also include input and output devices, network access devices, buses, etc.
[0083] The processor 610 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0084] The memory 620 may be an internal storage unit of the electronic device 600, such as a memory of the electronic device 600. The memory 620 may also be a pluggable external storage device of the electronic device 600, such as a pluggable hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 600. Further, the memory 620 may also include both an internal storage unit of the electronic device 600 and an external storage device. The memory 620 is used to store the computer program 621 and other programs and data required by the electronic device 600. The memory 620 may also be used to temporarily or permanently store data that has been output or is to be output.
[0085] The terms used in the drawings to describe positional relationships are only used for illustrative purposes and should not be construed as limiting this patent;
[0086] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for constructing a large data linked list with a self-contained verification function, characterized in that: include: Read the string T from the external memory from right to left, retrieve the position where the S* type character appears by comparing the lexicographic order of adjacent characters, and logically divide the string T into multiple blocks based on the device memory size and using the S* type character as a delimiter; Scan the string T, count the number of elements in each suffix bucket, and divide the suffix bucket into different suffix bucket blocks according to the device memory size, and complete the inductive sorting of each block in the memory; the suffix bucket block is composed of continuous suffix buckets, and the data blocks stored in the external memory; the suffix bucket is composed of suffixes with the same first letter in the suffix array; Recursively call the external memory block inductive sorting to calculate the order of the S* type suffixes of the string T, and use the fingerprint function to iteratively calculate the fingerprint values fp1 and fp2 of the ascending and descending S* type suffixes; According to the ordered S* type suffix, the predecessor characters of the L type suffix and the predecessor characters of the S type suffix of each block of the string T are calculated, and the predecessor characters of the L type suffix and the predecessor characters of the S type suffix are sequentially saved to the L type predecessor blocks and the S type predecessor blocks corresponding to each block of the string T; the L type predecessor blocks and the S type predecessor blocks are composed of the predecessor characters of the L type suffix and the S type suffix, and are respectively saved in the data blocks of the external memory; The traversed S* type suffixes and L type predecessor blocks are divided into small top heaps, and the first character of the suffix and the sequence number are used as sorting keywords to sort the L type suffixes into the suffix bucket blocks to which they belong, and the L* type suffix sequence is saved to external memory; The process of sorting the L-type suffixes into the suffix bucket blocks to which they belong: using the mini-heap HP1, taking the first character of the suffix and the sequence number as the sorting key, reading the top suffixes of the heap in sequence, and writing them into the corresponding L-type suffix bucket blocks, includes the following steps: (1) initializing the mini-heap HP1 to be empty, the sequence number id=0, reading the current smallest L-type suffix bucket block into the memory array Y, whose elements are two-tuples<chr, pos> , chr and pos represent the first character and position of the suffix respectively, and sort the array Y in a stable ascending order; (2) traverse the array Y and each suffix bucket of the S* type suffix in ascending order. For the same suffix bucket, traverse the S* type suffix bucket, array Y and mini-heap HP1 in turn. For the currently traversed suffix e=<chr, pos> , if its predecessor is of type L, read its predecessor character chr0 from its corresponding predecessor block; if the predecessor belongs to the current suffix bucket block, replace the predecessor tuple e0=<chr0, pos-1, id++> Push it into HP1, otherwise write the predecessor tuple e0 to its corresponding L-type suffix bucket block; if the predecessor of the suffix e is of type S, append the suffix e to the end of the L*-type suffix sequence LStar; (3) Continue to perform the above steps on the next L-type suffix bucket block until all L-type bucket blocks are traversed; Traverse the L* type suffixes and S type predecessor blocks in descending order, use a max-heap, use the first character of the suffix and the sequence number as the sorting key, sort the S type suffixes into the suffix bucket block to which they belong, and use the fingerprint function to iteratively calculate the fingerprint value fp3 of the descending S* type suffixes; The process of sorting the S-type suffixes into the suffix bucket blocks to which they belong: using the max-heap HP2, taking the first character of the suffix and the sequence number as the sorting key, reading the top suffixes of the heap in sequence, and writing them into the corresponding S-type suffix bucket blocks, includes the following steps: (1) initializing the max-heap HP2 to be empty, with the sequence number id=n, reading the current largest S-type suffix bucket block into the memory array Y, whose elements are two-tuples<chr, pos> , sort the array Y in stable descending order; (2) traverse the array Y and each suffix bucket of the L* type suffix sequence LStar in descending order. For the same suffix bucket, traverse the array Y, the L* type suffix sequence LStar and the max-heap HP2 in turn. For the currently traversed suffix e=<chr, pos> , if its predecessor is of type S, read its predecessor character chr0 from its corresponding predecessor block; if the predecessor belongs to the current suffix bucket block, replace the predecessor tuple e0=<chr0, pos-1, id--> Push it into the max-heap HP2. Otherwise, write the predecessor tuple e0 to its corresponding S-type suffix bucket block. If the predecessor of the suffix e is of type L, use the Karp-Rabin fingerprint function to iteratively calculate the fingerprint value fp3 of the descending S*-type suffix. (3) Continue to perform the above steps on the next S-type suffix bucket block until all S-type bucket blocks have been traversed. Adopt multi-way merge sort, obtain each suffix from L and S type suffix bucket blocks in lexicographic order, and calculate the pointer domain of the suffix and the suffix linked list block to which it belongs according to the position information of the adjacent suffixes, then sort the suffix linked list blocks according to the position, merge the suffix linked list blocks, and generate the final linked list. During this process, use the fingerprint function to iteratively calculate the fingerprint value fp4 of the ascending S* type suffix; The calculation process of the suffix pointer field and the suffix linked list block is as follows: Assume that the length of the suffix linked list block is K, e1, e2 and e3 are three suffixes taken out in sequence, when e2 is taken, the pointer field of e1 is set to e2.pos, and the tuple of e1 is constructed.<e1.pos,e2.pos> , and save it to the e1.pos / Kth suffix linked list block, where e1.pos and e2.pos are the positions of e1 and e2 respectively; when e3 is obtained, the pointer field and suffix linked list block of e2 are calculated; and so on, until the last suffix is obtained, its pointer field is set to 0, pointing to the head of the linked list; The process of merging the suffix chain list blocks to generate the final chain list first sorts the suffixes in the suffix chain list blocks by position, and then merges the suffix chain list blocks in sequence from left to right to obtain the final chain list; Compare the S* type suffix ascending fingerprint values fp1 and fp4 and the S* type suffix descending fingerprint values fp2 and fp3, and give the correctness verification result of the final generated suffix linked list.
2. The method according to claim 1, characterized in that The specific steps of generating the final linked list are as follows: (1) using multi-way merge sort, take out each suffix from the L-type suffix bucket block and the S-type suffix bucket block in lexicographic order; (2) according to the order relationship between two adjacent suffixes, calculate the pointer domain of the suffix, and sort the suffix to the suffix linked list block to which it belongs according to the position of the suffix; (3) if the current suffix is of S* type, use the Karp-Rabin fingerprint function formula to iteratively calculate the fingerprint value fp4 of the ascending S* type suffix; (4) sort the suffixes in the suffix linked list block by position, merge the suffix linked list blocks from left to right, and generate the final linked list.
3. A device for constructing a large data linked list with a self-verification function, applied to the method for constructing a large data linked list according to claim 1, characterized in that: include: The string preprocessing module divides the string T into multiple blocks and divides the suffix bucket into multiple suffix bucket blocks; The S* type suffix sorting module sorts the S* type suffixes of the string T and calculates the fingerprint values of the ascending and descending S* type suffixes; the suffix predecessor character calculation module is used to calculate the L type suffix predecessor characters and the S type suffix predecessor characters of each block of the string T, and save them to the corresponding predecessor blocks in the external memory; the L type suffix sorting module calculates the order of the L type suffixes according to the order of the S* type suffixes, and saves the L* type suffixes to the external memory; The S-type suffix sorting module calculates the order of the S-type suffixes according to the order of the L*-type suffixes, and calculates the fingerprint values of the descending S*-type suffixes; the suffix linking module links the suffixes in the L-type suffix bucket block and the S-type suffix bucket block to generate the final suffix linked list, and calculates the fingerprint values of the ascending S*-type suffixes; the verification module verifies the correctness of the suffix linked list by comparing the fingerprint values of the ascending S*-type suffixes with the fingerprint values of the descending S*-type suffixes.
4. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for constructing a large data linked list with a self-verification function as described in claim 1 is implemented.
