Skip to content

Commit 8d8c2c2

Browse files
committed
Add support for string mask early exit
1 parent 6e6ed16 commit 8d8c2c2

File tree

200 files changed

+906
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+906
-79
lines changed

Src/FastData.Benchmarks/Benchmarks/GPerfAnalyzerBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public GPerfAnalyzerBenchmarks()
1818
Random rng = new Random(42);
1919
_data = Enumerable.Range(1, 100).Select(_ => TestHelper.GenerateRandomString(rng, 50)).ToArray();
2020

21-
StringKeyProperties props = KeyAnalyzer.GetStringProperties(_data, false);
21+
StringKeyProperties props = KeyAnalyzer.GetStringProperties(_data, false, false);
2222
_analyzer = new GPerfAnalyzer(_data.Length, props, new GPerfAnalyzerConfig(), new Simulator(_data.Length, GeneratorEncoding.UTF16), NullLogger<GPerfAnalyzer>.Instance);
2323
}
2424

Src/FastData.Benchmarks/Benchmarks/KeyAnalyzerBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ public KeyAnalyzerBenchmarks()
1515
}
1616

1717
[Benchmark]
18-
public object GetStringProperties() => KeyAnalyzer.GetStringProperties(_data, true);
18+
public object GetStringProperties() => KeyAnalyzer.GetStringProperties(_data, true, false);
1919
}

Src/FastData.Benchmarks/Benchmarks/SegmentGeneratorsBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class SegmentGeneratorsBenchmarks
1414
private readonly OffsetGenerator _ofGen = new OffsetGenerator();
1515

1616
//We start at 8 and go up to 100 to cover as many cases as possible
17-
private readonly StringKeyProperties _props = KeyAnalyzer.GetStringProperties(Enumerable.Range(8, 100).Select(x => TestHelper.GenerateRandomString(Random.Shared, x)).ToArray(), false);
17+
private readonly StringKeyProperties _props = KeyAnalyzer.GetStringProperties(Enumerable.Range(8, 100).Select(x => TestHelper.GenerateRandomString(Random.Shared, x)).ToArray(), false, false);
1818

1919
[Benchmark]
2020
public object BruteForceGenerator() => _bfGen.Generate(_props).ToArray();

Src/FastData.Cli.Tests/CommandOutputs/cpp_-k UInt8_Files_Integers.input.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Structure: Auto (Conditional)
55
#pragma once
66
#include <array>
7+
#include <cstring>
78
#include <cstdint>
89
#include <limits>
910
#include <string_view>

Src/FastData.Cli.Tests/CommandOutputs/cpp_-s HashTable_Files_Strings.input.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Structure: HashTable
55
#pragma once
66
#include <array>
7+
#include <cstring>
78
#include <cstdint>
89
#include <limits>
910
#include <string_view>
@@ -43,6 +44,7 @@ public:
4344
return false;
4445

4546

47+
4648
const uint64_t hash = get_hash(key);
4749
const size_t index = hash % 2;
4850
int8_t i = static_cast<int8_t>(buckets[index] - 1);

Src/FastData.Cli.Tests/CommandOutputs/cpp_Files_Strings.input.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Structure: Auto (Conditional)
55
#pragma once
66
#include <array>
7+
#include <cstring>
78
#include <cstdint>
89
#include <limits>
910
#include <string_view>
@@ -15,6 +16,7 @@ public:
1516
if (key.length() != 5u)
1617
return false;
1718

19+
1820
if (key == "test1" || key == "test2")
1921
return true;
2022

Src/FastData.Cli.Tests/CommandOutputs/csharp_-s HashTable_Files_Strings.input.verified.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ internal static class MyData
6060
{
6161
if (key.Length != 5u)
6262
return false;
63+
ulong first = (ulong)key[0] | ((ulong)key[1] << 16) | ((ulong)key[2] << 32) | ((ulong)key[3] << 48);
64+
65+
if ((first & 18414092482483257227UL) != 0)
66+
return false;
6367

6468

6569
ulong hash = Hash(key);

Src/FastData.Cli.Tests/CommandOutputs/csharp_Files_Strings.input.verified.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ internal static class MyData
1515
{
1616
if (key.Length != 5u)
1717
return false;
18+
ulong first = (ulong)key[0] | ((ulong)key[1] << 16) | ((ulong)key[2] << 32) | ((ulong)key[3] << 48);
19+
20+
if ((first & 18414092482483257227UL) != 0)
21+
return false;
1822

1923

2024
switch (key)

Src/FastData.Cli.Tests/CommandOutputs/rust_-s HashTable_Files_Strings.input.verified.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const ENTRIES: [e; 2] = [
4545
if key.len() != 5 as usize {
4646
return false;
4747
}
48+
let bytes = key.as_bytes();
49+
let first = (bytes[0] as u64) | (bytes[1] as u64) << 8 | (bytes[2] as u64) << 16 | (bytes[3] as u64) << 24 | (bytes[4] as u64) << 32;
50+
51+
if (first & 878514576011u64) != 0 {
52+
return false;
53+
}
4854

4955

5056
let hash = unsafe { Self::get_hash(key) };

Src/FastData.Cli.Tests/CommandOutputs/rust_Files_Strings.input.verified.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ impl MyData {
1616
if key.len() != 5 as usize {
1717
return false;
1818
}
19+
let bytes = key.as_bytes();
20+
let first = (bytes[0] as u64) | (bytes[1] as u64) << 8 | (bytes[2] as u64) << 16 | (bytes[3] as u64) << 24 | (bytes[4] as u64) << 32;
21+
22+
if (first & 878514576011u64) != 0 {
23+
return false;
24+
}
1925

2026

2127
if key == "test1" || key == "test2" {

0 commit comments

Comments
 (0)