WO2020041928A1 - Data storage method and system and terminal device - Google Patents

Data storage method and system and terminal device Download PDF

Info

Publication number
WO2020041928A1
WO2020041928A1 PCT/CN2018/102490 CN2018102490W WO2020041928A1 WO 2020041928 A1 WO2020041928 A1 WO 2020041928A1 CN 2018102490 W CN2018102490 W CN 2018102490W WO 2020041928 A1 WO2020041928 A1 WO 2020041928A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
data block
block
file
index table
Prior art date
Application number
PCT/CN2018/102490
Other languages
French (fr)
Chinese (zh)
Inventor
王斌
刘文涛
归建章
苏晓天
Original Assignee
深圳市锐明技术股份有限公司
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 深圳市锐明技术股份有限公司 filed Critical 深圳市锐明技术股份有限公司
Priority to CN201880001157.2A priority Critical patent/CN110149803B/en
Priority to PCT/CN2018/102490 priority patent/WO2020041928A1/en
Publication of WO2020041928A1 publication Critical patent/WO2020041928A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application belongs to the field of computer technology, and particularly relates to a data storage method, system, and terminal device.
  • the data of one channel is usually used as a file. Since all channels will generate data at the same time, multiple files will be written to the SMR disk at the same time. This will increase the write position and cause the write speed to decrease.
  • embodiments of the present application provide a data storage method, system, and terminal device to solve the problem that the writing speed decreases when multi-channel data is written to an SMR disk in the prior art.
  • the data block index table includes multiple data block index nodes
  • the in-block index table in the cache is written to the tail of the free data block, and the step of finding the free data block according to the data block index table is continued.
  • a second aspect of the embodiments of the present application provides a data storage system, including:
  • the idle data block search module is used to read the data block index table, find the free data block according to the data block index table, and update the data block index node corresponding to the idle data block.
  • the data block index table includes multiple data block index nodes;
  • a cache allocation module configured to allocate a cache for an in-block index table in an idle data block
  • Cyclic reading module which is used to read the data in the data buffer area of each channel cyclically;
  • a data writing module is configured to read data of a preset time length in the data buffer area of the target channel if the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, and set the preset time The length of data is written into the free data block, and the data block index node corresponding to the free data block and the in-block index table in the cache are updated, and the target channel is any one of all channels;
  • a third aspect of the embodiments of the present application provides a terminal device including a memory, a processor, and a computer program stored in the memory and executable on the processor.
  • the processor executes the computer program, the data storage method described above is implemented. step.
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program is executed by one or more processors, the steps of the data storage method described above are implemented.
  • the embodiment of the present application first reads a data block index table, searches for a free data block according to the data block index table, and updates a data block index node corresponding to the idle data block, allocates a buffer for the in-block index table in the free data block, and then reads the data circularly Take the data in the data buffer area of each channel. If the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, then read the data of the preset time length in the data buffer area of the target channel.
  • the target channel is any one of all channels, and finally if the free data block is written When it is full, the in-block index table in the cache is written to the end of the free data block, and the steps of finding the free data block according to the data block index table are continued.
  • the data in the data buffer area of each channel is read cyclically, and it is determined whether the time length of the data in the data buffer area of each channel is greater than or equal to the preset time length. If so, the preset time is set.
  • the length of data is written into the free data block, which can combine multi-channel data into one channel of data for write operations, reducing the write position and improving the disk write speed; it also uses the data block index table and the in-block index table in the data block Build a two-level index to speed up retrieval and reading.
  • FIG. 1 is a schematic flowchart of a data storage method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a data block index table provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of an intra-block index table in a data block provided by an embodiment of the present application.
  • FIG. 6 is a schematic block diagram of a data storage system according to an embodiment of the present application.
  • FIG. 7 is a schematic block diagram of a terminal device according to an embodiment of the present application.
  • FIG. 1 is a schematic diagram of an implementation process of a data storage method provided by an embodiment of the present application. For ease of description, only parts related to the embodiment of the present application are shown.
  • the execution subject in this embodiment of the present application may be a terminal device. As shown in Figure 1, the method may include the following steps:
  • Step S101 Read a data block index table, find a free data block according to the data block index table, and update a data block index node corresponding to the idle data block.
  • the data block index table includes a plurality of data block index nodes.
  • the storage space of the SMR disk is divided into a plurality of data blocks according to a preset size, and each data block may be numbered, and the numbering may start from 0 and increase sequentially.
  • the preset size can be 256 megabytes (MByte, MB).
  • MB megabytes
  • a 4T hard disk can be divided into 256MB to obtain 16,384 data blocks.
  • the 16384 data blocks are numbered in sequence, with numbers ranging from 0 to 16383.
  • owner_stamp is a file ownership stamp, which can also be referred to as a file identifier.
  • Different files have different file ownership stamps. You can use the file ownership stamp to find out which data blocks are stored in the same file.
  • the files in the embodiments of the present application are files with time attributes, such as video files, audio files, and so on. Because the monitoring channels are multiple channels, all channels will generate data at the same time. A file is made up of data from all channels that are continuous in time.
  • inner_num is the internal number of the file, which is used to indicate the order in which the files are stored.
  • the internal number of the same file can be a continuous natural number starting from 1.
  • a file is often stored in multiple data blocks. Assuming a file is stored in data blocks 1, 3, and 5, the internal number of the file corresponding to data block 1 is 3, the internal number of the file corresponding to data block 2 is 2, and the data block The internal number of the file corresponding to 5 is 1. Then the order of storing the file is first stored in data block 5, after data block 5 is full, then it is stored in data block 3. After data block 3 is full, Stored in data block 1.
  • end_time is the end time of the file, indicating the end time of the file in the data block. That is, the data stored in the data block is data in the file from the file start time to the file end time.
  • chn_info is channel information, which indicates which channels of data are stored in the data block. Bits are used to indicate whether data for the corresponding channel is stored. For example, if the 0th bit is 1, it means that the data of channel 0 is stored. If the 0th bit is 0, it means that the data of channel 0 is not stored. The other channels are similar and will not be described again.
  • block_type is a data block type and is used to distinguish the type of the data block. You can use 0 to indicate free data blocks, that is, data blocks that do not store data; use 1 to indicate data blocks that store data block index tables; and use 2 to indicate data blocks that store data.
  • reserve [7] is a reserved field.
  • check_num is a check digit, which is used to determine whether the data is legal.
  • the data block index table is fixedly stored in the data block numbered 0, and only the data block index table is stored in the data block numbered 0. Therefore, the data block numbered 0 corresponds to The data block type is 1, the other data blocks are used to store the data of each channel.
  • Each data block is divided into a data area and an index area, as shown in Figure 2.
  • the data area stores data of each channel
  • the index area stores an index table in the block.
  • the index table in the block is constructed by data of a preset time length of each channel, and the preset time length can be 1 second.
  • the intra-block index table includes multiple intra-block index nodes, and each intra-block index node stores information related to one second of data.
  • the index table in the block can accurately locate the data of a certain channel for a certain second.
  • the index area (the index table in the block) is buffered into memory.
  • the in-block index table in the memory is written into the index area, which is equivalent to the write operation of the data block as a sequential write.
  • the index table in the block records the relevant information of each second of data.
  • the definition of the index node in the block is as follows:
  • chn is the channel number, which indicates that the data corresponding to the index node in the block belongs to the channel number.
  • Hour, minute, and second are hours, minutes, and seconds, respectively, indicating that the data corresponding to the i-nodes in the block are the hours, minutes, and seconds.
  • offset is the data offset, which indicates the offset of the data corresponding to the index node in the block in the data block.
  • length is the data size, which indicates the size of the data corresponding to the inodes in the block.
  • flag is the index flag. If it is 0, it means idle, if it is 1, it means occupied.
  • reserve [3] is a reserved field.
  • the 256KB index area occupies 1/1024 of the 256MB data block, which means that the space utilization rate can reach 99.9%.
  • the data block index table is first read, and the free data block is found according to the data block index table. After finding the free data block, the data block index node corresponding to the free data block is found.
  • the data block type in is updated from 0 to 2, and the file internal number is updated.
  • Step S102 Allocate a cache for the in-block index table in the free data block.
  • Step S103 The data in the data buffer area of each channel is read cyclically.
  • Each channel has a corresponding data buffer area, and the monitoring data of the corresponding channel is stored in the data buffer area.
  • Read the data in the data buffer area of each channel cyclically, and determine whether the time length of the data in the data buffer area of each channel is greater than or equal to the preset time length.
  • the data in the data buffer area of each channel is read cyclically.
  • the data in the data buffer area of channel 0 can be read first, and then read.
  • Data in the data buffer area of channel 1 then read the data in the data buffer area of channel 2, then read the data in the data buffer area of channel 3, and then read the data in the data buffer area of channel 0 again, In this way, the data in the data buffer area of each channel is read cyclically.
  • Step S104 If the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, then read the data of the preset time length in the data buffer area of the target channel and write the data of the preset time length Into the idle data block, and update the data block index node corresponding to the idle data block and the in-block index table in the cache, the target channel is any one of all channels.
  • the preset time length may be 1 second.
  • the time length of the data in the data buffer area of the target channel is greater than or equal to 1 second, then the data in the data buffer area of the target channel with a length of 1 second is read, and the 1 second is The data is written into the data area of the free data block, and the data block index node corresponding to the free data block and the in-block index table in the cache are updated.
  • Updating the intra-block index table in the cache may be to find an idle intra-block index node in the intra-block index table, that is, an intra-block index node with an index identifier of 0, and updating the idle intra-block index node according to the channel number of the target channel.
  • the data offset of the inode is updated according to the data size of the 1 second data of the inode in the idle block, and the index identifier is updated to 1.
  • Step S105 if the free data block is full, write the index table in the block in the cache to the tail of the free data block, and continue to perform the steps of finding the free data block according to the data block index table.
  • the index table in the block in the cache is written to the tail of the free data block, that is, the data of the free data block is written.
  • the index structure is small, it can complete high efficiency with less memory overhead.
  • Data retrieval and reading of specified data by writing a buffer to the in-block index table in the free data block before writing the data, while writing the data, the in-block index table in the cache is updated and the data is full Then, the in-block index table in the cache is written to the free data block, and the sequential writing of the data area and the index area in the data block is realized, reducing the writing position, further High write speed.
  • the method After updating the data block index node corresponding to the free data block and the in-block index table in the cache, the method further includes:
  • the embodiments of the present application can query the file information list that meets the requirements according to the start time, end time and channel number to be queried.
  • the in-block index node whose channel number is the channel number to be read is referred to as the target in-block index node.
  • Step S507 if there is an index node in the target block, use the index node in the target block as a new index node in the positioning block, and continue to determine the position of the data to be read according to the data offset in the index node in the positioning block. A step of.
  • Step S508 if there is no index node in the target block, then in the data block index table, find whether a file attribution stamp is the same as the file attribution corresponding to the positioning data block, and the file internal number is the internal number of the file corresponding to the positioning data block. Increment the target data block inode.
  • the file home stamp is the same as the file home stamp corresponding to the positioning data block, and the internal number of the file is the data block index node plus the internal number of the file corresponding to the positioning data block plus one as the target data block index node.
  • the intra-block index table in the new positioning data block is used as the new intra-block index table.
  • Step S510 traverse the new index table in the positioning block in the memory, determine the new index node in the positioning block where the channel number to be read is located, and continue to perform determination based on the data offset in the index node in the positioning block to be read Steps to get the location of the data.
  • the index node within the block with the same channel number as the channel number to be read is used as the new index node within the positioning block, and the new index node within the positioning block is replaced.
  • the previous index node in the positioning block returns to step S504, and the step of determining the position of the data to be read according to the data offset in the index node in the positioning block is executed cyclically.
  • the embodiment of the present application can read data after a certain time node in a channel, and first locate the data block according to the data block index table, and then accurately locate the data through the index table in the block, which can efficiently locate Required data.
  • the data block index node includes a file start time and a file end time
  • FIG. 6 is a schematic block diagram of a data storage system according to an embodiment of the present application. For convenience of explanation, only a part related to the embodiment of the present application is shown.
  • the data storage system 6 includes:
  • the idle data block search module 61 is configured to read a data block index table, find a free data block according to the data block index table, and update a data block index node corresponding to the idle data block.
  • the data block index table includes multiple data block index nodes;
  • a cache allocation module 62 configured to allocate a cache for an in-block index table in an idle data block
  • the index table writing module 65 is configured to write an in-block index table in the cache to the tail of the free data block if the free data block is full, and continue to perform the steps of finding the free data block according to the data block index table.
  • the idle data block search module 61 is further configured to cache the data block index table into memory;
  • the idle data block search module 61 further includes:
  • the file ownership stamp obtaining unit is used to traverse the data block index table in the memory to obtain the largest file ownership stamp, and determine the file ownership stamp of the file to be stored according to the largest file ownership stamp;
  • a judging module configured to continue to judge whether the time length of the data in the data buffer area of the next channel is greater than or equal to the preset time length if the time length of the data in the data buffer area of the target channel is less than the preset time length;
  • the first loop module is configured to, if the free data block is not full, continue to perform the step of cyclically reading data in the data buffer area of each channel.
  • the data block index node includes a file belonging stamp
  • the information to be queried includes a start time to be queried, an end time to be queried, and a channel number to be queried
  • the file description information includes a file belonging stamp, a file start time, a file end time, and channel information contained in the file
  • the query result acquisition module is specifically configured to determine a list of file information corresponding to the start time, the end time of the query, and the channel number to be queried according to the file start time, the file end time, and the channel information contained in the file.
  • the data storage system 6 further includes:
  • a positioning data block determination module which is used to traverse a data block index table to obtain a positioning data block to which a positioning time belongs;
  • the index table reading module is used to read the index table in the positioning block in the positioning data block, and cache the index table in the positioning block into memory;
  • the index node search module is used to find whether there is a target in-block index node containing the channel number to be read in the in-block index node after the in-block index node in the index table in the positioning block;
  • a first processing module configured to use the index node in the target block as a new index node in the positioning block if the index node in the target block exists, and continue to execute the determination of the to-be-read based on the data offset in the index node in the positioning block; Steps to get the location of the data;
  • the second processing module is configured to find, in the data block index table, if there is no inode in the target block, the file attribution stamp is the same as the file attribution corresponding to the positioning data block, and the internal number of the file corresponds to the positioning data block The internal number of the file plus the target data block index node;
  • a third processing module configured to: if a target data block index node exists, use the data block corresponding to the target data block index node as a new positioning data block, and read a new index table within the positioning block in the new positioning data block; And cache the index table in the new positioning block into memory;
  • the second loop module is used to traverse the new index table in the positioning block in memory, determine the index node in the positioning block where the channel number to be read is located, and continue to execute the determination based on the data offset in the index node in the positioning block. Steps for the location of the data to be read;
  • a fourth processing module is configured to: if the target data block index node does not exist, the data reading ends.
  • the data block index node includes a file start time and a file end time
  • the positioning data block determination module is specifically used to traverse the data block index table and obtain the positioning data block to which the positioning time belongs according to the file start time and the file end time.
  • FIG. 7 is a schematic block diagram of a terminal device according to an embodiment of the present application.
  • the terminal device 7 of this embodiment includes one or more processors 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70.
  • the processor 70 executes the computer program 72
  • the steps in the foregoing data storage method embodiments are implemented, for example, steps S101 to S105 shown in FIG.
  • the processor 70 executes the computer program 72
  • the functions of the modules / units in the foregoing embodiment of the data storage system are implemented, for example, the functions of modules 61 to 65 shown in FIG. 6.
  • a cache allocation module configured to allocate a cache for an in-block index table in an idle data block
  • a data writing module is configured to read data of a preset time length in the data buffer area of the target channel if the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, and set the preset time The length of data is written into the free data block, and the data block index node corresponding to the free data block and the in-block index table in the cache are updated, and the target channel is any one of all channels;
  • the terminal device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the terminal device 7 includes, but is not limited to, a processor 70 and a memory 71.
  • FIG. 7 is only an example of the terminal device, and does not constitute a limitation on the terminal device 7. It may include more or fewer components than shown in the figure, or combine some components or different components.
  • the terminal device 7 may further include an input device, an output device, a network access device, a bus, and the like.
  • the processor 70 may be a central processing unit (Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), and application-specific integrated circuits (Applications) Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • CPU Central Processing Unit
  • DSP digital signal processor
  • ASIC Application-specific integrated circuits
  • ASIC Applications Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the memory 71 may be an internal storage unit of the terminal device, such as a hard disk or a memory of the terminal device.
  • the memory 71 may also be an external storage device of the terminal device, for example, a plug-in hard disk, a smart memory card (Smart Media) Card, SMC), Secure Digital (SD) card, Flash Card, etc. Further, the memory 71 may further include both an internal storage unit of the terminal device and an external storage device.
  • the memory 71 is configured to store the computer program 72 and other programs and data required by the terminal device.
  • the memory 71 may also be used to temporarily store data that has been output or is to be output.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objective of the solution of this embodiment.
  • the integrated module / unit When the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this application implements all or part of the processes in the method of the above embodiment, and can also be completed by a computer program instructing related hardware.
  • the computer program can be stored in a computer-readable storage medium.
  • the computer When the program is executed by a processor, the steps of the foregoing method embodiments can be implemented.
  • the computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file, or some intermediate form.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application is applicable to the technical field of computers, and discloses a data storage method and system and a terminal device. The method comprises: reading a data block index table, searching for an idle data block according to the data block index table, and updating a data block index node corresponding to the idle data block; allocating a buffer for an in-block index table in idle data block; cyclically reading data in a data buffer of each channel; if a time length of data in a data buffer of a target channel is greater than or equal to a preset time length, reading data of the preset time length in the data buffer of the target channel, writing the data of the preset time length to the idle data block, and updating the data block index node corresponding to the idle data block and the in-block index table in the buffer; and if the idle data block is full, writing the in-block index table in the buffer to an end of the idle data block, and continuing performing the step of searching for an idle data block according to the data block index table. The present application reduces the number of writing positions, and improves a writing speed of a disc.

Description

数据存储方法、系统及终端设备Data storage method, system and terminal equipment 技术领域Technical field
本申请属于计算机技术领域,尤其涉及一种数据存储方法、系统及终端设备。The present application belongs to the field of computer technology, and particularly relates to a data storage method, system, and terminal device.
背景技术Background technique
随着监控数据的高清化及监控通道数的增多,监控需要存储的数据量也越来越大。硬盘作为一种经济高效的存储介质,广泛应用到了各行各业,但磁盘密度受到物理定律的限制,目前硬盘使用的垂直磁记录技术即将达到极限,由此叠瓦式磁记录 (Shingled Magnetic Recording,SMR) 盘应运而生。对于SMR盘,通常会设置一个写速度比较高的缓存,数据先写入缓存,等到SMR盘空闲时,再将数据从缓存写入叠瓦式磁道,这样可以提高写入效率。但是,由于缓存空间有限,当写入位置过多时,缓存空间不足,导致写入速度会大大降低。With the high-definition monitoring data and the increase in the number of monitoring channels, the amount of data that needs to be stored for monitoring is also increasing. Hard disk as a cost-effective storage medium is widely used in various industries, but the disk density is limited by the laws of physics. At present, the perpendicular magnetic recording technology used by hard disks is about to reach its limit. Therefore, shingled magnetic recording (Shingled Magnetic Recording, SMR) disk came into being. For SMR disks, a cache with a relatively high write speed is usually set. Data is written to the cache first. When the SMR disk is idle, data is written from the cache to the shingled track, which can improve the writing efficiency. However, due to the limited cache space, when there are too many write locations, the cache space is insufficient, resulting in a significant reduction in write speed.
目前,通常将一个通道的数据作为一个文件,由于所有通道都会同时产生数据,所以会有多个文件同时写入SMR盘,这样会增加写位置,导致写速度下降。At present, the data of one channel is usually used as a file. Since all channels will generate data at the same time, multiple files will be written to the SMR disk at the same time. This will increase the write position and cause the write speed to decrease.
技术问题technical problem
有鉴于此,本申请实施例提供了一种数据存储方法、系统及终端设备,以解决现有技术中对于多通道的数据写入SMR盘时,写速度下降的问题。In view of this, embodiments of the present application provide a data storage method, system, and terminal device to solve the problem that the writing speed decreases when multi-channel data is written to an SMR disk in the prior art.
技术解决方案Technical solutions
本申请实施例的第一方面提供了一种数据存储方法,包括:A first aspect of the embodiments of the present application provides a data storage method, including:
读取数据块索引表,根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,数据块索引表包括多个数据块索引节点;Read the data block index table, find the free data block according to the data block index table, and update the data block index node corresponding to the idle data block. The data block index table includes multiple data block index nodes;
为空闲数据块中的块内索引表分配缓存;Allocate a cache for the in-block index table in the free data block;
循环读取每个通道的数据缓存区中的数据;Read the data in the data buffer area of each channel cyclically;
若目标通道的数据缓存区中的数据的时间长度大于或等于预设时间长度,则读取目标通道的数据缓存区中的预设时间长度的数据,将预设时间长度的数据写入空闲数据块,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表,目标通道为所有通道中的任一个;If the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, then read the data of the preset time length in the data buffer area of the target channel and write the data of the preset time length to the idle data Block, and update the data block index node corresponding to the idle data block and the in-block index table in the cache, and the target channel is any one of all channels;
若空闲数据块写满,则将缓存中的块内索引表写入空闲数据块的尾部,并继续执行根据数据块索引表查找空闲数据块的步骤。If the free data block is full, the in-block index table in the cache is written to the tail of the free data block, and the step of finding the free data block according to the data block index table is continued.
本申请实施例的第二方面提供了一种数据存储系统,包括:A second aspect of the embodiments of the present application provides a data storage system, including:
空闲数据块查找模块,用于读取数据块索引表,根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,数据块索引表包括多个数据块索引节点;The idle data block search module is used to read the data block index table, find the free data block according to the data block index table, and update the data block index node corresponding to the idle data block. The data block index table includes multiple data block index nodes;
缓存分配模块,用于为空闲数据块中的块内索引表分配缓存;A cache allocation module, configured to allocate a cache for an in-block index table in an idle data block;
循环读取模块,用于循环读取每个通道的数据缓存区中的数据;Cyclic reading module, which is used to read the data in the data buffer area of each channel cyclically;
数据写入模块,用于若目标通道的数据缓存区中的数据的时间长度大于或等于预设时间长度,则读取目标通道的数据缓存区中的预设时间长度的数据,将预设时间长度的数据写入空闲数据块,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表,目标通道为所有通道中的任一个;A data writing module is configured to read data of a preset time length in the data buffer area of the target channel if the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, and set the preset time The length of data is written into the free data block, and the data block index node corresponding to the free data block and the in-block index table in the cache are updated, and the target channel is any one of all channels;
索引表写入模块,用于若空闲数据块写满,则将缓存中的块内索引表写入空闲数据块的尾部,并继续执行根据数据块索引表查找空闲数据块的步骤。The index table writing module is configured to write the index table in the block in the cache to the end of the free data block if the free data block is full, and continue to perform the steps of finding the free data block according to the data block index table.
本申请实施例的第三方面提供了一种终端设备,包括存储器、处理器以及存储在存储器中并可在处理器上运行的计算机程序,处理器执行计算机程序时实现如上所述数据存储方法的步骤。A third aspect of the embodiments of the present application provides a terminal device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the data storage method described above is implemented. step.
本申请实施例的第四方面提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被一个或多个处理器执行时实现如上所述数据存储方法的步骤。A fourth aspect of the embodiments of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by one or more processors, the steps of the data storage method described above are implemented.
有益效果Beneficial effect
本申请实施例首先读取数据块索引表,根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,为空闲数据块中的块内索引表分配缓存,然后循环读取每个通道的数据缓存区中的数据,若目标通道的数据缓存区中的数据的时间长度大于或等于预设时间长度,则读取目标通道的数据缓存区中的预设时间长度的数据,将预设时间长度的数据写入空闲数据块,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表,目标通道为所有通道中的任一个,最后若空闲数据块写满,则将缓存中的块内索引表写入空闲数据块的尾部,并继续执行根据数据块索引表查找空闲数据块的步骤。本申请实施例通过循环读取每个通道的数据缓存区中的数据,并判断每个通道的数据缓存区中的数据的时间长度是否大于或等于预设时间长度,若是,则将预设时间长度的数据写入空闲数据块,能够将多通道的数据合并成一路数据进行写入操作,减少写入位置,提高磁盘写入速度;还通过数据块索引表和数据块中的块内索引表构建两级索引,可以加快检索和读取速度。The embodiment of the present application first reads a data block index table, searches for a free data block according to the data block index table, and updates a data block index node corresponding to the idle data block, allocates a buffer for the in-block index table in the free data block, and then reads the data circularly Take the data in the data buffer area of each channel. If the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, then read the data of the preset time length in the data buffer area of the target channel. , Write the data of the preset time length into the free data block, and update the data block index node corresponding to the free data block and the in-block index table in the cache, the target channel is any one of all channels, and finally if the free data block is written When it is full, the in-block index table in the cache is written to the end of the free data block, and the steps of finding the free data block according to the data block index table are continued. In the embodiment of the present application, the data in the data buffer area of each channel is read cyclically, and it is determined whether the time length of the data in the data buffer area of each channel is greater than or equal to the preset time length. If so, the preset time is set. The length of data is written into the free data block, which can combine multi-channel data into one channel of data for write operations, reducing the write position and improving the disk write speed; it also uses the data block index table and the in-block index table in the data block Build a two-level index to speed up retrieval and reading.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本申请一实施例提供的数据存储方法的实现流程示意图;FIG. 1 is a schematic flowchart of a data storage method provided by an embodiment of the present application;
图2是本申请一实施例提供的数据块索引表的示意图;2 is a schematic diagram of a data block index table provided by an embodiment of the present application;
图3是本申请一实施例提供的数据块中的块内索引表的示意图;3 is a schematic diagram of an intra-block index table in a data block provided by an embodiment of the present application;
图4是本申请又一实施例提供的数据存储方法的实现流程示意图;4 is a schematic flowchart of a data storage method provided by another embodiment of the present application;
图5是本申请又一实施例提供的数据存储方法的实现流程示意图;5 is a schematic flowchart of an implementation method of a data storage method according to another embodiment of the present application;
图6是本申请一实施例提供的数据存储系统的示意框图;6 is a schematic block diagram of a data storage system according to an embodiment of the present application;
图7是本申请一实施例提供的终端设备的示意框图。FIG. 7 is a schematic block diagram of a terminal device according to an embodiment of the present application.
本发明的实施方式Embodiments of the invention
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。In order to explain the technical solution described in this application, specific examples are used for description below.
图1是本申请一实施例提供的数据存储方法的实现流程示意图,为了便于说明,仅示出了与本申请实施例相关的部分。本申请实施例的执行主体可以是终端设备。如图1所示,该方法可以包括以下步骤:FIG. 1 is a schematic diagram of an implementation process of a data storage method provided by an embodiment of the present application. For ease of description, only parts related to the embodiment of the present application are shown. The execution subject in this embodiment of the present application may be a terminal device. As shown in Figure 1, the method may include the following steps:
步骤S101:读取数据块索引表,根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,数据块索引表包括多个数据块索引节点。Step S101: Read a data block index table, find a free data block according to the data block index table, and update a data block index node corresponding to the idle data block. The data block index table includes a plurality of data block index nodes.
在本申请实施例中,将SMR盘的存储空间按照预设大小划分成多个数据块,可以为每个数据块进行编号,编号可以从0开始,依次递增。其中,预设大小可以是256兆(MByte,MB)。例如,一个4T的硬盘,按照256MB进行划分,可以得到16384个数据块,为这16384个数据块依次进行编号,编号为0到16383。In the embodiment of the present application, the storage space of the SMR disk is divided into a plurality of data blocks according to a preset size, and each data block may be numbered, and the numbering may start from 0 and increase sequentially. The preset size can be 256 megabytes (MByte, MB). For example, a 4T hard disk can be divided into 256MB to obtain 16,384 data blocks. The 16384 data blocks are numbered in sequence, with numbers ranging from 0 to 16383.
将划分的所有的数据块通过数据块索引表进行存储。如图2所示,数据块索引表包括多个数据块索引节点,每个数据块索引节点对应一个数据块。数据块索引节点包括文件归属戳、文件内部编号、文件开始时间、文件结束时间、通道信息、数据块类型、保留字段和校验位,其定义如下:All the divided data blocks are stored through a data block index table. As shown in FIG. 2, the data block index table includes multiple data block index nodes, and each data block index node corresponds to one data block. The data block index node includes the file ownership stamp, the file internal number, the file start time, the file end time, channel information, data block type, reserved fields, and check digits, which are defined as follows:
typedefstruct _block_info_typedefstruct _block_info_
{{
unsigned long owner_stamp;unsigned long owner_stamp;
unsigned long inner_num;unsigned long inner_num;
unsigned long start_time;unsigned long start_time;
unsigned long end_time;unsigned long end_time;
unsigned long chn_info; unsigned long chn_info;
unsigned char block_type;unsigned char block_type;
unsigned char reserve[7];unsigned char reserve [7];
unsigned long check_num;unsigned long check_num;
}block_info_t;} block_info_t;
其中,owner_stamp为文件归属戳,文件归属戳也可以称为文件标识,不同的文件对应的文件归属戳不同,通过文件归属戳可以查找同一个文件分别存储在哪几个数据块中。本申请实施例中的文件是具有时间属性的文件,例如视频文件、音频文件等等。由于监控通道为多个通道,所以,所有的通道均会同时产生数据。一个文件是由时间连续的所有通道的数据组成的。Among them, owner_stamp is a file ownership stamp, which can also be referred to as a file identifier. Different files have different file ownership stamps. You can use the file ownership stamp to find out which data blocks are stored in the same file. The files in the embodiments of the present application are files with time attributes, such as video files, audio files, and so on. Because the monitoring channels are multiple channels, all channels will generate data at the same time. A file is made up of data from all channels that are continuous in time.
inner_num为文件内部编号,用来表示文件存储的顺序,同一个文件的文件内部编号可以是从1开始的连续自然数。一个文件往往存储在多个数据块中,假设某个文件存储在数据块1、3和5中,数据块1对应的文件内部编号为3,数据块2对应的文件内部编号为2,数据块5对应的文件内部编号为1,那么该文件存储时的顺序是先存储在数据块5中,数据块5存储满了之后,再存储在数据块3中,数据块3存储满了之后,又存储在数据块1中。inner_num is the internal number of the file, which is used to indicate the order in which the files are stored. The internal number of the same file can be a continuous natural number starting from 1. A file is often stored in multiple data blocks. Assuming a file is stored in data blocks 1, 3, and 5, the internal number of the file corresponding to data block 1 is 3, the internal number of the file corresponding to data block 2 is 2, and the data block The internal number of the file corresponding to 5 is 1. Then the order of storing the file is first stored in data block 5, after data block 5 is full, then it is stored in data block 3. After data block 3 is full, Stored in data block 1.
start_time为文件开始时间,表示该数据块内文件的开始时间。start_time is the file start time, which indicates the start time of the file in the data block.
end_time为文件结束时间,表示该数据块内文件的结束时间。即该数据块内存储的数据为该文件从文件开始时间到文件结束时间这段时间内的数据。end_time is the end time of the file, indicating the end time of the file in the data block. That is, the data stored in the data block is data in the file from the file start time to the file end time.
chn_info为通道信息,表示该数据块存储有哪些通道的数据。使用比特(bit)位表示是否存储有对应通道的数据。例如,若第0位为1,则表示存储有通道0的数据,若第0位为0,则表示没有存储通道0的数据,其它通道类似,不再赘述。chn_info is channel information, which indicates which channels of data are stored in the data block. Bits are used to indicate whether data for the corresponding channel is stored. For example, if the 0th bit is 1, it means that the data of channel 0 is stored. If the 0th bit is 0, it means that the data of channel 0 is not stored. The other channels are similar and will not be described again.
block_type为数据块类型,用于区分数据块的类型。可以用0表示空闲数据块,即没有存储数据的数据块;用1表示存储有数据块索引表的数据块;用2表示存储有数据的数据块。block_type is a data block type and is used to distinguish the type of the data block. You can use 0 to indicate free data blocks, that is, data blocks that do not store data; use 1 to indicate data blocks that store data block index tables; and use 2 to indicate data blocks that store data.
reserve[7]为保留字段。reserve [7] is a reserved field.
check_num为校验位,通过校验位判断数据是否合法。check_num is a check digit, which is used to determine whether the data is legal.
一个数据块索引节点为32个字节,若一个4T的硬盘总共有16384个数据块,那么该硬盘对应的数据块索引表的大小为16384*32=524288字节。A data block index node is 32 bytes. If a 4T hard disk has a total of 16384 data blocks, the size of the data block index table corresponding to the hard disk is 16384 * 32 = 524288 bytes.
为了能够快速获取到数据块索引表,将数据块索引表固定存储在编号为0的数据块中,编号为0的数据块中只存储数据块索引表,因此,编号为0的数据块对应的数据块类型为1,其它的数据块用来存储各个通道的数据。In order to quickly obtain the data block index table, the data block index table is fixedly stored in the data block numbered 0, and only the data block index table is stored in the data block numbered 0. Therefore, the data block numbered 0 corresponds to The data block type is 1, the other data blocks are used to store the data of each channel.
每个数据块都分为数据区和索引区两部分,如图2所示。数据区存储各个通道的数据,索引区存储有块内索引表,块内索引表是以每个通道的预设时间长度的数据进行构建的,预设时间长度可以为1秒。如图3所示,块内索引表包括多个块内索引节点,每个块内索引节点存储有一秒数据的相关信息。通过块内索引表可以准确定位到某个通道某一秒的数据。为了避免数据区写入数据的同时索引区也写入信息的情况发生,即为了避免写入位置增加的情况发生,先将索引区(块内索引表)缓存到内存中,当数据区写完了之后,再将内存中的块内索引表写入索引区,相当于数据块的写入操作为顺序写入。Each data block is divided into a data area and an index area, as shown in Figure 2. The data area stores data of each channel, and the index area stores an index table in the block. The index table in the block is constructed by data of a preset time length of each channel, and the preset time length can be 1 second. As shown in FIG. 3, the intra-block index table includes multiple intra-block index nodes, and each intra-block index node stores information related to one second of data. The index table in the block can accurately locate the data of a certain channel for a certain second. In order to avoid the situation where the data is written into the data area while the data is written into the index area, that is, to avoid the increase in the write position, the index area (the index table in the block) is buffered into memory. When the data area is written After that, the in-block index table in the memory is written into the index area, which is equivalent to the write operation of the data block as a sequential write.
块内索引表记录了每一秒数据的相关信息,块内索引节点的定义如下:The index table in the block records the relevant information of each second of data. The definition of the index node in the block is as follows:
typedefstruct _data_info_typedefstruct _data_info_
{{
unsigned char chn;unsigned char chn;
unsigned char hour;unsigned char hour;
unsigned char minute;unsigned char minute;
unsigned char second;unsigned char second;
unsigned long offset;unsigned long offset;
unsigned long length; unsigned long length;
unsigned char flag;unsigned char flag;
unsigned char reserve[3];unsigned char reserve [3];
}data_info_t;} data_info_t;
其中,chn为通道号,表示该块内索引节点对应的数据属于该通道号。Among them, chn is the channel number, which indicates that the data corresponding to the index node in the block belongs to the channel number.
hour、minute和second分别为时、分和秒,表示该块内索引节点对应的数据为该时、分、秒的数据。Hour, minute, and second are hours, minutes, and seconds, respectively, indicating that the data corresponding to the i-nodes in the block are the hours, minutes, and seconds.
offset为数据偏移量,表示该块内索引节点对应的数据在数据块内的偏移量。offset is the data offset, which indicates the offset of the data corresponding to the index node in the block in the data block.
length为数据大小,表示该块内索引节点对应的数据的大小。length is the data size, which indicates the size of the data corresponding to the inodes in the block.
flag为索引标识,若为0表示空闲,若为1表示占用。flag is the index flag. If it is 0, it means idle, if it is 1, it means occupied.
reserve[3]为保留字段。reserve [3] is a reserved field.
由块内索引节点的定义可知,一个块内索引节点为16个字节。According to the definition of the i-node within a block, the i-node within a block is 16 bytes.
对于256MB的数据块,为索引区分配256KB的空间,那么索引区可以存储256*1024/16=16384个块内索引节点,即16384个块内索引节点用来索引256MB的数据,平均每个块内索引节点索引的数据大小为256*1024/16384=16KB,也就是说,平均每秒的数据为16KB,由于视频数据或音频数据的码率均大于16bps,所以256KB的索引区对于256MB的数据块完全够用。另外,256KB的索引区占用256MB的数据块的1/1024,即空间利用率可以达到99.9%。For 256MB data blocks, allocate 256KB of space for the index area, then the index area can store 256 * 1024/16 = 16384 in-block inodes, that is, 16384 in-block inodes are used to index 256MB of data. Each block is averaged. The size of the data indexed by the inner i-node is 256 * 1024/16384 = 16KB, that is, the average data per second is 16KB. Since the code rate of video data or audio data is greater than 16bps, the 256KB index area is 256MB of data. The blocks are completely adequate. In addition, the 256KB index area occupies 1/1024 of the 256MB data block, which means that the space utilization rate can reach 99.9%.
在本申请实施例中,当需要写入数据时,首先读取数据块索引表,根据数据块索引表查找空闲数据块,查找到空闲数据块后,将该空闲数据块对应的数据块索引节点中的数据块类型由0更新为2,并更新文件内部编号。In the embodiment of the present application, when data needs to be written, the data block index table is first read, and the free data block is found according to the data block index table. After finding the free data block, the data block index node corresponding to the free data block is found. The data block type in is updated from 0 to 2, and the file internal number is updated.
步骤S102:为空闲数据块中的块内索引表分配缓存。Step S102: Allocate a cache for the in-block index table in the free data block.
在本申请实施例中,在向空闲数据块中写入数据之前,首先为空闲数据块中的块内索引表分配缓存,将该块内索引表保存在缓存中,在之后的数据写入的同时,更新缓存中的块内索引表。In the embodiment of the present application, before writing data to the free data block, first allocate a cache for the in-block index table in the free data block, and save the in-block index table in the cache. At the same time, the in-block index table in the cache is updated.
步骤S103:循环读取每个通道的数据缓存区中的数据。Step S103: The data in the data buffer area of each channel is read cyclically.
其中,每个通道都有一个对应的数据缓存区,数据缓存区中保存有对应通道的监控数据。Each channel has a corresponding data buffer area, and the monitoring data of the corresponding channel is stored in the data buffer area.
循环读取每个通道的数据缓存区中的数据,并判断每个通道的数据缓存区中的数据的时间长度是否大于或等于预设时间长度。Read the data in the data buffer area of each channel cyclically, and determine whether the time length of the data in the data buffer area of each channel is greater than or equal to the preset time length.
假设有4个通道,分别为通道0、1、2和3,那么循环读取每个通道的数据缓存区中的数据,可以是首先读取通道0的数据缓存区中的数据,再读取通道1的数据缓存区中的数据,然后读取通道2的数据缓存区中的数据,接着读取通道3的数据缓存区中的数据,接着再次读取通道0的数据缓存区中的数据,如此循环读取每个通道的数据缓存区中的数据。Assume that there are 4 channels, which are channels 0, 1, 2 and 3, then the data in the data buffer area of each channel is read cyclically. The data in the data buffer area of channel 0 can be read first, and then read. Data in the data buffer area of channel 1, then read the data in the data buffer area of channel 2, then read the data in the data buffer area of channel 3, and then read the data in the data buffer area of channel 0 again, In this way, the data in the data buffer area of each channel is read cyclically.
步骤S104:若目标通道的数据缓存区中的数据的时间长度大于或等于预设时间长度,则读取目标通道的数据缓存区中的预设时间长度的数据,将预设时间长度的数据写入空闲数据块,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表,目标通道为所有通道中的任一个。Step S104: If the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, then read the data of the preset time length in the data buffer area of the target channel and write the data of the preset time length Into the idle data block, and update the data block index node corresponding to the idle data block and the in-block index table in the cache, the target channel is any one of all channels.
其中,预设时间长度可以为1秒。The preset time length may be 1 second.
在本申请实施例中,若目标通道的数据缓存区中的数据的时间长度大于或等于1秒,则读取该目标通道的数据缓存区中的时间长度为1秒的数据,将这1秒的数据写入空闲数据块的数据区,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表。In the embodiment of the present application, if the time length of the data in the data buffer area of the target channel is greater than or equal to 1 second, then the data in the data buffer area of the target channel with a length of 1 second is read, and the 1 second is The data is written into the data area of the free data block, and the data block index node corresponding to the free data block and the in-block index table in the cache are updated.
更新空闲数据块对应的数据块索引节点可以是更新该数据块索引节点的文件开始时间、文件结束时间、通道信息等内容。Updating the data block index node corresponding to the idle data block may be updating the file start time, file end time, channel information, etc. of the data block index node.
更新缓存中的块内索引表可以是查找该块内索引表中空闲的块内索引节点,即索引标识为0的块内索引节点,根据目标通道的通道号更新所述空闲的块内索引节点的通道号,根据这1秒的数据的时间更新所述空闲的块内索引节点的时、分和秒,根据这1秒的数据在空闲数据块中写入的位置更新所述空闲的块内索引节点的数据偏移量,根据这1秒的数据的大小更新所述空闲的块内索引节点的数据大小,将索引标识更新为1。Updating the intra-block index table in the cache may be to find an idle intra-block index node in the intra-block index table, that is, an intra-block index node with an index identifier of 0, and updating the idle intra-block index node according to the channel number of the target channel. Update the hour, minute, and second of the index node in the free block according to the time of the 1-second data, and update the free block according to the position where the 1-second data is written in the free data block The data offset of the inode is updated according to the data size of the 1 second data of the inode in the idle block, and the index identifier is updated to 1.
步骤S105:若空闲数据块写满,则将缓存中的块内索引表写入空闲数据块的尾部,并继续执行根据数据块索引表查找空闲数据块的步骤。Step S105: if the free data block is full, write the index table in the block in the cache to the tail of the free data block, and continue to perform the steps of finding the free data block according to the data block index table.
在本申请实施例中,若空闲数据块写满,也就是说空闲数据块的数据区写满,则将缓存中的块内索引表写入空闲数据块的尾部,即写入空闲数据块的索引区,并重新查找新的数据块,即返回步骤S101中的根据数据块索引表查找空闲数据块的步骤进行循环。In the embodiment of the present application, if the free data block is full, that is, the data area of the free data block is full, the index table in the block in the cache is written to the tail of the free data block, that is, the data of the free data block is written. Index area, and search for a new data block again, that is, return to the step of finding a free data block according to the data block index table in step S101 to perform a loop.
由上述描述可知,本申请实施例通过循环读取每个通道的数据缓存区中的数据,并判断每个通道的数据缓存区中的数据的时间长度是否大于或等于预设时间长度,若是,则将预设时间长度的数据写入空闲数据块,能够将多通道的数据合并成一路数据进行顺序写入操作,大大降低硬盘的寻址时间,减少写入位置,提高SMR盘的写入速度,能最大限速地避免SMR盘的写放大;通过数据块索引表和数据块中的块内索引表构建两级索引,由于索引结构较小,可以在较小的内存开销下,完成高效的数据检索和对指定数据的读取;通过在写入数据前,为空闲数据块中的块内索引表分配缓存,在写入数据的同时,更新缓存中的块内索引表,在数据写满后,将缓存中的块内索引表写入空闲数据块,实现了数据块内的数据区和索引区的顺序写入,减少了写入位置,进一步提高了写入速度。From the above description, it can be known that, in the embodiment of the present application, the data in the data buffer area of each channel is read cyclically, and it is determined whether the time length of the data in the data buffer area of each channel is greater than or equal to the preset time length. The data of a preset length of time is written into the free data block, and the data of multiple channels can be combined into one channel for sequential write operation, which greatly reduces the addressing time of the hard disk, reduces the write position, and improves the write speed of the SMR disk. , Which can avoid write amplification of SMR disks at the maximum speed limit; build a two-level index through the data block index table and the in-block index table in the data block. Because the index structure is small, it can complete high efficiency with less memory overhead. Data retrieval and reading of specified data; by writing a buffer to the in-block index table in the free data block before writing the data, while writing the data, the in-block index table in the cache is updated and the data is full Then, the in-block index table in the cache is written to the free data block, and the sequential writing of the data area and the index area in the data block is realized, reducing the writing position, further High write speed.
作为本申请又一实施例,数据块索引节点包括文件归属戳和数据块类型;As another embodiment of the present application, the data block index node includes a file belonging stamp and a data block type;
在读取数据块索引表之后,还包括:After reading the data block index table, it also includes:
将数据块索引表缓存到内存中。Cache the data block index table into memory.
根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,包括:Find the free data block according to the data block index table, and update the data block index node corresponding to the free data block, including:
遍历内存中的数据块索引表,得到最大的文件归属戳,并根据最大的文件归属戳确定待存储文件的文件归属戳。Traverse the data block index table in memory to get the largest file attribution stamp, and determine the file attribution stamp for the file to be stored based on the largest file attribution stamp.
根据数据块类型查找空闲数据块,并根据待存储文件的文件归属戳更新空闲数据块对应的数据块索引节点。Find the free data block according to the data block type, and update the data block index node corresponding to the free data block according to the file ownership stamp of the file to be stored.
在本申请实施例中,读取数据块索引表之后,将数据块索引表缓存到内存中,在之后的步骤中,需要读取数据块索引表的时候,可以直接在内存中读取,相比于在硬盘中读取数据块索引表,读取速度更快。In the embodiment of the present application, after reading the data block index table, the data block index table is cached in the memory. In the subsequent steps, when the data block index table needs to be read, it can be read directly in the memory. It is faster than reading the data block index table on the hard disk.
通过比较数据块索引表中所有的数据块索引节点的文件归属戳,得到所有的数据块索引节点的文件归属戳中最大的文件归属戳,最大的文件归属戳加1得到待存储文件的文件归属戳。By comparing the file attribution stamps of all data block index nodes in the data block index table, the largest file attribution stamp of the file attribution stamps of all data block inodes is obtained, and the largest file attribution stamp plus 1 is used to obtain the file attribution of the file to be stored. stamp.
空闲数据块即为数据块类型为0的数据块索引节点对应的数据块。查找到空闲数据块后,将空闲数据块对应的数据块索引节点的文件归属戳更新为所述待存储文件的文件归属戳,将空闲数据块对应的数据块索引节点的数据块类型更新为2,并更新空闲数据块对应的数据块索引节点的文件内部编号,该文件内部编号更新为待存储文件在上一个存储的数据块对应的数据块索引节点的文件内部编号加1,若不存在上一个存储的数据块,则该文件内部编号从头开始编号,可以更新为1。The idle data block is a data block corresponding to a data block index node whose data block type is 0. After finding the free data block, the file home stamp of the data block index node corresponding to the free data block is updated to the file home stamp of the file to be stored, and the data block type of the data block index node corresponding to the free data block is updated to 2 And update the file internal number of the data block index node corresponding to the free data block, and the file internal number is updated to the file internal number of the data block index node corresponding to the previously stored data block plus 1 if it does not exist. For a stored data block, the internal number of the file is numbered from the beginning and can be updated to 1.
作为本申请又一实施例,在循环读取每个通道的数据缓存区中的数据之后,还包括:As another embodiment of the present application, after reading the data in the data buffer area of each channel in a loop, the method further includes:
若目标通道的数据缓存区中的数据的时间长度小于预设时间长度,则继续判断下一个通道的数据缓存区中的数据的时间长度是否大于或等于预设时间长度。If the time length of the data in the data buffer area of the target channel is less than the preset time length, it continues to determine whether the time length of the data in the data buffer area of the next channel is greater than or equal to the preset time length.
在更新空闲数据块对应的数据块索引节点和缓存中的块内索引表之后,还包括:After updating the data block index node corresponding to the free data block and the in-block index table in the cache, the method further includes:
若空闲数据块未写满,则继续执行循环读取每个通道的数据缓存区中的数据的步骤。If the free data block is not full, the steps of reading data in the data buffer area of each channel in a loop are continued.
在本申请实施例中,若目标通道的数据缓存区中的数据的时间长度小于1秒,则继续读取下一个通道的数据缓存区中的数据,并判断下一个通道的数据缓存区中的数据的时间长度是否大于或等于1秒。In the embodiment of the present application, if the time length of the data in the data buffer area of the target channel is less than 1 second, the data in the data buffer area of the next channel is continuously read, and the data in the data buffer area of the next channel is determined. Whether the length of data is greater than or equal to 1 second.
若空闲数据块未写满,即空闲数据块的数据区未写满,则返回步骤S103循环执行。If the free data block is not full, that is, the data area of the free data block is not full, the process returns to step S103 to execute cyclically.
图4是本申请又一实施例提供的数据存储方法的实现流程示意图。如图4所示,在上述实施例的基础上,数据存储方法还可以包括以下步骤:FIG. 4 is a schematic flowchart of a data storage method provided by another embodiment of the present application. As shown in FIG. 4, based on the above embodiment, the data storage method may further include the following steps:
步骤S401:获取待查询信息。Step S401: Obtain information to be queried.
其中,待查询信息包括待查询开始时间、待查询结束时间和待查询通道号,用于查询待查询开始时间和待查询结束时间之间的这段时间内,所述待查询通道号的数据所属的文件信息列表。The information to be queried includes the time to be queried, the time to be queried and the number of the channel to be queried, and is used to query the time between the time to be queried and the time to be queried. The data of the channel number to be queried belongs to List of file information.
步骤S402:遍历数据块索引表,将所有文件归属戳相同的数据块索引节点合并为一项文件描述信息。Step S402: traverse the data block index table, and merge all data block index nodes with the same file ownership stamp into one file description information.
其中,文件描述信息包括文件归属戳、文件开始时间、文件结束时间和文件包含的通道信息,其定义如下:The file description information includes the file attribution stamp, the file start time, the file end time, and the channel information contained in the file. The definition is as follows:
typedefstruct _file_info_typedefstruct _file_info_
{{
unsigned long owner_stamp;unsigned long owner_stamp;
unsigned long start_time;unsigned long start_time;
unsigned long end_time;unsigned long end_time;
unsigned long chn_info; unsigned long chn_info;
}file_info_t;} file_info_t;
其中,owner_stamp为文件归属戳。Among them, owner_stamp is the file ownership stamp.
start_time为文件开始时间,该文件开始时间为该文件归属戳对应的所有数据块中的第一个数据块的文件开始时间。start_time is the file start time, and the file start time is the file start time of the first data block among all data blocks corresponding to the file home stamp.
end_time为文件结束时间,该文件结束时间为该文件归属戳对应的所有数据块中的最后一个数据块的文件结束时间。end_time is the end time of the file, and the end time of the file is the end time of the last data block among all data blocks corresponding to the file home stamp.
chn_info为文件包含的通道信息,该文件包含的通道信息为文件归属戳对应的所有数据块的通道信息的并集。chn_info is the channel information contained in the file, and the channel information contained in the file is the union of the channel information of all the data blocks corresponding to the file home stamp.
在本申请实施例中,将所有文件归属戳相同的数据块索引节点合并为一项文件描述信息,即一个文件对应一项文件描述信息。In the embodiment of the present application, all data block index nodes with the same home stamp are merged into one piece of file description information, that is, one file corresponds to one piece of file description information.
步骤S403:根据文件描述信息确定待查询信息对应的查询结果。Step S403: Determine a query result corresponding to the query information according to the file description information.
查找文件描述信息中的文件开始时间和文件结束时间之间的这段时间包含待查询开始时间和待查询结束时间之间的这段时间,且在文件包含的通道信息中,待查询通道号对应的比特位为1的文件信息列表。其中,文件信息列表可以包括文件归属戳、文件开始时间、文件结束时间和文件包含的通道信息等内容。The time between the file start time and the file end time in the file description information includes the time between the start time to be queried and the end time to be queried, and in the channel information contained in the file, the channel number to be queried corresponds to A list of file information with a bit of 1. The file information list may include content such as file ownership stamp, file start time, file end time, and channel information included in the file.
作为本申请又一实施例,待查询信息包括待查询开始时间、待查询结束时间和待查询通道号,文件描述信息包括文件归属戳、文件开始时间、文件结束时间和文件包含的通道信息;As another embodiment of the present application, the information to be queried includes a start time to be queried, an end time to be queried, and a channel number to be queried, and the file description information includes a file home stamp, a file start time, a file end time, and channel information contained in the file;
根据文件描述信息确定待查询信息对应的查询结果,包括:The query result corresponding to the query information is determined according to the file description information, including:
根据文件开始时间、文件结束时间和文件包含的通道信息,确定待查询开始时间、待查询结束时间和待查询通道号对应的文件信息列表。According to the file start time, file end time, and channel information contained in the file, a list of file information corresponding to the start time to be queried, the end time to be queried, and the channel number to be queried is determined.
由上述描述可知,本申请实施例可以根据待查询开始时间、待查询结束时间和待查询通道号查询得到符合要求的文件信息列表。It can be known from the foregoing description that the embodiments of the present application can query the file information list that meets the requirements according to the start time, end time and channel number to be queried.
图5是本申请又一实施例提供的数据存储方法的实现流程示意图。如图5所示,在上述实施例的基础上,数据存储方法还可以包括以下步骤:FIG. 5 is a schematic flowchart of a data storage method provided by another embodiment of the present application. As shown in FIG. 5, based on the above embodiment, the data storage method may further include the following steps:
步骤S501:获取定位时间和待读取通道号。Step S501: Obtain a positioning time and a channel number to be read.
在本申请实施例中,读取定位时间之后的所述待读取通道号的数据。In the embodiment of the present application, the data of the channel number to be read after the positioning time is read.
步骤S502:遍历数据块索引表,得到定位时间所属的定位数据块。Step S502: Traverse the data block index table to obtain the positioning data block to which the positioning time belongs.
其中,将定位时间所属的数据块称为定位数据块。The data block to which the positioning time belongs is referred to as a positioning data block.
在本申请实施例中,遍历数据块索引表,根据文件开始时间和文件结束时间得到定位时间所属的定位数据块,即定位数据块对应的文件开始时间和文件结束时间之间的这段时间包含所述定位时间。In the embodiment of the present application, the data block index table is traversed, and the positioning data block to which the positioning time belongs is obtained according to the file start time and the file end time, that is, the period between the file start time and the file end time corresponding to the positioning data block includes The positioning time.
步骤S503:读取定位数据块中的定位块内索引表,并将定位块内索引表缓存到内存中。Step S503: Read the index table in the positioning block in the positioning data block, and cache the index table in the positioning block into the memory.
在本申请实施例中,将定位数据块中的块内索引表称为定位块内索引表。读取定位块内索引表,并将定位块内索引表缓存到内存中。In the embodiment of the present application, the intra-block index table in the positioning data block is referred to as an intra-block index table. Read the index table in the positioning block, and cache the index table in the positioning block into memory.
步骤S504:遍历内存中的定位块内索引表,确定定位时间和待读取通道号所在的定位块内索引节点,并根据定位块内索引节点中的数据偏移量,确定待读取数据的位置。Step S504: traverse the index table in the positioning block in memory, determine the positioning time and the index node in the positioning block where the channel number to be read is located, and determine the data to be read according to the data offset in the index node in the positioning block. position.
在本申请实施例中,将定位时间和待读取通道号所在的块内索引节点称为定位块内索引节点。即定位块内索引节点的时分秒为所述定位时间,且定位块内索引节点的通道号为待读取通道号。In the embodiment of the present application, the index node in the block where the positioning time and the channel number to be read are located is referred to as the index node in the positioning block. That is, the hour, minute and second of the index node in the positioning block is the positioning time, and the channel number of the index node in the positioning block is the number of the channel to be read.
获取定位块内索引节点中的数据偏移量,并根据该数据偏移量确定定位数据块中待读取数据的位置。Obtain the data offset in the index node in the positioning block, and determine the position of the data to be read in the positioning data block according to the data offset.
步骤S505:根据待读取数据的位置读取待读取数据。Step S505: Read the data to be read according to the position of the data to be read.
在待读取数据的位置读取大小为定位块内索引节点的数据大小的待读取数据。At the position of the data to be read, the data to be read whose size is the data size of the index node in the positioning block is read.
步骤S506:在定位块内索引表中的定位块内索引节点之后的块内索引节点中,查找是否存在包含待读取通道号的目标块内索引节点。Step S506: In the in-block index node after the in-block index node in the in-block index table, find whether there is a target in-block index node that contains the channel number to be read.
在本申请实施例中,将在定位块内索引表中的定位块内索引节点之后的块内索引节点中,通道号为待读取通道号的块内索引节点称为目标块内索引节点。In the embodiment of the present application, among the in-block index nodes after the in-block index node in the in-block index table, the in-block index node whose channel number is the channel number to be read is referred to as the target in-block index node.
步骤S507:若存在目标块内索引节点,则将目标块内索引节点作为新的定位块内索引节点,并继续执行根据定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤。Step S507: if there is an index node in the target block, use the index node in the target block as a new index node in the positioning block, and continue to determine the position of the data to be read according to the data offset in the index node in the positioning block. A step of.
若存在目标块内索引节点,则将目标块内索引节点作为新的定位块内索引节点,并返回步骤S504的根据定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤进行循环。If there is an index node in the target block, the index node in the target block is used as a new index node in the positioning block, and the method returns to step S504 to determine the position of the data to be read according to the data offset in the index node in the positioning block. The steps are cycled.
步骤S508:若不存在目标块内索引节点,则在数据块索引表中,查找是否存在文件归属戳与定位数据块对应的文件归属戳相同,且文件内部编号为定位数据块对应的文件内部编号加一的目标数据块索引节点。Step S508: if there is no index node in the target block, then in the data block index table, find whether a file attribution stamp is the same as the file attribution corresponding to the positioning data block, and the file internal number is the internal number of the file corresponding to the positioning data block. Increment the target data block inode.
其中,将文件归属戳与定位数据块对应的文件归属戳相同,且文件内部编号为定位数据块对应的文件内部编号加一的数据块索引节点作为目标数据块索引节点。Wherein, the file home stamp is the same as the file home stamp corresponding to the positioning data block, and the internal number of the file is the data block index node plus the internal number of the file corresponding to the positioning data block plus one as the target data block index node.
若不存在目标块内索引节点,则在数据块索引表中,查找是否存在目标数据块索引节点。If there are no inodes in the target block, then in the data block index table, look up whether there is a target data block inode.
步骤S509:若存在目标数据块索引节点,则将目标数据块索引节点对应的数据块作为新的定位数据块,读取新的定位数据块中的新的定位块内索引表,并将新的定位块内索引表缓存到内存中。Step S509: if a target data block index node exists, use the data block corresponding to the target data block index node as a new positioning data block, read the new index table in the positioning block in the new positioning data block, and add the new The index table in the positioning block is cached in memory.
其中,将新的定位数据块中的块内索引表作为新的定位块内索引表。The intra-block index table in the new positioning data block is used as the new intra-block index table.
步骤S510:遍历内存中的新的定位块内索引表,确定待读取通道号所在的新的定位块内索引节点,并继续执行根据定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤。Step S510: traverse the new index table in the positioning block in the memory, determine the new index node in the positioning block where the channel number to be read is located, and continue to perform determination based on the data offset in the index node in the positioning block to be read Steps to get the location of the data.
在本申请实施例中,将在新的定位块内索引表中,通道号与待读取通道号相同的块内索引节点作为新的定位块内索引节点,用新的定位块内索引节点替代之前的定位块内索引节点,返回步骤S504中的根据定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤进行循环执行。In the embodiment of the present application, in the new index table within the positioning block, the index node within the block with the same channel number as the channel number to be read is used as the new index node within the positioning block, and the new index node within the positioning block is replaced. The previous index node in the positioning block returns to step S504, and the step of determining the position of the data to be read according to the data offset in the index node in the positioning block is executed cyclically.
步骤S511:若不存在目标数据块索引节点,则数据读取结束。Step S511: if the target data block index node does not exist, the data reading ends.
由上述描述可知,本申请实施例可以读取某一通道中的某一时间节点之后的数据,首先根据数据块索引表定位数据块,然后通过块内索引表进行精准定位,能够高效地定位到所需数据。From the above description, it can be known that the embodiment of the present application can read data after a certain time node in a channel, and first locate the data block according to the data block index table, and then accurately locate the data through the index table in the block, which can efficiently locate Required data.
作为本申请又一实施例,数据块索引节点包括文件开始时间和文件结束时间;As another embodiment of the present application, the data block index node includes a file start time and a file end time;
遍历数据块索引表,得到定位时间所属的定位数据块,包括:Traverse the data block index table to obtain the positioning data block to which the positioning time belongs, including:
遍历数据块索引表,根据文件开始时间和文件结束时间得到定位时间所属的定位数据块。Traverse the data block index table, and obtain the positioning data block to which the positioning time belongs according to the file start time and the file end time.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
图6是本申请一实施例提供的数据存储系统的示意框图,为了便于说明,仅示出与本申请实施例相关的部分。FIG. 6 is a schematic block diagram of a data storage system according to an embodiment of the present application. For convenience of explanation, only a part related to the embodiment of the present application is shown.
在本申请实施例中,数据存储系统6包括:In the embodiment of the present application, the data storage system 6 includes:
空闲数据块查找模块61,用于读取数据块索引表,根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,数据块索引表包括多个数据块索引节点;The idle data block search module 61 is configured to read a data block index table, find a free data block according to the data block index table, and update a data block index node corresponding to the idle data block. The data block index table includes multiple data block index nodes;
缓存分配模块62,用于为空闲数据块中的块内索引表分配缓存;A cache allocation module 62, configured to allocate a cache for an in-block index table in an idle data block;
循环读取模块63,用于循环读取每个通道的数据缓存区中的数据;A cyclic reading module 63, configured to cyclically read data in a data buffer area of each channel;
数据写入模块64,用于若目标通道的数据缓存区中的数据的时间长度大于或等于预设时间长度,则读取目标通道的数据缓存区中的预设时间长度的数据,将预设时间长度的数据写入空闲数据块,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表,目标通道为所有通道中的任一个;The data writing module 64 is configured to read data of a predetermined time length in the data buffer area of the target channel if the time length of the data in the data buffer area of the target channel is greater than or equal to a preset time length, and The length of data is written into the idle data block, and the data block index node corresponding to the idle data block and the in-block index table in the cache are updated, and the target channel is any one of all channels;
索引表写入模块65,用于若空闲数据块写满,则将缓存中的块内索引表写入空闲数据块的尾部,并继续执行根据数据块索引表查找空闲数据块的步骤。The index table writing module 65 is configured to write an in-block index table in the cache to the tail of the free data block if the free data block is full, and continue to perform the steps of finding the free data block according to the data block index table.
可选地,空闲数据块查找模块61,还用于将数据块索引表缓存到内存中;Optionally, the idle data block search module 61 is further configured to cache the data block index table into memory;
空闲数据块查找模块61还包括:The idle data block search module 61 further includes:
文件归属戳获取单元,用于遍历内存中的数据块索引表,得到最大的文件归属戳,并根据最大的文件归属戳确定待存储文件的文件归属戳;The file ownership stamp obtaining unit is used to traverse the data block index table in the memory to obtain the largest file ownership stamp, and determine the file ownership stamp of the file to be stored according to the largest file ownership stamp;
空闲数据块查找单元,用于根据数据块类型查找空闲数据块,并根据待存储文件的文件归属戳更新空闲数据块对应的数据块索引节点。The idle data block searching unit is configured to find an idle data block according to the data block type, and update a data block index node corresponding to the idle data block according to a file belonging stamp of a file to be stored.
可选地,数据存储系统6还包括:Optionally, the data storage system 6 further includes:
判断模块,用于若目标通道的数据缓存区中的数据的时间长度小于预设时间长度,则继续判断下一个通道的数据缓存区中的数据的时间长度是否大于或等于预设时间长度;A judging module, configured to continue to judge whether the time length of the data in the data buffer area of the next channel is greater than or equal to the preset time length if the time length of the data in the data buffer area of the target channel is less than the preset time length;
第一循环模块,用于若空闲数据块未写满,则继续执行循环读取每个通道的数据缓存区中的数据的步骤。The first loop module is configured to, if the free data block is not full, continue to perform the step of cyclically reading data in the data buffer area of each channel.
可选地,数据块索引节点包括文件归属戳;Optionally, the data block index node includes a file belonging stamp;
数据存储系统6还包括:The data storage system 6 further includes:
第一获取模块,用于获取待查询信息;A first obtaining module, configured to obtain information to be queried;
合并模块,用于遍历数据块索引表,将所有文件归属戳相同的数据块索引节点合并为一项文件描述信息;A merging module for traversing the data block index table and merging all data block index nodes with the same file ownership stamp into one file description information;
查询结果获取模块,用于根据文件描述信息确定待查询信息对应的查询结果。The query result obtaining module is configured to determine a query result corresponding to the query information according to the file description information.
可选地,待查询信息包括待查询开始时间、待查询结束时间和待查询通道号,文件描述信息包括文件归属戳、文件开始时间、文件结束时间和文件包含的通道信息;Optionally, the information to be queried includes a start time to be queried, an end time to be queried, and a channel number to be queried, and the file description information includes a file belonging stamp, a file start time, a file end time, and channel information contained in the file;
查询结果获取模块,具体用于根据文件开始时间、文件结束时间和文件包含的通道信息,确定待查询开始时间、待查询结束时间和待查询通道号对应的文件信息列表。The query result acquisition module is specifically configured to determine a list of file information corresponding to the start time, the end time of the query, and the channel number to be queried according to the file start time, the file end time, and the channel information contained in the file.
可选地,数据存储系统6还包括:Optionally, the data storage system 6 further includes:
第二获取模块,用于获取定位时间和待读取通道号;A second acquisition module, configured to acquire a positioning time and a channel number to be read;
定位数据块确定模块,用于遍历数据块索引表,得到定位时间所属的定位数据块;A positioning data block determination module, which is used to traverse a data block index table to obtain a positioning data block to which a positioning time belongs;
索引表读取模块,用于读取定位数据块中的定位块内索引表,并将定位块内索引表缓存到内存中;The index table reading module is used to read the index table in the positioning block in the positioning data block, and cache the index table in the positioning block into memory;
读取位置确定模块,用于遍历内存中的定位块内索引表,确定定位时间和待读取通道号所在的定位块内索引节点,并根据定位块内索引节点中的数据偏移量,确定待读取数据的位置;The reading position determination module is used to traverse the index table in the positioning block in memory, determine the positioning time and the index node in the positioning block where the channel number to be read is located, and determine according to the data offset in the index node in the positioning block. The location of the data to be read;
数据读取模块,用于根据待读取数据的位置读取待读取数据;A data reading module, configured to read the data to be read according to the position of the data to be read;
索引节点查找模块,用于在定位块内索引表中的定位块内索引节点之后的块内索引节点中,查找是否存在包含待读取通道号的目标块内索引节点;The index node search module is used to find whether there is a target in-block index node containing the channel number to be read in the in-block index node after the in-block index node in the index table in the positioning block;
第一处理模块,用于若存在目标块内索引节点,则将目标块内索引节点作为新的定位块内索引节点,并继续执行根据定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤;A first processing module, configured to use the index node in the target block as a new index node in the positioning block if the index node in the target block exists, and continue to execute the determination of the to-be-read based on the data offset in the index node in the positioning block; Steps to get the location of the data;
第二处理模块,用于若不存在目标块内索引节点,则在数据块索引表中,查找是否存在文件归属戳与定位数据块对应的文件归属戳相同,且文件内部编号为定位数据块对应的文件内部编号加一的目标数据块索引节点;The second processing module is configured to find, in the data block index table, if there is no inode in the target block, the file attribution stamp is the same as the file attribution corresponding to the positioning data block, and the internal number of the file corresponds to the positioning data block The internal number of the file plus the target data block index node;
第三处理模块,用于若存在目标数据块索引节点,则将目标数据块索引节点对应的数据块作为新的定位数据块,读取新的定位数据块中的新的定位块内索引表,并将新的定位块内索引表缓存到内存中;A third processing module, configured to: if a target data block index node exists, use the data block corresponding to the target data block index node as a new positioning data block, and read a new index table within the positioning block in the new positioning data block; And cache the index table in the new positioning block into memory;
第二循环模块,用于遍历内存中的新的定位块内索引表,确定待读取通道号所在的定位块内索引节点,并继续执行根据定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤;The second loop module is used to traverse the new index table in the positioning block in memory, determine the index node in the positioning block where the channel number to be read is located, and continue to execute the determination based on the data offset in the index node in the positioning block. Steps for the location of the data to be read;
第四处理模块,用于若不存在目标数据块索引节点,则数据读取结束。A fourth processing module is configured to: if the target data block index node does not exist, the data reading ends.
可选地,数据块索引节点包括文件开始时间和文件结束时间;Optionally, the data block index node includes a file start time and a file end time;
定位数据块确定模块,具体用于遍历数据块索引表,根据文件开始时间和文件结束时间得到定位时间所属的定位数据块。The positioning data block determination module is specifically used to traverse the data block index table and obtain the positioning data block to which the positioning time belongs according to the file start time and the file end time.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述数据存储系统的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述装置中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of the description, only the above-mentioned division of functional units and modules is used as an example. In practical applications, the above functions can be allocated by different functional units according to needs. Module completion, that is, dividing the internal structure of the data storage system into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated into one processing unit, or each unit may exist separately physically, or two or more units may be integrated into one unit. The integrated unit may be hardware. It can be implemented in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing from each other, and are not used to limit the protection scope of the present application. For specific working processes of the units and modules in the foregoing device, reference may be made to corresponding processes in the foregoing method embodiments, and details are not described herein again.
图7是本申请一实施例提供的终端设备的示意框图。如图7所示,该实施例的终端设备7包括:一个或多个处理器70、存储器71以及存储在所述存储器71中并可在所述处理器70上运行的计算机程序72。所述处理器70执行所述计算机程序72时实现上述各个数据存储方法实施例中的步骤,例如图1所示的步骤S101至S105。或者,所述处理器70执行所述计算机程序72时实现上述数据存储系统实施例中各模块/单元的功能,例如图6所示模块61至65的功能。FIG. 7 is a schematic block diagram of a terminal device according to an embodiment of the present application. As shown in FIG. 7, the terminal device 7 of this embodiment includes one or more processors 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70. When the processor 70 executes the computer program 72, the steps in the foregoing data storage method embodiments are implemented, for example, steps S101 to S105 shown in FIG. Alternatively, when the processor 70 executes the computer program 72, the functions of the modules / units in the foregoing embodiment of the data storage system are implemented, for example, the functions of modules 61 to 65 shown in FIG. 6.
示例性地,所述计算机程序72可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器71中,并由所述处理器70执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序72在所述终端设备7中的执行过程。例如,所述计算机程序72可以被分割成空闲数据块查找模块、缓存分配模块、循环读取模块、数据写入模块和索引表写入模块,各模块具体功能如下:Exemplarily, the computer program 72 may be divided into one or more modules / units, and the one or more modules / units are stored in the memory 71 and executed by the processor 70 to complete This application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into a free data block search module, a cache allocation module, a cyclic read module, a data write module, and an index table write module. The specific functions of each module are as follows:
空闲数据块查找模块,用于读取数据块索引表,根据数据块索引表查找空闲数据块,并更新空闲数据块对应的数据块索引节点,数据块索引表包括多个数据块索引节点;The idle data block search module is used to read the data block index table, find the free data block according to the data block index table, and update the data block index node corresponding to the idle data block. The data block index table includes multiple data block index nodes;
缓存分配模块,用于为空闲数据块中的块内索引表分配缓存;A cache allocation module, configured to allocate a cache for an in-block index table in an idle data block;
循环读取模块,用于循环读取每个通道的数据缓存区中的数据;Cyclic reading module, which is used to read the data in the data buffer area of each channel cyclically;
数据写入模块,用于若目标通道的数据缓存区中的数据的时间长度大于或等于预设时间长度,则读取目标通道的数据缓存区中的预设时间长度的数据,将预设时间长度的数据写入空闲数据块,并更新空闲数据块对应的数据块索引节点和缓存中的块内索引表,目标通道为所有通道中的任一个;A data writing module is configured to read data of a preset time length in the data buffer area of the target channel if the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, and set the preset time The length of data is written into the free data block, and the data block index node corresponding to the free data block and the in-block index table in the cache are updated, and the target channel is any one of all channels;
索引表写入模块,用于若空闲数据块写满,则将缓存中的块内索引表写入空闲数据块的尾部,并继续执行根据数据块索引表查找空闲数据块的步骤。The index table writing module is configured to write the index table in the block in the cache to the end of the free data block if the free data block is full, and continue to perform the steps of finding the free data block according to the data block index table.
其它模块或者单元可参照图6所示的实施例中的描述,在此不再赘述。For other modules or units, reference may be made to the description in the embodiment shown in FIG. 6, and details are not described herein again.
所述终端设备可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述终端设备7包括但不仅限于处理器70、存储器71。本领域技术人员可以理解,图7仅仅是终端设备的一个示例,并不构成对终端设备7的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备7还可以包括输入设备、输出设备、网络接入设备、总线等。The terminal device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The terminal device 7 includes, but is not limited to, a processor 70 and a memory 71. Those skilled in the art can understand that FIG. 7 is only an example of the terminal device, and does not constitute a limitation on the terminal device 7. It may include more or fewer components than shown in the figure, or combine some components or different components. For example, the terminal device 7 may further include an input device, an output device, a network access device, a bus, and the like.
所述处理器70可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现场可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 70 may be a central processing unit (Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), and application-specific integrated circuits (Applications) Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
所述存储器71可以是所述终端设备的内部存储单元,例如终端设备的硬盘或内存。所述存储器71也可以是所述终端设备的外部存储设备,例如所述终端设备上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器71还可以既包括终端设备的内部存储单元也包括外部存储设备。所述存储器71用于存储所述计算机程序72以及所述终端设备所需的其他程序和数据。所述存储器71还可以用于暂时地存储已经输出或者将要输出的数据。The memory 71 may be an internal storage unit of the terminal device, such as a hard disk or a memory of the terminal device. The memory 71 may also be an external storage device of the terminal device, for example, a plug-in hard disk, a smart memory card (Smart Media) Card, SMC), Secure Digital (SD) card, Flash Card, etc. Further, the memory 71 may further include both an internal storage unit of the terminal device and an external storage device. The memory 71 is configured to store the computer program 72 and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For a part that is not detailed or recorded in an embodiment, reference may be made to related descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art may realize that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
在本申请所提供的实施例中,应该理解到,所揭露的数据存储系统和方法,可以通过其它的方式实现。例如,以上所描述的数据存储系统实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed data storage system and method may be implemented in other ways. For example, the embodiments of the data storage system described above are merely schematic. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be another division manner, such as multiple units or units. Components can be combined or integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, which may be electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objective of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each of the units may exist separately physically, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional unit.
所述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括是电载波信号和电信信号。When the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this application implements all or part of the processes in the method of the above embodiment, and can also be completed by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium. The computer When the program is executed by a processor, the steps of the foregoing method embodiments can be implemented. The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signals, telecommunication signals, and software distribution media. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdictions. For example, in some jurisdictions, the computer-readable medium Excludes electric carrier signals and telecommunication signals.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to describe the technical solution of the present application, but are not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still implement the foregoing implementations. The technical solutions described in the examples are modified, or some of the technical features are equivalently replaced; and these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in Within the scope of this application.

Claims (10)

  1. 一种数据存储方法,其特征在于,包括:A data storage method, comprising:
    读取数据块索引表,根据所述数据块索引表查找空闲数据块,并更新所述空闲数据块对应的数据块索引节点,所述数据块索引表包括多个数据块索引节点;Read a data block index table, find a free data block according to the data block index table, and update a data block index node corresponding to the idle data block, where the data block index table includes a plurality of data block index nodes;
    为所述空闲数据块中的块内索引表分配缓存;Allocating a cache for an in-block index table in the idle data block;
    循环读取每个通道的数据缓存区中的数据;Read the data in the data buffer area of each channel cyclically;
    若目标通道的数据缓存区中的数据的时间长度大于或等于所述预设时间长度,则读取所述目标通道的数据缓存区中的预设时间长度的数据,将所述预设时间长度的数据写入所述空闲数据块,并更新所述空闲数据块对应的数据块索引节点和所述缓存中的块内索引表,所述目标通道为所有通道中的任一个;If the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, then read the data of the preset time length in the data buffer area of the target channel, and change the preset time length The data is written into the idle data block, and the data block index node corresponding to the idle data block and the in-block index table in the cache are updated, and the target channel is any one of all channels;
    若所述空闲数据块写满,则将所述缓存中的块内索引表写入所述空闲数据块的尾部,并继续执行所述根据所述数据块索引表查找空闲数据块的步骤。If the free data block is full, write an in-block index table in the cache to the tail of the free data block, and continue to execute the step of finding an idle data block according to the data block index table.
  2. 根据权利要求1所述的数据存储方法,其特征在于,所述数据块索引节点包括文件归属戳和数据块类型;The data storage method according to claim 1, wherein the data block index node includes a file belonging stamp and a data block type;
    在所述读取数据块索引表之后,还包括:After the reading the data block index table, the method further includes:
    将所述数据块索引表缓存到内存中;Buffering the data block index table into memory;
    所述根据所述数据块索引表查找空闲数据块,并更新所述空闲数据块对应的数据块索引节点,包括:The searching for an idle data block according to the data block index table and updating a data block index node corresponding to the idle data block includes:
    遍历内存中的所述数据块索引表,得到最大的文件归属戳,并根据所述最大的文件归属戳确定待存储文件的文件归属戳;Traverse the data block index table in the memory to obtain the largest file attribution stamp, and determine the file attribution stamp of the file to be stored according to the largest file attribution stamp;
    根据所述数据块类型查找空闲数据块,并根据所述待存储文件的文件归属戳更新所述空闲数据块对应的数据块索引节点。Find an idle data block according to the data block type, and update a data block index node corresponding to the idle data block according to a file ownership stamp of the file to be stored.
  3. 根据权利要求1所述的数据存储方法,其特征在于,在所述循环读取每个通道的数据缓存区中的数据之后,还包括:The data storage method according to claim 1, after the loop reading data in a data buffer area of each channel, further comprising:
    若所述目标通道的数据缓存区中的数据的时间长度小于所述预设时间长度,则继续判断下一个通道的数据缓存区中的数据的时间长度是否大于或等于所述预设时间长度;If the time length of the data in the data buffer area of the target channel is shorter than the preset time length, continue to determine whether the time length of the data in the data buffer area of the next channel is greater than or equal to the preset time length;
    在所述更新所述空闲数据块对应的数据块索引节点和所述缓存中的块内索引表之后,还包括:After the updating the data block index node corresponding to the idle data block and the in-block index table in the cache, the method further includes:
    若所述空闲数据块未写满,则继续执行所述循环读取每个通道的数据缓存区中的数据的步骤。If the idle data block is not full, the step of reading the data in the data buffer area of each channel in a loop is continued.
  4. 根据权利要求1所述的数据存储方法,其特征在于,所述数据块索引节点包括文件归属戳;The data storage method according to claim 1, wherein the data block index node includes a file belonging stamp;
    所述数据存储方法还包括:The data storage method further includes:
    获取待查询信息;Obtain the information to be queried;
    遍历所述数据块索引表,将所有文件归属戳相同的数据块索引节点合并为一项文件描述信息;Traverse the data block index table, and merge all data block index nodes with the same file ownership stamp into one file description information;
    根据所述文件描述信息确定所述待查询信息对应的查询结果。A query result corresponding to the query information is determined according to the file description information.
  5. 根据权利要求4所述的数据存储方法,其特征在于,所述待查询信息包括待查询开始时间、待查询结束时间和待查询通道号,所述文件描述信息包括文件归属戳、文件开始时间、文件结束时间和文件包含的通道信息;The data storage method according to claim 4, wherein the information to be queried includes a start time to be queried, an end time to be queried, and a channel number to be queried, and the file description information includes a file belonging stamp, a file start time, File end time and channel information contained in the file;
    所述根据所述文件描述信息确定所述待查询信息对应的查询结果,包括:The determining a query result corresponding to the information to be queried based on the file description information includes:
    根据所述文件开始时间、所述文件结束时间和所述文件包含的通道信息,确定所述待查询开始时间、所述待查询结束时间和所述待查询通道号对应的文件信息列表。Determining a file information list corresponding to the start time to be queried, the end time to be queried, and the channel number to be queried according to the file start time, the file end time, and channel information contained in the file.
  6. 根据权利要求1所述的数据存储方法,其特征在于,还包括:The data storage method according to claim 1, further comprising:
    获取定位时间和待读取通道号;Get the positioning time and the channel number to be read;
    遍历所述数据块索引表,得到所述定位时间所属的定位数据块;Traverse the data block index table to obtain a positioning data block to which the positioning time belongs;
    读取所述定位数据块中的定位块内索引表,并将所述定位块内索引表缓存到内存中;Reading the index table in the positioning block in the positioning data block, and buffering the index table in the positioning block into memory;
    遍历内存中的所述定位块内索引表,确定所述定位时间和所述待读取通道号所在的定位块内索引节点,并根据所述定位块内索引节点中的数据偏移量,确定待读取数据的位置;Traverse the index table in the positioning block in memory, determine the positioning time and the index node in the positioning block where the channel number to be read is located, and determine according to the data offset in the index node in the positioning block The location of the data to be read;
    根据所述待读取数据的位置读取所述待读取数据;Reading the data to be read according to the position of the data to be read;
    在所述定位块内索引表中的所述定位块内索引节点之后的块内索引节点中,查找是否存在包含所述待读取通道号的目标块内索引节点;Searching for an in-block index node following the in-block index node in the in-block index table to find a target in-block index node that includes the channel number to be read;
    若存在所述目标块内索引节点,则将所述目标块内索引节点作为新的定位块内索引节点,并继续执行所述根据所述定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤;If the index node in the target block exists, use the index node in the target block as a new index node in the positioning block, and continue to perform the determining based on the data offset in the index node in the positioning block. Steps to read the location of the data;
    若不存在所述目标块内索引节点,则在所述数据块索引表中,查找是否存在文件归属戳与所述定位数据块对应的文件归属戳相同,且文件内部编号为所述定位数据块对应的文件内部编号加一的目标数据块索引节点;If the index node in the target block does not exist, in the data block index table, find whether a file home stamp is the same as the file home stamp corresponding to the positioning data block, and the file internal number is the positioning data block. The target data block index node corresponding to the internal number of the file plus one;
    若存在所述目标数据块索引节点,则将所述目标数据块索引节点对应的数据块作为新的定位数据块,读取所述新的定位数据块中的新的定位块内索引表,并将所述新的定位块内索引表缓存到内存中;If the target data block index node exists, use the data block corresponding to the target data block index node as a new positioning data block, read a new index table in the positioning block in the new positioning data block, and Cache the index table in the new positioning block into memory;
    遍历内存中的所述新的定位块内索引表,确定所述待读取通道号所在的定位块内索引节点,并继续执行所述根据所述定位块内索引节点中的数据偏移量,确定待读取数据的位置的步骤;Traversing the new index table in the positioning block in memory, determining the index node in the positioning block where the channel number to be read is located, and continuing to perform the according to the data offset in the index node in the positioning block, Steps to determine the location of the data to be read;
    若不存在所述目标数据块索引节点,则数据读取结束。If the target data block index node does not exist, data reading ends.
  7. 根据权利要求6所述的数据存储方法,其特征在于,所述数据块索引节点包括文件开始时间和文件结束时间;The data storage method according to claim 6, wherein the data block index node includes a file start time and a file end time;
    所述遍历所述数据块索引表,得到所述定位时间所属的定位数据块,包括:The traversing the data block index table to obtain a positioning data block to which the positioning time belongs includes:
    遍历所述数据块索引表,根据所述文件开始时间和所述文件结束时间得到所述定位时间所属的定位数据块。Traverse the data block index table, and obtain a positioning data block to which the positioning time belongs according to the file start time and the file end time.
  8. 一种数据存储系统,其特征在于,包括:A data storage system, comprising:
    空闲数据块查找模块,用于读取数据块索引表,根据所述数据块索引表查找空闲数据块,并更新所述空闲数据块对应的数据块索引节点,所述数据块索引表包括多个数据块索引节点;An idle data block search module is configured to read a data block index table, find an idle data block according to the data block index table, and update a data block index node corresponding to the idle data block. The data block index table includes a plurality of Data block index node;
    缓存分配模块,用于为所述空闲数据块中的块内索引表分配缓存;A cache allocation module, configured to allocate a cache for an in-block index table in the idle data block;
    循环读取模块,用于循环读取每个通道的数据缓存区中的数据;Cyclic reading module, which is used to read the data in the data buffer area of each channel cyclically;
    数据写入模块,用于若目标通道的数据缓存区中的数据的时间长度大于或等于所述预设时间长度,则读取所述目标通道的数据缓存区中的预设时间长度的数据,将所述预设时间长度的数据写入所述空闲数据块,并更新所述空闲数据块对应的数据块索引节点和所述缓存中的块内索引表,所述目标通道为所有通道中的任一个;A data writing module, configured to read data of a predetermined time length in the data buffer area of the target channel if the time length of the data in the data buffer area of the target channel is greater than or equal to the preset time length, Write the data of the preset time length into the idle data block, and update the data block index node corresponding to the idle data block and the in-block index table in the cache, and the target channel is the one in all channels Either
    索引表写入模块,用于若所述空闲数据块写满,则将所述缓存中的块内索引表写入所述空闲数据块的尾部,并继续执行所述根据所述数据块索引表查找空闲数据块的步骤。An index table writing module is configured to write an in-block index table in the cache to the tail of the idle data block if the free data block is full, and continue to execute the index table based on the data block. Steps to find free data blocks.
  9. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至7任一项所述数据存储方法的步骤。A terminal device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the computer program according to claims 1 to 1 when executing the computer program. Steps of the data storage method according to any one of 7.
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序被一个或多个处理器执行时实现如权利要求1至7任一项所述数据存储方法的步骤。A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the data according to any one of claims 1 to 7 is realized Store method steps.
PCT/CN2018/102490 2018-08-27 2018-08-27 Data storage method and system and terminal device WO2020041928A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880001157.2A CN110149803B (en) 2018-08-27 2018-08-27 Data storage method, system and terminal equipment
PCT/CN2018/102490 WO2020041928A1 (en) 2018-08-27 2018-08-27 Data storage method and system and terminal device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/102490 WO2020041928A1 (en) 2018-08-27 2018-08-27 Data storage method and system and terminal device

Publications (1)

Publication Number Publication Date
WO2020041928A1 true WO2020041928A1 (en) 2020-03-05

Family

ID=67588283

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/102490 WO2020041928A1 (en) 2018-08-27 2018-08-27 Data storage method and system and terminal device

Country Status (2)

Country Link
CN (1) CN110149803B (en)
WO (1) WO2020041928A1 (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651407A (en) * 2020-04-16 2020-09-11 广州南方卫星导航仪器有限公司 Original observation data recording method, electronic device, storage medium and system
CN111723056A (en) * 2020-06-09 2020-09-29 北京青云科技股份有限公司 Small file processing method, device, equipment and storage medium
CN111782656A (en) * 2020-06-30 2020-10-16 北京海益同展信息科技有限公司 Data reading and writing method and device
CN111859033A (en) * 2020-07-22 2020-10-30 北京金山云网络技术有限公司 IP library query method and device and IP library compression method and device
CN113064860A (en) * 2020-12-08 2021-07-02 上海金融期货信息技术有限公司 Dynamic data caching system and method
CN113076458A (en) * 2021-04-13 2021-07-06 鹏城实验室 In-network cache control method, system, storage medium and terminal equipment
CN113220693A (en) * 2021-06-02 2021-08-06 北京字节跳动网络技术有限公司 Computing storage separation system, data access method, medium and electronic device thereof
CN114371810A (en) * 2020-10-15 2022-04-19 中国移动通信集团设计院有限公司 Data storage method and device of HDFS
CN115905219A (en) * 2022-11-04 2023-04-04 上海威固信息技术股份有限公司 Data storage driving system for multi-channel data storage cloud library and transmission method thereof
CN117931098A (en) * 2024-03-22 2024-04-26 江西云眼视界科技股份有限公司 Edge side event storage method, system, storage medium and computer
CN118069074A (en) * 2024-04-22 2024-05-24 联想凌拓科技有限公司 Data processing method and device, storage medium and computer program product

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111399762B (en) 2019-11-27 2021-06-18 杭州海康威视系统技术有限公司 Data storage method, device and storage system
CN111241090B (en) * 2019-12-23 2023-11-10 华为技术有限公司 Method and device for managing data index in storage system
CN111124313A (en) * 2019-12-24 2020-05-08 宁波三星医疗电气股份有限公司 Data reading and writing method and device for power acquisition terminal and electronic equipment
CN111025068B (en) * 2019-12-24 2022-05-20 宁波三星医疗电气股份有限公司 Ammeter load curve data reading method and device and electronic equipment
CN111190869A (en) * 2019-12-27 2020-05-22 深圳市恒扬数据股份有限公司 File storage method and terminal
CN111274295B (en) * 2020-01-12 2022-07-08 苏州浪潮智能科技有限公司 Method, device, equipment and medium for rapidly loading data in database
CN111309678B (en) * 2020-02-22 2023-01-03 呼和浩特市奥祥电力自动化有限公司 Data circular storage method and network message recording and analyzing device
CN111651127B (en) * 2020-06-10 2023-05-02 杭州海康威视数字技术股份有限公司 Monitoring data storage method and device based on shingled magnetic recording disk
CN113568868B (en) * 2021-07-28 2024-02-06 重庆紫光华山智安科技有限公司 File system management method, system, electronic equipment and medium
CN114116795B (en) * 2021-11-01 2022-12-20 北京力控元通科技有限公司 Data storage and query method, device, storage medium and electronic equipment
CN114153394A (en) * 2021-11-30 2022-03-08 浙江大华技术股份有限公司 Data storage management method, device and equipment
CN114385075A (en) * 2021-12-01 2022-04-22 浙江大华技术股份有限公司 Storage method and query method of characteristic value, electronic device and storage medium
CN114816277B (en) * 2022-06-30 2022-11-11 广东睿江云计算股份有限公司 Control method and control system for guaranteeing sequence of file data blocks
CN116112456B (en) * 2023-02-01 2024-02-13 镁佳(北京)科技有限公司 BAP protocol-based data caching method, device, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101316334A (en) * 2008-07-07 2008-12-03 中兴通讯股份有限公司 Method for processing television media data and television mobile phone
US20100174846A1 (en) * 2009-01-05 2010-07-08 Alexander Paley Nonvolatile Memory With Write Cache Having Flush/Eviction Methods
CN102332030A (en) * 2011-10-17 2012-01-25 中国科学院计算技术研究所 Data storing, managing and inquiring method and system for distributed key-value storage system
CN104393962A (en) * 2014-12-12 2015-03-04 成都朗锐芯科技发展有限公司 Multi-way E1 deframing system

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6252789B1 (en) * 2000-06-14 2001-06-26 Netlogic Microsystems, Inc. Inter-row configurability of content addressable memory
US8060481B1 (en) * 2005-06-30 2011-11-15 Symantec Operating Corporation Time indexed file system
WO2011020360A1 (en) * 2009-08-19 2011-02-24 北京书生国际信息技术有限公司 Document storage method
KR101954995B1 (en) * 2011-04-27 2019-05-31 시게이트 테크놀로지 엘엘씨 Method of merging data written on storage media, method for controlling write operation for storage media, storage device, computer system, and storage medium thereof
US8706971B1 (en) * 2012-03-14 2014-04-22 Netapp, Inc. Caching and deduplication of data blocks in cache memory
CN103310008B (en) * 2013-06-28 2018-06-01 安科智慧城市技术(中国)有限公司 A kind of cloud control server and its file index method
CN106302604B (en) * 2015-06-05 2020-09-11 腾讯科技(深圳)有限公司 Data transmission method and device
CN107391023B (en) * 2016-05-16 2021-01-22 深圳市中兴微电子技术有限公司 Multi-channel data memory and access method and device thereof
CN108255408B (en) * 2016-12-28 2021-03-23 中国电信股份有限公司 Data storage method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101316334A (en) * 2008-07-07 2008-12-03 中兴通讯股份有限公司 Method for processing television media data and television mobile phone
US20100174846A1 (en) * 2009-01-05 2010-07-08 Alexander Paley Nonvolatile Memory With Write Cache Having Flush/Eviction Methods
CN102332030A (en) * 2011-10-17 2012-01-25 中国科学院计算技术研究所 Data storing, managing and inquiring method and system for distributed key-value storage system
CN104393962A (en) * 2014-12-12 2015-03-04 成都朗锐芯科技发展有限公司 Multi-way E1 deframing system

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651407A (en) * 2020-04-16 2020-09-11 广州南方卫星导航仪器有限公司 Original observation data recording method, electronic device, storage medium and system
CN111723056A (en) * 2020-06-09 2020-09-29 北京青云科技股份有限公司 Small file processing method, device, equipment and storage medium
CN111723056B (en) * 2020-06-09 2024-04-30 北京青云科技股份有限公司 Small file processing method, device, equipment and storage medium
CN111782656A (en) * 2020-06-30 2020-10-16 北京海益同展信息科技有限公司 Data reading and writing method and device
CN111782656B (en) * 2020-06-30 2024-04-12 京东科技信息技术有限公司 Data reading and writing method and device
CN111859033B (en) * 2020-07-22 2023-10-27 北京金山云网络技术有限公司 IP library query method and device and IP library compression method and device
CN111859033A (en) * 2020-07-22 2020-10-30 北京金山云网络技术有限公司 IP library query method and device and IP library compression method and device
CN114371810A (en) * 2020-10-15 2022-04-19 中国移动通信集团设计院有限公司 Data storage method and device of HDFS
CN114371810B (en) * 2020-10-15 2023-10-27 中国移动通信集团设计院有限公司 Data storage method and device of HDFS
CN113064860A (en) * 2020-12-08 2021-07-02 上海金融期货信息技术有限公司 Dynamic data caching system and method
CN113076458B (en) * 2021-04-13 2024-02-06 鹏城实验室 Method, system, storage medium and terminal equipment for controlling in-network cache
CN113076458A (en) * 2021-04-13 2021-07-06 鹏城实验室 In-network cache control method, system, storage medium and terminal equipment
CN113220693B (en) * 2021-06-02 2023-10-20 北京火山引擎科技有限公司 Computing storage separation system, data access method thereof, medium and electronic equipment
CN113220693A (en) * 2021-06-02 2021-08-06 北京字节跳动网络技术有限公司 Computing storage separation system, data access method, medium and electronic device thereof
CN115905219B (en) * 2022-11-04 2023-09-19 上海威固信息技术股份有限公司 Data storage driving system for multichannel data cloud storage library and transmission method thereof
CN115905219A (en) * 2022-11-04 2023-04-04 上海威固信息技术股份有限公司 Data storage driving system for multi-channel data storage cloud library and transmission method thereof
CN117931098A (en) * 2024-03-22 2024-04-26 江西云眼视界科技股份有限公司 Edge side event storage method, system, storage medium and computer
CN117931098B (en) * 2024-03-22 2024-06-07 江西云眼视界科技股份有限公司 Edge side event storage method, system, storage medium and computer
CN118069074A (en) * 2024-04-22 2024-05-24 联想凌拓科技有限公司 Data processing method and device, storage medium and computer program product

Also Published As

Publication number Publication date
CN110149803B (en) 2023-06-09
CN110149803A (en) 2019-08-20

Similar Documents

Publication Publication Date Title
WO2020041928A1 (en) Data storage method and system and terminal device
US11238098B2 (en) Heterogenous key-value sets in tree database
US10303596B2 (en) Read-write control method for memory, and corresponding memory and server
US9047330B2 (en) Index compression in databases
WO2019062574A1 (en) Metadata query method and device
CN110555001B (en) Data processing method, device, terminal and medium
CN102129458A (en) Method and device for storing relational database
CN107766374B (en) Optimization method and system for storage and reading of massive small files
CN109240607B (en) File reading method and device
CN110147203B (en) File management method and device, electronic equipment and storage medium
CN109240944B (en) Data reading and writing method based on variable-length cache line
WO2017161540A1 (en) Data query method, data object storage method and data system
WO2013075306A1 (en) Data access method and device
CN116257523A (en) Column type storage indexing method and device based on nonvolatile memory
CN115878027A (en) Storage object processing method and device, terminal and storage medium
CN113656397A (en) Index construction and query method and device for time series data
US10311026B2 (en) Compressed data layout for optimizing data transactions
CN108804571B (en) Data storage method, device and equipment
CN114297196B (en) Metadata storage method and device, electronic equipment and storage medium
CN113535092B (en) Storage engine, method and readable medium for reducing memory metadata
CN115454353A (en) High-speed writing and query method for space application data
CN112131226A (en) Index obtaining method, data query method and related device
CN112015672A (en) Data processing method, device, equipment and storage medium in storage system
CN106991021B (en) Method and system for constructing new data file from existing data file
CN112380174B (en) XFS file system analysis method containing deleted files, terminal device and storage medium

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18932250

Country of ref document: EP

Kind code of ref document: A1