Skip to content

Commit e5a850c

Browse files
committed
feat: Adding skeleton for results table generator
1 parent b726ad2 commit e5a850c

File tree

9 files changed

+414
-15
lines changed

9 files changed

+414
-15
lines changed

utilities/script_builder/Common/scriptbuilder.data.config.pas renamed to utilities/common/utilities.data.config.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
unit ScriptBuilder.Data.Config;
1+
unit Utilities.Data.Config;
22

33
{$IFDEF FPC}
44
{$mode ObjFPC}{$H+}
@@ -13,7 +13,7 @@ interface
1313
, fpjson
1414
{$ELSE}
1515
{$ENDIF}
16-
, ScriptBuilder.Data.Entries
16+
, Utilities.Data.Entries
1717
;
1818

1919
type
@@ -28,7 +28,7 @@ interface
2828
{ ENodeStatusParamsWrongType }
2929
// ENodeStatusParamsWrongType = Exception;
3030

31-
{ TConfig }
31+
{ TConfig }
3232
TConfig = class(TObject)
3333
private
3434
FRootFolder: String;

utilities/script_builder/Common/scriptbuilder.data.entries.pas renamed to utilities/common/utilities.data.entries.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
unit ScriptBuilder.Data.Entries;
1+
unit Utilities.Data.Entries;
22

33
{$IFDEF FPC}
44
{$mode ObjFPC}{$H+}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
unit ResultsGenerator.Common;
2+
3+
{$IFDEF FPC}
4+
{$mode ObjFPC}{$H+}
5+
{$ENDIF}
6+
7+
interface
8+
9+
uses
10+
Classes
11+
, SysUtils
12+
, Utilities.Data.Config
13+
, Utilities.Data.Entries
14+
;
15+
16+
type
17+
{ TResults }
18+
TResults = class(TObject)
19+
private
20+
FConfig: TConfig;
21+
22+
function GenerateProgressBar(APBPosition, APBMax, APBWIdth: Integer): String;
23+
protected
24+
public
25+
constructor Create(AConfigFile: String);
26+
destructor Destroy; override;
27+
28+
{$IFDEF UNIX}
29+
{$ELSE}
30+
{$ENDIF}
31+
published
32+
end;
33+
34+
implementation
35+
36+
uses
37+
{$IFDEF FPC}
38+
fpjson
39+
, jsonparser
40+
{$ELSE}
41+
{$ENDIF}
42+
;
43+
44+
const
45+
lineBreak = #13;
46+
47+
{ TResults }
48+
49+
constructor TResults.Create(AConfigFile: String);
50+
var
51+
configStream: TFileStream;
52+
configJSONData: TJSONData;
53+
begin
54+
{ #todo 99 -ogcarreno : Config file must be used here }
55+
configStream:= TFileStream.Create(AConfigFile, fmOpenRead);
56+
try
57+
configJSONData:= GetJSON(configStream);
58+
FConfig:= TConfig.Create(configJSONData);
59+
configJSONData.Free;
60+
finally
61+
configStream.Free;
62+
end;
63+
end;
64+
65+
destructor TResults.Destroy;
66+
begin
67+
FConfig.Free;
68+
inherited Destroy;
69+
end;
70+
71+
function TResults.GenerateProgressBar(APBPosition, APBMax, APBWIdth: Integer
72+
): String;
73+
var
74+
percentDone: Double;
75+
filled: Integer;
76+
begin
77+
percentDone := 100 * (APBPosition / APBMax);
78+
filled := trunc(APBWIdth * (percentDone / 100));
79+
Result := '[';
80+
Result := Result + StringOfChar('#', filled);
81+
Result := Result + StringOfChar('-', APBWIdth - filled);
82+
Result := Result + Format('] %5.2f %%', [percentDone]);
83+
end;
84+
85+
end.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
unit ResultsGenerator.Console;
2+
3+
{$IFDEF FPC}
4+
{$mode ObjFPC}{$H+}
5+
{$ENDIF}
6+
7+
interface
8+
9+
uses
10+
Classes
11+
, SysUtils
12+
;
13+
14+
const
15+
cShortOptHelp: Char = 'h';
16+
cLongOptHelp = 'help';
17+
cShortOptVersion: Char = 'v';
18+
cLongOptVersion = 'version';
19+
cShortOptConfig: Char = 'c';
20+
cLongOptConfig = 'config-file';
21+
{$IFNDEF FPC}
22+
cShortOptions: array of char = ['h', 'v'{, 'i', 'o', 'n'}];
23+
cLongOptions: array of string = ['help', 'version'{, 'input-file', 'output-file',
24+
'line-count'}];
25+
{$ENDIF}
26+
27+
resourcestring
28+
rsAppTitle = 'One Billion Row Challenge Results Table Generator';
29+
rsScriptBuilderVersion = 'resultsgenerator v%s';
30+
rsErrorMessage = 'ERROR: %s';
31+
rsMissingConfigFlag = 'Missing config file flag.';
32+
rsConfigFile = 'Config Filename: "%s"';
33+
34+
var
35+
configFilename: String = '';
36+
37+
procedure WriteHelp;
38+
39+
40+
implementation
41+
42+
procedure WriteHelp;
43+
begin
44+
WriteLn('Generates a Markdown Table with the ordered results');
45+
WriteLn;
46+
WriteLn('USAGE');
47+
WriteLn(' resultsgenerator <flags>');
48+
WriteLn;
49+
WriteLn('FLAGS');
50+
WriteLn(' -h|--help Writes this help message and exits');
51+
WriteLn(' -v|--version Writes the version and exits');
52+
WriteLn(' -c|--config-file <filename> The file containing the configuration');
53+
end;
54+
55+
end.
56+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const
2+
cVersion = '0.1';
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CONFIG>
3+
<ProjectOptions>
4+
<Version Value="12"/>
5+
<General>
6+
<Flags>
7+
<MainUnitHasCreateFormStatements Value="False"/>
8+
<MainUnitHasTitleStatement Value="False"/>
9+
<MainUnitHasScaledStatement Value="False"/>
10+
<CompatibilityMode Value="True"/>
11+
</Flags>
12+
<SessionStorage Value="InProjectDir"/>
13+
<Title Value="Results Table Generator"/>
14+
<UseAppBundle Value="False"/>
15+
<ResourceType Value="res"/>
16+
</General>
17+
<BuildModes Count="3">
18+
<Item1 Name="Default" Default="True"/>
19+
<Item2 Name="Debug">
20+
<CompilerOptions>
21+
<Version Value="11"/>
22+
<Target>
23+
<Filename Value="../../../../bin/resultsgenerator"/>
24+
</Target>
25+
<SearchPaths>
26+
<IncludeFiles Value="$(ProjOutDir);../../Common"/>
27+
<OtherUnitFiles Value="../../Common;../../../common"/>
28+
<UnitOutputDirectory Value="../../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
29+
</SearchPaths>
30+
<Parsing>
31+
<SyntaxOptions>
32+
<IncludeAssertionCode Value="True"/>
33+
</SyntaxOptions>
34+
</Parsing>
35+
<CodeGeneration>
36+
<Checks>
37+
<IOChecks Value="True"/>
38+
<RangeChecks Value="True"/>
39+
<OverflowChecks Value="True"/>
40+
<StackChecks Value="True"/>
41+
</Checks>
42+
<VerifyObjMethodCallValidity Value="True"/>
43+
</CodeGeneration>
44+
<Linking>
45+
<Debugging>
46+
<DebugInfoType Value="dsDwarf3"/>
47+
<UseHeaptrc Value="True"/>
48+
<TrashVariables Value="True"/>
49+
<UseExternalDbgSyms Value="True"/>
50+
</Debugging>
51+
</Linking>
52+
</CompilerOptions>
53+
</Item2>
54+
<Item3 Name="Release">
55+
<CompilerOptions>
56+
<Version Value="11"/>
57+
<Target>
58+
<Filename Value="../../../../bin/resultsgenerator"/>
59+
</Target>
60+
<SearchPaths>
61+
<IncludeFiles Value="$(ProjOutDir);../../Common"/>
62+
<OtherUnitFiles Value="../../Common;../../../common"/>
63+
<UnitOutputDirectory Value="../../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
64+
</SearchPaths>
65+
<CodeGeneration>
66+
<SmartLinkUnit Value="True"/>
67+
<Optimizations>
68+
<OptimizationLevel Value="3"/>
69+
</Optimizations>
70+
</CodeGeneration>
71+
<Linking>
72+
<Debugging>
73+
<GenerateDebugInfo Value="False"/>
74+
<RunWithoutDebug Value="True"/>
75+
</Debugging>
76+
<LinkSmart Value="True"/>
77+
</Linking>
78+
</CompilerOptions>
79+
</Item3>
80+
</BuildModes>
81+
<PublishOptions>
82+
<Version Value="2"/>
83+
<UseFileFilters Value="True"/>
84+
</PublishOptions>
85+
<RunParams>
86+
<FormatVersion Value="2"/>
87+
</RunParams>
88+
<Units Count="5">
89+
<Unit0>
90+
<Filename Value="resultsgenerator.lpr"/>
91+
<IsPartOfProject Value="True"/>
92+
<UnitName Value="ResultsGenerator"/>
93+
</Unit0>
94+
<Unit1>
95+
<Filename Value="../../Common/resultsgenerator.console.pas"/>
96+
<IsPartOfProject Value="True"/>
97+
<UnitName Value="resultsgenerator.Console"/>
98+
</Unit1>
99+
<Unit2>
100+
<Filename Value="../../Common/resultsgenerator.common.pas"/>
101+
<IsPartOfProject Value="True"/>
102+
<UnitName Value="ResultsGenerator.Common"/>
103+
</Unit2>
104+
<Unit3>
105+
<Filename Value="../../../common/utilities.data.config.pas"/>
106+
<IsPartOfProject Value="True"/>
107+
</Unit3>
108+
<Unit4>
109+
<Filename Value="../../../common/utilities.data.entries.pas"/>
110+
<IsPartOfProject Value="True"/>
111+
</Unit4>
112+
</Units>
113+
</ProjectOptions>
114+
<CompilerOptions>
115+
<Version Value="11"/>
116+
<Target>
117+
<Filename Value="../../../../bin/resultsgenerator"/>
118+
</Target>
119+
<SearchPaths>
120+
<IncludeFiles Value="$(ProjOutDir);../../Common"/>
121+
<OtherUnitFiles Value="../../Common;../../../common"/>
122+
<UnitOutputDirectory Value="../../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
123+
</SearchPaths>
124+
</CompilerOptions>
125+
<Debugging>
126+
<Exceptions Count="3">
127+
<Item1>
128+
<Name Value="EAbort"/>
129+
</Item1>
130+
<Item2>
131+
<Name Value="ECodetoolError"/>
132+
</Item2>
133+
<Item3>
134+
<Name Value="EFOpenError"/>
135+
</Item3>
136+
</Exceptions>
137+
</Debugging>
138+
</CONFIG>

0 commit comments

Comments
 (0)