Skip to content

Commit f156431

Browse files
authored
Add option for changing ignoreBadDataPoints in GetExtractedRanges (#646)
* Add option for changing ignoreBadDataPoints in GetExtractedRanges * remove false change
1 parent c95d7f4 commit f156431

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

Cognite.Extensions/TimeSeries/DataPointExtensions.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,15 @@ private static async Task<HashSet<Identity>> DeleteDataPointsIgnoreErrorsChunk(
466466
/// <param name="chunkSize">Number of timeseries per request</param>
467467
/// <param name="throttleSize">Maximum number of parallel requests</param>
468468
/// <param name="token">Cancellation token</param>
469+
/// <param name="ignoreBadDataPoints">Ignore bad status datapoints, true by default</param>
469470
/// <returns>Dictionary from externalId to last timestamp, only contains existing timeseries</returns>
470471
public static async Task<IDictionary<Identity, DateTime>> GetLatestTimestamps(
471472
this DataPointsResource dataPoints,
472473
IEnumerable<(Identity id, DateTime before)> ids,
473474
int chunkSize,
474475
int throttleSize,
475-
CancellationToken token)
476+
CancellationToken token,
477+
bool ignoreBadDataPoints = true)
476478
{
477479
var ret = new ConcurrentDictionary<Identity, DateTime>();
478480
var idSet = new HashSet<Identity>(ids.Select(id => id.id));
@@ -497,6 +499,7 @@ public static async Task<IDictionary<Identity, DateTime>> GetLatestTimestamps(
497499
{
498500
idt.Before = pair.before.ToUnixTimeMilliseconds().ToString();
499501
}
502+
idt.IgnoreBadDataPoints = ignoreBadDataPoints;
500503
return idt;
501504
})
502505
.ChunkBy(chunkSize)
@@ -558,21 +561,23 @@ await generators
558561
/// <param name="chunkSize">Number of timeseries per request</param>
559562
/// <param name="throttleSize">Maximum number of parallel requests</param>
560563
/// <param name="token">Cancellation token</param>
564+
/// <param name="ignoreBadDataPoints">Ignore bad status datapoints, true by default</param>
561565
/// <returns>Dictionary from externalId to first timestamp, only contains existing timeseries</returns>
562566
public static async Task<IDictionary<Identity, DateTime>> GetEarliestTimestamps(
563567
this DataPointsResource dataPoints,
564568
IEnumerable<(Identity id, DateTime after)> ids,
565569
int chunkSize,
566570
int throttleSize,
567-
CancellationToken token)
571+
CancellationToken token,
572+
bool ignoreBadDataPoints = true)
568573
{
569574
var ret = new ConcurrentDictionary<Identity, DateTime>();
570575
var idSet = new HashSet<Identity>(ids.Select(id => id.id));
571576

572577
var chunks = ids
573578
.Select((pair) =>
574579
{
575-
var query = new DataPointsQueryItem();
580+
var query = new DataPointsQueryItem() { IgnoreBadDataPoints = ignoreBadDataPoints };
576581
if (pair.id.Id.HasValue)
577582
{
578583
query.Id = pair.id.Id.Value;
@@ -660,6 +665,7 @@ await generators
660665
/// <param name="latest">If true, fetch latest timestamps</param>
661666
/// <param name="earliest">If true, fetch earliest timestamps</param>
662667
/// <param name="token">Cancellation token</param>
668+
/// <param name="ignoreBadDataPoints">Ignore bad status datapoints, true by default</param>
663669
/// <returns></returns>
664670
public static async Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
665671
this DataPointsResource dataPoints,
@@ -669,7 +675,8 @@ public static async Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
669675
int throttleSize,
670676
bool latest,
671677
bool earliest,
672-
CancellationToken token)
678+
CancellationToken token,
679+
bool ignoreBadDataPoints = true)
673680
{
674681
if (ids == null)
675682
{
@@ -684,12 +691,12 @@ public static async Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
684691
if (latest)
685692
{
686693
tasks.Add(dataPoints.GetLatestTimestamps(ids.Select(pair => (pair.id, pair.limit?.Last ?? DateTime.MaxValue)),
687-
chunkSizeLatest, throttleSize, token));
694+
chunkSizeLatest, throttleSize, token, ignoreBadDataPoints));
688695
}
689696
if (earliest)
690697
{
691698
tasks.Add(dataPoints.GetEarliestTimestamps(ids.Select(pair => (pair.id, pair.limit?.First ?? CogniteTime.DateTimeEpoch)),
692-
chunkSizeEarliest, throttleSize, token));
699+
chunkSizeEarliest, throttleSize, token, ignoreBadDataPoints));
693700
}
694701
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
695702
if (latest)

ExtractorUtils/Cognite/CogniteDestination.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,12 +719,14 @@ public Task DeleteRowsAsync(string dbName, string tableName, IEnumerable<string>
719719
/// <param name="token">Cancellation token</param>
720720
/// <param name="earliest">If true, fetch earliest timestamps, default true</param>
721721
/// <param name="latest">If true, fetch latest timestamps, default true</param>
722+
/// <param name="ignoreBadDataPoints">Ignore bad status datapoints, true by default</param>
722723
/// <returns></returns>
723724
public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
724725
IEnumerable<Identity> ids,
725726
CancellationToken token,
726727
bool earliest = true,
727-
bool latest = true
728+
bool latest = true,
729+
bool ignoreBadDataPoints = true
728730
)
729731
{
730732
return _client.DataPoints.GetExtractedRanges(
@@ -734,7 +736,8 @@ public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
734736
_throttling.Ranges,
735737
latest,
736738
earliest,
737-
token);
739+
token,
740+
ignoreBadDataPoints);
738741
}
739742

740743

@@ -747,12 +750,14 @@ public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
747750
/// <param name="token">Cancellation token</param>
748751
/// <param name="earliest">If true, fetch earliest timestamps, default true</param>
749752
/// <param name="latest">If true, fetch latest timestamps, default true</param>
753+
/// <param name="ignoreBadDataPoints">Ignore bad status datapoints, true by default</param>
750754
/// <returns></returns>
751755
public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
752756
IEnumerable<(Identity id, TimeRange limit)> ids,
753757
CancellationToken token,
754758
bool earliest = true,
755-
bool latest = true
759+
bool latest = true,
760+
bool ignoreBadDataPoints = true
756761
)
757762
{
758763
return _client.DataPoints.GetExtractedRanges(
@@ -762,7 +767,8 @@ public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(
762767
_throttling.Ranges,
763768
latest,
764769
earliest,
765-
token);
770+
token,
771+
ignoreBadDataPoints);
766772
}
767773

768774

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.39.1
1+
1.40.0

0 commit comments

Comments
 (0)