Index system, data processing method and query optimization device
Through the dynamic index structure based on frequency calculation and the use of two-dimensional fingerprint matrix and hash function, the performance problems caused by the uneven data frequency distribution in dynamic data stream processing are solved, efficient data storage and query optimization are achieved, and large-scale improvements are made. Data processing efficiency.
Patent Information
- Application Number
- CN202410998880.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-07-24
AI Technical Summary
The performance of existing databases and data warehouses is affected when processing dynamic data flows, and they lack effective dynamic data index structures. Especially when the data frequency distribution is uneven, it is difficult to achieve efficient data processing and query optimization.
Adopt a dynamic index structure based on frequency calculation, realize efficient storage and query of data through two-dimensional fingerprint matrix and hash function, use frequency calculation function to determine the data storage range, store high-frequency data in a centralized manner, store low-frequency data in a decentralized manner, and improve the efficiency of the index. Space utilization and query performance.
On the premise of maintaining high space utilization and high query performance, dynamic data flows with uneven data frequency distribution are dynamically processed, which improves the efficiency of big data processing and query optimization capabilities.
Smart Images

Figure CN118519971B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to an index system, a data processing method and a query optimization device. Background Art
[0002] At present, the amount of data is growing exponentially, and how to efficiently store, process and analyze this massive amount of data has become an important research topic. Especially in the field of big data processing, the processing of dynamic data streams and query optimization are the keys to improving data processing capabilities.
[0003] Database and data warehouse technologies perform well when processing static data sets, but their performance is often severely affected when facing dynamically changing data streams. Although the industry now tends to use a combination of big data computing engines and data lakes when processing dynamic data, the problem of lack of dynamic data indexes has not been solved. Dynamic data streams are constantly changing, which requires the index structure to adapt to the real-time update and query requirements of data.
[0004] In addition, dynamic data streams often exhibit the characteristic of uneven data frequency distribution, that is, a small amount of high-frequency data occupies most of the storage and query load, while a large amount of low-frequency data is scattered in various locations. Summary of the invention
[0005] In the first aspect, the present invention provides an indexing system, which is an improved dynamic indexing structure based on frequency calculation, and can improve the data processing capability of a large data processing device. The present invention implements fingerprint storage based on frequency, and can support efficient data insertion, deletion, and query operations while maintaining high space utilization, especially in processing dynamic data flow scenarios with uneven data frequency distribution characteristics. The indexing system proposed by the present invention is used in actual equipment to effectively improve the efficiency of large data processing in the industry.
[0006] An indexing system includes a data processing module and a two-dimensional fingerprint matrix;
[0007] The data processing module is used to execute the fingerprint storage method based on frequency calculation, including a frequency calculation function, a first hash function, a second hash function and two bit masks that are complementary to each other. The frequency calculation function is used to calculate the frequency of data in the data stream, and the data storage range is determined according to the calculated frequency result. The data storage range represents the distribution and span of the data storage position in the two-dimensional fingerprint matrix. The higher the frequency, the smaller the data storage range, and the lower the frequency, the larger the data storage range. The data storage position includes a first storage position, a second storage position, a third storage position and a fourth storage position. The first hash function is used to generate a fixed-length data fingerprint and a first storage position. The second hash function and the two bit masks that are complementary to each other are used to generate a hash fingerprint and a second storage position, a third storage position and a fourth storage position.
[0008] The two-dimensional fingerprint matrix includes a plurality of rows, each row includes a plurality of data bits, and each data bit is used to store the data fingerprint to identify whether the data exists; each of the storage locations is a row of the two-dimensional fingerprint matrix.
[0009] The present invention can calculate the data frequency in the case of processing a dynamic data flow with uneven data frequency distribution, and optimize the index query performance by centrally storing high-frequency data using the principle of data locality, and disperse the storage of low-frequency data to improve the space utilization of the index. The index system can be further used in a large data processing device as a component of a query optimization device to optimize the data processing capability of the large data processing device.
[0010] The present invention can realize dynamic processing of dynamic data streams with uneven data frequency distribution characteristics under the premise of ensuring high space utilization and high query performance.
[0011] The frequency calculation function described in the present invention may adopt existing technologies, such as minimum counting, sketch counting, and various improved frequency estimation algorithms.
[0012] In some embodiments, for any data , the first hash function calculates the data Data fingerprint , , Represents the first hash function and obtains the first storage location , , represents the modulo operation, Represents the total number of rows assigned to the two-dimensional fingerprint matrix, and the second hash function calculates the data fingerprint Hash fingerprint of , , Represents the second hash function and obtains the second storage location , , Represents an exclusive OR operation, using two bit masks that complement each other and Calculate the third storage location and the fourth storage location , Representation and operation, and satisfy , Indicates a left shift operation. The above four storage locations can be derived from each other.
[0013] In some embodiments, data will be stored in the idle data bits in the row with the least data load among the four rows of the two-dimensional fingerprint matrix, where the data load is the amount of data stored in the row of the two-dimensional fingerprint matrix.
[0014] In some embodiments, the indexing system dynamically maintains the data stream, each index is associated with a segment of the data stream, and the frequency calculation is performed based on the data stream data associated with the generated index, ensuring that the same data items in each segment of the data stream are assigned the same index, thereby maintaining accuracy when data is inserted.
[0015] In the present invention, the data storage range determines the regional range of the data storage location. The higher the calculation frequency, the smaller the data storage range, and the regional range of the data storage location tends to be concentrated in a smaller local area, which is convenient for the CPU or other high-speed hardware devices to perform one-time efficient reading and access. The lower the calculation frequency, the larger the data storage range, and the regional range of the data storage location will be larger, which is beneficial to improving the overall space utilization of the index system.
[0016] Methods for determining the data storage range include but are not limited to allocating according to a specific ratio according to the number of rows of the two-dimensional fingerprint matrix, allocating using a fixed value, etc.
[0017] In a second aspect, the present invention provides a data processing method, which utilizes the index system to maintain and use data, including any one or more of data insertion, data deletion, data merging, and data query.
[0018] The present invention can divide the dynamic data stream according to the user definition, based on the data volume or time interval, and initialize the index system.
[0019] In some embodiments, the data insertion comprises the steps of:
[0020] S21: using a frequency calculation function to calculate the frequency of the data to be inserted in the data stream, and then determining the data storage range;
[0021] S22: using the first hash function to determine the data fingerprint of the data to be inserted, and combining the second hash function and two bit masks that are complementary to each other to determine the data storage location of the data to be inserted;
[0022] S23: Check whether there is any free data bit in the two-dimensional fingerprint matrix at the data storage location determined in step S22;
[0023] If there are free data bits, select the row of the two-dimensional fingerprint matrix with the smallest data load in the data storage position determined in step S22, and store the data fingerprint of the data to be inserted into a data bit in the row;
[0024] If there is no free data bit, a data fingerprint with the same minimum number located in the data storage location determined in step S22 is randomly selected for kicking out, and the kicked out data fingerprint is stored in a free place in the four corresponding storage locations, and then the data fingerprint of the data to be inserted is stored in the free position obtained after the kick out;
[0025] If the data to be inserted cannot be successfully inserted after more than 1 / 4 of the total number of rows of the two-dimensional fingerprint matrix have been kicked out, the data fingerprint of the data to be inserted cannot be inserted into the index system. A new index system needs to be built, and then the data fingerprint of the data to be inserted is re-inserted into the new index system.
[0026] In some embodiments, the data deletion comprises the steps of:
[0027] S31: using a frequency calculation function to calculate the frequency of target data in the data stream, thereby determining a data storage range;
[0028] S32: using the first hash function to determine the data fingerprint of the target data, and combining the second hash function and two bit masks that are complementary to each other to determine the data storage location of the target data;
[0029] S33: Check whether there is a fingerprint identical to the data fingerprint of the target data in the four rows corresponding to the data storage location determined in step S32 in the two-dimensional fingerprint matrix;
[0030] If there are identical fingerprints, if there are multiple identical fingerprints, delete the corresponding data in the row with the highest data load. If there is only one identical fingerprint, delete the corresponding data directly.
[0031] In some embodiments, the data merging comprises the steps of:
[0032] S41: creating a new index system, and expanding the number of data bits in each row of the two-dimensional fingerprint matrix of the index system;
[0033] S42: inserting the data in the two index systems to be merged into the new index system according to the data.
[0034] In step S41, the number of data bits in each row of the two-dimensional fingerprint matrix of the index system may be expanded by any one or more of the following combinations:
[0035] a) expanding by a fixed multiple of the number of data bits per row in the larger or smaller two-dimensional fingerprint matrix of the two index systems to be merged;
[0036] b) expanding by a fixed cumulative number of the number of data bits per row in the larger or smaller two-dimensional fingerprint matrix in the two index systems to be merged;
[0037] c) expanding according to the sum of the number of data bits of each row in the two two-dimensional fingerprint matrices in the two index systems to be merged.
[0038] In some embodiments, the data query comprises the steps of:
[0039] S51: using a frequency calculation function to calculate the frequency of the data to be searched in the data stream, and then determining the data storage range;
[0040] S52: using the first hash function to determine the data fingerprint of the data to be found, and combining the second hash function and two bit masks that are complementary to each other to determine the data storage location of the data to be found;
[0041] S53: Check whether there is a fingerprint identical to the data fingerprint of the data to be searched in the four rows corresponding to the data storage location determined in step S52 in the two-dimensional fingerprint matrix;
[0042] If the same fingerprint exists, it indicates that there is data to be found in the index system;
[0043] If the same fingerprint does not exist, it indicates that the data to be searched does not exist in the index system.
[0044] In a third aspect, the present invention provides a query optimization device, including a data file and the corresponding index system;
[0045] The query optimization device uses the index system to determine whether the query data is in the data file. If the query data exists, the query optimization device reads and returns the query data. If the query data does not exist, the query optimization device skips the data file.
[0046] The query optimization device of the present invention utilizes the index system to optimize the big data processing device and improve the query efficiency of the big data processing framework for data streams and data on storage media.
[0047] The big data processing framework includes but is not limited to databases, data warehouses, data lakes, computing engines, etc., including big data storage media and big data processing devices.
[0048] The big data storage medium is used to store data in the storage medium and organize it in the form of data files. The data files are the organization form of the dynamic data stream after being stored in the storage medium.
[0049] The big data processing device is used to read data from the corresponding data files in the big data storage medium, and perform operations of querying and returning data.
[0050] A method for optimizing queries in a big data processing device comprises the steps of:
[0051] S61: The user initiates a request for querying data reading by interacting with the big data processing device, and the big data processing device determines a corresponding data file of the data stored in the big data storage medium;
[0052] S62: reading the index system corresponding to the data file from the storage medium, and quickly determining whether the query data exists in the data file through a data query method of the index system;
[0053] If the query data exists in the data file, the big data processing device needs to further read the data file and then return the data corresponding to the query data;
[0054] If the query data does not exist in the data file, the big data processing device can directly skip the data file, thereby saving the total amount of data files that need to be scanned, thereby optimizing the query efficiency.
[0055] Compared with the prior art, the present invention has the following beneficial effects:
[0056] The present invention can maintain indexes for dynamic data streams to support real-time queries. After the dynamic data streams are stored in storage media as data files, they can be used in a big data processing device to quickly determine whether the query data exists in the corresponding data file to achieve query optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A schematic diagram of an indexing system of the present invention.
[0058] Figure 2 The figure is a flowchart of a data insertion method.
[0059] Figure 3 The figure is a flowchart of a data deletion method.
[0060] Figure 4 A flowchart of a data merging method is shown in FIG. DETAILED DESCRIPTION
[0061] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0062] An indexing system includes a data processing module and a two-dimensional fingerprint matrix;
[0063] The data processing module is used to execute the fingerprint storage method based on frequency calculation, including a frequency calculation function, a first hash function, a second hash function and two bit masks that are complementary to each other. The frequency calculation function is used to calculate the frequency of data in the data stream, and the data storage range is determined according to the calculated frequency result. The data storage range represents the distribution and span of the data storage position in the two-dimensional fingerprint matrix. The higher the frequency, the smaller the data storage range, and the lower the frequency, the larger the data storage range. The data storage position includes a first storage position, a second storage position, a third storage position and a fourth storage position. The first hash function is used to generate a fixed-length data fingerprint and a first storage position. The second hash function and the two bit masks that are complementary to each other are used to generate a hash fingerprint and a second storage position, a third storage position and a fourth storage position.
[0064] The two-dimensional fingerprint matrix includes a plurality of rows, each row includes a plurality of data bits, and each data bit is used to store the data fingerprint to identify whether the data exists; each of the storage locations is a row of the two-dimensional fingerprint matrix.
[0065] For any data , the first hash function calculates the data Data fingerprint , , Represents the first hash function and obtains the first storage location , , represents the modulo operation, Represents the total number of rows assigned to the two-dimensional fingerprint matrix, and the second hash function calculates the data fingerprint Hash fingerprint of , , Represents the second hash function and obtains the second storage location , , Represents an exclusive OR operation, using two bit masks that complement each other and Calculate the third storage location and the fourth storage location , Representation and operation, and satisfy , Indicates left shift operation;
[0066] The above four storage locations can be derived from each other, and the data will be stored in the idle data bits in the row with the least data load among the four rows of the two-dimensional fingerprint matrix. The data load is the amount of data stored in the row of the two-dimensional fingerprint matrix.
[0067] Assume that the index system needs to maintain the name information in the data stream, and so far, the data inserted into the index system are Adam, Bob, Carl, Wendy, Xena, Yuri, Zane, and their data fingerprints are .
[0068] Assume data fingerprint The corresponding data are all high-frequency words, calculated by the frequency calculation function The frequencies obtained are higher than The data storage range is defined as a fixed value. , assuming , that is, the frequency is higher than The data is concentrated in 4 adjacent rows. In addition, the data fingerprint The corresponding data are all low-frequency words, and the frequency is and The data storage range is defined as 3 That is 12, which means the frequency is and The data between is distributed in four rows within the range of 12 rows. Assume that the data fingerprint here is The corresponding storage locations are rows , data fingerprint The corresponding storage locations are rows , Figure 1 This is a sample representation of the index system after some data has been inserted.
[0069] The index system dynamically maintains the data stream, each index is associated with a segment of the data stream, and the frequency calculation is performed based on the data stream data associated with the generated index, ensuring that the same data items in each segment of the data stream are assigned the same index.
[0070] A data processing method utilizes the index system to maintain and use data, including any one or more methods of data insertion, data deletion, data merging, and data query.
[0071] According to user definition, the dynamic data stream is divided based on data volume or time interval, and the indexing system is initialized.
[0072] First, divide the dynamic data stream according to the time span or data quantity, and divide it according to the data volume in the dynamic data stream segment. Figure 1 The structure shown initializes the index system, where the two-dimensional fingerprint matrix is allocated a total of rows, of which Indicates the amount of data. Each row is assigned four storage locations for data fingerprints. Assume that the number of bits of data fingerprint is , each row is assigned The space for the units.
[0073] According to the index system, an efficient data insertion method based on frequency calculation is designed to insert the dynamically inserted data into the index system in an adaptively distributed manner, while ensuring efficient space utilization and supporting efficient query. Figure 2 , data insertion specifically includes the following steps:
[0074] S21: Use a frequency calculation function to calculate the frequency of the data to be inserted in the data stream, and then determine the data storage range.
[0075] First, we can get the frequency calculation function based on the past data. Here we can use, but are not limited to, CountMin, CountSketch, Learned CM or Learned CS. Assume that the name data to be inserted is , whose data fingerprint is , the frequency of the data is calculated to be greater than .
[0076] The data storage range will be implemented based on the data frequency composite using a fixed value and the method of allocating according to the number of rows in the two-dimensional fingerprint matrix. Assume that the number of rows in the two-dimensional fingerprint matrix is ,in represents the amount of data, then the data According to the calculated frequency size ,according to Three threshold steps to allocate data range ,in , for calculating the frequency The data storage range is set to a fixed value. ;for Calculate frequency The data storage range can be set to a fixed value ;for Calculate frequency The data storage range can be set to a specific ratio of the number of rows in the two-dimensional fingerprint matrix, such as ;for For the frequency calculation data, the data storage range can be set to a specific ratio of the number of rows in another two-dimensional fingerprint matrix, such as .
[0077] Because of data fingerprinting The frequency is greater than , so the data fingerprint The data storage range of the corresponding data will be set to , here we assume is 4.
[0078] S22: Use the first hash function to determine the data fingerprint of the data to be inserted, and combine the second hash function and two bit masks that are complementary to each other to determine the data storage location of the data to be inserted.
[0079] For any data After obtaining the data storage range, the data can be further calculated by the first hash function Data fingerprint , , Represents the first hash function and obtains the first storage location , , represents the modulo operation, Represents the total number of rows assigned to the two-dimensional fingerprint matrix, and the second hash function calculates the data fingerprint Hash fingerprint of , , Represents the second hash function and obtains the second storage location , , Represents an exclusive OR operation, using two bit masks that complement each other and Calculate the third storage location and the fourth storage location , Representation and operation, and satisfy , The above four storage locations can be derived from each other, so the correct kick-out operation can be implemented to achieve the uniform distribution of data in the two-bit hash matrix as much as possible.
[0080] To simplify the explanation, we will directly use the data fingerprint The four storage locations corresponding to the corresponding data are set as four consecutive rows, namely Figure 2 As shown, row .
[0081] S23: Check whether there is any free data bit in the two-dimensional fingerprint matrix at the data storage location determined in step S22.
[0082] For example, four storage locations are traversed, the number of free locations in each row is checked and recorded, and if there is a free data location in at least one row, it is marked that there is a free data location, otherwise it is not present.
[0083] If there are free data bits, the row of the two-dimensional fingerprint matrix with the smallest data load in the data storage position determined in step S22 is selected, and the data fingerprint of the data to be inserted is stored in a data bit in the row.
[0084] For example, the number of free positions in the rows corresponding to the two-dimensional fingerprint matrix corresponding to the four storage positions is sorted, and then a row with the most free positions is selected, and then the data fingerprint to be inserted is stored in a data position of the row. Figure 2 As shown, due to the first insertion of fingerprint When , among the four storage locations, only row 10 has an empty position, so according to the sorting, the first inserted fingerprint will be Store in row 10.
[0085] If there are no free data bits, a data fingerprint with the same minimum number located in the data storage location determined in step S22 is randomly selected for kicking out, and the kicked out data fingerprint is stored in a free place in the four corresponding storage locations, and then the data fingerprint of the data to be inserted is stored in the free position obtained after kicking out.
[0086] For example, the number of data fingerprints in the rows of the two-dimensional fingerprint matrix corresponding to the four storage locations where the data is inserted is sorted, and then the data fingerprint with the least number is backed up, and the data fingerprint to be inserted is stored in the location in an overwrite manner, and then the backed-up data fingerprint is recursively inserted into the rows of the two-dimensional fingerprint matrix corresponding to the other three storage locations of the fingerprint. Figure 2 As shown, due to the second fingerprint insertion When , all four storage locations are full, so they need to be kicked out. Here, it is assumed that the fingerprint to be kicked out is , so fingerprint will be stored in its corresponding location, and the fingerprint It will be kicked out to the row with the smallest data load among its corresponding candidate positions, that is, row 1.
[0087] If the data to be inserted cannot be successfully inserted after more than 1 / 4 of the total number of rows in the two-dimensional fingerprint matrix have been kicked out, the data fingerprint of the data to be inserted cannot be inserted into the index system, and a new index system needs to be built, and then the data fingerprint of the data to be inserted is re-inserted into the new index system. For example, according to the initialization process, an index system is rebuilt, and then based on the data as the demarcation point, the index system is maintained for the dynamic data stream based on the newly built index system.
[0088] According to the index system, an efficient deletion method based on frequency calculation is designed to delete the fingerprints corresponding to the data that needs to be dynamically deleted in the index system. Figure 3 , specifically including the steps:
[0089] S31: Use the frequency calculation function to calculate the frequency of the target data in the data stream, and then determine the data storage range. For details, please refer to the introduction of step S21.
[0090] S32: Use the first hash function to determine the data fingerprint of the target data, and combine the second hash function and two complementary bit masks to determine the data storage location of the target data. For details, please refer to the introduction of step S22.
[0091] S33: Check whether there is a fingerprint identical to the data fingerprint of the target data in the four rows corresponding to the data storage location determined in step S32 in the two-dimensional fingerprint matrix.
[0092] For example, four storage locations are traversed, and the data fingerprint of the target data is compared with the data fingerprint stored in each row. If the same data fingerprint exists, the number of the data fingerprint in each row is returned, otherwise it is returned that it does not exist.
[0093] If there are identical fingerprints, if there are multiple identical fingerprints, delete the corresponding data in the row with the highest data load. If there is only one identical fingerprint, delete the corresponding data directly.
[0094] Assume that the data is to be deleted , then its fingerprint Among the four corresponding candidate positions, there are 3 identical fingerprints in row 7, 2 in row 8, and 1 each in row 9 and row 10, so one fingerprint in row 7 will be deleted. , after deletion, the result is as follows Figure 3 shown.
[0095] According to the index system, an efficient index merging method is designed. When the data fingerprint load in two or more index systems is small, merging can be realized to save storage space and improve query efficiency. Figure 4 , specifically including the steps:
[0096] S41: Create a new index system and expand the number of data bits in each row of the two-dimensional fingerprint matrix of the index system.
[0097] For example, suppose two index systems need to be merged, and the number of data fingerprints stored in each row in the two index systems is and , then the data fingerprint that can be accommodated in each row of the newly created index system is Similarly, if there are multiple index systems, the number of data fingerprints that can be accommodated in each row of the newly created index system is the cumulative sum of the number of data fingerprints that can be accommodated in each row of the original index systems.
[0098] like Figure 4 As shown, when merging two index systems, since the number of data fingerprints stored in each row of the original two index systems is 2 and 2 respectively, the number of data fingerprints stored in each row of the newly created index system is set to 4, and all data fingerprints in the original index systems are inserted into the corresponding rows of the newly created index system.
[0099] S42: inserting the data in the two index systems to be merged into the new index system according to the data.
[0100] For example, according to the data insertion method described above, the data fingerprint in the original index system is inserted into the newly created index system. To improve efficiency, it is also possible to directly insert the data fingerprint in the original index system into the corresponding row in the newly created index system, and then redistribute the data of the newly created index system in the background, that is, insert the data in the row with a larger load into its corresponding other rows to achieve load balancing.
[0101] According to the index system, an efficient query method based on frequency calculation is designed, which can perform real-time query and quickly return results when facing dynamic query, and specifically includes the following steps:
[0102] S51: Use the frequency calculation function to calculate the frequency of the data to be searched in the data stream, and then determine the data storage range. For details, please refer to the introduction of step S21.
[0103] S52: Use the first hash function to determine the data fingerprint of the data to be found, and combine the second hash function and two complementary bit masks to determine the data storage location of the data to be found. For details, please refer to the introduction of step S22.
[0104] S53: Check whether there is a fingerprint identical to the data fingerprint of the data to be searched in the four rows corresponding to the data storage location determined in step S52 in the two-dimensional fingerprint matrix.
[0105] For example, four storage locations are traversed, and the data fingerprint to be found is compared with the data fingerprints stored in each row. If the first identical data fingerprint is found, it is directly returned that it exists, otherwise it is returned that it does not exist.
[0106] If the same fingerprint exists, it indicates that there is data to be found in the index system;
[0107] If the same fingerprint does not exist, it indicates that the data to be searched does not exist in the index system.
[0108] A query optimization device, comprising a data file and the corresponding index system;
[0109] The query optimization device uses the index system to determine whether the query data is in the data file. If the query data exists, the query optimization device reads and returns the query data. If the query data does not exist, the query optimization device skips the data file.
[0110] Based on the indexing system, a method for optimizing queries in a big data processing device is designed. When a user initiates a data query request, the big data processing device first uses the indexing system to quickly determine whether the query data is in the data file. If the data exists, the device reads and returns the data; if not, the device skips the file to improve query efficiency.
[0111] Specifically, it can be divided into the following sub-steps:
[0112] S61: The user initiates a request for querying data reading by interacting with the big data processing device, and the big data processing device determines a corresponding data file of the data stored in the big data storage medium;
[0113] Specifically, the user can send a query request to a big data processing device including but not limited to a database, a data warehouse, a data lake, or a computing engine. Suppose the user wants to query the data stream for data, then the big data processing device will first find the location of all data files in the table T corresponding to the data stream. Assume that there are only two data files here. and .
[0114] S62: Reading the index system corresponding to the data file from the storage medium, and quickly determining whether the query data exists in the data file through the data query method of the index system.
[0115] Assume data file Indexing system Corresponding to Figure 3 The structure shown, and the data file Indexing system There is no data in The corresponding fingerprint .
[0116] S63: If the query data exists in the data file, the big data processing device needs to further read the data file and then return the data corresponding to the query data.
[0117] Through the query method, the results can be obtained quickly, because Fingerprints exist in , so the big data processing device needs to further scan the data files To obtain relevant data results.
[0118] S64: If the query data does not exist in the data file, the big data processing device can directly skip the data file, thereby saving the total amount of data files that need to be scanned, thereby optimizing the query efficiency.
[0119] because No fingerprint exists in , so the big data processing device can directly skip the data file , thus reducing the total number of documents scanned by the big data processing device by 50%.
[0120] In addition, it should be understood that after reading the above description of the present invention, those skilled in the art may make various changes or modifications to the present invention, and these equivalent forms also fall within the scope defined by the claims attached to this application.
Claims
1. An indexing system, characterized in that: It includes a data processing module and a two-dimensional fingerprint matrix; The data processing module is used to execute the fingerprint storage method based on frequency calculation, including a frequency calculation function, a first hash function, a second hash function and two bit masks that are complementary to each other. The frequency calculation function is used to calculate the frequency of data in the data stream, and the data storage range is determined according to the calculated frequency result. The data storage range represents the distribution and span of the data storage position in the two-dimensional fingerprint matrix. The higher the frequency, the smaller the data storage range, and the lower the frequency, the larger the data storage range. The data storage position includes a first storage position, a second storage position, a third storage position and a fourth storage position. The first hash function is used to generate a fixed-length data fingerprint and a first storage position. The second hash function and the two bit masks that are complementary to each other are used to generate a hash fingerprint and a second storage position, a third storage position and a fourth storage position. The two-dimensional fingerprint matrix includes a plurality of rows, each row includes a plurality of data bits, and each data bit is used to store the data fingerprint to identify whether the data exists; each of the storage locations is a row of the two-dimensional fingerprint matrix; For any data , the first hash function calculates the data Data fingerprint , , Represents the first hash function and obtains the first storage location , , represents the modulo operation, Represents the total number of rows assigned to the two-dimensional fingerprint matrix, and the second hash function calculates the data fingerprint Hash fingerprint of , , Represents the second hash function and obtains the second storage location , , Represents an exclusive OR operation, using two bit masks that complement each other and Calculate the third storage location and the fourth storage location , Representation and operation, and satisfy , Indicates left shift operation; The data will be stored in the idle data bits in the row with the least data load among the four rows of the two-dimensional fingerprint matrix, where the data load is the amount of data stored in the row of the two-dimensional fingerprint matrix.
2. The indexing system according to claim 1, characterized in that: The index system dynamically maintains the data stream, each index is associated with a segment of the data stream, and the frequency calculation is performed based on the data stream data associated with the generated index, ensuring that the same data items in each segment of the data stream are assigned the same index.
3. A data processing method, characterized in that: The index system described in claim 1 or 2 is used to maintain and use data, including any one or more of data insertion, data deletion, data merging, and data query.
4. The data processing method according to claim 3, characterized in that: According to user definition, the dynamic data stream is divided based on data volume or time interval, and the indexing system is initialized.
5. The data processing method according to claim 3, characterized in that: The data insertion comprises the steps of: S21: using a frequency calculation function to calculate the frequency of the data to be inserted in the data stream, and then determining the data storage range; S22: using the first hash function to determine the data fingerprint of the data to be inserted, and combining the second hash function and two bit masks that are complementary to each other to determine the data storage location of the data to be inserted; S23: Check whether there is any free data bit in the two-dimensional fingerprint matrix at the data storage location determined in step S22; If there are free data bits, select the row of the two-dimensional fingerprint matrix with the smallest data load in the data storage position determined in step S22, and store the data fingerprint of the data to be inserted into a data bit in the row; If there is no free data bit, a data fingerprint with the same minimum number located in the data storage location determined in step S22 is randomly selected for kicking out, and the kicked out data fingerprint is stored in a free place in the four corresponding storage locations, and then the data fingerprint of the data to be inserted is stored in the free position obtained after the kick out; If the data to be inserted cannot be successfully inserted after more than 1 / 4 of the total number of rows of the two-dimensional fingerprint matrix have been kicked out, the data fingerprint of the data to be inserted cannot be inserted into the index system. A new index system needs to be built, and then the data fingerprint of the data to be inserted is re-inserted into the new index system.
6. The data processing method according to claim 3, characterized in that: The data deletion comprises the steps of: S31: using a frequency calculation function to calculate the frequency of target data in the data stream, thereby determining a data storage range; S32: using the first hash function to determine the data fingerprint of the target data, and combining the second hash function and two bit masks that are complementary to each other to determine the data storage location of the target data; S33: Check whether there is a fingerprint identical to the data fingerprint of the target data in the four rows corresponding to the data storage location determined in step S32 in the two-dimensional fingerprint matrix; If there are identical fingerprints, if there are multiple identical fingerprints, delete the corresponding data in the row with the highest data load. If there is only one identical fingerprint, delete the corresponding data directly.
7. The data processing method according to claim 5, characterized in that: The data merging comprises the steps of: S41: creating a new index system, and expanding the number of data bits in each row of the two-dimensional fingerprint matrix of the index system; S42: inserting the data in the two index systems to be merged into the new index system according to the data.
8. The data processing method according to claim 3, characterized in that: The data query comprises the steps of: S51: using a frequency calculation function to calculate the frequency of the data to be searched in the data stream, and then determining the data storage range; S52: using the first hash function to determine the data fingerprint of the data to be found, and combining the second hash function and two bit masks that are complementary to each other to determine the data storage location of the data to be found; S53: Check whether there is a fingerprint identical to the data fingerprint of the data to be searched in the four rows corresponding to the data storage location determined in step S52 in the two-dimensional fingerprint matrix; If the same fingerprint exists, it indicates that there is data to be found in the index system; If the same fingerprint does not exist, it indicates that the data to be searched does not exist in the index system.
9. A query optimization device, characterized in that: comprising a data file and a corresponding index system as claimed in claim 1 or 2; The query optimization device uses the index system to determine whether the query data is in the data file. If the query data exists, the query optimization device reads and returns the query data. If the query data does not exist, the query optimization device skips the data file.
