ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject [17/33] ignite git commit: IGNITE-3675 .NET: Use separate caches for different entities in QueryExample.
Date Mon, 14 Nov 2016 09:26:29 GMT
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/390c8d59
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/390c8d59
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/390c8d59

Branch: refs/heads/master
Commit: 390c8d59cf8d44d9703e5fbf8d9c0f8028a4a172
Parents: d7dee52
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Aug 11 16:18:14 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Wed Nov 2 11:16:33 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/390c8d59/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/390c8d59/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,


Mime
View raw message