An application-driven data storage and indexing method
Through the application-driven column-based storage and B+ tree index structure, the efficiency of massive number of call list data storage and analysis is solved, efficient storage and query is achieved, adapting to the expansion of call list fields, and improving the utilization of data value.
Patent Information
- Application Number
- CN201810039941.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-01-16
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2038-01-16
AI Technical Summary
When the existing technology processes massive volume of call order data, traditional relational database storage methods are difficult to provide effective data analysis support, while distributed processing solutions are costly and fail to fully mine data value, and the expansion of call order fields brings new storage and indexing challenges.
Adopting an application-driven data storage method, by storing each field by column and using a B+ tree index structure, the file name contains field flags, start time and range, and combining flag bits and forward difference method to optimize storage space and query efficiency.
It improves the efficiency of storage space and indexing rate, and can flexibly select required fields for querying, reducing the problem of reducing query efficiency when data volume increases, and saving hard disk space.
Smart Images

Figure CN110109914B
Abstract
Description
Technical Field
[0001] The invention relates to an application-driven data storage and indexing method, and belongs to the technical field of data processing. Background Art
[0002] With the growth of Internet information, a large amount of data needs to be stored, which requires more hard disk devices. As the amount of data continues to grow, the types of data are also increasing. As one of the many types of data, the volume of call records is increasing, and the fields in the call record format are also expanding.
[0003] Different types of applications have different requirements for data storage and analysis. It is undoubtedly more efficient to customize different solutions for different data types than to use a unified storage platform. Application-driven means customizing differentiated storage solutions for different application needs.
[0004] Multi-dimensional refers to multiple angles. Through specific methods, users can quickly and efficiently obtain the data from the specific angles they need, which is of great benefit to subsequent work. Subsequent analysis does not require secondary processing of the data to obtain specific basic data for analysis.
[0005] There are currently two situations facing call bill data: one is that it is stored in traditional relational databases, which are relatively flexible and have absolute advantages in processing short-term data. However, when faced with massive amounts of data, its storage method cannot provide effective help for subsequent data analysis; the other is that a distributed processing solution is adopted, which directly adopts some common distributed technologies, which guarantees the data scale and query rate, but the cost is high and the value of call bill data is not fully tapped.
[0006] In order to improve the application value of call record data and respond to the expansion of call record fields, it is particularly important to find a suitable storage and indexing method. Summary of the invention
[0007] In view of this, the present invention provides an application-driven data storage and indexing method. As information grows, users use data more and more frequently, and an effective method for flexible indexing based on storage is provided. This method can improve the efficiency of storage space usage and provide a higher indexing rate.
[0008] The present invention solves the above technical problems by the following technical means:
[0009] An application-driven data storage method of the present invention stores data in columns, each column is not completely independent, a single file storage content contains only one field, each field is preceded by a flag bit, indicating the number of storage contents of the field in the file, and other corresponding fields also have corresponding flag bits, and different fields of the same record have the same row number flag in different files;
[0010] The file name contains three fields: field flag, the start time of storing the file, and the range of the field in the file. The start time field of storing the file ensures the uniqueness of the file, and the field flag and the range of the field in the file ensure the establishment of subsequent indexes.
[0011] An application-driven data indexing method, the indexing method adopts the form of B+ tree, which includes:
[0012] Use the three fields in the file name as the data for building a B+ tree. Take the maximum value of the field range of the file as the key and the first five digits of the start time as the value to build a B+ tree. Similarly, take the minimum value of the field range of the file as the key and the last five digits of the start time as the value to build a B+ tree.
[0013] To query the time of the field, query two B+ trees at the same time, combine the query results into ranges, add field markers to locate the file, and finally query the specific content in the file.
[0014] An application-driven data storage method places flags in front of three field contents. Each time a piece of information is obtained, the encoded field content is compared with the data in the corresponding memory. If the same content already exists, the encoded flag corresponding to the newly obtained field content is added to the front of the existing field. If the content does not exist, the new field and flag are encoded and added to the corresponding memory.
[0015] An application-driven data indexing method, based on the fact that the data in the memory has been written into the file, there are two ways to obtain the leaf nodes of the B+ tree. One is to obtain from the memory variable, monitor the memory dynamics at any time, and obtain the start time and field range when executing the write file operation. The other is to obtain directly from the file name;
[0016] Get the time and field range in the file name. The standard time length is 10, divided into two fields with five digits each. At the same time, take out the maximum and minimum values of the field range. The maximum value and the first five digits of the time form a dictionary. The maximum value is the key, and the first five digits of the time are the value. The minimum value and the last five digits of the time form a dictionary. The minimum value is the key, and the last five digits of the time are the value.
[0017] The key-value pairs obtained are used as leaf nodes of the B+ tree, and two B+ trees are established. When querying, the two B+ trees are queried at the same time, and the query results are combined into field ranges, and field flags are added to find the corresponding files in the file list.
[0018] The process of establishing and updating the B+ tree is as follows:
[0019] Step 1: Determine whether the key-value is a leaf node. If so, go to step 3; if not, go to step 2;
[0020] Step 2: Determine the number of leaf nodes and the type of child nodes. If the number of nodes is greater than 1, use binary search to find the insertion position. If the number of nodes is 1, compare the size of the key and then determine the node type. If the node type is a leaf node, go to step 3. If the node type is a non-leaf node, continue with step 2.
[0021] Step 3: Determine the status of the leaf node. If the node status is empty, insert data. If it is not empty, determine the number of leaf nodes. When the number of leaf nodes is greater than 1, use binary search to find the insertion position, and then go to step 4. When the number of leaf nodes is equal to 1, go directly to step 4.
[0022] Step 4: Compare the size of the leaf node and the data to determine whether the leaf node is full. If the leaf node is not full, insert the data. If the leaf node is full, split the B+ tree and go to step 5.
[0023] Step 5: Create a parent node. If it is, insert data. If not, determine the number of nodes and node type. If the node is not full, insert data. If the node is full, continue with step 5.
[0024] The present invention divides the data into files of a specified size for storage, and stores the time field and data-related information in the file name, which can ensure the uniqueness of the file and a certain amount of information;
[0025] Use binary representation flags to reduce the length of file names;
[0026] When the content of the same field is not very different, using the forward difference method can effectively save hard disk space;
[0027] Use B+ tree to create indexes, so that query efficiency will not be significantly reduced even if the amount of data increases;
[0028] By using column storage, you can flexibly select the required fields for query and extraction.
[0029] Beneficial effects of the present invention: With the growth of information, users use data more and more frequently, and an effective method for flexible indexing based on storage is provided, which can improve the efficiency of storage space utilization and provide a higher indexing rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0031] Figure 1 is a flow chart of a method for storing data provided by Embodiment 1 of the present invention;
[0032] Figure 2 is a flow chart of a method for establishing an index provided by Embodiment 2 of the present invention;
[0033] Figure 3 This is the flow chart for establishing and updating the B+ tree. DETAILED DESCRIPTION
[0034] The present invention will be described in detail below with reference to the accompanying drawings. Figure 1 , 2 As shown in Figure 3: In order to make the objectives, technical solutions and advantages of the present invention more clear, the implementation methods of the present invention will be further described in detail below in conjunction with the accompanying drawings.
[0035] An application-driven data storage method, where data is stored in columns. Each column is not completely independent. A single file stores only one field. Each field has a flag, indicating the first row of the file in which the field is stored. Other fields also have corresponding flags. Different fields of the same record have the same row number flag in different files.
[0036] The file name contains three fields: field flag, the start time of storing the file, and the range of the field in the file. The start time field of storing the file ensures the uniqueness of the file, and the field flag and the range of the field in the file ensure the establishment of subsequent indexes.
[0037] An application-driven data indexing method, the indexing method adopts the form of B+ tree, which includes:
[0038] Use the three fields in the file name as the data for building a B+ tree. Take the maximum value of the field range of the file as the key and the first five digits of the start time as the value to build a B+ tree. Similarly, take the minimum value of the field range of the file as the key and the last five digits of the start time as the value to build a B+ tree.
[0039] To query the time of the field, query two B+ trees at the same time, combine the query results into ranges, add field markers to locate the file, and finally query the specific content in the file.
[0040] An application-driven data storage method places flags in front of three field contents. Each time a piece of information is obtained, the encoded field content is compared with the data in the corresponding memory. If the same content already exists, the encoded flag corresponding to the newly obtained field content is added to the front of the existing field. If the content does not exist, the new field and flag are encoded and added to the corresponding memory.
[0041] An application-driven data indexing method, based on the fact that the data in the memory has been written into the file, there are two ways to obtain the leaf nodes of the B+ tree. One is to obtain from the memory variable, monitor the memory dynamics at any time, and obtain the start time and field range when executing the write file operation. The other is to obtain directly from the file name;
[0042] Get the time and field range in the file name. The standard time length is 10, divided into two fields with five digits each. At the same time, take out the maximum and minimum values of the field range. The maximum value and the first five digits of the time form a dictionary. The maximum value is the key, and the first five digits of the time are the value. The minimum value and the last five digits of the time form a dictionary. The minimum value is the key, and the last five digits of the time are the value.
[0043] The key-value pairs obtained are used as leaf nodes of the B+ tree, and two B+ trees are established. When querying, the two B+ trees are queried at the same time, and the query results are combined into field ranges, and field flags are added to find the corresponding files in the file list.
[0044] Example 1
[0045] A method of storing data, taking call record data as an example. Figure 1 , wherein the method comprises:
[0046] Get the call record and store it in memory. Set the file size threshold. When the call record size in memory reaches the threshold, a file is generated. The file name is field ID + time + the range value of the field in the file (hexadecimal). The field ID starts from 0, 0 represents the first field, 1 represents the second field, and so on. Since the call record field type has only two forms: integer and string, the file content is uniformly converted to binary for storage.
[0047] 101: Get the call record content from the outside, specify a flag bit for each call record, indicating which data item this call record is in the block of memory, and then store it by column.
[0048] The encoding method of the flag bit is: convert the flag bit to binary, and form an eight-bit sixth bit in a segment of six bits starting from the low bit. If the bit is insufficient, fill it with 0. The highest bit is always 1. The second lowest bit indicates the length of the flag bit byte. 0 indicates the length bit 1, and 1 indicates the length bit 2, including this byte. For example, if the flag bit is 156, the binary representation is 0b10011100. The length is more than 6 but less than 12, indicating that the length of the flag bit is 2. After conversion, it is 0b110000100b10011100.
[0049] The types of call record fields are divided into integer and string. Convert both the integer and string into binary representation. Then use the specified encoding method:
[0050] In one case, if the field does not change much, a minimum value can be set manually, and the difference between the new field content and the minimum value can be calculated by the forward difference method. For example, the International Mobile Subscriber Identity (IMSI) can be set to a minimum of 460000000000000, and then the difference between the new field content and the value can be calculated for subsequent encoding;
[0051] In another case, if the field changes significantly, you can choose not to set the minimum value, or use the default minimum value of 0 for subsequent encoding.
[0052] Specific encoding method bit: After the field content is converted into binary, starting from the low bit, every seven bits form a segment to form the seventh bit of an eight-bit segment, and the highest bit is always 0.
[0053] Combination of flag and field content: Place the flag before the field content. Each time a call record information is obtained, the encoded field content is compared with the data in the corresponding memory. If the same content already exists, the encoded flag corresponding to the newly obtained field content is added to the front of the existing field. If there is no content, the new field and flag are encoded and added to the corresponding memory.
[0054] While comparing the field content, two variables are set in the memory to represent the maximum and minimum values of the field stored in the memory block, and the starting value is 0. When the new field content is obtained, it will be compared: first, it is compared with the specific content. If the field content already exists, the maximum and minimum values are not compared. If the field content does not exist in the memory, the value is compared with the minimum value and replaced.
[0055] 102: Get the timestamp of the current time (the floating point number of seconds since the epoch of 1970), a total of ten digits. According to the number of bill fields, give each bill field a corresponding flag starting from 0, field 1 corresponds to flag 0, field 2 corresponds to flag 1, etc. The range size of the field is updated at all times.
[0056] 103: Set a threshold of a memory block. When the memory block reaches the threshold, the current field flag, start time, and field range are set as the file name, and the data in the memory block is written to the file.
[0057] Example 2
[0058] The embodiment of the present invention provides a method for establishing an index. Figure 2 , the method comprising:
[0059] This method is based on the fact that the data in the memory has been written into the file. There are two ways to obtain the leaf nodes of the B+ tree. One is to obtain them from the memory variables, monitor the memory dynamics at any time, and obtain the starting time and field range when executing the file write operation. The other is to obtain them directly from the file name.
[0060] 201: Get the time and field range in the file name. The standard time length is 10, divided into two fields with five bits each, and the maximum and minimum values of the field range are taken at the same time. The maximum value and the first five bits of the time form a dictionary, the maximum value is the key, the first five bits of the time are the value, and the minimum value and the last five bits of the time form a dictionary, the minimum value is the key, and the last five bits of the time are the value.
[0061] 202: Use the key-value pairs obtained in the previous step as leaf nodes of the B+ tree to build two B+ trees. When searching, search in both B+ trees at the same time, form the search results into field ranges, add field flags, and search for corresponding files in the file list.
[0062] The process of establishing and updating the B+ tree is as follows Figure 3 , the specific process is as follows:
[0063] S1: Determine whether the key-value is a leaf node. If so, go to S3; if not, go to S2.
[0064] S2: Determine the number of leaf nodes and the type of child nodes. If the number of nodes is greater than 1, use binary search to find the insertion position. If the number of nodes is 1, compare the size of the key and then determine the node type. If the node type is a leaf node, go to S3. If the node type is a non-leaf node, continue with S2.
[0065] S3: Determine the status of the leaf node. If the node status is empty, insert data. If it is not empty, determine the number of leaf nodes. When the number of leaf nodes is greater than 1, use binary search to find the insertion position, and then turn to S4. When the number of leaf nodes is equal to 1, turn directly to S4.
[0066] S4: Compare the size of the leaf node and the data to determine whether the leaf node is full. If the leaf node is not full, insert the data. If the leaf node is full, split the B+ tree and go to S5.
[0067] S5: Create a parent node. If it is, insert data. If not, determine the number of nodes and node type. If the node is not full, insert data. If the node is full, continue with S5.
[0068] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. An application-driven data storage and indexing method, characterized in that: Data is stored in columns. Each column is not completely independent. A single file stores only one field. There is a flag in front of each field, indicating the number of rows in the file where the field is located. Other fields also have corresponding flags. Different fields of the same record have the same row number flag in different files. The file name contains three fields: field flag, the start time of storing the file, and the range of the field in the file. The start time field of storing the file ensures the uniqueness of the file, and the field flag and the range of the field in the file ensure the establishment of subsequent indexes. The encoding method of the flag bit is as follows: convert the flag bit into binary, and form an eight-bit sixth bit in a segment of six bits starting from the low bit. If the bit is insufficient, fill it with 0. The highest bit is always 1. The second lowest bit indicates the length of the flag bit byte. 0 indicates length bit 1, and 1 indicates length bit 2, including this byte. The stored call record field types are divided into integer and string. Both the integer and string are converted into binary representation, and then encoded using the specified encoding method: In one case, the field does not change much, so a minimum value is set and the difference between the new field content and the minimum value is calculated using the forward difference method. Another case is that the field changes significantly, and the minimum value is not set, or the default minimum value is 0, and then subsequent encoding is performed. The specific encoding method is: after the field content is converted into binary, starting from the low bit, every seven bits form a segment to form the seventh bit of an eight-bit, and the highest bit is always 0; Combination of flag and field content: Place the flag before the field content. Each time a call record information is obtained, compare the encoded field content with the data in the corresponding memory. If the same content already exists, add the encoded flag corresponding to the newly obtained field content to the front of the existing field. If no content exists, encode the new field and flag and add them to the corresponding memory.
2. The application-driven data storage and indexing method according to claim 1, characterized in that: The index method adopts the form of B+ tree, which includes: Use the three fields in the file name as the data for building a B+ tree. Take the maximum value of the field range of the file as the key and the first five digits of the start time as the value to build a B+ tree. Similarly, take the minimum value of the field range of the file as the key and the last five digits of the start time as the value to build a B+ tree. To query the time of the field, query two B+ trees at the same time, combine the query results into ranges, add field markers to locate the file, and finally query the specific content in the file.
3. The application-driven data storage and indexing method according to claim 2, characterized in that: Since the data in the memory has been written into the file, there are two ways to obtain the leaf nodes of the B+ tree. One is to obtain them from the memory variables, monitor the memory dynamics at any time, and obtain the start time and field range when executing the write file operation. The other is to obtain them directly from the file name. Get the time and field range in the file name. The standard time length is 10, which is divided into two fields with five digits each. At the same time, take out the maximum and minimum values of the field range. The maximum value and the first five digits of the time form a dictionary. The maximum value is the key, and the first five digits of the time are the value. The minimum value and the last five digits of the time form a dictionary. The minimum value is the key, and the last five digits of the time are the value. Use the obtained key-value pairs as leaf nodes of the B+ tree and build two B+ trees; When querying, query in two B+ trees at the same time, organize the query results into field ranges, add field marks, and search for corresponding files in the file list.
4. The application-driven data storage and indexing method according to claim 3, characterized in that: The process of establishing and updating the B+ tree is as follows: Step 1: Determine whether the key-value is a leaf node. If so, go to step 3; if not, go to step 2; Step 2: Determine the number of leaf nodes and the type of child nodes. If the number of nodes is greater than 1, use binary search to find the insertion position. If the number of nodes is 1, compare the size of the key and then determine the node type. If the node type is a leaf node, go to step 3. If the node type is a non-leaf node, continue with step 2. Step 3: Determine the status of the leaf node. If the node status is empty, insert data. If it is not empty, determine the number of leaf nodes. When the number of leaf nodes is greater than 1, use binary search to find the insertion position, and then go to step 4. When the number of leaf nodes is equal to 1, go directly to step 4. Step 4: Compare the size of the leaf node and the data to determine whether the leaf node is full. If the leaf node is not full, insert the data. If the leaf node is full, split the B+ tree and go to step 5. Step 5: Create a parent node. If it is, insert data. If not, determine the number of nodes and node type. If the node is not full, insert data. If the node is full, continue with step 5.
Citation Information
Patent Citations
Cloud computing system with data cube storage index structure
CN102508913A
Key-Value local storage method and system based on solid state disk (SSD)
CN102722449A
Read-optimized memory database Trie tree index method
CN105117417A
Chain log storage structure, hash index structure and data operation method thereof, server and medium
CN107515901A
Data storing and query combination method in a flush type system
CN1464436A
