High-performance storage method for Internet of Things gateway
By adopting the structure of file header, index area and data area in the IoT system, the problem of performance degradation of SQLite database under large data volume is solved, efficient data storage and query are achieved, and it is suitable for various embedded IoT scenarios. , improving storage and reading performance.
Patent Information
- Application Number
- CN202410803580.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-27
AI Technical Summary
When the amount of stored data exceeds tens of millions, the storage and reading performance of the SQLite database will drop significantly, and reading non-index fields takes a long time, affecting the user experience.
Adopt a high-performance storage method for Internet of Things correlation, including file header, index area and data area. The file header describes the overall information of the data file, the index area stores index information for quick query, the data area stores specific data, and the index area is used to quickly locate data to improve query efficiency.
It has improved data storage and reading performance, and the query rate is not affected by the size of the data. It is suitable for any embedded IoT scenario and enhances the versatility of the storage format.
Smart Images

Figure CN118708588A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a high-performance storage method for an Internet of Things gateway. Background Art
[0002] With the development of electronic technology, embedded systems have been widely used; SQLite is generally used to store structured data in existing embedded systems. SQLite is a lightweight relational database that occupies few resources, supports mainstream operating systems, can be combined with multiple languages, and has fast processing speed, so it is widely used. The data in the SQLite database involves confidential data and privacy of state agencies, the military, enterprises, institutions, and individuals; and the SQLite database implements a SQL database engine with zero configuration, no server and transaction functions.
[0003] However, when using SQLite storage, when the amount of stored data exceeds tens of millions, the data storage and reading performance will drop significantly, and the reading of non-indexed fields will take a long time, affecting the user experience. Summary of the invention
[0004] The purpose of the present invention is to provide a high-performance storage method for an Internet of Things gateway to solve the problem that when the amount of stored data exceeds tens of millions, the data storage and reading performance will drop significantly and the reading of non-indexed fields will take a long time.
[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions: A high-performance storage method for an Internet of Things gateway includes: a file header, wherein the file header is used to describe overall information of a current data file; Index area: The index area is used to store all index information. When querying data, you can load the index area to quickly query the corresponding data; Data area: The data area is used to store specific data.
[0006] A further technical solution is that the overall information of the data file includes: magic: The magic number in the file header is used to distinguish whether the format of the data file is correct or whether the data file is damaged; File version: When parsing a data file, it is convenient to match the corresponding parsing method through the version information of the data file; Start timestamp / end timestamp: the time (in milliseconds) when the first data item and the last data item are stored in the current data file; File length: the total size of the data file and the file header; Number of data items: The total number of data items stored in the data file.
[0007] A further technical solution is that the field description of an index information in the index area includes: Frame sequence: the sequence number of the data described by the current index in the current file; Timestamp: the time when the data described by the current index was generated; key: the data type described by the current index; Data length: the length of the data described by the current index; The storage location of data in the file: the location where the data described by the current index is stored in the data area; SN BKDRHash: Hash value of the device serial number to which the data described by the current index belongs.
[0008] A further technical solution is that the default size of the index area is 10MB, and a single file can store up to approximately 430,000 pieces of data.
[0009] A further technical solution is that the format definition of a piece of data stored in the data area includes: Frame header / frame tail: the definition of the head and tail of a piece of data; Sequence number: the storage sequence number of the current data in the file; Timestamp: the time when the current data is generated; key type: current data type; sn: the serial number of the device to which the current data belongs; Data type: the format type in which the current data is stored; Data length: the length of the current data; Data: the specific content of the current data storage; Verification code: current data verification.
[0010] Compared with the prior art, the beneficial effects of the present invention are: 1. By not having any business-related definition in the data format definition, the storage format can be applied to data storage in any embedded Internet of Things scenario, thereby enhancing the versatility of the storage format.
[0011] 2. This storage format has a large data storage capacity, and its data storage and reading performance is only limited by the size of the memory. At the same time, the index area stores all data index information. When querying data, the index area can be loaded to quickly query the corresponding data. The data query rate is not affected by the amount of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 The present invention is a schematic structural diagram of a high-performance storage method for an Internet of Things gateway.
[0013] Figure 2 It is a schematic diagram of the overall information structure of the data file of the present invention.
[0014] Figure 3This is a schematic diagram of the index area structure of the present invention.
[0015] Figure 4 This is a schematic diagram of a field description structure of index information of the present invention.
[0016] Figure 5 It is a schematic diagram of the data area structure of the present invention.
[0017] Figure 6 This is a schematic diagram of a data format definition structure of the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0019] Example: See also Figures 1 to 6 As shown, a high-performance storage method for an Internet of Things gateway includes: File header: The file header is used to describe the overall information of the current data file; Index area: the index area is used to store all index information. When querying data, you can load the index area to quickly query the corresponding data; Data area: the data area is used to store specific data.
[0020] The overall information of the data file includes: magic: The magic number in the file header is used to distinguish whether the format of the data file is correct or whether the data file is damaged; File version: When parsing data files, it is convenient to match the corresponding parsing method through the version information of the data file; in order to deal with the iterative update of the storage format of the data file, the storage formats of different versions are different, and avoid the failure to parse the data file; Start timestamp / end timestamp: the time (in milliseconds) when the first data item and the last data item are stored in the current data file; File length: the total size of the data file and the file header; Number of data items: The total number of data items stored in the data file.
[0021] The field description of an index information in the index area includes: Frame sequence: the sequence number of the data described by the current index in the current file; Timestamp: the time when the data described by the current index was generated; Key type: the data type described by the current index. The specific type of data is determined by the business user. For example, in the general IoT gateway, it is defined as follows: 1-system operation data 2-sensor data 3-system fault data; Data length: the length of the data described by the current index; Data storage location in the file: The location where the data described by the current index is stored in the data area, through which the data can be quickly read; SN BKDRHash: The Hash value of the device serial number to which the data described by the current index belongs. This value can be used to quickly filter the data devices to be queried.
[0022] The default size of the index area is 10MB, and a single file can store up to approximately 430,000 pieces of data.
[0023] The format definition of a piece of data stored in the data area includes: Frame header / frame tail: defines the header and tail of a piece of data. When part of the data in a file is damaged, the file can be quickly repaired and the index information can be restored through the frame header and frame tail information. Sequence number: the storage sequence number of the current data in the file; Timestamp: the time when the current data is generated; key type: current data type. The specific data type definition is determined by the business user. For example, in the general IoT gateway, it is defined as follows: 1-system operation data 2-sensor data 3-system fault data; sn: the serial number of the device to which the current data belongs; data type: the format type in which the current data is stored. It can store numerical values or strings, etc. Data length: the length of the current data; Data: the specific content of the current data storage; Verification code: Verify the current data to prevent data tampering or confusion.
[0024] In summary, by not defining any business-related definitions in the data format definition, this storage format can be applied to data storage in any embedded IoT scenario, enhancing the versatility of this storage format. This storage format has a large data storage capacity, and its data storage and reading performance is only limited by the size of the memory. At the same time, the index area stores all data index information. When querying data, the index area can be loaded to quickly query the corresponding data, and the data query rate is not affected by the amount of data.
[0025] Although the present invention is described herein with reference to a number of illustrative embodiments of the present invention, it will be appreciated that those skilled in the art may devise many other modifications and implementations that fall within the scope and spirit of the principles disclosed herein. More specifically, within the scope of the present disclosure, drawings, and claims, a variety of variations and modifications may be made to the components and / or layout of the subject combination layout. In addition to the variations and modifications made to the components and / or layout, other uses will also be apparent to those skilled in the art.
Claims
1. A high-performance storage method for an Internet of Things gateway, characterized in that: include: A file header, which is used to describe the overall information of the current data file; An index area, which is used to store all index information. When querying data, the index area can be loaded to quickly query the corresponding data; A data area, wherein the data area is used to store specific data.
2. According to claim 1, a high-performance storage method for an Internet of Things gateway is characterized in that: The overall information of the data file includes: magic: a magic number in the file header, which is used to distinguish whether the format of the data file is correct or whether the data file is damaged; File version: when parsing the data file, it is convenient to match the corresponding parsing method through the version information of the data file; Start timestamp / end timestamp: the time (in milliseconds) when the first data item and the last data item are stored in the current data file; File length: the total size of the data file and the file header; Number of data items: the total number of data items stored in the data file.
3. According to claim 1, a high-performance storage method for an Internet of Things gateway is characterized in that: The field description of one of the index information in the index area includes: Frame sequence: the sequence number of the data described by the current index in the current file; Timestamp: the time when the data described by the current index was generated; key type: the data type described by the current index; Data length: the length of the data described by the current index; The storage location of data in the file: the location where the data described by the current index is stored in the data area; SN BKDRHash: Hash value of the device serial number to which the data described by the current index belongs.
4. The high-performance storage method for an Internet of Things gateway according to claim 1, characterized in that: The default size of the index area is 10MB, and a single file can store up to approximately 430,000 pieces of data.
5. The high-performance storage method for an Internet of Things gateway according to claim 1, characterized in that: The format definition of a piece of data stored in the data area includes: Frame header / frame tail: the header and tail definition of a piece of data; Sequence number: the storage sequence number of the current data in the file; Timestamp: the time when the current data is generated; key type: current data type; sn: the serial number of the device to which the current data belongs; Data type: the format type in which the current data is stored; Data length: the length of the current data; Data: the specific content of the current data storage; Verification code: current data verification.
