Example #1
0
 internal CheckedContext(string dataSource, string table, string column, DValueType columnType)
 {
     DataSource = dataSource;
     Table      = table;
     Column     = column;
     ColumnType = columnType;
 }
Example #2
0
        public BucketedDatetimes(
            string tableName,
            string columnName,
            DValueType columnType = DValueType.Datetime)
        {
            QueryComponents = columnType switch
            {
                DValueType.Datetime => DateComponents.Concat(TimeComponents).ToArray(),
                DValueType.Timestamp => TimeComponents,
                DValueType.Date => DateComponents,
                _ => throw new System.ArgumentException($"Expected Datetime, Date or Time, got {columnType}."),
            };
            var groupsFragment = string.Join(",\n", QueryComponents.Select(s => $"date_trunc('{s}', {columnName})"));
            var groupingSets   = string.Join(", ", Enumerable.Range(2, QueryComponents.Length));

            QueryStatement = $@"
                select
                    grouping_id(
                        {groupsFragment}
                    ),
                    {groupsFragment},
                    count(*),
                    count_noise(*)
                from {tableName}
                group by grouping sets ({groupingSets})";
        }
Example #3
0
 public BucketedDatetimes(DValueType columnType = DValueType.Datetime)
 {
     QueryComponents = columnType switch
     {
         DValueType.Datetime => DateTimeComponents,
         DValueType.Timestamp => TimeComponents,
         DValueType.Date => DateComponents,
         _ => throw new ArgumentException($"Expected Datetime, Date or Time, got {columnType}."),
     };
 }
Example #4
0
#pragma warning disable CA2000 // Call System.IDisposable.Dispose on object (Allow calling context to dispose the scope.)
        public ComponentTestScope SimpleComponentTestScope(
            string dataSource,
            string table,
            string column,
            string vcrFilename,
            DValueType columnType = DValueType.Unknown) =>
        PrepareTestScope()
        .LoadCassette(vcrFilename)
        .WithConnectionParams(ApiUri, dataSource)
        .WithContext(dataSource, table, column, columnType);
Example #5
0
        public DElement(int groupNumber, int elementNumber, DVR vr, DValueType type)
        {
            IsRef = false;

            DicomVR  dicomVR  = DHelper.ConvertToDicomVR(vr);
            DicomTag dicomTag = new DicomTag((ushort)groupNumber, (ushort)elementNumber);

            _element = CreateEmptyElement(dicomTag, dicomVR);

            Type = type;
        }
Example #6
0
        public DElement(int tag, DVR vr, DValueType type)
        {
            IsRef = false;

            DicomVR  dicomVR  = DHelper.ConvertToDicomVR(vr);
            DicomTag dicomTag = DHelper.Int2DicomTag(tag);

            _element = CreateEmptyElement(dicomTag, dicomVR);

            Type = type;
        }
Example #7
0
 public BucketisingProjection(
     string column,
     DValueType columnType,
     int index,
     NumericDistribution distribution,
     NumericDistribution?decimalsCountDistribution)
     : base(column, index)
 {
     BucketSize = ComputeBucketSize(distribution.Quartiles.Item1, distribution.Quartiles.Item3);
     ColumnType = columnType;
     DecimalsCountDistribution = decimalsCountDistribution;
 }
Example #8
0
 public ComponentTestScope WithContext(
     string dataSource,
     string tableName,
     string columnName,
     DValueType columnType = DValueType.Unknown)
 {
     Inner.Scope.Inject <ExplorerContext>(
         new ExplorerTestContext
     {
         DataSource = dataSource,
         Table      = tableName,
         Column     = columnName,
         ColumnType = columnType,
     });
     return(new ComponentTestScope(Inner));
 }
Example #9
0
        public static Action <ExplorationConfig> ColumnConfiguration(DValueType columnType)
        {
            Action <ExplorationConfig> typeBasedConfiguration = columnType switch
            {
                DValueType.Integer => NumericExploration,
                DValueType.Real => NumericExploration,
                DValueType.Text => TextExploration,
                DValueType.Timestamp => DatetimeExploration,
                DValueType.Date => DatetimeExploration,
                DValueType.Datetime => DatetimeExploration,
                DValueType.Bool => BoolExploration,
                _ => throw new ArgumentException(
                          $"Cannot explore column type {columnType}.", nameof(columnType)),
            };

            return(config =>
            {
                CommonConfiguration(config);
                typeBasedConfiguration(config);
            });
        }
Example #10
0
 public IdentityProjection(string column, int index, DValueType columnType)
     : base(column, index)
 {
     this.columnType = columnType;
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DColumnInfo"/> class.
 /// </summary>
 /// <param name="columnType">Specifies the column data type.</param>
 /// <param name="type">Specifies additional information used by Diffix for the column: user_id/isolating/regular.</param>
 public DColumnInfo(DValueType columnType, ColumnType type)
 {
     Type      = columnType;
     UserId    = type == ColumnType.UserId;
     Isolating = type != ColumnType.Regular;
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DColumnInfo"/> class.
 /// </summary>
 /// <param name="columnType">Specifies the column data type.</param>
 /// <param name="userId">Specifies whether the column contains a "user_id" information.</param>
 /// <param name="isolating">Specifies whether the column is "isolating" or not.</param>
 public DColumnInfo(DValueType columnType, bool userId, bool isolating)
 {
     Type      = columnType;
     UserId    = userId;
     Isolating = isolating;
 }