Exemple #1
0
  public override bool NewRow( Value [] row )
  {
    Value [] a; // The accumulator row, initialised from the first row with a given set of group values.

    if ( Rows.TryGetValue( row, out a ) )
    for ( int i = 0; i < Agg.Length; i += 1 ) // Do the Aggregate calculation.
    {
      int cix = Agg[ i ].ColIx;
      switch( Agg[ i ].Op )
      {
        case AggOp.Count: 
          a[ cix ].L += 1; 
          break;
        case AggOp.Sum: 
          switch ( Agg[ i ].Type )
          {
            case DataType.Double: a[ cix ].D += row[ cix ].D; break;
            default: a[ cix ].L += row[ cix ].L; break;
          }
          break;  
        case AggOp.Min: 
          if ( Util.Compare( row[ cix ], a[ cix ], Agg[ i ].Type ) < 0 ) a[ cix ] = row[ cix ];
          break;    
        case AggOp.Max: 
          if ( Util.Compare( row[ cix ], a[ cix ], Agg[ i ].Type ) > 0 ) a[ cix ] = row[ cix ];
          break;     
      }
    }
    else
    {
      Rows.Add( (Value[])row.Clone() );
    }
    return true;
  }
  public override bool NewRow( Value [] row )
  {
    Value [] v;
    bool first = !Rows.TryGetValue( row, out v );
    if ( first )
    {
      v = (Value[])row.Clone();
      Rows.Add( v );
    }

    // Now do the Aggregate calculation.
    for ( int i = 0; i < Agg.Length; i += 1 )
    {
      int cix = Agg[i].ColIx;
      switch( Agg[i].Op )
      {
        case AggOp.Count: v[ cix ].L += 1; break;

        case AggOp.Sum: 
          if ( !first ) switch ( Agg[i].Type )
          {
            case DataType.Double: v[ cix ].D += row[ cix ].D; break;
            default: v[ cix].L += row[ cix ].L; break;
          }
          break;  
        case AggOp.Min: 
          if ( !first ) if ( Util.Compare( row[ cix ], v[ cix ], Agg[i].Type ) < 0 ) v[ cix ] = row[ cix ];
          break;    
        case AggOp.Max: 
          if ( !first ) if ( Util.Compare( row[ cix ], v[ cix ], Agg[i].Type ) > 0 ) v[ cix ] = row[ cix ];
          break;     
      }
    }
    return true;
  }
Exemple #3
0
 public override void CheckNames( Exec  e )
 {
   var set = new G.HashSet<string>();
   for ( int i = 0; i < ColumnCount; i += 1 )
   {
     string name = Exps[ i ].Name;
     if ( name == "" ) e.Error( "Unnamed expression" );
     else if ( set.Contains(name) ) e.Error( "Duplicate name: " + name );
     set.Add( name );
   }
 }
 public void DeleteFile( FileType ft, long id )
 {
   long fileId = ft == FileType.System ? id : 4 + id*2 + (long)ft;
   DeletedFiles.Add( fileId );
   Log.SetLength( fileId, 0 );
 }