Data storage method, device, terminal equipment and storage medium
By distinguishing and managing hot data and cold data according to the storage duration of time series data, the problem of low efficiency of time series data storage and query is solved, and efficient data storage and query are achieved.
Patent Information
- Application Number
- CN202010524018.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-10
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-06-10
AI Technical Summary
In the existing technology, the huge amount of time series data results in low query efficiency, and the existing storage methods cannot effectively handle the storage and query problems of time series data.
By dividing time series data into hot data and cold data according to their storage duration, and saving them in hot data storage nodes and cold data storage nodes respectively, hot data storage nodes are used to quickly respond to hot data query requests, and cold data storage nodes are used to quickly respond to hot data query requests. In response to the cold data query request, hot data will be deleted from the hot data storage node after the storage period exceeds the preset period.
It improves the query efficiency of hot data, reduces the data volume of hot data storage nodes, ensures that cold data can respond to query requests in a timely manner when needed, and achieves efficient data storage and query.
Smart Images

Figure CN113779426B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular, relates to a data storage method, apparatus, terminal equipment and storage medium. Background Art
[0002] In life, we often need to continuously monitor and record the status data of the same target in the time dimension, such as continuously recording the surveillance image data of the same designated area at different time points, the meteorological data of the same area at different time points, etc. The status data of the same target in the time dimension can be called time series data. As time goes by, new time series data (i.e., status data corresponding to new time points) will be continuously generated, so the amount of time series data is usually huge.
[0003] In the prior art, time series data is usually stored centrally or through random and disordered data sharding. However, due to the huge amount of time series data, the existing storage method will result in low efficiency of subsequent data query. Summary of the invention
[0004] In view of this, embodiments of the present application provide a data storage method, apparatus, terminal device and storage medium to solve the problem in the prior art of improper storage of huge amounts of time-series data, resulting in low efficiency of subsequent data query.
[0005] A first aspect of an embodiment of the present application provides a data storage method, including:
[0006] Acquire data and record timestamp information of the data, the data being time series data;
[0007] The data is stored as hot data in a hot data storage node, and is also stored in a cold data storage node; wherein the hot data storage node is used to respond to query requests for hot data; and the cold data storage node is used to respond to query requests for cold data;
[0008] If it is detected that the storage time of the data exceeds the preset hot data storage time, the data is determined to be cold data and deleted from the hot data storage node, wherein the storage time of the data is determined according to the timestamp information of the data.
[0009] A second aspect of an embodiment of the present application provides a data storage device, including:
[0010] A data acquisition unit, used to acquire data and record the timestamp information of the data, the data being time series data;
[0011] A data storage unit, used to store the data as hot data to a hot data storage node, and to a cold data storage node at the same time; wherein the hot data storage node is used to respond to a query request for hot data; and the cold data storage node is used to respond to a query request for cold data;
[0012] The deleting unit is used to determine that the data is cold data and delete the data from the hot data storage node if it detects that the storage time of the data exceeds the preset hot data storage time, wherein the storage time of the data is determined according to the timestamp information of the data.
[0013] A third aspect of an embodiment 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, wherein when the processor executes the computer program, the terminal device implements the steps of the data storage method.
[0014] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, a terminal device implements the steps of the data storage method.
[0015] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the steps of the data storage method described in the first aspect.
[0016] The beneficial effect of the embodiments of the present application compared with the prior art is as follows: In the embodiments of the present application, considering that in time series data, usually the more recently stored data (i.e., the data with a shorter storage time) is the hot data that is frequently queried, the data is distinguished as hot data or cold data based on the storage time of the data, so that the hot data is specially distinguished and stored in a hot data storage node specifically used to respond to query requests for hot data, thereby ensuring data query efficiency. Specifically, on the first aspect, the data just acquired is first stored as hot data in the hot data storage node, and when the storage time of the data determined according to the timestamp information exceeds the hot data storage time, the data is determined to be cold data and deleted from the hot data storage node, so that the hot data storage node only stores the hot data part, thereby reducing the amount of data in the hot data storage node, thereby reducing the retrieval scope when responding to hot data queries, and thus improving the hot data query efficiency; on the second aspect, when the data is just acquired, in addition to storing it as hot data in the hot data storage node, it is also stored in the cold data storage node. When the data is still hot data, the data stored in the cold data storage node can be used as backup data of the hot data, and when the data exceeds the preset hot data storage time and is determined to be cold data, the cold data storage node can still store the data for a long time to respond to occasional cold data query requests. In summary, the embodiments of the present application strategically control the storage of data in hot data storage nodes and cold data storage nodes to achieve differentiated storage of hot data and cold data, control the amount of data stored in hot data storage nodes, improve the query efficiency of hot data, and at the same time ensure that cold data can also respond to queries through cold data nodes when needed, thereby ensuring the efficiency of subsequent data queries through orderly and effective data storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 This is a schematic diagram of an application scenario of a data storage method provided in an embodiment of the present application.
[0019] Figure 2 This is a schematic diagram of the implementation process of the first data storage method provided in the embodiment of the present application;
[0020] Figure 3 This is a schematic diagram of the implementation process of the second data storage method provided in the embodiment of the present application;
[0021] Figure 4is a schematic diagram of a linked list provided in an embodiment of the present application;
[0022] Figure 5 It is a schematic diagram of a linked list after a preset table is split according to an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of a linked list after merging preset tables provided in an embodiment of the present application;
[0024] Figure 7 is a schematic diagram of a data storage device provided in an embodiment of the present application;
[0025] Figure 8 It is a schematic diagram of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0027] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0028] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0029] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0030] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0031] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0032] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0033] The schematic diagram of the application scenario of the data storage method of the embodiment of the present application is as follows Figure 1 As shown, it includes a collection device 11 for collecting time series data, a data storage device 12, a hot data storage node 121, a cold data storage node 122 and a user 13. The details are as follows:
[0034] Time series data is the status data of the same monitoring target in the time dimension. The acquisition device 11 can be a camera, a temperature and humidity monitor, a meteorological monitor, etc. Correspondingly, the time series data can be the image data captured by the camera in real time in the same monitoring area, the temperature and humidity data monitored in real time by the temperature and humidity monitor in the same environment, and the meteorological data monitored in real time by the meteorological monitor in the same area.
[0035] The data storage device 12 obtains the collected data from the collection device 11, and saves the data as hot data to the hot data storage node 121 and the cold data storage node 122 at the same time, and when it is detected that the storage time of the data exceeds the preset hot data storage time, the data is determined to be cold data and deleted from the hot data storage node 121, so that the hot data storage node 121 only stores hot data whose storage time is within the hot data storage time. The hot data storage node 121 and the cold data storage node 122 can be part of the data storage device 12, or each can be an external memory independent of the data storage device.
[0036] When user 13 needs to query data, a query request containing query time range information is sent to the data storage device 12. The data storage device 12 determines one as the target response node from the hot data storage node 121 and the cold data storage node 122 according to the query time range information, obtains the data corresponding to the query request from the target response node, and returns the data corresponding to the query request to user 13.
[0037] The embodiments of the present application strategically control the storage of data in hot data storage nodes and cold data storage nodes to achieve differentiated storage of hot data and cold data, control the amount of data stored in hot data storage nodes, improve the query efficiency of hot data, and at the same time ensure that cold data can also respond to queries through cold data nodes when needed, thereby ensuring the efficiency of subsequent data queries through orderly and effective data storage.
[0038] Embodiment 1:
[0039] Figure 2 The flowchart of the first data storage method provided in the embodiment of the present application is shown. The execution subject of the data storage method is a terminal device, which is described in detail as follows:
[0040] In S201, data is acquired and timestamp information of the data is recorded, and the data is time series data.
[0041] The data in the embodiments of the present application are time series data obtained by a collection device collecting data on the same monitoring target in the time dimension. The terminal device obtains data from the collection device and records the timestamp information when the data is obtained.
[0042] In S202, the data is saved as hot data to a hot data storage node, and is also saved to a cold data storage node; wherein the hot data storage node is used to respond to query requests for hot data; and the cold data storage node is used to respond to query requests for cold data.
[0043] In the embodiment of the present application, hot data refers to data that is frequently accessed (the query frequency is greater than or equal to the preset frequency), and cold data refers to data that is seldom accessed (the query frequency is less than the preset frequency). In the actual application of time series data, the frequently accessed data is the newer data that has been stored recently, and the seldom accessed data is the historical data that has been stored for a long time. Therefore, in the embodiment of the present application, hot data is specifically defined as the newer time series data whose storage time is within the preset hot data storage time, and cold data is defined as the historical time series data whose storage time exceeds the preset hot data storage time.
[0044] In the embodiment of the present application, the hot data storage node specifically stores hot data and is used to respond to query requests for hot data; the cold data storage node stores all acquired data and is used to respond to query requests for cold data.
[0045] The data just obtained from step S201 is relatively new time series data, so it is saved as hot data in the hot data storage node and is also saved in the cold data storage node.
[0046] In S203, if it is detected that the storage time of the data exceeds the preset hot data storage time, the data is determined to be cold data and deleted from the hot data storage node, wherein the storage time of the data is determined according to the timestamp information of the data.
[0047] In an embodiment of the present application, the data retention period is determined based on the timestamp information of the data. Specifically, the system timestamp of the current terminal device is subtracted from the timestamp information when the data is acquired, and the result is converted into a form consistent with the time unit of the preset hot data retention period, thereby obtaining the data retention period.
[0048] When it is detected that the storage time of the data exceeds the preset hot data storage time, the data is judged as cold data with a longer storage time, and the data is deleted from the hot data storage node, so that the hot data storage node remains in a state of storing only hot data, reducing the amount of data stored in the hot data storage node and speeding up the hot data storage node's response to hot data queries.
[0049] Optionally, the hot data storage nodes are stored in a solid-state memory, and the cold data storage nodes are stored in a mechanical memory.
[0050] In an embodiment of the present application, the hot data storage node is specifically stored in a solid-state memory, such as a solid-state hard disk (Solid State Disk or Solid State Drive, referred to as SSD); and the cold data storage node is stored in a mechanical memory, such as a mechanical hard disk (Hard Disk Drive, referred to as HDD).
[0051] Solid-state storage is characterized by fast read and write speeds but low capacity and high hardware costs, while mechanical storage is characterized by large capacity and low hardware costs. In the embodiment of the present application, hot data storage nodes with a small amount of stored data are stored in solid-state storage, which can further improve the query speed of commonly used hot data, and cold data storage nodes with a large amount of stored data are stored in mechanical storage, which can ensure stable storage of large amounts of data and reduce hardware costs. Therefore, by storing hot data storage nodes in solid-state storage and cold data storage nodes in mechanical storage, it is possible to improve the query speed of data and meet the storage requirements of data while controlling hardware costs, thereby further improving the storage efficiency of data and subsequent query efficiency.
[0052] Optionally, after step S203, the method further includes:
[0053] S20401: Obtain a query request, where the query request includes query time range information;
[0054] S20402: If it is determined that the query request is a query request for hot data according to the query time range information and the hot data storage duration, the hot data storage node is determined as a target response node; otherwise, the cold data storage node is determined as a target response node;
[0055] S20403: Query the target response node to obtain data corresponding to the query request.
[0056] In S20401, the terminal device can obtain the query request by obtaining the key input information, touch information or voice information operated by the user on the terminal device, or by receiving the request data sent by the user terminal. The query request in the embodiment of the present application at least includes the query time range information, and the specific unit of the query time range information can be month, date, week, hour, minute, second, etc. For example, the query time range information can be "the last week" or the specific date "April 1, 2020". In addition to the query time range information, the query request can also include other query constraints. Exemplarily, assuming that the data obtained in the embodiment of the present application is image data, and the image data is divided into different image data types such as face images and animal images, then the query request can also include image data type information. Exemplarily, assuming that the data obtained in the embodiment of the present application is temperature and humidity data, that is, specifically including temperature data and humidity data, then the query request can also specify to query any one of the temperature data and humidity data or query the temperature data and humidity data at the same time.
[0057] In S20402, based on the query time range information and the preset hot data storage time, determine whether the current query request is a query request for hot data or a query request for cold data; if the current query request is a query request for hot data, the hot data storage node is determined as the target response node, and if the current query request is a query request for cold data, the cold data storage node is determined as the target response node. Specifically, when the query time range information is within the hot data storage time, the query request is determined as a query request for hot data, otherwise, the query request is determined as a query request for cold data. Exemplarily, assuming that the hot data storage time is one month and the current query time range information is the most recent week, the query time range information is within the hot data storage time, and the query request is determined to be a query request for hot data. Exemplarily, assuming that the current time is May 6, 2020, the hot data storage period is one month (that is, the data from April 6, 2020 to May 6, 2020 is the hot data), and the query time range information is April 1, 2020, then the query time range information is outside the hot data storage period, and the query request is determined to be a query request for cold data.
[0058] In S20403, according to the query request, the data corresponding to the query request is queried in the determined target response node. Specifically, if the query request only contains the query time range information, the data corresponding to the query request is the data stored in the target response node within the query time range. Optionally, if the query request also includes other query constraints, the data corresponding to the query request is the data stored in the target response node within the query time range and meeting the other query constraints. Exemplarily, assuming that the current query request contains the query constraint "face image" and the query time range information "last week", and the target response node determined in step S20402 is a hot data storage node, then the data corresponding to the query request finally queried in the hot data storage node is all face image data stored in the last week.
[0059] In an embodiment of the present application, after obtaining a query request, it is possible to distinguish between query requests for hot data and query requests for cold data based on the query time range information contained in the query request, and determine the corresponding target response node, so as to obtain the corresponding data faster and more accurately, thereby improving data query efficiency.
[0060] Optionally, before step S201, the method further includes:
[0061] Get a setting instruction, and set the hot data storage time according to the setting instruction.
[0062] In the embodiment of the present application, the hot data storage duration can be set according to actual needs. Optionally, the setting instruction in the embodiment of the present application can be an instruction containing duration information input by the administrator through text input or voice input, and the duration information can be "half a year", "three months", "one month", "one week", etc.; then, according to the setting instruction, the duration information is set as the hot data storage duration. Optionally, the setting instruction includes a statistical average query time range; the terminal device automatically counts the query time range information contained in the query request within the preset time period at regular intervals, determines the average query time range, and generates a setting instruction containing the average query time range, and then, according to the average query time range, sets a duration close to the average query time range as the hot data storage duration, so that the hot data storage duration setting is more in line with the actual query request. Optionally, the setting instruction includes storage capacity information of the hot data storage node and information on the amount of data collected per unit time. Based on the storage capacity information and the amount of data collected per unit time, a reasonable hot data retention period is determined (for example, the storage capacity information is divided by the amount of data collected per unit time to obtain the time as the hot data retention period), so that the hot data storage node can reasonably store more hot data.
[0063] In the embodiment of the present application, since the hot data storage time can be flexibly set according to the setting instruction, the hot data storage time can be made to more reasonably meet the actual application needs, thereby further improving the data storage efficiency.
[0064] In the embodiment of the present application, considering that in time series data, the latest stored data (i.e., the data with a shorter storage time) is usually the hot data that is frequently queried, so the data is distinguished as hot data or cold data based on the storage time of the data, so that the hot data is specially distinguished and stored in a hot data storage node specifically used to respond to query requests for hot data, thereby ensuring the query efficiency of the data. Specifically, on the first aspect, the data just acquired is first stored as hot data in the hot data storage node, and when the storage time of the data determined according to the timestamp information exceeds the hot data storage time, the data is determined to be cold data and deleted from the hot data storage node, so that the hot data storage node only stores the hot data part, thereby reducing the amount of data in the hot data storage node, thereby reducing the retrieval scope when responding to hot data queries, and thus improving the hot data query efficiency; on the second aspect, when the data is just acquired, in addition to storing it as hot data in the hot data storage node, it is also stored in the cold data storage node. When the data is still hot data, the data stored in the cold data storage node can be used as backup data of the hot data, and when the data exceeds the preset hot data storage time and is determined to be cold data, the cold data storage node can still store the data for a long time to respond to occasional cold data query requests. In summary, the embodiments of the present application strategically control the storage of data in hot data storage nodes and cold data storage nodes to achieve differentiated storage of hot data and cold data, control the amount of data stored in hot data storage nodes, improve the query efficiency of hot data, and at the same time ensure that cold data can also respond to queries through cold data nodes when needed, thereby ensuring the efficiency of subsequent data queries through orderly and effective data storage.
[0065] Embodiment 2:
[0066] Figure 3 The flowchart of the second data storage method provided by the embodiment of the present application is shown. The execution subject of the embodiment of the present application is a terminal device, which is described in detail as follows:
[0067] In S301 , a preset table for storing time series data of a preset period is created at every preset time.
[0068] In the embodiment of the present application, the preset time period may be a specified N days, N hours or N weeks, etc., where N is a positive integer greater than or equal to 1, and a preset table for storing time series data within the preset time period is regularly created at every preset time. For example, if the preset time period is one day, a preset table for storing time series data within the entire time period from 0:00 to 24:00 the next day may be regularly created at 23:00 every day, that is, the data of each day is stored in a corresponding preset table.
[0069] In S302, data is continuously acquired within a preset period of time, timestamp information of the data is recorded, and the data and the timestamp information of the data are correspondingly stored in the preset table.
[0070] After the preset table is created, the collected data is continuously obtained from the collection device within the preset period, and the system time of the terminal device when the data is obtained is recorded as the timestamp information corresponding to the data. Afterwards, the data and the timestamp information corresponding to the data are stored in the preset table in a corresponding manner, for example, the data and the timestamp information corresponding to the data are stored in the same row of the preset table.
[0071] In S303, all data in the preset table are taken as hot data, and the preset table is saved in the hot data storage node and the cold data storage node.
[0072] When the preset period ends, all data in the preset table is saved as hot data in the hot data storage node, and is also saved in the cold data storage node. For example, if the preset period is one day, then after one day ends, all data stored in the preset table for one day is saved as hot data in the hot data storage node, and is also saved in the cold data storage node.
[0073] In S304, the maximum timestamp in the preset table is determined according to the timestamp information in the preset table.
[0074] According to the timestamp information in the preset table, a maximum timestamp in the preset table is determined, where the maximum timestamp is the timestamp information corresponding to the data last acquired within the preset time period.
[0075] In S305, the storage duration corresponding to the preset table is determined according to the maximum timestamp and the current system timestamp.
[0076] In the embodiment of the present application, the maximum timestamp in the preset table is used as the final timestamp information of the preset table to calculate the storage duration corresponding to the preset table. Specifically, the storage duration corresponding to the preset table is obtained by subtracting the maximum timestamp in the preset table from the current system timestamp of the terminal device.
[0077] In S306, if it is detected that the storage time corresponding to the preset table is greater than the storage time of the hot data, all the data in the preset table is determined to be cold data, and the preset table is deleted from the hot data storage node.
[0078] When it is detected that the storage time corresponding to the preset table is longer than the hot data storage time, all the data in the preset table is determined to be cold data, and the preset table is deleted from the hot data storage node so that the hot data storage node only stores a certain amount of hot data.
[0079] In an embodiment of the present application, a preset table for storing time series data within a preset time period is periodically created, so that the data storage process, the process of determining whether the data is hot or cold, and the process of deleting the data from the hot data storage node are all performed in units of tables. Therefore, multiple data within the preset time period can be uniformly stored and processed at one time, thereby saving resource operating overhead and further improving data storage efficiency.
[0080] Optionally, the cold data storage node stores at least two of the preset tables, the cold data storage node stores at least two of the preset tables, the cold data storage node further includes a linked list for recording information of the preset table, each linked list node of the linked list corresponds to a preset table in turn, the node information of each linked list node includes adjacent linked list node address pointer information, identification information of the preset table and query record information, wherein the identification information of the preset table is used to determine the correspondence between the linked list node and the preset table, and correspondingly, the method further includes:
[0081] A1: monitoring query record information of each preset table in each unit time period, and storing the query record information in the linked list node corresponding to the preset table, wherein the query record information at least includes query time consumption;
[0082] A2: If it is detected that there is a time-consuming node in the linked list node, the preset table corresponding to the time-consuming node is split into L updated preset tables, where the time-consuming node is a linked list node whose stored query time is greater than a preset time-consuming threshold; L is a positive integer greater than 1 determined according to the query time and the preset time-consuming threshold;
[0083] A3: According to the L updated preset tables, (L-1) new linked list nodes are inserted after the time-consuming node in the linked list, and the corresponding node information is set for the new linked list node, the time-consuming node, and the next linked list node of the time-consuming node, respectively, to complete the update of the linked list.
[0084] In the embodiment of the present application, the cold data storage node stores two or more preset tables, each of which stores data for a preset period of time. The cold data storage node also includes a linked list for recording information of the preset table, and each linked list node of the linked list corresponds to a preset table in sequence, such as Figure 4 As shown. Among them, the information of each linked list node includes adjacent linked list node address pointer information, preset table identification information and query record information. Specifically, the adjacent linked list node address pointer information is used to record the node address information of other linked list nodes adjacent to the linked list node (specifically including the node address information of the previous linked list node and the node address information of the next linked list node). The identification information of the preset table is used to determine the correspondence between the linked list node and the preset table in sequence, wherein the data storage locations of the preset table corresponding to adjacent linked list nodes are adjacent, and the identification information of the preset table can be the table name of the preset table, the timestamp information identifier determined according to the timestamp information of the data stored in the preset table (specifically can include the maximum timestamp information and / or the minimum timestamp information of the preset table), the storage address information of the preset table, etc.
[0085] In A1, query record information of each preset table is monitored in each unit time period, and the query record information at least includes query time consumption, wherein the unit time period is a preset time period, which can be one day, one week, one month, etc. In a unit time period, if a query request for querying the data of the preset table is detected, the response time from obtaining the query request to obtaining the data corresponding to the query request is recorded, and the response time is the query time consumption corresponding to the preset table, and the query time consumption is stored in the linked list node corresponding to the preset table.
[0086] In A2, when it is detected that there is a linked list node in the linked list whose stored query time is greater than the preset time threshold, the linked list node is determined to be a time-consuming node, indicating that the preset table corresponding to the current time-consuming node contains too much data, resulting in a slow response to the query request. Therefore, the preset table corresponding to the linked list node needs to be split to reduce the amount of data contained in a single preset table and improve query efficiency. At this time, according to the query time and the preset time threshold, the linked list node is split to obtain L split preset tables. Specifically, assuming that the query time is m and the preset time threshold is n, then That is, the query time is divided by the preset time threshold and rounded up to get the number of preset tables to be split.
[0087] Optionally, in the embodiment of the present application, the query time comparison and the splitting step of the preset table are performed at a specified time point within the unit time period, and the specified time point is a time point in a non-busy period (i.e., there are fewer query requests). For example, if the unit time period is one day, the specified time point may be 2:00 a.m. If there are multiple query requests for querying the preset table within a unit time period, and multiple query times corresponding to the multiple query requests are stored in the linked list node, the average of the multiple query times is calculated as the query time corresponding to the preset table.
[0088] In A3, after the preset table corresponding to the time-consuming node is split into L updated preset tables, it is necessary to establish a corresponding linked list node for the newly added preset table. Specifically, since the preset table corresponding to the original time-consuming node is split into L updated preset tables, the number of preset tables is increased by (L-1) compared to before the split, so it is necessary to establish corresponding (L-1) new linked list nodes for the newly added preset table. After establishment, the (L-1) new linked list nodes are inserted into the position after the time-consuming node in the linked list. For example, suppose Figure 4 The preset table 2 shown is split into two updated preset tables: Figure 5 The preset table 2A and the preset table 2B shown in the figure have an additional number of 2-1=1 compared to before the split. Therefore, it is necessary to create a new linked list node and insert the new linked list node into the linked list. For example, Figure 5 The newly added linked list node k is shown. At the same time, the corresponding node information is set for the newly created linked list node, and the node information contained in the time-consuming node and the node of the next linked list of the time-consuming node is updated, so as to complete the update of the linked list, so that the linked list can timely and accurately represent the information of each preset table in the current cold data storage node, so as to be accurately used for subsequent query and preset table management operations.
[0089] Optionally, the identification information of the preset table in the embodiment of the present application is specifically a timestamp information identification, and the step A3 includes:
[0090] A31: Create L-1 newly created linked list nodes;
[0091] A32: according to the node address information of the time-consuming node, the next linked list node of the time-consuming node and the newly created linked list node, set the adjacent linked list node address pointer information of the newly created linked list node, and update the adjacent linked list node address pointer information of the time-consuming node and the next linked list node of the time-consuming node, so as to insert the newly created linked list node into the position after the time-consuming node in the linked list;
[0092] A33: updating the timestamp information identifier of the time-consuming node and the timestamp information identifier of the newly created linked list node according to the timestamp information of the data contained in the L updated preset tables, so as to establish a corresponding relationship between the L updated preset tables and the time-consuming node or the newly created linked list node;
[0093] A34: Clear the query record of each linked list node in the linked list to complete the update of the linked list.
[0094] In A31, according to the number L of preset tables obtained by splitting, L-1 new linked list nodes are established.
[0095] In A32, the node address information of the linked list node in the embodiment of the present application may be the label information or unique identification information of the linked list node, for example Figure 4 The node address information of the linked list node 1 in the can be directly digitally labeled "1" or textually labeled "linked list node 1" and the like. The adjacent linked list node address pointer information in the node information stored in each linked list node specifically includes the node address information of the previous linked list node of the linked list node and the node address information of the next linked list node of the linked list node. After determining that the insertion position of the newly created linked list node is the position of the time-consuming node, the adjacent linked list node address pointer information of each newly created linked list node is set accordingly according to the corresponding node address information of the time-consuming node, the next linked list node of the time-consuming node and the newly created linked list node, and the adjacent linked list node address pointer information of the time-consuming node and the next linked list node of the time-consuming node is updated, thereby completing the insertion of the newly created linked list node.
[0096] For example, Figure 4 In the linked list shown, suppose that the node address information corresponding to linked list nodes 1 to 4 is "1", "2", "3" and "4" respectively; linked list node 2 is the current time-consuming node, and its corresponding node address information is "2", and its currently stored adjacent linked list node pointer information is: "2→prior=1" and "2→next=3", which are used to indicate that the node address information of the previous linked list node of linked list node 2 is "1", and the node information of the next linked list node of linked list node 2 is "3"; linked list node 3 is the next linked list node of the current time-consuming node (linked list node 2), and its corresponding node address information is "3", and its currently stored adjacent linked list node pointer information is "3→prior=2" and "3→next=4". Split the preset table corresponding to the time-consuming node, i.e., linked list node 2, into the following: Figure 5After the preset table 2A and preset table 2B shown in the figure, it is necessary to create a newly added linked list node k, and the node address information of the newly added linked list node k is "k". It is determined that the position of the newly added linked list node k should be after the linked list node 2 and before the linked list node 3, then according to the node address information of the linked list node 2 and the linked list node 3: "2", "3", the adjacent linked list node pointer information of the newly added linked list node is set to "k→prior=2" and "k→next=3"; according to the node address information "k" of the newly added linked list node k, the adjacent linked list node pointer information in the linked list node 2 is updated to "2→prior=1" and "2→next=k", and the adjacent linked list node pointer information in the linked list node 3 is updated to "3→prior=k" and "3→next=4", so that the newly added linked list node k is as follows. Figure 5 Inserted into the linked list as shown is located after the time-consuming node, linked list node 2.
[0097] In A33, in the embodiment of the present application, the preset table corresponding to the linked list node is determined based on the timestamp information stored in the linked list node, and the timestamp information identifier may include the maximum timestamp information and the minimum timestamp information of the data in the preset table. Figure 4 In the data stored in the preset table 2 shown, the corresponding minimum timestamp information is: 1590940800, and the maximum timestamp information is: 1591027199. Therefore, the timestamp information identifier of the linked list node 2 is set to "1590940800, 1591027199" to determine the unique correspondence between the linked list node 2 and the preset table 2.
[0098] After the preset table corresponding to the time-consuming node is split into L updated preset tables, it is necessary to update the timestamp information identifier of the time-consuming node and the timestamp information identifier of the newly created linked list node according to the timestamp information of the data contained in the L updated preset tables, so as to establish a corresponding relationship between the L updated preset tables and the time-consuming node or the newly created linked list node. Figure 4 The preset table 2 shown is split into Figure 5The preset table 2A and preset table 2B shown, the timestamp information identifier of the preset table 2A is "1590940800, 1590984000", and the timestamp information identifier of the preset table 2B is "1590984001, 1591027199", then the timestamp information identifier of the linked list node 2 is updated from the original "1590940800, 1591027199" to "1590940800, 1590984000" to establish a corresponding relationship between the linked list node 2 and the preset table 2A; the timestamp information identifier of the newly added linked list node k is set to "1590984001, 1591027199" to establish a corresponding relationship between the newly added linked list node k and the preset table 2B.
[0099] In A34, after obtaining the updated preset table, the query records stored in each linked list node are reset to zero to prevent the previous query records from affecting subsequent monitoring.
[0100] Through the above steps A31 to A34, the newly created linked list nodes are inserted into the original linked list and the node information of each linked list node is updated (specifically including adjacent linked list node pointer information, timestamp information and query records), so as to accurately update the linked list, so that the updated linked list can accurately and orderly correspond to the information of each preset table.
[0101] In the embodiment of the present application, the information of each preset table in the cold data storage node is accurately and orderly recorded through a linked list, so that each preset table can be managed in an orderly manner, the orderliness and accuracy of data query can be ensured, and the data storage efficiency and query efficiency can be improved; and according to the query time-consuming information of each preset table recorded in the linked list, the preset table can be reasonably split, thereby reducing the amount of data contained in a single preset table, narrowing the data search range when querying the data stored in the preset table, thereby improving the data query efficiency. Specifically, since the number of preset tables obtained by splitting (i.e., L) can be determined according to the query time and the preset time-consuming threshold, the query time corresponding to each preset table is controlled within the preset time-consuming threshold, so that the response speed of the query request can be more accurately and effectively improved.
[0102] Optionally, the query record information also includes the number of queries within a unit time period. Correspondingly, after monitoring the query record information of each preset table within each unit time period and storing the query record information in the linked list node corresponding to the preset table, it also includes:
[0103] B1: If it is detected that there is a target node in the linked list node, then according to the adjacent linked list node address pointer information of the target node, the node information of the first adjacent linked list node is obtained; the target node is a linked list node whose stored query times is 0 or less than a first preset times, and the first adjacent linked list node is a linked list node adjacent to the target node;
[0104] B2: determining the first adjacent linked list node whose node information meets the preset condition as a node to be deleted, and merging the first preset table corresponding to the target node with the preset table corresponding to the node to be deleted;
[0105] B3: Update the node information of the second adjacent linked list node and the node information of the target node, and delete the node to be deleted from the linked list to complete the update of the linked list; the second adjacent linked list node is the linked list node adjacent to the node to be deleted except the target node.
[0106] In an embodiment of the present application, the query record information in the linked list node also includes the query count information within a unit time period, that is, within the unit time period, if a query request for querying the data in the preset table is detected, the query time corresponding to the query request is recorded, and the query record count of the preset table is increased by 1.
[0107] In B1, after the current unit time period ends, the query times stored in each linked list node are detected. If there is a target node whose query times are 0 or less than the preset times, it means that the preset table corresponding to the target node (hereinafter referred to as the first preset table) contains data that is requested to be queried less frequently, that is, the first preset table can be merged, so that storage space can be saved without affecting the query efficiency. At this time, the node information of the first adjacent linked list node is obtained, and the first adjacent linked list node is the linked list node adjacent to the target node. The node information of the first adjacent linked list node is used to further determine whether the first preset table corresponding to the target node can be merged with the adjacent preset table. Specifically, the information of the first adjacent linked list node includes the node information of the previous linked list node of the target node and / or the node information of the next linked list node of the target node.
[0108] In B2, it is determined whether the node information of the first adjacent linked list node meets the preset conditions. If so, the first adjacent linked list node is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the preset table corresponding to the node to be deleted. Optionally, the first adjacent linked list node includes the previous linked list node of the target node and the next linked list node of the target node; it can be determined whether the previous linked list node of the target node meets the preset conditions first, if so, the previous linked list node of the target node is directly determined as the node to be deleted; if not, it is further determined whether the next linked list node of the target node meets the preset conditions, if so, the next linked list node of the target node is determined as the node to be deleted; if both the previous linked list node of the target node and the next linked list node of the target node do not meet the preset conditions, it is determined that the current first preset table cannot be merged with the adjacent preset table, and the merge operation is not performed.
[0109] In B3, since the node to be deleted needs to be deleted, it is necessary to update the node information of the linked list nodes adjacent to the node to be deleted, specifically, update the adjacent linked list node address pointer information of the linked list nodes adjacent to the node to be deleted. Among them, the linked list nodes adjacent to the node to be deleted include the target node and the second adjacent linked list node other than the target node. Specifically, if the node to be deleted is the previous linked list node of the target node, the second adjacent linked list node is the previous linked list node of the node to be deleted; if the node to be deleted is the next linked list node of the target node, the second adjacent linked list node is the next linked list node of the node to be deleted. After updating the node information of the second adjacent linked list node and the node information of the target node, the node to be deleted can be deleted to complete the update of the linked list.
[0110] In an embodiment of the present application, preset tables with lower query frequencies are merged based on the query count information of the preset tables recorded in the linked list nodes in the linked list; since the preset tables with lower query frequencies do not need to respond to query requests frequently, even if the preset tables store more data, it will not affect the query efficiency of the data. Therefore, the preset tables with lower query frequencies are merged, so that the preset tables with lower query frequencies can store more data, which can save storage space without affecting the query efficiency and further improve the data storage efficiency.
[0111] Optionally, the identification information of the preset table specifically includes a timestamp information identifier, the first adjacent linked list node includes a previous linked list node of the target node, and the step B2 includes:
[0112] If the node information of the previous linked list node of the target node meets the preset condition, the previous linked list node of the target node is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the second preset table corresponding to the previous linked list node of the target node;
[0113] Correspondingly, the step B3 includes:
[0114] B31a: Update the address pointer information of the adjacent linked list node of the previous linked list node of the node to be deleted and the address pointer information of the adjacent linked list node of the target node, and delete the node to be deleted from the linked list;
[0115] B32a: According to the timestamp information contained in the new preset table obtained by merging, the timestamp information identifier of the target node is updated to establish a corresponding relationship between the new preset table and the target node.
[0116] The first adjacent linked list node in the embodiment of the present application includes the previous linked list node of the target node, and the preset table corresponding to the previous linked list node of the target node is the second preset table. In step B2, when it is determined that the previous linked list node of the target node meets the preset conditions, it is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the second preset table. Specifically, the data content of the second preset table (including the stored data and the timestamp information corresponding to the data) is merged into the first preset table.
[0117] In step B31a, since the node to be deleted needs to be deleted, it is necessary to first update the adjacent linked list node address pointer information of the linked list nodes adjacent to the node to be deleted, so as to avoid the situation where the adjacent linked list node address pointer information is incorrect after the node to be deleted is deleted. Specifically, the linked list nodes adjacent to the node to be deleted in the embodiment of the present application include the previous linked list node of the node to be deleted and the target node; the adjacent linked list node address pointer information of the previous linked list node of the node to be deleted and the adjacent linked list node address pointer information of the target node are updated, and then the node to be deleted is deleted from the linked list. Specifically, according to the node address information of the target node, the adjacent linked list node address pointer information of the previous linked list node of the node to be deleted is updated, and according to the node address information of the previous linked list node of the node to be deleted, the adjacent linked list node address pointer information of the target node is updated. Exemplarily, suppose Figure 4 In the linked list shown in FIG. 1 , the target node is linked list node 3, and the node to be deleted is linked list node 2. Then, the previous linked list node of the node to be deleted is specifically the previous linked list node of linked list node 2, that is, Figure 4The linked list node 1 shown in the figure; let the node address information of the linked list node 1 (i.e. the previous linked list node of the node to be deleted) be "1", and the node address information of the linked list node 3 (i.e. the target node) be "3". If the linked list node 2 needs to be deleted, it is necessary to establish a pointing connection relationship between the linked list node 1 and the linked list node 3, and specifically, to establish the pointing connection relationship by respectively updating the adjacent linked list node address pointer information of the linked list node 1 and the linked list node 3. Specifically, let Figure 4 In the figure, the original adjacent linked list node address pointer information stored in linked list node 1 is "1→next=2", indicating that the next linked list node of linked list node 1 is linked list node 2. Since linked list node 2 is the node to be deleted, it is necessary to point linked list node 1 to linked list node 3, that is, update the adjacent linked list node pointer information stored in linked list node 1 to "1→next=3"; the original adjacent linked list node address pointer information stored in linked list node 3 is "3→prior=2" and "3→next=4". Since linked list node 2 is the node to be deleted, the adjacent linked list node pointer information stored in linked list node 3 is updated to "3→prior=1" and "3→next=4". After establishing the pointing connection relationship between linked list node 1 and linked list node 3, delete linked list node 2 from the linked list, and obtain the following Figure 6 The linked list shown.
[0118] In step B32a, since the timestamp information of the data contained in the first preset table has changed after the second preset table is merged into the first preset table, it is necessary to update the timestamp information identifier stored in the target node according to the current timestamp information of the first preset table, so that the merged and updated first preset table and the target node establish a unique correspondence through the timestamp information. Specifically, find out the minimum timestamp information and the maximum timestamp information in the timestamp information corresponding to the data contained in the merged first preset table, and update the timestamp information identifier of the minimum timestamp information and the maximum timestamp information to the target node. For example, Figure 6 As shown, assuming that the new preset table obtained by merging is preset table 2_3, the minimum timestamp information and the maximum timestamp information of the preset table 2_3 are updated as the current timestamp information identifier of the target node, so that the target node uniquely corresponds to the preset table 2_3.
[0119] In an embodiment of the present application, specifically when the previous linked list node of a target node with a smaller number of queries meets a preset condition, the first preset table corresponding to the target node is merged with the second preset table corresponding to the previous linked list node of the target node, thereby saving storage space without affecting the query efficiency and further improving the data storage efficiency; and, the previous linked list node of the target node is used as a node to be deleted, and after merging the preset tables, the adjacent linked list node pointer information of the previous linked list node of the node to be deleted and the adjacent linked list node pointer information of the target node are updated, and the node to be deleted is deleted, thereby ensuring the accuracy of the mutual connection pointing relationship of each linked list node in the linked list; and, the timestamp information identifier stored in the target node can also be updated according to the timestamp information of the merged preset table to ensure the correspondence between the target node and the merged preset table, so that the linked list can accurately correspond to and record the information of each preset table, thereby facilitating accurate management of each preset table to improve data storage efficiency and query response efficiency.
[0120] Optionally, the identification information of the preset table specifically includes a timestamp information identifier, the first adjacent linked list node includes a next linked list node of the target node, and the step B2 includes:
[0121] If the node information of the next linked list node of the target node meets the preset condition, the next linked list node of the target node is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the third preset table corresponding to the next linked list node of the target node;
[0122] Correspondingly, the step B3 includes:
[0123] B31b: updating the adjacent linked list node address pointer information of the next linked list node of the to-be-deleted node and the adjacent linked list node address pointer information of the target node, and deleting the to-be-deleted node from the linked list;
[0124] B32b: According to the timestamp information contained in the new preset table obtained by merging, the timestamp information identifier of the target node is updated to establish a corresponding relationship between the new preset table and the target node.
[0125] The first adjacent linked list node in the embodiment of the present application includes the next linked list node of the target node, and the preset table corresponding to the next linked list node of the target node is the third preset table. In step B2, when it is determined that the next linked list node of the target node meets the preset condition, it is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the third preset table. Specifically, the data content of the third preset table (including the stored data and the timestamp information corresponding to the data) is merged into the first preset table.
[0126] In step B31b, specifically, the linked list nodes adjacent to the node to be deleted in the embodiment of the present application include the next linked list node of the node to be deleted and the target node; the adjacent linked list node address pointer information of the next linked list node of the node to be deleted and the adjacent linked list node address pointer information of the target node are updated, and then the node to be deleted is deleted from the linked list. Specifically, according to the node address information of the target node, the adjacent linked list node address pointer information of the next linked list node of the node to be deleted is updated, and according to the node address information of the next linked list node of the node to be deleted, the adjacent linked list node address pointer information of the target node is updated.
[0127] In step B32b, since the timestamp information of the data contained in the first preset table has changed after the third preset table is merged into the first preset table, it is necessary to update the timestamp information identifier stored in the target node according to the current timestamp information of the first preset table, so that the merged and updated first preset table and the target node establish a unique correspondence through the timestamp information. Specifically, find out the minimum timestamp information and the maximum timestamp information in the timestamp information corresponding to the data contained in the merged first preset table, and update the timestamp information identifiers of the minimum timestamp information and the maximum timestamp information to the target node.
[0128] Optionally, after step B32a or step B32b, the method further includes:
[0129] The query record of each linked list node in the linked list is cleared to zero. The query record of each linked list node in the linked list is reset to zero, and a new round of query record monitoring is started to prevent the previous query record from affecting the subsequent monitoring.
[0130] In an embodiment of the present application, specifically when the next linked list node of a target node with a small number of queries meets a preset condition, the first preset table corresponding to the target node and the third preset table corresponding to the next linked list node of the target node are merged, thereby saving storage space without affecting the query efficiency and further improving the data storage efficiency; and, the next linked list node of the target node is used as a node to be deleted, and after merging the preset tables, the adjacent linked list node pointer information of the next linked list node of the node to be deleted and the adjacent linked list node pointer information of the target node are updated, and the node to be deleted is deleted, thereby ensuring the accuracy of the mutual connection pointing relationship of each linked list node in the linked list; and, the timestamp information identifier stored in the target node can also be updated according to the timestamp information of the merged preset table to ensure the correspondence between the target node and the merged preset table, so that the linked list can accurately correspond to and record the information of each preset table, thereby facilitating accurate management of each preset table to improve data storage efficiency and query response efficiency.
[0131] Optionally, the preset conditions include:
[0132] The query times stored in the first adjacent linked list node is 0 or less than a second preset times; and / or the sum of the data volume of the preset table corresponding to the first adjacent linked list node and the data volume of the first preset table is less than a preset data volume.
[0133] The preset condition may include that the query number in the node information of the first adjacent linked list node is 0 or less than the second preset number. That is, the query number of the adjacent preset table merged with the first preset table also needs to be as small as possible, so as to avoid excessive query times of a single first preset table after the merger and reduce data query efficiency. Among them, the second preset number can be the same as or different from the above-mentioned first preset number, which is not limited here.
[0134] The preset condition may also include that the sum of the data volume of the preset table corresponding to the first adjacent linked list node and the data volume of the first preset table is less than the preset data volume. Specifically, if the first adjacent linked list node is the previous linked list node of the target node, the preset table corresponding to the linked list node is the second preset table; if the first adjacent linked list node is the next linked list node of the target node, the preset table corresponding to the first adjacent linked list node is the third preset table. When the sum of the data volume of the preset table corresponding to the first adjacent linked list node plus the number of the first preset table is less than the preset data volume, it means that even after the preset table corresponding to the first adjacent linked list node and the first preset table are merged into a new preset table, the data volume of the new preset table will not be too large, so the time consuming for data query from the new preset table will not be too long, and the first preset table and the preset table corresponding to the first adjacent linked list node can be merged at this time. Otherwise, it means that after the preset table corresponding to the first adjacent linked list node and the first preset table are merged into a new preset table, there may be a situation where the query efficiency is affected by the excessive amount of data. At this time, it is determined that the linked list node does not meet the preset condition and the preset table is not merged.
[0135] In the embodiment of the present application, since the number of queries stored in the first adjacent linked list node adjacent to the target node (i.e., the previous linked list node of the target node or the next linked list node of the target node) and / or the sum of the data volume of the preset table adjacent to the first preset table (e.g., the second preset table or the third preset table) and the data volume of the first preset table can be considered, the number of queries or the data volume of the merged new preset table can be controlled in advance, thereby avoiding a reduction in the overall data query efficiency due to the low query response efficiency of the merged new preset table.
[0136] It should be understood that the size of the serial 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.
[0137] Embodiment three:
[0138] Figure 7 A schematic diagram of the structure of a data storage device provided in an embodiment of the present application is shown. For ease of description, only the part related to the embodiment of the present application is shown:
[0139] The data storage device includes: a data acquisition unit 71 , a data storage unit 72 , and a deletion unit 73 .
[0140] in:
[0141] The data acquisition unit 71 is used to acquire data and record the timestamp information of the data, and the data is time series data.
[0142] The data storage unit 72 is used to store the data as hot data to a hot data storage node and to a cold data storage node at the same time; wherein the hot data storage node is used to respond to query requests for hot data; and the cold data storage node is used to respond to query requests for cold data.
[0143] The deleting unit 73 is used to determine that the data is cold data and delete the data from the hot data storage node if it is detected that the storage time of the data exceeds the preset hot data storage time, wherein the storage time of the data is determined according to the timestamp information of the data.
[0144] Optionally, in the data storage unit 72, the hot data storage nodes are stored in a solid-state memory, and the cold data storage nodes are stored in a mechanical memory.
[0145] Optionally, the data storage device further includes:
[0146] A query unit is used to obtain a query request, wherein the query request includes query time range information; if the query request is determined to be a query request for hot data based on the query time range information and the hot data storage duration, the hot data storage node is determined as a target response node, otherwise the cold data storage node is determined as a target response node; and data corresponding to the query request is obtained by querying in the target response node.
[0147] Optionally, the data storage device further includes:
[0148] A preset table creation unit, used to create a preset table for storing time series data of a preset period at every preset time;
[0149] Correspondingly, the data acquisition unit 71 is specifically used to continuously acquire data within a preset period of time, record the timestamp information of the data, and store the data and the timestamp information of the data in the preset table accordingly;
[0150] Correspondingly, the data storage unit 72 is specifically used to take all the data in the preset table as hot data, and save the preset table to the hot data storage node and the cold data storage node;
[0151] Correspondingly, the deletion unit 73 is specifically used to determine the maximum timestamp in the preset table according to the timestamp information in the preset table; determine the storage duration corresponding to the preset table according to the maximum timestamp and the current system timestamp; if it is detected that the storage duration corresponding to the preset table is greater than the hot data storage duration, then all the data in the preset table is determined to be cold data, and the preset table is deleted from the hot data storage node.
[0152] Optionally, the cold data storage node stores at least two of the preset tables, and the cold data storage node further includes a linked list for recording information of the preset table, each linked list node of the linked list corresponds to a preset table in sequence, and the node information of each linked list node includes adjacent linked list node address pointer information, identification information of the preset table and query record information, wherein the identification information of the preset table is used to sequentially determine the correspondence between the linked list node and the preset table, and correspondingly, the data storage device further includes:
[0153] A query record information monitoring unit, used to monitor the query record information of each preset table in each unit time period, and store the query record information in the linked list node corresponding to the preset table, wherein the query record information at least includes the query time consumption;
[0154] A preset table splitting unit is used for splitting the preset table corresponding to the time-consuming node into L updated preset tables if a time-consuming node is detected in the linked list node, wherein the time-consuming node is a linked list node whose stored query time is greater than a preset time-consuming threshold; L is a positive integer greater than 1 determined according to the query time and the preset time-consuming threshold;
[0155] The first updating unit is used to insert a newly created linked list node after the time-consuming node in the linked list according to the L updated preset tables, and set the corresponding node information for the newly created linked list node, the time-consuming node, and the next linked list node of the time-consuming node, respectively, to complete the update of the linked list.
[0156] Optionally, the data storage device further includes:
[0157] A target node detection unit, configured to, if detecting that a target node exists in the linked list node, obtain node information of a first adjacent linked list node according to address pointer information of an adjacent linked list node of the target node; the target node is a linked list node whose stored query times is 0 or less than a first preset times, and the first adjacent linked list node is a linked list node adjacent to the target node;
[0158] A preset table merging unit, configured to determine the first adjacent linked list node whose node information meets a preset condition as a node to be deleted, and merge the first preset table corresponding to the target node with the preset table corresponding to the node to be deleted;
[0159] The second updating unit is used to update the node information of the second adjacent linked list node and the node information of the target node, and delete the node to be deleted from the linked list to complete the update of the linked list; the second adjacent linked list node is the linked list node adjacent to the node to be deleted except the target node.
[0160] Optionally, the identification information of the preset table specifically includes a timestamp information identifier, and the first adjacent linked list node includes a previous linked list node of the target node, and correspondingly:
[0161] The preset table merging unit is specifically used to determine the previous linked list node of the target node as a node to be deleted if the node information of the previous linked list node of the target node meets the preset condition, and merge the first preset table corresponding to the target node with the second preset table corresponding to the previous linked list node of the target node;
[0162] The second updating unit is specifically used to update the adjacent linked list node address pointer information of the previous linked list node of the node to be deleted and the adjacent linked list node address pointer information of the target node, and delete the node to be deleted from the linked list; according to the timestamp information contained in the new preset table obtained by merging, update the timestamp information identifier of the target node to establish a corresponding relationship between the new preset table and the target node.
[0163] Optionally, the identification information of the preset table specifically includes a timestamp information identifier, and the first adjacent linked list node includes a next linked list node of the target node, and correspondingly:
[0164] The preset table merging unit is specifically used to determine the next linked list node of the target node as a node to be deleted if the node information of the next linked list node of the target node meets the preset condition, and merge the first preset table corresponding to the target node with the third preset table corresponding to the next linked list node of the target node;
[0165] The second update unit is specifically used to update the adjacent linked list node address pointer information of the next linked list node of the node to be deleted and the adjacent linked list node address pointer information of the target node, and delete the node to be deleted from the linked list; according to the timestamp information contained in the new preset table obtained by merging, update the timestamp information identifier of the target node to establish a corresponding relationship between the new preset table and the target node.
[0166] Optionally, the preset conditions include:
[0167] The query times stored in the first adjacent linked list node is 0 or less than a second preset times and / or the sum of the data volume of the preset table corresponding to the first adjacent linked list node and the data volume of the first preset table is less than a preset data volume.
[0168] Optionally, the data storage device further includes:
[0169] The setting unit is used to obtain a setting instruction and set the hot data storage time according to the setting instruction.
[0170] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0171] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or 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 each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0172] Embodiment 4:
[0173] Figure 8 Schematic diagram of a terminal device provided by an embodiment of the present application. Figure 8As shown, the terminal device 8 of this embodiment includes: a processor 80, a memory 81, and a computer program 82 stored in the memory 81 and executable on the processor 80, such as a data storage program. When the processor 80 executes the computer program 82, the steps in the above-mentioned various data storage method embodiments are implemented, such as Figure 2 Alternatively, when the processor 80 executes the computer program 82, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 7 The functions of the units 71 to 73 are shown.
[0174] Exemplarily, the computer program 82 may be divided into one or more modules / units, which are stored in the memory 81 and executed by the processor 80 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 82 in the terminal device 8. For example, the computer program 82 may be divided into a data acquisition unit, a data storage unit, and a deletion unit, and the specific functions of each unit are as follows:
[0175] The data acquisition unit is used to acquire data and record the timestamp information of the data, and the data is time series data.
[0176] A data storage unit is used to store the data as hot data to a hot data storage node and to a cold data storage node at the same time; wherein the hot data storage node is used to respond to query requests for hot data; and the cold data storage node is used to respond to query requests for cold data.
[0177] The deleting unit is used to determine that the data is cold data and delete the data from the hot data storage node if it detects that the storage time of the data exceeds the preset hot data storage time, wherein the storage time of the data is determined according to the timestamp information of the data.
[0178] The terminal device 8 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will appreciate that Figure 8 It is only an example of the terminal device 8 and does not constitute a limitation of the terminal device 8. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0179] The processor 80 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (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 any conventional processor, etc.
[0180] The memory 81 may be an internal storage unit of the terminal device 8, such as a hard disk or memory of the terminal device 8. The memory 81 may also be an external storage device of the terminal device 8, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 8. Further, the memory 81 may also include both an internal storage unit and an external storage device of the terminal device 8. The memory 81 is used to store the computer program and other programs and data required by the terminal device. The memory 81 may also be used to temporarily store data that has been output or is to be output.
[0181] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or 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 each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0182] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0183] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in 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 and technical personnel 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.
[0184] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0185] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0187] If 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, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. 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 jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0188] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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 present application, and should all be included in the protection scope of the present application.
Claims
1. A data storage method, characterized in that: include: Acquire data and record timestamp information of the data, the data being time series data; The data is stored as hot data in a hot data storage node, and is also stored in a cold data storage node; wherein the hot data storage node is used to respond to query requests for hot data; and the cold data storage node is used to respond to query requests for cold data; If it is detected that the storage time of the data exceeds the preset hot data storage time, the data is determined to be cold data, and the data is deleted from the hot data storage node, wherein the storage time of the data is determined according to the timestamp information of the data; Before acquiring the data, the method further includes: creating a preset table for storing time series data of a preset period at every preset time interval; The acquiring data and recording the timestamp information of the data includes: continuously acquiring the data within the preset time period, recording the timestamp information of the data, and storing the data and the timestamp information of the data in the preset table correspondingly; Correspondingly, the storing the data as hot data in a hot data storage node and simultaneously storing the data in a cold data storage node includes: storing all the data in the preset table as hot data and storing the preset table in the hot data storage node and the cold data storage node; The cold data storage node stores at least two preset tables, and the cold data storage node also includes a linked list for recording information of the preset table, each linked list node of the linked list corresponds to a preset table in turn, and the node information of each linked list node includes adjacent linked list node address pointer information, identification information of the preset table and query record information, wherein the identification information of the preset table is used to determine the correspondence between the linked list node and the preset table in sequence; Correspondingly, the method further includes: Monitor query record information of each preset table in each unit time period, and store the query record information in the linked list node corresponding to the preset table, wherein the query record information at least includes query time consumption; If it is detected that there is a time-consuming node in the linked list node, the preset table corresponding to the time-consuming node is split into L updated preset tables, wherein the time-consuming node is a linked list node in which the stored query time is greater than the preset time-consuming threshold, and L is a positive integer greater than 1 determined according to the query time and the preset time-consuming threshold; According to the L updated preset tables, (L-1) new linked list nodes are inserted after the time-consuming node in the linked list, and the corresponding node information is set for the new linked list node, the time-consuming node, and the next linked list node of the time-consuming node, respectively, to complete the update of the linked list.
2. The data storage method according to claim 1, characterized in that: The hot data storage nodes are stored in solid-state memory, and the cold data storage nodes are stored in mechanical memory.
3. The data storage method according to claim 1, characterized in that: After determining that the data is cold data if it is detected that the storage time of the data exceeds the preset hot data storage time, and deleting the data from the hot data storage node, the method further includes: Obtaining a query request, wherein the query request includes query time range information; If it is determined that the query request is a query request for hot data according to the query time range information and the hot data storage duration, the hot data storage node is determined as the target response node, otherwise the cold data storage node is determined as the target response node; The target response node is queried to obtain data corresponding to the query request.
4. The data storage method according to claim 1, characterized in that: Correspondingly, if it is detected that the storage time of the data exceeds the preset hot data storage time, the data is determined to be cold data, and the data is deleted from the hot data storage node, including: Determine the maximum timestamp in the preset table according to the timestamp information in the preset table; Determine the storage time length corresponding to the preset table according to the maximum timestamp and the current system timestamp; If it is detected that the storage time corresponding to the preset table is greater than the storage time of the hot data, all the data in the preset table is determined to be cold data, and the preset table is deleted from the hot data storage node.
5. The data storage method according to claim 1, characterized in that: The query record information also includes the number of queries within a unit time period. Correspondingly, after monitoring the query record information of each preset table within each unit time period and storing the query record information in the linked list node corresponding to the preset table, it also includes: If it is detected that there is a target node in the linked list node, then according to the adjacent linked list node address pointer information of the target node, the node information of the first adjacent linked list node is obtained; the target node is a linked list node whose stored query times is 0 or less than a first preset times, and the first adjacent linked list node is a linked list node adjacent to the target node; Determine the first adjacent linked list node whose node information meets the preset condition as a node to be deleted, and merge the first preset table corresponding to the target node with the preset table corresponding to the node to be deleted; Update the node information of the second adjacent linked list node and the node information of the target node, and delete the node to be deleted from the linked list to complete the update of the linked list; the second adjacent linked list node is a linked list node adjacent to the node to be deleted except the target node.
6. The data storage method according to claim 5, characterized in that: The identification information of the preset table specifically includes a timestamp information identifier, the first adjacent linked list node includes a previous linked list node of the target node, the first adjacent linked list node whose node information meets a preset condition is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the preset table corresponding to the node to be deleted, including: If the node information of the previous linked list node of the target node meets the preset condition, the previous linked list node of the target node is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the second preset table corresponding to the previous linked list node of the target node; Correspondingly, the second adjacent linked list node is specifically a previous linked list node of the node to be deleted, and the updating of the node information of the second adjacent linked list node and the node information of the target node, and deleting the node to be deleted from the linked list to complete the updating of the linked list, includes: Update the adjacent linked list node address pointer information of the previous linked list node of the to-be-deleted node and the adjacent linked list node address pointer information of the target node, and delete the to-be-deleted node from the linked list; According to the timestamp information contained in the new preset table obtained by merging, the timestamp information identifier of the target node is updated to establish a corresponding relationship between the new preset table and the target node.
7. The data storage method according to claim 5, characterized in that: The identification information of the preset table specifically includes a timestamp information identifier, the first adjacent linked list node includes a next linked list node of the target node, the first adjacent linked list node whose node information meets a preset condition is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the preset table corresponding to the node to be deleted, including: If the node information of the next linked list node of the target node meets the preset condition, the next linked list node of the target node is determined as a node to be deleted, and the first preset table corresponding to the target node is merged with the third preset table corresponding to the next linked list node of the target node; Correspondingly, the second adjacent linked list node is specifically the next linked list node of the node to be deleted, and the updating of the node information of the second adjacent linked list node and the node information of the target node, and deleting the node to be deleted from the linked list to complete the updating of the linked list, includes: Update the adjacent linked list node address pointer information of the next linked list node of the to-be-deleted node and the adjacent linked list node address pointer information of the target node, and delete the to-be-deleted node from the linked list; According to the timestamp information contained in the new preset table obtained by merging, the timestamp information identifier of the target node is updated to establish a corresponding relationship between the new preset table and the target node.
8. The data storage method according to claim 5, characterized in that: The preset conditions include: The query times stored in the first adjacent linked list node is 0 or less than a second preset times; and / or the sum of the data volume of the preset table corresponding to the first adjacent linked list node and the data volume of the first preset table is less than a preset data volume.
9. The data storage method according to any one of claims 1 to 8, characterized in that: Before determining that the data is cold data if it is detected that the storage time of the data exceeds the preset storage time of hot data, and deleting the data from the hot data storage node, the method further includes: Get a setting instruction, and set the hot data storage time according to the setting instruction.
10. A data storage device, characterized in that: include: A data acquisition unit, used to acquire data and record the timestamp information of the data, the data being time series data; A data storage unit, used to store the data as hot data to a hot data storage node, and to a cold data storage node at the same time; wherein the hot data storage node is used to respond to a query request for hot data; and the cold data storage node is used to respond to a query request for cold data; a deleting unit, configured to determine that the data is cold data and delete the data from the hot data storage node if it is detected that the storage time of the data exceeds a preset storage time of hot data, wherein the storage time of the data is determined according to the timestamp information of the data; The cold data storage node stores at least two preset tables, and the cold data storage node also includes a linked list for recording information of the preset table, each linked list node of the linked list corresponds to a preset table in turn, and the node information of each linked list node includes adjacent linked list node address pointer information, preset table identification information and query record information, wherein the preset table identification information is used to sequentially determine the correspondence between the linked list node and the preset table, wherein the preset table is created at every preset time for storing time series data of a preset period, and the preset table stores the data and the timestamp information of the data; Wherein, the data storage device further comprises: A preset table creation unit, used to create a preset table for storing time series data of a preset period at every preset time; Correspondingly, the data acquisition unit is used to continuously acquire data within a preset period of time, record the timestamp information of the data, and store the data and the timestamp information of the data in the preset table correspondingly; Correspondingly, the data storage unit is used to take all the data in the preset table as hot data, and save the preset table to the hot data storage node and the cold data storage node; Correspondingly, the data storage device further includes: A query record information monitoring unit, used to monitor the query record information of each preset table in each unit time period, and store the query record information in the linked list node corresponding to the preset table, wherein the query record information at least includes the query time consumption; A preset table splitting unit is used for splitting the preset table corresponding to the time-consuming node into L updated preset tables if a time-consuming node is detected in the linked list node, wherein the time-consuming node is a linked list node whose stored query time is greater than a preset time-consuming threshold; L is a positive integer greater than 1 determined according to the query time and the preset time-consuming threshold; The first updating unit is used to insert a newly created linked list node after the time-consuming node in the linked list according to the L updated preset tables, and set the corresponding node information for the newly created linked list node, the time-consuming node, and the next linked list node of the time-consuming node, respectively, to complete the update of the linked list.
11. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the terminal device implements the steps of the method according to any one of claims 1 to 9.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the terminal device implements the steps of the method according to any one of claims 1 to 9.
