Skip to content

Commit

Permalink
Unittest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wsm2110 committed Apr 14, 2024
1 parent 65ec512 commit 2bfc5ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 75 deletions.
76 changes: 3 additions & 73 deletions src/Faster.Map.QuadMap/QuadMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,78 +268,6 @@ public bool Emplace(TKey key, TValue value)
} while (true);
}


/// <summary>
///
/// Tries to emplace a key-value pair into the map
///
/// If the map already contains this key, update the existing KeyValuePair
///
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public void EmplaceOrUpdate(TKey key, TValue value)
//{
// //Resize if loadfactor is reached
// if (Count > _maxLookupsBeforeResize)
// {
// Resize();
// }

// //Get object identity hashcode
// var hashcode = (uint)key.GetHashCode();

// // Objectidentity hashcode * golden ratio (fibonnachi hashing) followed by a shift
// uint index = hashcode * _goldenRatio >> _shift;

// uint jumpDistance = 1;

// // Get 7 high bits
// var h2 = hashcode & _bitmask;

// do
// {
// //retrieve infobyte
// ref var metadata = ref _metadata[index];

// //Empty spot, add entry
// if (metadata == _emptyBucket || metadata == _tombstone)
// {
// _entries[index].Key = key;
// _entries[index].Value = value;

// metadata = Unsafe.As<long, sbyte>(ref h2);

// ++Count;
// return;
// }

// ref var entry = ref _entries[index];

// //validate hash
// if (h2 == metadata && _comparer.Equals(key, entry.Key))
// {
// // Update existing value
// entry.Value = value;
// return;
// }

// index += jumpDistance;

// if (index >= _length)
// {
// // adding jumpdistance to the index will prevent endless loops.
// // Every time this code block is entered jumpdistance will be different hence the index will be different too
// // thus it will always look for an empty spot
// index = BitOperations.RotateRight(hashcode, 31) + jumpDistance >> _shift;
// }

// jumpDistance += 1;

// } while (true);
//}

/// <summary>
/// Gets the value with the corresponding key
/// </summary>
Expand All @@ -353,7 +281,9 @@ public bool Get(TKey key, out TValue value)
var hashcode = (uint)key.GetHashCode();

Check warning on line 281 in src/Faster.Map.QuadMap/QuadMap.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
// Objectidentity hashcode * golden ratio (fibonnachi hashing) followed by a shift
uint index = _goldenRatio * hashcode >> _shift;

long h2 = hashcode & _bitmask;

uint jumpDistance = 0;

while (true)
Expand All @@ -367,7 +297,7 @@ public bool Get(TKey key, out TValue value)
return true;
}

//Empty spot, add entry
//Empty spot
if (entry.Metadata == _emptyBucket)
{
value = _defaultValue;

Check warning on line 303 in src/Faster.Map.QuadMap/QuadMap.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Faster.Map.DenseMap;
using Xunit;

namespace Faster.Map.RobinhoodMap.Tests
namespace Faster.Map.Densemap.Tests
{
public class DenseMapStringWrapperTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Faster.Map.RobinhoodMap.Tests
[assembly: CollectionBehavior(DisableTestParallelization = true)]

namespace Faster.Map.RobinhoodMap.Tests
{
public class RobinhoodBenchmarkFixture
{
Expand Down

0 comments on commit 2bfc5ec

Please sign in to comment.