You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/08/19 11:48:49 UTC
[32/53] [abbrv] ignite git commit: IGNITE-3675 .NET: Use separate
caches for different entities in QueryExample.
IGNITE-3675 .NET: Use separate caches for different entities in QueryExample.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ef09db5f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ef09db5f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ef09db5f
Branch: refs/heads/ignite-3299
Commit: ef09db5fef2057177046518934e256ae14fbf975
Parents: f4f364d
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Aug 11 16:18:14 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Aug 11 16:18:14 2016 +0300
----------------------------------------------------------------------
.../Datagrid/LinqExample.cs | 38 ++++++++++++-------
.../Datagrid/QueryExample.cs | 39 +++++++++++++-------
2 files changed, 51 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ef09db5f/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
index 2223600..848d8f5 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
@@ -43,8 +43,11 @@ namespace Apache.Ignite.Examples.Datagrid
/// </summary>
public class LinqExample
{
- /// <summary>Cache name.</summary>
- private const string CacheName = "dotnet_cache_query";
+ /// <summary>Organization cache name.</summary>
+ private const string OrganizationCacheName = "dotnet_cache_query_organization";
+
+ /// <summary>Employee cache name.</summary>
+ private const string EmployeeCacheName = "dotnet_cache_query_employee";
[STAThread]
public static void Main()
@@ -54,25 +57,27 @@ namespace Apache.Ignite.Examples.Datagrid
Console.WriteLine();
Console.WriteLine(">>> Cache LINQ example started.");
- var cache = ignite.GetOrCreateCache<object, object>(new CacheConfiguration
+ var employeeCache = ignite.GetOrCreateCache<EmployeeKey, Employee>(new CacheConfiguration
{
- Name = CacheName,
+ Name = EmployeeCacheName,
QueryEntities = new[]
{
- new QueryEntity(typeof(int), typeof(Organization)),
new QueryEntity(typeof(EmployeeKey), typeof(Employee))
}
});
- // Clean up caches on all nodes before run.
- cache.Clear();
+ var organizationCache = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration
+ {
+ Name = OrganizationCacheName,
+ QueryEntities = new[]
+ {
+ new QueryEntity(typeof(int), typeof(Organization))
+ }
+ });
// Populate cache with sample data entries.
- PopulateCache(cache);
-
- // Create cache that will work with specific types.
- var employeeCache = ignite.GetCache<EmployeeKey, Employee>(CacheName);
- var organizationCache = ignite.GetCache<int, Organization>(CacheName);
+ PopulateCache(employeeCache);
+ PopulateCache(organizationCache);
// Run SQL query example.
QueryExample(employeeCache);
@@ -177,7 +182,7 @@ namespace Apache.Ignite.Examples.Datagrid
/// Populate cache with data for this example.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void PopulateCache(ICache<object, object> cache)
+ private static void PopulateCache(ICache<int, Organization> cache)
{
cache.Put(1, new Organization(
"Apache",
@@ -192,7 +197,14 @@ namespace Apache.Ignite.Examples.Datagrid
OrganizationType.Private,
DateTime.Now
));
+ }
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<EmployeeKey, Employee> cache)
+ {
cache.Put(new EmployeeKey(1, 1), new Employee(
"James Wilson",
12500,
http://git-wip-us.apache.org/repos/asf/ignite/blob/ef09db5f/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
index ccd6fd9..8b5e6f3 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -43,8 +43,11 @@ namespace Apache.Ignite.Examples.Datagrid
/// </summary>
public class QueryExample
{
- /// <summary>Cache name.</summary>
- private const string CacheName = "dotnet_cache_query";
+ /// <summary>Organization cache name.</summary>
+ private const string OrganizationCacheName = "dotnet_cache_query_organization";
+
+ /// <summary>Employee cache name.</summary>
+ private const string EmployeeCacheName = "dotnet_cache_query_employee";
[STAThread]
public static void Main()
@@ -54,24 +57,27 @@ namespace Apache.Ignite.Examples.Datagrid
Console.WriteLine();
Console.WriteLine(">>> Cache query example started.");
- var cache = ignite.GetOrCreateCache<object, object>(new CacheConfiguration
+ var employeeCache = ignite.GetOrCreateCache<EmployeeKey, Employee>(new CacheConfiguration
{
- Name = CacheName,
+ Name = EmployeeCacheName,
QueryEntities = new[]
{
- new QueryEntity(typeof(int), typeof(Organization)),
new QueryEntity(typeof(EmployeeKey), typeof(Employee))
}
});
- // Clean up caches on all nodes before run.
- cache.Clear();
+ var organizationCache = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration
+ {
+ Name = OrganizationCacheName,
+ QueryEntities = new[]
+ {
+ new QueryEntity(typeof(int), typeof(Organization))
+ }
+ });
// Populate cache with sample data entries.
- PopulateCache(cache);
-
- // Create cache that will work with specific types.
- var employeeCache = ignite.GetCache<EmployeeKey, Employee>(CacheName);
+ PopulateCache(employeeCache);
+ PopulateCache(organizationCache);
// Run SQL query example.
SqlQueryExample(employeeCache);
@@ -119,7 +125,7 @@ namespace Apache.Ignite.Examples.Datagrid
const string orgName = "Apache";
var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, Organization " +
+ "from Employee, \"dotnet_cache_query_organization\".Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
Console.WriteLine();
@@ -163,7 +169,7 @@ namespace Apache.Ignite.Examples.Datagrid
/// Populate cache with data for this example.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void PopulateCache(ICache<object, object> cache)
+ private static void PopulateCache(ICache<int, Organization> cache)
{
cache.Put(1, new Organization(
"Apache",
@@ -178,7 +184,14 @@ namespace Apache.Ignite.Examples.Datagrid
OrganizationType.Private,
DateTime.Now
));
+ }
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<EmployeeKey, Employee> cache)
+ {
cache.Put(new EmployeeKey(1, 1), new Employee(
"James Wilson",
12500,