ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Helper/LevelDB.pas
(Generate patch)

Comparing oup/current/Helper/LevelDB.pas (file contents):
Revision 140 by alloc, Fri Mar 30 01:06:52 2007 UTC vs.
Revision 142 by alloc, Fri Mar 30 02:08:49 2007 UTC

# Line 74 | Line 74 | var
74    RawLinks:   TRawDataList;
75  
76    DatFileStream, RawFileStream: TMemoryStream;
77
78 // ###########################
79  datsum, linksum, rawsum: Int64;
80  freq: Int64;
81  tempticks1, tempticks2: Int64;
82 // ###########################
77   const
78    Steps: Byte = 3;
79  
# Line 297 | Line 291 | begin
291    lbl_estimation.Caption := 'Estimated finishing time: unknown';
292    Application.ProcessMessages;
293  
300  QueryPerformanceFrequency(freq);
301  datsum := 0;
302  linksum := 0;
303  rawsum := 0;
304
294    FileTime := Time;
295    for FileID := 0 to DatHeader.Files - 1 do
296    begin
# Line 310 | Line 299 | begin
299        FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j];
300      if FileInfo.Size > 0 then
301      begin
313      QueryPerformanceCounter(tempticks1);
314
302        FilesHeader[FileID].DataAddr := Stream_Body.Size + 8;
303        DatFileStream := TMemoryStream.Create;
304        Connection.LoadDatFile(FileID, TStream(DatFileStream));
# Line 320 | Line 307 | begin
307        DatFileStream.Write(tempi, 4);
308        DatFileStream.Write(LevelID, 4);
309  
323      QueryPerformanceCounter(tempticks2);
324      datsum := datsum + (tempticks2 - tempticks1);
325
310        DatLinks := Connection.GetDatLinks(FileID);
311        if Length(DatLinks) > 0 then
312        begin
# Line 337 | Line 321 | begin
321          end;
322        end;
323  
340      QueryPerformanceCounter(tempticks1);
341      linksum := linksum + (tempticks1 - tempticks2);
342
324        RawLinks := Connection.GetRawList(FileID);
325        if Length(RawLinks) > 0 then
326        begin
# Line 366 | Line 347 | begin
347        end;
348        DatFileStream.Seek(0, soFromBeginning);
349        Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size);
369
370      QueryPerformanceCounter(tempticks2);
371      rawsum := rawsum + (tempticks2 - tempticks1);
350      end
351      else
352        FilesHeader[FileID].DataAddr := 0;
# Line 391 | Line 369 | begin
369      Application.ProcessMessages;
370    end;
371  
394  ShowMessage('AvgDats: ' + FloatToStr((datsum / progress.Max) / freq) + #13#10 +
395      'AvgLinks: ' + FloatToStr((linksum / progress.Max) / freq) + #13#10 +
396      'AvgRaws: ' + FloatToStr((rawsum / progress.Max) / freq)
397   );
398
372    Stream_Dat.Write(DatHeader, SizeOf(DatHeader));
373    for i := 0 to High(FilesHeader) do
374      Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i]));
# Line 450 | Line 423 | var
423  
424    BeginTime, FileTime: Double;
425    Step:       Integer;
453  LevelID:    Integer;
426    TimeFormat: TFormatSettings;
427  
428    ConID:      Integer;
# Line 459 | Line 431 | var
431  
432    FileID:     Integer;
433  
462  Strings:    TStrings;
434    i:          Integer;
435    temps:      String;
465  tempi:      Integer;
466  tempb:      Byte;
436    tempdata:   TByteData;
437    FileInfo:   TFileInfo;
438    DatLinks:   TDatLinkList;
# Line 585 | Line 554 | begin
554    Query.ExecSQL;
555    Query.SQL.Text :=
556      'CREATE TABLE linkmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' +
557 <    'src_link_offset INTEGER, target_id INTEGER,  INDEX idsrcid x src_id, ' +
558 <    'INDEX iddestid x target_id);';
557 >    'src_link_offset INTEGER, target_id INTEGER);';
558 >  Query.ExecSQL;
559 >  Query.SQL.Text := 'CREATE INDEX idsrcid ON linkmap (src_id);';
560 >  Query.ExecSQL;
561 >  Query.SQL.Text := 'CREATE INDEX idtargetid ON linkmap (target_id);';
562    Query.ExecSQL;
563    Query.SQL.Text :=
564      'CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' +
565      'src_link_offset INTEGER, sep BOOLEAN, size INTEGER, ' +
566 <    'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib, ' +
595 <    'INDEX idsrcid x src_id);';
566 >    'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib);';
567    //    Query.SQL.Text:='CREATE TABLE rawmap  ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );';
568    Query.ExecSQL;
569 +  Query.SQL.Text := 'CREATE INDEX idsrcid ON rawmap (src_id);';
570 +  Query.ExecSQL;
571    Query.SQL.Text :=
572      'CREATE TABLE datfiles  ( id INTEGER PRIMARY KEY, extension CHAR(4), ' +
573      'name STRING(128), contenttype INTEGER, size INTEGER, ' +
# Line 631 | Line 604 | begin
604    DoStep('Writing .dat-fileslist');
605    Application.ProcessMessages;
606  
607 +  FileTime := Time;
608    Database.StartTransaction;
609    for FileID := 0 to Connection.GetFileCount - 1 do
610    begin
# Line 705 | Line 679 | begin
679      end;
680      if ((FileID mod 10) = 0) and (FileID >= 100) then
681        lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr(
682 <        (Time - BeginTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat );
682 >        (Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat );
683      progress.Position := FileID;
684      lbl_progress.Caption := 'Files done: ' + IntToStr(FileID) + '/' + IntToStr(progress.Max);
685      Application.ProcessMessages;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)