Database data compression method, electronic device, storage medium and program product
By segmenting database row records and constructing a high-frequency word matrix, and using mutually exclusive hierarchical dictionary tree grouping and Huffman coding, the problem of semantic loss and insufficient compression rate in database compression is solved, and more efficient data compression and querying are achieved. performance.
Patent Information
- Application Number
- CN202410759266.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-13
AI Technical Summary
Existing database compression methods suffer from semantic loss in Chinese search data, have insufficient compression rates, and are not adapted to the processing of database scenarios.
By word segmenting the database row records, a high-frequency word matrix is constructed, the target mutually exclusive phrases are determined, the row records are grouped based on the mutually exclusive hierarchical dictionary tree, and dictionary node encoding is used to generate compressed block data, and Huffman coding is used for data compression. .
It improves the compression rate, reduces redundant data reading during query, reduces storage space costs, improves input, output and computing performance, and is suitable for computing acceleration of hardware acceleration devices.
Smart Images

Figure CN118332011B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer systems and big data technology, and in particular to a database data compression method, an electronic device, a storage medium and a program product. Background Art
[0002] Compressed storage is a technology that reduces the amount of data through a specific algorithm. It can compress a large amount of original data into a smaller volume, thereby saving storage space. Compressed storage is also often used in databases for data compression and data query. However, the current compressed storage has semantic loss for Chinese search data; compression is based on the original order of the data, which is not suitable for processing in database scenarios, resulting in insufficient data compression rate. Summary of the invention
[0003] In view of the above problems, embodiments of the present invention are proposed to provide a database data compression method, an electronic device, a storage medium and a program product that overcome the above problems or at least partially solve the above problems.
[0004] In order to solve the above problems, in a first aspect of the present invention, an embodiment of the present invention discloses a database data compression method, comprising:
[0005] Segment the database rows and build a high-frequency word matrix based on the segmentation statistics;
[0006] Based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases;
[0007] Grouping the database row records based on the target mutually exclusive phrase;
[0008] Optionally, the database data compression method further includes:
[0009] The mutually exclusive hierarchical dictionary tree is constructed according to the database row records.
[0010] Optionally, the step of constructing the mutually exclusive hierarchical dictionary tree according to the database row records includes:
[0011] Constructing a general dictionary of phrases according to the database row records;
[0012] A mutually exclusive hierarchical dictionary tree is determined based on the phrase total dictionary.
[0013] Optionally, the step of constructing a general phrase dictionary based on the database row records includes:
[0014] Split the character string in the database row record to generate initial phrases;
[0015] Performing word frequency statistics on the initial word group to determine the word frequency corresponding to the initial word group;
[0016] According to the frequency of the word, the initial word group corresponding to the word frequency is Huffman encoded to generate the total word group dictionary.
[0017] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary includes:
[0018] Extracting high-frequency words from the total word dictionary to determine high-frequency word groups;
[0019] Constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases;
[0020] A mutually exclusive hierarchical dictionary tree is determined based on the common root dictionary and the mutually exclusive dictionary set.
[0021] Optionally, the step of constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases includes:
[0022] According to each of the high-frequency phrases, construct a high-frequency word truth value matrix;
[0023] Accumulating the high-frequency word truth value matrix row by row to generate a high-frequency word accumulation matrix;
[0024] Constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix;
[0025] The mutually exclusive dictionary set is constructed according to the row data of the high-frequency word accumulation matrix.
[0026] Optionally, the step of constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix includes:
[0027] Calculate the cumulative sum and variance of the column data of the high-frequency word accumulation matrix;
[0028] In the high-frequency word accumulation matrix, high-frequency word groups whose cumulative sum is greater than a preset first threshold and whose variance is less than a preset second threshold are removed to obtain a target high-frequency word accumulation matrix;
[0029] The high-frequency word group in the target high-frequency word accumulation matrix is determined as the common root dictionary.
[0030] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix includes:
[0031] Determine the high-frequency phrase group corresponding to the preset target value of the row data of the high-frequency word accumulation matrix as the target high-frequency phrase group;
[0032] In the high-frequency word accumulation matrix, determining mutually exclusive words, strongly associated words, and weakly associated words corresponding to the target high-frequency word group;
[0033] A corresponding dictionary is established based on the mutually exclusive words and the strongly associated words to generate the mutually exclusive dictionary set.
[0034] Optionally, the step of determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency word group in the high-frequency word accumulation matrix includes:
[0035] Determine the index position value of the target high-frequency phrase;
[0036] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is greater than a preset third threshold as the mutually exclusive word;
[0037] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is less than a preset fourth threshold as the strongly associated word;
[0038] Determine that the high-frequency word group whose row number in the high-frequency word accumulation matrix is less than a preset fifth threshold is a weakly associated word.
[0039] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix further includes:
[0040] The weakly associated words are deleted from the high-frequency word accumulation matrix.
[0041] Optionally, the method further comprises:
[0042] The weakly associated words are compressed independently.
[0043] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set comprises:
[0044] Build the common root dictionary as a first-level dictionary;
[0045] Grouping the mutually exclusive dictionary sets;
[0046] The grouped mutually exclusive dictionary set is constructed as a secondary dictionary;
[0047] The first-level dictionary and the second-level dictionary are combined to generate the mutually exclusive hierarchical dictionary tree.
[0048] Optionally, the step of determining at least one set of target mutually exclusive phrases from the database row records based on the high-frequency word matrix includes:
[0049] Based on the high-frequency word matrix, the database row records are traversed to determine the at least one group of target mutually exclusive phrases.
[0050] Optionally, the step of grouping the database row records based on the target mutually exclusive phrases includes:
[0051] For each of the target mutually exclusive phrases, the database row records having the target mutually exclusive phrases are grouped into the same group.
[0052] Optionally, the step of replacing the database row record for each group with the corresponding dictionary node code to generate compressed block data includes:
[0053] For each group of words in the database row record, replace them with the corresponding dictionary node code to generate coded data;
[0054] The coded data is compression-coded to generate compressed block data.
[0055] Optionally, the step of compressing and encoding the encoded data to generate compressed block data includes:
[0056] The encoded data is subjected to dictionary Huffman encoding to generate the compressed block data.
[0057] Optionally, the step of replacing the phrases in the database row records of each group with corresponding dictionary node codes to generate compressed block data further includes:
[0058] The compressed block data of different groups are merged to generate data block data.
[0059] Optionally, the step of merging the compressed block data of different groups to generate data block data includes:
[0060] Determining meta information of the compressed block data of the different groups; the meta information is located at an index position of the compressed block data;
[0061] The compressed block data and corresponding meta information of the different groups are merged to generate data block data.
[0062] Optionally, the method further comprises:
[0063] The row meta information of the database row record is established according to the meta information.
[0064] Optionally, the step of establishing row meta information of the database row record according to the meta information includes:
[0065] Determining a row record access frequency of a database row record of a compressed block corresponding to the meta information;
[0066] In response to the row record access frequency being lower than a preset access threshold, performing the determining of the meta information of the compressed block data of the different groups;
[0067] In response to the row record access frequency being not lower than a preset access threshold, the meta information of the compressed block data of the different groups is combined to generate the row meta information.
[0068] Optionally, the database data compression method further includes:
[0069] receiving a search instruction, wherein the search instruction carries a search mutually exclusive phrase;
[0070] Determines the target row records that match the search mutually exclusive phrase.
[0071] Optionally, the step of determining a target row record matching the mutually exclusive phrase to be searched includes:
[0072] Determine the data block whose index position matches the search mutually exclusive phrase as the target data block;
[0073] Determine the row record corresponding to the target data block as the target row record.
[0074] Optionally, the database data compression method further includes:
[0075] Determine a row record count value corresponding to the target row record;
[0076] The row record count value is fed back.
[0077] Optionally, the database data compression method further includes:
[0078] Decompress the target row record.
[0079] Optionally, the target row record corresponds to a decompression priority; the decompression priority corresponds to the mutually exclusive phrase;
[0080] The step of decompressing the target row record comprises:
[0081] Determine the decompression priority of the target row record;
[0082] In response to the decompression priority being the first priority, preferentially decompressing the data block corresponding to the target row record;
[0083] In response to the decompression priority being the second priority, the data block corresponding to the target row record is conventionally decompressed.
[0084] Optionally, the method further comprises:
[0085] Get historical search terms; hot search terms are input search terms;
[0086] Perform word frequency statistics on the historical search terms to determine hot search terms;
[0087] Grouping database row records matching the hot search term into the same group;
[0088] The database row records that do not match the hot search term are divided into another same group.
[0089] In the second aspect of the present invention, an embodiment of the present invention discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the database data compression method as described above when executed by the processor.
[0090] In a third aspect of the present invention, an embodiment of the present invention discloses a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the database data compression method described above are implemented.
[0091] In a fourth aspect of the present invention, an embodiment of the present invention discloses a computer program product, including computer instructions, which implement the steps of the database data compression method as described above when executed by a processor.
[0092] The embodiments of the present invention include the following advantages:
[0093] The embodiment of the present invention performs word segmentation on database row records, and constructs a high-frequency word matrix according to word segmentation statistics; obtains the database row records; determines at least one group of target mutually exclusive phrases from the database row records based on a mutually exclusive hierarchical dictionary tree, wherein the mutually exclusive hierarchical dictionary tree has a multi-level mutually exclusive word dictionary node, and the mutually exclusive word dictionary node includes mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases; groups the database row records based on the target mutually exclusive phrases; and replaces the target mutually exclusive phrases with corresponding dictionary node codes for each grouped database row record to generate compressed block data. By utilizing the storage location of the data row records and the characteristics of not affecting the query results in a database-oriented scenario, similar row records are grouped and compressed, which can not only improve the compression rate, but also reduce the redundant data reading during the query, thereby reducing the query delay. Less storage space is used, and the method has the characteristics of sequential decompression, which is more suitable for hardware acceleration devices to perform calculation acceleration. The storage space cost of the database server is reduced while the input, output and computing performance are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0094] Figure 1is a flowchart of a method for compressing database data according to an embodiment of the present invention;
[0095] Figure 2 is a flowchart of another database data compression method embodiment of the present invention;
[0096] Figure 3 is a flowchart of the steps of constructing an example of a general dictionary of phrases of the present invention;
[0097] Figure 4 It is a schematic diagram of a word segmentation example of the present invention;
[0098] Figure 5 is a schematic diagram of an example of word frequency statistics of the present invention;
[0099] Figure 6 is a schematic diagram of an example of Huffman coding of an initial phrase of the present invention;
[0100] Figure 7 is a schematic diagram of a phrase after Huffman encoding of the present invention;
[0101] Figure 8 It is a comparative schematic diagram of a phrase before and after Huffman coding of the present invention;
[0102] Fig. 9 is a flowchart of the steps of constructing an example of a mutually exclusive hierarchical dictionary tree of the present invention;
[0103] Fig.10 It is a schematic diagram of constructing a mutually exclusive hierarchical dictionary tree of the present invention;
[0104] Fig.11 is a flowchart of steps of a data compression example of the present invention;
[0105] Fig.12 The data compression diagram of the present invention is Figure 1 ;
[0106] Fig.13 The data compression diagram of the present invention is Figure 2 ;
[0107] Fig.14 is a flowchart of steps of a data search example of the present invention;
[0108] Fig.15 It is a data search schematic diagram of the present invention;
[0109] Fig.16 is a flowchart of an example of a method for compressing database data of the present invention;
[0110] Fig.17 is a structural block diagram of an electronic device provided by an embodiment of the present invention;
[0111] Fig.18 is a structural block diagram of a storage medium provided by an embodiment of the present invention;
[0112] Fig.19 It is a structural block diagram of a computer program product provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0113] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0114] Reference Figure 1 , shows a flowchart of a method for compressing database data according to an embodiment of the present invention, wherein the method for compressing database data may specifically include the following steps:
[0115] Step 101, segment the database row records, and build a high-frequency word matrix based on the segmentation statistics;
[0116] When data in a database needs to be compressed, the database row records can be obtained. The database row records store and manage data values corresponding to the database table structure. The database row records are segmented, and the frequency of each segmented word is counted after the segmentation to build a high-frequency word matrix.
[0117] Step 102, based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases;
[0118] The mutually exclusive hierarchical dictionary tree has multiple levels of mutually exclusive word dictionary nodes, each of which includes a mutually exclusive word group and a dictionary node code corresponding to the mutually exclusive word group.
[0119] Based on the high frequency word matrix, mutually exclusive word groups of each mutually exclusive word dictionary node in the mutually exclusive hierarchical dictionary tree can be used to determine at least one set of target mutually exclusive word groups from database row records, and the target mutually exclusive word groups are matched with the mutually exclusive word groups in the mutually exclusive hierarchical dictionary tree.
[0120] Step 103, grouping the database row records based on the target mutually exclusive phrase;
[0121] Then, based on each target mutually exclusive phrase, database row records in the database having the same target mutually exclusive phrase are classified; and based on all target mutually exclusive phrases, the database row records can be grouped.
[0122] Step 104: replace the database row records of each group with the corresponding dictionary node code to generate compressed block data.
[0123] For each grouped database row record, the phrase in the database row record is replaced with the corresponding dictionary node code, and then the entire database row record is converted into the form of dictionary node code for recording to generate compressed block data.
[0124] The embodiment of the present invention performs word segmentation on database row records, and constructs a high-frequency word matrix according to word segmentation statistics; obtains the database row records; determines at least one group of target mutually exclusive phrases from the database row records based on a mutually exclusive hierarchical dictionary tree, wherein the mutually exclusive hierarchical dictionary tree has a multi-level mutually exclusive word dictionary node, and the mutually exclusive word dictionary node includes mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases; groups the database row records based on the target mutually exclusive phrases; and replaces the target mutually exclusive phrases with corresponding dictionary node codes for each grouped database row record to generate compressed block data. By utilizing the storage location of the data row records and the characteristics of not affecting the query results in a database-oriented scenario, similar row records are grouped and compressed, which can not only improve the compression rate, but also reduce the redundant data reading during the query, thereby reducing the query delay. Less storage space is used, and the method has the characteristics of sequential decompression, which is more suitable for hardware acceleration devices to perform calculation acceleration. The storage space cost of the database server is reduced while the input, output and computing performance are improved.
[0125] Reference Figure 2 , shows a flowchart of another database data compression method embodiment of the present invention, the database data compression method may specifically include the following steps:
[0126] Step 201, construct the mutually exclusive hierarchical dictionary tree according to the database row records.
[0127] The phrases recorded in the database row records in the database can be extracted and combined to construct a mutually exclusive hierarchical dictionary tree.
[0128] In an optional embodiment of the present invention, the step of constructing the mutually exclusive hierarchical dictionary tree according to the database row records includes:
[0129] Sub-step S2011, constructing a general phrase dictionary according to the database row records;
[0130] Corresponding to the construction of mutually exclusive hierarchical dictionary trees, a total word dictionary can be constructed based on the word groups in the database row records.
[0131] Specifically, the step of constructing a total phrase dictionary based on the historical row records includes: segmenting the character strings in the database row records to generate initial phrases; performing word frequency statistics on the initial phrases to determine the word frequencies corresponding to the initial phrases; and performing Huffman encoding on the initial phrases corresponding to the word frequencies based on the word frequencies to generate the total phrase dictionary.
[0132] In the embodiment of the present invention, the character string in the historical line record can be segmented into multiple phrases, namely, initial phrases. The segmentation method can be segmented according to the part of speech, such as dividing the phrases according to the nouns, verbs, adjectives, prepositions, etc. in the sentence. A neural network model for phrase classification can also be used, and the specific neural network model type is not limited.
[0133] Then, the frequency of the initial phrase is counted to determine the frequency of the initial phrase, that is, the frequency of the initial phrase. According to the frequency, the initial phrase corresponding to the frequency is Huffman coded, and the initial phrase with higher frequency is represented by a shorter code, while the initial phrase with lower frequency is marked with a longer code, and a total phrase dictionary is generated.
[0134] You can refer to Figure 3 , split the string in the row record into phrases. Perform word frequency statistics on the phrases after word segmentation. Count the number of times each phrase appears in the text. Use the Huffman tree to encode the phrases and build a total phrase dictionary. By performing Huffman encoding on the initial phrases, the dictionary stores semantic phrase texts, thereby retaining the original semantics.
[0135] In order to make the construction process of the phrase dictionary more clear to those skilled in the art, an example is used to illustrate the process below:
[0136] You can refer to Figure 4 , record the text in the database, and segment the sentences according to the word groups. Then, statistics are collected for the initial word groups after segmentation. Figure 5 As shown, the word frequencies of all the initial phrases are counted.
[0137] like Figure 6 As shown in the figure, based on the statistical word frequency, the initial phrase is Huffman encoded. The higher the word frequency, the closer it is to the root node of the Huffman tree, and the fewer encoding bits are used to construct the Huffman tree. The phrase is mounted on the leaf node of the Huffman tree. Figure 6 The leaf nodes are represented by boxes, and the boxes contain phrases (word frequencies) [compressed coding]. The compression coding rules use the Huffman tree coding method, that is, starting from the root node, the right is 1, and the left is 0 until a leaf node is encountered. Figure 7 As shown, for Figure 4By performing Huffman coding on the data in the dictionary, a total dictionary of phrases represented by the code can be obtained. The original text can be represented by the code in the dictionary. Since the dictionary code uses fewer bits to represent it, the data compression effect is improved. As shown in Figure 8, the original text has 12 characters (including the carriage return character \n). Using UTF-8 (encoding method), each Chinese character requires 24 bits to represent (3 bytes). It takes a total of 288 bits (36 bytes) to store the original text. After using the compression code in the dictionary, only 27 bits are needed to represent the line of data, so it can achieve the effect of compressed storage. At the same time, the data corresponding to the dictionary code is a text with semantics, which can better provide retrieval of the content of the compressed data packet.
[0138] Sub-step S2012, determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary.
[0139] After obtaining the phrase general dictionary, a mutually exclusive hierarchical dictionary tree is determined based on the phrase index relationship in the phrase general dictionary.
[0140] In an optional embodiment of the present invention, the step of determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary includes:
[0141] Sub-step S20121, extracting high-frequency words from the total word dictionary to determine high-frequency word groups;
[0142] Extracting high-frequency phrases from the total phrase dictionary to determine the high-frequency phrases;
[0143] Sub-step S20122, constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases;
[0144] After the high-frequency phrases are determined, a common root dictionary and a mutually exclusive dictionary set can be constructed based on the high-frequency phrases, so that the common phrases and the mutually exclusive phrases can be graded.
[0145] Specifically, the step of constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases includes: constructing a high-frequency word truth value matrix based on each of the high-frequency phrases; accumulating the high-frequency word truth value matrix row by row to generate a high-frequency word accumulation matrix; constructing the common root dictionary based on the column data of the high-frequency word accumulation matrix; and constructing the mutually exclusive dictionary set based on the row data of the high-frequency word accumulation matrix.
[0146] For the construction of mutually exclusive dictionaries, high-frequency words in the total dictionary can be extracted based on each high-frequency phrase, and the row records can be scanned to construct a high-frequency word truth matrix. Using high-frequency words as indexes, scan the row records one by one. When the high-frequency word exists in the row record, mark the index as 1, otherwise mark it as 0, forming a high-frequency word truth matrix composed of 0 and 1; traverse the high-frequency word indexes one by one, and accumulate the matrix rows with index position 1 in the high-frequency word truth matrix to obtain the high-frequency word accumulation matrix. In the accumulation matrix, for each row at the index position, the larger the value in the row, the stronger the correlation between the high-frequency words, the smaller the value, the stronger the mutual exclusivity, and equal to 0 means that the corresponding high-frequency words are mutually exclusive.
[0147] Then, the column data of the high-frequency word accumulation matrix is calculated, that is, the columns of the high-frequency word accumulation matrix are calculated to determine the corresponding high-frequency words to construct a common root dictionary. The row data of the high-frequency word accumulation matrix is also calculated, that is, the rows of the high-frequency word accumulation matrix are calculated to determine the corresponding high-frequency words to construct a mutually exclusive dictionary set.
[0148] Furthermore, the step of constructing the common root dictionary based on the column data of the high-frequency word accumulation matrix includes: calculating the cumulative sum and variance of the column data of the high-frequency word accumulation matrix; in the high-frequency word accumulation matrix, removing the high-frequency phrases whose cumulative sum is greater than a preset first threshold and whose variance is less than a preset second threshold to obtain a target high-frequency word accumulation matrix; and determining the high-frequency phrases in the target high-frequency word accumulation matrix as the common root dictionary.
[0149] Traverse the columns of the high-frequency word accumulation matrix, calculate the cumulative sum and variance of the column data of the high-frequency word accumulation matrix, and after accumulation by column, the larger the cumulative sum, the higher the frequency of the high-frequency word in all records; the smaller the variance, the higher the correlation between the high-frequency word and other high-frequency words; the larger the variance, the greater the frequency of mutual exclusion between the high-frequency word and some other high-frequency word.
[0150] The high-frequency words whose cumulative sum is greater than the preset first threshold and whose variance is less than the preset second threshold are removed from the cumulative matrix to obtain the target high-frequency word cumulative matrix. The high-frequency phrases in the high-frequency word cumulative matrix, i.e., the high-frequency phrases remaining after removing the high-frequency words whose cumulative sum is greater than the preset first threshold and whose variance is less than the preset second threshold, are determined as the common root dictionary. The first threshold and the second threshold are determined according to the actual situation, and the embodiment of the present invention does not make any specific limitation on this.
[0151] Furthermore, the step of constructing the mutually exclusive dictionary set based on the row data of the high-frequency word accumulation matrix includes: determining the high-frequency phrase group corresponding to the preset target value of the row data of the high-frequency word accumulation matrix as the target high-frequency phrase group; in the high-frequency word accumulation matrix, determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency phrase group; and establishing corresponding dictionaries based on the mutually exclusive words and the strongly associated words to generate the mutually exclusive dictionary set.
[0152] Traverse the rows of the high-frequency word accumulation matrix, and identify the high-frequency words in the matrix rows that correspond to the preset target values as mutually exclusive words of the high-frequency phrase group at the index position; that is, determine them as the target high-frequency phrase group. For high-frequency words with mutually exclusive words, determine the mutually exclusive words, strongly associated words, and weakly associated words corresponding to the target high-frequency phrase group in the high-frequency word accumulation matrix; and use the mutually exclusive words and strongly associated words together as a dictionary. Each mutually exclusive word corresponds to a dictionary to form a mutually exclusive dictionary set. Among them, the preset target value can be 0.
[0153] Furthermore, for the high-frequency word accumulation matrix, the step of determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency phrases includes: determining the index position value of the target high-frequency phrase; in the high-frequency word accumulation matrix, determining the high-frequency phrases whose difference with the index position value is greater than a preset third threshold as the mutually exclusive words; in the high-frequency word accumulation matrix, determining the high-frequency phrases whose difference with the index position value is less than a preset fourth threshold as the strongly associated words; and determining the high-frequency phrases whose rows in the high-frequency word accumulation matrix are less than a preset fifth threshold as weakly associated words.
[0154] The high-frequency word groups whose row data of the high-frequency word accumulation matrix is less than a preset fifth threshold value can be determined as weakly associated words and processed separately, thereby improving the compression efficiency.
[0155] In addition, the weakly associated words can be deleted from the high-frequency word accumulation matrix. That is, the high-frequency words with smaller logarithmic values are identified as mutually exclusive words, and the high-frequency words with smaller values are marked as weakly associated words in the dictionary set. Weak keywords are deleted from the high-frequency word accumulation matrix to reduce the dictionary construction steps for weakly associated words and improve processing efficiency.
[0156] Furthermore, the weakly associated words are compressed independently; the weakly associated words are changed into mutually exclusive words, and this part of the row records are placed in a group separately, and can be compressed and stored independently using a conventional compression algorithm.
[0157] Sub-step S20123, determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set.
[0158] Finally, the common root dictionary and the mutually exclusive dictionary set are used as nodes in the mutually exclusive hierarchical dictionary tree, thereby generating a mutually exclusive hierarchical dictionary tree. By putting similar row records together, the records with mutually exclusive words are grouped and compressed, which not only reduces the capacity of the dictionary in the group, but also provides a function for fast filtering during query.
[0159] Specifically, the step of determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set includes: constructing the common root dictionary into a first-level dictionary; grouping the mutually exclusive dictionary set; constructing the grouped mutually exclusive dictionary set into a second-level dictionary; and combining the first-level dictionary and the second-level dictionary to generate the mutually exclusive hierarchical dictionary tree.
[0160] The common root dictionaries with common high-frequency words are divided into a group, and the common root dictionaries are extracted to build a first-level dictionary. The parent dictionary is set as the root dictionary to form a first-level dictionary tree. Mutually exclusive dictionaries are centrally created as second-level dictionaries, and their parent nodes are designated as first-level dictionaries to form a second-level dictionary tree. The first-level dictionary and the second-level dictionary are combined to generate a mutually exclusive hierarchical dictionary tree. Among them, the root dictionary can have multiple.
[0161] Optionally, in an embodiment of the present invention, historical search terms may also be obtained; hot search terms are input search terms; word frequency statistics are performed on the historical search terms to determine hot search terms; database row records that match the hot search terms are divided into the same group; and database row records that do not match the hot search terms are divided into another same group. When grouping, hot search terms are added as grouping conditions, and row records containing hot search terms are compressed together. In this way, for a large number of hot search term searches, decompression of row records that do not contain hot search terms can be avoided, thereby reducing IO delays and decompression overhead. Database row records that do not match the hot search terms are divided into another same group for storage.
[0162] In order to make those skilled in the art understand the mutually exclusive hierarchical dictionary tree construction process of the embodiment of the present invention, the following example is used for explanation:
[0163] You can refer to Fig. 9 , 1. Construct the truth value matrix of high-frequency words. 2. Calculate the accumulation matrix of high-frequency words. 3. Construct a common root dictionary. 4. Construct a mutually exclusive dictionary set. 5. Construct a hierarchical dictionary tree.
[0164] For example, Fig.10 As shown in the figure, 1) the line record is segmented and the string is divided into phrases. The segmented phrases are represented by | in the figure.
[0165] 2) Count the number of occurrences of various phrases after word segmentation as word frequency.
[0166] 3) Extract high-frequency words and construct a high-frequency word matrix. As shown in the figure: words with a frequency greater than 3 are regarded as high-frequency words. When the high-frequency word appears in a row record, the corresponding position is marked as 1, otherwise it is marked as 0.
[0167] 4) Calculate the accumulation matrix. Traverse each high-frequency word, filter out the records where the high-frequency word appears in the row record (the corresponding position in the matrix is 1), and accumulate the corresponding records by column. The values in the accumulation matrix represent the correlation and mutual exclusivity of the occurrence of various phrases for the row record samples.
[0168] 5) Build a root dictionary. After accumulation, you can see that the calculated values of ventilation, carriage return, and comma are 10, which is the same as the number of rows, indicating that the phrase will be used in every row. Therefore, extracting common phrases with higher frequency of occurrence as the root dictionary is beneficial to reduce the dictionary capacity required for compression coding. It is worth noting that in order to facilitate the reader's understanding, the examples in this article are relatively simple. Real sample data fluctuates. For example, some words appear 9 times and can also be identified as common phrases. Therefore, in the present invention, the judgment of common phrases is not to simply take the words with the same number of rows and the accumulated value in the accumulation matrix, but to add the columns of each row and calculate the variance.
[0169] 6) Construct a mutually exclusive dictionary set. In the cumulative matrix without common high-frequency words, find mutually exclusive words, weakly associated words, and strongly associated words. Construct different dictionaries according to mutually exclusive words. The dictionary corresponding to each mutually exclusive word contains phrases that are strongly associated with the mutually exclusive word, but does not contain mutually exclusive phrases or weakly associated words.
[0170] 7) Construct a hierarchical dictionary tree. Since one mutually exclusive word may have multiple strongly associated words, the strongly associated words of multiple mutually exclusive words often overlap. In order to reduce the dictionary capacity, the mutually exclusive word dictionary is optimized in the present invention, and the mutually exclusive dictionary set is grouped, and the dictionaries with common high-frequency words are grouped together. The high-frequency words in the group are used as the first-level dictionary, and the remaining word groups are used as the second-level dictionary. The inheritance relationship between dictionaries is marked to form a dictionary tree structure. In order to speed up the subsequent compression calculation speed in the present invention, a unique number is assigned to the mutually exclusive dictionary in the dictionary tree, and the number is an integer power of 2 to ensure that only one bit in the number is 1, and the dictionary number is marked on the corresponding word in the total dictionary.
[0171] Step 202, segment the database row records, and build a high-frequency word matrix based on the segmentation statistics;
[0172] When it is necessary to compress the data in the database, the database row records can be obtained; the database row records can be segmented, and a high-frequency word matrix can be constructed based on the segmentation statistics.
[0173] Step 203, based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases;
[0174] The mutually exclusive hierarchical dictionary tree has multiple levels of mutually exclusive word dictionary nodes, and the mutually exclusive word dictionary nodes include mutually exclusive word groups and dictionary node codes corresponding to the mutually exclusive word groups;
[0175] For each database row record, the mutually exclusive hierarchical dictionary tree corresponding to the constructed high-frequency word matrix is matched with the database row record to determine the match with the mutually exclusive phrases in the mutually exclusive hierarchical dictionary tree to determine at least one set of target mutually exclusive phrases.
[0176] Specifically, the step of determining at least one set of target mutually exclusive phrases from the database row records based on the high-frequency word matrix includes: based on the high-frequency word matrix, traversing the database row records to determine the at least one set of target mutually exclusive phrases.
[0177] Each database row record is traversed, and at least one set of target mutually exclusive phrases is determined based on matching the phrases in the database row record with the mutually exclusive hierarchical dictionary tree.
[0178] Step 204, grouping the database row records based on the target mutually exclusive phrase;
[0179] The database row records may be grouped according to the target mutually exclusive phrases; thereby the database row records may be classified based on the target mutually exclusive phrases for easy compression.
[0180] Specifically, the step of grouping the database row records based on the target mutually exclusive phrases includes: for each of the target mutually exclusive phrases, merging the database row records having the target mutually exclusive phrases into the same group.
[0181] Step 205: Replace the database row records of each group with the corresponding dictionary node code to generate compressed block data.
[0182] For each database row record in each group, the phrase in the database row record is replaced with the corresponding dictionary node code, and the dictionary node code is used to represent the database row record to generate compressed block data.
[0183] Specifically, for each group of database row records, the target mutually exclusive phrases are replaced with corresponding dictionary node codes to generate compressed block data, including: for each group of database row records, the phrases are replaced with corresponding dictionary node codes to generate encoded data; and the encoded data is compressed and encoded to generate compressed block data.
[0184] Records can be made for each grouped database row, and all phrases can be replaced with corresponding dictionary node codes to generate coded data; and then compression coding is performed based on the coded data to generate compressed block data.
[0185] Specifically, the step of compressing and encoding the coded data to generate compressed block data includes: performing dictionary Huffman encoding on the coded data to generate the compressed block data. The coded data may be subjected to dictionary Huffman encoding, and the coded data may be recompressed in the form of Huffman encoding to generate compressed block data in the form of Huffman encoding, thereby further improving the compression rate and reducing storage space.
[0186] Furthermore, the step of replacing the phrases in the database row records of each group with the corresponding dictionary node codes to generate compressed block data also includes: merging the compressed block data of different groups to generate data block data.
[0187] One data block is generated by merging compressed block data of different target mutually exclusive phrases.
[0188] Furthermore, the step of merging the compressed block data of different groups to generate data block data includes: determining meta information of the compressed block data of different groups; the meta information is located at an index position of the compressed block data; and merging the compressed block data of different groups and the corresponding meta information to generate data block data.
[0189] In the embodiment of the present invention, corresponding meta information may be added to index positions corresponding to different groups of compressed block data; and the compressed block data of different groups and the corresponding meta information may be merged to generate data block data.
[0190] Furthermore, the row meta information of the database row record may be established based on the meta information. The database row record is identified based on the meta information of the compressed block to form the row meta information.
[0191] Specifically, the step of establishing the row meta information of the database row record based on the meta information includes: determining the row record access frequency of the database row record of the compressed block corresponding to the meta information; in response to the row record access frequency being lower than a preset access threshold, executing the step of determining the meta information of the compressed block data of the different groups; in response to the row record access frequency being not lower than the preset access threshold, combining the meta information of the compressed block data of the different groups to generate the row meta information. In order to further reduce the space occupied by data; it can be determined whether to generate the row meta information of the database row record according to the row record access frequency of the row record. When the row record access frequency is lower than the preset access threshold, it means that the access is less, and the corresponding row meta information may not be generated for the row record, and the meta information is added for the compressed block data. When the row record access frequency is not lower than the preset access threshold, it means that the access frequency is above the regular number; the row meta information may be added to the database row record that meets the requirements.
[0192] In order to make the process of row record compression clear to those skilled in the art, an example is used to illustrate the process below:
[0193] You can refer to Fig.11 ; 1. Traverse the mutually exclusive dictionary numbers recorded in the row records. Traverse the row records after word segmentation, and record the mutually exclusive dictionary numbers needed for the row and the low-frequency words outside the dictionary tree according to the dictionary tree numbers of the phrases in the total dictionary. Perform an AND operation on the dictionary numbers used as the hash value.
[0194] 2. Merge records with the same mutually exclusive dictionary number and perform compression coding. Put the records with the same hash value together for compression coding, and record the offset position of the phrase in the dictionary tree in the row record compression coding as meta information.
[0195] 3. Combine compressed blocks of different groups and add metadata. Combine compressed blocks of different groups, add the offset, length, dictionary number used, metadata of each line record, and total dictionary data of the compressed block in the file header as the header information of the header file. Compress the file header information using a conventional compression algorithm, and then store the compressed data blocks of each group.
[0196] Specifically, for example, see Fig.12 and Fig.13 ;1) Traverse each row of records and record the dictionary number used for compression of the row of records according to the dictionary tree. In the example, each row of records is grouped according to the two-level dictionary, and the dictionary number corresponding to the group can be obtained.
[0197] 2) Compress the records of the same group. The compression code uses the total dictionary tree compression code. You can also perform secondary Huffman coding on the phrases in the group to generate the corresponding dictionary, and use the grouped dictionary Huffman coding for compression.
[0198] 3) Combine the compressed blocks of different groups into one compressed file, add the metadata of the compressed blocks to the header of the file, and mark the starting offset, length and dictionary of each compressed block in the combined file. Different from the prior art, in the present invention, each row record is compressed separately according to the storage characteristics of the database, and the length information of each row after compression and the high-frequency word information used are added. It is worth mentioning that the row metadata is compressed using a conventional compression algorithm, such as gzip and LZ77. The final compressed file contains the metadata of the grouped compressed blocks and the metadata of each row. The conventional compression algorithm, the compressed dictionary and the hierarchical dictionary tree are stored at the end of the file. It is worth mentioning that if quadratic Huffman coding is used in block compression, there is no need to store the total dictionary.
[0199] In addition, correspondingly, when searching and filtering in compressed data is required, corresponding data can be quickly found based on the mutually exclusive phrases. A search instruction is received, the search instruction carries the search mutually exclusive phrase; and a target row record matching the search mutually exclusive phrase is determined.
[0200] A search instruction sent by a user may be received, the search instruction carrying a search mutually exclusive phrase, and a row record having a mutually exclusive phrase matching the search mutually exclusive phrase is searched in all compressed block data, that is, a target row record.
[0201] Specifically, the step of determining the target row record matching the search mutually exclusive phrase includes: determining a data block whose index position matches the search mutually exclusive phrase as a target data block; and determining a row record corresponding to the target data block as a target row record.
[0202] In the retrieval query stage, you can first determine whether the phrase corresponding to the index position is a phrase that matches the search mutually exclusive phrase based on the encoding of the index position. If the phrase at the index position is not a search term, there is no need to read and decompress the row of data; for the phrase at the index position and the search mutually exclusive phrase, the corresponding data block can be the target data block; the row record corresponding to the data frame is the target row record.
[0203] Furthermore, when the user finds the data that needs to be read, the target compressed block data can be decompressed.
[0204] Specifically, for data decompression, the target row record corresponds to a decompression priority; the decompression priority corresponds to the mutually exclusive phrase; the step of decompressing the target row record includes: determining the decompression priority of the target row record; in response to the decompression priority being the first priority, preferentially decompressing the data block corresponding to the target row record; in response to the decompression priority being the second priority, conventionally decompressing the data block corresponding to the target row record.
[0205] Among them, the first priority will take precedence over the second priority. A conventional compression algorithm can be used for the second priority data row records. For this part of the data block, it is impossible to determine whether the keyword exists before it is fully decompressed. The decompression priority of this part of the data can be lowered. By setting the decompression priority, the query mutually exclusive phrase containing the search keyword is determined as the first priority; the data block with the mutually exclusive dictionary is decompressed first, and the data is fed back to the user as soon as possible, reducing the waiting time for the query feedback delay. While the user is browsing the first page, the low-priority compressed block is decompressed and returned as the data of the second page.
[0206] In addition, only the statistical value may be fed back without decompressing the data block, thereby improving the query efficiency. The row record count value corresponding to the target row record may be determined; and the row record count value may be fed back.
[0207] In order to make the process of data search clear to those skilled in the art, the following reference Fig.14 , to illustrate with an example:
[0208] 1. Preprocessing of search terms: Split the search terms by part of speech and replace their semantics to convert them into a target search term set.
[0209] 2. Determine whether the search term after splitting is a high-frequency mutually exclusive word in the dictionary. If yes, execute step 3; otherwise, execute step 1.
[0210] 3. Traverse and read the compressed block meta information to determine whether the target search term exists in the dictionary. If so, read the compressed block from the disk and execute step 4; otherwise, skip the compressed block and process the next compressed block.
[0211] 4. Traverse and decompress to read the row meta information, and determine whether the high-frequency word index position code is the target search word. If so, execute step 5; otherwise, skip the compressed row and process the next compressed row.
[0212] 5. Determine whether the SQL (Structured Query Language) statement is a statistical operation. If yes, go to step 6; otherwise, go to step 7.
[0213] 6. Do not read compressed rows, only increase the statistical count value.
[0214] 7. Read the compressed row and decompress the entire row of data.
[0215] 8. Determine whether it is the last line of the compressed block. If yes, go to step 9, otherwise go to step 4.
[0216] 9. Determine whether it is the last compressed block. If yes, exit; otherwise, proceed to step 3.
[0217] 10. Read all compressed blocks sequentially and decompress each line until the last line is recorded, then exit.
[0218] For example: you can refer to Fig.15 . 1) For the query search terms entered by the user, preprocessing is first performed. In the preprocessing, the keywords are split according to the part of speech. Optionally, the keywords are replaced with words with similar meanings according to semantics. For example, the user enters the search term: pink skirt. In the preprocessing, according to the part of speech, it is split into two keywords: pink and skirt. At the same time, fuzzy matching is optionally used to expand skirt to synonyms that may exist in the keyword dictionary, such as dress and lace skirt.
[0219] 2) Check whether the search terms after splitting are mutually exclusive words in the dictionary. This step is the key point of the invention to produce beneficial effects. If the search terms are mutually exclusive words, unnecessary compressed blocks can be skipped, thereby reducing disk IO reading delay and decompression delay. If the search terms are not mutually exclusive words in the dictionary, the traditional full decompression reading method is still used to ensure the correctness of the query results.
[0220] 3) When the search term is a mutually exclusive term in the dictionary, the metadata of the compressed block is first read from the metadata of the compressed file to determine whether the search term is in the dictionary of the compressed block. If it is not in the dictionary, the compressed block is not read from the disk.
[0221] 4) For compressed blocks with search terms, the present invention further optimizes the query for database scenarios, and stores the index position of each row of high-frequency keywords in the compressed code stream in each compressed block. When querying, first determine whether it is a search term based on the encoding of the index position. If the high-frequency word at the index position is not a search term, there is no need to read and decompress the row of data.
[0222] 5) At the same time, the present invention optimizes the design for the commonly used statistical queries in SQL statements. For example, the query statement in SQL2 does not need to obtain all the text information in the record due to statistical query, but only needs to determine whether the filtering conditions are met. Therefore, for statistical query in the present invention, it is only necessary to read the meta information of the row and determine whether the target search term is included in the index from the meta information, without decompressing all the row records.
[0223] In order to make the overall implementation process of the present invention clear to those skilled in the art, an example can be used to illustrate the above:
[0224] You can refer to Fig.161. Word segmentation, statistics, and construction of a total dictionary of phrases. In this step, the character string in the database row record is segmented into phrases according to the part of speech, the phrase frequency is counted, and a total dictionary is constructed. Different from the prior art, the dictionary content in the present invention is a phrase with logical semantics, rather than a meaningless binary code stream, which provides a basis for fast filtering and querying of compressed files.
[0225] 2. Construct a word segmentation dictionary tree. The total dictionary constructed in step 1 contains dictionaries used for all row records, which are often large in content and take a long time to decompress and retrieve. Different from the prior art, the present invention optimizes the total dictionary into a dictionary tree, groups and compresses row records with mutually exclusive words, and constructs a corresponding dictionary set. The dictionaries are described using inheritance relationships to reduce the dictionary capacity of grouped data while providing a quick filtering function during query.
[0226] 3. Merge and compress row records, and add dictionary indexes and phrase indexes. After the dictionary tree is constructed in step 2, the row records in the database are merged and compressed. Different from the prior art, the method proposed in the present invention distributes row records containing mutually exclusive phrases in high-frequency words to different groups for compression, and the corresponding dictionaries do not contain mutually exclusive words. The compressed blocks can be skipped during query, thus reducing IO delay. At the same time, in the embodiment of the present invention, data is compressed row by row for database scenarios, and a high-frequency word position index is added to the row meta information of the database, so that it is possible to determine whether the row record meets the filtering conditions without decompressing the row record, greatly improving the count() statistical performance in the SQL statement.
[0227] 4. Query, filter and decompress the compressed block. After step 3 compresses the database row record, the user initiates a query through the database SQL statement. Different from the prior art, the present invention pre-processes the filtering conditions of the where clause in the SQL statement, and first queries the dictionary at all levels to see whether the keyword exists in the current compressed block, including but not limited to roots, affixes, and semantically similar words. Combined with the data requirements of the SQL statement for the target row record, part of the data can be selectively decompressed to improve query performance.
[0228] It should be noted that various thresholds mentioned in the embodiments of the present invention can be preset according to actual conditions, and the embodiments of the present invention do not limit the specific values.
[0229] The embodiment of the present invention extracts mutually exclusive high-frequency words in the record, and constructs a dictionary with mutually exclusive attributes, thereby reducing the reading of redundant data during query. For Chinese search, semantic part-of-speech segmentation is used for compression, and the original semantics are retained in the compressed file, which is more conducive to data retrieval during query. The index of keywords is added to the metadata of the row record, which solves the disadvantage of inserting separators in the code stream in the prior art, which requires reading data one by one. The dictionary information and keyword location information of the compressed data are marked by block metadata and row metadata. The problem of the prior art that all data needs to be read from the disk in the database usage scenario is solved. In particular, for statistical query statements in the database, only metadata needs to be read to obtain the query results, which greatly reduces the IO delay of disk reading. For database storage scenarios, in compressed storage, the storage location of row records and the characteristics that do not affect the query results are fully utilized, and similar row records are grouped and compressed, which can not only improve the compression rate, but also reduce the redundant data reading during query, thereby reducing query delay.
[0230] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0231] Reference Fig.17 , an embodiment of the present invention further provides an electronic device, including:
[0232] A processor 1701 and a storage medium 1702, wherein the storage medium 1702 stores a computer program executable by the processor 1701, and when the electronic device is running, the processor 1701 executes the computer program to perform the database data compression method as described in any one of the embodiments of the present invention.
[0233] The database data compression method comprises:
[0234] Segment the database rows and build a high-frequency word matrix based on the segmentation statistics;
[0235] Based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases;
[0236] Grouping the database row records based on the target mutually exclusive phrase;
[0237] Optionally, the database data compression method further includes:
[0238] The mutually exclusive hierarchical dictionary tree is constructed according to the database row records.
[0239] Optionally, the step of constructing the mutually exclusive hierarchical dictionary tree according to the database row records includes:
[0240] Constructing a general dictionary of phrases according to the database row records;
[0241] A mutually exclusive hierarchical dictionary tree is determined based on the phrase total dictionary.
[0242] Optionally, the step of constructing a general phrase dictionary based on the database row records includes:
[0243] Split the character string in the database row record to generate initial phrases;
[0244] Performing word frequency statistics on the initial word group to determine the word frequency corresponding to the initial word group;
[0245] According to the frequency of the word, the initial word group corresponding to the word frequency is Huffman encoded to generate the total word group dictionary.
[0246] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary includes:
[0247] Extracting high-frequency words from the total word dictionary to determine high-frequency word groups;
[0248] Constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases;
[0249] A mutually exclusive hierarchical dictionary tree is determined based on the common root dictionary and the mutually exclusive dictionary set.
[0250] Optionally, the step of constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases includes:
[0251] According to each of the high-frequency phrases, construct a high-frequency word truth value matrix;
[0252] Accumulating the high-frequency word truth value matrix row by row to generate a high-frequency word accumulation matrix;
[0253] Constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix;
[0254] The mutually exclusive dictionary set is constructed according to the row data of the high-frequency word accumulation matrix.
[0255] Optionally, the step of constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix includes:
[0256] Calculate the cumulative sum and variance of the column data of the high-frequency word accumulation matrix;
[0257] In the high-frequency word accumulation matrix, high-frequency word groups whose cumulative sum is greater than a preset first threshold and whose variance is less than a preset second threshold are removed to obtain a target high-frequency word accumulation matrix;
[0258] The high-frequency word group in the target high-frequency word accumulation matrix is determined as the common root dictionary.
[0259] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix includes:
[0260] Determine the high-frequency phrase group corresponding to the preset target value of the row data of the high-frequency word accumulation matrix as the target high-frequency phrase group;
[0261] In the high-frequency word accumulation matrix, determining mutually exclusive words, strongly associated words, and weakly associated words corresponding to the target high-frequency word group;
[0262] A corresponding dictionary is established based on the mutually exclusive words and the strongly associated words to generate the mutually exclusive dictionary set.
[0263] Optionally, the step of determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency word group in the high-frequency word accumulation matrix includes:
[0264] Determine the index position value of the target high-frequency phrase;
[0265] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is greater than a preset third threshold as the mutually exclusive word;
[0266] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is less than a preset fourth threshold as the strongly associated word;
[0267] Determine that the high-frequency word group whose row number in the high-frequency word accumulation matrix is less than a preset fifth threshold is a weakly associated word.
[0268] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix further includes:
[0269] The weakly associated words are deleted from the high-frequency word accumulation matrix.
[0270] Optionally, the method further comprises:
[0271] The weakly associated words are compressed independently.
[0272] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set comprises:
[0273] Build the common root dictionary as a first-level dictionary;
[0274] Grouping the mutually exclusive dictionary sets;
[0275] The grouped mutually exclusive dictionary set is constructed as a secondary dictionary;
[0276] The first-level dictionary and the second-level dictionary are combined to generate the mutually exclusive hierarchical dictionary tree.
[0277] Optionally, the step of determining at least one set of target mutually exclusive phrases from the database row records based on the high-frequency word matrix includes:
[0278] Based on the high-frequency word matrix, the database row records are traversed to determine the at least one group of target mutually exclusive phrases.
[0279] Optionally, the step of grouping the database row records based on the target mutually exclusive phrases includes:
[0280] For each of the target mutually exclusive phrases, the database row records having the target mutually exclusive phrases are grouped into the same group.
[0281] Optionally, the step of replacing the database row record for each group with the corresponding dictionary node code to generate compressed block data includes:
[0282] For each group of words in the database row record, replace them with the corresponding dictionary node code to generate coded data;
[0283] The coded data is compression-coded to generate compressed block data.
[0284] Optionally, the step of compressing and encoding the encoded data to generate compressed block data includes:
[0285] The encoded data is subjected to dictionary Huffman encoding to generate the compressed block data.
[0286] Optionally, the step of replacing the phrases in the database row records of each group with corresponding dictionary node codes to generate compressed block data further includes:
[0287] The compressed block data of different groups are merged to generate data block data.
[0288] Optionally, the step of merging the compressed block data of different groups to generate data block data includes:
[0289] Determining meta information of the compressed block data of the different groups; the meta information is located at an index position of the compressed block data;
[0290] The compressed block data and corresponding meta information of the different groups are merged to generate data block data.
[0291] Optionally, the method further comprises:
[0292] The row meta information of the database row record is established according to the meta information.
[0293] Optionally, the step of establishing row meta information of the database row record according to the meta information includes:
[0294] Determining a row record access frequency of a database row record of a compressed block corresponding to the meta information;
[0295] In response to the row record access frequency being lower than a preset access threshold, performing the determining of the meta information of the compressed block data of the different groups;
[0296] In response to the row record access frequency being not lower than a preset access threshold, the meta information of the compressed block data of the different groups is combined to generate the row meta information.
[0297] Optionally, the database data compression method further includes:
[0298] receiving a search instruction, wherein the search instruction carries a search mutually exclusive phrase;
[0299] Determines the target row records that match the search mutually exclusive phrase.
[0300] Optionally, the step of determining a target row record matching the mutually exclusive phrase to be searched includes:
[0301] Determine the data block whose index position matches the search mutually exclusive phrase as the target data block;
[0302] Determine the row record corresponding to the target data block as the target row record.
[0303] Optionally, the database data compression method further includes:
[0304] Determine a row record count value corresponding to the target row record;
[0305] The row record count value is fed back.
[0306] Optionally, the database data compression method further includes:
[0307] Decompress the target row record.
[0308] Optionally, the target row record corresponds to a decompression priority; the decompression priority corresponds to the mutually exclusive phrase;
[0309] The step of decompressing the target row record comprises:
[0310] Determine the decompression priority of the target row record;
[0311] In response to the decompression priority being the first priority, preferentially decompressing the data block corresponding to the target row record;
[0312] In response to the decompression priority being the second priority, the data block corresponding to the target row record is conventionally decompressed.
[0313] Optionally, the method further comprises:
[0314] Get historical search terms; hot search terms are input search terms;
[0315] Perform word frequency statistics on the historical search terms to determine hot search terms;
[0316] Grouping database row records matching the hot search term into the same group;
[0317] The database row records that do not match the hot search term are divided into another same group.
[0318] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the processor.
[0319] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0320] Reference Fig.18The embodiment of the present invention further provides a computer-readable storage medium 1801, on which a computer program is stored. When the computer program is executed by a processor, the database data compression method as described in any one of the embodiments of the present invention is executed.
[0321] The database data compression method comprises:
[0322] Segment the database rows and build a high-frequency word matrix based on the segmentation statistics;
[0323] Based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases;
[0324] Grouping the database row records based on the target mutually exclusive phrase;
[0325] Optionally, the database data compression method further includes:
[0326] The mutually exclusive hierarchical dictionary tree is constructed according to the database row records.
[0327] Optionally, the step of constructing the mutually exclusive hierarchical dictionary tree according to the database row records includes:
[0328] Constructing a general dictionary of phrases according to the database row records;
[0329] A mutually exclusive hierarchical dictionary tree is determined based on the phrase total dictionary.
[0330] Optionally, the step of constructing a general phrase dictionary based on the database row records includes:
[0331] Split the character string in the database row record to generate initial phrases;
[0332] Performing word frequency statistics on the initial word group to determine the word frequency corresponding to the initial word group;
[0333] According to the frequency of the word, the initial word group corresponding to the word frequency is Huffman encoded to generate the total word group dictionary.
[0334] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary includes:
[0335] Extracting high-frequency words from the total word dictionary to determine high-frequency word groups;
[0336] Constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases;
[0337] A mutually exclusive hierarchical dictionary tree is determined based on the common root dictionary and the mutually exclusive dictionary set.
[0338] Optionally, the step of constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases includes:
[0339] According to each of the high-frequency phrases, construct a high-frequency word truth value matrix;
[0340] Accumulating the high-frequency word truth value matrix row by row to generate a high-frequency word accumulation matrix;
[0341] Constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix;
[0342] The mutually exclusive dictionary set is constructed according to the row data of the high-frequency word accumulation matrix.
[0343] Optionally, the step of constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix includes:
[0344] Calculate the cumulative sum and variance of the column data of the high-frequency word accumulation matrix;
[0345] In the high-frequency word accumulation matrix, high-frequency word groups whose cumulative sum is greater than a preset first threshold and whose variance is less than a preset second threshold are removed to obtain a target high-frequency word accumulation matrix;
[0346] The high-frequency word group in the target high-frequency word accumulation matrix is determined as the common root dictionary.
[0347] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix includes:
[0348] Determine the high-frequency phrase group corresponding to the preset target value of the row data of the high-frequency word accumulation matrix as the target high-frequency phrase group;
[0349] In the high-frequency word accumulation matrix, determining mutually exclusive words, strongly associated words, and weakly associated words corresponding to the target high-frequency word group;
[0350] A corresponding dictionary is established based on the mutually exclusive words and the strongly associated words to generate the mutually exclusive dictionary set.
[0351] Optionally, the step of determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency word group in the high-frequency word accumulation matrix includes:
[0352] Determine the index position value of the target high-frequency phrase;
[0353] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is greater than a preset third threshold as the mutually exclusive word;
[0354] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is less than a preset fourth threshold as the strongly associated word;
[0355] Determine that the high-frequency word group whose row number in the high-frequency word accumulation matrix is less than a preset fifth threshold is a weakly associated word.
[0356] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix further includes:
[0357] The weakly associated words are deleted from the high-frequency word accumulation matrix.
[0358] Optionally, the method further comprises:
[0359] The weakly associated words are compressed independently.
[0360] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set comprises:
[0361] Build the common root dictionary as a first-level dictionary;
[0362] Grouping the mutually exclusive dictionary sets;
[0363] The grouped mutually exclusive dictionary set is constructed as a secondary dictionary;
[0364] The first-level dictionary and the second-level dictionary are combined to generate the mutually exclusive hierarchical dictionary tree.
[0365] Optionally, the step of determining at least one set of target mutually exclusive phrases from the database row records based on the high-frequency word matrix includes:
[0366] Based on the high-frequency word matrix, the database row records are traversed to determine the at least one group of target mutually exclusive phrases.
[0367] Optionally, the step of grouping the database row records based on the target mutually exclusive phrases includes:
[0368] For each of the target mutually exclusive phrases, the database row records having the target mutually exclusive phrases are grouped into the same group.
[0369] Optionally, the step of replacing the database row record for each group with the corresponding dictionary node code to generate compressed block data includes:
[0370] For each group of words in the database row record, replace them with the corresponding dictionary node code to generate coded data;
[0371] The coded data is compression-coded to generate compressed block data.
[0372] Optionally, the step of compressing and encoding the encoded data to generate compressed block data includes:
[0373] The encoded data is subjected to dictionary Huffman encoding to generate the compressed block data.
[0374] Optionally, the step of replacing the phrases in the database row records of each group with corresponding dictionary node codes to generate compressed block data further includes:
[0375] The compressed block data of different groups are merged to generate data block data.
[0376] Optionally, the step of merging the compressed block data of different groups to generate data block data includes:
[0377] Determining meta information of the compressed block data of the different groups; the meta information is located at an index position of the compressed block data;
[0378] The compressed block data and corresponding meta information of the different groups are merged to generate data block data.
[0379] Optionally, the method further comprises:
[0380] The row meta information of the database row record is established according to the meta information.
[0381] Optionally, the step of establishing row meta information of the database row record according to the meta information includes:
[0382] Determining a row record access frequency of a database row record of a compressed block corresponding to the meta information;
[0383] In response to the row record access frequency being lower than a preset access threshold, performing the determining of the meta information of the compressed block data of the different groups;
[0384] In response to the row record access frequency being not lower than a preset access threshold, the meta information of the compressed block data of the different groups is combined to generate the row meta information.
[0385] Optionally, the database data compression method further includes:
[0386] receiving a search instruction, wherein the search instruction carries a search mutually exclusive phrase;
[0387] Determines the target row records that match the search mutually exclusive phrase.
[0388] Optionally, the step of determining a target row record matching the mutually exclusive phrase to be searched includes:
[0389] Determine the data block whose index position matches the search mutually exclusive phrase as the target data block;
[0390] Determine the row record corresponding to the target data block as the target row record.
[0391] Optionally, the database data compression method further includes:
[0392] Determine a row record count value corresponding to the target row record;
[0393] The row record count value is fed back.
[0394] Optionally, the database data compression method further includes:
[0395] Decompress the target row record.
[0396] Optionally, the target row record corresponds to a decompression priority; the decompression priority corresponds to the mutually exclusive phrase;
[0397] The step of decompressing the target row record comprises:
[0398] Determine the decompression priority of the target row record;
[0399] In response to the decompression priority being the first priority, preferentially decompressing the data block corresponding to the target row record;
[0400] In response to the decompression priority being the second priority, the data block corresponding to the target row record is conventionally decompressed.
[0401] Optionally, the method further comprises:
[0402] Get historical search terms; hot search terms are input search terms;
[0403] Perform word frequency statistics on the historical search terms to determine hot search terms;
[0404] Grouping database row records matching the hot search term into the same group;
[0405] The database row records that do not match the hot search term are divided into another same group.
[0406] Reference Fig.19 , shows a structural block diagram of a computer program product provided by an embodiment of the present invention. The computer program product includes computer instructions 1901, and when the computer instructions 1901 are executed by a processor, the steps of the database data compression method described above are implemented.
[0407] The database data compression method comprises:
[0408] Segment the database rows and build a high-frequency word matrix based on the segmentation statistics;
[0409] Based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases;
[0410] Grouping the database row records based on the target mutually exclusive phrase;
[0411] Optionally, the database data compression method further includes:
[0412] The mutually exclusive hierarchical dictionary tree is constructed according to the database row records.
[0413] Optionally, the step of constructing the mutually exclusive hierarchical dictionary tree according to the database row records includes:
[0414] Constructing a general dictionary of phrases according to the database row records;
[0415] A mutually exclusive hierarchical dictionary tree is determined based on the phrase total dictionary.
[0416] Optionally, the step of constructing a general phrase dictionary based on the database row records includes:
[0417] Split the character string in the database row record to generate initial phrases;
[0418] Performing word frequency statistics on the initial word group to determine the word frequency corresponding to the initial word group;
[0419] According to the frequency of the word, the initial word group corresponding to the word frequency is Huffman encoded to generate the total word group dictionary.
[0420] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary includes:
[0421] Extracting high-frequency words from the total word dictionary to determine high-frequency word groups;
[0422] Constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases;
[0423] A mutually exclusive hierarchical dictionary tree is determined based on the common root dictionary and the mutually exclusive dictionary set.
[0424] Optionally, the step of constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases includes:
[0425] According to each of the high-frequency phrases, construct a high-frequency word truth value matrix;
[0426] Accumulating the high-frequency word truth value matrix row by row to generate a high-frequency word accumulation matrix;
[0427] Constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix;
[0428] The mutually exclusive dictionary set is constructed according to the row data of the high-frequency word accumulation matrix.
[0429] Optionally, the step of constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix includes:
[0430] Calculate the cumulative sum and variance of the column data of the high-frequency word accumulation matrix;
[0431] In the high-frequency word accumulation matrix, high-frequency word groups whose cumulative sum is greater than a preset first threshold and whose variance is less than a preset second threshold are removed to obtain a target high-frequency word accumulation matrix;
[0432] The high-frequency word group in the target high-frequency word accumulation matrix is determined as the common root dictionary.
[0433] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix includes:
[0434] Determine the high-frequency phrase group corresponding to the preset target value of the row data of the high-frequency word accumulation matrix as the target high-frequency phrase group;
[0435] In the high-frequency word accumulation matrix, determining mutually exclusive words, strongly associated words, and weakly associated words corresponding to the target high-frequency word group;
[0436] A corresponding dictionary is established based on the mutually exclusive words and the strongly associated words to generate the mutually exclusive dictionary set.
[0437] Optionally, the step of determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency word group in the high-frequency word accumulation matrix includes:
[0438] Determine the index position value of the target high-frequency phrase;
[0439] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is greater than a preset third threshold as the mutually exclusive word;
[0440] In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is less than a preset fourth threshold as the strongly associated word;
[0441] Determine that the high-frequency word group whose row number in the high-frequency word accumulation matrix is less than a preset fifth threshold is a weakly associated word.
[0442] Optionally, the step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix further includes:
[0443] The weakly associated words are deleted from the high-frequency word accumulation matrix.
[0444] Optionally, the method further comprises:
[0445] The weakly associated words are compressed independently.
[0446] Optionally, the step of determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set comprises:
[0447] Build the common root dictionary as a first-level dictionary;
[0448] Grouping the mutually exclusive dictionary sets;
[0449] The grouped mutually exclusive dictionary set is constructed as a secondary dictionary;
[0450] The first-level dictionary and the second-level dictionary are combined to generate the mutually exclusive hierarchical dictionary tree.
[0451] Optionally, the step of determining at least one set of target mutually exclusive phrases from the database row records based on the high-frequency word matrix includes:
[0452] Based on the high-frequency word matrix, the database row records are traversed to determine the at least one group of target mutually exclusive phrases.
[0453] Optionally, the step of grouping the database row records based on the target mutually exclusive phrases includes:
[0454] For each of the target mutually exclusive phrases, the database row records having the target mutually exclusive phrases are grouped into the same group.
[0455] Optionally, the step of replacing the database row record for each group with the corresponding dictionary node code to generate compressed block data includes:
[0456] For each group of words in the database row record, replace them with the corresponding dictionary node code to generate coded data;
[0457] The coded data is compression-coded to generate compressed block data.
[0458] Optionally, the step of compressing and encoding the encoded data to generate compressed block data includes:
[0459] The encoded data is subjected to dictionary Huffman encoding to generate the compressed block data.
[0460] Optionally, the step of replacing the phrases in the database row records of each group with corresponding dictionary node codes to generate compressed block data further includes:
[0461] The compressed block data of different groups are merged to generate data block data.
[0462] Optionally, the step of merging the compressed block data of different groups to generate data block data includes:
[0463] Determining meta information of the compressed block data of the different groups; the meta information is located at an index position of the compressed block data;
[0464] The compressed block data and corresponding meta information of the different groups are merged to generate data block data.
[0465] Optionally, the method further comprises:
[0466] The row meta information of the database row record is established according to the meta information.
[0467] Optionally, the step of establishing row meta information of the database row record according to the meta information includes:
[0468] Determining a row record access frequency of a database row record of a compressed block corresponding to the meta information;
[0469] In response to the row record access frequency being lower than a preset access threshold, performing the determining of the meta information of the compressed block data of the different groups;
[0470] In response to the row record access frequency being not lower than a preset access threshold, the meta information of the compressed block data of the different groups is combined to generate the row meta information.
[0471] Optionally, the database data compression method further includes:
[0472] receiving a search instruction, wherein the search instruction carries a search mutually exclusive phrase;
[0473] Determines the target row records that match the search mutually exclusive phrase.
[0474] Optionally, the step of determining a target row record matching the mutually exclusive phrase to be searched includes:
[0475] Determine the data block whose index position matches the search mutually exclusive phrase as the target data block;
[0476] Determine the row record corresponding to the target data block as the target row record.
[0477] Optionally, the database data compression method further includes:
[0478] Determine a row record count value corresponding to the target row record;
[0479] The row record count value is fed back.
[0480] Optionally, the database data compression method further includes:
[0481] Decompress the target row record.
[0482] Optionally, the target row record corresponds to a decompression priority; the decompression priority corresponds to the mutually exclusive phrase;
[0483] The step of decompressing the target row record comprises:
[0484] Determine the decompression priority of the target row record;
[0485] In response to the decompression priority being the first priority, preferentially decompressing the data block corresponding to the target row record;
[0486] In response to the decompression priority being the second priority, the data block corresponding to the target row record is conventionally decompressed.
[0487] Optionally, the method further comprises:
[0488] Get historical search terms; hot search terms are input search terms;
[0489] Perform word frequency statistics on the historical search terms to determine hot search terms;
[0490] Grouping database row records matching the hot search term into the same group;
[0491] The database row records that do not match the hot search term are divided into another same group.
[0492] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0493] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0494] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0495] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0496] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0497] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0498] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0499] The above is a detailed introduction to a database data compression method, an electronic device, a storage medium and a program product provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A database data compression method, characterized in that: include: Segment the database rows and build a high-frequency word matrix based on the segmentation statistics; Based on the high-frequency word matrix, determining at least one set of target mutually exclusive phrases from the database row records, the high-frequency word matrix corresponding to a mutually exclusive hierarchical dictionary tree, the mutually exclusive hierarchical dictionary tree having multiple levels of mutually exclusive word dictionary nodes, the mutually exclusive word dictionary nodes including mutually exclusive phrases and dictionary node codes corresponding to the mutually exclusive phrases; For each of the target mutually exclusive phrases, merging database row records having the target mutually exclusive phrases into the same group; For each group of database row records, replace them with the corresponding dictionary node code to generate compressed block data; The step of replacing the database row record for each group with the corresponding dictionary node code to generate compressed block data includes: replacing the phrases in the database row record for each group with the corresponding dictionary node code to generate encoded data; and compressing and encoding the encoded data to generate compressed block data.
2. The database data compression method according to claim 1, characterized in that: The database data compression method also includes: The mutually exclusive hierarchical dictionary tree is constructed according to the database row records.
3. The database data compression method according to claim 2, characterized in that: The step of constructing the mutually exclusive hierarchical dictionary tree according to the database row records comprises: Constructing a general dictionary of phrases according to the database row records; A mutually exclusive hierarchical dictionary tree is determined based on the phrase total dictionary.
4. The database data compression method according to claim 3, characterized in that: The step of constructing a general word dictionary based on the database row records includes: Split the character string in the database row record to generate initial phrases; Performing word frequency statistics on the initial word group to determine the word frequency corresponding to the initial word group; According to the frequency of the word, the initial word group corresponding to the word frequency is Huffman encoded to generate the total word group dictionary.
5. The database data compression method according to claim 3, characterized in that: The step of determining a mutually exclusive hierarchical dictionary tree based on the phrase total dictionary comprises: Extracting high-frequency words from the total word dictionary to determine high-frequency word groups; Constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases; A mutually exclusive hierarchical dictionary tree is determined based on the common root dictionary and the mutually exclusive dictionary set.
6. The database data compression method according to claim 5, characterized in that: The step of constructing a common root dictionary and a mutually exclusive dictionary set based on the high-frequency phrases comprises: According to each of the high-frequency phrases, construct a high-frequency word truth value matrix; Accumulating the high-frequency word truth value matrix row by row to generate a high-frequency word accumulation matrix; Constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix; The mutually exclusive dictionary set is constructed according to the row data of the high-frequency word accumulation matrix.
7. The database data compression method according to claim 6, characterized in that: The step of constructing the common root dictionary according to the column data of the high-frequency word accumulation matrix comprises: Calculate the cumulative sum and variance of the column data of the high-frequency word accumulation matrix; In the high-frequency word accumulation matrix, high-frequency word groups whose cumulative sum is greater than a preset first threshold and whose variance is less than a preset second threshold are removed to obtain a target high-frequency word accumulation matrix; The high-frequency word group in the target high-frequency word accumulation matrix is determined as the common root dictionary.
8. The database data compression method according to claim 6, characterized in that: The step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix comprises: Determine the high-frequency phrase group corresponding to the preset target value of the row data of the high-frequency word accumulation matrix as the target high-frequency phrase group; In the high-frequency word accumulation matrix, determining mutually exclusive words, strongly associated words, and weakly associated words corresponding to the target high-frequency word group; A corresponding dictionary is established based on the mutually exclusive words and the strongly associated words to generate the mutually exclusive dictionary set.
9. The database data compression method according to claim 8, characterized in that: The step of determining the mutually exclusive words, strongly associated words and weakly associated words corresponding to the target high-frequency phrase in the high-frequency word accumulation matrix comprises: Determine the index position value of the target high-frequency phrase; In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is greater than a preset third threshold as the mutually exclusive word; In the high-frequency word accumulation matrix, determining the high-frequency word group whose difference with the index position value is less than a preset fourth threshold as the strongly associated word; Determine that the high-frequency word group whose row number in the high-frequency word accumulation matrix is less than a preset fifth threshold is a weakly associated word.
10. The database data compression method according to claim 8, characterized in that: The step of constructing the mutually exclusive dictionary set according to the row data of the high-frequency word accumulation matrix also includes: The weakly associated words are deleted from the high-frequency word accumulation matrix.
11. The database data compression method according to claim 8, characterized in that: The method further comprises: The weakly associated words are compressed independently.
12. The database data compression method according to claim 5, characterized in that: The step of determining a mutually exclusive hierarchical dictionary tree based on the common root dictionary and the mutually exclusive dictionary set comprises: Build the common root dictionary as a first-level dictionary; Grouping the mutually exclusive dictionary sets; The grouped mutually exclusive dictionary set is constructed as a secondary dictionary; The first-level dictionary and the second-level dictionary are combined to generate the mutually exclusive hierarchical dictionary tree.
13. The database data compression method according to claim 1, characterized in that: The step of determining at least one set of target mutually exclusive phrases from the database row records based on the high-frequency word matrix comprises: Based on the high-frequency word matrix, the database row records are traversed to determine the at least one group of target mutually exclusive phrases.
14. The database data compression method according to claim 1, characterized in that: The step of compressing and encoding the coded data to generate compressed block data comprises: The encoded data is subjected to dictionary Huffman encoding to generate the compressed block data.
15. The database data compression method according to claim 14, characterized in that: The step of replacing the phrases in the database row records of each group with the corresponding dictionary node codes to generate compressed block data also includes: The compressed block data of different groups are merged to generate data block data.
16. The database data compression method according to claim 15, characterized in that: The step of merging the compressed block data of different groups to generate data block data comprises: Determining meta information of the compressed block data of the different groups; the meta information is located at an index position of the compressed block data; The compressed block data and corresponding meta information of the different groups are merged to generate data block data.
17. The database data compression method according to claim 16, characterized in that: The method further comprises: The row meta information of the database row record is established according to the meta information.
18. The database data compression method according to claim 17, characterized in that: The step of establishing row meta information of the database row record according to the meta information comprises: Determining a row record access frequency of a database row record of a compressed block corresponding to the meta information; In response to the row record access frequency being lower than a preset access threshold, performing the determining of the meta information of the compressed block data of the different groups; In response to the row record access frequency being not lower than a preset access threshold, the meta information of the compressed block data of the different groups is combined to generate the row meta information.
19. The database data compression method according to claim 16, characterized in that: The database data compression method also includes: receiving a search instruction, wherein the search instruction carries a search mutually exclusive phrase; Determines the target row records that match the search mutually exclusive phrase.
20. The database data compression method according to claim 19, characterized in that: The step of determining the target row record matching the mutually exclusive phrase to be searched comprises: Determine the data block whose index position matches the search mutually exclusive phrase as the target data block; Determine the row record corresponding to the target data block as the target row record.
21. The database data compression method according to claim 20, characterized in that: The database data compression method also includes: Determine a row record count value corresponding to the target row record; The row record count value is fed back.
22. The database data compression method according to claim 20, characterized in that: The database data compression method also includes: Decompress the target row record.
23. The database data compression method according to claim 22, characterized in that: The target row record corresponds to a decompression priority; the decompression priority corresponds to the mutually exclusive phrase; the step of decompressing the target row record includes: Determine the decompression priority of the target row record; In response to the decompression priority being the first priority, preferentially decompressing the data block corresponding to the target row record; In response to the decompression priority being the second priority, the data block corresponding to the target row record is conventionally decompressed.
24. The database data compression method according to claim 1, characterized in that: The method further comprises: Get historical search terms; hot search terms are input search terms; Perform word frequency statistics on the historical search terms to determine hot search terms; Grouping database row records matching the hot search term into the same group; The database row records that do not match the hot search term are divided into another same group.
25. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the database data compression method according to any one of claims 1 to 24 when executed by the processor.
26. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the database data compression method according to any one of claims 1 to 24 are implemented.
27. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the steps of the database data compression method according to any one of claims 1 to 24 are implemented.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and storage medium
CN114764557A
Text compression method, module, chip, electronic device, and storage medium
US20230394225A1
Textual database management, storage and retrieval system utilizing word-oriented, dictionary-based data compression / decompression
US5893102A
Near-synonym pushing method and apparatus, electronic device, and medium
WO2021174783A1
Person profile finder using semantic similarity measurement of object based on internet source and related keywords
WO2022025750A1
