Background
The ordering is to arrange the unordered data elements according to the keyword sequence by a certain method. Ordering is a type of operation that is often performed in a computer, and its purpose is to adjust a set of "unordered" recording sequences to "ordered" recording sequences, which is a very important, research and application-wide class of problems in the field of computer applications. For example, ordering algorithms have found very wide application in data processing, databases, data compression, distributed computing, image processing, and computer graphics. Meanwhile, the sorting algorithm is very many, related algorithms are also applied to various fields, but the traditional multi-sorting algorithm is often not very good in application effect on time sequence data.
Time series data flow in an on-board avionics system is the most typical data, sensors are constantly generating streaming data at all times, a large amount of data arrives continuously at a very fast speed in a short time, the data amount is often infinite, the avionics system does not store the whole data, the data changes dynamically with time, on-board software needs to update the data in real time, and the data needs to be ordered by importance degree, distance, target attribute and the like. In the ordered data set, when a new data set comes, the earliest data needs to be removed, and the new data set is inserted into the ordered data set.
Although the ranking method is relatively mature, the time series based multi-class ranking method is not available in avionics systems.
Disclosure of Invention
The method and the device are used for rapidly deleting, inserting and sequencing the data flow targets in the avionics system, so that the memory overhead is saved, and the time consumption is saved.
The invention provides a multi-classification ordering method based on a time sequence data set, which comprises the following steps:
establishing a position mapping table and a time mapping table;
Inserting first data into a sub-data set based on the position mapping table and the time mapping table, wherein the sub-data set is established according to the attribute of the first data;
and ordering the data in the sub data set based on the attribute of the first data, and updating the position mapping table and the time mapping table based on the sequence of the ordered data.
Preferably, the method further comprises:
Under the condition that the database is full, inputting second data, deleting sub data in the first data based on the position mapping table, wherein the sub data is the data with earliest writing time in the database;
determining a moving direction of remaining data in the database based on the size of the sub-data set and the position of the sub-data;
And moving the residual data based on the moving direction to obtain a target position, and inserting the second data into the target position.
Preferably, the target location is a location in a target sub-data set.
Preferably, after the second data is inserted into the target position, the method further includes:
And ordering the data in the target sub-data set based on the attribute of the target sub-data set, and updating the time mapping table and the position mapping table based on the sequence of the ordered data.
Preferably, the establishing a location mapping table includes:
And establishing a position mapping table based on the position relation between the first data and the ordering data.
Preferably, the establishing the time mapping table includes:
and establishing a time mapping table based on the time relation between the first data and the ordering data.
Preferably, the attribute of the first data is used for classifying the first data.
Preferably, the first data is written into the database at a time earlier than the second data is written into the database.
The beneficial technical effects of the invention are as follows:
the invention provides a multi-classification method based on time sequence, which can quickly locate the earliest data through a suggested position mapping table and a time mapping table, reject the data, insert and sort the data on the basis of the existing classification sorting, reduce the memory overhead, shorten the sorting time and meet the real-time performance of multi-classification sorting of the data flow of the airborne software of an avionics system.
Detailed Description
Referring to fig. 1, in a first embodiment, the present invention provides a multi-classification ordering method based on a time-series dataset, including:
step 101, a position mapping table and a time mapping table are established.
In the embodiment of the application, a position mapping table is established based on the position relation between the first data and the ordering data, and a time mapping table is established based on the time relation between the first data and the ordering data.
Step 102, inserting the first data into the sub-data set based on the location mapping table and the time mapping table.
Wherein the sub-data set is established based on the attribute of the first data.
Step 103, sorting the data in the sub data set based on the attribute of the first data, and updating the position mapping table and the time mapping table based on the sequence of the sorted data.
The attribute of the first data is used for classifying the first data.
Step 104, under the condition that the database is full, inputting second data, and deleting sub-data in the first data based on the position mapping table;
The sub data is the data with the earliest time of writing into the database, and the time of writing the first data into the database is earlier than the time of writing the second data into the database.
And 105, determining the moving direction of the residual data in the database based on the size of the sub-data set and the position of the sub-data, moving the residual data based on the moving direction to obtain a target position, and inserting second data into the target position.
And 106, sorting the data in the target sub-data set based on the attribute of the target sub-data set, and updating the time mapping table and the position mapping table based on the sequence of the sorted data.
In a second embodiment, the method for sorting multiple categories based on a time sequence data set mainly comprises four modules:
position mapping table
Wherein the avionics system does not store all time stream data in a conditional way, the onboard software needs to update the data in real time, eliminates excessive data according to time and sorts the data, but after sorting, the sorting of the data sets is not sorted according to time, the earliest data set cannot be directly removed, and the method can save the memory and quickly locate the time attribute of each data by establishing the position mapping table to index the data. The mapping table is mapped to be the sequence position of the data set after sequencing, when a new sequence comes, the earliest data is removed through the mapping table, the mapping table is updated, and the data set is updated, which is a forward deleting process.
Time mapping table
In order to establish a connection between data and the position mapping table and update the data quickly, the invention records the time sequence of each data of the data set at the same time, and can quickly locate the data set which arrives first through the position mapping table because the data which arrives first in the data needs to be removed, but can directly locate the position of the position mapping table by establishing the time mapping table when the data is ordered, and can update the data set and then update the time mapping table and then update the position mapping table when the data ordering position changes, thus completing the reverse updating.
Sub-dataset size statistics record table
The data source in the onboard software is a data source with known classification, under the condition that the classification and the ordering sequence of the data sets are known, the data quantity of each sub-classification can be recorded, when new data arrives, which category is judged through known attributes, then the new data set is inserted into the head of the category by calculating the quantity of the known data set, and the position mapping table and the time mapping table are updated simultaneously.
Multi-class ranking
The invention classifies time sequence data, adopts a mapping table method to record time and position information of the data, can rapidly locate earliest data, eliminates the earliest data, rapidly inserts new data into the data which is already ordered according to classification, and then performs bubbling ordering under subclassification.
In the third embodiment, the data set size is 10, and 3 classification categories are assumed, namely A, AA and AAA, arranged in sequence as shown in Table 1.
TABLE 1
When new data fff arrives, the following steps are performed:
1. And deleting the position of the earliest data in the position mapping table, namely the number 6 bit, through the position mapping table, and updating the number 2 of the sub-data categories.
2. Calculating the fff type starting position, 5+2=7, moving the data, and judging the data moving direction.
3. The new data fff to 8 positions are inserted and the time map and position map and sub-data set sizes are updated.
4. And sorting in the sub-categories, and updating the position mapping table and the time mapping table to obtain the table 2.
TABLE 2
The invention performs multi-classification sorting on time series data sets, establishes a time mapping table and a position mapping table, and rapidly inserts new data sets into the data sets through the number of sub-class data sets, and sorts the new data only in the classification of the new data sets. The invention provides a method for sequencing time series data sets, saves memory overhead and shortens sequencing time.