This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace deequ.Analyzers | |
{ | |
interface IAnalyzer<out M> | |
{ | |
M Calculate(DataFrame data, Option<IStateLoader> aggregateWith = default, Option<IStatePersister> saveStateWith = default); | |
IEnumerable<Action<StructType>> Preconditions(); | |
M ToFailureMetric(Exception e); | |
void AggregateStateTo(IStateLoader sourceA, IStateLoader sourceB, IStatePersister target); | |
M LoadStateAndComputeMetric(IStateLoader source); | |
void CopyStateTo(IStateLoader source, IStatePersister target); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VerificationResult result; | |
//... | |
if (result.Status == CheckStatus.Success) { | |
Console.WriteLine("Success"); | |
} else { | |
Console.WriteLine("Errors:"); | |
IEnumerable<ConstraintResult> constraints = result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using deequ.Constraints; | |
namespace deequ.Checks | |
{ | |
public class CheckResult | |
{ | |
Check Check { get;} | |
CheckStatus Status { get;} | |
IEnumerable<ConstraintResult> ConstraintResults { get;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VerificationResult | |
{ | |
Dictionary<Check, CheckResult> CheckResults; | |
Dictionary<IAnalyzer<IMetric>, IMetric> Metrics; | |
CheckStatus Status; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val numTitles = fetchNumTitles(); | |
val maxExpectedPhoneRatio = calcMaxExpectedPhoneRatio(); | |
val result = VerificationSuite() | |
.onData(data) | |
.addCheck(Check(CheckLevel.Error, "Completeness + uniqueness on main fields") | |
.areComplete(Seq("customerId", "title", "impressionStart", "impressionEnd", "deviceType", "priority")) | |
.areUnique(Seq("customerId", "countryResidence", "deviceType", "title")) | |
.hasApproxCountDistinct("", value => numTitles >= value) | |
.hasHistogramValues("deviceType", distribution => maxExpectedPhoneRatio >= distribution("phone").ratio)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using deequ; | |
using deequ.Checks; | |
using deequ.Extensions; | |
using Microsoft.Spark.Sql; | |
namespace DeequExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1: Spawn 20 threads | |
2: Performing n.20 Set operations from multiple threads | |
Setting the following id: 16 | |
Setting the following id: 3 | |
Setting the following id: 18 | |
Setting the following id: 1 | |
Setting the following id: 0 | |
Setting the following id: 2 | |
Setting the following id: 6 | |
Setting the following id: 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading; | |
using Xunit; | |
using Xunit.Abstractions; | |
namespace Blog.LRUCacheThreadSafe.Tests | |
{ | |
public class LRUCacheSignalingTests | |
{ | |
private const int threadNumbers = 20; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading; | |
namespace Blog.LRUCacheThreadSafe | |
{ | |
public class LRUCacheReaderWriterLock<T> | |
{ | |
private readonly Dictionary<int, LRUCacheItem<T>> _records = new Dictionary<int, LRUCacheItem<T>>(); | |
private readonly LinkedList<int> _freq = new LinkedList<int>(); | |
private readonly ReaderWriterLockSlim _rw = new ReaderWriterLockSlim(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LRUCacheReaderWriterLock<T> | |
{ | |
private readonly Dictionary<int, LRUCacheItem<T>> _records =new Dictionary<int, LRUCacheItem<T>>(); | |
private readonly LinkedList<int> _freq = new LinkedList<int>(); | |
private readonly ReaderWriterLockSlim _rw = new ReaderWriterLockSlim(); | |
private readonly int _capacity; | |
public LRUCacheReaderWriterLock(int capacity) | |
{ | |
_capacity = capacity; |