Class DataPointExtensions
Extensions to datapoints
Inherited Members
Namespace: Cognite.Extensions
Assembly: Cognite.Extensions.dll
Syntax
public static class DataPointExtensions
Methods
| Edit this page View SourceDeleteIgnoreErrorsAsync(DataPointsResource, IDictionary<Identity, IEnumerable<TimeRange>>, int, int, int, int, CancellationToken)
Deletes ranges of data points in CDF. The ranges
parameter contains the first (inclusive)
and last (inclusive) timestamps for the range. After the delete request is sent to CDF, attempt to confirm that
the data points were deleted by querying the time range. Deletes in CDF are eventually consistent, failing to
confirm the deletion does not mean that the operation failed in CDF
Declaration
public static Task<DeleteError> DeleteIgnoreErrorsAsync(this DataPointsResource dataPoints, IDictionary<Identity, IEnumerable<TimeRange>> ranges, int deleteChunkSize, int listChunkSize, int deleteThrottleSize, int listThrottleSize, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataPointsResource | dataPoints | Cognite datapoints resource |
IDictionary<Identity, IEnumerable<TimeRange>> | ranges | Ranges to delete |
int | deleteChunkSize | Chunk size for delete operations |
int | listChunkSize | Chunk size for list operations |
int | deleteThrottleSize | Throttle size for delete operations |
int | listThrottleSize | Throttle size for list operations |
CancellationToken | token | Cancelation token |
Returns
Type | Description |
---|---|
Task<DeleteError> | A DeleteError object with any missing ids or ids with unconfirmed deletes |
GetEarliestTimestamps(DataPointsResource, IEnumerable<(Identity id, DateTime after)>, int, int, CancellationToken)
Get the first timestamp for each time series given in ids
after each given timestamp.
Ignores timeseries not in CDF. The return dictionary contains only ids that exist in CDF.
Declaration
public static Task<IDictionary<Identity, DateTime>> GetEarliestTimestamps(this DataPointsResource dataPoints, IEnumerable<(Identity id, DateTime after)> ids, int chunkSize, int throttleSize, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataPointsResource | dataPoints | DataPointsResource to use |
IEnumerable<(Identity id, DateTime before)> | ids | ExternalIds and last timestamp. Let last timestamp be Epoch to use default. |
int | chunkSize | Number of timeseries per request |
int | throttleSize | Maximum number of parallel requests |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<IDictionary<Identity, DateTime>> | Dictionary from externalId to first timestamp, only contains existing timeseries |
GetExtractedRanges(DataPointsResource, IEnumerable<(Identity id, TimeRange limit)>, int, int, int, bool, bool, CancellationToken)
Fetches the range of datapoints present in CDF. Limited by given ranges for each id. Note that end limits closer to actual endpoints in CDF is considerably faster.
Declaration
public static Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(this DataPointsResource dataPoints, IEnumerable<(Identity id, TimeRange limit)> ids, int chunkSizeEarliest, int chunkSizeLatest, int throttleSize, bool latest, bool earliest, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataPointsResource | dataPoints | DataPointsResource to use |
IEnumerable<(Identity id, TimeRange limit)> | ids | ExternalIds and start/end of region to look for datapoints. Use TimeRange.Complete for first after epoch, and last before now. |
int | chunkSizeEarliest | Number of timeseries to read for each earliest request |
int | chunkSizeLatest | Number of timeseries to read for each latest request |
int | throttleSize | Max number of parallel requests |
bool | latest | If true, fetch latest timestamps |
bool | earliest | If true, fetch earliest timestamps |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<IDictionary<Identity, TimeRange>> |
GetLatestTimestamps(DataPointsResource, IEnumerable<(Identity id, DateTime before)>, int, int, CancellationToken)
Get the last timestamp for each time series given in ids
before each given timestamp.
Ignores timeseries not in CDF. The return dictionary contains only ids that exist in CDF.
Note that end limits closer to actual endpoints in CDF is considerably faster.
Declaration
public static Task<IDictionary<Identity, DateTime>> GetLatestTimestamps(this DataPointsResource dataPoints, IEnumerable<(Identity id, DateTime before)> ids, int chunkSize, int throttleSize, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataPointsResource | dataPoints | DataPointsResource to use |
IEnumerable<(Identity id, DateTime before)> | ids | ExternalIds and last timestamp. Let last timestamp be DateTime.MaxValue to use default ("now"). |
int | chunkSize | Number of timeseries per request |
int | throttleSize | Maximum number of parallel requests |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<IDictionary<Identity, DateTime>> | Dictionary from externalId to last timestamp, only contains existing timeseries |
InsertAsync(Client, IDictionary<Identity, IEnumerable<Datapoint>>, int, int, int, int, int, int, SanitationMode, RetryMode, double?, CancellationToken)
Insert datapoints to timeseries. Insertions are chunked and cleaned according to configuration, and can optionally handle errors.
Declaration
public static Task<CogniteResult<DataPointInsertError>> InsertAsync(Client client, IDictionary<Identity, IEnumerable<Datapoint>> points, int keyChunkSize, int valueChunkSize, int throttleSize, int timeseriesChunkSize, int timeseriesThrottleSize, int gzipCountLimit, SanitationMode sanitationMode, RetryMode retryMode, double? nanReplacement, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
Client | client | Cognite client |
IDictionary<Identity, IEnumerable<Datapoint>> | points | Datapoints to insert |
int | keyChunkSize | Maximum number of timeseries per chunk |
int | valueChunkSize | Maximum number of datapoints per timeseries |
int | throttleSize | Maximum number of parallel request |
int | timeseriesChunkSize | Maximum number of timeseries to retrieve per request |
int | timeseriesThrottleSize | Maximum number of parallel requests to retrieve timeseries |
int | gzipCountLimit | Number of datapoints total before using gzip compression. |
SanitationMode | sanitationMode | How to sanitize datapoints |
RetryMode | retryMode | How to handle retries |
double? | nanReplacement | Optional replacement for NaN double values |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<CogniteResult<DataPointInsertError>> | Result with a list of errors |
InsertAsyncCreateMissing(Client, IDictionary<Identity, IEnumerable<Datapoint>>, int, int, int, int, int, int, SanitationMode, RetryMode, double?, long?, CancellationToken)
Insert datapoints to timeseries. Insertions are chunked and cleaned according to configuration, and can optionally handle errors. If any timeseries missing from the result and inserted by externalId, they are created before the points are inserted again.
Declaration
public static Task<(CogniteResult<DataPointInsertError> DataPointResult, CogniteResult<TimeSeries, TimeSeriesCreate>? TimeSeriesResult)> InsertAsyncCreateMissing(Client client, IDictionary<Identity, IEnumerable<Datapoint>> points, int keyChunkSize, int valueChunkSize, int throttleSize, int timeseriesChunkSize, int timeseriesThrottleSize, int gzipCountLimit, SanitationMode sanitationMode, RetryMode retryMode, double? nanReplacement, long? dataSetId, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
Client | client | Cognite client |
IDictionary<Identity, IEnumerable<Datapoint>> | points | Datapoints to insert |
int | keyChunkSize | Maximum number of timeseries per chunk |
int | valueChunkSize | Maximum number of datapoints per timeseries |
int | throttleSize | Maximum number of parallel request |
int | timeseriesChunkSize | Maximum number of timeseries to retrieve per request |
int | timeseriesThrottleSize | Maximum number of parallel requests to retrieve timeseries |
int | gzipCountLimit | Number of datapoints total before using gzip compression. |
SanitationMode | sanitationMode | How to sanitize datapoints |
RetryMode | retryMode | How to handle retries |
double? | nanReplacement | Optional replacement for NaN double values |
long? | dataSetId | Optional data set id |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<(CogniteResult<DataPointInsertError> DataPointResult, CogniteResult<TimeSeries, TimeSeriesCreate> TimeSeriesResult)> | Results with a list of errors. If TimeSeriesResult is null, no timeseries were attempted created. |
ToInsertRequest(IDictionary<Identity, IEnumerable<Datapoint>>)
Create a protobuf insertion request from dictionary
Declaration
public static DataPointInsertionRequest ToInsertRequest(this IDictionary<Identity, IEnumerable<Datapoint>> dps)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<Identity, IEnumerable<Datapoint>> | dps | Datapoints to insert |
Returns
Type | Description |
---|---|
DataPointInsertionRequest | Converted request |