CN109726176B - Method for rapidly storing and inquiring railway signal electrical equipment data - Google Patents

Method for rapidly storing and inquiring railway signal electrical equipment data Download PDF

Info

Publication number
CN109726176B
CN109726176B CN201811509714.XA CN201811509714A CN109726176B CN 109726176 B CN109726176 B CN 109726176B CN 201811509714 A CN201811509714 A CN 201811509714A CN 109726176 B CN109726176 B CN 109726176B
Authority
CN
China
Prior art keywords
data
index
block
record
blocks
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811509714.XA
Other languages
Chinese (zh)
Other versions
CN109726176A (en
Inventor
张硕
刘伟
石成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Henan Splendor Science and Technology Co Ltd
Original Assignee
Henan Splendor Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Henan Splendor Science and Technology Co Ltd filed Critical Henan Splendor Science and Technology Co Ltd
Priority to CN201811509714.XA priority Critical patent/CN109726176B/en
Publication of CN109726176A publication Critical patent/CN109726176A/en
Application granted granted Critical
Publication of CN109726176B publication Critical patent/CN109726176B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

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

Abstract

The invention provides a method for quickly storing and inquiring railway signal electrical equipment data, which comprises the following steps: creating a null data file; storing the data records in a data block of the empty data file according to the data type in a time sequence; dividing the data block into a plurality of sub data blocks; extracting the storage time and the position offset of a first data record in the sub-data block as index records; storing the index record in an index block of the empty data file; the method for inquiring the railway signal electrical equipment data comprises the following steps: the file reader obtains all corresponding index blocks according to the input data types and then obtains corresponding index records in the index blocks according to the input time parameters; and traversing the corresponding data block according to the index record, searching the corresponding sub-data block, decompressing the data record of the sub-data block, and returning a data set. The invention has the advantages of strong practicability, cyclic storage and quick positioning.

Description

Rapid storage and query method for railway signal electrical equipment data
Technical Field
The invention relates to the technical field of data storage and query, in particular to a method for quickly storing and querying data of railway signal electrical equipment.
Background
The data of the railway signal equipment are mainly divided into switching value, analog value and recording curve data, and the forms of the three data are different. The switching value has three modes: unknown, suck up and drop down; the analog quantity is continuous linear data; a log is a collection of sets of data. The data is large and complex, the requirement of circular storage and adaptability to different data versions of a station needs to be met, the total amount and the sequence of various data with different versions are also different, and a data storage mode which can completely record the three types of data and has the functions of rapid storage and query is urgently needed to be found.
In order to solve the above problems, people always seek an ideal technical solution.
Disclosure of Invention
The invention aims to overcome the defects in the prior art and provide a method for quickly storing and inquiring railway signal electrical equipment data.
In order to achieve the purpose, the invention adopts the technical scheme that: a method for rapidly storing and inquiring railway signal electrical equipment data comprises the following steps:
creating an empty data file to circularly store the railway signal electrical equipment data; the empty data file comprises a plurality of data blocks and a plurality of index blocks;
converting railway signal electrical equipment data to be stored into a binary array, and then compressing the binary array to be used as data record; storing the data records in a data block of the empty data file according to a data type in a time sequence;
dividing the data block into a plurality of sub data blocks; each sub data block comprises N data records;
extracting the storage time and the position offset of a first data record in the sub data block as index records; storing the index record in an index block of the empty data file;
the method for inquiring the railway signal electrical equipment data comprises the following steps:
creating a file reader, and inputting a data type and a time parameter by a user;
the file reader obtains all corresponding index blocks according to the input data types and then obtains corresponding index records in the index blocks according to the input time parameters;
and traversing the corresponding data blocks according to the index records, searching the corresponding sub data blocks, decompressing the data records of the sub data blocks, and returning a data set.
Based on the above, the data blocks are divided into switching value data blocks, analog value data blocks and recording curve data blocks; the index blocks are divided into switching value index blocks, analog value index blocks and recording curve index blocks;
the switching value data block corresponds to the switching value index block, the analog value data block corresponds to the analog value index block, and the recording curve data block corresponds to the recording curve index block.
Based on the above, the empty data file includes the number of data blocks, the size of the data blocks, the index interval, and the set of data types.
Based on the above, the method for rapidly storing the railway signal electrical equipment data specifically comprises the following steps:
step a, inputting a data record to be stored, and if the data type of the data record is a defined data type, turning to step b;
otherwise, storing the data type of the data record in the data type set, allocating an empty data block and an index block for the data type, and then turning to the step b;
b, if the data type is not the event type, turning to the step c;
otherwise, adding an event record in the data blocks of all data types, and ending the storage flow of the railway signal electrical equipment data;
step c, if the data block or the index block corresponding to the data type is not fully written, turning to step e;
otherwise, acquiring a writer of the next empty data file, writing the overflow data record, and ending the storage process of the railway signal electrical equipment data;
e, if the requirement of writing the index record is not met, acquiring a data block corresponding to the data type, and turning to the step f;
otherwise, acquiring an index block corresponding to the data type, and judging whether the residual space of the index block meets the storage requirement:
if the storage requirement is met, directly compressing the index record and writing the compressed index record into the index block, updating the used space of the index block, and turning to the step h;
if the storage requirement is not met, distributing a new index block, compressing the index record and writing the compressed index record into the index block, updating the used space of the index block, and turning to the step h;
step f, if the residual space of the data block meets the storage requirement, step g; otherwise, distributing a new data block, and then turning to the step g;
g, after converting the railway signal electrical equipment data to be stored into a binary array, compressing the binary array and writing the binary array into the data block; updating the write offset pointer of the data type, and then turning to the step h;
and h, updating the file header, the data type table and the block distribution table, and ending the storage flow of the railway signal electrical equipment data.
Compared with the prior art, the method has outstanding substantive characteristics and remarkable progress, and particularly provides a method for rapidly storing and inquiring railway signal electrical equipment data, a set of compressed binary file storage structure is designed, all data are converted into binary data groups, and different types of data are stored in a circulating mode; when reading, the index block is firstly read by utilizing the type and the time range of the data to be acquired, the adjacent index record is read from the index block, the data record is quickly positioned according to the record information of the index record, and the efficient data query and acquisition mode is realized.
Drawings
FIG. 1 is a flow chart illustrating a data storage method according to the present invention.
FIG. 2 is a flow chart of a data query method of the present invention.
Detailed Description
The technical solution of the present invention is further described in detail by the following embodiments.
Example 1
As shown in fig. 1 and fig. 2, a method for rapidly storing and querying railway signal electrical equipment data includes:
creating an empty data file to circularly store the railway signal electrical equipment data; the empty data file comprises a plurality of data blocks and a plurality of index blocks;
converting railway signal electrical equipment data to be stored into a binary array, and then compressing the binary array to be used as data record; storing the data records in a data block of the empty data file according to a data type in a time sequence;
dividing the data block into a plurality of sub data blocks; each sub data block comprises N data records;
extracting the storage time and the position offset of a first data record in the sub data block as index records; storing the index record in an index block of the empty data file;
the method for inquiring the railway signal electrical equipment data comprises the following steps:
creating a file reader, and inputting a data type and a time parameter by a user;
the file reader obtains all corresponding index blocks according to the input data types and then obtains corresponding index records in the index blocks according to the input time parameters;
and traversing the corresponding data blocks according to the index records, searching the corresponding sub data blocks, decompressing the data records of the sub data blocks, and returning a data set.
Specifically, the data blocks are divided into switching value data blocks, analog value data blocks and recording curve data blocks; the index blocks are divided into switching value index blocks, analog value index blocks and recording curve index blocks; the switching value data blocks and the switching value index blocks, the analog value data blocks and the analog value index blocks, and the recording curve data blocks and the recording curve index blocks are in one-to-one correspondence.
Specifically, the data record is a data set of switching value data, analog value data or recording curve data in a preset time region. The index record is convenient to be positioned on the target data record quickly through the index record in reading, and the reading speed is improved.
Example 2
The method for rapidly storing the railway signal electrical equipment data specifically comprises the following steps:
step a, inputting a data record to be stored, and if the data type of the data record is a defined data type, turning to step b;
otherwise, storing the data type of the data record in the data type set, allocating an empty data block and an index block for the data type, and then turning to the step b;
b, if the data type is not the event type, turning to the step c;
otherwise, adding an event record in the data blocks of all data types, and ending the storage flow of the railway signal electrical equipment data;
step c, if the data block or the index block corresponding to the data type is not fully written, turning to step e;
otherwise, acquiring a writer of the next empty data file, writing the overflow data record, and ending the storage process of the railway signal electrical equipment data;
step e, if the requirement of writing the index record is not satisfied, acquiring a data block corresponding to the data type, and turning to step f;
otherwise, acquiring an index block corresponding to the data type, and judging whether the residual space of the index block meets the storage requirement:
if the storage requirement is met, directly compressing the index record and writing the compressed index record into the index block, updating the used space of the index block, and turning to the step h;
if the storage requirement is not met, distributing a new index block, compressing the index record and writing the compressed index record into the index block, updating the used space of the index block, and turning to the step h;
step f, if the residual space of the data block meets the storage requirement, step g; otherwise, distributing a new data block, and then turning to the step g;
g, after converting the railway signal electrical equipment data to be stored into a binary array, compressing the binary array and writing the binary array into the data block; updating the write offset pointer of the data type, and then turning to the step h;
and h, updating the file header, the data type table and the block distribution table, and ending the storage flow of the railway signal electrical equipment data.
Each data type is independently distributed with a data block and an index block, the data record is stored in the data block, and the index record is stored in the index block. And not all data records have index records, the index records only comprise key records, and the storage time and the position offset of the first data record in the sub data block are extracted as the index records, so that the system can conveniently and quickly locate and search. For example, each of the sub data blocks contains 100 data records, i.e., an index record is added to each 100 data records.
After the data block or the index block is fully written, an empty data block or an index block can be applied to be allocated, and simultaneously, the block number is written into a block allocation table for unified management. A new empty data file can be automatically generated after an empty data file is fully written, the file header of the new empty data file is consistent with the data type set, a new data block and an index block can be applied for each data type in the new empty data file, and the block information in the block allocation table of the first fully written file can be recorded again after the number of the empty data files reaches the limit value, so that the circular storage of data is realized.
Example 3
Applying for creating empty data files, wherein each empty data file comprises a file header, a data type table, a block allocation table, a data block and an index block; the specific file structure is as follows:
Figure DEST_PATH_IMAGE001
when the empty data file is generated, the file header information of the empty data file is fixed; the size of the empty data file is set to 2048 bytes; the file header is used for recording the version number, the data format version, the number of data blocks, the size of each data block, the size of a data type table, the size of a block allocation table, the current recording number and the starting recording number of the empty data file; as shown in the following table:
Figure 604046DEST_PATH_IMAGE002
when the empty data file is generated, the data type table information of the empty data file is already fixed. The size of the data type table is set to 2048 bytes and used for recording the size of the data type table, the number of the data types and the specific data types; the data type is set to 256 bytes and is used for recording a data type ID, a data type name, a data block head block number of the type, a current writing position, an index block head block number, a current writing position of an index block, the number of data records and the number of index records. As shown in the following table:
description of field Offset byte Occupied byte
Directory area size (including self, byte) 0 4
Number of data types 4 4
Retention 8 56
0 th data type 64 256
…… …… ……
Number n-1According to type 256*(n-1)+64 256
Free area xx xxx
Description of field Offset byte Occupied byte
Data type 0 4
Data type name 4 128
Data block head number 132 4
Current writing position of data block 136 4
Index Block head Block number 140 4
Current writing position of index block 146 4
Number of data records 148 4
Number of index records 152 4
Total number of bytes of data record 156 8
Recording data format 164 1
Whether to store an index 165 1
Retention 166 90
When the empty data file is generated, the format of the block allocation table of the empty data file is fixed, and the allocation mark and the use space of each block are continuously updated when data is written. The block allocation table is used for recording the size of the allocation table, the number of blocks allocated to the file and the allocation record of each block; each block contains an allocation flag for the block (whether it is a free block, if not pointing to the next block number) and the space that the block has used. As shown in the following table:
description of field Offset byte Occupied byte
Allocation table size (including self) 0 4
Number of blocks 4 4
Retention 8 120
Block 0 allocation record 128 10
…… …… ……
Fast n-1 allocation recording 128+(n-1)*10 10
Free area
Block allocation entry:
block allocation flag 0 4
Blocks already use space (bytes) 4 4
Version [1 ] of recording format in data block] 8 2
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention and not to limit it; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art will understand that: modifications to the specific embodiments of the invention or equivalent substitutions for parts of the technical features may be made; without departing from the spirit of the invention, it is intended to cover all modifications within the scope of the invention as claimed.

Claims (4)

1. A method for rapidly storing and inquiring railway signal electrical equipment data is characterized by comprising the following steps:
creating an empty data file to circularly store the railway signal electrical equipment data; the empty data file comprises a plurality of data blocks and a plurality of index blocks;
converting railway signal electrical equipment data to be stored into a binary array, and then compressing the binary array to be used as data record; storing the data records in a data block of the empty data file according to a data type in a time sequence;
dividing the data block into a plurality of sub data blocks; each sub data block comprises N data records;
extracting the storage time and the position offset of a first data record in the sub data block as index records; storing the index record in an index block of the empty data file;
the method for inquiring the railway signal electrical equipment data comprises the following steps:
creating a file reader, and inputting a data type and a time parameter by a user;
the file reader obtains all corresponding index blocks according to the input data types and then obtains corresponding index records in the index blocks according to the input time parameters;
and traversing the corresponding data block according to the index record, searching the corresponding sub-data block, decompressing the data record of the sub-data block, and returning a data set.
2. The method for rapidly storing and querying railway signal electrical equipment data as claimed in claim 1, wherein: the data blocks are divided into switching value data blocks, analog value data blocks and recording curve data blocks; the index blocks are divided into switching value index blocks, analog value index blocks and recording curve index blocks;
the switching value data block corresponds to the switching value index block, the analog value data block corresponds to the analog value index block, and the recording curve data block corresponds to the recording curve index block.
3. The method for rapidly storing and querying railway signal electrical equipment data as claimed in claim 1, wherein: the empty data file includes a number of data blocks, a size of the data blocks, an index interval, and a set of data types.
4. The method for rapidly storing and querying the railway signal electrical equipment data according to claim 2, wherein the method for rapidly storing the railway signal electrical equipment data specifically comprises the following steps:
step a, inputting a data record to be stored, and if the data type of the data record is a defined data type, turning to step b;
otherwise, storing the data type of the data record in the data type set, allocating an empty data block and an index block for the data type, and then turning to the step b;
b, if the data type is not the event type, turning to the step c;
otherwise, adding an event record in the data blocks of all data types, and ending the storage flow of the railway signal electrical equipment data;
step c, if the data block or the index block corresponding to the data type is not fully written, turning to step e;
otherwise, acquiring a writer of the next empty data file, writing the overflow data record, and ending the storage process of the railway signal electrical equipment data;
step e, if the requirement of writing the index record is not satisfied, acquiring a data block corresponding to the data type, and turning to step f;
otherwise, acquiring an index block corresponding to the data type, and judging whether the residual space of the index block meets the storage requirement:
if the storage requirement is met, directly compressing the index record and writing the compressed index record into the index block, updating the used space of the index block, and turning to the step h;
if the storage requirement is not met, distributing a new index block, compressing the index record and writing the compressed index record into the index block, updating the used space of the index block, and turning to the step h;
step f, if the residual space of the data block meets the storage requirement, step g; otherwise, distributing a new data block, and then turning to the step g;
g, after converting the railway signal electrical equipment data to be stored into a binary array, compressing the binary array and writing the binary array into the data block; updating the write offset pointer of the data type, and then turning to the step h;
and h, updating the file header, the data type table and the block distribution table, and ending the storage process of the railway signal electrical equipment data.
CN201811509714.XA 2018-12-11 2018-12-11 Method for rapidly storing and inquiring railway signal electrical equipment data Active CN109726176B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811509714.XA CN109726176B (en) 2018-12-11 2018-12-11 Method for rapidly storing and inquiring railway signal electrical equipment data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811509714.XA CN109726176B (en) 2018-12-11 2018-12-11 Method for rapidly storing and inquiring railway signal electrical equipment data

Publications (2)

Publication Number Publication Date
CN109726176A CN109726176A (en) 2019-05-07
CN109726176B true CN109726176B (en) 2022-12-06

Family

ID=66294889

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811509714.XA Active CN109726176B (en) 2018-12-11 2018-12-11 Method for rapidly storing and inquiring railway signal electrical equipment data

Country Status (1)

Country Link
CN (1) CN109726176B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112084145A (en) * 2020-09-04 2020-12-15 深圳科安达电子科技股份有限公司 Data storage and reading method for railway signal centralized monitoring system
CN112523863B (en) * 2020-11-18 2022-04-05 中国航空工业集团公司西安航空计算技术研究所 Electric control engine cycle monitoring method based on combination of long meters and short meters
CN112699146A (en) * 2020-12-31 2021-04-23 新奥数能科技有限公司 Data pushing method and device based on general information model, server and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1277213C (en) * 2004-12-31 2006-09-27 大唐微电子技术有限公司 A flash memory file system management method
CN103577339B (en) * 2012-07-27 2018-01-30 深圳市腾讯计算机系统有限公司 A kind of date storage method and system

Also Published As

Publication number Publication date
CN109726176A (en) 2019-05-07

Similar Documents

Publication Publication Date Title
CN109726176B (en) Method for rapidly storing and inquiring railway signal electrical equipment data
CN104346357B (en) The file access method and system of a kind of built-in terminal
CN102663090B (en) Method and device for inquiry metadata
KR100285265B1 (en) Db management system and inverted index storage structure using sub-index and large-capacity object
CN109739811B (en) Storage method supporting two-dimensional query of mass monitoring data
CN104462141B (en) Method, system and the storage engines device of a kind of data storage and inquiry
CN101782922B (en) Multi-level bucket hashing index method for searching mass data
CN101656094A (en) Data storage method and storage device
CN101464901B (en) Object search method in object storage device
CN102446184B (en) Industrial data storage and index method based on time series
CN101620617A (en) Method and device for searching and processing log file
US20110040761A1 (en) Estimation of postings list length in a search system using an approximation table
CN103745007A (en) File managing method and device
CN102622434A (en) Data storage method, data searching method and device
CN104035993A (en) Memory search method for e-books, e-book management system and reading system
CN102253985B (en) File system data management method and system
KR101654314B1 (en) Distributed processing system in spatial data and method for operating the same
CN102609492A (en) Metadata management method supporting variable table modes
CN101196916A (en) Method and device for fragment storage file
CN100359592C (en) Data storage method for hard disk for camera-shooting and recording device
CN109521954B (en) Distribution network FTU fixed point file management method and device
US20080071732A1 (en) Master/slave index in computer systems
CN101894098B (en) Embedded font data processing method and device
CN101533675B (en) Scanning and management method for flash memory medium
CN102915324A (en) Data storing and retrieving device and data storing and retrieving method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant