--- oup/current/Helper/LevelDB.pas 2007/03/30 00:49:02 138 +++ oup/current/Helper/LevelDB.pas 2007/03/30 02:08:49 142 @@ -74,12 +74,6 @@ var RawLinks: TRawDataList; DatFileStream, RawFileStream: TMemoryStream; - -// ########################### - datsum, linksum, rawsum: Int64; - freq: Int64; - tempticks1, tempticks2: Int64; -// ########################### const Steps: Byte = 3; @@ -297,11 +291,6 @@ begin lbl_estimation.Caption := 'Estimated finishing time: unknown'; Application.ProcessMessages; - QueryPerformanceFrequency(freq); - datsum := 0; - linksum := 0; - rawsum := 0; - FileTime := Time; for FileID := 0 to DatHeader.Files - 1 do begin @@ -310,8 +299,6 @@ begin FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j]; if FileInfo.Size > 0 then begin - QueryPerformanceCounter(tempticks1); - FilesHeader[FileID].DataAddr := Stream_Body.Size + 8; DatFileStream := TMemoryStream.Create; Connection.LoadDatFile(FileID, TStream(DatFileStream)); @@ -320,9 +307,6 @@ begin DatFileStream.Write(tempi, 4); DatFileStream.Write(LevelID, 4); - QueryPerformanceCounter(tempticks2); - datsum := datsum + (tempticks2 - tempticks1); - DatLinks := Connection.GetDatLinks(FileID); if Length(DatLinks) > 0 then begin @@ -337,9 +321,6 @@ begin end; end; - QueryPerformanceCounter(tempticks1); - linksum := linksum + (tempticks1 - tempticks2); - RawLinks := Connection.GetRawList(FileID); if Length(RawLinks) > 0 then begin @@ -366,9 +347,6 @@ begin end; DatFileStream.Seek(0, soFromBeginning); Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size); - - QueryPerformanceCounter(tempticks2); - rawsum := rawsum + (tempticks2 - tempticks1); end else FilesHeader[FileID].DataAddr := 0; @@ -391,11 +369,6 @@ begin Application.ProcessMessages; end; - ShowMessage('AvgDats: ' + FloatToStr((datsum / progress.Max) / freq) + #13#10 + - 'AvgLinks: ' + FloatToStr((linksum / progress.Max) / freq) + #13#10 + - 'AvgRaws: ' + FloatToStr((rawsum / progress.Max) / freq) - ); - Stream_Dat.Write(DatHeader, SizeOf(DatHeader)); for i := 0 to High(FilesHeader) do Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i])); @@ -450,7 +423,6 @@ var BeginTime, FileTime: Double; Step: Integer; - LevelID: Integer; TimeFormat: TFormatSettings; ConID: Integer; @@ -459,11 +431,8 @@ var FileID: Integer; - Strings: TStrings; i: Integer; temps: String; - tempi: Integer; - tempb: Byte; tempdata: TByteData; FileInfo: TFileInfo; DatLinks: TDatLinkList; @@ -585,16 +554,20 @@ begin Query.ExecSQL; Query.SQL.Text := 'CREATE TABLE linkmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' + - 'src_link_offset INTEGER, target_id INTEGER, INDEX idsrcid src_id, ' + - 'INDEX iddestid target_id);'; + 'src_link_offset INTEGER, target_id INTEGER);'; + Query.ExecSQL; + Query.SQL.Text := 'CREATE INDEX idsrcid ON linkmap (src_id);'; + Query.ExecSQL; + Query.SQL.Text := 'CREATE INDEX idtargetid ON linkmap (target_id);'; Query.ExecSQL; Query.SQL.Text := 'CREATE TABLE rawmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, ' + 'src_link_offset INTEGER, sep BOOLEAN, size INTEGER, ' + - 'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib, ' + - 'INDEX idsrcid src_id);'; + 'data BLOB BlobCompressionMode 9 BlobBlockSize 1024 BlobCompressionAlgorithm ZLib);'; // Query.SQL.Text:='CREATE TABLE rawmap ( id AUTOINC PRIMARY KEY, src_id INTEGER, src_link_offset INTEGER, size INTEGER, data BLOB BlobCompressionAlgorithm None );'; Query.ExecSQL; + Query.SQL.Text := 'CREATE INDEX idsrcid ON rawmap (src_id);'; + Query.ExecSQL; Query.SQL.Text := 'CREATE TABLE datfiles ( id INTEGER PRIMARY KEY, extension CHAR(4), ' + 'name STRING(128), contenttype INTEGER, size INTEGER, ' + @@ -631,6 +604,7 @@ begin DoStep('Writing .dat-fileslist'); Application.ProcessMessages; + FileTime := Time; Database.StartTransaction; for FileID := 0 to Connection.GetFileCount - 1 do begin @@ -705,7 +679,7 @@ begin end; if ((FileID mod 10) = 0) and (FileID >= 100) then lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr( - (Time - BeginTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat ); + (Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat ); progress.Position := FileID; lbl_progress.Caption := 'Files done: ' + IntToStr(FileID) + '/' + IntToStr(progress.Max); Application.ProcessMessages;