-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kristjan Nielsen
committed
Oct 22, 2023
1 parent
41f04c2
commit b80c07c
Showing
11 changed files
with
82 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Threading.Tasks; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
public static class CacheUtility { | ||
public static ConcurrentBag<int> GetMissingKeys<T>( | ||
this IDictionary<int, T> existing, ICollection<int> newKeys) { | ||
var missingIds = new ConcurrentBag<int>(); | ||
Parallel.ForEach(newKeys, key => { | ||
if (!existing.ContainsKey(key)) { | ||
missingIds.Add(key); | ||
} | ||
}); | ||
|
||
return missingIds; | ||
} | ||
|
||
public static ConcurrentDictionary<int, T> GetSubset<T>( | ||
this IDictionary<int, T> dictionary, ICollection<int> keys) { | ||
var subset = new ConcurrentDictionary<int, T>(); | ||
Parallel.ForEach(keys, key => subset.TryAdd(key, dictionary[key])); | ||
return subset; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
public interface INodeResultCache<T> where T : IResultQuantitySet { | ||
public IApiResult ApiResult { get; set; } | ||
public IDictionary<string, IResultSubset<T>> Cache { get;} | ||
public IResultSubset<T> ResultSubset(string list); | ||
public ConcurrentDictionary<int, ICollection<T>> Cache { get; } | ||
public IResultSubset<T> ResultSubset(ICollection<int> list); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
public interface IResultSubset<T> where T : IResultQuantitySet { | ||
public T Max { get; } | ||
public T Min { get; } | ||
public List<int> Ids { get; } | ||
public ConcurrentDictionary<int, Collection<T>> Results { get; } | ||
public ConcurrentDictionary<int, ICollection<T>> Results { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters