Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/27/13 10:28:48 (12 years ago)
Author:
pfleck
Message:

#2063:
StatisticsGenerator fills and updates client dimension table.
Removed week from time dimension table.

Location:
branches/HiveStatistics/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml

    r9524 r9538  
    259259      <Column Name="Hour" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
    260260      <Column Name="Day" Type="System.DateTime" DbType="Date NOT NULL" CanBeNull="false" />
    261       <Column Name="Week" Type="System.DateTime" DbType="Date NOT NULL" CanBeNull="false" />
    262261      <Column Name="Month" Type="System.DateTime" DbType="Date NOT NULL" CanBeNull="false" />
    263262      <Column Name="Year" Type="System.DateTime" DbType="Date NOT NULL" CanBeNull="false" />
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout

    r9524 r9538  
    121121      </nestedChildShapes>
    122122    </classShape>
    123     <associationConnector edgePoints="[(11.25 : 1.87677124023437); (10.9375 : 1.87677124023437); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     123    <associationConnector edgePoints="[(11.25 : 1.87677124023437); (10.9375 : 1.87677124023437); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    124124      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_StateLog" />
    125125      <nodes>
     
    265265      </nestedChildShapes>
    266266    </classShape>
    267     <classShape Id="a769f2ac-c8e3-4860-baa5-c46f46c38ed8" absoluteBounds="3.625, 8.5, 2, 1.7535424804687487">
     267    <classShape Id="a769f2ac-c8e3-4860-baa5-c46f46c38ed8" absoluteBounds="3.625, 8.5, 2, 1.5891951497395844">
    268268      <DataClassMoniker Name="/HiveDataContext/DimTime" />
    269269      <nestedChildShapes>
    270         <elementListCompartment Id="694c4a5a-20fb-43a9-bc9a-7b59d794a7fb" absoluteBounds="3.6399999999999997, 8.96, 1.9700000000000002, 1.19354248046875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     270        <elementListCompartment Id="694c4a5a-20fb-43a9-bc9a-7b59d794a7fb" absoluteBounds="3.6399999999999997, 8.96, 1.9700000000000002, 1.0291951497395833" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    271271      </nestedChildShapes>
    272272    </classShape>
     
    283283      </nestedChildShapes>
    284284    </classShape>
    285     <associationConnector edgePoints="[(6.625 : 16.1191239261004); (7.875 : 16.1191239261004); (7.875 : 14.4826684570313)]" fixedFrom="Caller" fixedTo="Algorithm">
     285    <associationConnector edgePoints="[(6.625 : 16.1191239261004); (7.875 : 16.1191239261004); (7.875 : 14.4826684570313)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    286286      <AssociationMoniker Name="/HiveDataContext/DimClient/DimClient_FactTask" />
    287287      <nodes>
     
    290290      </nodes>
    291291    </associationConnector>
    292     <associationConnector edgePoints="[(8.5 : 10.5498478190104); (8.5 : 11.25)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     292    <associationConnector edgePoints="[(8.5 : 10.5498478190104); (8.5 : 11.25)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    293293      <AssociationMoniker Name="/HiveDataContext/DimJob/DimJob_FactTask" />
    294294      <nodes>
     
    297297      </nodes>
    298298    </associationConnector>
    299     <associationConnector edgePoints="[(5.625 : 9.57218767438616); (7.15624775 : 9.57218767438616); (7.15624775 : 11.25)]" fixedFrom="Caller" fixedTo="Algorithm">
     299    <associationConnector edgePoints="[(5.15625 : 10.0891951497396); (5.15625 : 14.3889184570313); (6.875 : 14.3889184570313)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    300300      <AssociationMoniker Name="/HiveDataContext/DimTime/DimTime_FactTask" />
    301301      <nodes>
     
    304304      </nodes>
    305305    </associationConnector>
    306     <associationConnector edgePoints="[(5.625 : 9.28136218952683); (7.4999995 : 9.28136218952683); (7.4999995 : 11.25)]" fixedFrom="Caller" fixedTo="Algorithm">
     306    <associationConnector edgePoints="[(5.4218775 : 10.0891951497396); (5.4218775 : 13.3576659570313); (6.71675495975 : 13.3576659570313); (6.71675495975 : 13.359301744963); (6.875 : 13.359301744963)]" manuallyRouted="true" fixedFrom="Algorithm" fixedTo="Caller">
    307307      <AssociationMoniker Name="/HiveDataContext/DimTime/DimTime_FactTask1" />
    308308      <nodes>
     
    311311      </nodes>
    312312    </associationConnector>
    313     <associationConnector edgePoints="[(4.625 : 16.2383361179518); (3.59375 : 16.2383361179518); (3.59375 : 14.2326684570313)]" fixedFrom="Caller" fixedTo="Algorithm">
     313    <associationConnector edgePoints="[(4.625 : 16.2383361179518); (3.59375 : 16.2383361179518); (3.59375 : 14.2326684570313)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    314314      <AssociationMoniker Name="/HiveDataContext/DimClient/DimClient_FactClientInfo" />
    315315      <nodes>
     
    318318      </nodes>
    319319    </associationConnector>
    320     <associationConnector edgePoints="[(4.125 : 10.2535424804687); (4.125 : 11)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     320    <associationConnector edgePoints="[(4.125 : 10.0891951497396); (4.125 : 11)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    321321      <AssociationMoniker Name="/HiveDataContext/DimTime/DimTime_FactClientInfo" />
    322322      <nodes>
     
    325325      </nodes>
    326326    </associationConnector>
    327     <associationConnector edgePoints="[(1.59375 : 9.97115315755208); (1.59375 : 12.6163342285156); (2.625 : 12.6163342285156)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     327    <associationConnector edgePoints="[(1.59375 : 9.97115315755208); (1.59375 : 12.6163342285156); (2.625 : 12.6163342285156)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    328328      <AssociationMoniker Name="/HiveDataContext/DimUser/DimUser_FactClientInfo" />
    329329      <nodes>
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs

    r9524 r9538  
    55755575    private System.DateTime _Day;
    55765576   
    5577     private System.DateTime _Week;
    5578    
    55795577    private System.DateTime _Month;
    55805578   
     
    55975595    partial void OnDayChanging(System.DateTime value);
    55985596    partial void OnDayChanged();
    5599     partial void OnWeekChanging(System.DateTime value);
    5600     partial void OnWeekChanged();
    56015597    partial void OnMonthChanging(System.DateTime value);
    56025598    partial void OnMonthChanged();
     
    56695665          this.SendPropertyChanged("Day");
    56705666          this.OnDayChanged();
    5671         }
    5672       }
    5673     }
    5674    
    5675     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Week", DbType="Date NOT NULL")]
    5676     public System.DateTime Week
    5677     {
    5678       get
    5679       {
    5680         return this._Week;
    5681       }
    5682       set
    5683       {
    5684         if ((this._Week != value))
    5685         {
    5686           this.OnWeekChanging(value);
    5687           this.SendPropertyChanging();
    5688           this._Week = value;
    5689           this.SendPropertyChanged("Week");
    5690           this.OnWeekChanged();
    56915667        }
    56925668      }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql

    r9524 r9538  
    205205    [Hour]  DATETIME NOT NULL,
    206206    [Day]   DATE     NOT NULL,
    207     [Week]  DATE     NOT NULL,
    208207    [Month] DATE     NOT NULL,
    209208    [Year]  DATE     NOT NULL,
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r9533 r9538  
    2727      UpdateJobs(db);
    2828      UpdateUsers(db);
    29       // UpdateClients
     29      UpdateClients(db);
    3030
    3131      return newTime;
     
    4646          Hour = new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0),
    4747          Day = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0),
    48           Week = new DateTime(now.Year, now.Month, now.Day - (int)now.DayOfWeek, 0, 0, 0), // Week begins with Sunday
    4948          Month = new DateTime(now.Year, now.Month, 1, 0, 0, 0),
    5049          Year = new DateTime(now.Year, 1, 1, 0, 0, 0)
     
    9089    }
    9190
     91    private void UpdateClients(HiveDataContext db) {
     92      var removedClients =
     93        from c in db.DimClients
     94        where c.ExpirationTime == null &&
     95              !db.Resources.OfType<Slave>().Select(x => x.ResourceId).Contains(c.ResourceId)
     96        select c;
     97
     98      var modifiedClients =
     99        from s in db.Resources.OfType<Slave>()
     100        join c in db.DimClients on s.ResourceId equals c.ResourceId
     101        where c.ExpirationTime == null
     102              && (s.Name != c.Name || s.ParentResourceId != c.ResourceGroupId ||
     103                  s.ParentResource.ParentResourceId != c.ResourceGroup2Id)
     104        select new { Slave = s, Client = c };
     105
     106      foreach (var client in removedClients.Union(modifiedClients.Select(x => x.Client))) {
     107        client.ExpirationTime = DateTime.Now;
     108      }
     109
     110      var newClients =
     111        from s in db.Resources.OfType<Slave>()
     112        where !db.DimClients.Select(x => x.ResourceId).Contains(s.ResourceId)
     113          || modifiedClients.Select(x => x.Slave.ResourceId).Contains(s.ResourceId)
     114        select new {
     115          Slave = s,
     116          Group = s.ParentResourceId,
     117          Group2 = s.ParentResource.ParentResourceId
     118        };
     119
     120      var newDimClients =
     121        from s in newClients.ToList()
     122        select new DimClient {
     123          ResourceId = s.Slave.ResourceId,
     124          Name = s.Slave.Name,
     125          ExpirationTime = null,
     126          ResourceGroupId = s.Group,
     127          ResourceGroup2Id = s.Group2
     128        };
     129
     130      db.DimClients.InsertAllOnSubmit(newDimClients);
     131    }
     132
    92133    private void UpdateDataTables(DimTime newTime, HiveDataContext db) {
    93134
Note: See TracChangeset for help on using the changeset viewer.