Skip to content

Commit 8be908e

Browse files
committed
Skip missing implementations for now
1 parent 202b9ab commit 8be908e

13 files changed

Lines changed: 217 additions & 1 deletion

Src/FastData.Generator.CPlusPlus/CPlusPlusCodeGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ protected override void AppendFooter<T>(StringBuilder sb, GeneratorConfig<T> gen
7777
HashTableCompactContext<TKey, TValue> x => new HashTableCompactCode<TKey, TValue>(x, Shared),
7878
HashTablePerfectContext<TKey, TValue> x => new HashTablePerfectCode<TKey, TValue>(x, Shared),
7979
KeyLengthContext<TValue> x => new KeyLengthCode<TKey, TValue>(x, Shared),
80+
EliasFanoContext<TKey> x => new EliasFanoCode<TKey>(x),
81+
RrrBitVectorContext x => new RrrBitVectorCode<TKey>(x),
8082
_ => null
8183
};
8284
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Genbox.FastData.Generator.CPlusPlus.Internal.Framework;
2+
using Genbox.FastData.Generator.Enums;
3+
using Genbox.FastData.Generators.Contexts;
4+
5+
namespace Genbox.FastData.Generator.CPlusPlus.Internal.Generators;
6+
7+
internal sealed class EliasFanoCode<TKey>(EliasFanoContext<TKey> ctx) : CPlusPlusOutputWriter<TKey>
8+
{
9+
public override string Generate()
10+
{
11+
_ = ctx;
12+
13+
return $$"""
14+
public:
15+
{{MethodAttribute}}
16+
{{GetMethodModifier(true)}}bool contains(const {{KeyTypeName}} {{InputKeyName}}){{PostMethodModifier}} {
17+
{{GetMethodHeader(MethodType.Contains)}}
18+
return false;
19+
}
20+
""";
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Genbox.FastData.Generator.CPlusPlus.Internal.Framework;
2+
using Genbox.FastData.Generator.Enums;
3+
using Genbox.FastData.Generators.Contexts;
4+
5+
namespace Genbox.FastData.Generator.CPlusPlus.Internal.Generators;
6+
7+
internal sealed class RrrBitVectorCode<TKey>(RrrBitVectorContext ctx) : CPlusPlusOutputWriter<TKey>
8+
{
9+
public override string Generate()
10+
{
11+
_ = ctx;
12+
13+
return $$"""
14+
public:
15+
{{MethodAttribute}}
16+
{{GetMethodModifier(true)}}bool contains(const {{KeyTypeName}} {{InputKeyName}}){{PostMethodModifier}} {
17+
{{GetMethodHeader(MethodType.Contains)}}
18+
return false;
19+
}
20+
""";
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Genbox.FastData.Generator.Enums;
2+
using Genbox.FastData.Generator.Rust.Internal.Framework;
3+
using Genbox.FastData.Generators.Contexts;
4+
5+
namespace Genbox.FastData.Generator.Rust.Internal.Generators;
6+
7+
internal sealed class EliasFanoCode<TKey>(EliasFanoContext<TKey> ctx) : RustOutputWriter<TKey>
8+
{
9+
public override string Generate()
10+
{
11+
_ = ctx;
12+
bool customKey = !typeof(TKey).IsPrimitive;
13+
14+
return $$"""
15+
{{MethodAttribute}}
16+
{{MethodModifier}}fn contains({{InputKeyName}}: {{GetKeyTypeName(customKey)}}) -> bool {
17+
{{GetMethodHeader(MethodType.Contains)}}
18+
let _ = {{InputKeyName}};
19+
false
20+
}
21+
""";
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Genbox.FastData.Generator.Enums;
2+
using Genbox.FastData.Generator.Rust.Internal.Framework;
3+
using Genbox.FastData.Generators.Contexts;
4+
5+
namespace Genbox.FastData.Generator.Rust.Internal.Generators;
6+
7+
internal sealed class RrrBitVectorCode<TKey>(RrrBitVectorContext ctx) : RustOutputWriter<TKey>
8+
{
9+
public override string Generate()
10+
{
11+
_ = ctx;
12+
bool customKey = !typeof(TKey).IsPrimitive;
13+
14+
return $$"""
15+
{{MethodAttribute}}
16+
{{MethodModifier}}fn contains({{InputKeyName}}: {{GetKeyTypeName(customKey)}}) -> bool {
17+
{{GetMethodHeader(MethodType.Contains)}}
18+
let _ = {{InputKeyName}};
19+
false
20+
}
21+
""";
22+
}
23+
}

Src/FastData.Generator.Rust/RustCodeGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ protected override void AppendFooter<T>(StringBuilder sb, GeneratorConfig<T> gen
7272
HashTableCompactContext<TKey, TValue> x => new HashTableCompactCode<TKey, TValue>(x, genCfg, Shared),
7373
HashTablePerfectContext<TKey, TValue> x => new HashTablePerfectCode<TKey, TValue>(x, genCfg, Shared),
7474
KeyLengthContext<TValue> x => new KeyLengthCode<TKey, TValue>(x, Shared),
75+
EliasFanoContext<TKey> x => new EliasFanoCode<TKey>(x),
76+
RrrBitVectorContext x => new RrrBitVectorCode<TKey>(x),
7577
_ => null
7678
};
7779
}

Src/FastData.TestHarness.Runner/Code/TestHarnessRunnerHelper.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Genbox.FastData.InternalShared;
22
using Genbox.FastData.InternalShared.TestClasses;
33
using Genbox.FastData.InternalShared.TestHarness;
4+
using Xunit.Sdk;
45

56
namespace Genbox.FastData.TestHarness.Runner.Code;
67

@@ -9,6 +10,18 @@ internal static class TestHarnessRunnerHelper
910
private const int SuccessExitCode = 1;
1011
private const string FeatureDirectory = "../Verify/Features/";
1112
private const string VectorDirectory = "../Verify/Vectors/";
13+
private const string CPlusPlusHarnessName = "CPlusPlus";
14+
private const string RustHarnessName = "Rust";
15+
private const string EliasFanoStructureName = "EliasFanoStructure";
16+
private const string RrrBitVectorStructureName = "RrrBitVectorStructure";
17+
18+
internal static void SkipIfEmptyImplementation(ITestHarness harness, Type structureType)
19+
{
20+
if (!IsEmptyImplementation(harness.Name, structureType))
21+
return;
22+
23+
throw SkipException.ForSkip($"Empty implementation for {structureType.Name} in {harness.Name}.");
24+
}
1225

1326
internal static async Task VerifyFeatureAsync(ITestHarness harness, string snapshotId, string source)
1427
{
@@ -41,4 +54,14 @@ internal static int RunTryLookupProgram<TKey, TValue>(ITestHarness harness, Gene
4154
}
4255

4356
internal static void AssertSuccessExitCode(int exitCode) => Assert.Equal(SuccessExitCode, exitCode);
44-
}
57+
58+
private static bool IsEmptyImplementation(string harnessName, Type structureType)
59+
{
60+
if (harnessName != CPlusPlusHarnessName && harnessName != RustHarnessName)
61+
return false;
62+
63+
string typeName = structureType.Name;
64+
return typeName.StartsWith(EliasFanoStructureName, StringComparison.Ordinal)
65+
|| typeName.StartsWith(RrrBitVectorStructureName, StringComparison.Ordinal);
66+
}
67+
}

Src/FastData.TestHarness.Runner/FeatureTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class FeatureTests
1515
[ClassData(typeof(FloatNaNZeroTestVectors))]
1616
public async Task FloatNaNOrZeroHashSupport<T>(ITestHarness harness, TestVector<T> vector)
1717
{
18+
TestHarnessRunnerHelper.SkipIfEmptyImplementation(harness, vector.Type);
1819
GeneratorSpec spec = Generate(harness.CreateGenerator, vector);
1920

2021
string snapshotId = $"{nameof(FloatNaNOrZeroHashSupport)}_{spec.Identifier}";

Src/FastData.TestHarness.Runner/VectorTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class VectorTests
1515
[ClassData(typeof(KeyValueTestVectors))]
1616
public async Task KeyValueVectors<TKey, TValue>(ITestHarness harness, TestVector<TKey, TValue> vector) where TValue : notnull
1717
{
18+
TestHarnessRunnerHelper.SkipIfEmptyImplementation(harness, vector.Type);
1819
GeneratorSpec spec = Generate(harness.CreateGenerator, vector);
1920
Assert.NotEmpty(spec.Source);
2021

@@ -29,6 +30,7 @@ public async Task KeyValueVectors<TKey, TValue>(ITestHarness harness, TestVector
2930
[ClassData(typeof(ValueTestVectors))]
3031
public async Task ValueVectors<T>(ITestHarness harness, TestVector<T> vector)
3132
{
33+
TestHarnessRunnerHelper.SkipIfEmptyImplementation(harness, vector.Type);
3234
GeneratorSpec spec = Generate(harness.CreateGenerator, vector);
3335
Assert.NotEmpty(spec.Source);
3436

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This file is auto-generated. Do not edit manually.
2+
// Structure: EliasFano
3+
#pragma once
4+
#include <array>
5+
#include <cstring>
6+
#include <cstdint>
7+
#include <limits>
8+
#include <string_view>
9+
10+
class EliasFanoStructure_Int32_1000_natural_sparse final {
11+
public:
12+
[[nodiscard]]
13+
static constexpr bool contains(const int32_t key) noexcept {
14+
if ((static_cast<uint32_t>(key) & 4294901760u) != 0)
15+
return false;
16+
17+
return false;
18+
}
19+
20+
static constexpr size_t item_count = 1000;
21+
static constexpr int32_t min_key = 11727;
22+
static constexpr int32_t max_key = 38755;
23+
};

0 commit comments

Comments
 (0)