diff --git a/generator/Common/generate.common.pas b/generator/Common/generate.common.pas index 5a9bf20..81704f9 100644 --- a/generator/Common/generate.common.pas +++ b/generator/Common/generate.common.pas @@ -17,6 +17,7 @@ interface TGenerator = class(TObject) private + rndState: Array [0..1] of Cardinal; FInputFile: String; FOutPutFile: String; FLineCount: Int64; @@ -52,7 +53,7 @@ implementation ; const - cSeed: LongInt = 46668267; // '1BRC' in ASCII + cSeed = 46668267; // '1BRC' in ASCII linesPercent = 10; stationsCapacity = 50000; chunkBatch = 10000; @@ -160,17 +161,15 @@ function TGenerator.GenerateProgressBar(APBPosition, APBMax, APBWIdth, AFileSize end; function TGenerator.Rng1brc(Range: longint): longint; -const - state: Array [0..1] of DWord = (46668267, 7266); var - s0, s1, s2: DWord; + s0, s1, s2: Cardinal; begin - s0 := state[0]; - s1 := state[1] xor s0; - s2 := RolDWord(s1 * 3, 5) * 7; + s0 := rndState[0]; + s1 := rndState[1] xor s0; + s2 := ((s1 * 3) xor 5) * 7; Result := longint(Int64(s2 * range) shr 32); - state[0] := s2; - state[1] := s0 xor (s1 shl 9); + rndState[0] := s2; + rndState[1] := s0 xor (s1 shl 9); end; procedure TGenerator.Generate; @@ -186,10 +185,9 @@ procedure TGenerator.Generate; chunkCount, chunkLen, stationsCount, temperaturesCount: Integer; start: TDateTime; begin - // Randomize sets this variable depending on the current time - // We just set it to our own value - RandSeed := cSeed; - + //random init + rndState[0] := cSeed; + rndState[1] := 7266; // Build list of station names BuildStationNames;