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:50 UTC
[33/53] [abbrv] ignite git commit: IGNITE-3673 .NET: Add examples for
distributed joins.
IGNITE-3673 .NET: Add examples for distributed joins.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b0450edc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b0450edc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b0450edc
Branch: refs/heads/ignite-3299
Commit: b0450edc448cd0a697cb57c0a8b41ae6cfffa1b1
Parents: ef09db5
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Aug 11 17:32:13 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Aug 11 17:32:13 2016 +0300
----------------------------------------------------------------------
.../Datagrid/LinqExample.cs | 195 +++++++++++++------
.../Datagrid/QueryExample.cs | 174 ++++++++++++-----
.../Apache.Ignite.ExamplesDll.csproj | 1 -
.../Binary/Employee.cs | 10 +-
.../Binary/EmployeeKey.cs | 88 ---------
5 files changed, 271 insertions(+), 197 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0450edc/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 848d8f5..86739b4 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
@@ -18,10 +18,10 @@
namespace Apache.Ignite.Examples.Datagrid
{
using System;
- using System.Collections.Generic;
using System.Linq;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Affinity;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.ExamplesDll.Binary;
@@ -49,6 +49,9 @@ namespace Apache.Ignite.Examples.Datagrid
/// <summary>Employee cache name.</summary>
private const string EmployeeCacheName = "dotnet_cache_query_employee";
+ /// <summary>Colocated employee cache name.</summary>
+ private const string EmployeeCacheNameColocated = "dotnet_cache_query_employee_colocated";
+
[STAThread]
public static void Main()
{
@@ -57,26 +60,18 @@ namespace Apache.Ignite.Examples.Datagrid
Console.WriteLine();
Console.WriteLine(">>> Cache LINQ example started.");
- var employeeCache = ignite.GetOrCreateCache<EmployeeKey, Employee>(new CacheConfiguration
- {
- Name = EmployeeCacheName,
- QueryEntities = new[]
- {
- new QueryEntity(typeof(EmployeeKey), typeof(Employee))
- }
- });
-
- var organizationCache = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration
- {
- Name = OrganizationCacheName,
- QueryEntities = new[]
- {
- new QueryEntity(typeof(int), typeof(Organization))
- }
- });
+ var employeeCache = ignite.GetOrCreateCache<int, Employee>(
+ new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
+
+ var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
+ new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
+
+ var organizationCache = ignite.GetOrCreateCache<int, Organization>(
+ new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
// Populate cache with sample data entries.
PopulateCache(employeeCache);
+ PopulateCache(employeeCacheColocated);
PopulateCache(organizationCache);
// Run SQL query example.
@@ -86,7 +81,10 @@ namespace Apache.Ignite.Examples.Datagrid
CompiledQueryExample(employeeCache);
// Run SQL query with join example.
- JoinQueryExample(employeeCache, organizationCache);
+ JoinQueryExample(employeeCacheColocated, organizationCache);
+
+ // Run SQL query with distributed join example.
+ DistributedJoinQueryExample(employeeCache, organizationCache);
// Run SQL fields query example.
FieldsQueryExample(employeeCache);
@@ -103,17 +101,17 @@ namespace Apache.Ignite.Examples.Datagrid
/// Queries employees that have provided ZIP code in address.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void QueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void QueryExample(ICache<int, Employee> cache)
{
const int zip = 94109;
- IQueryable<ICacheEntry<EmployeeKey, Employee>> qry =
+ IQueryable<ICacheEntry<int, Employee>> qry =
cache.AsCacheQueryable().Where(emp => emp.Value.Address.Zip == zip);
Console.WriteLine();
Console.WriteLine(">>> Employees with zipcode " + zip + ":");
- foreach (ICacheEntry<EmployeeKey, Employee> entry in qry)
+ foreach (ICacheEntry<int, Employee> entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
@@ -121,18 +119,18 @@ namespace Apache.Ignite.Examples.Datagrid
/// Queries employees that have provided ZIP code in address with a compiled query.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void CompiledQueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void CompiledQueryExample(ICache<int, Employee> cache)
{
const int zip = 94109;
// Compile cache query to eliminate LINQ overhead on multiple runs.
- Func<int, IQueryCursor<ICacheEntry<EmployeeKey, Employee>>> qry =
+ Func<int, IQueryCursor<ICacheEntry<int, Employee>>> qry =
CompiledQuery.Compile((int z) => cache.AsCacheQueryable().Where(emp => emp.Value.Address.Zip == z));
Console.WriteLine();
Console.WriteLine(">>> Employees with zipcode using compiled query " + zip + ":");
- foreach (ICacheEntry<EmployeeKey, Employee> entry in qry(zip))
+ foreach (ICacheEntry<int, Employee> entry in qry(zip))
Console.WriteLine(">>> " + entry.Value);
}
@@ -141,25 +139,54 @@ namespace Apache.Ignite.Examples.Datagrid
/// </summary>
/// <param name="employeeCache">Employee cache.</param>
/// <param name="organizationCache">Organization cache.</param>
- private static void JoinQueryExample(ICache<EmployeeKey, Employee> employeeCache,
+ private static void JoinQueryExample(ICache<AffinityKey, Employee> employeeCache,
ICache<int, Organization> organizationCache)
{
const string orgName = "Apache";
- IQueryable<ICacheEntry<EmployeeKey, Employee>> employees = employeeCache.AsCacheQueryable();
+ IQueryable<ICacheEntry<AffinityKey, Employee>> employees = employeeCache.AsCacheQueryable();
IQueryable<ICacheEntry<int, Organization>> organizations = organizationCache.AsCacheQueryable();
- IQueryable<ICacheEntry<EmployeeKey, Employee>> qry =
+ IQueryable<ICacheEntry<AffinityKey, Employee>> qry =
+ from employee in employees
+ from organization in organizations
+ where employee.Value.OrganizationId == organization.Key && organization.Value.Name == orgName
+ select employee;
+
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+ foreach (ICacheEntry<AffinityKey, Employee> entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries employees that work for organization with provided name.
+ /// </summary>
+ /// <param name="employeeCache">Employee cache.</param>
+ /// <param name="organizationCache">Organization cache.</param>
+ private static void DistributedJoinQueryExample(ICache<int, Employee> employeeCache,
+ ICache<int, Organization> organizationCache)
+ {
+ const string orgName = "Apache";
+
+ var queryOptions = new QueryOptions {EnableDistributedJoins = true};
+
+ IQueryable<ICacheEntry<int, Employee>> employees = employeeCache.AsCacheQueryable(queryOptions);
+ IQueryable<ICacheEntry<int, Organization>> organizations = organizationCache.AsCacheQueryable(queryOptions);
+
+ IQueryable<ICacheEntry<int, Employee>> qry =
from employee in employees
from organization in organizations
- where employee.Key.OrganizationId == organization.Key && organization.Value.Name == orgName
+ where employee.Value.OrganizationId == organization.Key && organization.Value.Name == orgName
select employee;
Console.WriteLine();
Console.WriteLine(">>> Employees working for " + orgName + ":");
- foreach (ICacheEntry<EmployeeKey, Employee> entry in qry)
+ foreach (ICacheEntry<int, Employee> entry in qry)
Console.WriteLine(">>> " + entry.Value);
}
@@ -167,7 +194,7 @@ namespace Apache.Ignite.Examples.Datagrid
/// Queries names and salaries for all employees.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void FieldsQueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void FieldsQueryExample(ICache<int, Employee> cache)
{
var qry = cache.AsCacheQueryable().Select(entry => new {entry.Value.Name, entry.Value.Salary});
@@ -188,71 +215,125 @@ namespace Apache.Ignite.Examples.Datagrid
"Apache",
new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
OrganizationType.Private,
- DateTime.Now
- ));
+ DateTime.Now));
cache.Put(2, new Organization(
"Microsoft",
new Address("1096 Eddy Street, San Francisco, CA", 94109),
OrganizationType.Private,
- DateTime.Now
- ));
+ DateTime.Now));
+ }
+
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<AffinityKey, Employee> cache)
+ {
+ cache.Put(new AffinityKey(1, 1), new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new[] {"Human Resources", "Customer Service"},
+ 1));
+
+ cache.Put(new AffinityKey(2, 1), new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78130),
+ new[] {"Development", "QA"},
+ 1));
+
+ cache.Put(new AffinityKey(3, 1), new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new[] {"Logistics"},
+ 1));
+
+ cache.Put(new AffinityKey(4, 2), new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new[] {"Development"},
+ 2));
+
+ cache.Put(new AffinityKey(5, 2), new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new[] {"Sales"},
+ 2));
+
+ cache.Put(new AffinityKey(6, 2), new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new[] {"Sales"},
+ 2));
+
+ cache.Put(new AffinityKey(7, 2), new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ new[] {"Development", "QA"},
+ 2));
}
/// <summary>
/// Populate cache with data for this example.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void PopulateCache(ICache<EmployeeKey, Employee> cache)
+ private static void PopulateCache(ICache<int, Employee> cache)
{
- cache.Put(new EmployeeKey(1, 1), new Employee(
+ cache.Put(1, new Employee(
"James Wilson",
12500,
new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> { "Human Resources", "Customer Service" }
- ));
+ new[] {"Human Resources", "Customer Service"},
+ 1));
- cache.Put(new EmployeeKey(2, 1), new Employee(
+ cache.Put(2, new Employee(
"Daniel Adams",
11000,
new Address("184 Fidler Drive, San Antonio, TX", 78130),
- new List<string> { "Development", "QA" }
- ));
+ new[] {"Development", "QA"},
+ 1));
- cache.Put(new EmployeeKey(3, 1), new Employee(
+ cache.Put(3, new Employee(
"Cristian Moss",
12500,
new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- new List<string> { "Logistics" }
- ));
+ new[] {"Logistics"},
+ 1));
- cache.Put(new EmployeeKey(4, 2), new Employee(
+ cache.Put(4, new Employee(
"Allison Mathis",
25300,
new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new List<string> { "Development" }
- ));
+ new[] {"Development"},
+ 2));
- cache.Put(new EmployeeKey(5, 2), new Employee(
+ cache.Put(5, new Employee(
"Breana Robbin",
6500,
new Address("3960 Sundown Lane, Austin, TX", 78130),
- new List<string> { "Sales" }
- ));
+ new[] {"Sales"},
+ 2));
- cache.Put(new EmployeeKey(6, 2), new Employee(
+ cache.Put(6, new Employee(
"Philip Horsley",
19800,
new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- new List<string> { "Sales" }
- ));
+ new[] {"Sales"},
+ 2));
- cache.Put(new EmployeeKey(7, 2), new Employee(
+ cache.Put(7, new Employee(
"Brian Peters",
10600,
new Address("1407 Pearlman Avenue, Boston, MA", 12110),
- new List<string> { "Development", "QA" }
- ));
+ new[] {"Development", "QA"},
+ 2));
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0450edc/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 8b5e6f3..1c35149 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Examples.Datagrid
using System.Collections.Generic;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Affinity;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.ExamplesDll.Binary;
@@ -49,6 +50,9 @@ namespace Apache.Ignite.Examples.Datagrid
/// <summary>Employee cache name.</summary>
private const string EmployeeCacheName = "dotnet_cache_query_employee";
+ /// <summary>Employee cache name.</summary>
+ private const string EmployeeCacheNameColocated = "dotnet_cache_query_employee_colocated";
+
[STAThread]
public static void Main()
{
@@ -57,33 +61,28 @@ namespace Apache.Ignite.Examples.Datagrid
Console.WriteLine();
Console.WriteLine(">>> Cache query example started.");
- var employeeCache = ignite.GetOrCreateCache<EmployeeKey, Employee>(new CacheConfiguration
- {
- Name = EmployeeCacheName,
- QueryEntities = new[]
- {
- new QueryEntity(typeof(EmployeeKey), typeof(Employee))
- }
- });
-
- var organizationCache = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration
- {
- Name = OrganizationCacheName,
- QueryEntities = new[]
- {
- new QueryEntity(typeof(int), typeof(Organization))
- }
- });
+ var employeeCache = ignite.GetOrCreateCache<int, Employee>(
+ new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
+
+ var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
+ new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
+
+ var organizationCache = ignite.GetOrCreateCache<int, Organization>(
+ new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
// Populate cache with sample data entries.
PopulateCache(employeeCache);
+ PopulateCache(employeeCacheColocated);
PopulateCache(organizationCache);
// Run SQL query example.
SqlQueryExample(employeeCache);
// Run SQL query with join example.
- SqlJoinQueryExample(employeeCache);
+ SqlJoinQueryExample(employeeCacheColocated);
+
+ // Run SQL query with distributed join example.
+ SqlDistributedJoinQueryExample(employeeCache);
// Run SQL fields query example.
SqlFieldsQueryExample(employeeCache);
@@ -103,7 +102,7 @@ namespace Apache.Ignite.Examples.Datagrid
/// Queries employees that have provided ZIP code in address.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void SqlQueryExample(ICache<int, Employee> cache)
{
const int zip = 94109;
@@ -120,7 +119,7 @@ namespace Apache.Ignite.Examples.Datagrid
/// Queries employees that work for organization with provided name.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void SqlJoinQueryExample(ICache<AffinityKey, Employee> cache)
{
const string orgName = "Apache";
@@ -136,10 +135,32 @@ namespace Apache.Ignite.Examples.Datagrid
}
/// <summary>
+ /// Queries employees that work for organization with provided name.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlDistributedJoinQueryExample(ICache<int, Employee> cache)
+ {
+ const string orgName = "Apache";
+
+ var qry = cache.Query(new SqlQuery("Employee",
+ "from Employee, \"dotnet_cache_query_organization\".Organization " +
+ "where Employee.organizationId = Organization._key and Organization.name = ?", orgName)
+ {
+ EnableDistributedJoins = true
+ });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
/// Queries names and salaries for all employees.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void SqlFieldsQueryExample(ICache<int, Employee> cache)
{
var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
@@ -154,7 +175,7 @@ namespace Apache.Ignite.Examples.Datagrid
/// Queries employees that live in Texas using full-text query API.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
+ private static void FullTextQueryExample(ICache<int, Employee> cache)
{
var qry = cache.Query(new TextQuery("Employee", "TX"));
@@ -175,71 +196,124 @@ namespace Apache.Ignite.Examples.Datagrid
"Apache",
new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
OrganizationType.Private,
- DateTime.Now
- ));
+ DateTime.Now));
- cache.Put(2, new Organization(
- "Microsoft",
+ cache.Put(2, new Organization("Microsoft",
new Address("1096 Eddy Street, San Francisco, CA", 94109),
OrganizationType.Private,
- DateTime.Now
- ));
+ DateTime.Now));
+ }
+
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<AffinityKey, Employee> cache)
+ {
+ cache.Put(new AffinityKey(1, 1), new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new[] {"Human Resources", "Customer Service"},
+ 1));
+
+ cache.Put(new AffinityKey(2, 1), new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78130),
+ new[] {"Development", "QA"},
+ 1));
+
+ cache.Put(new AffinityKey(3, 1), new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new[] {"Logistics"},
+ 1));
+
+ cache.Put(new AffinityKey(4, 2), new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new[] {"Development"},
+ 2));
+
+ cache.Put(new AffinityKey(5, 2), new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new[] {"Sales"},
+ 2));
+
+ cache.Put(new AffinityKey(6, 2), new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new[] {"Sales"},
+ 2));
+
+ cache.Put(new AffinityKey(7, 2), new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ new[] {"Development", "QA"},
+ 2));
}
/// <summary>
/// Populate cache with data for this example.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void PopulateCache(ICache<EmployeeKey, Employee> cache)
+ private static void PopulateCache(ICache<int, Employee> cache)
{
- cache.Put(new EmployeeKey(1, 1), new Employee(
+ cache.Put(1, new Employee(
"James Wilson",
12500,
new Address("1096 Eddy Street, San Francisco, CA", 94109),
- new List<string> { "Human Resources", "Customer Service" }
- ));
+ new[] {"Human Resources", "Customer Service"},
+ 1));
- cache.Put(new EmployeeKey(2, 1), new Employee(
+ cache.Put(2, new Employee(
"Daniel Adams",
11000,
new Address("184 Fidler Drive, San Antonio, TX", 78130),
- new List<string> { "Development", "QA" }
- ));
+ new[] {"Development", "QA"},
+ 1));
- cache.Put(new EmployeeKey(3, 1), new Employee(
+ cache.Put(3, new Employee(
"Cristian Moss",
12500,
new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- new List<string> { "Logistics" }
- ));
+ new[] {"Logistics"},
+ 1));
- cache.Put(new EmployeeKey(4, 2), new Employee(
+ cache.Put(4, new Employee(
"Allison Mathis",
25300,
new Address("2702 Freedom Lane, San Francisco, CA", 94109),
- new List<string> { "Development" }
- ));
+ new[] {"Development"},
+ 2));
- cache.Put(new EmployeeKey(5, 2), new Employee(
+ cache.Put(5, new Employee(
"Breana Robbin",
6500,
new Address("3960 Sundown Lane, Austin, TX", 78130),
- new List<string> { "Sales" }
- ));
+ new[] {"Sales"},
+ 2));
- cache.Put(new EmployeeKey(6, 2), new Employee(
+ cache.Put(6, new Employee(
"Philip Horsley",
19800,
new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- new List<string> { "Sales" }
- ));
+ new[] {"Sales"},
+ 2));
- cache.Put(new EmployeeKey(7, 2), new Employee(
+ cache.Put(7, new Employee(
"Brian Peters",
10600,
new Address("1407 Pearlman Avenue, Boston, MA", 12110),
- new List<string> { "Development", "QA" }
- ));
+ new[] {"Development", "QA"},
+ 2));
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0450edc/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
index 16d0be3..41981d8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -57,7 +57,6 @@
<Compile Include="Binary\Account.cs" />
<Compile Include="Binary\Address.cs" />
<Compile Include="Binary\Employee.cs" />
- <Compile Include="Binary\EmployeeKey.cs" />
<Compile Include="Binary\Organization.cs" />
<Compile Include="Binary\OrganizationType.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0450edc/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
index 0fc3230..4cff2a8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
@@ -35,12 +35,14 @@ namespace Apache.Ignite.ExamplesDll.Binary
/// <param name="salary">Salary.</param>
/// <param name="address">Address.</param>
/// <param name="departments">Departments.</param>
- public Employee(string name, long salary, Address address, ICollection<string> departments)
+ public Employee(string name, long salary, Address address, ICollection<string> departments,
+ int organizationId = 0)
{
Name = name;
Salary = salary;
Address = address;
Departments = departments;
+ OrganizationId = organizationId;
}
/// <summary>
@@ -50,6 +52,12 @@ namespace Apache.Ignite.ExamplesDll.Binary
public string Name { get; set; }
/// <summary>
+ /// Organization id.
+ /// </summary>
+ [QuerySqlField(IsIndexed = true)]
+ public int OrganizationId { get; set; }
+
+ /// <summary>
/// Salary.
/// </summary>
[QuerySqlField]
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0450edc/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs
deleted file mode 100644
index e699648..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.ExamplesDll.Binary
-{
- using Apache.Ignite.Core.Cache.Affinity;
- using Apache.Ignite.Core.Cache.Configuration;
-
- /// <summary>
- /// Employee key. Used in query example to co-locate employees with their organizations.
- /// </summary>
- public class EmployeeKey
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="id">ID.</param>
- /// <param name="orgId">Organization ID.</param>
- public EmployeeKey(int id, int orgId)
- {
- Id = id;
- OrganizationId = orgId;
- }
-
- /// <summary>
- /// ID.
- /// </summary>
- public int Id { get; private set; }
-
- /// <summary>
- /// Organization ID.
- /// </summary>
- [AffinityKeyMapped]
- [QuerySqlField(IsIndexed = true)]
- public int OrganizationId { get; private set; }
-
- /// <summary>
- /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
- /// </summary>
- /// <returns>
- /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
- /// </returns>
- /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
- public override bool Equals(object obj)
- {
- EmployeeKey other = obj as EmployeeKey;
-
- return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
- }
-
- /// <summary>
- /// Serves as a hash function for a particular type.
- /// </summary>
- /// <returns>
- /// A hash code for the current <see cref="T:System.Object"/>.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- public override int GetHashCode()
- {
- return 31 * Id + OrganizationId;
- }
-
- /// <summary>
- /// Returns a string that represents the current object.
- /// </summary>
- /// <returns>
- /// A string that represents the current object.
- /// </returns>
- public override string ToString()
- {
- return string.Format("{0} [id={1}, organizationId={2}]", typeof(EmployeeKey).Name, Id, OrganizationId);
- }
- }
-}