Skip to content

Commit

Permalink
Only write the best graph info when in "find best graph" mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpn committed Feb 17, 2020
1 parent 3edb7ab commit c932aa5
Show file tree
Hide file tree
Showing 7 changed files with 5,813 additions and 5,221 deletions.
5,284 changes: 5,284 additions & 0 deletions src/PerfectHash/BulkCreateBestCsv.h

Large diffs are not rendered by default.

5,682 changes: 476 additions & 5,206 deletions src/PerfectHash/BulkCreateCsv.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/PerfectHash/PerfectHash.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<ClInclude Include="..\..\include\CompiledPerfectHash.h" />
<ClInclude Include="..\..\include\PerfectHash.h" />
<ClInclude Include="..\..\include\PerfectHashErrors.h" />
<ClInclude Include="BulkCreateBestCsv.h" />
<ClInclude Include="Chm01.h" />
<ClInclude Include="Chm01FileWork.h" />
<ClInclude Include="Chunk.h" />
Expand Down Expand Up @@ -270,4 +271,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>
</Project>
5 changes: 4 additions & 1 deletion src/PerfectHash/PerfectHash.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@
<ClInclude Include="CompiledPerfectHashTableChm01IndexRotateMultiplyXorRotate2And_CSource_RawCString.h">
<Filter>Private Header Files %28Auto-Generated%29</Filter>
</ClInclude>
<ClInclude Include="BulkCreateBestCsv.h">
<Filter>Private Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="PerfectHash.def">
Expand Down Expand Up @@ -563,4 +566,4 @@
<Filter>Resource Files</Filter>
</Natvis>
</ItemGroup>
</Project>
</Project>
2 changes: 2 additions & 0 deletions src/PerfectHash/PerfectHashConstants.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ const UNICODE_STRING KeysWildcardSuffix = RCS(L"*.keys");
const UNICODE_STRING KeysTableSizeSuffix = RCS(L".TableSize");
const UNICODE_STRING PerfectHashBulkCreateCsvBaseName =
RCS(L"PerfectHashBulkCreate");
const UNICODE_STRING PerfectHashBulkCreateBestCsvBaseName =
RCS(L"PerfectHashBulkCreateBest");
const UNICODE_STRING PerfectHashTableCreateCsvBaseName =
RCS(L"PerfectHashTableCreate");

Expand Down
1 change: 1 addition & 0 deletions src/PerfectHash/PerfectHashConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ extern const UNICODE_STRING KeysWildcardSuffix;
extern const UNICODE_STRING TableInfoStreamName;
extern const UNICODE_STRING KeysTableSizeSuffix;
extern const UNICODE_STRING PerfectHashBulkCreateCsvBaseName;
extern const UNICODE_STRING PerfectHashBulkCreateBestCsvBaseName;
extern const UNICODE_STRING PerfectHashTableCreateCsvBaseName;

extern const STRING NullString;
Expand Down
57 changes: 44 additions & 13 deletions src/PerfectHash/PerfectHashContextBulkCreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Module Name:

#include "stdafx.h"
#include "BulkCreateCsv.h"
#include "BulkCreateBestCsv.h"


#define PH_ERROR_EX(Name, Result, ...) \
Expand Down Expand Up @@ -48,7 +49,8 @@ _Success_(return >= 0)
HRESULT
(STDAPICALLTYPE PREPARE_BULK_CREATE_CSV_FILE)(
_In_ PPERFECT_HASH_CONTEXT Context,
_In_ ULONG NumberOfKeysFiles
_In_ ULONG NumberOfKeysFiles,
_In_ BOOLEAN FindBestGraph
);
typedef PREPARE_BULK_CREATE_CSV_FILE *PPREPARE_BULK_CREATE_CSV_FILE;
extern PREPARE_BULK_CREATE_CSV_FILE PrepareBulkCreateCsvFile;
Expand Down Expand Up @@ -160,6 +162,7 @@ Return Value:
BOOLEAN Silent;
BOOLEAN Failed;
BOOLEAN Terminate;
BOOLEAN FindBestGraph;
HRESULT Result;
HRESULT TableCreateResult;
PCHAR Buffer;
Expand Down Expand Up @@ -259,7 +262,8 @@ Return Value:
// Arguments have been validated, proceed.
//

Silent = (TableCreateFlags.Silent == TRUE);
Silent = (TableCreateFlags.Silent != FALSE);
FindBestGraph = (TableCreateFlags.FindBestGraph != FALSE);
ZeroStruct(EmptyCoverage);

//
Expand Down Expand Up @@ -288,7 +292,12 @@ Return Value:
// Create a "row buffer" we can use for the CSV file.
//

NumberOfPages = 13;
if (FindBestGraph) {
NumberOfPages = BULK_CREATE_BEST_CSV_ROW_BUFFER_NUMBER_OF_PAGES;
} else {
NumberOfPages = BULK_CREATE_CSV_ROW_BUFFER_NUMBER_OF_PAGES;

}

Result = Rtl->Vtbl->CreateBuffer(Rtl,
&ProcessHandle,
Expand Down Expand Up @@ -456,7 +465,9 @@ Return Value:
//

if (TableCreateFlags.DisableCsvOutputFile == FALSE) {
Result = PrepareBulkCreateCsvFile(Context, NumberOfKeysFiles);
Result = PrepareBulkCreateCsvFile(Context,
NumberOfKeysFiles,
FindBestGraph);
if (FAILED(Result)) {
PH_ERROR(PerfectHashContextBulkCreate_PrepareCsvFile, Result);
goto Error;
Expand Down Expand Up @@ -745,7 +756,11 @@ Return Value:
//

_No_competing_thread_begin_
WRITE_BULK_CREATE_CSV_ROW();
if (FindBestGraph) {
WRITE_BULK_CREATE_BEST_CSV_ROW();
} else {
WRITE_BULK_CREATE_CSV_ROW();
}
_No_competing_thread_end_

ReleaseTable:
Expand Down Expand Up @@ -883,15 +898,16 @@ _Use_decl_annotations_
HRESULT
PrepareBulkCreateCsvFile(
PPERFECT_HASH_CONTEXT Context,
ULONG NumberOfKeysFiles
ULONG NumberOfKeysFiles,
BOOLEAN FindBestGraph
)
/*++
Routine Description:
Prepares the <BaseOutputDir>\PerfectHashBulkCreate_<HeaderHash>.csv file.
This involves determining the header hash, constructing a path instance,
creating a file instance, and opening it for append.
Prepares the <BaseOutputDir>\PerfectHashBulkCreate(Best)?_<HeaderHash>.csv
file. This involves determining the header hash, constructing a path
instance, creating a file instance, and opening it for append.
Arguments:
Expand All @@ -901,6 +917,10 @@ Routine Description:
processed during the bulk create operation. This is used to derive
an appropriate file size to use for the .csv file.
FindBestGraph - Supplies a boolean indicating whether or not the "find
best graph" solving mode is active. This is used to select the base
file name used for the .csv file, as well as the header used.
Return Value:
S_OK on success, an appropriate error code otherwise.
Expand Down Expand Up @@ -952,9 +972,15 @@ Return Value:
OUTPUT_RAW(#Name); \
OUTPUT_CHR('\n');

BULK_CREATE_CSV_ROW_TABLE(EXPAND_AS_COLUMN_NAME_THEN_COMMA,
EXPAND_AS_COLUMN_NAME_THEN_COMMA,
EXPAND_AS_COLUMN_NAME_THEN_NEWLINE);
if (FindBestGraph) {
BULK_CREATE_BEST_CSV_ROW_TABLE(EXPAND_AS_COLUMN_NAME_THEN_COMMA,
EXPAND_AS_COLUMN_NAME_THEN_COMMA,
EXPAND_AS_COLUMN_NAME_THEN_NEWLINE);
} else {
BULK_CREATE_CSV_ROW_TABLE(EXPAND_AS_COLUMN_NAME_THEN_COMMA,
EXPAND_AS_COLUMN_NAME_THEN_COMMA,
EXPAND_AS_COLUMN_NAME_THEN_NEWLINE);
}

Header.Length = (USHORT)RtlPointerToOffset(Base, Output);
Header.MaximumLength = Header.Length;
Expand Down Expand Up @@ -1015,7 +1041,12 @@ Return Value:
// Create the .csv file's path name.
//

BaseName = &PerfectHashBulkCreateCsvBaseName;
if (FindBestGraph) {
BaseName = &PerfectHashBulkCreateBestCsvBaseName;
} else {
BaseName = &PerfectHashBulkCreateCsvBaseName;
}

ExistingPath = Context->BaseOutputDirectory->Path;
NewDirectory = &Context->BaseOutputDirectory->Path->FullPath;

Expand Down

0 comments on commit c932aa5

Please sign in to comment.