Design method of embedded IoT time series database for hybrid solid-state storage system
By building an embedded IoT time series database in the memory driver, combining the characteristics of NVM and SSD, optimizing the time series data storage process solves the problems of traditional time series database software overhead and low storage efficiency, and achieves efficient and low-overhead time series data management and Query.
Patent Information
- Application Number
- CN202011302704.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-19
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2040-11-19
AI Technical Summary
After using high-speed NVM in existing time series databases, software overhead problems are exposed, resulting in the system being unable to fully utilize the excellent features of NVM. In addition, traditional time series data storage systems have high dependence on external software, low throughput rates, low concurrency, and large storage space overhead.
Build an embedded IoT time series database in the memory driver. Through data compression and hierarchical management strategies, combined with the characteristics of NVM and SSD, we design a hierarchical heterogeneous data indexing mechanism, shorten the I/O software stack, and optimize the time series data storage process.
It improves the storage efficiency of time series data, reduces storage space overhead, reduces wear and tear on NVM and SSD, improves the concurrency and scalability of the system, and achieves efficient time series data management and query.
Smart Images

Figure CN112506922B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer storage technology, and in particular relates to an embedded IoT time series database for a hybrid solid-state storage system. Background Art
[0002] Non-volatile memory NVM has the characteristics of byte addressability, persistence, read and write performance similar to DRAM and high storage density. Its types mainly include phase change memory, impedance memory and 3D-XPoint. Taking phase change memory as an example, its read and write delays are about 70ns and 150ns respectively, which can provide performance guarantee for high concurrency and massive time series data storage. However, the existing time series databases are all secondary developed based on general database systems, resulting in excessive I / O software stack overhead and difficulty in optimizing for the characteristics of time series data. When these time series databases work on HDD or SSD, the delay of I / O software overhead can be masked by the high latency of the memory, but when high-speed NVM is added, these software overhead problems are exposed, and the performance bottleneck of the computer storage system is transformed from hardware speed to software speed, which makes the system unable to maximize the excellent characteristics of NVM. The present invention optimizes the data storage process according to the characteristics of time series data while reducing the I / O software stack of the time series database, so that the hybrid storage system composed of NVM and SSD can be well used in the application scenario of IoT (Internet of Things) time series data storage. Summary of the invention
[0003] In order to solve the above problems, the present invention optimizes the process of storing time series data according to the various characteristics of IoT time series data, so that the system can read and write time series data more efficiently and with less storage space overhead, which can solve the problems of high external software dependence, low throughput, low concurrency, and large storage space overhead in traditional time series data storage systems. The present invention proposes an embedded IoT time series database for hybrid solid-state storage systems, which constructs a time series database engine in the memory driver, compresses data according to the characteristics of time series data, and designs a hierarchical data management strategy and data indexing strategy by combining the characteristics of NVM and SSD.
[0004] In order to achieve the above object, the technical solution of the present invention is:
[0005] The embedded IoT time series database for hybrid solid-state storage system includes the following steps:
[0006] Step 1) establishing a time series data storage engine in a memory driver;
[0007] Step 2) partitioning the time series data according to different IoT sources when writing data;
[0008] Step 3) The time series data is compressed and stored in NVM (Non-Volatile Memory) in 4KB blocks.
[0009] Step 4) When the number of data blocks in the NVM reaches a certain threshold, the time series data blocks with lower timeliness are migrated to the SSD (Solid State Disk);
[0010] Step 5) when querying data, index the time series data in NVM and SSD according to the hierarchical heterogeneous time series data indexing mechanism;
[0011] Furthermore, in the above step 1), the specific steps of establishing a time series data storage engine in the memory driver are as follows:
[0012] Step 1.1: Declare the time series database engine system call function in the kernel's system call library
[0013] sys_call_TSNSM(name, interval, precision, range) The parameter name represents the name of the sensor, which we call the name of the IoT source in the storage system. The interval represents the time interval for the device to send data. The precision represents the number of decimal places in the data value sent by the device. The range represents the time range in which the user needs to frequently access the data of this device.
[0014] Step 1.2: Implement the read and write functions required by the time series database in the kernel's memory driver;
[0015] put_tsnsm(name, timestamp, value, batch) write function, name indicates the name of the IoT source, timestamp indicates the timestamp, value indicates the value, batch indicates whether the insertion mode is normal insertion or batch insertion, and the default is normal insertion;
[0016] read_tsnsm(name, time_start, time_end) read function, name indicates the name of the IoT source, time_start and time_end indicate the start and end of the time period to be read respectively;
[0017] Step 1.3: Add the above-mentioned time series database engine call function and time series database read and write call function operation interface to the kernel's block device operation set.
[0018] Furthermore, in the above step 2), the time series data is partitioned according to different IoT sources when writing data. The specific steps are as follows:
[0019] Step 2.1: Create an information area for each IoT source in NVM, including the name of the IoT source, the time interval for generating data, the numerical precision, the frequent query time range, and the migration threshold, and allocate an independent time series data storage area for this IoT source;
[0020] Step 2.2: Create a hash index structure for the IoT source information area, convert the IoT source name from a string into a unique pure numeric string, use the pure numeric string as the key, and the address of the IoT source information area as the value, and use the square median method to assign a hash value to each IoT source;
[0021] Furthermore, in the above step 3), the time series data is compressed and stored in NVM after being deduplicated in 4KB blocks. The specific steps are as follows:
[0022] Step 3.1: In the time series data storage area, check the number of data blocks contained;
[0023] Step 3.2: If the number of data blocks is zero, create a data block of size 4KB, which consists of the block header (start_stime, start_value, p_num, next, pre) and the block body D array, where start_stime indicates the start time of the data block, start_value indicates the start value, p_num indicates the number of consecutive repetitions of start_value, next indicates the address of the next block, and pre indicates the address of the next block. The D array is used to store compressed values d one by one; the timestamp and value of the time series data to be stored are saved in the start_time and start_value positions of the block header;
[0024] Step 3.3: If the number of data blocks is not zero, check whether the first data block has space to accommodate the new value. If not, generate a new block using the method in step 3.2, and make the next pointer point to the current first block, and then make the pre pointer of the current first block point to the newly created block, so that the newly created block is always in the first block;
[0025] Step 3.4: If there is still room for the new value in the first data block, compare the value of the time series data point to be stored with the start_value. If they are equal, only the p_num variable at the beginning of the data block is incremented. If they are not equal, calculate the Value to get a positive integer d, and store d in the D array. The calculation formula of d is:
[0026] d=(Value-start_value)*10 precision
[0027] Furthermore, in the above step 4), when the number of data blocks in the NVM reaches a certain threshold, the time series data blocks with lower timeliness are migrated to the SSD. The specific steps are as follows:
[0028] Step 4.1: After each new data block is created, check whether the number of data blocks owned by the IoT source reaches its migration threshold. The threshold is calculated as follows:
[0029] threshold="range*3600 / interval*2034]
[0030] Step 4.2: If the migration threshold is reached, the last data block in the data storage area is migrated to the SSD, and the address of the SSD is saved in the variable Lblock_value. The starting timestamp, p_num, and IoT source name of the data block are concatenated into a string and saved in the variable Lblock_key.
[0031] Step 4.3: Insert (Lblock_key, Lblock_value) as a key-value pair into the summary B-tree of low-age time series data on the NVM.
[0032] Furthermore, in the above step 5), when querying data, the time series data in the NVM and SSD are indexed according to the hierarchical heterogeneous time series data indexing mechanism, and the specific steps are as follows:
[0033] Step 5.1: First, according to the IoT source name entered by the user, the IoT source information is found through the hash index;
[0034] Step 5.2: Get the first address of the time series data storage area, that is, the head node of the data block linked list, and then determine which data block or blocks the data required by the user is located according to the start and end time input by the user. The judgment formula is as follows:
[0035]
[0036] If both (1) and (2) are satisfied, it means that the current data block contains the required data, where search_time_start and search_time_end represent the start time point and end time point of the time period to be queried by the user, respectively. The meanings of other symbols are as in step 3.2 and step 2.1;
[0037] Step 5.3: Locate the target data block and locate the starting position x of the target data in the block according to the following formula:
[0038]
[0039] Where search_time represents the timestamp of the specific time series data to be obtained. The meanings of other symbols are as in steps 3.2 and 2.1.
[0040] Step 5.4: Get the value of the time series data according to the size of x or extract the elements in the D array and decompress them to get the value of the time series data. The formula is as follows:
[0041]
[0042] Where value represents the numerical value of the specific time series data to be obtained, and the meanings of other symbols are as shown in step 3.2;
[0043] Step 5.5: Continuously obtain the values in the subsequent array elements and decompress them. After each calculation, search_time plus interval until search_time equals search_time_end;
[0044] Step 5.6: If the query time range entered by the user exceeds the time range of the time series data included in the migration threshold, it means that the data is located on the SSD or does not exist;
[0045] Step 5.7: Index the summary of the low-availability time series data on the NVM. If the entry Lblock_key containing the target time series data is found in the summary, locate the target data block in the SSD according to Lblock_value, use the formulas in steps 5.3 and 5.4 to calculate the position and value of the starting point data and continue to obtain the remaining data.
[0046] The present invention reduces the I / O software stack of the time series database by establishing a native time series data storage engine in the memory driver. At the same time, when designing the storage engine, a data storage strategy integrating redundancy removal and compression is designed according to the characteristics of the time series data structure. According to the characteristics of the access and management of the time series data and the characteristics of the hybrid solid-state storage system constructed by NVM and SSD, a layered time series data management structure is designed. According to the characteristics of NVM and SSD, a two-dimensional spatial index structure and a summary index mechanism are designed respectively, thereby realizing that in the process of storage, management and indexing of time series data, frequent exchange of large amounts of data between the host and the storage system is avoided, the required storage space is reduced, and the wear on NVM and SSD is reduced. The respective advantages of NVM and SSD are utilized to realize the integration and management of time series data and efficient range query, thereby improving the economy and scalability of the time series database.
[0047] The device for realizing the object of the present invention is as follows:
[0048] An embedded IoT time series database for hybrid solid-state storage systems includes an embedded time series database storage engine, a data storage strategy that integrates redundancy removal and compression, a two-level hierarchical management strategy for time series data, and a hierarchical heterogeneous time series data indexing mechanism. The embedded time series database storage engine is used to reduce the I / O software stack of the entire time series data storage process; the data storage strategy that integrates redundancy removal and compression is used to reduce the required storage space while reducing the wear on NVM and SSD; the two-level hierarchical management strategy for time series data is used to combine the respective advantages of NVM and SSD to hierarchize time series data with different timeliness, thereby improving the economy and scalability of time series data management; the hierarchical heterogeneous time series data indexing mechanism is used to meet the indexing requirements of time series data with different timeliness, thereby improving the query efficiency of time series data.
[0049] Compared with the prior art, the present invention has the following beneficial effects:
[0050] 1. Build a native storage engine for IoT time series data in the storage driver, alleviating the problems of software dependency and high system I / O software stack overhead;
[0051] 2. Use a data storage strategy that combines redundancy removal and compression to save storage space required for time series data;
[0052] 3. Use a two-level hierarchical management strategy for time series data to store and manage high-timeliness time series data and low-timeliness time series data in layers, and divide high-timeliness time series data into independent storage areas according to IoT sources, thereby improving the concurrency of the time series database system while improving the economy and scalability of the time series data storage system;
[0053] 4. A hierarchical heterogeneous time series data indexing mechanism is used. A two-dimensional spatial index combining hash index and ordered linked list is used for high-timeliness time series data stored in NVM. A summary index is used for low-timeliness time series data stored on SSD by taking advantage of the performance of NVM, thereby improving the concurrency and indexing efficiency of the entire time series data storage system. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 It is the overall system structure diagram of the present invention;
[0055] Figure 2 The overall system device diagram of the present invention;
[0056] Figure 3 A flow chart of the data storage and indexing process in the present invention; DETAILED DESCRIPTION
[0057] In order to more clearly understand the technical content of the present invention, the present invention is further described below in conjunction with the accompanying drawings and specific implementation cases. It should be pointed out that the implementation cases described are intended to facilitate the understanding of the present invention without any prior requirements therefor.
[0058] The method of the present invention mainly includes the following parts. The technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention.
[0059] Example 1
[0060] like Figure 1 The figure shows the overall design structure of the system of the present invention. The present invention is an embedded IoT time series database for a hybrid solid-state storage system, comprising the following steps:
[0061] Step 1) establishing a time series data storage engine in a memory driver;
[0062] Step 2) partitioning the time series data according to different IoT sources when writing data;
[0063] Step 3) The time series data is compressed and stored in NVM (Non-Volatile Memory) in 4KB blocks.
[0064] Step 4) When the number of data blocks in the NVM reaches a certain threshold, the time series data blocks with lower timeliness are migrated to the SSD (Solid State Disk);
[0065] Step 5) when querying data, index the time series data in NVM and SSD according to the hierarchical heterogeneous time series data indexing mechanism;
[0066] This method is applied to the actual IoT time series data storage and management to improve the storage efficiency and space utilization of the system. Figure 1 The specific operation steps are as follows.
[0067] Step 1: The IoT system calls the time series database engine sys_call_TSNSM() function at the application layer. Its system call number is 330. Assuming that the sensor Sensor0 corresponds to the IoT source name temperature01, the interval (interval) of the data it generates is 2 seconds, the numerical accuracy (precision) is 2, and the frequent query time range (rang) is 24 hours, then the function and parameters it calls are: syscall(330, "temperature01", 2, 2, 24);
[0068] Step 2: Create an information area for the IoT source in NVM, named IoT_data0, the name of the IoT source (name) is "temperature01", the interval for generating data (interval) is 2, the numerical precision (precision) is 2, and the frequent query time range (rang) is: 24 hours, through the formula:
[0069] threshold="range*3600 / interval*2034]
[0070] The migration threshold (threshold) = [24*3600 / (2*2034)] = 22 is calculated, and an independent time series data storage area is allocated for this IoT source, and then an entry ("2051365181202118501", &IoT_data0) is inserted into the hash index structure;
[0071] Step 3: Perform the write operation first. Assume that it sends three time series data to the time series data storage system, namely [1604812898, 31.22, temperature01], [1604812900, 31.22, temperature01], and [1604812902, 31.34, temperature01]. The put_tsnsm() function is called three times. Its system call number is 331. The calling format is syscall(331, "temperature01", 1604812898, 31.22, 1), syscall(331, "temperature01", 1604812900, 31.22, 1), and syscall(331, "temperature01", 1604812902, 31.34, 0);
[0072] Step 4: The time series database receives the first time series data and converts "temperature01" into a pure digital string "2051365181202118501". The last 6 digits are squared and the hash value is 248. The information of IoT_data0 is obtained by indexing.
[0073] Step 5: Get the pointer of its time series data storage area. Assuming that the first block "Block0-22" in the area is full (if there are 2033 elements in the D array, it means it is full), the system will immediately generate a 4KB data block "Block0-n", which consists of the block header (start_stime, start_value, p_num, next, pre) and the block body D array. Start_stime indicates the start time of the data block, start_value indicates the start value, p_num indicates the number of consecutive repetitions of start_value, next indicates the address of the next block, and pre indicates the address of the next block. The D array is used to store compressed values d. Then write 1604812898 to the start_time of the block header of "Block0-n", and write 31.22 to the start_value And make the next pointer of "Block0-n" point to the current first block "Block0-22", and then make the pre pointer of the current first block "Block0-22" point to the newly created block Block0-n, so that the newly created block is always in the first block;
[0074] Step 6: It is known that the migration threshold of this IoT source time series data area is 22, and n is equal to 23 at this time, so the data block needs to be migrated to the low-timeliness time series data layer;
[0075] Step 7: Migrate the data block Block0-0 at the end of the sequential data area, write the content of this data block to the SSD, and record its starting address adress0-0 in the SSD;
[0076] Step 8: Create a new KV pair (Lblock_key0-0, Lblock_value0-0). Lblock_key0-0 is a string obtained by concatenating "temperature01_" + "start_time" of Block0-0 + "p_num" of Block0-0. Lblock_value0-0 stores the value of adress0-0. Then write this KV pair into the summary B-tree of low-availability time series data on NVM to complete the migration of the data block.
[0077] Step 9: The first time series data is written, but because batch = 1, indicating batch insertion mode, the system does not close the insertion function but falls back to step 5 and immediately receives the second time series data;
[0078] Step 10: Currently, the first block in the area is "Block0-n", which is not full and there is no element in the D array, so 31.22 is compared with start_value. If they are equal, p_num is increased by 1 to complete the writing of the second time series data. Similarly, batch = 1, and the process goes back to step 5 to receive the second time series data immediately.
[0079] Step 11: Similarly, compare 31.34 with start_value and find that they are not equal. Use the formula:
[0080] d=(Value-start_value)*10precision
[0081] Calculation yields d = (31.34-31.22)*10 2 =12, so the result 12 is stored in the D0 element position of the D array of "Block0-n", completing the writing of the third time series data; since batch = 0 at this time, the insertion function is closed;
[0082] Step 12: Next, the user sends a request to read the time series data of "temperature01" and calls the read_tsnsm() function. Its system call number is 332. Using the hierarchical heterogeneous time series data indexing mechanism, assuming that the user wants to query the data in two time ranges, which are timestamps 1604812898-1604812902 and 1604640010-1604640050, the call to the read_tsnsm function is in the form of syscall(332, "temperature01", 1604812898, 1604812902) and syscall(332, "temperature01", 1604640010, 1604640050);
[0083] Step 13: The system first receives the first query request. Similar to step 4, the IoT source information IoT_data0 is obtained through the index, and its interval = 2 and precision = 2 are known.
[0084] Step 14: Get the first address of its time series data storage area, that is, the head node "Block0-n" of the data block linked list. Knowing that the start_time of the block is 1604812898, start_value is 31.22, and p_num is 1, then according to the time starting point search_time_start=1604812898 and the end point search_time_end=1604812902 input by the user, determine in which data block or blocks the data required by the user is located;
[0085] Step 15: According to the formula:
[0086]
[0087] It is found that the head node data block satisfies both equations (1) and (2), so the current data block contains the required data, and the target time series data is extracted;
[0088] Step 16: According to the formula:
[0089]
[0090] Where search_time represents the timestamp of the specific time series data to be obtained. First, 1604812898 is calculated to obtain the corresponding x=-2; then search_time plus interval is added to obtain x=-1 corresponding to the time point 1604812900; similarly, x=0 corresponding to the time point 1604812902 is obtained; at this time, search_time is equal to search_time_end;
[0091] Step 17: According to the formula:
[0092]
[0093] The value corresponding to the timestamp 1604812898 is = start_value = 31.22, the value corresponding to 1604812900 is = start_value = 31.22, and the value corresponding to 1604812902 is = start_value + D[x] * 10 -precision =31.22+D[0]*10 -2 =31.22+0.12=31.34;
[0094] Step 18: Next, the system receives the second read request, search_time_start=1604640010 and end point search_time_end=1604640050, which is the same as steps 13 and 14, but through calculation, it is found that the first data block only satisfies formula (1) in step 15, and the pointer jumps to next. It is assumed that until the last node of the linked list, only formula (1) can be satisfied;
[0095] Step 19: Start to perform summary indexing, that is, query the summary of the low-efficiency time series data on the NVM. Through the B-tree index, query the LBlobk_key that is closest to the string "temperature01_1604640010". Assume that there is an entry (temperature01_1604640003_5, &address0-0) on the B-tree. Then, according to the formula in step 15, it can be known that the data block represented by this entry contains the time series data range required by the user, and is the target data block.
[0096] Step 20: Locate the address of the target data block in the SSD through the pointer address0-0. Similar to steps 16 and 17, calculate the position and value of the starting point data and continue to obtain the remaining data.
[0097] Example 2
[0098] like Figure 2 As shown, the embedded IoT time series database for hybrid solid-state storage system includes an embedded time series database storage engine, a data storage module integrating redundancy removal and compression, a hierarchical time series data management module, and a hierarchical heterogeneous time series data indexing module. The embedded time series database storage engine is used to reduce the I / O software stack of the entire process of time series data storage; the data storage strategy integrating redundancy removal and compression is used to reduce the required storage space and reduce the wear on NVM and SSD; the two-level hierarchical management strategy of time series data is used to combine the respective advantages of NVM and SSD to hierarchize time series data with different timeliness, thereby improving the economy and scalability of time series data management; the hierarchical heterogeneous time series data indexing mechanism is used to meet the indexing requirements of time series data with different timeliness, thereby improving the query efficiency of time series data with timeliness.
[0099] Example 3
[0100] like Figure 3 As shown in the figure, the specific execution process of the embedded IoT time series database for hybrid solid-state storage system is as follows:
[0101] Step 1: The user calls the system call function of the time series database;
[0102] Step 2: Get the user's parameters and data;
[0103] Step 3: Find the target IoT source according to the IoT source name entered by the user;
[0104] Step 4: Determine the read or write operation based on the parameters input by the user;
[0105] Step 5: If it is a write operation, determine whether the head node of the data block linked list is full. If not, compress the data and write it to the D array of the head node data block. If it is full, allocate a new data block and write the data to the block header.
[0106] Step 6: Determine whether the number of data blocks reaches a threshold. If so, migrate the data block nodes at the end of the linked list to the low-efficiency sequential data storage area of the SSD.
[0107] Step 7: If it is a read operation, first search for the target data block in the high-efficiency time series data of the NVM. If the target data block is found, extract the data and decompress and output it. If not found, search for the summary of the low-efficiency time series data in the NVM.
[0108] Step 8: If the corresponding entry is found, locate the target data block in the SSD according to the summary information, extract the data and decompress and output it. If the corresponding entry is not found, it means that the data does not exist.
[0109] In summary, the present invention provides an embedded IoT time series database design method for a hybrid solid-state storage system. A time series database engine is established in the memory driver, and the read and write access operations of the time series database are encapsulated with system calls, so that the system skips the overhead of the file system layer when reading and writing time series data; in view of the structural characteristics of time series data, a data storage strategy integrating redundancy removal and compression is designed and implemented on the time series database engine; in view of the particularity of time series data in access, a layered time series data management strategy is designed and implemented, so that low-timeliness data can be automatically migrated to the SSD, and a two-dimensional hybrid index strategy and a summary index strategy are designed for the time series data on NVM and SSD respectively; and a time series database structure is given, and the main modules are introduced. The present invention has the following advantages: the system can optimize the data storage process according to the many characteristics of time series data, and can use the advantages of NVM to optimize the index of data on SSD, so that the storage system can achieve higher space utilization while dynamically managing the distribution of data in NVM and SSD, and can index time series data with high concurrency and high speed.
[0110] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0111] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. Design method of embedded IoT time series database for hybrid solid-state storage system, characterized by: The specific steps are as follows: Step 1) Establishing a time series data storage engine in the memory driver; Step 2) partitioning the time series data according to different IoT sources when writing data; Step 3) The time series data is compressed and stored in a non-volatile memory NVM in units of 4KB blocks; Step 4) When the number of data blocks in the NVM reaches a certain threshold, the time series data blocks with lower timeliness are migrated to the solid state drive SSD, and their summaries are saved on the NVM; Step 5) when querying data, index the time series data in NVM and SSD according to the hierarchical heterogeneous time series data indexing mechanism; The specific steps of step 2) are as follows: Step 2.1: Create an information area for the IoT source in NVM, including the name of the IoT source, the interval for generating data, the numerical precision, the frequent query time range, the migration threshold, and allocate an independent time series data storage area for this IoT source; Step 2.2: Create a hash index structure for the IoT source information area, convert the IoT source name from a string into a unique pure numeric string, use the pure numeric string as the key, and the address of the IoT source information area as the value, and use the square median method to assign a hash value to each IoT source; The specific steps of step 3) are as follows: Step 3.1: In the time series data storage area, check the number of data blocks contained; Step 3.2: If the number of data blocks is zero, create a data block of size 4KB, which consists of the block header (start_stime, start_value, p_num, next, pre) and the block body D array, where start_stime indicates the start time of the data block, start_value indicates the start value, p_num indicates the number of consecutive repetitions of start_value, next indicates the address of the next block, and pre indicates the address of the next block. The D array is used to store compressed values d one by one; the timestamp and value of the time series data to be stored are saved in the start_time and start_value positions of the block header; Step 3.3: If the number of data blocks is not zero, check whether the first data block has space to accommodate the new value. If not, generate a new block using the method in step 3.2, and make the next pointer point to the current first block, and then make the pre pointer of the current first block point to the newly created block, so that the newly created block is always in the first block; Step 3.4: If there is still room for the new value in the first data block, compare the value Value of the time series data point to be stored with the start_value. If they are equal, only the p_num variable at the beginning of the data block is incremented. If they are not equal, calculate Value to get a positive integer d, and store d in the D array. The calculation formula of d is: d=(Value–start_value)*10 precision ; The specific steps of step 5) are as follows: Step 5.1: First, according to the IoT source name entered by the user, the IoT source information is found through the hash index; Step 5.2: Get the first address of the time series data storage area, that is, the head node of the data block linked list, and then determine which data block or blocks the data required by the user is located according to the start and end time input by the user. The judgment formula is as follows: If both (1) and (2) are satisfied, it means that the current data block contains the required data, where search_time_start and search_time_end represent the start time point and end time point of the time period that the user wants to query, respectively; Step 5.3: Locate the target data block and locate the starting position x of the target data in the block according to the following formula: Where search_time represents the timestamp of the specific time series data to be obtained; Step 5.4: Get the value of the time series data according to the size of x or extract the elements in the D array and decompress them to get the value of the time series data. The formula is as follows: Where value represents the value of the specific time series data to be obtained; Step 5.5: Continuously obtain the values in the subsequent array elements and decompress them. After each calculation, search_time plus interval until search_time equals search_time_end; Step 5.6: If the query time range entered by the user exceeds the time range of the time series data included in the migration threshold, it means that the data is located on the SSD or does not exist; Step 5.7: Index the summary of the low-availability time series data on the NVM. If the entry Lblock_key containing the target time series data is found in the summary, locate the target data block in the SSD according to Lblock_value, use the formulas in steps 5.3 and 5.4 to calculate the position and value of the starting point data, and continue to obtain the remaining data.
2. The method according to claim 1, characterized in that The specific steps of step 1) are as follows: Step 1.1: Declare the time series database engine system call function sys_call_TSNSM(name, interval, precision, range) in the kernel's system call library. The parameter name represents the name of the sensor, which is called the name of the IoT source in the storage system. The interval represents the time interval for the device to send data. The precision represents the number of decimal places in the data value sent by the device. The range represents the time range in which the user needs to frequently access the data of this device. Step 1.2: Implement the read and write functions required by the time series database in the kernel's memory driver; put_tsnsm(name, timestamp, value, batch) writes a function, where name indicates the name of the IoT source, timestamp indicates the timestamp, value indicates the value, and batch indicates whether the insertion mode is normal insertion or batch insertion. The default is normal insertion. read_tsnsm(name, time_start, time_end) read function, name indicates the name of the IoT source, time_start and time_end indicate the start and end of the time period to be read respectively; Step 1.3: Assign system call numbers to the above functions in the kernel. The system call numbers of the functions sys_call_TSNSM(), put_tsnsm(), and read_tsnsm() are 330, 331, and 332 respectively.
3. The method according to claim 1, characterized in that The specific steps of step 4) are as follows: Step 4.1: After each new data block is created, check whether the number of data blocks owned by the IoT source reaches its migration threshold. The threshold is calculated as follows: Step 4.2: If the migration threshold is reached, the last data block in the data storage area is migrated to the SSD, and the address of the SSD is saved in the variable Lblock_value. The starting timestamp, p_num, and IoT source name of the data block are concatenated into a string and saved in the variable Lblock_key. Step 4.3: Insert (Lblock_key, Lblock_value) as a key-value pair into the summary B-tree of low-age time series data on the NVM.
