Skip to content

Commit 5effd82

Browse files
committed
Remove early exits from data structure vectors
1 parent 5e4d4e7 commit 5effd82

256 files changed

Lines changed: 29 additions & 678 deletions

File tree

Some content is hidden

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

Src/FastData.TestHarness.Runner/Code/Abstracts/VectorTestsBase.cs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using Genbox.FastData.Config;
3+
using Genbox.FastData.Internal.Structures;
34
using Genbox.FastData.InternalShared.Harness;
45
using Genbox.FastData.InternalShared.TestClasses;
56
using Genbox.FastData.TestHarness.Runner.Code.Theory;
@@ -19,15 +20,26 @@ public async Task ValueVectors<TKey>(TestVector<TKey> vector)
1920
string source;
2021

2122
if (vector.Keys is string[] strKeys)
22-
source = FastDataGenerator.Generate(strKeys, new StringDataConfig { StructureTypeOverride = vector.StructureType }, Harness.Generator);
23+
{
24+
StringDataConfig config = new StringDataConfig();
25+
config.StructureTypeOverride = vector.StructureType;
26+
config.EarlyExitConfig.Disabled = true;
27+
source = FastDataGenerator.Generate(strKeys, config, Harness.Generator);
28+
}
2329
else
24-
source = FastDataGenerator.Generate(vector.Keys, new NumericDataConfig { StructureTypeOverride = vector.StructureType }, Harness.Generator);
30+
{
31+
NumericDataConfig config = new NumericDataConfig();
32+
config.StructureTypeOverride = vector.StructureType;
33+
config.EarlyExitConfig.Disabled = true;
34+
source = FastDataGenerator.Generate(vector.Keys, config, Harness.Generator);
35+
}
2536

2637
Assert.NotEmpty(source);
2738

2839
string id = $"{nameof(ValueVectors)}_{vector.Identifier}";
2940
await VerifyVectorAsync(Harness.Name, id, source);
30-
Assert.Equal(1, await Harness.RunContainsAsync(source, id, vector.Keys, vector.NotPresent, TestContext.Current.CancellationToken));
41+
TKey[] notPresent = vector.StructureType == typeof(BloomFilterStructure<,>) ? Array.Empty<TKey>() : vector.NotPresent;
42+
Assert.Equal(1, await Harness.RunContainsAsync(source, id, vector.Keys, notPresent, TestContext.Current.CancellationToken));
3143
}
3244

3345
[Theory]
@@ -37,14 +49,25 @@ public async Task KeyValueVectors<TKey, TValue>(TestVector<TKey, TValue> vector)
3749
string source;
3850

3951
if (vector.Keys is string[] strKeys)
40-
source = FastDataGenerator.GenerateKeyed(strKeys, vector.Values, new StringDataConfig { StructureTypeOverride = vector.StructureType }, Harness.Generator);
52+
{
53+
StringDataConfig config = new StringDataConfig();
54+
config.StructureTypeOverride = vector.StructureType;
55+
config.EarlyExitConfig.Disabled = true;
56+
source = FastDataGenerator.GenerateKeyed(strKeys, vector.Values, config, Harness.Generator);
57+
}
4158
else
42-
source = FastDataGenerator.GenerateKeyed(vector.Keys, vector.Values, new NumericDataConfig { StructureTypeOverride = vector.StructureType }, Harness.Generator);
59+
{
60+
NumericDataConfig config = new NumericDataConfig();
61+
config.StructureTypeOverride = vector.StructureType;
62+
config.EarlyExitConfig.Disabled = true;
63+
source = FastDataGenerator.GenerateKeyed(vector.Keys, vector.Values, config, Harness.Generator);
64+
}
4365

4466
Assert.NotEmpty(source);
4567

4668
string id = $"{nameof(KeyValueVectors)}_{vector.Identifier}";
4769
await VerifyFeatureAsync(Harness.Name, id, source);
48-
Assert.Equal(1, await Harness.RunTryLookupAsync(source, id, vector.Keys, vector.Values, vector.NotPresent, TestContext.Current.CancellationToken));
70+
TKey[] notPresent = vector.StructureType == typeof(BloomFilterStructure<,>) ? Array.Empty<TKey>() : vector.NotPresent;
71+
Assert.Equal(1, await Harness.RunTryLookupAsync(source, id, vector.Keys, vector.Values, notPresent, TestContext.Current.CancellationToken));
4972
}
5073
}

Src/FastData.TestHarness.Runner/Verify/Features/CPlusPlus/KeyValueVectors_KeyLength_String_3_complex.verified.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,13 @@ class fastdata final {
2929
public:
3030
[[nodiscard]]
3131
static constexpr bool contains(const std::string_view key) noexcept {
32-
const size_t len = key.length();
33-
if (len < 1u || len > 3u)
34-
return false;
3532

3633

3734
return key == keys[key.length() - 1];
3835
}
3936

4037
[[nodiscard]]
4138
static bool try_lookup(const std::string_view key, const Person*& value) noexcept {
42-
const size_t len = key.length();
43-
if (len < 1u || len > 3u)
44-
{
45-
value = nullptr;
46-
return false;
47-
}
4839

4940

5041
size_t idx = key.length() - 1;

Src/FastData.TestHarness.Runner/Verify/Features/CPlusPlus/KeyValueVectors_KeyLength_String_3_simple.verified.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,13 @@ class fastdata final {
2222
public:
2323
[[nodiscard]]
2424
static constexpr bool contains(const std::string_view key) noexcept {
25-
const size_t len = key.length();
26-
if (len < 1u || len > 3u)
27-
return false;
2825

2926

3027
return key == keys[key.length() - 1];
3128
}
3229

3330
[[nodiscard]]
3431
static bool try_lookup(const std::string_view key, const int32_t*& value) noexcept {
35-
const size_t len = key.length();
36-
if (len < 1u || len > 3u)
37-
{
38-
value = nullptr;
39-
return false;
40-
}
4132

4233

4334
size_t idx = key.length() - 1;

Src/FastData.TestHarness.Runner/Verify/Features/CSharp/KeyValueVectors_KeyLength_String_3_complex.verified.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,13 @@ internal static class FastData
3636

3737
public static bool Contains(string key)
3838
{
39-
int len = key.Length;
40-
if (len < 1u || len > 3u)
41-
return false;
4239

4340

4441
return StringComparer.Ordinal.Equals(key, _keys[key.Length - 1]);
4542
}
4643

4744
public static bool TryLookup(string key, out Person value)
4845
{
49-
int len = key.Length;
50-
if (len < 1u || len > 3u)
51-
{
52-
value = default;
53-
return false;
54-
}
5546

5647

5748
int idx = key.Length - 1;

Src/FastData.TestHarness.Runner/Verify/Features/CSharp/KeyValueVectors_KeyLength_String_3_simple.verified.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,13 @@ internal static class FastData
2323

2424
public static bool Contains(string key)
2525
{
26-
int len = key.Length;
27-
if (len < 1u || len > 3u)
28-
return false;
2926

3027

3128
return StringComparer.Ordinal.Equals(key, _keys[key.Length - 1]);
3229
}
3330

3431
public static bool TryLookup(string key, out int value)
3532
{
36-
int len = key.Length;
37-
if (len < 1u || len > 3u)
38-
{
39-
value = default;
40-
return false;
41-
}
4233

4334

4435
int idx = key.Length - 1;

Src/FastData.TestHarness.Runner/Verify/Features/Rust/KeyValueVectors_KeyLength_String_3_complex.verified.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,13 @@ impl fastdata {
3535

3636
#[must_use]
3737
pub fn contains(key: &'static str) -> bool {
38-
let len = key.len();
39-
if len < 1 as usize || len > 3 as usize {
40-
return false;
41-
}
4238

4339

4440
return key == Self::KEYS[key.len() - 1];
4541
}
4642

4743
#[must_use]
4844
pub fn try_lookup(key: &'static str) -> Option<&'static Person> {
49-
let len = key.len();
50-
if len < 1 as usize || len > 3 as usize {
51-
return None;
52-
}
5345

5446

5547
let idx = (key.len() - 1) as usize;

Src/FastData.TestHarness.Runner/Verify/Features/Rust/KeyValueVectors_KeyLength_String_3_simple.verified.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,13 @@ impl fastdata {
2525

2626
#[must_use]
2727
pub fn contains(key: &'static str) -> bool {
28-
let len = key.len();
29-
if len < 1 as usize || len > 3 as usize {
30-
return false;
31-
}
3228

3329

3430
return key == Self::KEYS[key.len() - 1];
3531
}
3632

3733
#[must_use]
3834
pub fn try_lookup(key: &'static str) -> Option<i32> {
39-
let len = key.len();
40-
if len < 1 as usize || len > 3 as usize {
41-
return None;
42-
}
4335

4436

4537
let idx = (key.len() - 1) as usize;

Src/FastData.TestHarness.Runner/Verify/Vectors/CPlusPlus/ValueVectors_Array_Double_4.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class fastdata final {
1414
public:
1515
[[nodiscard]]
1616
static constexpr bool contains(const double key) noexcept {
17-
if (key < std::numeric_limits<double>::lowest() || key > std::numeric_limits<double>::max())
18-
return false;
1917

2018

2119
for (size_t i = 0; i < 4; i++)

Src/FastData.TestHarness.Runner/Verify/Vectors/CPlusPlus/ValueVectors_Array_Int16_5.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class fastdata final {
1414
public:
1515
[[nodiscard]]
1616
static constexpr bool contains(const int16_t key) noexcept {
17-
if ((static_cast<uint16_t>(key) & 0) != 0)
18-
return false;
1917

2018

2119
for (size_t i = 0; i < 5; i++)

Src/FastData.TestHarness.Runner/Verify/Vectors/CPlusPlus/ValueVectors_Array_Int32_100.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class fastdata final {
2323
public:
2424
[[nodiscard]]
2525
static constexpr bool contains(const int32_t key) noexcept {
26-
if ((static_cast<uint32_t>(key) & 4294967168u) != 0)
27-
return false;
2826

2927

3028
for (size_t i = 0; i < 100; i++)

0 commit comments

Comments
 (0)