Пример #1
0
  /* Private methods */

  void Commit( CommitStage c )
  {
    SysString.Commit( c );
    SysBinary.Commit( c );
    SysStringIndex.Commit( c );
    SysBinaryIndex.Commit( c );
    foreach( G.KeyValuePair<string,Schema> p in SchemaDict )
      foreach( G.KeyValuePair<string,TableExpression> q in p.Value.TableDict )
        q.Value.Commit( c );
  }
  /* Private methods */

  void  RollbackOrCommit()
  {
    if ( Rollback )
    {
      Log.Reset();
      foreach( G.KeyValuePair<string,Schema> p in SchemaDict )
        foreach( G.KeyValuePair<string,TableExpression> q in p.Value.TableDict )
          q.Value.Rollback();
      Rollback = false;
    }
    else 
    {
      // Save indexes to underlying buffered streams ( can add more Log entries ). 
      SysStringIndex.PrepareToCommit();
      SysBinaryIndex.PrepareToCommit();
      foreach( G.KeyValuePair<string,Schema> p in SchemaDict )
        foreach( G.KeyValuePair<string,TableExpression> q in p.Value.TableDict )
          q.Value.PrepareToCommit();  
    
      if ( Log.Commit() )
      {
        SysString.Flush(); SysStringIndex.Commit();
        SysBinary.Flush(); SysBinaryIndex.Commit();

        foreach( G.KeyValuePair<string,Schema> p in SchemaDict )
          foreach( G.KeyValuePair<string,TableExpression> q in p.Value.TableDict )
            q.Value.Commit();

        foreach ( long fileId in DeletedFiles )
        {
          var f = new IO.FileInfo( Name + fileId );
          f.Delete();
        }
        Log.Reset();
      }
    }
    DeletedFiles.Clear();
  }