Embodiments of the present invention relate to communications technologies, and in particular, to a time series data processing method and apparatus.
At present, there are three manners of machine to machine (Machine-To-Machine, M2M for short) wireless communications: machine to machine, machine to mobile phone (such as remote user monitoring), and mobile phone to machine (such as remote user control). A OneM2M standard provides a common M2M service layer. This layer may be embedded into various types of hardware and software, and may connect numerous devices in the field.
The OneM2M standard uses a container resource and a child instance resource to describe data. The two resources include multiple attributes. Storage space corresponding to a content attribute in the child instance resource stores data. For each content attribute, one piece of data is correspondingly stored. However, there is time series data in the prior art, and the time series data is time series data. The time series data is a data series recorded in a time order according to a uniform indicator. It is an inevitable outcome to introduce the time series data to the OneM2M standard. However, there is no specific insert operation, delete operation, or query operation for the time series data in the prior art. Therefore, if multiple pieces of time series data are correspondingly stored for each content attribute, a corresponding operation cannot be performed for one piece or some pieces of time series data, thereby reducing operation reliability.
Embodiments of the present invention provide a time series data processing method and apparatus, so as to perform a corresponding search, delete, and insert operation on time series data, thereby improving operation reliability.
According to a first aspect, an embodiment of the present invention provides a time series data processing method, including: receiving, by a common services entity CSE, a request message sent by an application entity AE, where the request message carries a first operation type and at least one piece of first time series data, or carries a second operation type and at least one filter criterion, the first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation; and processing, by the common services entity CSE, a time series data set according to the request message, and sending a processing result to the application entity AE, where the first time series data is a two-dimensional array, including: a first data parameter and a first time parameter, the time series data set includes at least one piece of second time series data, the second time series data is a two-dimensional array, including: a second data parameter and a second time parameter, and the time series data set is stored in storage space corresponding to a container resource in a oneM2M standard.
With reference to the first aspect, in a first possible implementation manner of the first aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the insert operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: determining an insert location of the first time series data according to the first time parameter of the first time series data; and inserting the first time series data into the corresponding insert location.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the determining an insert location of the first time series data according to the first time parameter of the first time series data specifically includes: if the time series data set stores all the second time series data in ascending order of the second time parameters, querying, by the common services entity CSE, a second time parameter first greater than the first time parameter in ascending order of the second time parameters, and determining a storage location of corresponding second time series data as the insert location; or if the time series data set stores all the second time series data in descending order of the second time parameters, querying, by the common services entity CSE, a second time parameter first less than the first time parameter in descending order of the second time parameters, and determining a storage location of corresponding second time series data as the insert location.
With reference to the first aspect, in a third possible implementation manner of the first aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the delete operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: searching the time series data set for a second time parameter same as the first time parameter, and deleting second time series data corresponding to the second time parameter from the time series data set.
With reference to the first aspect, in a fourth possible implementation manner of the first aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the query operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: querying, in the time series data set, second time series data corresponding to a second time parameter same as the first time parameter.
With reference to the first aspect, in a fifth possible implementation manner of the first aspect, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the delete operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: if the filter criterion includes two first time parameters, deleting second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, deleting second time series data corresponding to a second data parameter that includes the at least one character field.
With reference to the first aspect, in a sixth possible implementation manner of the first aspect, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the query operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: if the filter criterion includes two first time parameters, querying second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, querying second time series data corresponding to a second data parameter that includes the at least one character field.
According to a second aspect, an embodiment of the present invention provides a time series data processing apparatus, including: a receiving module, configured to receive a request message sent by an application entity AE, where the request message carries a first operation type and at least one piece of first time series data, or carries a second operation type and at least one filter criterion, the first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation; and a processing module, configured to process a time series data set according to the request message, and send a processing result to the application entity AE, where the first time series data is a two-dimensional array, including: a first data parameter and a first time parameter, the time series data set includes at least one piece of second time series data, the second time series data is a two-dimensional array, including: a second data parameter and a second time parameter, and the time series data set is stored in storage space corresponding to a container resource in a oneM2M standard.
With reference to the second aspect, in a first possible implementation manner of the second aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the insert operation, the processing module is specifically configured to: determine an insert location of the first time series data according to the first time parameter of the first time series data; and insert the first time series data into the corresponding insert location.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the processing module is specifically configured to: if the time series data set stores all the second time series data in ascending order of the second time parameters, query a second time parameter first greater than the first time parameter in ascending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location; or if the time series data set stores all the second time series data in descending order of the second time parameters, query a second time parameter first less than the first time parameter in descending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location.
With reference to the second aspect, in a third possible implementation manner of the second aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the delete operation, the processing module is specifically configured to: search the time series data set for a second time parameter same as the first time parameter, and delete second time series data corresponding to the second time parameter from the time series data set.
With reference to the second aspect, in a fourth possible implementation manner of the second aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the query operation, the processing module is specifically configured to: query, in the time series data set, second time series data corresponding to a second time parameter same as the first time parameter.
With reference to the second aspect, in a fifth possible implementation manner of the second aspect, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the delete operation, the processing module is specifically configured to: if the filter criterion includes two first time parameters, delete second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, delete second time series data corresponding to a second data parameter that includes the at least one character field.
With reference to the second aspect, in a sixth possible implementation manner of the second aspect, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the query operation, the processing module is specifically configured to: if the filter criterion includes two first time parameters, query second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, query second time series data corresponding to a second data parameter that includes the at least one character field.
According to a third aspect, an embodiment of the present invention provides a time series data processing apparatus, including: a receiver, configured to receive a request message sent by an application entity AE, where the request message carries a first operation type and at least one piece of first time series data, or carries a second operation type and at least one filter criterion, the first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation; and a processor, configured to process a time series data set according to the request message, and send a processing result to the application entity AE, where the first time series data is a two-dimensional array, including: a first data parameter and a first time parameter, the time series data set includes at least one piece of second time series data, the second time series data is a two-dimensional array, including: a second data parameter and a second time parameter, and the time series data set is stored in storage space corresponding to a container resource in a oneM2M standard.
With reference to the third aspect, in a first possible implementation manner of the third aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the insert operation, the processor is specifically configured to: determine an insert location of the first time series data according to the first time parameter of the first time series data; and insert the first time series data into the corresponding insert location.
With reference to the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, the processor is specifically configured to: if the time series data set stores all the second time series data in ascending order of the second time parameters, query a second time parameter first greater than the first time parameter in ascending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location; or if the time series data set stores all the second time series data in descending order of the second time parameters, query a second time parameter first less than the first time parameter in descending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location.
With reference to the third aspect, in a third possible implementation manner of the third aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the delete operation, the processor is specifically configured to: search the time series data set for a second time parameter same as the first time parameter, and delete second time series data corresponding to the second time parameter from the time series data set.
With reference to the third aspect, in a fourth possible implementation manner of the third aspect, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the query operation, the processor is specifically configured to: query, in the time series data set, second time series data corresponding to a second time parameter same as the first time parameter.
With reference to the third aspect, in a fifth possible implementation manner of the third aspect, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the delete operation, the processor is specifically configured to: if the filter criterion includes two first time parameters, delete second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, delete second time series data corresponding to a second data parameter that includes the at least one character field.
With reference to the third aspect, in a sixth possible implementation manner of the third aspect, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the query operation, the processor is specifically configured to: if the filter criterion includes two first time parameters, query second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, query second time series data corresponding to a second data parameter that includes the at least one character field.
According to a fourth aspect, an embodiment of the present invention provides a time series data resource management method, including:
receiving, by a hosting common services entity Hosting CSE, an operation request for a time series data resource, where the operation request for the time series data resource is sent by an application entity AE or a common services entity CSE, the operation request carries an operation type and attribute information of the time series data resource, and the operation type is one of the following operations: create, delete, update, and obtain; and
processing, by the Hosting CSE, the time series data resource according to the operation type and the attribute information of the time series data resource, and sending a processing result to the AE or the CSE.
In a possible implementation manner, the time series data resource is used to store time series data information and the attribute information of the time series data resource.
In a possible implementation manner, the time series data information is stored in a time series data instance resource;
the time series data information includes a time at which time series data is collected and/or a time series data value; and
the time series data instance resource is a child resource of the time series data resource.
In a possible implementation manner, the attribute information of the time series data resource includes at least one of data time duplication and a data time type; where
the data time duplication is used to indicate whether times at which time series data of different time series data instance resources are collected are allowed to be the same; and
the data time type is used to indicate whether the time at which the time series data is collected is a relative time or an absolute time.
In a possible implementation manner, the attribute information of the time series data resource further includes a period and data detection.
In a possible implementation manner, the processing, by the Hosting CSE, the time series data resource according to the operation type and the attribute information of the time series data resource includes:
if the operation type is create, verifying, by the Hosting CSE, the attribute information of the time series data resource, and after the verification succeeds, creating the time series data resource; or
if the attribute information of the time series data resource further includes the period and the data detection, detecting, by the Hosting CSE, the time series data according to the period, and when the time series data is missing, storing, by the Hosting CSE, a time at which the time series data is missing.
According to a fifth aspect, another embodiment of the present invention provides a time series data instance resource management method, including:
receiving, by a Hosting CSE, an operation request for a time series data instance resource, where the operation request for the time series data instance resource is sent by an AE or a CSE, and the operation request carries an operation type and attribute information of the time series data instance resource; and
processing, by the Hosting CSE, the time series data instance resource according to the operation type and the attribute information of the time series data instance resource, and sending a processing result to the AE or the CSE.
In a possible implementation manner, the operation type is one of the following operations: create, delete, update, and obtain.
In a possible implementation manner, the attribute information of the time series data instance resource includes at least one of a time at which time series data is collected and a time series data value.
In a possible implementation manner, time series data includes a time at which the time series data is collected and a time series data value. The time series data is stored in a content attribute of a content instance resource. The time at which the time series data is collected is stored in a content time attribute of the content instance resource.
The embodiments of the present invention provide a time series data processing method and apparatus, where the method includes: receiving, by a common services entity CSE, a request message sent by an application entity AE, where the request message carries a first operation type and at least one piece of first time series data, or carries a second operation type and at least one filter criterion, the first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation; and processing, by the common services entity CSE, a time series data set according to the request message, and sending a processing result to the application entity AE, where the first time series data is a two-dimensional array, including: a first data parameter and a first time parameter, the time series data set includes at least one piece of second time series data, the second time series data is a two-dimensional array, including: a second data parameter and a second time parameter, and the time series data set is stored in storage space corresponding to a container resource in a oneM2M standard. Therefore, a corresponding search, delete, and insert operation may be performed on time series data, so as to improve operation reliability.
To describe the technical solutions in the embodiments of the present invention more clearly, the following briefly describes the accompanying drawings required for describing the embodiments. Apparently, the accompanying drawings in the following description show merely some embodiments of the present invention, and persons of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts.
1 is schematic diagram 6 of a data format according to an embodiment of the present invention;
2 is a Chinese format of schematic diagram 6 of a data format according to an embodiment of the present invention;
1 is schematic diagram 7 of a data format according to an embodiment of the present invention;
2 is a Chinese format of schematic diagram 7 of a data format according to an embodiment of the present invention;
The following clearly describes the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are merely some but not all of the embodiments of the present invention. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
There are three types of interfaces between layers in the oneM2M system. Mca is an interface between the AE and the CSE, and is responsible for communication from the AE to the CSE or from the CSE to the AE. Mcc and Mcc′ are interfaces between two CSEs, and are responsible for communication between the CSEs. Mcn is an interface between the CSE and the NSE, and is responsible for communication from the CSE to the NSE or from the NSE to the CSE. It should be understood that, in the present invention, all entities in the oneM2M system, for example, an AE, a CSE, and data, are represented in a resource form.
S201. The common services entity CSE receives a request message sent by an application entity AE, where the request message carries a first operation type and at least one piece of first time series data, or carries a second operation type and at least one filter criterion, the first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation.
S202. The common services entity CSE processes a time series data set according to the request message, and sends a processing result to the application entity AE.
Specifically, the common services entity CSE receives the request message sent by the application entity AE. The application entity AE herein may be an intelligent terminal such as a sensor, a computer, a notebook computer, or a mobile phone. The request message carries the first operation type and the at least one piece of first time series data, or carries the second operation type and the at least one filter criterion. The first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation. The first time series data is a two-dimensional array, including: a first data parameter and a first time parameter. The time series data set includes at least one piece of second time series data, and the second time series data is a two-dimensional array, including: a second data parameter and a second time parameter. The time series data set is stored in storage space corresponding to a container resource in a oneM2M standard. Certainly, the request message may further carry an application entity AE identifier (Identify, ID for short) or a common services entity CSE identifier. It should be noted that the first time parameter and the second time parameter may be determined by the application entity AE, or may be determined by the common services entity CSE. Therefore, a time parameter in a piece of time series data refers to a time at which the time series data is generated in the application entity AE or the common services entity CSE. The first time series data herein is equivalent to to-be-processed data. The second time series data is data included in the time series data set. A data parameter in the first time series data or the second time series data may be a real number, a picture, or any piece of abstract one-dimensional data. In the prior art, a container resource and a child instance resource are used to describe data. The two resources include multiple attributes, and the multiple attributes include universal attributes. For example, a universal attribute in the container resource includes: a resource type, a resource identifier, a parent node identifier, an expiration time, an access control policy identifier, and a state tag; and a universal attribute in the child instance resource includes: a resource type, a resource identifier, a parent node identifier, a creator, a creation type, and a last modified time. In addition, the container resource and the child instance resource further include specific attributes.
In the prior art, storage space corresponding to a content attribute in a child instance resource stores data. For each content attribute, one piece of data is correspondingly stored. The data herein refers to any piece of abstract one-dimensional data. However, in real life, time series data is usually used to describe a time-characterized record. For example, populations at the ends of years from 2005 to 2014 in one province are represented by a time series data array including 10 time point numbers. A data parameter of each piece of time series data is population, and a time parameter of each piece of time series data is year.
Further, the time series data may be represented as item=(c, t), where c indicates the data parameter, and t indicates the time parameter. The time series data set may be represented as DS={(c1, t1), (c2, t2), (cn, tn)}, or DS={item1, item2, itemn}, and there is a partial ordering relation between DS,≦ and the time series data set DS. Storage of time series data may include the following four cases:
1. Based on the data format shown in
2. Based on the data format shown in
3. Based on the data format shown in
4. Based on the data format shown in
Further, based on the foregoing definition that the time series data is a two-dimensional array, three operations different from those in the prior art may be defined: an insert operation, a delete operation, and a query operation. Regardless of whether a time series data storage manner is which of the foregoing four cases, multiple pieces of time series data are generally stored, and all the foregoing three operations are implemented based on a time parameter in the time series data. If receiving a request message sent by the application entity AE, where the request message carries a first operation type and at least one piece of first time series data, for example, the request message carries the first operation type: a delete operation, and one piece of first time series data, the common services entity CSE may search a time series data set for the first time series data. If there is the first time series data in the time series data set, the common services entity CSE directly deletes the first time series data. If the request message carries a second operation type and at least one filter criterion, for example, the second operation type is the delete operation, and the filter criterion has a time parameter range, the common services entity CSE deletes second time series data, whose time parameter falls within the range, in the time series data set. Finally, the common services entity CSE sends a processing result to the application entity AE.
This embodiment of the present invention provides a time series data processing method, including: receiving, by a common services entity CSE, a request message sent by an application entity AE, where the request message carries a first operation type and at least one piece of first time series data, or carries a second operation type and at least one filter criterion, the first operation type is an insert operation, a delete operation, or a query operation, and the second operation type is a delete operation or a query operation; and processing, by the common services entity CSE, a time series data set according to the request message, and sending a processing result to the application entity AE, where both the first time series data and second time series data are two-dimensional arrays, and the time series data set includes at least one piece of second time series data. According to the processing method provided in this embodiment of the present invention, in comparison with the prior art, a corresponding operation may be performed for one piece or some pieces of second time series data in the time series data set, thereby improving operation reliability.
Based on the foregoing embodiment, optionally, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the insert operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: determining an insert location of the first time series data according to the first time parameter of the first time series data; and inserting the first time series data into the corresponding insert location.
The determining an insert location of the first time series data according to the first time parameter of the first time series data specifically includes: first, if the time series data set stores all second time series data in ascending order of second time parameters, querying a second time parameter first greater than the first time parameter in ascending order of the second time parameters, and determining a storage location of corresponding second time series data as the insert location; or second, if the time series data set stores all second time series data in descending order of second time parameters, querying a second time parameter first less than the first time parameter in descending order of the second time parameters, and determining a storage location of corresponding second time series data as the insert location.
For example, it is assumed that the first operation type carried in the request message is an insert operation, and the first time series data is (50, 2009). Before the common services entity CSE performs the insert operation, a time series data set of the common services entity CSE is {(40, 2007), (39, 2008), (42, 2010)}. Then, a process of determining the insert location according to a first time parameter 2009 is: when the time series data set stores all the second time series data in ascending order of second time parameters, querying a second time parameter first greater than the first time parameter in ascending order of the second time parameters. Therefore, the second time parameter that is found in this example and that is first greater than the first time parameter is 2010. In this case, a storage location of (42, 2010) is determined as an insert location of the first time series data.
Optionally, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the delete operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: searching the time series data set for a second time parameter same as the first time parameter, and deleting second time series data corresponding to the second time parameter from the time series data set.
Further, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the query operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: querying, in the time series data set, second time series data corresponding to a second time parameter same as the first time parameter.
If the request message carries the second operation type and the at least one filter criterion, and the second operation type is the delete operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: if the filter criterion includes two first time parameters, deleting second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, deleting second time series data corresponding to a second data parameter that includes the at least one character field.
For example, it is assumed that a time series data set of the common services entity CSE is {(40, 2007), (39, 2008), (50, 2009), (42, 2010)}. When the second operation type carried in the request message is a delete operation, and a given filter criterion is that two time parameters are 2008 and 2010, the common services entity CSE carries, according to the request message, second time series data whose second time parameter is between 2008 and 2010. In this example, (50, 2009) needs to be deleted.
For another example, it is assumed that a time series data set of the common services entity CSE is {(40, 2007), (400, 2008), (4000, 2009), (40000, 2010)}. When the second operation type carried in the request message is a delete operation, and a given filter criterion is a character field “400*”, the common services entity CSE deletes, according to the request message, second time series data corresponding to a second data parameter that includes a character field “400”. In this example, (400, 2008), (4000, 2009), and (40000, 2010) need to be deleted.
Optionally, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the query operation, the processing, by the common services entity CSE, a time series data set according to the request message specifically includes: if the filter criterion includes two first time parameters, querying second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, querying second time series data corresponding to a second data parameter that includes the at least one character field.
In the foregoing examples, corresponding operation processing is performed for a time series data set. In addition, the foregoing insert operation, delete operation, and query operation may be performed for an attribute. For example, the delete operation is performed for a content attribute, that is, the delete operation is to delete all time series data stored in storage space corresponding to the content attribute.
For example, CSEs of an X taxi company store uploaded data of all taxis of the company, and a taxi of the company sends location information of the taxi to the CSE of the company at an interval of 30 seconds. For example, location information of a α taxi stored in the CSE of the company may be described as GPSα={(l1, t1), (l2, t2), . . . , (ln t)|t1<t2< . . . <tn}. li indicates a location coordinate of the α taxi in an ith time of statistics collecting, and ti indicates a time at which the ith time of statistics collecting is performed. Certainly, when statistics collecting is performed, passenger carrying information of the α taxi, fuel consumption information of the α taxi, or the like, may further be included.
GPS
α={(l1,t1),(l2,t2), . . . ,(ln,tn),(ln+1,tn+1)|t1<t2<<tn<tn+1}.
The foregoing case is relatively special. Generally, to avoid occupying a resource such as a communications channel, a vehicle sends some pieces or dozens of pieces of location information once:
GPS′α={(ln+1, tn+1), (ln+2, tn+2) . . . , (ln+m,tn+m)|tn+1<tn+2 . . . <tn+m}. When the CSE of the company performs the insert operation, m pieces of first time series data are included. After the insert operation is completed,
GPS
α={(l1,t1),(l2,t2), . . . ,(li,ti), . . . ,(ln,tn),(ln+1,tn+1), . . . ,(ln+m,tn+m)|t1<t2< . . . <tn< . . . <tn+1<, . . . ,tn+m}
When the α taxi queries location information of the α taxi in a specific time period, the CSE performs a query operation. The α taxi may query time series data whose time parameter is between ti and tj.
In conclusion, first, all the insert operation, the delete operation, and the query operation provided in the present invention are to perform a corresponding operation for one piece or multiple pieces of time series data in a time series data set. Therefore, operation reliability is improved. Second, the time series data is a two-dimensional array. Therefore, insertion, deletion, or query may be performed according to a time parameter of the time series data, thereby improving operation efficiency.
In a first optional manner, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the insert operation, the processing module 902 is specifically configured to: determine an insert location of the first time series data according to the first time parameter of the first time series data; and insert the first time series data into the corresponding insert location. Further, the processing module 902 is specifically configured to: if the time series data set stores all second time series data in ascending order of second time parameters, query a second time parameter first greater than the first time parameter in ascending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location; or if the time series data set stores all second time series data in descending order of second time parameters, query a second time parameter first less than the first time parameter in descending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location.
In a second optional manner, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the delete operation, the processing module 902 is specifically configured to: search the time series data set for a second time parameter same as the first time parameter, and delete second time series data corresponding to the second time parameter from the time series data set.
In a third optional manner, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the query operation, the processing module 902 is specifically configured to: query, in the time series data set, second time series data corresponding to a second time parameter same as the first time parameter.
In a fourth optional manner, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the delete operation, the processing module 902 is specifically configured to: if the filter criterion includes two first time parameters, delete second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, delete second time series data corresponding to a second data parameter that includes the at least one character field.
In a fifth optional manner, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the query operation, the processing module 902 is specifically configured to: if the filter criterion includes two first time parameters, query second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, query second time series data corresponding to a second data parameter that includes the at least one character field.
The time series data processing apparatus provided in this embodiment is configured to execute the implementation technical solution of the time series data processing method corresponding to
In a first possible implementation manner, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the insert operation, the processor 1002 is specifically configured to: determine an insert location of the first time series data according to the first time parameter of the first time series data; and insert the first time series data into the corresponding insert location. The processor 1002 is specifically configured to: if the time series data set stores all second time series data in ascending order of second time parameters, query a second time parameter first greater than the first time parameter in ascending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location; or if the time series data set stores all second time series data in descending order of second time parameters, query a second time parameter first less than the first time parameter in descending order of the second time parameters, and determine a storage location of corresponding second time series data as the insert location.
In a second possible implementation manner, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the delete operation, the processor 1002 is specifically configured to: search the time series data set for a second time parameter same as the first time parameter, and delete second time series data corresponding to the second time parameter from the time series data set.
In a third possible implementation manner, if the request message carries the first operation type and the at least one piece of first time series data, and the first operation type is the query operation, the processor 1002 is specifically configured to: query, in the time series data set, second time series data corresponding to a second time parameter same as the first time parameter.
In a fourth possible implementation manner, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the delete operation, the processor 1002 is specifically configured to: if the filter criterion includes two first time parameters, delete second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, delete second time series data corresponding to a second data parameter that includes the at least one character field.
In a fifth optional manner, if the request message carries the second operation type and the at least one filter criterion, and the second operation type is the query operation, the processor 1002 is specifically configured to: if the filter criterion includes two first time parameters, query second time series data corresponding to a second time parameter between the two first time parameters in the time series data set; or if the filter criterion includes at least one character field, query second time series data corresponding to a second data parameter that includes the at least one character field.
The time series data processing apparatus provided in this embodiment is configured to execute the implementation technical solution of the time series data processing method corresponding to
As shown in
S1101. A hosting common services entity Hosting CSE receives an operation request for a time series data resource, where the operation request for the time series data resource is sent by an application entity AE or a common services entity CSE, the operation request carries an operation type and attribute information of the time series data resource, and the operation type is one of the following operations: create, delete, update, and obtain.
S1102. The Hosting CSE processes the time series data resource according to the operation type and the attribute information of the time series data resource, and sends a processing result to the AE or the CSE.
The time series data resource is used to store time series data information and the attribute information of the time series data resource.
The time series data information is stored in a time series data instance resource.
The time series data information includes a time at which time series data is collected and/or a time series data value.
The time series data instance resource is a child resource of the time series data resource.
Optionally, in an embodiment, an example is used to describe a relationship between a time series data resource (timeSeriesData) and a time series data instance resource (tsdInstance).
As shown in
All records of heartbeat information of a person are stored in a time series data resource (timeSeriesData), and each specific piece of record information is stored in a time series data instance resource (tsdInstance). That is, the time series data resource (timeSeriesData) is a time series data instance resource (tsdInstance) set. A specific oneM2M resource structure is reflected as follows: A time series data instance resource (tsdInstance) is a child resource of a time series data resource (timeSeriesData), and the time series data resource (timeSeriesData) may have multiple child time series data instance resources (tsdInstance). A time and a data value recorded each time correspond to two attributes of the time series data instance resource (tsdInstance).
The attribute information of the time series data resource includes at least one of data time duplication and a data time type.
The data time duplication is used to indicate whether times at which time series data of different time series data instance resources are collected are allowed to be the same.
The data time type is used to indicate whether the time at which the time series data is collected is a relative time or an absolute time.
This embodiment describes a function of a time series data resource (timeSeriesData resource) and a specific resource structure: attribute information and child resources. It should be noted that, only two types of attribute information are listed in this embodiment: data time duplication and a data time type. In another embodiment, one or more pieces of attribute information shown in a round rectangle in
A time series data resource (timeSeriesData resource) and a time series data instance resource (tsdInstance resource) may be understood as: All time series data records of a same object (for example, human heartbeat information collection) are stored in the timeSeriesData, and each record is stored in the tsdInstnace.
Two new resource structures are shown in
In an embodiment, the attribute information of the time series data resource further includes a period and data detection.
Specifically, as shown in
if the operation type is create, verifying, by the Hosting CSE, the attribute information of the time series data resource, and after the verification succeeds, creating the time series data resource; or
if the attribute information of the time series data resource further includes the period and the data detection, detecting, by the Hosting CSE, the time series data according to the period, and when the time series data is missing, storing, by the Hosting CSE, a time at which the time series data is missing.
Herein, when a time series data resource (timeSeriesData resource) Create Request operation is performed, if a time series data resource carries two pieces of attribute information: period and dataDetect, the hosting CSE correspondingly sets a specific operation.
As shown in
S1401. A Hosting CSE receives an operation request for a time series data instance resource, where the operation request for the time series data instance resource is sent by an AE or a CSE, and the operation request carries an operation type and attribute information of the time series data instance resource.
S1402. The Hosting CSE processes the time series data instance resource according to the operation type and the attribute information of the time series data instance resource, and sends a processing result to the AE or the CSE.
The operation type is one of the following operations: create, delete, update, and obtain.
The attribute information of the time series data instance resource includes at least one of a time at which time series data is collected and a time series data value.
This embodiment describes attribute information of a time series data instance resource (tsdInstance resource). A structure of the tsdInstance resource is the structure shown in
It should be noted that, in another embodiment of the present invention, as shown in
Persons of ordinary skill in the art may understand that all or some of the steps of the method embodiments may be implemented by a program instructing relevant hardware. The program may be stored in a computer-readable storage medium. When the program runs, the steps of the method embodiments are performed. The foregoing storage medium includes: any medium that can store program code, such as a ROM, a RAM, a magnetic disk, or an optical disc.
Finally, it should be noted that the foregoing embodiments are merely intended for describing the technical solutions of the present invention, but not for limiting the present invention. Although the present invention is described in detail with reference to the foregoing embodiments, persons of ordinary skill in the art should understand that they may still make modifications to the technical solutions described in the foregoing embodiments or make equivalent replacements to some or all technical features thereof, without departing from the scope of the technical solutions of the embodiments of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
PCT/CN2015/074107 | Mar 2015 | CN | national |
This application is a continuation of International Application No. PCT/CN2015/093378, filed on Oct. 30, 2015, which claims priority to International Application No. PCT/CN2015/074107, filed on Mar. 12, 2015. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2015/093378 | Oct 2015 | US |
Child | 15702001 | US |