mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
DedupeType influences sort more than anything
This commit is contained in:
@@ -335,10 +335,10 @@ namespace SabreTools.DatFiles
|
|||||||
/// Perform deduplication based on the deduplication type provided
|
/// Perform deduplication based on the deduplication type provided
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dedupeType">Dedupe type that should be used</param>
|
/// <param name="dedupeType">Dedupe type that should be used</param>
|
||||||
public void Deduplicate(DedupeType dedupeType)
|
public void Deduplicate()
|
||||||
{
|
{
|
||||||
Items.Deduplicate(dedupeType);
|
Items.Deduplicate();
|
||||||
ItemsDB.Deduplicate(dedupeType);
|
ItemsDB.Deduplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
// For comparison's sake, we want to use CRC as the base bucketing
|
// For comparison's sake, we want to use CRC as the base bucketing
|
||||||
datFile.BucketBy(ItemKey.CRC);
|
datFile.BucketBy(ItemKey.CRC);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
intDat.BucketBy(ItemKey.CRC);
|
intDat.BucketBy(ItemKey.CRC);
|
||||||
|
|
||||||
// Then we do a hashwise comparison against the base DAT
|
// Then we do a hashwise comparison against the base DAT
|
||||||
@@ -511,7 +511,7 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
// For comparison's sake, we want to use Machine Name as the base bucketing
|
// For comparison's sake, we want to use Machine Name as the base bucketing
|
||||||
datFile.BucketBy(ItemKey.Machine);
|
datFile.BucketBy(ItemKey.Machine);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
intDat.BucketBy(ItemKey.Machine);
|
intDat.BucketBy(ItemKey.Machine);
|
||||||
|
|
||||||
// Then we do a namewise comparison against the base DAT
|
// Then we do a namewise comparison against the base DAT
|
||||||
@@ -579,7 +579,7 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
// For comparison's sake, we want to use CRC as the base bucketing
|
// For comparison's sake, we want to use CRC as the base bucketing
|
||||||
datFile.BucketBy(ItemKey.CRC);
|
datFile.BucketBy(ItemKey.CRC);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
intDat.BucketBy(ItemKey.CRC);
|
intDat.BucketBy(ItemKey.CRC);
|
||||||
|
|
||||||
// Then we do a hashwise comparison against the base DAT
|
// Then we do a hashwise comparison against the base DAT
|
||||||
@@ -621,7 +621,7 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
// For comparison's sake, we want to use Machine Name as the base bucketing
|
// For comparison's sake, we want to use Machine Name as the base bucketing
|
||||||
datFile.BucketBy(ItemKey.Machine);
|
datFile.BucketBy(ItemKey.Machine);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
intDat.BucketBy(ItemKey.Machine);
|
intDat.BucketBy(ItemKey.Machine);
|
||||||
|
|
||||||
// Then we do a namewise comparison against the base DAT
|
// Then we do a namewise comparison against the base DAT
|
||||||
@@ -680,7 +680,7 @@ namespace SabreTools.DatFiles
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
intDat.BucketBy(ItemKey.CRC);
|
intDat.BucketBy(ItemKey.CRC);
|
||||||
intDat.Deduplicate(DedupeType.Full);
|
intDat.Deduplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then we compare against the base DAT
|
// Then we compare against the base DAT
|
||||||
|
|||||||
@@ -169,29 +169,6 @@ namespace SabreTools.DatFiles
|
|||||||
ALL = ulong.MaxValue,
|
ALL = ulong.MaxValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines the DAT deduplication type
|
|
||||||
/// </summary>
|
|
||||||
public enum DedupeType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// No deduplication
|
|
||||||
/// </summary>
|
|
||||||
None = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deduplicate across all available fields
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Requires sorting by any hash</remarks>
|
|
||||||
Full,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deduplicate on a per-machine basis
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Requires sorting by machine</remarks>
|
|
||||||
Game,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines merging tag handling for DAT output
|
/// Determines merging tag handling for DAT output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey _bucketedBy = ItemKey.NULL;
|
private ItemKey _bucketedBy = ItemKey.NULL;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determine merging type for all items
|
|
||||||
/// </summary>
|
|
||||||
private DedupeType _mergedBy = DedupeType.None;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal dictionary for the class
|
/// Internal dictionary for the class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -381,22 +376,10 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform deduplication based on the deduplication type provided
|
/// Perform deduplication on the current sorted dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dedupeType">Dedupe type that should be used</param>
|
public void Deduplicate()
|
||||||
public void Deduplicate(DedupeType dedupeType)
|
|
||||||
{
|
{
|
||||||
// Set the sorted type
|
|
||||||
_mergedBy = dedupeType;
|
|
||||||
|
|
||||||
// If no deduplication is requested, just return
|
|
||||||
if (dedupeType == DedupeType.None)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Ensure Game deduplication is valid
|
|
||||||
if (dedupeType == DedupeType.Game && _bucketedBy != ItemKey.Machine)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
|
Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
|
||||||
#elif NET40_OR_GREATER
|
#elif NET40_OR_GREATER
|
||||||
@@ -579,9 +562,6 @@ namespace SabreTools.DatFiles
|
|||||||
// Set the sorted type
|
// Set the sorted type
|
||||||
_bucketedBy = bucketBy;
|
_bucketedBy = bucketBy;
|
||||||
|
|
||||||
// Reset the merged type since this might change the merge
|
|
||||||
_mergedBy = DedupeType.None;
|
|
||||||
|
|
||||||
// First do the initial sort of all of the roms inplace
|
// First do the initial sort of all of the roms inplace
|
||||||
List<string> oldkeys = [.. SortedKeys];
|
List<string> oldkeys = [.. SortedKeys];
|
||||||
|
|
||||||
|
|||||||
@@ -679,19 +679,10 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform deduplication based on the deduplication type provided
|
/// Perform deduplication on the current sorted dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dedupeType">Dedupe type that should be used</param>
|
public void Deduplicate()
|
||||||
public void Deduplicate(DedupeType dedupeType)
|
|
||||||
{
|
{
|
||||||
// If no deduplication is requested, just return
|
|
||||||
if (dedupeType == DedupeType.None)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Ensure Game deduplication is valid
|
|
||||||
if (dedupeType == DedupeType.Game && _bucketedBy != ItemKey.Machine)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
|
Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
|
||||||
#elif NET40_OR_GREATER
|
#elif NET40_OR_GREATER
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ namespace SabreTools.DatTools
|
|||||||
if (DedupeRoms == DedupeType.Full)
|
if (DedupeRoms == DedupeType.Full)
|
||||||
{
|
{
|
||||||
datFile.BucketBy(ItemKey.CRC);
|
datFile.BucketBy(ItemKey.CRC);
|
||||||
datFile.Deduplicate(DedupeRoms);
|
datFile.Deduplicate();
|
||||||
}
|
}
|
||||||
else if (DedupeRoms == DedupeType.Game)
|
else if (DedupeRoms == DedupeType.Game)
|
||||||
{
|
{
|
||||||
datFile.BucketBy(ItemKey.Machine);
|
datFile.BucketBy(ItemKey.Machine);
|
||||||
datFile.Deduplicate(DedupeRoms);
|
datFile.Deduplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process description to machine name
|
// Process description to machine name
|
||||||
|
|||||||
@@ -1,5 +1,28 @@
|
|||||||
namespace SabreTools.DatTools
|
namespace SabreTools.DatTools
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Determines the DAT deduplication type
|
||||||
|
/// </summary>
|
||||||
|
public enum DedupeType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No deduplication
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deduplicate across all available fields
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Requires sorting by any hash</remarks>
|
||||||
|
Full,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deduplicate on a per-machine basis
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Requires sorting by machine</remarks>
|
||||||
|
Game,
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines which files should be skipped in DFD
|
/// Determines which files should be skipped in DFD
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -211,12 +211,12 @@ namespace SabreTools.DatTools
|
|||||||
if (hashOnly)
|
if (hashOnly)
|
||||||
{
|
{
|
||||||
datFile.BucketBy(ItemKey.CRC);
|
datFile.BucketBy(ItemKey.CRC);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
datFile.BucketBy(ItemKey.Machine);
|
datFile.BucketBy(ItemKey.Machine);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then mark items for removal
|
// Then mark items for removal
|
||||||
@@ -261,12 +261,12 @@ namespace SabreTools.DatTools
|
|||||||
if (hashOnly)
|
if (hashOnly)
|
||||||
{
|
{
|
||||||
datFile.BucketBy(ItemKey.CRC);
|
datFile.BucketBy(ItemKey.CRC);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
datFile.BucketBy(ItemKey.Machine);
|
datFile.BucketBy(ItemKey.Machine);
|
||||||
datFile.Deduplicate(DedupeType.Full);
|
datFile.Deduplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then mark items for removal
|
// Then mark items for removal
|
||||||
|
|||||||
Reference in New Issue
Block a user