Beispiel #1
0
 /** <inheritdoc /> */
 public IBinaryObject PersonMethodBinary(IBinaryObject person)
 {
     return(person
            .ToBuilder()
            .SetField("Id", person.GetField <int>("Id") + 1)
            .Build());
 }
Beispiel #2
0
        private static void ComplexObjects()
        {
            var cfg = new IgniteConfiguration
            {
                // Register custom class for Ignite serialization
                BinaryConfiguration = new BinaryConfiguration(typeof(Person))
            };
            IIgnite ignite = Ignition.Start(cfg);

            ICache <int, Person> cache = ignite.GetOrCreateCache <int, Person>("persons");

            cache[1] = new Person {
                Name = "John Doe", Age = 27
            };

            foreach (ICacheEntry <int, Person> cacheEntry in cache)
            {
                Console.WriteLine(cacheEntry);
            }

            var           binCache  = cache.WithKeepBinary <int, IBinaryObject>();
            IBinaryObject binPerson = binCache[1];

            Console.WriteLine(binPerson.GetField <string>("Name"));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var cfg = new IgniteConfiguration
            {
                // Register custom class for ignite serialization
                BinaryConfiguration = new BinaryConfiguration(typeof(Person))
            };

            IIgnite ignite = Ignition.Start(cfg);

            ICache <int, Person> cache = ignite.GetOrCreateCache <int, Person>("person");

            cache[1] = new Person {
                name = "Razi Ahmad", age = 27
            };
            cache[2] = new Person {
                name = "Harsh Babu", age = 22
            };
            cache[3] = new Person {
                name = "Razi Ahmad", age = 27
            };
            cache[2] = new Person {
                name = "Harsh Babu", age = 22
            };
            foreach (ICacheEntry <int, Person> cacheEntry in cache)
            {
                Console.WriteLine(cacheEntry);
            }

            var           binCache   = cache.WithKeepBinary <int, IBinaryObject>();
            IBinaryObject binPerson1 = binCache[1];

            Console.WriteLine(binPerson1.GetField <string>("name") + " : " + binPerson1.GetField <int>("age"));

            IBinaryObject binPerson2 = binCache[2];

            Console.WriteLine(binPerson2.GetField <string>("name") + " : " + binPerson2.GetField <int>("age"));

            IBinaryObject binPerson3 = binCache[3];

            Console.WriteLine(binPerson3.GetField <string>("name") + " : " + binPerson3.GetField <int>("age"));


            Console.ReadKey();
        }
Beispiel #4
0
        /// <summary>
        /// Reads binary object fields and modifies them.
        /// </summary>
        /// <param name="cache">Cache.</param>
        private static void ReadModifyExample(ICache <int, IBinaryObject> cache)
        {
            const int id = 1;

            IBinaryObject person = cache[id];

            string name = person.GetField <string>(NameField);

            Console.WriteLine();
            Console.WriteLine($">>> Name of the person with id {id}: {name}");

            // Modify the binary object.
            cache[id] = person.ToBuilder().SetField("Name", $"{name} Jr.").Build();

            Console.WriteLine($">>> Modified person with id {id}: {cache[1]}");
        }
Beispiel #5
0
        /// <summary>
        /// Reads binary object fields and modifies them.
        /// </summary>
        /// <param name="cache">Cache.</param>
        private static void ReadModifyExample(ICacheClient <int, IBinaryObject> cache)
        {
            const int id = 1;

            IBinaryObject person = cache[id];

            string name = person.GetField <string>(NameField);

            Console.WriteLine();
            Console.WriteLine(">>> Name of the person with id {0}: {1}", id, name);

            // Modify the binary object.
            cache[id] = person.ToBuilder().SetField("Name", name + " Jr.").Build();

            Console.WriteLine(">>> Modified person with id {0}: {1}", id, cache[1]);
        }
        public void TestEchoTaskBinarizableNoClass()
        {
            ICompute compute = _grid1.GetCompute();

            compute.WithKeepBinary();

            IBinaryObject res = compute.ExecuteJavaTask <IBinaryObject>(EchoTask, EchoTypeBinarizableJava);

            Assert.AreEqual(1, res.GetField <int>("field"));

            // This call must fail because "keepBinary" flag is reset.
            var ex = Assert.Throws <BinaryObjectException>(() =>
            {
                compute.ExecuteJavaTask <IBinaryObject>(EchoTask, EchoTypeBinarizableJava);
            });

            Assert.AreEqual("Unknown pair [platformId=1, typeId=2009791293]", ex.Message);
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            IIgnite ignite = Ignition.Start();

            ICache <int, Person> cache = ignite.GetOrCreateCache <int, Person>("persons");

            cache[1] = new Person {
                name = "Razi"
            };

            ICache <int, IBinaryObject> binaryCache = cache.WithKeepBinary <int, IBinaryObject>();
            IBinaryObject binaryPerson = binaryCache[1];

            string name = binaryPerson.GetField <string>("name");

            Console.WriteLine(name);
            Console.ReadKey();
        }
        public void TestPutLoadBinarizable()
        {
            var cache = GetBinaryStoreCache <int, Value>();

            cache.Put(1, new Value(1));

            IDictionary map = StoreMap();

            Assert.AreEqual(1, map.Count);

            IBinaryObject v = (IBinaryObject)map[1];

            Assert.AreEqual(1, v.GetField <int>("_idx"));

            cache.LocalEvict(new[] { 1 });

            Assert.AreEqual(0, cache.GetSize());

            Assert.AreEqual(1, cache.Get(1).Index());

            Assert.AreEqual(1, cache.GetSize());
        }
        /// <summary>
        /// Checks the string date guid enum values.
        /// </summary>
        private void CheckStringDateGuidEnum1(IBinaryObject binObj, DateTime? nDate, Guid? nGuid)
        {
            Assert.AreEqual(100, binObj.GetHashCode());

            IBinaryType meta = binObj.GetBinaryType();

            Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);

            Assert.AreEqual(10, meta.Fields.Count);

            Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
            Assert.AreEqual(BinaryTypeNames.TypeNameTimestamp, meta.GetFieldTypeName("fNTimestamp"));
            Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
            Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayTimestamp, meta.GetFieldTypeName("fTimestampArr"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));

            Assert.AreEqual("str", binObj.GetField<string>("fStr"));
            Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
            Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNTimestamp"));
            Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
            Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
            Assert.AreEqual(new[] {"str"}, binObj.GetField<string[]>("fStrArr"));
            Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fDateArr"));
            Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fTimestampArr"));
            Assert.AreEqual(new[] {nGuid}, binObj.GetField<Guid?[]>("fGuidArr"));
            Assert.AreEqual(new[] {TestEnum.One}, binObj.GetField<TestEnum[]>("fEnumArr"));

            StringDateGuidEnum obj = binObj.Deserialize<StringDateGuidEnum>();

            Assert.AreEqual("str", obj.FStr);
            Assert.AreEqual(nDate, obj.FnDate);
            Assert.AreEqual(nDate, obj.FnTimestamp);
            Assert.AreEqual(nGuid, obj.FnGuid);
            Assert.AreEqual(TestEnum.One, obj.FEnum);
            Assert.AreEqual(new[] {"str"}, obj.FStrArr);
            Assert.AreEqual(new[] {nDate}, obj.FDateArr);
            Assert.AreEqual(new[] {nGuid}, obj.FGuidArr);
            Assert.AreEqual(new[] {TestEnum.One}, obj.FEnumArr);

            // Check builder field caching.
            var builder = _grid.GetBinary().GetBuilder(binObj);

            Assert.AreEqual("str", builder.GetField<string>("fStr"));
            Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
            Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNTimestamp"));
            Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
            Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
            Assert.AreEqual(new[] {"str"}, builder.GetField<string[]>("fStrArr"));
            Assert.AreEqual(new[] {nDate}, builder.GetField<DateTime?[]>("fDateArr"));
            Assert.AreEqual(new[] {nDate}, builder.GetField<DateTime?[]>("fTimestampArr"));
            Assert.AreEqual(new[] {nGuid}, builder.GetField<Guid?[]>("fGuidArr"));
            Assert.AreEqual(new[] {TestEnum.One}, builder.GetField<TestEnum[]>("fEnumArr"));

            // Check reassemble.
            binObj = builder.Build();

            Assert.AreEqual("str", binObj.GetField<string>("fStr"));
            Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
            Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNTimestamp"));
            Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
            Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
            Assert.AreEqual(new[] {"str"}, binObj.GetField<string[]>("fStrArr"));
            Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fDateArr"));
            Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fTimestampArr"));
            Assert.AreEqual(new[] {nGuid}, binObj.GetField<Guid?[]>("fGuidArr"));
            Assert.AreEqual(new[] {TestEnum.One}, binObj.GetField<TestEnum[]>("fEnumArr"));

            obj = binObj.Deserialize<StringDateGuidEnum>();

            Assert.AreEqual("str", obj.FStr);
            Assert.AreEqual(nDate, obj.FnDate);
            Assert.AreEqual(nDate, obj.FnTimestamp);
            Assert.AreEqual(nGuid, obj.FnGuid);
            Assert.AreEqual(TestEnum.One, obj.FEnum);
            Assert.AreEqual(new[] {"str"}, obj.FStrArr);
            Assert.AreEqual(new[] {nDate}, obj.FDateArr);
            Assert.AreEqual(new[] {nGuid}, obj.FGuidArr);
            Assert.AreEqual(new[] {TestEnum.One}, obj.FEnumArr);
        }
Beispiel #10
0
        /// <summary>
        /// Checks the primitive array fields.
        /// </summary>
        private static void CheckPrimitiveArrayFields2(IBinaryObject binObj)
        {
            Assert.AreEqual(200, binObj.GetHashCode());

            Assert.AreEqual(new byte[] { 7 }, binObj.GetField<byte[]>("fByte"));
            Assert.AreEqual(new[] { false }, binObj.GetField<bool[]>("fBool"));
            Assert.AreEqual(new short[] { 8 }, binObj.GetField<short[]>("fShort"));
            Assert.AreEqual(new[] { 'b' }, binObj.GetField<char[]>("fChar"));
            Assert.AreEqual(new[] { 9 }, binObj.GetField<int[]>("fInt"));
            Assert.AreEqual(new long[] { 10 }, binObj.GetField<long[]>("fLong"));
            Assert.AreEqual(new float[] { 11 }, binObj.GetField<float[]>("fFloat"));
            Assert.AreEqual(new double[] { 12 }, binObj.GetField<double[]>("fDouble"));
            Assert.AreEqual(new decimal?[] { 13.13m }, binObj.GetField<decimal?[]>("fDecimal"));

            var obj = binObj.Deserialize<PrimitiveArrays>();

            Assert.AreEqual(new byte[] { 7 }, obj.FByte);
            Assert.AreEqual(new[] { false }, obj.FBool);
            Assert.AreEqual(new short[] { 8 }, obj.FShort);
            Assert.AreEqual(new[] { 'b' }, obj.FChar);
            Assert.AreEqual(new[] { 9 }, obj.FInt);
            Assert.AreEqual(new long[] { 10 }, obj.FLong);
            Assert.AreEqual(new float[] { 11 }, obj.FFloat);
            Assert.AreEqual(new double[] { 12 }, obj.FDouble);
            Assert.AreEqual(new decimal?[] { 13.13m }, obj.FDecimal);
        }
Beispiel #11
0
        /// <summary>
        /// Checks the primitive array fields.
        /// </summary>
        private static void CheckPrimitiveArrayFields1(IBinaryObject binObj)
        {
            Assert.AreEqual(100, binObj.GetHashCode());

            IBinaryType meta = binObj.GetBinaryType();

            Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);

            Assert.AreEqual(9, meta.Fields.Count);

            Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
            Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("fDecimal"));

            Assert.AreEqual(new byte[] { 1 }, binObj.GetField<byte[]>("fByte"));
            Assert.AreEqual(new[] { true }, binObj.GetField<bool[]>("fBool"));
            Assert.AreEqual(new short[] { 2 }, binObj.GetField<short[]>("fShort"));
            Assert.AreEqual(new[] { 'a' }, binObj.GetField<char[]>("fChar"));
            Assert.AreEqual(new[] { 3 }, binObj.GetField<int[]>("fInt"));
            Assert.AreEqual(new long[] { 4 }, binObj.GetField<long[]>("fLong"));
            Assert.AreEqual(new float[] { 5 }, binObj.GetField<float[]>("fFloat"));
            Assert.AreEqual(new double[] { 6 }, binObj.GetField<double[]>("fDouble"));
            Assert.AreEqual(new decimal?[] { 7.7m }, binObj.GetField<decimal?[]>("fDecimal"));

            PrimitiveArrays obj = binObj.Deserialize<PrimitiveArrays>();

            Assert.AreEqual(new byte[] { 1 }, obj.FByte);
            Assert.AreEqual(new[] { true }, obj.FBool);
            Assert.AreEqual(new short[] { 2 }, obj.FShort);
            Assert.AreEqual(new[] { 'a' }, obj.FChar);
            Assert.AreEqual(new[] { 3 }, obj.FInt);
            Assert.AreEqual(new long[] { 4 }, obj.FLong);
            Assert.AreEqual(new float[] { 5 }, obj.FFloat);
            Assert.AreEqual(new double[] { 6 }, obj.FDouble);
            Assert.AreEqual(new decimal?[] { 7.7m }, obj.FDecimal);
        }
Beispiel #12
0
        /// <summary>
        /// Checks the primitive fields values.
        /// </summary>
        private static void CheckPrimitiveFields2(IBinaryObject binObj)
        {
            Assert.AreEqual(200, binObj.GetHashCode());

            Assert.AreEqual(7, binObj.GetField<byte>("fByte"));
            Assert.AreEqual(false, binObj.GetField<bool>("fBool"));
            Assert.AreEqual(8, binObj.GetField<short>("fShort"));
            Assert.AreEqual('b', binObj.GetField<char>("fChar"));
            Assert.AreEqual(9, binObj.GetField<int>("fInt"));
            Assert.AreEqual(10, binObj.GetField<long>("fLong"));
            Assert.AreEqual(11, binObj.GetField<float>("fFloat"));
            Assert.AreEqual(12, binObj.GetField<double>("fDouble"));
            Assert.AreEqual(13.13m, binObj.GetField<decimal>("fDecimal"));

            var obj = binObj.Deserialize<Primitives>();

            Assert.AreEqual(7, obj.FByte);
            Assert.AreEqual(false, obj.FBool);
            Assert.AreEqual(8, obj.FShort);
            Assert.AreEqual('b', obj.FChar);
            Assert.AreEqual(9, obj.FInt);
            Assert.AreEqual(10, obj.FLong);
            Assert.AreEqual(11, obj.FFloat);
            Assert.AreEqual(12, obj.FDouble);
            Assert.AreEqual(13.13m, obj.FDecimal);
        }
Beispiel #13
0
        /// <summary>
        /// Checks the primitive fields values.
        /// </summary>
        private static void CheckPrimitiveFields1(IBinaryObject binObj)
        {
            Assert.AreEqual(100, binObj.GetHashCode());

            IBinaryType meta = binObj.GetBinaryType();

            Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);

            Assert.AreEqual(9, meta.Fields.Count);

            Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
            Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
            Assert.AreEqual(BinaryTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
            Assert.AreEqual(BinaryTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
            Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
            Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
            Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
            Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
            Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("fDecimal"));

            Assert.AreEqual(1, binObj.GetField<byte>("fByte"));
            Assert.AreEqual(true, binObj.GetField<bool>("fBool"));
            Assert.AreEqual(2, binObj.GetField<short>("fShort"));
            Assert.AreEqual('a', binObj.GetField<char>("fChar"));
            Assert.AreEqual(3, binObj.GetField<int>("fInt"));
            Assert.AreEqual(4, binObj.GetField<long>("fLong"));
            Assert.AreEqual(5, binObj.GetField<float>("fFloat"));
            Assert.AreEqual(6, binObj.GetField<double>("fDouble"));
            Assert.AreEqual(7.7m, binObj.GetField<decimal>("fDecimal"));

            Primitives obj = binObj.Deserialize<Primitives>();

            Assert.AreEqual(1, obj.FByte);
            Assert.AreEqual(true, obj.FBool);
            Assert.AreEqual(2, obj.FShort);
            Assert.AreEqual('a', obj.FChar);
            Assert.AreEqual(3, obj.FInt);
            Assert.AreEqual(4, obj.FLong);
            Assert.AreEqual(5, obj.FFloat);
            Assert.AreEqual(6, obj.FDouble);
            Assert.AreEqual(7.7m, obj.FDecimal);
        }
Beispiel #14
0
        /// <summary>
        /// Checks the string date guid enum values.
        /// </summary>
        private static void CheckStringDateGuidEnum2(IBinaryObject binObj, DateTime? nDate, Guid? nGuid)
        {
            Assert.AreEqual(200, binObj.GetHashCode());

            Assert.AreEqual("str2", binObj.GetField<string>("fStr"));
            Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
            Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNTimestamp"));
            Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
            Assert.AreEqual(TestEnum.Two, binObj.GetField<TestEnum>("fEnum"));
            Assert.AreEqual(new[] { "str2" }, binObj.GetField<string[]>("fStrArr"));
            Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
            Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fTimestampArr"));
            Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
            Assert.AreEqual(new[] { TestEnum.Two }, binObj.GetField<TestEnum[]>("fEnumArr"));

            var obj = binObj.Deserialize<StringDateGuidEnum>();

            Assert.AreEqual("str2", obj.FStr);
            Assert.AreEqual(nDate, obj.FnDate);
            Assert.AreEqual(nDate, obj.FnTimestamp);
            Assert.AreEqual(nGuid, obj.FnGuid);
            Assert.AreEqual(TestEnum.Two, obj.FEnum);
            Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
            Assert.AreEqual(new[] { nDate }, obj.FDateArr);
            Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
            Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            string   s;
            DateTime startTime;
            DateTime endTime;

            IgniteConfiguration cfg = new IgniteConfiguration()
            {
                IgniteInstanceName = "TRex",

                // Register custom class for Ignite serialization
                BinaryConfiguration = new Apache.Ignite.Core.Binary.BinaryConfiguration(typeof(MyCacheClass))
            };

            IIgnite ignite = Ignition.Start(cfg);

            // Add a cache to Ignite
            ICache <string, MyCacheClass> cache = ignite.CreateCache <string, MyCacheClass>
                                                      (new CacheConfiguration()
            {
                Name                      = "TestCache",
                CopyOnRead                = false,
                KeepBinaryInStore         = false,
                CacheStoreFactory         = new TRexCacheStoreFactory(),
                ReadThrough               = true,
                WriteThrough              = true,
                WriteBehindFlushFrequency = new TimeSpan(0, 0, 5),     // 5 seconds
                EvictionPolicy            = new LruEvictionPolicy()
                {
                    MaxMemorySize = 1000000,
                }
            });

            int NumCacheEntries = 5000;

            // Add a cache item
            cache.Put("First", new MyCacheClass("FirstItem"));

            // Add a collectikon of items
            startTime = DateTime.Now;
            for (int i = 0; i < NumCacheEntries; i++)
            {
                cache.Put("First" + i, new MyCacheClass("First" + i));
            }
            endTime = DateTime.Now;

            s = string.Format("{0}", endTime - startTime);
            Console.WriteLine("Time to add cache items with serialisation: {0}", s);

            int sumsum = 0;

            // Query back the cache items with serialisation
            startTime = DateTime.Now;
            for (int i = 0; i < NumCacheEntries; i++)
            {
                MyCacheClass first = cache.Get("First" + i);

                int sum = 0;
                for (int ii = 0; ii < first.localData.Length; ii++)
                {
                    sum += first.localData[ii];
                }
                sumsum += sum;
            }
            endTime = DateTime.Now;

            s = string.Format("{0}", endTime - startTime);
            Console.WriteLine("Time to query cache items with serialisation: {0}, sum = {1}", s, sumsum);

            var binCache = cache.WithKeepBinary <string, IBinaryObject>();

            //            IBinaryObject binCacheItem = binCache["First"];
            //            Console.WriteLine(binCacheItem.GetField<string>("Name"));

            // Query back the cache items without serialisation (using BinaryObject)
            startTime = DateTime.Now;
            for (int i = 0; i < NumCacheEntries; i++)
            {
                IBinaryObject binCacheItem = binCache["First" + i];

                byte[] bytes = binCacheItem.GetField <byte[]>("localData");

                int sum = 0;
                for (int ii = 0; ii < bytes.Length; ii++)
                {
                    sum += bytes[ii];
                }
                sumsum += sum;
            }
            endTime = DateTime.Now;

            s = string.Format("{0}", endTime - startTime);
            Console.WriteLine("Time to query cache items without serialisation: {0}, sum = {1}", s, sumsum);

            // Get compute instance over all nodes in the cluster.
            ICompute      compute  = ignite.GetCompute();
            IClusterGroup compute2 = ignite.GetCompute().ClusterGroup;



            // Execute a map reduce on the cluster
            if (compute2.ForServers()?.GetNodes()?.Any() == true)
            {
                try
                {
                    string mapReduceResult = ignite.GetCompute().Execute <string, string, string>(new MyComputeTask(), "Bob");
                    Console.WriteLine("Mapreduce result = '{0}'", mapReduceResult);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception executing mapReduce execution\r\n: {0}", e);
                }
            }
            else
            {
                Console.WriteLine("Calling cluster mapReduce broadcast function: No servers present in cluster");
            }

            // Execute a command using affinity on the cluster
            try
            {
                string affinityResult = ignite.GetCompute().AffinityCall <string>("TestCache", "First", new AffinityComputeFunc("First"));
                Console.WriteLine("Affinity result = '{0}'", affinityResult);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception executing affinity execution\r\n: {0}", e);
            }

            if (ignite == null)
            {
                Console.WriteLine("Ignite instance is null at end of method");
            }
            Console.ReadKey();
        }