Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions generator/Common/generate.common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface

TGenerator = class(TObject)
private
rndState: Array [0..1] of Cardinal;
FInputFile: String;
FOutPutFile: String;
FLineCount: Int64;
Expand Down Expand Up @@ -52,7 +53,7 @@ implementation
;

const
cSeed: LongInt = 46668267; // '1BRC' in ASCII
cSeed = 46668267; // '1BRC' in ASCII
linesPercent = 10;
stationsCapacity = 50000;
chunkBatch = 10000;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down