From a52a2083dda9a22527846fc287ef22b90dfc25a3 Mon Sep 17 00:00:00 2001 From: Ogoun Date: Mon, 14 Nov 2022 22:41:56 +0300 Subject: [PATCH] PartitionStorage FilePartitionsPresets --- .../PartitionStorage/FilePartitionsPresets.cs | 38 +++++++++++++++++++ ZeroLevel/ZeroLevel.csproj | 8 ++-- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 ZeroLevel/Services/PartitionStorage/FilePartitionsPresets.cs diff --git a/ZeroLevel/Services/PartitionStorage/FilePartitionsPresets.cs b/ZeroLevel/Services/PartitionStorage/FilePartitionsPresets.cs new file mode 100644 index 0000000..55f425d --- /dev/null +++ b/ZeroLevel/Services/PartitionStorage/FilePartitionsPresets.cs @@ -0,0 +1,38 @@ +using System; +using ZeroLevel.Services.HashFunctions; + +namespace ZeroLevel.Services.PartitionStorage +{ + public static class FilePartitionsPresets + { + public static StoreFilePartition StringDivideIntoParts(string name, int parts) + { + Func extractor = (key, _) => ((int)Math.Abs(StringHash.DotNetFullHash(key) % parts)).ToString(); + return new StoreFilePartition(name, extractor); + } + + public static StoreFilePartition ULongDivideIntoParts(string name, int parts) + { + Func extractor = (key, _) => (key % (ulong)parts).ToString(); + return new StoreFilePartition(name, extractor); + } + + public static StoreFilePartition LongDivideIntoParts(string name, int parts) + { + Func extractor = (key, _) => (key % (long)parts).ToString(); + return new StoreFilePartition(name, extractor); + } + + public static StoreFilePartition UIntDivideIntoParts(string name, int parts) + { + Func extractor = (key, _) => (key % (uint)parts).ToString(); + return new StoreFilePartition(name, extractor); + } + + public static StoreFilePartition IntDivideIntoParts(string name, int parts) + { + Func extractor = (key, _) => (key % parts).ToString(); + return new StoreFilePartition(name, extractor); + } + } +} \ No newline at end of file diff --git a/ZeroLevel/ZeroLevel.csproj b/ZeroLevel/ZeroLevel.csproj index 815787d..12c9293 100644 --- a/ZeroLevel/ZeroLevel.csproj +++ b/ZeroLevel/ZeroLevel.csproj @@ -6,16 +6,16 @@ ogoun ogoun - 3.3.7.3 - PartitionStorage append indexes + 3.3.7.4 + PartitionStorage FilePartitionsPresets https://github.com/ogoun/Zero/wiki Copyright Ogoun 2022 https://github.com/ogoun/Zero git - 3.3.7.3 - 3.3.7.3 + 3.3.7.4 + 3.3.7.4 AnyCPU;x64;x86 zero.png full