You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2017/04/06 06:04:01 UTC
ignite git commit: IGNITE-4899 .NET: Review Dictionary usage in APIs
Repository: ignite
Updated Branches:
refs/heads/master 740621afb -> 17d00a4fb
IGNITE-4899 .NET: Review Dictionary usage in APIs
This closes #1738
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/17d00a4f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/17d00a4f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/17d00a4f
Branch: refs/heads/master
Commit: 17d00a4fb09539af91a07b18d1d8660d21a84301
Parents: 740621a
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Apr 6 09:03:52 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Apr 6 09:03:52 2017 +0300
----------------------------------------------------------------------
.../ExpiryCacheHolderTest.cs | 12 ++++-----
.../Cache/CacheAbstractTest.cs | 18 ++++++-------
.../Cache/CacheTestAsyncWrapper.cs | 12 ++++-----
.../Cache/Store/CacheStoreTest.cs | 2 +-
.../Compute/MixedClusterTest.cs | 2 +-
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 16 +++++------
.../Cache/ICacheEntryProcessorResult.cs | 12 ++++++---
.../Impl/Cache/CacheEntryProcessorResult.cs | 27 ++++++++++++++-----
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 28 ++++++++++----------
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 17 +++++++-----
.../Impl/DbCache.cs | 2 +-
.../Datagrid/PutGetExample.cs | 13 ++++-----
12 files changed, 93 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
index 64c9884..9d1a2b5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
@@ -209,12 +209,12 @@ namespace Apache.Ignite.AspNet.Tests
throw new NotImplementedException();
}
- public IDictionary<int, int> GetAll(IEnumerable<int> keys)
+ public ICollection<ICacheEntry<int, int>> GetAll(IEnumerable<int> keys)
{
throw new NotImplementedException();
}
- public Task<IDictionary<int, int>> GetAllAsync(IEnumerable<int> keys)
+ public Task<ICollection<ICacheEntry<int, int>>> GetAllAsync(IEnumerable<int> keys)
{
throw new NotImplementedException();
}
@@ -299,12 +299,12 @@ namespace Apache.Ignite.AspNet.Tests
throw new NotImplementedException();
}
- public void PutAll(IDictionary<int, int> vals)
+ public void PutAll(IEnumerable<KeyValuePair<int, int>> vals)
{
throw new NotImplementedException();
}
- public Task PutAllAsync(IDictionary<int, int> vals)
+ public Task PutAllAsync(IEnumerable<KeyValuePair<int, int>> vals)
{
throw new NotImplementedException();
}
@@ -449,12 +449,12 @@ namespace Apache.Ignite.AspNet.Tests
throw new NotImplementedException();
}
- public IDictionary<int, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
+ public ICollection<ICacheEntryProcessorResult<int, TRes>> InvokeAll<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
{
throw new NotImplementedException();
}
- public Task<IDictionary<int, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
+ public Task<ICollection<ICacheEntryProcessorResult<int, TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
{
throw new NotImplementedException();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index ce0441d..316d0f9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -565,7 +565,7 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.Put(4, 4);
cache.Put(5, 5);
- IDictionary<int, int> map = cache.GetAll(new List<int> { 0, 1, 2, 5 });
+ var map = cache.GetAll(new List<int> {0, 1, 2, 5}).ToDictionary(x => x.Key, x => x.Value);
Assert.AreEqual(3, map.Count);
@@ -582,7 +582,7 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.Put(2, 2);
cache.Put(3, 3);
- var map = cache.GetAll(new List<int> { 0, 1, 2 });
+ var map = cache.GetAll(new List<int> {0, 1, 2}).ToDictionary(x => x.Key, x => x.Value);
Assert.AreEqual(2, map.Count);
@@ -2469,7 +2469,7 @@ namespace Apache.Ignite.Core.Tests.Cache
// Existing entries
var res = cache.InvokeAll(entries.Keys, new T(), arg);
- var results = res.OrderBy(x => x.Key).Select(x => x.Value.Result);
+ var results = res.OrderBy(x => x.Key).Select(x => x.Result);
var expectedResults = entries.OrderBy(x => x.Key).Select(x => x.Value + arg);
Assert.IsTrue(results.SequenceEqual(expectedResults));
@@ -2481,13 +2481,13 @@ namespace Apache.Ignite.Core.Tests.Cache
// Remove entries
res = cache.InvokeAll(entries.Keys, new T {Remove = true}, arg);
- Assert.IsTrue(res.All(x => x.Value.Result == 0));
+ Assert.IsTrue(res.All(x => x.Result == 0));
Assert.AreEqual(0, cache.GetAll(entries.Keys).Count);
// Non-existing entries
res = cache.InvokeAll(entries.Keys, new T {Exists = false}, arg);
- Assert.IsTrue(res.All(x => x.Value.Result == arg));
+ Assert.IsTrue(res.All(x => x.Result == arg));
Assert.IsTrue(cache.GetAll(entries.Keys).All(x => x.Value == arg));
// Test exceptions
@@ -2510,9 +2510,9 @@ namespace Apache.Ignite.Core.Tests.Cache
{
if (procRes.Key == errKey)
// ReSharper disable once AccessToForEachVariableInClosure
- AssertThrowsCacheEntryProcessorException(() => { var x = procRes.Value.Result; }, exceptionText);
+ AssertThrowsCacheEntryProcessorException(() => { var x = procRes.Result; }, exceptionText);
else
- Assert.Greater(procRes.Value.Result, 0);
+ Assert.Greater(procRes.Result, 0);
}
}
@@ -2709,9 +2709,9 @@ namespace Apache.Ignite.Core.Tests.Cache
}
// Check keepBinary for GetAll operation.
- var allObjs1 = binCache.GetAll(keys);
+ var allObjs1 = binCache.GetAll(keys).ToDictionary(x => x.Key, x => x.Value);
- var allObjs2 = binCache.GetAll(keys);
+ var allObjs2 = binCache.GetAll(keys).ToDictionary(x => x.Key, x => x.Value);
for (int i = 0; i < cnt; i++)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 14dfbca..c44a17b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -199,13 +199,13 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
+ public ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys)
{
return GetResult(_cache.GetAllAsync(keys));
}
/** <inheritDoc /> */
- public Task<IDictionary<TK, TV>> GetAllAsync(IEnumerable<TK> keys)
+ public Task<ICollection<ICacheEntry<TK, TV>>> GetAllAsync(IEnumerable<TK> keys)
{
return _cache.GetAllAsync(keys);
}
@@ -307,13 +307,13 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public void PutAll(IDictionary<TK, TV> vals)
+ public void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals)
{
WaitResult(_cache.PutAllAsync(vals));
}
/** <inheritDoc /> */
- public Task PutAllAsync(IDictionary<TK, TV> vals)
+ public Task PutAllAsync(IEnumerable<KeyValuePair<TK, TV>> vals)
{
return _cache.PutAllAsync(vals);
}
@@ -487,14 +487,14 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ public ICollection<ICacheEntryProcessorResult<TK, TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
return GetResult(_cache.InvokeAllAsync(keys, processor, arg));
}
/** <inheritDoc /> */
- public Task<IDictionary<TK, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
+ public Task<ICollection<ICacheEntryProcessorResult<TK, TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
return _cache.InvokeAllAsync(keys, processor, arg);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index 76241d2..f2c3f4d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -327,7 +327,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
for (int i = 0; i < 10; i++)
keys.Add(i);
- IDictionary<int, string> loaded = cache.GetAll(keys);
+ IDictionary<int, string> loaded = cache.GetAll(keys).ToDictionary(x => x.Key, x => x.Value);
Assert.AreEqual(10, loaded.Count);
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
index 41817eb..eb5945d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
@@ -104,7 +104,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
try
{
- Assert.AreEqual(0, res.Value.Result);
+ Assert.AreEqual(0, res.Result);
}
catch (CacheEntryProcessorException ex)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 77e47c7..5a4cdcf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -317,7 +317,7 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="keys">Keys.</param>
/// <returns>Map of key-value pairs.</returns>
- IDictionary<TK, TV> GetAll(IEnumerable<TK> keys);
+ ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys);
/// <summary>
/// Retrieves values mapped to the specified keys from cache.
@@ -328,7 +328,7 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="keys">Keys.</param>
/// <returns>Map of key-value pairs.</returns>
- Task<IDictionary<TK, TV>> GetAllAsync(IEnumerable<TK> keys);
+ Task<ICollection<ICacheEntry<TK, TV>>> GetAllAsync(IEnumerable<TK> keys);
/// <summary>
/// Associates the specified value with the specified key in the cache.
@@ -514,7 +514,7 @@ namespace Apache.Ignite.Core.Cache
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
/// </summary>
/// <param name="vals">Key-value pairs to store in cache.</param>
- void PutAll(IDictionary<TK, TV> vals);
+ void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals);
/// <summary>
/// Stores given key-value pairs in cache.
@@ -522,7 +522,7 @@ namespace Apache.Ignite.Core.Cache
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
/// </summary>
/// <param name="vals">Key-value pairs to store in cache.</param>
- Task PutAllAsync(IDictionary<TK, TV> vals);
+ Task PutAllAsync(IEnumerable<KeyValuePair<TK, TV>> vals);
/// <summary>
/// Attempts to evict all entries associated with keys. Note, that entry will be evicted only
@@ -785,12 +785,12 @@ namespace Apache.Ignite.Core.Cache
/// <param name="processor">The processor.</param>
/// <param name="arg">The argument.</param>
/// <returns>
- /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any,
+ /// Map of <see cref="ICacheEntryProcessorResult{K, R}" /> of the processing per key, if any,
/// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.
/// No mappings will be returned for processors that return a null value for a key.
/// </returns>
/// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
- IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ ICollection<ICacheEntryProcessorResult<TK, TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
/// <summary>
@@ -809,12 +809,12 @@ namespace Apache.Ignite.Core.Cache
/// <param name="processor">The processor.</param>
/// <param name="arg">The argument.</param>
/// <returns>
- /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any,
+ /// Map of <see cref="ICacheEntryProcessorResult{K, R}" /> of the processing per key, if any,
/// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.
/// No mappings will be returned for processors that return a null value for a key.
/// </returns>
/// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
- Task<IDictionary<TK, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys,
+ Task<ICollection<ICacheEntryProcessorResult<TK, TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
index 2d0f709..bf89c04 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
@@ -18,13 +18,19 @@
namespace Apache.Ignite.Core.Cache
{
/// <summary>
- /// Represents a result of processing <see cref="ICacheEntry{K, V}"/>
- /// by <see cref="ICacheEntryProcessor{K, V, A, R}"/>.
+ /// Represents a result of processing <see cref="ICacheEntry{K, V}" />
+ /// by <see cref="ICacheEntryProcessor{K, V, A, R}" />.
/// </summary>
+ /// <typeparam name="TK">Key type.</typeparam>
/// <typeparam name="T">Processor result type.</typeparam>
- public interface ICacheEntryProcessorResult<out T>
+ public interface ICacheEntryProcessorResult<out TK, out T>
{
/// <summary>
+ /// Gets the cache key.
+ /// </summary>
+ TK Key { get; }
+
+ /// <summary>
/// Gets the result of processing an entry.
/// <para />
/// If an exception was thrown during the processing of an entry,
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
index 9a0af4f..51c575d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
@@ -21,11 +21,16 @@ namespace Apache.Ignite.Core.Impl.Cache
using Apache.Ignite.Core.Cache;
/// <summary>
- /// Represents a result of <see cref="ICacheEntryProcessor{TK,TV,TA,TR}"/> invocation.
+ /// Represents a result of <see cref="ICacheEntryProcessor{TK,TV,TA,TR}" /> invocation.
/// </summary>
+ /// <typeparam name="TK">Key type.</typeparam>
/// <typeparam name="T">Result type.</typeparam>
- internal class CacheEntryProcessorResult<T> : ICacheEntryProcessorResult<T>
+ /// <seealso cref="Apache.Ignite.Core.Cache.ICacheEntryProcessorResult{TK, T}" />
+ internal class CacheEntryProcessorResult<TK, T> : ICacheEntryProcessorResult<TK, T>
{
+ // Key
+ private readonly TK _key;
+
// Result
private readonly T _res;
@@ -33,24 +38,34 @@ namespace Apache.Ignite.Core.Impl.Cache
private readonly Exception _err;
/// <summary>
- /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{T}"/> class.
+ /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{TK, T}" /> class.
/// </summary>
+ /// <param name="key">The key.</param>
/// <param name="result">The result.</param>
- public CacheEntryProcessorResult(T result)
+ public CacheEntryProcessorResult(TK key, T result)
{
+ _key = key;
_res = result;
}
/// <summary>
- /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{T}"/> class.
+ /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{TK, T}" /> class.
/// </summary>
+ /// <param name="key">The key.</param>
/// <param name="error">The error.</param>
- public CacheEntryProcessorResult(Exception error)
+ public CacheEntryProcessorResult(TK key, Exception error)
{
+ _key = key;
_err = error;
}
/** <inheritdoc /> */
+ public TK Key
+ {
+ get { return _key; }
+ }
+
+ /** <inheritdoc /> */
public T Result
{
get
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 2523cf7..516f91c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -406,7 +406,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
+ public ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys)
{
IgniteArgumentCheck.NotNull(keys, "keys");
@@ -417,7 +417,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public Task<IDictionary<TK, TV>> GetAllAsync(IEnumerable<TK> keys)
+ public Task<ICollection<ICacheEntry<TK, TV>>> GetAllAsync(IEnumerable<TK> keys)
{
IgniteArgumentCheck.NotNull(keys, "keys");
@@ -618,7 +618,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritdoc /> */
- public void PutAll(IDictionary<TK, TV> vals)
+ public void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals)
{
IgniteArgumentCheck.NotNull(vals, "vals");
@@ -628,7 +628,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public Task PutAllAsync(IDictionary<TK, TV> vals)
+ public Task PutAllAsync(IEnumerable<KeyValuePair<TK, TV>> vals)
{
IgniteArgumentCheck.NotNull(vals, "vals");
@@ -878,7 +878,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritdoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ public ICollection<ICacheEntryProcessorResult<TK, TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
IgniteArgumentCheck.NotNull(keys, "keys");
@@ -899,7 +899,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public Task<IDictionary<TK, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys,
+ public Task<ICollection<ICacheEntryProcessorResult<TK, TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
IgniteArgumentCheck.NotNull(keys, "keys");
@@ -1170,14 +1170,14 @@ namespace Apache.Ignite.Core.Impl.Cache
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="reader">Stream.</param>
/// <returns>Results of InvokeAll operation.</returns>
- private IDictionary<TK, ICacheEntryProcessorResult<T>> ReadInvokeAllResults<T>(BinaryReader reader)
+ private ICollection<ICacheEntryProcessorResult<TK, T>> ReadInvokeAllResults<T>(BinaryReader reader)
{
var count = reader.ReadInt();
if (count == -1)
return null;
- var results = new Dictionary<TK, ICacheEntryProcessorResult<T>>(count);
+ var results = new List<ICacheEntryProcessorResult<TK, T>>(count);
for (var i = 0; i < count; i++)
{
@@ -1185,9 +1185,9 @@ namespace Apache.Ignite.Core.Impl.Cache
var hasError = reader.ReadBoolean();
- results[key] = hasError
- ? new CacheEntryProcessorResult<T>(ReadException(reader))
- : new CacheEntryProcessorResult<T>(reader.ReadObject<T>());
+ results.Add(hasError
+ ? new CacheEntryProcessorResult<TK, T>(key, ReadException(reader))
+ : new CacheEntryProcessorResult<TK, T>(key, reader.ReadObject<T>()));
}
return results;
@@ -1227,7 +1227,7 @@ namespace Apache.Ignite.Core.Impl.Cache
/// </summary>
/// <param name="reader">Reader.</param>
/// <returns>Dictionary.</returns>
- private static IDictionary<TK, TV> ReadGetAllDictionary(BinaryReader reader)
+ private static ICollection<ICacheEntry<TK, TV>> ReadGetAllDictionary(BinaryReader reader)
{
if (reader == null)
return null;
@@ -1238,14 +1238,14 @@ namespace Apache.Ignite.Core.Impl.Cache
{
int size = stream.ReadInt();
- IDictionary<TK, TV> res = new Dictionary<TK, TV>(size);
+ var res = new List<ICacheEntry<TK, TV>>(size);
for (int i = 0; i < size; i++)
{
TK key = reader.ReadObject<TK>();
TV val = reader.ReadObject<TV>();
- res[key] = val;
+ res.Add(new CacheEntry<TK, TV>(key, val));
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index 621bfa5..8dd8eaf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -215,19 +215,22 @@ namespace Apache.Ignite.Core.Impl
/// </summary>
/// <param name="writer">Writer.</param>
/// <param name="vals">Values.</param>
- /// <returns>The same writer.</returns>
- protected static BinaryWriter WriteDictionary<T1, T2>(BinaryWriter writer,
- IDictionary<T1, T2> vals)
+ protected static void WriteDictionary<T1, T2>(BinaryWriter writer, IEnumerable<KeyValuePair<T1, T2>> vals)
{
- writer.WriteInt(vals.Count);
+ var pos = writer.Stream.Position;
+ writer.WriteInt(0); // Reserve count.
+
+ int cnt = 0;
- foreach (KeyValuePair<T1, T2> pair in vals)
+ foreach (var pair in vals)
{
writer.Write(pair.Key);
writer.Write(pair.Value);
+
+ cnt++;
}
- return writer;
+ writer.Stream.WriteInt(pos, cnt);
}
/// <summary>
@@ -237,7 +240,7 @@ namespace Apache.Ignite.Core.Impl
/// <param name="item">Item.</param>
/// <param name="writeItem">Write action to perform on item when it is not null.</param>
/// <returns>The same writer for chaining.</returns>
- protected static BinaryWriter WriteNullable<T>(BinaryWriter writer, T item,
+ private static BinaryWriter WriteNullable<T>(BinaryWriter writer, T item,
Func<BinaryWriter, T, BinaryWriter> writeItem) where T : class
{
if (item == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Impl/DbCache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Impl/DbCache.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Impl/DbCache.cs
index a7ac2c9..d62bdd0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Impl/DbCache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Impl/DbCache.cs
@@ -252,7 +252,7 @@ namespace Apache.Ignite.EntityFramework.Impl
private IDictionary<string, long> GetEntitySetVersions(ICollection<EntitySetBase> sets)
{
// LINQ Select allocates less that a new List<> will do.
- var versions = _metaCache.GetAll(sets.Select(x => x.Name));
+ var versions = _metaCache.GetAll(sets.Select(x => x.Name)).ToDictionary(x => x.Key, x => x.Value);
// Some versions may be missing, fill up with 0.
foreach (var set in sets)
http://git-wip-us.apache.org/repos/asf/ignite/blob/17d00a4f/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
index 10a75fa..d07c58d 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Examples.Datagrid
using System.Collections.Generic;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache;
using Apache.Ignite.ExamplesDll.Binary;
/// <summary>
@@ -159,13 +160,13 @@ namespace Apache.Ignite.Examples.Datagrid
cache.PutAll(map);
// Get recently created organizations as a strongly-typed fully de-serialized instances.
- IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
+ ICollection<ICacheEntry<int, Organization>> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
Console.WriteLine();
Console.WriteLine(">>> Retrieved organization instances from cache:");
- foreach (Organization org in mapFromCache.Values)
- Console.WriteLine(">>> " + org);
+ foreach (ICacheEntry<int, Organization> org in mapFromCache)
+ Console.WriteLine(">>> " + org.Value);
}
/// <summary>
@@ -200,13 +201,13 @@ namespace Apache.Ignite.Examples.Datagrid
var binaryCache = cache.WithKeepBinary<int, IBinaryObject>();
// Get recently created organizations as binary objects.
- IDictionary<int, IBinaryObject> binaryMap = binaryCache.GetAll(new List<int> { 1, 2 });
+ ICollection<ICacheEntry<int, IBinaryObject>> binaryMap = binaryCache.GetAll(new List<int> { 1, 2 });
Console.WriteLine();
Console.WriteLine(">>> Retrieved organization names from binary objects:");
- foreach (IBinaryObject poratbleOrg in binaryMap.Values)
- Console.WriteLine(">>> " + poratbleOrg.GetField<string>("name"));
+ foreach (var pair in binaryMap)
+ Console.WriteLine(">>> " + pair.Value.GetField<string>("name"));
}
}
}