Skip to content

Commit e95f1dc

Browse files
committed
Add prefix/suffix support
1 parent bae2f24 commit e95f1dc

File tree

74 files changed

+619
-216
lines changed

Some content is hidden

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

74 files changed

+619
-216
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-
StringProperties props = KeyAnalyzer.GetStringProperties(_data);
21+
StringProperties props = KeyAnalyzer.GetStringProperties(_data, 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);
18+
public object GetStringProperties() => KeyAnalyzer.GetStringProperties(_data, true);
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 StringProperties _props = KeyAnalyzer.GetStringProperties(Enumerable.Range(8, 100).Select(x => TestHelper.GenerateRandomString(Random.Shared, x)).ToArray());
17+
private readonly StringProperties _props = KeyAnalyzer.GetStringProperties(Enumerable.Range(8, 100).Select(x => TestHelper.GenerateRandomString(Random.Shared, x)).ToArray(), false);
1818

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const ENTRIES: [e; 2] = [
4545
if key.len() != 5 as usize {
4646
return false;
4747
}
48+
4849
let hash = unsafe { Self::get_hash(key) };
4950
let index = (hash % 2) as usize;
5051

Src/FastData.Generator.CPlusPlus.Tests/Vectors/ArrayStructure_String_13.verified.txt renamed to Src/FastData.Generator.CPlusPlus.Tests/Vectors/ArrayStructure_String_13_non_ascii.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <limits>
77
#include <string_view>
88

9-
class ArrayStructure_String_13 final {
9+
class ArrayStructure_String_13_non_ascii final {
1010
static constexpr std::array<std::u32string_view, 13> keys = {
1111
U"æ", U"à", U"ä", U"ö", U"ü", U"ß", U"é", U"è", U"ê", U"ç",
1212
U"ñ", U"ø", U"å"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This file is auto-generated. Do not edit manually.
2+
// Structure: Array
3+
#pragma once
4+
#include <array>
5+
#include <cstdint>
6+
#include <limits>
7+
#include <string_view>
8+
9+
class ArrayStructure_String_2_prefix_suffix final {
10+
static constexpr std::array<std::string_view, 2> keys = {
11+
"suf", "pre"
12+
};
13+
14+
public:
15+
[[nodiscard]]
16+
static constexpr bool contains(const std::string_view key) noexcept {
17+
if (key.length() != 6u)
18+
return false;
19+
if (!(key.compare(key.length() - 3, 3, "fix") == 0))
20+
return false;
21+
22+
const auto trimmedKey = key.substr(0, key.length() - 3);
23+
24+
for (size_t i = 0; i < 2; i++)
25+
{
26+
if (keys[i] == trimmedKey)
27+
return true;
28+
}
29+
return false;
30+
}
31+
32+
static constexpr size_t item_count = 2;
33+
static constexpr size_t min_key_length = 6;
34+
static constexpr size_t max_key_length = 6;
35+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This file is auto-generated. Do not edit manually.
2+
// Structure: Array
3+
#pragma once
4+
#include <array>
5+
#include <cstdint>
6+
#include <limits>
7+
#include <string_view>
8+
9+
class ArrayStructure_String_3_prefix_suffix final {
10+
static constexpr std::array<std::string_view, 3> keys = {
11+
"text", "fetch", "fix"
12+
};
13+
14+
public:
15+
[[nodiscard]]
16+
static constexpr bool contains(const std::string_view key) noexcept {
17+
if (const size_t len = key.length(); len < 6u || len > 8u)
18+
return false;
19+
if (!(key.compare(0, 3, "pre") == 0))
20+
return false;
21+
22+
const auto trimmedKey = key.substr(3, key.length() - 3);
23+
24+
for (size_t i = 0; i < 3; i++)
25+
{
26+
if (keys[i] == trimmedKey)
27+
return true;
28+
}
29+
return false;
30+
}
31+
32+
static constexpr size_t item_count = 3;
33+
static constexpr size_t min_key_length = 6;
34+
static constexpr size_t max_key_length = 8;
35+
};

Src/FastData.Generator.CPlusPlus.Tests/Vectors/BinarySearchStructure_String_13.verified.txt renamed to Src/FastData.Generator.CPlusPlus.Tests/Vectors/BinarySearchStructure_String_13_non_ascii.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <limits>
77
#include <string_view>
88

9-
class BinarySearchStructure_String_13 final {
9+
class BinarySearchStructure_String_13_non_ascii final {
1010
static constexpr std::array<std::u32string_view, 13> keys = {
1111
U"ß", U"à", U"ä", U"å", U"æ", U"ç", U"è", U"é", U"ê", U"ñ",
1212
U"ö", U"ø", U"ü"

Src/FastData.Generator.CPlusPlus.Tests/Vectors/BitSetStructure_Int32_5.verified.txt renamed to Src/FastData.Generator.CPlusPlus.Tests/Vectors/BitSetStructure_Int32_5_range_bitset.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <limits>
77
#include <string_view>
88

9-
class BitSetStructure_Int32_5 final {
9+
class BitSetStructure_Int32_5_range_bitset final {
1010
static constexpr std::array<uint64_t, 1> bitset = {
1111
31ull
1212
};

Src/FastData.Generator.CPlusPlus.Tests/Vectors/ConditionalStructure_String_13.verified.txt renamed to Src/FastData.Generator.CPlusPlus.Tests/Vectors/ConditionalStructure_String_13_non_ascii.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <limits>
77
#include <string_view>
88

9-
class ConditionalStructure_String_13 final {
9+
class ConditionalStructure_String_13_non_ascii final {
1010
public:
1111
[[nodiscard]]
1212
static constexpr bool contains(const std::u32string_view key) noexcept {

0 commit comments

Comments
 (0)