[go: up one dir, main page]

CN117785073A - Internet of things device and time series data access method thereof and corresponding device and medium - Google Patents

Internet of things device and time series data access method thereof and corresponding device and medium Download PDF

Info

Publication number
CN117785073A
CN117785073A CN202410217257.6A CN202410217257A CN117785073A CN 117785073 A CN117785073 A CN 117785073A CN 202410217257 A CN202410217257 A CN 202410217257A CN 117785073 A CN117785073 A CN 117785073A
Authority
CN
China
Prior art keywords
storage
data
information
sector
time sequence
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410217257.6A
Other languages
Chinese (zh)
Other versions
CN117785073B (en
Inventor
吴锴
吴文龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Zhiyan Technology Co Ltd
Shenzhen Qianyan Technology Co Ltd
Original Assignee
Shenzhen Zhiyan Technology Co Ltd
Shenzhen Qianyan Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Zhiyan Technology Co Ltd, Shenzhen Qianyan Technology Co Ltd filed Critical Shenzhen Zhiyan Technology Co Ltd
Priority to CN202410217257.6A priority Critical patent/CN117785073B/en
Publication of CN117785073A publication Critical patent/CN117785073A/en
Application granted granted Critical
Publication of CN117785073B publication Critical patent/CN117785073B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请涉及一种物联网设备及其时序数据存取方法和相应的装置与介质,所述方法包括:创建存储空间内扇区中的存储区块,所述存储区块包括多个时序相对应的存储位置;更新所述存储空间的存储分配信息中所述扇区相对应的扇区信息,所述扇区信息包括时序范围信息;更新所述存储空间的存储分配信息中所述存储区块相对应的区块信息,所述区块信息包括时序寻址信息;基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,开始存取所述目标时序数据的各个数据单元。采用单个存储区块用于存储多个数据单元,将数据单元的时序表示在相对应的时序寻址信息中,可大幅提升存储空间的存储效率,能提升物联网设备的信息容量,降低其成本。

This application relates to an Internet of Things device and its sequential data access method and corresponding devices and media. The method includes: creating a storage block in a sector in the storage space, and the storage block includes multiple sequential data access methods. the storage location; update the sector information corresponding to the sector in the storage allocation information of the storage space, where the sector information includes timing range information; update the storage block in the storage allocation information of the storage space Corresponding block information, the block information includes timing addressing information; based on the storage allocation information, determine the starting timing position corresponding to the access target timing data, and start accessing each data of the target timing data unit. Using a single storage block to store multiple data units, and expressing the timing of the data units in the corresponding timing addressing information, can greatly improve the storage efficiency of the storage space, increase the information capacity of IoT devices, and reduce their costs. .

Description

物联网设备及其时序数据存取方法和相应的装置与介质Internet of Things equipment and its time series data access methods and corresponding devices and media

技术领域Technical field

本申请涉及物联网领域,尤其涉及一种物联网设备及其时序数据存取方法和相应的装置与介质。The present application relates to the field of Internet of Things, and in particular to an Internet of Things device and its time series data access method and corresponding devices and media.

背景技术Background technique

物联网设备的应用越来越普及,物联网设备有诸多形态,广泛应用到个人消费和家庭消费领域,例如家用取暖器、加温器、各种可穿戴设备等,这些物联网共同一般都携带各种传感器,需要长时间采集各种传感数据,按照时序将各个时序相对应的传感数据构成时序数据,利用嵌入式芯片对这些时序数据进行存储和使用。The application of IoT devices is becoming more and more popular. IoT devices come in many forms and are widely used in personal consumption and household consumption, such as home heaters, warmers, various wearable devices, etc. These IoT devices are generally carried Various sensors need to collect various sensing data for a long time. The sensing data corresponding to each time sequence is composed of time series data according to the time sequence. Embedded chips are used to store and use these time series data.

时序数据是指按时间的顺序去记录的一组数据,每组数据中包括多个时序相对应的数据单元,各个数据单元的数据内容一般是同构的。时序数据可以通过时序数据库进行存储和管理。在嵌入式领域里,常用的存储介质为Flash即闪存,适应闪存的特性,通常采用与其特性相适配的嵌入式数据库来管理闪存的存储空间。与传统的基于文件系统的数据库不同,这种嵌入式数据库结合了 Flash 的特性,具有较强的性能及可靠性,并在保证极低的资源占用前提下,尽可能延长 Flash 使用寿命。Time series data refers to a set of data recorded in time order. Each set of data includes multiple data units corresponding to time series. The data content of each data unit is generally isomorphic. Time series data can be stored and managed through time series databases. In the embedded field, the commonly used storage medium is Flash memory, which adapts to the characteristics of flash memory. An embedded database that matches its characteristics is usually used to manage the storage space of flash memory. Different from traditional file system-based databases, this embedded database combines the characteristics of Flash, has strong performance and reliability, and can extend the service life of Flash as much as possible while ensuring extremely low resource usage.

基于Flash特性的嵌入式数据库通常提供两种数据库模式:键值数据库和时序数据库。键值数据库是一种非关系数据库,它将数据存储为键值(Key-Value)对集合,其中键作为唯一标识符。键值数据库操作简洁,可扩展性强。时序数据库将数据按照时间顺序存储,以时间戳对时序数据进行管理,数据存储量大,插入及查询性能高。Embedded databases based on Flash features usually provide two database modes: key-value database and time series database. A key-value database is a non-relational database that stores data as a collection of key-value pairs, where the key serves as a unique identifier. The key-value database is simple to operate and highly scalable. Time series database stores data in chronological order and manages time series data with timestamps. It has large data storage capacity and high insertion and query performance.

时序数据库技术,虽然能够很好地保存和查找时序数据,但是每一个数据单元也即每个数据点,都需要对应保存一个数据头结构,所以,数据头结构对存储空间的占用,与数据单元的总量正相关,损耗极高。实践中,物联网设备所使用的闪存介质存储空间一般不大,在有限的存储空间的限制下,为了实现时序数据存储效率最大化,需要对现有的时序数据存储技术进行优化。Although time series database technology can save and search time series data very well, each data unit, that is, each data point, needs to store a corresponding data header structure. Therefore, the data header structure occupies storage space and is different from the data unit. The total amount is positively correlated, and the loss is extremely high. In practice, the storage space of flash media used by IoT devices is generally not large. Under the constraints of limited storage space, in order to maximize the efficiency of time series data storage, existing time series data storage technology needs to be optimized.

发明内容Contents of the invention

本申请的目的在于提供一种物联网设备及其时序数据存取方法和相应的装置与介质。The purpose of this application is to provide an Internet of Things device and its time series data access method and corresponding devices and media.

根据本申请的一个方面,提供一种时序数据存取方法,包括:According to one aspect of this application, a time series data access method is provided, including:

创建存储空间内扇区中的存储区块,所述存储区块包括多个时序相对应的存储位置,用于有序存储时序数据中各个时序相对应的数据单元;Create a storage block in a sector in the storage space. The storage block includes a plurality of storage locations corresponding to time series, and is used to orderly store data units corresponding to each time series in the time series data;

更新所述存储空间的存储分配信息中所述扇区相对应的扇区信息,所述扇区信息包括时序范围信息,用于表示该扇区各个存储区块实际存储的数据单元所构成的时序范围;Update the sector information corresponding to the sector in the storage allocation information of the storage space. The sector information includes timing range information, which is used to represent the timing composed of data units actually stored in each storage block of the sector. scope;

更新所述存储空间的存储分配信息中所述存储区块相对应的区块信息,所述区块信息包括时序寻址信息,用于表示该存储区块实际存储的数据单元的时序;Update the block information corresponding to the storage block in the storage allocation information of the storage space, where the block information includes timing addressing information used to represent the timing of the data units actually stored in the storage block;

基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,从该起始时序位置开始存取所述目标时序数据的各个数据单元。Based on the storage allocation information, a starting timing position corresponding to the access target timing data is determined, and each data unit of the target timing data is accessed starting from the starting timing position.

根据本申请的另一方面,提供一种时序数据存取装置,包括:According to another aspect of the present application, a sequential data access device is provided, including:

创建执行模块,设置为创建存储空间内扇区中的存储区块,所述存储区块包括多个时序相对应的存储位置,用于有序存储时序数据中各个时序相对应的数据单元;Create an execution module, configured to create a storage block in a sector in the storage space. The storage block includes a plurality of storage locations corresponding to time series, and is used to orderly store data units corresponding to each time series in the time series data;

扇区更新模块,设备为更新所述存储空间的存储分配信息中所述扇区相对应的扇区信息,所述扇区信息包括时序范围信息,用于表示该扇区各个存储区块实际存储的数据单元所构成的时序范围;The sector update module is used to update the sector information corresponding to the sector in the storage allocation information of the storage space. The sector information includes timing range information and is used to represent the actual storage of each storage block in the sector. The timing range composed of data units;

区块更新模块,设置为更新所述存储空间的存储分配信息中所述存储区块相对应的区块信息,所述区块信息包括时序寻址信息,用于表示该存储区块实际存储的数据单元的时序;A block update module, configured to update block information corresponding to the storage block in the storage allocation information of the storage space, wherein the block information includes timing addressing information for indicating the timing of the data unit actually stored in the storage block;

数据存取模块,设置为基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,从该起始时序位置开始存取所述目标时序数据的各个数据单元。The data access module is configured to determine a starting timing position corresponding to the access target timing data based on the storage allocation information, and start accessing each data unit of the target timing data from the starting timing position.

根据本申请的另一方面,提供一种物联网设备,包括控制单元和闪存介质,所述控制单元包括中央处理器和存储器,所述存储器存储有计算机可读指令,所述中央处理器从所述存储器调用所述计算机可读指令,以执行所述时序数据存取方法中的步骤,以确定存储介质提供的存储空间的存储分配信息,以根据所述存储分配信息向所述存储空间存取时序数据。According to another aspect of the present application, an Internet of Things device is provided, including a control unit and a flash memory medium. The control unit includes a central processor and a memory. The memory stores computer-readable instructions. The central processor obtains the The memory calls the computer readable instructions to execute the steps in the sequential data access method to determine storage allocation information of the storage space provided by the storage medium, so as to access the storage space according to the storage allocation information. Time series data.

根据本申请的另一方面,提供一种非易失性计算机可读存储介质,其以计算机可读指令的形式存储有依据所述时序数据存取方法所实现的计算机程序,所述计算机程序被计算机调用运行时,执行该方法所包括的步骤。According to another aspect of the present application, a non-volatile computer-readable storage medium is provided, which stores a computer program implemented according to the sequential data access method in the form of computer-readable instructions, and the computer program is When the computer calls the runtime, it executes the steps involved in the method.

相对于现有技术,本申请具有多方面技术优势,包括但不限于如下各方面:Compared with the existing technology, this application has many technical advantages, including but not limited to the following aspects:

首先,在对存储空间进行空间规划的层面,将存储空间按照两级进行分区,将整个存储空间先按扇区划分,再将扇区按存储区块划分,对应扇区与存储区块的结构,提供相应的存储分配信息,其中包括各个扇区的扇区信息和每个扇区中的每个存储区块相对应的区块信息;在对存储空间进行时序规划的层面,本申请按照时序进行寻址管理,在每个存储区块中提供多个存储位置,以便对应存储时序数据中的各个数据单元,使每个数据单元都可以确定其相应的存储位置,存储位置以时序来表示,对于每个存储区块,采用单个区块信息来表示该存储区块中的多个数据单元的时序寻址信息,而不必为每个数据单元单独设置数据头结构,每个扇区的扇区信息也通过时序范围信息对其所辖的各个存储区块中存储的数据单元的时序范围进行组织,由此,实现对存储的统一化规划,在此基础上,可以实现更为高效的时序数据存取操作。First, at the level of space planning for storage space, the storage space is divided into two levels. The entire storage space is first divided into sectors, and then the sectors are divided into storage blocks, corresponding to the structure of sectors and storage blocks. , providing corresponding storage allocation information, including sector information of each sector and block information corresponding to each storage block in each sector; at the level of timing planning of storage space, this application follows the timing Perform addressing management and provide multiple storage locations in each storage block to correspond to each data unit in the storage time series data, so that each data unit can determine its corresponding storage location. The storage location is represented by time series. For each storage block, a single block information is used to represent the timing addressing information of multiple data units in the storage block, without having to set a separate data header structure for each data unit. The sector of each sector The information also organizes the timing range of the data units stored in each storage block under its jurisdiction through timing range information. This enables unified planning of storage. On this basis, more efficient timing data can be achieved. access operations.

其次,本申请利用存储位置连续的存储区块来存储时序数据中的多个数据单元,每个数据单元无需设置数据头结构,基于时序数据中各个数据单元都有相同数据结构而有相同的存储尺寸的特点,存储区块可以通过其时序寻址信息来表示其中存储区块内全部数据单元的时序,由此,时序寻址信息只需极少量的字节数,便可实现对其存储区块内各个数据单元的时序的表示,极大地节省了存储开销,大幅提升存储空间的存储效率。Secondly, the present application utilizes storage blocks with continuous storage locations to store multiple data units in the timing data. There is no need to set a data header structure for each data unit. Based on the characteristics that each data unit in the timing data has the same data structure and the same storage size, the storage block can use its timing addressing information to represent the timing of all data units in the storage block. Therefore, the timing addressing information only requires a very small number of bytes to represent the timing of each data unit in its storage block, which greatly saves storage overhead and significantly improves the storage efficiency of the storage space.

此外,基于本申请具有提升存储空间的存储效率的优势,可将其应用到物联网设备中,使物联网设备可以基于有限存储空间的闪存介质,存储更大时序范围的时序数据,提升物联网设备的信息容量,降低物联网设备的成本。In addition, this application has the advantage of improving the storage efficiency of storage space, and can be applied to Internet of Things devices, so that Internet of Things devices can store time series data in a larger time series range based on flash memory media with limited storage space, improving the Internet of Things. The information capacity of the device reduces the cost of IoT devices.

附图说明Description of the drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without exerting creative efforts.

图1为本申请示例性的扇区存储空间结构示意图;Figure 1 is a schematic diagram of an exemplary sector storage space structure of this application;

图2为本申请示例性存储区块的区块信息的数据结构示意图;FIG2 is a schematic diagram of a data structure of block information of an exemplary storage block of the present application;

图3为本申请示例性扇区的扇区信息的数据结构示意图;Figure 3 is a schematic diagram of the data structure of sector information of an exemplary sector in this application;

图4为本申请实施例中的计算机设备/物联网设备的结构示意图。Figure 4 is a schematic structural diagram of a computer device/Internet of Things device in an embodiment of the present application.

图5为本申请实施例中时序数据存取方法的流程示意图;Figure 5 is a schematic flowchart of the time series data access method in the embodiment of the present application;

图6为本申请实施例中的时序数据存取装置的结构示意图。FIG. 6 is a schematic diagram of the structure of a timing data access device in an embodiment of the present application.

具体实施方式Detailed ways

本申请的存储空间可以由闪存介质所提供,通过将本申请的时序数据存储方法实现为时序数据库技术,为向该存储空间的时序数据存取操作提供相应的数据读写服务。The storage space of the present application can be provided by a flash memory medium. By implementing the time series data storage method of the present application as a time series database technology, corresponding data reading and writing services are provided for the time series data access operations to the storage space.

根据本申请所实现的时序数据库技术,存储空间的文件系统将整个存储空间划分为多个扇区,将每个扇区划分为多个存储区块,其中,每个扇区可以有固定的空间占用,同理,每个存储区块也可以有固定的空间占用。每个存储区块用于存储按照时序组织的多个数据单元,每个数据单元只需包含具体数据,而无需为其独立设置数据头结构。文件系统可以通过存储分配信息对其存储空间的组织结构进行描述,据此,本申请的扇区可按照图1所示的空间结构进行组织。由图1可知,每个扇区由扇区头即其扇区信息和有序开辟的各个存储区块构成,每个存储区块中包括其相应的区块信息,每个区块信息之后为其相应的存储区块。对应的,本申请将存储分配信息设置为包括各个扇区相对应的扇区信息,和每个扇区中各个存储区块相对应的区块信息,其中,虽然每个存留区块包含有多个存储位置,以用于对应存储时序数据中的多个数据单元,但是只为存储区块一一对应设置其相应的区块信息。According to the time series database technology implemented in this application, the file system of the storage space divides the entire storage space into multiple sectors, and divides each sector into multiple storage blocks. Each sector can have a fixed space. Occupation, in the same way, each storage block can also have a fixed space occupation. Each storage block is used to store multiple data units organized in time series. Each data unit only needs to contain specific data without setting up an independent data header structure for it. The file system can describe the organizational structure of its storage space through storage allocation information. Accordingly, the sectors of this application can be organized according to the space structure shown in Figure 1. As can be seen from Figure 1, each sector consists of a sector header, that is, its sector information, and various storage blocks opened in an orderly manner. Each storage block includes its corresponding block information. After each block information is its corresponding storage block. Correspondingly, this application sets the storage allocation information to include sector information corresponding to each sector, and block information corresponding to each storage block in each sector. Although each storage block contains multiple A storage location is used to correspond to multiple data units in the storage time series data, but its corresponding block information is only set for a one-to-one correspondence between storage blocks.

由于时序数据中的数据单元是按照时序产生的,且各个数据单元基本同构而通常具有一致的存储尺寸,所以,每个存储区块相对应的区块信息中,可以综合表示其存储区块内实际存储的各个数据单元相对应的时序寻址信息,例如,一个实施例中,可以在时序寻址信息中,给出本存储区块所实际存储的各个数据单元中的最早时间戳,该最早时刻戳即为本存储区块所存储的起始时序,再按照其中实际存储的数据单元的总量确定出本存储区块的存储数据长度,由于每个数据单元的数据尺寸是确定的,所以,存储数据长度实际上给出了本存储区块实际存储的全部数据单元相对应的最大时序偏移量,据此,由最早时间戳和存储数据长度,便可构成本存储区块的时序寻址信息。不难理解,以该最早时间戳为基础,以该存储数据长度为终点进行步进,便可实现对本存储区块中实际存储的各个数据单元的遍历。同理,当需要在本存储区块确定一个存储位置时,根据该存储位置相对于该最早时间戳确定的时序偏移量,也可以确定相应的存储位置,可以向该存储位置读取或写入数据单元。同理,在该存储数据长度相对应的存储位置之后,一般是未写入数据单元的空余存储位置,可以在该空余存储位置中追加写入时序数据中的数据单元。Since the data units in time series data are generated according to time series, and each data unit is basically isomorphic and usually has the same storage size, the block information corresponding to each storage block can comprehensively represent its storage block. Timing addressing information corresponding to each data unit actually stored in this storage block. For example, in one embodiment, the earliest timestamp in each data unit actually stored in this storage block can be given in the timing addressing information. The earliest time stamp is the starting time sequence stored in this storage block, and then the storage data length of this storage block is determined according to the total amount of data units actually stored in it. Since the data size of each data unit is determined, Therefore, the storage data length actually gives the maximum timing offset corresponding to all data units actually stored in this storage block. Accordingly, the timing of this storage block can be formed from the earliest timestamp and the storage data length. Addressing information. It is easy to understand that based on the earliest timestamp and stepping with the stored data length as the end point, each data unit actually stored in this storage block can be traversed. Similarly, when a storage location needs to be determined in this storage block, the corresponding storage location can also be determined based on the timing offset of the storage location relative to the earliest timestamp, and the storage location can be read or written. Enter the data unit. Similarly, after the storage location corresponding to the storage data length, there is generally an empty storage location where no data unit has been written, and data units in the sequential data can be additionally written in the empty storage location.

如图2所示,本申请示例性地给出存储区块的数据结构,该数据结构包括有区块信息和相应的存储区块,区块信息中包括存储数据长度、预留字段、设备状态、开始时间戳,其中,区块信息与该存储区块的存储数据相对应设置,实际上构成该存储区块的头部结构。区块信息中的存储数据长度是指存储区块所存储的数据单元的总量;区块信息中的预留字段为非必需项,可灵活定义;区块信息中的设备状态可在某些实施例中使用,根据需要写入相应设备状态标识,以表示所存储的时序数据所对应的物联网设备的设备状态,例如,加湿器、取暖器等物联网设备,设备状态可以用来表示这些设备的不同档位状态,或者异常状态等,在使用该设备状态时,可以灵活运用,例如可以区分不同设备状态存储同一物联网设备的同类时序数据;区块信息中的开始时间戳,是相应的存储区块中时序最早的数据单元相对应的时间戳,所以也可称为最早时间戳。根据图1不难看出,开始时间戳可以仅需占用4个字节,而存储数据长度可以仅占用2个字节,总共6个字节,便可以实现对存储数据中的各个数据单元的寻址,空间占用极低,相对于为每个数据单元都采用数据头结构来进行索引来说,索引效率是极高的。As shown in Figure 2, this application exemplarily provides the data structure of a storage block. The data structure includes block information and corresponding storage blocks. The block information includes storage data length, reserved fields, and device status. , start timestamp, in which the block information is set corresponding to the storage data of the storage block, and actually constitutes the header structure of the storage block. The storage data length in the block information refers to the total amount of data units stored in the storage block; the reserved fields in the block information are optional and can be flexibly defined; the device status in the block information can be defined in certain Used in the embodiment, the corresponding device status identifier is written as needed to represent the device status of the IoT device corresponding to the stored time series data, for example, humidifier, heater and other IoT devices. The device status can be used to represent these Different gear states or abnormal states of the device can be used flexibly when using the device state. For example, different device states can be distinguished to store similar timing data of the same IoT device; the start timestamp in the block information is the corresponding The timestamp corresponding to the earliest data unit in the storage block, so it can also be called the earliest timestamp. It is easy to see from Figure 1 that the start timestamp can only occupy 4 bytes, and the storage data length can only occupy 2 bytes, a total of 6 bytes, so that each data unit in the stored data can be searched. The space occupied is extremely low. Compared with using the data header structure for indexing for each data unit, the indexing efficiency is extremely high.

存储分配信息中,对应每个扇区都提供一个相应的扇区信息,该扇区信息主要用来表示相应扇区内部的各个存储区块所存储的全部数据单元所占据的时序范围信息,通常可以采用开始时间戳和结束时间戳来表示。除此之外,还可以提供更为丰富的相关信息,例如,示例性的一个扇区信息的数据结构如图3所示,根据该示例,扇区信息中的字段,除了包括用来界定时序范围信息的开始时间戳和结束时间戳之外,还可以包括扇区状态、预留字段、存储区块总数、校验码等。扇区信息中的扇区状态,可以用来表示本扇区的使用状态,例如0xFF表示扇区未初始化,0x7F表示扇区为空,0x3F表示扇区使用中,0x1F表示扇区已满,在实际使用中可以根据扇区使用情况及时维护该扇区状态字段。扇区信息中的保留字段,可按需灵活使用。扇区信息中的存储区块总数,表示最后一个存储区块相对于本扇区的起始地址的偏移量,所以可用来协助寻址之用。扇区信息中的校验,可以用来判断本扇区中的全部数据是否正常。扇区信息中的开始时间戳和结束时间戳,分别表示在标准时间体系下,首个同步了标准时间的数据单元的时间戳和最后一个同步了标准时间的数据单元的时间戳。由此可见,扇区信息中,给出了查找存储区块所需的时间范围信息,此外,还通过存储区块总数给出了寻址所需的信息。根据存储区块总数可以快速定位到最新的存储区块,根据时间范围信息可以判断任意目标存储区块是否属于该扇区。In the storage allocation information, a corresponding sector information is provided for each sector. This sector information is mainly used to represent the timing range information occupied by all data units stored in each storage block within the corresponding sector. Usually It can be represented by a start timestamp and an end timestamp. In addition, richer related information can also be provided. For example, an exemplary data structure of sector information is shown in Figure 3. According to this example, the fields in the sector information include fields used to define timing. In addition to the start timestamp and end timestamp of the range information, it can also include sector status, reserved fields, total number of storage blocks, check codes, etc. The sector status in the sector information can be used to indicate the usage status of this sector. For example, 0xFF indicates that the sector is not initialized, 0x7F indicates that the sector is empty, 0x3F indicates that the sector is in use, and 0x1F indicates that the sector is full. In actual use, the sector status field can be maintained in time according to the sector usage. Reserved fields in sector information, which can be used flexibly as needed. The total number of storage blocks in the sector information indicates the offset of the last storage block relative to the starting address of the sector, so it can be used to assist in addressing. The checksum in the sector information can be used to determine whether all the data in this sector is normal. The start timestamp and end timestamp in the sector information respectively represent the timestamp of the first data unit synchronized with standard time and the timestamp of the last data unit synchronized with standard time under the standard time system. It can be seen that the sector information provides the time range information required to find the storage block. In addition, the total number of storage blocks also provides the information required for addressing. The latest storage block can be quickly located based on the total number of storage blocks, and whether any target storage block belongs to this sector can be determined based on the time range information.

一些实施例中,可以将存储分配信息作为闪存介质的分区信息使用,其他一些实施例中,存储分配信息也可以作为文件系统中的文件存储结构使用,其中的各个扇区的扇区信息、存储区块的区块信息及存储区块的存储数据等,均可以存储为这个文件系统中的具体文件。可见,本申请的存储分配信息的具体应用方式是灵活的,并不影响本申请的创造精神的体现。In some embodiments, the storage allocation information can be used as the partition information of the flash memory medium. In other embodiments, the storage allocation information can also be used as the file storage structure in the file system, in which the sector information and storage of each sector The block information of the block and the storage data of the storage block can be stored as specific files in this file system. It can be seen that the specific application method of storing and allocating information in this application is flexible and does not affect the embodiment of the creative spirit of this application.

不难理解,根据本申请以上的文件系统数据结构,可以在闪存介质的存储空间中进行高效的时序数据存取操作,本申请所称的存取,可以是指时序数据的存储,也可以是指时序数据的读取。本申请的闪存介质可以用于物联网设备中,用于存储物联网设备所采集的时序数据,当然,也可从该闪存介质中读取已存储的时序数据。本申请的时序数据,可以是物联网设备的传感器,例如温度传感器、湿度传感器、加速度传感器、心率传感器等等,任意传感器所采集的时序数据,这些时序数据包括同一传感器按照时序间隔采集的各个数据单元,对于同一传感器来说,其每个数据单元都具有相同数据结构,故具有相同的存储尺寸。本申请的物联网设备,可以是家用电器也可以可穿戴设备,家用电器可以是取暖器、加温器等,可穿戴设备可以是智能手表、智能眼镜等。It is not difficult to understand that according to the above file system data structure of the present application, efficient time series data access operations can be performed in the storage space of the flash memory medium. The access referred to in the present application may refer to the storage of time series data or the reading of time series data. The flash memory medium of the present application can be used in an Internet of Things device to store the time series data collected by the Internet of Things device. Of course, the stored time series data can also be read from the flash memory medium. The time series data of the present application can be a sensor of an Internet of Things device, such as a temperature sensor, a humidity sensor, an acceleration sensor, a heart rate sensor, etc., and the time series data collected by any sensor. These time series data include each data unit collected by the same sensor according to the time series interval. For the same sensor, each of its data units has the same data structure, so it has the same storage size. The Internet of Things device of the present application can be a household appliance or a wearable device. The household appliance can be a heater, a warmer, etc., and the wearable device can be a smart watch, smart glasses, etc.

根据以上关于存储空间的示例性的文件系统存储结构和工作原理,本申请的时序数据存取方法,可以实现为计算机程序产品,存储于如图4所示的物联网设备的存储介质中,由控制单元中的中央处理器从该存储器中调用后运行,在运行时确定传感器的时序数据,对闪存介质的存储空间进行该些时序数据的存取操作,具体可以先确定闪存介质提供的存储空间的存储分配信息,再根据存储分配信息向该存储空间存取该些时序数据。According to the above exemplary file system storage structure and working principle regarding storage space, the time series data access method of this application can be implemented as a computer program product and stored in the storage medium of the Internet of Things device as shown in Figure 4. The central processor in the control unit runs after being called from the memory, determines the timing data of the sensor at runtime, and performs access operations on the timing data in the storage space of the flash memory medium. Specifically, the storage space provided by the flash memory medium can be determined first. storage allocation information, and then accesses the timing data to the storage space according to the storage allocation information.

请参阅图5,在一个实施例中,本申请的时序数据存取方法,由控制单元负责执行,包括:Please refer to Figure 5. In one embodiment, the sequential data access method of the present application is executed by the control unit, including:

步骤S5100、创建存储空间内扇区中的存储区块,所述存储区块包括多个时序相对应的存储位置,用于有序存储时序数据中各个时序相对应的数据单元;Step S5100: Create a storage block in a sector in the storage space. The storage block includes a plurality of storage locations corresponding to time series, and is used to orderly store data units corresponding to each time series in the time series data;

可以按需在本申请的存储空间中创建扇区和/或存储区块,具体可以因应各种创建条件而灵活响应,例如:Sectors and/or storage blocks may be created in the storage space of the present application as needed, and may be flexibly responded to various creation conditions, for example:

一些实施例中,可以在多种创建条件之下,在已有扇区之下创建新存储区块。各种创建条件包括但不限于如下任意一种:当新扇区建立时,为其创造一个存储区块;当正在存储的时序数据,其正在写入的存储区块的存储容量不足以写入时序数据中的一个数据单元时,可以创建新的存储区块;当需要存储的时序数据携带物联网设备的设备状态标识,且该设备状态标识与当前定位的存储区块的区块信息中所存储的设备状态标识不同时,可以创建新的存储区块;当响应于存储区块创建指令时,创建相应的新存储区块。诸如此类均可。In some embodiments, a new storage block can be created under an existing sector under various creation conditions. Various creation conditions include, but are not limited to, any of the following: when a new sector is established, a storage block is created for it; when the storage capacity of the storage block to which the time series data is being stored is insufficient to write a data unit in the time series data, a new storage block can be created; when the time series data to be stored carries a device status identifier of an IoT device, and the device status identifier is different from the device status identifier stored in the block information of the currently located storage block, a new storage block can be created; when responding to a storage block creation instruction, a corresponding new storage block is created. And so on.

一些实施例中,也可以先创建新扇区,新扇区的创建条件包括但不限于如下任意一种:当对存储空间进行格式化时,初始创建至少一个新扇区;当正在写入时序数据的当前扇区容量不足时,创建一个新扇区以及其中的新存储区块,以便在该扇区的新存储区块中继续存储该时序数据中未写入的数据单元。In some embodiments, a new sector may also be created first. The conditions for creating a new sector include but are not limited to any of the following: when formatting the storage space, initially creating at least one new sector; when the writing sequence is in progress. When the capacity of the current sector of data is insufficient, a new sector and a new storage block in it are created so that unwritten data units in the timing data can continue to be stored in the new storage block of the sector.

本申请中,可以事先对扇区及其中的存储区块的存储容量进行规范,使每个扇区的存储容量都按定值设定而得到标准化,同理,扇区中的每个存储区块的存储容量也可以设为定值而实现标准化,当然,扇区由于可以包含一个或多个存储区块,其存储容量一般按照存储区块所占用的存储容量的有限倍数设定。In this application, the storage capacity of the sectors and the storage blocks therein can be standardized in advance, so that the storage capacity of each sector is standardized according to a fixed value setting. Similarly, each storage area in the sector The storage capacity of a block can also be set to a fixed value to achieve standardization. Of course, since a sector can contain one or more storage blocks, its storage capacity is generally set according to a limited multiple of the storage capacity occupied by the storage block.

一个实施例中,允许每个扇区、每个存储区块按需设定其相应的存储容量,以便为开发提供一定的灵活度,为此,可以在扇区的扇区信息、存储区块的区块信息的预留字段中,写入相应的扇区、存储区块的最大存储容量,后续可通过计算相应扇区、存储区块中已存储的数据单元所占用的存储容量是否达到该最大存储容量,确定相应的扇区、存储区块的剩余存储空间,以便据此做出是否需要扩展新扇区、新存储区块的判断。In one embodiment, each sector and each storage block is allowed to set its corresponding storage capacity as needed to provide a certain degree of flexibility for development. To this end, the sector information and storage block of the sector can be set. In the reserved field of the block information, write the maximum storage capacity of the corresponding sector and storage block. Subsequently, you can calculate whether the storage capacity occupied by the data units stored in the corresponding sector and storage block reaches the maximum storage capacity. The maximum storage capacity determines the remaining storage space of the corresponding sectors and storage blocks, so that a judgment can be made based on whether new sectors or new storage blocks need to be expanded.

如前文所揭示,本申请的存储区块,包括多个时序相对应的存储位置,每个存储位置对应存储时序数据中的一个数据单元,所以,这个存储位置是根据存储到该存储区块中的数据单元的存储尺寸确定的,不难理解,当数据单元的存储尺寸较大时,存储区块的有限存储容量便只能容纳数量较少的数据单元,反之,当数据单元的存储尺寸较小时,存储区块的有限存储容量便能容纳数量较多的数据单元,所以,存储位置是应数据单元的存入而确定的,当数据单元存储相应的存储位置后,由于数据单元本身是按时序读写的,此时,其存储位置也对应该数据单元的时序,也就是说,存储区块中的各个存储位置,有序存储时序数据中的各个时序相对应的数据单元,可以通过时序变动来实施对各个存储位置的存取操作。As disclosed above, the storage block of this application includes multiple storage locations corresponding to time series. Each storage location corresponds to a data unit in the storage time series data. Therefore, this storage location is stored in the storage block based on The storage size of the data unit is determined. It is not difficult to understand that when the storage size of the data unit is larger, the limited storage capacity of the storage block can only accommodate a smaller number of data units. On the contrary, when the storage size of the data unit is larger, When the data unit is small, the limited storage capacity of the storage block can accommodate a larger number of data units. Therefore, the storage location is determined according to the deposit of the data unit. When the data unit stores the corresponding storage location, since the data unit itself is on time Sequential reading and writing, at this time, its storage location also corresponds to the timing of the data unit, that is to say, each storage location in the storage block, the data unit corresponding to each timing in the sequential storage of timing data, can be passed through the timing Changes to implement access operations to various storage locations.

当需要在存储空间内创建某个已有扇区的存储区块时,会涉及到对存储空间的存储分配信息的更新,具体请见后文。When it is necessary to create a storage block of an existing sector in the storage space, it will involve updating the storage allocation information of the storage space. Please see the following for details.

步骤S5200、更新所述存储空间的存储分配信息中所述扇区相对应的扇区信息,所述扇区信息包括时序范围信息,用于表示该扇区各个存储区块实际存储的数据单元所构成的时序范围;Step S5200: Update the sector information corresponding to the sector in the storage allocation information of the storage space. The sector information includes timing range information, which is used to represent the data units actually stored in each storage block of the sector. The timing range of the composition;

由于扇区中新增了区块信息,意味着创建了一个相应的存储区块,在这种情况下,可以对存储区间的存储分配信息进行更新,具体而言,在存储分配信息中,对应该存储区块所属扇区的扇区信息,也需要进行相应的更新,例如,如图3所示例的扇区信息数据结构中,由于新建的存储区块成为最后一个存储区块,所以,其中的存储区块总数便需要做相应的更新,使其与新建的存储区块相对应。Since new block information is added to the sector, it means that a corresponding storage block is created. In this case, the storage allocation information of the storage interval can be updated. Specifically, in the storage allocation information, the sector information of the sector to which the storage block belongs also needs to be updated accordingly. For example, in the sector information data structure shown in FIG. 3, since the newly created storage block becomes the last storage block, the total number of storage blocks therein needs to be updated accordingly to correspond to the newly created storage block.

如前文所揭示,扇区信息中还包括有时序范围信息,在如图3的示例中,该时序范围信息包括开始时间戳和结束时间戳,这两个字段需要根据本扇区中各个存储区块实际存储的数据单元所构成的时序范围来确定,因而,后续在向新增的存储区块存储数据单元之后,会导致其中的结束时间戳被更新。As disclosed above, the sector information also includes timing range information. In the example of Figure 3, the timing range information includes a start timestamp and an end timestamp. These two fields need to be determined based on the timing range constituted by the data units actually stored in each storage block in this sector. Therefore, after the data units are subsequently stored in the newly added storage block, the end timestamp therein will be updated.

步骤S5300、更新所述存储空间的存储分配信息中所述存储区块相对应的区块信息,所述区块信息包括时序寻址信息,用于表示该存储区块实际存储的数据单元的时序;Step S5300: Update the block information corresponding to the storage block in the storage allocation information of the storage space. The block information includes timing addressing information used to represent the timing of the data units actually stored in the storage block. ;

同理,在存储空间的存储分配信息中,会更新该存储区块相对应的区块信息,具体是增加该存储区块相对应的区块信息,该区块信息由于是插入更新的,所以其如图2所示的各个字段,需要进行初始化,由于该区块信息是新创建的,所以,对其中的各个字段进行初始化的操作,实际也是对该区块信息进行更新的操作,将其中的各个字段都更新为其初始化相对应的初始值。Similarly, in the storage allocation information of the storage space, the block information corresponding to the storage block will be updated. Specifically, the block information corresponding to the storage block will be added. Since the block information is inserted and updated, so Each field shown in Figure 2 needs to be initialized. Since the block information is newly created, the operation of initializing each field is actually an operation of updating the block information. Each field of is updated to its initial value corresponding to initialization.

如前文所揭示,区块信息中还包括时序寻址信息,在如图2的示例中,该时序寻址信息包括开始时间戳和存储数据长度,该存储数据长度可以在新建下一存储区块时才进行更新,开始时间戳指示存储区块中实际存储的首个数据单元相对应的时序,而存储数据长度指示存储区块中实际存储的数据单元总量,而数据单元的存储尺寸是确定的,实际上通过存储数据长度和开始时间戳便限定出了本存储区块中各个数据单元的时序寻址信息,例如,通过在该存储数据长度范围内,基于该开始时间戳进行步进,便可逐一确定本存储区块中的各个存储位置,也即确定各个时序相对应的数据单元,可以据此进行存取操作。As disclosed previously, the block information also includes timing addressing information. In the example of Figure 2, the timing addressing information includes the start timestamp and the storage data length. The storage data length can be used to create the next storage block. It is updated only when the start timestamp indicates the timing corresponding to the first data unit actually stored in the storage block, and the storage data length indicates the total amount of data units actually stored in the storage block, and the storage size of the data unit is determined In fact, the timing addressing information of each data unit in this storage block is defined by storing the data length and the start timestamp. For example, by stepping within the storage data length range based on the start timestamp, Then each storage location in this storage block can be determined one by one, that is, the data units corresponding to each timing sequence can be determined, and access operations can be performed accordingly.

步骤S5400、基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,从该起始时序位置开始存取所述目标时序数据的各个数据单元。Step S5400: Based on the storage allocation information, determine the starting timing position corresponding to the access target timing data, and start accessing each data unit of the target timing data from the starting timing position.

当完成存储区块的创建及相应更新存储分配信息后,存储分配信息中便包含有相应的存储区块的完整的区块信息,在此基础上,当需要对目标时序数据进行存取时,便可以根据该存储分配信息进行寻址确定起始时序位置,然后从起始时序位置开始存取该目标时序数据的各个数据单元。After the creation of the storage block and the corresponding update of the storage allocation information are completed, the storage allocation information will contain the complete block information of the corresponding storage block. On this basis, when the target timing data needs to be accessed, the starting timing position can be determined according to the storage allocation information, and then the various data units of the target timing data can be accessed from the starting timing position.

一种实施例中,实施存取操作可以是指实施存储操作,据此,根据该存储分配信息,可以根据其中的最新扇区的扇区信息中的存储区块总数确定出其最新存储区块,然后,根据该最新存储区块的区块信息给定的开始时间戳及其相应的存储数据长度,便可确定出可以存储数据单元的存储位置,将该存储位置作为起始时序位置,将目标时序数据中的各个数据单元从该起始时序位置开始,存储至该存储单元中。若当前存储区块不足以存储后续的数据单元,可以继续循环本申请的步骤S5100至步骤S5300,继续在本扇区中创建新的存储区块;同理,若当前扇区不足以创建新的存储区块,只要存储空间的剩余空间充足,还可以继续创建新扇区,再在新扇区中创建新的存储区块,以此类推即可。In one embodiment, implementing an access operation may refer to implementing a storage operation, whereby, according to the storage allocation information, the latest storage block can be determined according to the total number of storage blocks in the sector information of the latest sector, and then, according to the start timestamp given in the block information of the latest storage block and its corresponding storage data length, the storage position where the data unit can be stored can be determined, and the storage position is used as the starting timing position, and each data unit in the target timing data is stored in the storage unit starting from the starting timing position. If the current storage block is not sufficient to store subsequent data units, the steps S5100 to S5300 of the present application can be continuously looped to continue to create a new storage block in the current sector; similarly, if the current sector is not sufficient to create a new storage block, as long as there is sufficient remaining space in the storage space, new sectors can continue to be created, and then new storage blocks can be created in the new sectors, and so on.

另一实施例中,实施存取操作可以是指实施读取操作,据此,在给定了对目标时序数据进行寻址所需的开始时间戳和结束时间戳的情况下,可以根据该存储分配信息中各个扇区信息中的开始时间戳和结束时间戳所界定的时序范围信息,判断目标时序数据的开始时间戳、结束时间戳落入哪一个扇区,然后,在所落入的扇区中,通过对该扇区的各个区块信息的开始时间戳进行识别,可以快速确定目标时序数据的开始时间戳、结束时间戳所对应的存储区块,然后在相应存储区块中,便可以根据其中的开始时间戳和存储数据长度,为目标时序数据的开始时间戳、结束时间戳进行寻址,确定出它们在相应存储区块中的存储位置,其中,目标时序数据的开始时间戳相对应的扇区中的存储区块中的存储位置,即为起始时序位置,而目标时序数据的结束时间戳相对应的扇区中的存储区块中的存储位置,即为结束时序位置,据此,从该起始时序位置开始按时序读取数据单元,一直到结束时序位置相对应的数据单元,这个时序跨度相对应的各个数据单元,便构成目标时序数据,由此,便完成对目标时序数据的读取。In another embodiment, performing an access operation may refer to performing a read operation. Accordingly, given the start timestamp and the end timestamp required for addressing the target time series data, it is possible to determine which sector the start timestamp and the end timestamp of the target time series data fall into based on the time range information defined by the start timestamp and the end timestamp in each sector information in the storage allocation information. Then, in the sector in which the target time series data falls, by identifying the start timestamp of each block information of the sector, the storage block corresponding to the start timestamp and the end timestamp of the target time series data can be quickly determined. Then, in the corresponding storage block, the start timestamp can be determined based on the start timestamp. The time stamp and the storage data length are used to address the start timestamp and the end timestamp of the target timing data, and determine their storage positions in the corresponding storage blocks, wherein the storage position in the storage block in the sector corresponding to the start timestamp of the target timing data is the starting timing position, and the storage position in the storage block in the sector corresponding to the end timestamp of the target timing data is the ending timing position. Based on this, data units are read in sequence from the starting timing position until the data units corresponding to the ending timing position. The data units corresponding to this timing span constitute the target timing data, thereby completing the reading of the target timing data.

根据以上实施例可以知晓,本申请具有多方面技术优势,包括但不限于如下各方面:It can be known from the above embodiments that this application has many technical advantages, including but not limited to the following aspects:

首先,在对存储空间进行空间规划的层面,将存储空间按照两级进行分区,将整个存储空间先按扇区划分,再将扇区按存储区块划分,对应扇区与存储区块的结构,提供相应的存储分配信息,其中包括各个扇区的扇区信息和每个扇区中的每个存储区块相对应的区块信息;在对存储空间进行时序规划的层面,本申请按照时序进行寻址管理,在每个存储区块中提供多个存储位置,以便对应存储时序数据中的各个数据单元,使每个数据单元都可以确定其相应的存储位置,存储位置以时序来表示,对于每个存储区块,采用单个区块信息来表示该存储区块中的多个数据单元的时序寻址信息,而不必为每个数据单元单独设置数据头结构,每个扇区的扇区信息也通过时序范围信息对其所辖的各个存储区块中存储的数据单元的时序范围进行组织,由此,实现对存储的统一化规划,在此基础上,可以实现更为高效的时序数据存取操作。First, at the level of spatial planning of the storage space, the storage space is partitioned into two levels, the entire storage space is first divided into sectors, and then the sectors are divided into storage blocks. Corresponding to the structure of sectors and storage blocks, corresponding storage allocation information is provided, including sector information of each sector and block information corresponding to each storage block in each sector; at the level of timing planning of the storage space, the present application performs addressing management according to timing, and provides multiple storage locations in each storage block to correspond to each data unit in the storage timing data, so that each data unit can determine its corresponding storage location, and the storage location is represented by timing. For each storage block, a single block information is used to represent the timing addressing information of multiple data units in the storage block, without having to set a data header structure separately for each data unit. The sector information of each sector also organizes the timing range of the data units stored in each storage block under its jurisdiction through the timing range information, thereby realizing unified storage planning. On this basis, more efficient timing data access operations can be achieved.

其次,本申请利用存储位置连续的存储区块来存储时序数据中的多个数据单元,每个数据单元无需设置数据头结构,基于时序数据中各个数据单元都有相同数据结构而有相同的存储尺寸的特点,存储区块可以通过其时序寻址信息来表示其中存储区块内全部数据单元的时序,由此,时序寻址信息只需极少量的字节数,便可实现对其存储区块内各个数据单元的时序的表示,极大地节省了存储开销,大幅提升存储空间的存储效率。Secondly, this application uses storage blocks with continuous storage locations to store multiple data units in the time series data. Each data unit does not need to set a data header structure. Based on the fact that each data unit in the time series data has the same data structure and the same storage Due to the characteristics of size, the storage block can represent the timing of all data units in the storage block through its timing addressing information. Therefore, the timing addressing information only requires a very small number of bytes to implement the timing of the storage area. The timing representation of each data unit in the block greatly saves storage overhead and greatly improves the storage efficiency of storage space.

此外,基于本申请具有提升存储空间的存储效率的优势,可将其应用到物联网设备中,使物联网设备可以基于有限存储空间的闪存介质,存储更大时序范围的时序数据,提升物联网设备的信息容量,降低物联网设备的成本。In addition, this application has the advantage of improving the storage efficiency of storage space, and can be applied to Internet of Things devices, so that Internet of Things devices can store time series data in a larger time series range based on flash memory media with limited storage space, improving the Internet of Things. The information capacity of the device reduces the cost of IoT devices.

在本申请的方法的任意实施例的基础上,本申请的时序数据存取方法还包括:Based on any embodiment of the method of the present application, the time series data access method of the present application further includes:

步骤S6100、持续同步标准时间,用于确定数据单元的时序;Step S6100: Continuously synchronize the standard time to determine the timing of the data unit;

本申请中,在后台维持一个并行任务,由该并行任务实施时间同步操作,对时钟同步系统提供的标准时间进行同步,以便为本申请的存取操作尤其是存储操作提供时序基准。时钟同步系统可以是云端的时钟同步服务器提供的。从时钟同步系统同步的时间,作为标准时间使用。In this application, a parallel task is maintained in the background, and the parallel task implements time synchronization operations and synchronizes the standard time provided by the clock synchronization system to provide a timing reference for the access operations, especially storage operations, of this application. The clock synchronization system can be provided by a clock synchronization server in the cloud. The time synchronized from the clock synchronization system is used as the standard time.

步骤S6200、当同步标准时间成功时,将标准时间用于更新所述目标时序数据中的数据单元所在的存储区块的时序寻址信息;Step S6200: When the synchronization of the standard time is successful, the standard time is used to update the timing addressing information of the storage block where the data unit in the target timing data is located;

在实施对存储空间的存取操作时,通常都以标准时间为依据进行数据单元的读写,在顺利同步到标准时间的情况下,当在存储空间中,创建新的扇区、存储区块,或者对相应的存储区块实施时序数据的存取操作,尤其是存储操作,之后,存储区块中的时序寻址信息可以依据标准时间来更新。When performing access operations to storage space, data units are usually read and written based on standard time. When the standard time is successfully synchronized, new sectors and storage blocks are created in the storage space. , or implement time-series data access operations, especially storage operations, on the corresponding storage block. After that, the time-series addressing information in the storage block can be updated according to the standard time.

一种实施例中,在新建存储区块时,需要向相应的区块信息中写入开始时间戳,该开始时间戳便可以该标准时间为依据进行取值。In one embodiment, when creating a new storage block, a start timestamp needs to be written into the corresponding block information, and the start timestamp can be valued based on the standard time.

另一实施例中,当已有扇区不足存储目标时序数据时,会新建扇区以及在新建的扇区中新建存储区块,同理,扇区的扇区信息和存储区块的区块信息中,都需要写入开始时间戳,且扇区信息中还有结束时间戳,这些时间戳均可以标准时间为依据进行取值更新,也就是说,扇区的扇区信息中的时序范围信息和存储区块的区块信息中的时序寻址信息,默认均以标准时间为基准进行设置。In another embodiment, when the existing sectors are insufficient to store the target timing data, a new sector will be created and a new storage block will be created in the newly created sector. Similarly, the sector information of the sector and the block of the storage block will be created. In the information, a start timestamp needs to be written, and there is an end timestamp in the sector information. These timestamps can be updated based on standard time. That is to say, the timing range in the sector information of the sector The timing addressing information in the information and block information of the storage block are set based on standard time by default.

基于标准时间来实施对扇区信息和区块信息的维护,可以确保存储空间中的时序数据的时序一致性,据此,当需要在存储空间中查找扇区、存储区块、数据单元时,同样以标准时间为依据,可以精确地定位到具体的时序、存储位置,从而可以在指定的存储位置进行相应数据单元的存取。Maintaining sector information and block information based on standard time can ensure the timing consistency of timing data in the storage space. Therefore, when it is necessary to find sectors, storage blocks, and data units in the storage space, the specific timing and storage location can be accurately located based on the standard time, so that the corresponding data unit can be accessed at the specified storage location.

步骤S6300、当同步标准时间失败时,新建存储区块用于存储所述目标时序数据的数据单元,将系统时间用于更新该存储区块的时序寻址信息。Step S6300: When the synchronization of the standard time fails, create a new storage block to store the data unit of the target timing data, and use the system time to update the timing addressing information of the storage block.

由于网络条件的变化或者其他可能的原因,同步标准时间时也可能失败,这种情况下,不得不使用系统时间作为时序计算基准,系统时间与标准时间属于不同时间系统,所以,如果继续将目标时序数据存储到当前空闲的存储区块中,会导致后续存储的数据单元的时序基准与在先存储的数据单元的时序基准不一致,导致,根据时序寻址信息进行寻址时出错,这种情况下,本实施例的解决方式是另行按照本申请步骤S5100至步骤S5300的过程,创建新的存储区块,然后使用系统时间为时间基准配置新的存储区块的区块信息中的开始时间戳,将目标时序数据的各个待存储的数据单元从该开始时间戳指向的存储位置开始,有序存储到该新的存储区块中。由此,适应时间同步失败而启用系统时间的情况,可以确保将以系统时间记载的时序与以标准时间记载的时序相互区分,避免不同时间基准导致数据错乱。Due to changes in network conditions or other possible reasons, synchronization of the standard time may also fail. In this case, the system time has to be used as the timing calculation baseline. The system time and the standard time belong to different time systems. Therefore, if you continue to set the target Storing timing data into the currently free storage block will cause the timing reference of the subsequently stored data unit to be inconsistent with the timing reference of the previously stored data unit, resulting in an error when addressing based on the timing addressing information. This situation Next, the solution in this embodiment is to additionally follow the process from step S5100 to step S5300 of this application to create a new storage block, and then use the system time as the time base to configure the start timestamp in the block information of the new storage block. , each data unit to be stored of the target time series data is stored in the new storage block in an orderly manner starting from the storage location pointed to by the start timestamp. Therefore, adapting to the situation where time synchronization fails and enabling system time can ensure that the time series recorded in system time and the time series recorded in standard time are distinguished from each other, avoiding data confusion caused by different time bases.

为方便后续快速查找到这些以系统时间进行时序表示的存储区块,可以将这些存储区块标示为异常区块,例如,可以向该存储区块中的预留字段中写入表示时序异常相对应的标识,或者,另行建立到这些存储区块的指针信息等。In order to facilitate the subsequent quick search of these storage blocks that are expressed in system time, these storage blocks can be marked as abnormal blocks. For example, a reserved field in the storage block can be written to indicate the timing abnormality. Corresponding identifiers, or separately established pointer information to these storage blocks, etc.

根据以上实施例可以知晓,以标准时间作为存储空间中所存储的时序数据的时间基准,可以确保存储空间中的各个数据单元的时序整齐可靠,当同步标准时间失败时,启用系统时间为时间基准,通过新建存储区块来存储同步标准时间失败后的时序数据,这些时序数据中的数据单元可以使用系统时间来表示其时序,由此可以起到灾备容错的作用,确保两种基准的时序相互之间有一定的独立性,避免数据存取出错,数据安全性更强。According to the above embodiments, it can be known that using the standard time as the time base for the timing data stored in the storage space can ensure that the timing of each data unit in the storage space is neat and reliable. When synchronization of the standard time fails, the system time is enabled as the time base. , create a new storage block to store the timing data after the synchronization standard time fails. The data units in these timing data can use the system time to represent their timing, which can play a role in disaster recovery and fault tolerance and ensure the timing of the two benchmarks. They have a certain degree of independence from each other to avoid data access errors and have stronger data security.

在本申请的方法的任意实施例的基础上,当同步标准时间失败时,新建存储区块用于存储所述目标时序数据的数据单元,将系统时间用于更新该存储区块的时序寻址信息之后,包括:On the basis of any embodiment of the method of the present application, when synchronization with the standard time fails, a new storage block is created to store the data unit of the target time series data, and after the system time is used to update the timing addressing information of the storage block, the method includes:

步骤S6500、当同步到最新的标准时间时,确定最新的标准时间与当前的系统时间之间的误差值;Step S6500: When synchronizing to the latest standard time, determine the error value between the latest standard time and the current system time;

当同步标准时间失败而启用系统时间作为时序依据用于标示时序数据的时序之后,如果在继续同步标准时间的过程中,再次成功同步到最新的标准时间,此时,可以触发对存储空间中是否存在以系统时间进行时序表示的存储区块,以便将这些存储区块的时序寻址信息修改成以标准时间表示的数据。为此,可以先计算出最新的标准时间与当前的系统时间之间的误差值,该误差值表征系统时间相对于标准时间的滞后或超前情况。When the synchronization of the standard time fails and the system time is used as the timing basis to mark the timing of the timing data, if the synchronization of the standard time is continued and the latest standard time is successfully synchronized again, at this time, it can be triggered to check whether the storage space is There are memory blocks that are timed in system time so that the timed addressing information of these memory blocks can be modified into data in standard time. To this end, you can first calculate the error value between the latest standard time and the current system time. This error value represents the lag or advance of the system time relative to the standard time.

步骤S6600、检测确定所述存储分配信息中以系统时间表示的时序寻址信息;Step S6600: Detect and determine the timing addressing information expressed in system time in the storage allocation information;

以系统时间表示时序的存储区块,事先已经被标示,例如,在其区块信息的预留字段中添加有表示时序异常相对应的标识,或者其它任意方式均可,在这种情况下,根据对应的标示,在存储分配信息中,可以快速确定出这些采用系统时间进行时序表示的存储区块的区块信息,作为需要进行时序修正的区块信息,以备修正其中的时序寻址信息。The storage block whose timing is represented by system time has been marked in advance. For example, a mark corresponding to timing anomaly is added to the reserved field of its block information, or any other method can be used. In this case, According to the corresponding labels, in the storage allocation information, the block information of these storage blocks expressed in timing using system time can be quickly determined as the block information that needs timing correction in preparation for correcting the timing addressing information. .

步骤S6700、根据所述误差值修正所述时序寻址信息中的系统时间为标准时间。Step S6700: Correct the system time in the timing addressing information to the standard time according to the error value.

对于需要做时序修正的存储区块的时序寻址信息,具体例如其中的开始时间戳,将该开始时间戳叠加该误差值,便可将原来以系统时间表示的开始时间戳,修改为以标准时间表示的开始时间戳,由此,便将以系统时间表示时序的存储区块修改为以标准时间表示时序,使该存储区块的各个数据单元均可以标准时间为时序基准进行访问。当然,如果这个被修正的存储区块的预留字段中之前标记了表示时序异常相对应的标识,需对其进行恢复,以避免后续误识别。For the timing addressing information of the storage block that needs timing correction, such as the start timestamp, by superimposing the start timestamp with the error value, the start timestamp originally expressed in system time can be modified to standard The start timestamp of the time representation, thereby modifying the storage block that expresses the timing in system time to the timing in standard time, so that each data unit of the storage block can be accessed based on standard time as the timing basis. Of course, if the reserved field of the corrected storage block was previously marked with an identifier corresponding to a timing anomaly, it needs to be restored to avoid subsequent misidentification.

根据以上实施例可见,在标准时间同步失败后,以系统时间表示时序数据的时序以实现灾备容错处理,将时序数据暂存到新的存储区块中,当标准时间再次同步成功时,利用系统时间与标准时间之间的误差便可以将这些存储区块中的时序寻址信息修正为以标准时间进行时序表示,从而,确保全部时序数据都可以统一到同一时间基准,使存储空间中的全部时序数据都整齐有序、安全可靠。According to the above embodiments, after the standard time synchronization fails, the timing of the timing data is represented by the system time to achieve disaster recovery and fault tolerance processing, and the timing data is temporarily stored in a new storage block. When the standard time is synchronized successfully again, the error between the system time and the standard time can be used to correct the timing addressing information in these storage blocks to represent the timing in standard time, thereby ensuring that all timing data can be unified to the same time base, so that all timing data in the storage space are neat, orderly, safe and reliable.

在本申请的方法的任意实施例的基础上,创建存储空间内扇区中的存储区块之前,包括:Based on any embodiment of the method of this application, before creating the storage block in the sector in the storage space, the following steps are included:

步骤S4100、读取存储空间内各个扇区的扇区信息中携带的校验码,根据校验码对相应的扇区进行校验,当校验失败时将相应的扇区作为异常扇区,当校验成功时则作为正常扇区;Step S4100: Read the check code carried in the sector information of each sector in the storage space, and check the corresponding sector according to the check code. When the check fails, the corresponding sector is regarded as an abnormal sector. When the verification is successful, it is regarded as a normal sector;

如图3所示的扇区信息的结构图中,扇区信息可以给出一个校验码字段,用来存储扇区信息的校验码,在这种情况下,在必要时,通常是物联网设备上电时,可以对扇区的数据完整性进行校验。As shown in the structural diagram of sector information as shown in Figure 3, the sector information can be given a check code field to store the check code of the sector information. In this case, when necessary, it is usually a physical When the networking device is powered on, the data integrity of the sector can be verified.

为此,可以从存储分配信息中,针对每个扇区进行遍历,确定各个扇区的扇区信息,提取其中携带的校验码,根据生成校验码相对应的业务逻辑,对扇区信息中的目标字段相对应的各项数据生成另一校验码,将两个校验码进行比较,当两者一致时,表示这个扇区是正常扇区;当校验码不一致时,表示这个扇区出错,是异常扇区。To this end, each sector can be traversed from the storage allocation information to determine the sector information of each sector, extract the check code carried therein, and generate another check code for each data corresponding to the target field in the sector information according to the business logic corresponding to the generated check code. The two check codes are compared. When the two check codes are consistent, it indicates that the sector is a normal sector; when the check codes are inconsistent, it indicates that the sector is erroneous and is an abnormal sector.

步骤S4200、针对正常扇区,检测该正常扇区的扇区信息中的时序范围信息及其中最新存储区块的时序寻址信息是否正确,当不正确时,根据所述最新存储区块中实际存储的数据单元的时序修正所述时序寻址信息和所述时序范围信息;Step S4200: For a normal sector, detect whether the timing range information in the sector information of the normal sector and the timing addressing information of the latest storage block are correct. If it is incorrect, check whether the timing range information in the sector information of the normal sector is correct. The timing of stored data units corrects the timing addressing information and the timing range information;

本申请中,目标存储区块中的存储数据长度,其默认为一个特定的标识例如0xFF,当创建下一存储区块时,才根据该目标存储区块实际存储的数据单元的数量,更新其存储数据长度。如果一个存储区块在写入时序数据的过程中出现断电时,该存储区块的区块信息中构成时序寻址信息的存储数据长度可能未得到更新,在这种情况下,不仅会导致时序寻址信息不正确,常常也会导致相应的正常扇区中的时序范围信息不正确,主要表现为该时序范围信息的结束时间戳不正确。In the present application, the storage data length in the target storage block defaults to a specific identifier such as 0xFF. When the next storage block is created, the storage data length is updated according to the number of data units actually stored in the target storage block. If a storage block loses power during the process of writing timing data, the storage data length constituting the timing addressing information in the block information of the storage block may not be updated. In this case, not only will the timing addressing information be incorrect, but the timing range information in the corresponding normal sector will often be incorrect, which is mainly manifested in the incorrect end timestamp of the timing range information.

据此,对于正常扇区来说,可以进一步根据该正常扇区中的最新存储区块,也是其属于时序最后的存储区块实际存储的数据单元的数量,该数量自然也对应这些数据单元所涵盖的时序范围,据此检测该正常扇区的扇区信息中的时序范围信息,以及该最新存储区块的区块信息中的时序寻址信息是否正确,当正确时,表示正常扇区中的时序范围信息以及最新存储区块中的时序寻址信息无误,不必处理;否则,相应的,该正常扇区中的时序范围信息和最新存储区块中的时序寻址信息是不正确的,需要做相应的修正。Accordingly, for a normal sector, the number of data units actually stored in the latest storage block in the normal sector, which is also the last storage block in the sequence, naturally corresponds to the number of these data units. The timing range covered is used to detect whether the timing range information in the sector information of the normal sector and the timing addressing information in the block information of the latest storage block are correct. When correct, it means that the timing range information in the normal sector is correct. The timing range information and the timing addressing information in the latest storage block are correct and do not need to be processed; otherwise, correspondingly, the timing range information in the normal sector and the timing addressing information in the latest storage block are incorrect. Corresponding corrections are required.

据此,根据最新存储区块中实际存储的数据单元的数量,也就是存储区块所存储的时序总数,便可用来更新该最新存储区块的区块信息内时序寻址信息中的存储数据长度,并且,根据这个时序总数,与该最新存储区块的时序寻址信息中的开始时间戳进行结合计算,可以确定出整个正常扇区的结束时间戳,将该结束时间戳更新为该正常扇区的相应字段,便可实现对该正常扇区的时序范围信息的修正。Accordingly, according to the number of data units actually stored in the latest storage block, that is, the total number of timings stored in the storage block, it can be used to update the storage data in the timing addressing information in the block information of the latest storage block. length, and based on this timing total, combined with the start timestamp in the timing addressing information of the latest storage block, the end timestamp of the entire normal sector can be determined, and the end timestamp is updated to the normal The corresponding field of the sector can be used to correct the timing range information of the normal sector.

步骤S4300、针对异常扇区,对其进行初始化处理,使其扇区信息恢复默认的初始化信息。Step S4300: Perform initialization processing on the abnormal sectors to restore their sector information to default initialization information.

当一个扇区通过校验被确认为异常扇区之后,可以对其进行初始化处理,重置其扇区信息中的各个字段的数值,将各个字段的数值都恢复为默认的初始化信息即可。After a sector is confirmed as an abnormal sector through verification, it can be initialized, reset the values of each field in its sector information, and restore the values of each field to the default initialization information.

根据以上实施例不难理解,可以在物联网设备上电时,或者在其它任意需要对闪存介质中的数据安全性进行检测的时刻,对闪存介质的存储空间的各个扇区以及其中的存储区块进行异常排查,及时发现数据异常并予以相应的修复,确保存储在其中的时序数据具有较高的安全可靠性。It is easy to understand from the above embodiments that when the Internet of Things device is powered on, or at any other time when the security of the data in the flash memory medium needs to be detected, each sector of the storage space of the flash memory medium and the storage area therein can be checked. Block anomalies are checked to detect data anomalies in a timely manner and repair them accordingly, ensuring that the time series data stored therein has high security and reliability.

在本申请的方法的任意实施例的基础上,基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,从该起始时序位置开始存取所述目标时序数据的各个数据单元,包括:Based on any embodiment of the method of the present application, based on the storage allocation information, the starting timing position corresponding to the access target timing data is determined, and each of the target timing data is accessed starting from the starting timing position. Data units include:

步骤S7100、响应数据存储指令,将物联网设备所采集的待存储时序数据作为目标时序数据;Step S7100: Respond to the data storage instruction and use the time series data to be stored collected by the Internet of Things device as the target time series data;

当对本申请的存储空间实施的存取操作为存储操作时,可以由物联网设备触发相应的数据存储指令,响应于该指令,控制单元便可以获取物联网设备通过其传感器所采集的待存储时序数据,将这个待存储时序数据作为进行数据存取相对应的目标时序数据。When the access operation to the storage space of this application is a storage operation, the corresponding data storage instruction can be triggered by the Internet of Things device. In response to the instruction, the control unit can obtain the to-be-stored time series collected by the Internet of Things device through its sensor. Data, use this time series data to be stored as the target time series data corresponding to data access.

步骤S7200、根据所述存储分配信息确定最新存储区块中的首个空余存储位置,作为目标时序数据相对应的起始时序位置;Step S7200: Determine the first free storage location in the latest storage block according to the storage allocation information as the starting timing position corresponding to the target timing data;

存储空间中对时序数据的存储,是根据时序数据的特点,有序存储的,所以,本实施例进行数据存储时,所采用的调度规则,是将需要存储的目标时序数据写入存储空间中最新存储区块的首个空余存储位置。据此,可以根据存储分配信息中各个扇区的扇区信息,确定其中开始时间戳最新的扇区,然后在该扇区之下的各个存储区块中,确定其中开始时间戳最新的存储区块为最新存储区块,根据最新存储区块的时序寻址信息,也即其中的开始时间戳及存储数据长度,便可确定出该最新存储区块中的首个空余存储位置,将这个空余存储位置作为要写入目标时序数据的起始时序位置使用。The storage of time series data in the storage space is stored in order according to the characteristics of the time series data. Therefore, when storing data in this embodiment, the scheduling rule adopted is to write the target time series data to be stored into the first free storage position of the latest storage block in the storage space. Accordingly, the sector with the latest start timestamp can be determined according to the sector information of each sector in the storage allocation information, and then the storage block with the latest start timestamp is determined as the latest storage block in each storage block under the sector. According to the timing addressing information of the latest storage block, that is, the start timestamp and the length of the stored data, the first free storage position in the latest storage block can be determined, and this free storage position is used as the starting timing position to write the target time series data.

步骤S7300、基于所述起始时序位置开始有序存储所述目标时序数据的各个数据单元;Step S7300: Start storing each data unit of the target timing data in an orderly manner based on the starting timing position;

在确定起始时序位置的基础上,便可将目标时序数据中的各个数据单元,按照每个数据单元对应一个存储位置的方式存入到该最新存储区块中,不难理解,每个数据单元占用一个对应的时序,随着目标时序数据中数据单元的追加存储,将会导致存储区块被占用的空间越来越多。On the basis of determining the starting timing position, each data unit in the target timing data can be stored in the latest storage block in a manner that each data unit corresponds to a storage location. It is not difficult to understand that each data unit The unit occupies a corresponding time series. With the additional storage of data units in the target time series data, more and more space will be occupied by the storage block.

步骤S7400、在存储所述目标时序数据的各个数据单元的过程中,检测正在存储的存储区块的存储位置是否已满,当已满时,新建存储区块以继续存储所述目标时序数据的数据单元,根据已满的存储区块实际存储的数据单元更新已满的存储区块的时序寻址信息。Step S7400: In the process of storing each data unit of the target timing data, detect whether the storage location of the storage block being stored is full. If it is full, create a new storage block to continue storing the data units of the target timing data, and update the timing addressing information of the full storage block according to the data units actually stored in the full storage block.

在最新存储区块中存储目标时序数据的各个数据单元的过程中,在将要写入每个数据单元时,会检测当前存储区块的剩余容量是否足以存储一个数据单元,如果容量充足,则可直接写入该数据单元,否则,存储区块提供的存储容量已满,不足以存储一个数据单元,在这种情况下,便需要按照本申请的步骤S5100至步骤S5300的过程,创建新的存储区块,再在新的存储区块中继续存储目标时序数据中的后续数据单元,以此类推,直至完成目标时序数据中全部数据单元的存储。In the process of storing each data unit of the target time series data in the latest storage block, when each data unit is about to be written, it will be detected whether the remaining capacity of the current storage block is enough to store one data unit. If the capacity is sufficient, it can Directly write the data unit, otherwise, the storage capacity provided by the storage block is full and is not enough to store one data unit. In this case, it is necessary to create a new storage according to the process from step S5100 to step S5300 of this application. block, and then continue to store subsequent data units in the target time series data in the new storage block, and so on, until all data units in the target time series data are stored.

需要指出的是,对于每个正在进行存储操作的存储区块来说,由于时序数据是持续写入的,出于效率考虑,无需在向其写入每个数据单元时便更新其时序寻址信息,所以,本实施例采用的调度原则是在本存储区块已经被写满,而创建新的存储区块时,在创建了新的存储区块的情况下,才根据本存储区块实际存储的数据单元总量更新本存储区块的时序寻址信息中的存储数据长度,由此,使本存储区块的区块信息表示出准确的时序寻址信息。It should be pointed out that for each storage block in which storage operations are being performed, since sequential data is continuously written, for efficiency reasons, there is no need to update its sequential addressing when each data unit is written to it. Information, therefore, the scheduling principle adopted in this embodiment is that when the current storage block is full and a new storage block is created, the actual data of the current storage block will be calculated when a new storage block is created. The total amount of stored data units updates the stored data length in the timing addressing information of this storage block, thereby causing the block information of this storage block to represent accurate timing addressing information.

一些实施例中,当完成目标时序数据的全部存储操作后,可以对应更新被存储的存储区块所属扇区的扇区信息中的时序范围信息,具体通常是更新其中的结束时间戳。In some embodiments, after all storage operations of the target timing data are completed, the timing range information in the sector information of the sector to which the stored storage block belongs can be correspondingly updated. Specifically, the end timestamp thereof is usually updated.

当然,如果此时掉电,后续重新上电时,仍可根据本申请前文的实施例,通过对扇区的扇区信息和最新存储区块的区块信息进行检查和修复,来确保时序范围信息和时序寻址信息的可靠性。Of course, if the power is cut off at this time, when the power is restored later, the reliability of the timing range information and timing addressing information can still be ensured by checking and repairing the sector information of the sector and the block information of the latest storage block according to the previous embodiments of this application.

根据以上实施例,不难理解,当数据存取操作是数据存储操作时,本申请基于在新建存储区块时才对上一存储区块的时序寻址信息中的存储数据长度进行确定,避免响应目标时序数据中的每个数据单元的写入频繁修改时序寻址信息,同理,由于只需对存储区块的区块信息确定起始时序位置后便可实现连续的存储操作,无需对应每个数据单元具体确定其时序信息,所以,整个存储过程可以有效降低操作频度,确保存储过程更高效快速。According to the above embodiments, it is easy to understand that when the data access operation is a data storage operation, the present application determines the length of the stored data in the timing addressing information of the previous storage block only when a new storage block is created to avoid The timing addressing information is frequently modified in response to the writing of each data unit in the target timing data. Similarly, since only the starting timing position of the block information of the storage block is determined, continuous storage operations can be realized without corresponding Each data unit specifically determines its timing information, so the entire storage process can effectively reduce the frequency of operations and ensure that the storage process is more efficient and faster.

在本申请的方法的任意实施例的基础上,本申请的时序数据存取方法还包括:Based on any embodiment of the method of the present application, the time series data access method of the present application further includes:

步骤S8100、响应数据存储指令,获取物联网设备所采集的待存储时序数据作为目标时序数据,并获取物联网设备的设备状态标识;Step S8100: Respond to the data storage instruction, obtain the time series data to be stored collected by the Internet of Things device as the target time series data, and obtain the device status identification of the Internet of Things device;

当本申请的数据存取操作是数据存储操作时,响应相对应的数据存储指令,控制单元除了获取物联网设备的传感器所采集的待存储时序数据作为目标时序数据来进行数据存储操作之外,还可以获取物联网设备的设备状态标识,这个设备状态标识根据其数值不同,可以表示物联网设备的不同工作状态,例如,工作在不同档位相对应的不同状态等,以便因应不同工作状态,对不同工作状态下的时序数据进行相对独立的存储,以提升数据调度效率。When the data access operation of this application is a data storage operation, in response to the corresponding data storage instruction, the control unit not only obtains the time series data to be stored collected by the sensor of the Internet of Things device as the target time series data to perform the data storage operation, You can also obtain the device status identifier of the IoT device. Depending on its value, this device status identifier can represent different working states of the IoT device, for example, working in different states corresponding to different gears, etc., in order to respond to different working states. Store timing data in different working states relatively independently to improve data scheduling efficiency.

步骤S8200、根据所述存储分配信息确定出用于开始存储该目标时序数据相对应的目标存储区块;Step S8200: Determine the target storage block corresponding to the target timing data for starting to store according to the storage allocation information;

与前一实施例同理,对于需要存储的目标时序数据,可以根据存储分配信息,确定出最新存储区块作为目标存储区块,可参考步骤S7200所揭示的内容,此处不行赘述。Similar to the previous embodiment, for the target time series data to be stored, the latest storage block can be determined as the target storage block according to the storage allocation information. Please refer to the content disclosed in step S7200, which will not be repeated here.

步骤S8300、校验该设备状态标识与所述目标存储区块的区块信息中的设备状态标识是否一致,当不一致时,新建下一存储区块用于存储该目标时序数据,向该下一存储区块的区块信息中写入该设备状态标识。Step S8300: Verify whether the device status identifier is consistent with the device status identifier in the block information of the target storage block. If they are inconsistent, create a new storage block to store the target timing data, and send the next storage block to the next storage block. The device status identifier is written in the block information of the storage block.

如图2所示,本申请的存储区块的区块信息中,可以预设一个设备状态字段,用来存储设备状态标识,在这种情况下,可以将设备状态标识相同的时序数据存储在同一存储区块中,而将设备状态标识不同的时序数据存储在不同的存储区块中。根据这个原则,可以根据物联网设备提供的设备状态标识,是否与目标存储区块的区块信息中记载的设备状态标识一致,当两者一致时,可以按照步骤S7200所揭示的方式,在目标存储区块中确定存储目标时序数据相对应的起始时序位置。否则,则需为需要写入的目标时序数据创建新的存储区块,这个新建的存储区块是一个空区块,其区块信息中的设备状态字段可以写入物联网设备提供的设备状态标识,然后,从其存储区块中的首个存储位置开始,将目标时序数据中的各个数据单元存储到各个相应的存储位置,按照本申请前文实施例中步骤S7300至步骤S7400的过程,完成目标时序数据的存储即可。As shown in FIG2 , in the block information of the storage block of the present application, a device status field can be preset to store the device status identifier. In this case, the timing data with the same device status identifier can be stored in the same storage block, and the timing data with different device status identifiers can be stored in different storage blocks. According to this principle, it can be determined whether the device status identifier provided by the IoT device is consistent with the device status identifier recorded in the block information of the target storage block. When the two are consistent, the starting timing position corresponding to the storage target timing data can be determined in the target storage block in the manner disclosed in step S7200. Otherwise, a new storage block needs to be created for the target timing data to be written. This newly created storage block is an empty block, and the device status field in its block information can be written to the device status identifier provided by the IoT device. Then, starting from the first storage position in its storage block, each data unit in the target timing data is stored in each corresponding storage position. According to the process of steps S7300 to S7400 in the previous embodiment of the present application, the storage of the target timing data is completed.

根据以上实施例可见,本申请通过在区块信息中增设设备状态字段,可以解决区别物联网设备的不同设备状态存储相应设备状态下的时序数据的问题,方便根据物联网设备的不同设备状态,调用相应的时序数据,避免数据管理混乱。According to the above embodiments, this application can solve the problem of distinguishing different device states of IoT devices and storing time series data in corresponding device states by adding a device status field in the block information, making it convenient to store time series data according to different device states of IoT devices. Call the corresponding time series data to avoid confusion in data management.

在本申请的方法的任意实施例的基础上,基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,从该起始时序位置开始存取所述目标时序数据的各个数据单元,包括:Based on any embodiment of the method of the present application, based on the storage allocation information, the starting timing position corresponding to the access target timing data is determined, and each of the target timing data is accessed starting from the starting timing position. Data units include:

步骤S9100、响应数据读取指令,确定物联网设备所指定的寻址定位信息,所述寻址定位信息包括开始时间戳和结束时间戳;Step S9100: Respond to the data reading instruction and determine the addressing and positioning information specified by the Internet of Things device. The addressing and positioning information includes a start timestamp and an end timestamp;

当本申请的数据存取操作是数据读取操作时,物联网设备会触发相应的数据读取指令,响应该指令,控制单元便可获取该数据读取指令相对应的寻址定位信息。示例而言,该寻址定位信息通常包括开始时间戳和结束时间戳,表示要获取从开始时间戳开始到结束时间戳结束的过程中,各个时序相对应的数据单元作为要读取的目标时序数据。When the data access operation of this application is a data reading operation, the Internet of Things device will trigger the corresponding data reading instruction. In response to the instruction, the control unit can obtain the addressing and positioning information corresponding to the data reading instruction. For example, the addressing positioning information usually includes a start timestamp and an end timestamp, which means that in the process from the start timestamp to the end of the end timestamp, the data units corresponding to each time series are to be obtained as the target time series to be read. data.

在一些实施例中,寻址定位信息中的结束时间戳可以缺省,由控制单元将存储空间最新扇区的扇区信息中的结束时间戳作为其默认值,表示读取该开始时间戳之后的全部数据单元作为目标时序数据。In some embodiments, the end timestamp in the addressing positioning information can be defaulted, and the control unit uses the end timestamp in the sector information of the latest sector in the storage space as its default value, indicating that after reading the start timestamp All data units are used as target time series data.

步骤S9200、根据存储空间的存储分配信息进行寻址,确定所述开始时间戳和结束时间戳相对应的开始时序位置和结束时序位置;Step S9200: Address according to the storage allocation information of the storage space, and determine the start timing position and the end timing position corresponding to the start timestamp and the end timestamp;

据此,可以根据开始时间戳和结束时间戳在存储空间的存储分配信息进行寻址,每个时间戳的寻址都同理,具体而言,将寻址定位信息中的开始时间戳或结束时间戳作为目标时间戳为例,先根据存储分配信息中的各个扇区的扇区信息中标记的开始时间戳和结束时间戳所界定的时序范围信息,判断该目标时间戳所属的时序范围,当目标时间戳落入一个扇区信息的时序范围时,该扇区信息所属的扇区,即为该目标时间戳相匹配的目标扇区。Accordingly, addressing can be performed based on the storage allocation information of the start timestamp and end timestamp in the storage space. The addressing of each timestamp is the same. Specifically, the start timestamp or end timestamp in the addressing location information will be addressed. Taking the timestamp as the target timestamp as an example, first determine the timing range to which the target timestamp belongs based on the timing range information defined by the start timestamp and end timestamp marked in the sector information of each sector in the storage allocation information. When the target timestamp falls within the timing range of a sector information, the sector to which the sector information belongs is the target sector that matches the target timestamp.

然后,在属于目标扇区的各个存储区块相对应的区块信息中,根据其中记载的时序寻址信息中的开始时间戳和提供时序偏移信息的存储数据长度所界定的时序范围,便可确定目标时间戳是否属于该存储区块的时序寻址信息所界定的时序范围,当属于某个存储区块的时序范围时,该存储区块便是目标存储区块。Then, in the block information corresponding to each storage block belonging to the target sector, based on the start timestamp in the timing addressing information recorded therein and the timing range defined by the storage data length providing timing offset information, It can be determined whether the target timestamp belongs to the timing range defined by the timing addressing information of the storage block. When it belongs to the timing range of a certain storage block, the storage block is the target storage block.

在确定目标存储区块后,根据给出的目标时间戳与该目标存储区块中的开始时间戳之间的差值,自然可以确定相应的偏移量,由此,便可定位到该目标区块中该目标时间戳相对应的存储位置,这个存储位置,如果是根据物联网设备给出的开始时间戳确定的,便是开始时序位置;如果是根据物联网设备给出的结束时间戳确定的,便是结束时序位置。After determining the target storage block, the corresponding offset can naturally be determined based on the difference between the given target timestamp and the start timestamp in the target storage block. Thus, the storage position corresponding to the target timestamp in the target block can be located. If this storage position is determined based on the start timestamp given by the IoT device, it is the start timing position; if it is determined based on the end timestamp given by the IoT device, it is the end timing position.

需要指出的是,开始时序位置和结束时序位置可能属于不同的存储区块,或者跨越多个存储区块,具体视物联网设备在寻址定位信息中给出的开始时间戳和结束时间戳所界定的时间跨度而定,但这个时间跨度或长或短并不影响本申请创造精神的体现。It should be pointed out that the start timing position and the end timing position may belong to different storage blocks, or span multiple storage blocks, depending on the start timestamp and end timestamp given by the IoT device in the addressing and positioning information. It depends on the defined time span, but whether this time span is longer or shorter does not affect the embodiment of the creative spirit of this application.

步骤S9300、从所述开始时序位置开始读取数据单元,直到所述结束时序位置相应的数据单元为止,构成所述目标时序数据返回给所述物联网设备调用。Step S9300: Read data units starting from the start timing position until the data unit corresponding to the end timing position, and then construct the target timing data and return it to the Internet of Things device for calling.

在确定了需要调用的目标时序数据相对应的开始时序位置和结束时序位置后,便可从该开始时序位置开始读取数据单元,直到读出结束时序位置相对应的数据单元为止,将从开始时序位置到结束时序位置所界定的时间跨度范围内的全部数据单元,构成物联网设备需要调用的目标时序数据,返回给物联网设备使用,物联网设备进而可以根据这些目标时序数据做数据挖掘和效果呈现,或者将其上传到云端服务器中做进一步处理,诸如此类,可做更为丰富的扩展应用。After determining the start timing position and the end timing position corresponding to the target timing data that needs to be called, the data unit can be read from the start timing position until the data unit corresponding to the end timing position is read. All data units within the time span defined from the time series position to the end time series position constitute the target time series data that the IoT device needs to call, and are returned to the IoT device for use. The IoT device can then perform data mining and analysis based on these target time series data. Effect presentation, or uploading it to the cloud server for further processing, etc., can be used for richer extended applications.

根据以上实施例可以看出,基于本申请的存储分配实现所规范的分区数据结构,在进行时序数据的数据读取操作时,只需根据寻址定位信息确定相应的起始时序位置和结束时序位置,便可高效地读取各个存储区块中相应的数据单元作为需要调用的目标时序数据,由于无需对每个数据单元进行时间信息的比对,只需通过数据单元所在的存储区块的区块信息进行寻址,所以,其数据读取效率更高。According to the above embodiments, it can be seen that based on the standardized partition data structure implemented by the storage allocation of this application, when performing a data reading operation of time series data, it is only necessary to determine the corresponding starting timing position and ending timing based on the addressing and positioning information. position, the corresponding data unit in each storage block can be efficiently read as the target timing data that needs to be called. Since there is no need to compare the time information of each data unit, only the storage block where the data unit is located needs to be compared. Block information is addressed, so its data reading efficiency is higher.

通过实施本申请,可以显著提升闪存介质的存储效率,以下给出若干示例性分析供参考:By implementing this application, the storage efficiency of flash memory media can be significantly improved. Several exemplary analyzes are given below for reference:

假设连续时间存储情况下,存储空间为24个扇区(24*4096个字节),10分钟保存一次数据,数据单元的数据长度为30个字节,分别测试两种存储方案的结果。Assume that in the case of continuous time storage, the storage space is 24 sectors (24*4096 bytes), data is saved every 10 minutes, the data length of the data unit is 30 bytes, and the results of the two storage solutions are tested respectively.

使用传统时序数据存储技术,每个数据单元都设置一个数据头结构来标记其时间戳,据此,计算方式如下:Using traditional time-series data storage technology, each data unit is set with a data header structure to mark its timestamp. Based on this, the calculation method is as follows:

单个扇区可以保存(4096 - 40)/(16 + 30) = 88(取整)个数据单元。A single sector can hold (4096 - 40)/(16 + 30) = 88 (rounded) data units.

24个扇区总共可以保存24 * 88 = 2112个数据单元。24 sectors can store a total of 24 * 88 = 2112 data units.

使用本申请的时序数据存储技术,只通过存储区块的区块信息中的时序寻址信息来标记各个数据单元的时序,计算方式如下:Using the timing data storage technology of this application, the timing of each data unit is marked only by the timing addressing information in the block information of the storage block. The calculation method is as follows:

单个扇区可以保存(4096 - 16 - 8)/(30) = 135(取整)个数据点。A single sector can hold (4096 - 16 - 8)/(30) = 135 (rounded) data points.

24个扇区总共可以保存24 * 135 = 3240个数据点。24 sectors can hold a total of 24 * 135 = 3240 data points.

本申请与传统技术相比较,可存储的数据单元增加的比例为(3240 - 2112)/2112= 53%左右,比原来可以多存储一半的数据。Compared with traditional technology, this application increases the proportion of storable data units by (3240 - 2112)/2112= about 53%, which can store half more data than the original.

假设其他条件一样,数据单元的数据长度减为3个字节,分别测试两种存储方案的结果。Assuming other conditions are the same, the data length of the data unit is reduced to 3 bytes, and the results of the two storage schemes are tested respectively.

使用传统时序数据存储技术,每个数据单元都设置一个数据头结构来标记其时间戳,据此,计算方式如下:Using traditional time series data storage technology, each data unit is set with a data header structure to mark its timestamp. Accordingly, the calculation method is as follows:

单个扇区可以保存(4096 - 40)/(16 + 3) = 225(取整)个数据点。A single sector can hold (4096 - 40)/(16 + 3) = 225 (rounded) data points.

24个扇区总共可以保存24 * 225 = 5400个数据点。24 sectors can hold a total of 24 * 225 = 5400 data points.

使用本申请的时序数据存储技术,只通过存储区块的区块信息中的时序寻址信息来标记各个数据单元的时序,计算方式如下:Using the time series data storage technology of the present application, the time series of each data unit is marked only by the time series addressing information in the block information of the storage block, and the calculation method is as follows:

单个扇区可以保存(4096 - 16 - 8)/(3) = 1357(取整)个数据点。A single sector can hold (4096 - 16 - 8)/(3) = 1357 (rounded) data points.

24个扇区总共可以保存24 * 1357 = 32568个数据点。24 sectors can hold a total of 24 * 1357 = 32568 data points.

增加的比例为(32568 - 5400)/5400 = 500%左右,比原来可以多5倍的数据。根据以上的分析可见,本申请所取得技术效果是极其显著的。The increased ratio is (32568 - 5400)/5400 = about 500%, which is 5 times more data than before. According to the above analysis, it can be seen that the technical effects achieved by this application are extremely significant.

请参阅图6,本申请的另一实施例还提供一种时序数据存取装置,其包括创建执行模块5100、扇区更新模块5200、区块更新模块5300,以及数据存取模块5400,其中,所述创建执行模块5100,设置为创建存储空间内扇区中的存储区块,所述存储区块包括多个时序相对应的存储位置,用于有序存储时序数据中各个时序相对应的数据单元;所述扇区更新模块5200,设备为更新所述存储空间的存储分配信息中所述扇区相对应的扇区信息,所述扇区信息包括时序范围信息,用于表示该扇区各个存储区块实际存储的数据单元所构成的时序范围;所述区块更新模块5300,设置为更新所述存储空间的存储分配信息中所述存储区块相对应的区块信息,所述区块信息包括时序寻址信息,用于表示该存储区块实际存储的数据单元的时序;所述数据存取模块5400,设置为基于所述存储分配信息,确定存取目标时序数据相对应的起始时序位置,从该起始时序位置开始存取所述目标时序数据的各个数据单元。Please refer to FIG. 6 , another embodiment of the present application further provides a timing data access device, which includes a creation execution module 5100, a sector update module 5200, a block update module 5300, and a data access module 5400, wherein the creation execution module 5100 is configured to create a storage block in a sector in a storage space, and the storage block includes a plurality of storage locations corresponding to timings, and is used to sequentially store data units corresponding to each timing in the timing data; the sector update module 5200 is a device for updating the sector information corresponding to the sector in the storage allocation information of the storage space, and the sector update module 5300 is configured to update ... The sector information includes timing range information, which is used to indicate the timing range constituted by the data units actually stored in each storage block of the sector; the block update module 5300 is configured to update the block information corresponding to the storage block in the storage allocation information of the storage space, and the block information includes timing addressing information, which is used to indicate the timing of the data units actually stored in the storage block; the data access module 5400 is configured to determine the starting timing position corresponding to the access target timing data based on the storage allocation information, and access each data unit of the target timing data starting from the starting timing position.

在本申请的装置的任意实施例的基础上,本申请的时序数据存取装置,还包括:时间同步模块,设置为持续同步标准时间,用于确定数据单元的时序;成功处理模块,设置为当同步标准时间成功时,将标准时间用于更新所述目标时序数据中的数据单元所在的存储区块的时序寻址信息;失败处理模块,设置为当同步标准时间失败时,新建存储区块用于存储所述目标时序数据的数据单元,将系统时间用于更新该存储区块的时序寻址信息。Based on any embodiment of the device of this application, the time series data access device of this application also includes: a time synchronization module, set to continuously synchronize the standard time, used to determine the timing of the data unit; a success processing module, set to When the synchronization of the standard time is successful, the standard time is used to update the timing addressing information of the storage block where the data unit in the target timing data is located; the failure processing module is configured to create a new storage block when the synchronization of the standard time fails. The data unit used to store the target timing data uses system time to update the timing addressing information of the storage block.

在本申请的装置的任意实施例的基础上,后于所述失败处理模块的运行,本申请的时序数据存取装置,还包括:误差确定模块,设置为当同步到最新的标准时间时,确定最新的标准时间与当前的系统时间之间的误差值;数据排查模块,设置为检测确定所述存储分配信息中以系统时间表示的时序寻址信息;数据修正模块,设置为根据所述误差值修正所述时序寻址信息中的系统时间为标准时间。Based on any embodiment of the device of the present application, after the operation of the failure processing module, the time series data access device of the present application further includes: an error determination module, set to when synchronizing to the latest standard time, Determine the error value between the latest standard time and the current system time; the data troubleshooting module is configured to detect and determine the timing addressing information represented by system time in the storage allocation information; the data correction module is configured to determine the timing based on the error The value corrects the system time in the timing addressing information to the standard time.

在本申请的装置的任意实施例的基础上,先于所述创建执行模块5100的运行,本申请的时序数据存取装置,还包括:校验执行模块,设置为读取存储空间内各个扇区的扇区信息中携带的校验码,根据校验码对相应的扇区进行校验,当校验失败时将相应的扇区作为异常扇区,当校验成功时则作为正常扇区;正常响应模块,设置为针对正常扇区,检测该正常扇区的扇区信息中的时序范围信息及其中最新存储区块的时序寻址信息是否正确,当不正确时,根据所述最新存储区块中实际存储的数据单元的时序修正所述时序寻址信息和所述时序范围信息;异常响应模块,设置为针对异常扇区,对其进行初始化处理,使其扇区信息恢复默认的初始化信息。Based on any embodiment of the device of the present application, prior to the operation of the creation execution module 5100, the sequential data access device of the present application further includes: a verification execution module configured to read each sector in the storage space. The check code carried in the sector information of the area is checked according to the check code. When the check fails, the corresponding sector is regarded as an abnormal sector. When the check succeeds, the corresponding sector is regarded as a normal sector. ; The normal response module is configured to detect whether the timing range information in the sector information of the normal sector and the timing addressing information of the latest storage block in the normal sector are correct. When it is incorrect, according to the latest storage The timing of the data unit actually stored in the block corrects the timing addressing information and the timing range information; the exception response module is configured to initialize the abnormal sector so that its sector information returns to the default initialization information.

在本申请的装置的任意实施例的基础上,所述数据存取模块5400,包括:存储响应模块,设置为响应数据存储指令,将物联网设备所采集的待存储时序数据作为目标时序数据;存储定位模块,设置为根据所述存储分配信息确定最新存储区块中的首个空余存储位置,作为目标时序数据相对应的起始时序位置;存储执行模块,设置为基于所述起始时序位置开始有序存储所述目标时序数据的各个数据单元;区块切换模块,设置为在存储所述目标时序数据的各个数据单元的过程中,检测正在存储的存储区块的存储位置是否已满,当已满时,新建存储区块以继续存储所述目标时序数据的数据单元,根据已满的存储区块实际存储的数据单元更新已满的存储区块的时序寻址信息。Based on any embodiment of the device of the present application, the data access module 5400 includes: a storage response module configured to respond to data storage instructions and use the time series data to be stored collected by the Internet of Things device as the target time series data; The storage positioning module is configured to determine the first free storage location in the latest storage block according to the storage allocation information as the starting timing position corresponding to the target timing data; the storage execution module is configured to determine the starting timing position based on the starting timing position Begin to store each data unit of the target time series data in an orderly manner; the block switching module is configured to detect whether the storage location of the storage block being stored is full during the process of storing each data unit of the target time series data, When it is full, a new storage block is created to continue to store the data units of the target timing data, and the timing addressing information of the full storage block is updated according to the data units actually stored in the full storage block.

在本申请的装置的任意实施例的基础上,本申请的时序数据存取装置,还包括:响应获取模块,设置为响应数据存储指令,获取物联网设备所采集的待存储时序数据作为目标时序数据,并获取物联网设备的设备状态标识;目标确定模块,设置为根据所述存储分配信息确定出用于开始存储该目标时序数据相对应的目标存储区块;状态校验模块,设置为校验该设备状态标识与所述目标存储区块的区块信息中的设备状态标识是否一致,当不一致时,新建下一存储区块用于存储该目标时序数据,向该下一存储区块的区块信息中写入该设备状态标识。Based on any embodiment of the device of the present application, the time series data access device of the present application also includes: a response acquisition module configured to respond to the data storage instruction and obtain the time series data to be stored collected by the Internet of Things device as the target time series data, and obtain the device status identification of the Internet of Things device; the target determination module is configured to determine the target storage block corresponding to the target timing data for starting to store according to the storage allocation information; the status verification module is configured to verify Verify whether the device status identifier is consistent with the device status identifier in the block information of the target storage block. If they are inconsistent, create a new storage block to store the target timing data, and send the next storage block to the next storage block. The device status identifier is written in the block information.

在本申请的装置的任意实施例的基础上,所述数据存取模块5400,包括:读取响应模块,设置为响应数据读取指令,确定物联网设备所指定的寻址定位信息,所述寻址定位信息包括开始时间戳和结束时间戳;位置确定模块,设置为根据存储空间的存储分配信息进行寻址,确定所述开始时间戳和结束时间戳相对应的开始时序位置和结束时序位置;数据调用模块,设置为从所述开始时序位置开始读取数据单元,直到所述结束时序位置相应的数据单元为止,构成所述目标时序数据返回给所述物联网设备调用。Based on any embodiment of the device of the present application, the data access module 5400 includes: a read response module configured to respond to the data read instruction and determine the addressing and positioning information specified by the Internet of Things device. The addressing and positioning information includes a start timestamp and an end timestamp; the position determination module is configured to perform addressing according to the storage allocation information of the storage space, and determine the start timing position and the end timing position corresponding to the start timestamp and the end timestamp. ; The data calling module is configured to read the data unit starting from the starting timing position until the data unit corresponding to the ending timing position, forming the target timing data and returning it to the Internet of Things device for calling.

在本申请任意实施例的基础上,请参阅图4,本申请的另一实施例还提供一种计算机设备,该计算机设备可以充当物联网设备使用,如图4所示,计算机设备的内部结构示意图。该计算机设备包括通过系统总线连接的处理器、存储介质、存储器、网络接口以及传感器,处理器为中央处理器,该存储介质可以是闪存介质之类的非易失性计算机可读存储介质,该存储器可以是相对于存储介质具有更高存取速度的内存部件。其中,该计算机设备的存储介质存储有操作系统、数据库和封装计算机可读指令的计算机程序,数据库中可存储有控件信息序列,该计算机可读指令被处理器执行时,可使得处理器实现一种时序数据存取方法。存储介质可以有多个,以便分别存储不同类型的数据,例如可以采用闪存介质作为专门的存储介质用于存储本申请的时序数据。该计算机设备的处理器用于提供计算和控制能力,支撑整个计算机设备的运行。该计算机设备的存储器中存储有计算机可读指令,这些计算机可读指令可以是从存储介质中加载的,该计算机可读指令被处理器执行时,可使得处理器执行本申请的时序数据存取方法。该计算机设备的网络接口用于与终端连接通信。该计算机设备的传感器可以按照时序连续采集环境数据,将每个时序的环境数据作为数据单元,由各个数据单元构成时序数据,存储到存储介质中。该传感器可以是温度传感器、加速度传感器等任意传感器。本领域技术人员可以理解,图4中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Based on any embodiment of the present application, please refer to Figure 4. Another embodiment of the present application also provides a computer device, which can be used as an Internet of Things device. As shown in Figure 4, the internal structure of the computer device Schematic diagram. The computer device includes a processor, a storage medium, a memory, a network interface and a sensor connected through a system bus. The processor is a central processing unit. The storage medium can be a non-volatile computer-readable storage medium such as a flash memory medium. The memory may be a memory component with higher access speed relative to the storage medium. Among them, the storage medium of the computer device stores an operating system, a database and a computer program encapsulating computer-readable instructions. The database can store a sequence of control information. When the computer-readable instructions are executed by the processor, the processor can implement a A time series data access method. There can be multiple storage media to store different types of data respectively. For example, a flash memory medium can be used as a special storage medium to store the time series data of this application. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. Computer readable instructions are stored in the memory of the computer device. These computer readable instructions can be loaded from the storage medium. When the computer readable instructions are executed by the processor, they can cause the processor to perform the sequential data access of the present application. method. The network interface of the computer device is used for communication with the terminal connection. The sensors of the computer equipment can continuously collect environmental data in time series, and use the environmental data of each time series as a data unit. Each data unit constitutes time series data and stores it in a storage medium. The sensor can be any sensor such as a temperature sensor or an acceleration sensor. Those skilled in the art can understand that the structure shown in Figure 4 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. Specific computer equipment can May include more or fewer parts than shown, or combine certain parts, or have a different arrangement of parts.

本实施方式中处理器用于执行图6中的各个模块及其子模块的具体功能,存储器存储有执行上述模块或子模块所需的程序代码和各类数据。网络接口用于向用户终端或服务器之间的数据传输。本实施方式中的存储器存储有本申请的时序数据存取装置中执行所有模块/子模块所需的程序代码及数据,服务器能够调用服务器的程序代码及数据执行所有子模块的功能。In this embodiment, the processor is used to execute the specific functions of each module and its submodule in Figure 6, and the memory stores the program code and various data required to execute the above modules or submodules. The network interface is used to transmit data between user terminals or servers. The memory in this embodiment stores the program code and data required to execute all modules/submodules in the timing data access device of this application, and the server can call the program code and data of the server to execute the functions of all submodules.

本申请还提供一种非易失性计算机可读存储介质,其存储有封装了计算机可读指令的计算机程序,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行本申请任一实施例所述时序数据存取方法的步骤。This application also provides a non-volatile computer-readable storage medium, which stores a computer program encapsulating computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors Execute the steps of the sequential data access method described in any embodiment of this application.

本申请还提供一种计算机程序产品,包括计算机程序/指令,该计算机程序/指令被一个或多个处理器执行时实现本申请任一实施例所述时序数据存取方法的步骤。The present application also provides a computer program product, which includes a computer program/instruction. When the computer program/instruction is executed by one or more processors, the steps of the sequential data access method described in any embodiment of the present application are implemented.

本领域普通技术人员可以理解实现本申请上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,该计算机程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,前述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)、闪存等计算机可读存储介质,或随机存储记忆体(Random Access Memory,RAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments of the present application can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage. In the medium, when the program is executed, it may include the processes of the above method embodiments. Among them, the aforementioned storage media can be computer-readable storage media such as magnetic disks, optical disks, read-only memory (Read-Only Memory, ROM), flash memory, or random access memory (Random Access Memory, RAM), etc.

以上所述仅是本申请的部分实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above are only some of the embodiments of the present application. It should be pointed out that those of ordinary skill in the technical field can also make several improvements and modifications without departing from the principles of the present application. These improvements and modifications can also be made. should be regarded as the scope of protection of this application.

综上所述,本申请采用单个存储区块用于存储多个数据单元,将数据单元的时序表示在存储区块相对应的时序寻址信息中,可以大幅提升存储空间的存储效率,从而提升使用这种技术的物联网设备的信息容量,由此也可降低物联网设备的硬件成本。To sum up, this application uses a single storage block to store multiple data units, and expresses the timing of the data units in the timing addressing information corresponding to the storage block, which can greatly improve the storage efficiency of the storage space, thereby improving The information capacity of IoT devices using this technology can also reduce the hardware cost of IoT devices.

Claims (10)

1. A method for accessing time-series data, comprising:
creating a storage block in a sector in a storage space, wherein the storage block comprises a plurality of storage positions corresponding to time sequences and is used for orderly storing data units corresponding to each time sequence in time sequence data;
updating sector information corresponding to the sector in storage allocation information of the storage space, wherein the sector information comprises time sequence range information used for representing a time sequence range formed by data units actually stored in each storage block of the sector;
Updating block information corresponding to the storage block in storage allocation information of the storage space, wherein the block information comprises time sequence addressing information used for representing the time sequence of a data unit actually stored in the storage block;
and determining a starting time sequence position corresponding to the access target time sequence data based on the storage allocation information, and starting to access each data unit of the target time sequence data from the starting time sequence position.
2. The method of claim 1, further comprising:
the continuous synchronization standard time is used for determining the time sequence of the data unit;
when the standard time is successful, the standard time is used for updating the time sequence addressing information of the storage block where the data unit in the target time sequence data is located;
when the synchronous standard time fails, a new storage block is created for storing the data unit of the target time sequence data, and the system time is used for updating the time sequence addressing information of the storage block.
3. The method of claim 2, wherein when the synchronization standard time fails, creating a memory block for storing the data unit of the target time sequence data, and using the system time for updating the time sequence address information of the memory block, comprises:
When synchronizing to the latest standard time, determining an error value between the latest standard time and the current system time;
detecting and determining time sequence addressing information expressed by system time in the storage allocation information;
and correcting the system time in the time sequence addressing information to be standard time according to the error value.
4. The method of claim 1, wherein prior to creating the memory blocks in the sectors in the memory space, comprising:
reading check codes carried in sector information of each sector in the storage space, checking the corresponding sector according to the check codes, wherein the corresponding sector is used as an abnormal sector when the check fails, and is used as a normal sector when the check succeeds;
for a normal sector, detecting whether the time sequence range information in the sector information of the normal sector and the time sequence addressing information of the latest storage block are correct or not, and when the time sequence addressing information and the time sequence range information are incorrect, correcting the time sequence addressing information and the time sequence range information according to the time sequence of a data unit actually stored in the latest storage block;
and initializing the abnormal sector to restore the sector information to default initialization information.
5. The method according to any one of claims 1 to 4, wherein determining a start timing position corresponding to access to target timing data based on the memory allocation information, starting from the start timing position to access each data unit of the target timing data, comprises:
responding to the data storage instruction, and taking the time sequence data to be stored, which is acquired by the Internet of things equipment, as target time sequence data;
determining a first vacant storage position in the latest storage block according to the storage allocation information, and taking the first vacant storage position as a starting time sequence position corresponding to the target time sequence data;
starting to orderly store each data unit of the target time sequence data based on the starting time sequence position;
and in the process of storing each data unit of the target time sequence data, detecting whether the storage position of the storage block being stored is full, when the storage position is full, creating a new storage block to continuously store the data unit of the target time sequence data, and updating the time sequence addressing information of the full storage block according to the data unit actually stored by the full storage block.
6. The method for accessing time-series data according to any one of claims 1 to 4, further comprising:
Responding to the data storage instruction, acquiring time sequence data to be stored, which is acquired by the Internet of things equipment, as target time sequence data, and acquiring equipment state identification of the Internet of things equipment;
determining a target storage block corresponding to the target time sequence data to start to be stored according to the storage allocation information;
checking whether the equipment state identifier is consistent with the equipment state identifier in the block information of the target storage block, and when the equipment state identifier is inconsistent with the equipment state identifier, creating a next storage block for storing the target time sequence data, and writing the equipment state identifier into the block information of the next storage block.
7. The method according to any one of claims 1 to 4, wherein determining a start timing position corresponding to access to target timing data based on the memory allocation information, starting from the start timing position to access each data unit of the target timing data, comprises:
responding to a data reading instruction, and determining addressing positioning information appointed by the Internet of things equipment, wherein the addressing positioning information comprises a start time stamp and an end time stamp;
addressing according to storage allocation information of the storage space, and determining a start time sequence position and an end time sequence position corresponding to the start time stamp and the end time stamp;
And starting to read the data unit from the starting time sequence position until the data unit corresponding to the ending time sequence position, and returning the target time sequence data to the Internet of things equipment for calling.
8. A time series data access device, comprising:
the system comprises a creation execution module, a storage module and a storage module, wherein the creation execution module is used for creating a storage block in a sector in a storage space, and the storage block comprises a plurality of storage positions corresponding to time sequences and is used for orderly storing data units corresponding to each time sequence in time sequence data;
the sector updating module is used for updating sector information corresponding to the sector in the storage allocation information of the storage space, wherein the sector information comprises time sequence range information which is used for representing the time sequence range formed by data units actually stored in each storage block of the sector;
the block updating module is configured to update block information corresponding to the storage block in storage allocation information of the storage space, wherein the block information comprises time sequence addressing information used for representing time sequence of a data unit actually stored in the storage block;
and the data access module is used for determining a starting time sequence position corresponding to the access target time sequence data based on the storage allocation information, and accessing each data unit of the target time sequence data from the starting time sequence position.
9. An internet of things device comprising a control unit and a flash memory medium, the control unit comprising a central processor and a memory, characterized in that the memory stores computer readable instructions, the central processor invoking the computer readable instructions from the memory to perform the steps in the time sequential data access method according to any of claims 1 to 7 to determine memory allocation information of a memory space provided by the memory medium to access time sequential data to the memory space according to the memory allocation information.
10. A non-transitory computer readable storage medium, characterized in that it stores a computer program in the form of computer readable instructions, which when invoked by a computer to run, performs the steps of the method according to any one of claims 1 to 7.
CN202410217257.6A 2024-02-28 2024-02-28 Internet of things device and time series data access method thereof and corresponding device and medium Active CN117785073B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410217257.6A CN117785073B (en) 2024-02-28 2024-02-28 Internet of things device and time series data access method thereof and corresponding device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410217257.6A CN117785073B (en) 2024-02-28 2024-02-28 Internet of things device and time series data access method thereof and corresponding device and medium

Publications (2)

Publication Number Publication Date
CN117785073A true CN117785073A (en) 2024-03-29
CN117785073B CN117785073B (en) 2024-06-21

Family

ID=90383786

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410217257.6A Active CN117785073B (en) 2024-02-28 2024-02-28 Internet of things device and time series data access method thereof and corresponding device and medium

Country Status (1)

Country Link
CN (1) CN117785073B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119513935A (en) * 2024-11-05 2025-02-25 北京长擎软件有限公司 Data change method, device, computer equipment, medium and program product

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050209991A1 (en) * 2004-03-22 2005-09-22 Microsoft Corporation Computing device with relatively limited storage space and operating / file system thereof
US20110040931A1 (en) * 2008-02-20 2011-02-17 Koji Shima Memory control method and device, memory access control method, computer program, and recording medium
CN102081575A (en) * 2011-01-27 2011-06-01 北京深思洛克软件技术股份有限公司 Dynamic distribution method and device of memory space of virtual disc
US9110785B1 (en) * 2011-05-12 2015-08-18 Densbits Technologies Ltd. Ordered merge of data sectors that belong to memory space portions
CN109947369A (en) * 2019-03-22 2019-06-28 河南卓正电子科技有限公司 Date storage method and device
CN112506918A (en) * 2020-11-03 2021-03-16 深圳市宏电技术股份有限公司 Data access method, terminal and computer readable storage medium
CN113297278A (en) * 2021-07-26 2021-08-24 阿里云计算有限公司 Time sequence database, data processing method, storage device and computer program product
CN113947498A (en) * 2021-09-15 2022-01-18 中国电力科学研究院有限公司 A data storage and retrieval method for integrated terminal data center
CN114116643A (en) * 2021-11-19 2022-03-01 宁波水表(集团)股份有限公司 A log processing method, device and storage medium for embedded system
CN114328280A (en) * 2021-11-26 2022-04-12 金卡智能集团股份有限公司 A Flash-based log access method, device, storage medium and terminal
CN114615306A (en) * 2022-05-10 2022-06-10 中南林业科技大学 Efficient file system of sink node in Internet of things and processing method thereof
CN117075801A (en) * 2023-08-04 2023-11-17 中汽创智科技有限公司 Data storage management method, device and equipment

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050209991A1 (en) * 2004-03-22 2005-09-22 Microsoft Corporation Computing device with relatively limited storage space and operating / file system thereof
US20110040931A1 (en) * 2008-02-20 2011-02-17 Koji Shima Memory control method and device, memory access control method, computer program, and recording medium
CN102081575A (en) * 2011-01-27 2011-06-01 北京深思洛克软件技术股份有限公司 Dynamic distribution method and device of memory space of virtual disc
US9110785B1 (en) * 2011-05-12 2015-08-18 Densbits Technologies Ltd. Ordered merge of data sectors that belong to memory space portions
CN109947369A (en) * 2019-03-22 2019-06-28 河南卓正电子科技有限公司 Date storage method and device
CN112506918A (en) * 2020-11-03 2021-03-16 深圳市宏电技术股份有限公司 Data access method, terminal and computer readable storage medium
CN113297278A (en) * 2021-07-26 2021-08-24 阿里云计算有限公司 Time sequence database, data processing method, storage device and computer program product
CN113947498A (en) * 2021-09-15 2022-01-18 中国电力科学研究院有限公司 A data storage and retrieval method for integrated terminal data center
CN114116643A (en) * 2021-11-19 2022-03-01 宁波水表(集团)股份有限公司 A log processing method, device and storage medium for embedded system
CN114328280A (en) * 2021-11-26 2022-04-12 金卡智能集团股份有限公司 A Flash-based log access method, device, storage medium and terminal
CN114615306A (en) * 2022-05-10 2022-06-10 中南林业科技大学 Efficient file system of sink node in Internet of things and processing method thereof
CN117075801A (en) * 2023-08-04 2023-11-17 中汽创智科技有限公司 Data storage management method, device and equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119513935A (en) * 2024-11-05 2025-02-25 北京长擎软件有限公司 Data change method, device, computer equipment, medium and program product

Also Published As

Publication number Publication date
CN117785073B (en) 2024-06-21

Similar Documents

Publication Publication Date Title
CN110535969B (en) Data storage method, device, storage medium and device based on blockchain network
CN109189756A (en) Electronic device, the method for Data Migration and storage medium
CN117785073B (en) Internet of things device and time series data access method thereof and corresponding device and medium
CN111782134B (en) Data processing method, device, system and computer readable storage medium
US20240106668A1 (en) Proof-of-work operation method, proof-of-work chip, and upper computer
CN113553373A (en) Data synchronization method and device, storage medium and electronic equipment
CN110286859B (en) Data storage method and device based on FAT file system
CN111680019A (en) Data capacity expansion method and device for block chain
WO2025001042A1 (en) Asset information reporting method and apparatus, and non-volatile readable storage medium and electronic device
CN112214384A (en) Hard disk serial number management method, system, terminal and storage medium
CN109710698A (en) A kind of data assemblage method, device, electronic equipment and medium
CN112558868A (en) Method, device and equipment for storing configuration data
CN111522827B (en) Data updating method and device and electronic equipment
CN113419897A (en) File processing method and device, electronic equipment and storage medium thereof
CN111078790B (en) Method and system for synchronizing isolated block data in block chain and storage medium
CN114491145B (en) Metadata design method based on stream storage
CN115712683A (en) Database synchronization method and device, computer equipment and storage medium
CN114490196A (en) Database switching method, system, device and medium
CN119311640B (en) Snapshot data processing method, device, electronic device and storage medium
CN119311695B (en) Verification method, device, computer equipment, and readable storage medium for incremental synchronization
CN110674214A (en) Big data synchronization method and device, computer equipment and storage medium
CN114327289B (en) Data synchronization method and device and electronic equipment
CN113392071B (en) File acquisition processing method, device and equipment of file acquisition device
CN111694887B (en) Data adaptive storage scheduling system and method
CN119248581A (en) Time series data master-slave synchronization method, system, computer device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 518057 3301, Building C, Lot 1, Chuangzhi Yuncheng, Liuxian Avenue, Xili Community, Xili Street, Nanshan District, Shenzhen, Guangdong

Patentee after: Shenzhen Zhiyan Technology Co.,Ltd.

Country or region after: China

Patentee after: Shenzhen Qianyan Technology Co.,Ltd.

Address before: 518057 3301, Building C, Lot 1, Chuangzhi Yuncheng, Liuxian Avenue, Xili Community, Xili Street, Nanshan District, Shenzhen, Guangdong

Patentee before: SHENZHEN ZHIYAN TECHNOLOGY Co.,Ltd.

Country or region before: China

Patentee before: Shenzhen Qianyan Technology Co.,Ltd.