/// <summary>
        /// Start execution.
        /// </summary>
        /// <param name="grid">Ignite instance.</param>
        /// <param name="writer">Writer.</param>
        /// <param name="cb">Callback invoked when all necessary data is written to stream.</param>
        /// <param name="qry">Query.</param>
        public void Start(Ignite grid, PortableWriterImpl writer, Func <IUnmanagedTarget> cb,
                          ContinuousQuery <TK, TV> qry)
        {
            // 1. Inject resources.
            ResourceProcessor.Inject(_lsnr, grid);
            ResourceProcessor.Inject(_filter, grid);

            // 2. Allocate handle.
            _hnd = grid.HandleRegistry.Allocate(this);

            // 3. Write data to stream.
            writer.WriteLong(_hnd);
            writer.WriteBoolean(qry.Local);
            writer.WriteBoolean(_filter != null);

            ContinuousQueryFilterHolder filterHolder = _filter == null || qry.Local ? null :
                                                       new ContinuousQueryFilterHolder(typeof(TK), typeof(TV), _filter, _keepPortable);

            writer.WriteObject(filterHolder);

            writer.WriteInt(qry.BufferSize);
            writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
            writer.WriteBoolean(qry.AutoUnsubscribe);

            // 4. Call Java.
            _nativeQry = cb();

            // 5. Initial query.
            var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry);

            _initialQueryCursor = nativeInitialQryCur == null
                ? null
                : new QueryCursor <TK, TV>(nativeInitialQryCur, _marsh, _keepPortable);
        }
Exemplo n.º 2
0
        static void Main()
        {
            IIgnite ignite = Ignition.Start();

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

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

            var sqlQuery = new SqlQuery(typeof(Person), "where Age > ?", 30);
            IQueryCursor <ICacheEntry <int, Person> > queryCursor = cache.Query(sqlQuery);

            foreach (ICacheEntry <int, Person> cacheEntry in queryCursor)
            {
                Console.WriteLine(cacheEntry);
            }
            var fieldsQuery = new SqlFieldsQuery("select name from Person where Age > ? ", 30);
            IQueryCursor <IList> quertCursor = cache.QueryFields(fieldsQuery);

            foreach (IList fieldsList in quertCursor)
            {
                Console.WriteLine(fieldsList[0]);
            }
            var fieldsquery = new SqlFieldsQuery("select sum(Age) from Person");
            IQueryCursor <IList> queryCursor1 = cache.QueryFields(fieldsquery);

            Console.WriteLine(queryCursor1.GetAll()[0][0]);
        }
Exemplo n.º 3
0
        public void TestCursor()
        {
            Cache().Put(1, new QueryPerson("Ivanov", 30));
            Cache().Put(1, new QueryPerson("Petrov", 40));
            Cache().Put(1, new QueryPerson("Sidorov", 50));

            SqlQuery qry = new SqlQuery(typeof(QueryPerson), "age >= 20");

            // 1. Test GetAll().
            using (IQueryCursor <ICacheEntry <int, QueryPerson> > cursor = Cache().Query(qry))
            {
                cursor.GetAll();

                Assert.Throws <InvalidOperationException>(() => { cursor.GetAll(); });
                Assert.Throws <InvalidOperationException>(() => { cursor.GetEnumerator(); });
            }

            // 2. Test GetEnumerator.
            using (IQueryCursor <ICacheEntry <int, QueryPerson> > cursor = Cache().Query(qry))
            {
                cursor.GetEnumerator();

                Assert.Throws <InvalidOperationException>(() => { cursor.GetAll(); });
                Assert.Throws <InvalidOperationException>(() => { cursor.GetEnumerator(); });
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var cfg = new IgniteConfiguration
            {
                BinaryConfiguration = new BinaryConfiguration(typeof(Employee),
                                                              typeof(EmployeeFilter))
            };
            IIgnite ignite = Ignition.Start(cfg);

            ICache <int, Employee> cache = ignite.GetOrCreateCache <int, Employee>("employees");

            cache[1] = new Employee {
                Name = "John Doe", Age = 27
            };
            cache[2] = new Employee {
                Name = "Jane Moe", Age = 43
            };
            cache[3] = new Employee {
                Name = "Sofia Romi", Age = 29
            };
            cache[4] = new Employee {
                Name = "Abdul Kalam", Age = 33
            };

            var scanQuery = new ScanQuery <int, Employee>(new EmployeeFilter());
            IQueryCursor <ICacheEntry <int, Employee> > queryCursor = cache.Query(scanQuery);

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

            Console.ReadKey();
        }
Exemplo n.º 5
0
        private static void SCanQuery()
        {
            var cfg = new IgniteConfiguration
            {
                BinaryConfiguration = new BinaryConfiguration(typeof(Person),
                                                              typeof(PersonFilter))
            };
            IIgnite ignite = Ignition.Start(cfg);

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

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

            var scanQuery = new ScanQuery <int, Person>(new PersonFilter());
            IQueryCursor <ICacheEntry <int, Person> > queryCursor = cache.Query(scanQuery);

            foreach (ICacheEntry <int, Person> cacheEntry in queryCursor)
            {
                Console.WriteLine(cacheEntry);
            }
        }
Exemplo n.º 6
0
        public void TestSqlFieldsQuery([Values(true, false)] bool loc, [Values(true, false)] bool distrJoin,
                                       [Values(true, false)] bool enforceJoinOrder, [Values(true, false)] bool lazy)
        {
            int cnt = MaxItemCnt;

            var cache = Cache();

            // 1. Populate cache with data, calculating expected count in parallel.
            var exp = PopulateCache(cache, loc, cnt, x => x < 50);

            // 2. Validate results.
            var qry = new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50")
            {
                EnableDistributedJoins = distrJoin,
                EnforceJoinOrder       = enforceJoinOrder,
                Colocated      = !distrJoin,
                ReplicatedOnly = false,
                Local          = loc,
                Timeout        = TimeSpan.FromSeconds(2),
                Lazy           = lazy
            };

            using (IQueryCursor <IList> cursor = cache.QueryFields(qry))
            {
                HashSet <int> exp0 = new HashSet <int>(exp);

                foreach (var entry in cursor.GetAll())
                {
                    Assert.AreEqual(2, entry.Count);
                    Assert.AreEqual(entry[0].ToString(), entry[1].ToString());

                    exp0.Remove((int)entry[1]);
                }

                Assert.AreEqual(0, exp0.Count);
            }

            using (IQueryCursor <IList> cursor = cache.QueryFields(qry))
            {
                HashSet <int> exp0 = new HashSet <int>(exp);

                foreach (var entry in cursor)
                {
                    Assert.AreEqual(entry[0].ToString(), entry[1].ToString());

                    exp0.Remove((int)entry[1]);
                }

                Assert.AreEqual(0, exp0.Count);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Test SQL query arguments passing.
        /// </summary>
        public void TestSqlQueryArguments()
        {
            Cache().Put(1, new QueryPerson("Ivanov", 30));
            Cache().Put(2, new QueryPerson("Petrov", 40));
            Cache().Put(3, new QueryPerson("Sidorov", 50));

            // 1. Empty result set.
            using (
                IQueryCursor <ICacheEntry <int, QueryPerson> > cursor =
                    Cache().Query(new SqlQuery(typeof(QueryPerson), "age < ?", 50)))
            {
                foreach (ICacheEntry <int, QueryPerson> entry in cursor.GetAll())
                {
                    Assert.IsTrue(entry.Key == 1 || entry.Key == 2);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Test SQL fields query arguments passing.
        /// </summary>
        public void TestSqlFieldsQueryArguments()
        {
            Cache().Put(1, new QueryPerson("Ivanov", 30));
            Cache().Put(2, new QueryPerson("Petrov", 40));
            Cache().Put(3, new QueryPerson("Sidorov", 50));

            // 1. Empty result set.
            using (
                IQueryCursor <IList> cursor = Cache().QueryFields(
                    new SqlFieldsQuery("SELECT age FROM QueryPerson WHERE age < ?", 50)))
            {
                foreach (IList entry in cursor.GetAll())
                {
                    Assert.IsTrue((int)entry[0] < 50);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Start execution.
        /// </summary>
        /// <param name="grid">Ignite instance.</param>
        /// <param name="writer">Writer.</param>
        /// <param name="cb">Callback invoked when all necessary data is written to stream.</param>
        /// <param name="qry">Query.</param>
        public void Start(Ignite grid, BinaryWriter writer, Func <IUnmanagedTarget> cb,
                          ContinuousQuery <TK, TV> qry)
        {
            // 1. Inject resources.
            ResourceProcessor.Inject(_lsnr, grid);
            ResourceProcessor.Inject(_filter, grid);

            // 2. Allocate handle.
            _hnd = grid.HandleRegistry.Allocate(this);

            // 3. Write data to stream.
            writer.WriteLong(_hnd);
            writer.WriteBoolean(qry.Local);
            writer.WriteBoolean(_filter != null);

            var javaFilter = _filter as PlatformJavaObjectFactoryProxy;

            if (javaFilter != null)
            {
                writer.WriteObject(javaFilter.GetRawProxy());
            }
            else
            {
                var filterHolder = _filter == null || qry.Local
                    ? null
                    : new ContinuousQueryFilterHolder(_filter, _keepBinary);

                writer.WriteObject(filterHolder);
            }

            writer.WriteInt(qry.BufferSize);
            writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
            writer.WriteBoolean(qry.AutoUnsubscribe);

            // 4. Call Java.
            _nativeQry = cb();

            // 5. Initial query.
            var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry);

            _initialQueryCursor = nativeInitialQryCur == null
                ? null
                : new QueryCursor <TK, TV>(nativeInitialQryCur, _marsh, _keepBinary);
        }
Exemplo n.º 10
0
        public void TestEnumerator()
        {
#pragma warning disable 618
            Cache().Put(1, new QueryPerson("Ivanov", 30));
            Cache().Put(2, new QueryPerson("Petrov", 40));
            Cache().Put(3, new QueryPerson("Sidorov", 50));
            Cache().Put(4, new QueryPerson("Unknown", 60));

            // 1. Empty result set.
            using (IQueryCursor <ICacheEntry <int, QueryPerson> > cursor =
                       Cache().Query(new SqlQuery(typeof(QueryPerson), "age = 100")))
            {
                IEnumerator <ICacheEntry <int, QueryPerson> > e = cursor.GetEnumerator();

                Assert.Throws <InvalidOperationException>(() =>
                                                          { ICacheEntry <int, QueryPerson> entry = e.Current; });

                Assert.IsFalse(e.MoveNext());

                Assert.Throws <InvalidOperationException>(() =>
                                                          { ICacheEntry <int, QueryPerson> entry = e.Current; });

                Assert.Throws <NotSupportedException>(() => e.Reset());

                e.Dispose();
            }

            SqlQuery qry = new SqlQuery(typeof(QueryPerson), "age < 60");

            Assert.AreEqual(QueryBase.DefaultPageSize, qry.PageSize);

            // 2. Page size is bigger than result set.
            qry.PageSize = 4;
            CheckEnumeratorQuery(qry);

            // 3. Page size equal to result set.
            qry.PageSize = 3;
            CheckEnumeratorQuery(qry);

            // 4. Page size if less than result set.
            qry.PageSize = 2;
            CheckEnumeratorQuery(qry);
#pragma warning restore 618
        }
Exemplo n.º 11
0
        private static void SQLQuery()
        {
            var cfg = new IgniteConfiguration
            {
                BinaryConfiguration = new BinaryConfiguration(typeof(Person),
                                                              typeof(PersonFilter))
            };
            IIgnite ignite = Ignition.Start(cfg);

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

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

            var sqlQuerry = new SqlQuery(typeof(Person), "where age > ?", 30);
            IQueryCursor <ICacheEntry <int, Person> > queryCursor = cache.Query(sqlQuerry);

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

            var fieldsQuery  = new SqlFieldsQuery("select name from Person where age > ?", 30);
            var queryCursor2 = cache.Query(fieldsQuery);

            foreach (var fieldList in queryCursor2)
            {
                Console.WriteLine(fieldList[0]);
            }

            var fieldsQuery2 = new SqlFieldsQuery("select sum(age) from Person");
            var queryCursor3 = cache.Query(fieldsQuery2);

            Console.WriteLine(queryCursor3.GetAll()[0][0]);   // 70
        }
Exemplo n.º 12
0
    static void Main(string[] args)
    {
        //IIgnite ignite = Ignition.Start();
        //ICache<int, String> cache = ignite.GetOrCreateCache<int, string>("Test");
        //cache.Put(1, "HelloWorld");
        //Console.WriteLine(cache.Get(1));
        //IIgnite ignite = Ignition.Start();
        //ICache<int, String> cache = ignite.GetOrCreateCache<int, String>("test");
        //if(cache.PutIfAbsent(1,"Hello World"))
        //{
        //    Console.WriteLine("Data added to cache");
        //}
        //else
        //{
        //    Console.WriteLine(cache.Get(1));
        //}
        var cfg = new IgniteConfiguration
        {
            BinaryConfiguration = new BinaryConfiguration(typeof(person), typeof(PersonFilter))
        };
        IIgnite ignite             = Ignition.Start(cfg);
        ICache <int, person> cache = ignite.GetOrCreateCache <int, person>("persons");

        cache[1] = new person {
            Name = "Jonny", Age = 22
        };
        cache[2] = new person {
            Name = "Rmi", Age = 33
        };
        var scanQuery = new ScanQuery <int, person>(new PersonFilter());
        IQueryCursor <ICacheEntry <int, person> > queryCursor = cache.Query(scanQuery);

        foreach (ICacheEntry <int, person> cacheEntries in queryCursor)
        {
            Console.WriteLine(cacheEntries);
        }

        //var binCache = cache.WithKeepBinary<int, IBinaryObject>();
        //IBinaryObject binaryObject = binCache[1];
        //Console.WriteLine(binaryObject.GetField<String>("Name"));
    }
        /** <inheritdoc /> */
        public IQueryCursor <ICacheEntry <TK, TV> > GetInitialQueryCursor()
        {
            lock (this)
            {
                if (_disposed)
                {
                    throw new ObjectDisposedException("Continuous query handle has been disposed.");
                }

                var cur = _initialQueryCursor;

                if (cur == null)
                {
                    throw new InvalidOperationException("GetInitialQueryCursor() can be called only once.");
                }

                _initialQueryCursor = null;

                return(cur);
            }
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            var cfg = new IgniteConfiguration
            {
                BinaryConfiguration = new BinaryConfiguration(typeof(Person2))
            };

            IIgnite ignite = Ignition.Start(cfg);
            ICache <int, Person2> cache = ignite.GetOrCreateCache <int, Person2>(
                new CacheConfiguration("persons", typeof(Person2)));

            //ICache<int, Person1> cache = ignite.GetOrCreateCache<int, Person1>("persons");
            cache[1] = new Person2 {
                Name = "John Doe", Age = 27
            };
            cache[2] = new Person2 {
                Name = "Jane Moe", Age = 43
            };
            cache[3] = new Person2 {
                Name = "Sofia Romi", Age = 29
            };
            cache[4] = new Person2 {
                Name = "Abdul Kalam", Age = 33
            };

            var fieldsQuery = new SqlFieldsQuery(
                "select name from Person2 where age > ?", 30);
            IQueryCursor <IList> queryCursor = cache.QueryFields(fieldsQuery);

            foreach (IList fieldList in queryCursor)
            {
                Console.WriteLine(fieldList[0]);
            }

            //var fieldsQuery = new SqlFieldsQuery("select sum(age) from Person2");
            //IQueryCursor<IList> queryCursor = cache.QueryFields(fieldsQuery);
            //Console.WriteLine(queryCursor.GetAll()[0]);

            Console.ReadKey();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Check SQL fields query.
        /// </summary>
        /// <param name="cnt">Amount of cache entries to create.</param>
        /// <param name="loc">Local query flag.</param>
        private void CheckSqlFieldsQuery(int cnt, bool loc)
        {
            var cache = Cache();

            // 1. Populate cache with data, calculating expected count in parallel.
            var exp = PopulateCache(cache, loc, cnt, x => x < 50);

            // 2. Vlaidate results.
            SqlFieldsQuery qry = loc ? new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50", true) :
                                 new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age < 50");

            using (IQueryCursor <IList> cursor = cache.QueryFields(qry))
            {
                HashSet <int> exp0 = new HashSet <int>(exp);

                foreach (var entry in cursor.GetAll())
                {
                    Assert.AreEqual(2, entry.Count);
                    Assert.AreEqual(entry[0].ToString(), entry[1].ToString());

                    exp0.Remove((int)entry[1]);
                }

                Assert.AreEqual(0, exp0.Count);
            }

            using (IQueryCursor <IList> cursor = cache.QueryFields(qry))
            {
                HashSet <int> exp0 = new HashSet <int>(exp);

                foreach (var entry in cursor)
                {
                    Assert.AreEqual(entry[0].ToString(), entry[1].ToString());

                    exp0.Remove((int)entry[1]);
                }

                Assert.AreEqual(0, exp0.Count);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Check query result for enumerator test.
        /// </summary>
        /// <param name="qry">QUery.</param>
        private void CheckEnumeratorQuery(SqlQuery qry)
        {
            using (IQueryCursor <ICacheEntry <int, QueryPerson> > cursor = Cache().Query(qry))
            {
                bool first  = false;
                bool second = false;
                bool third  = false;

                foreach (var entry in cursor)
                {
                    if (entry.Key == 1)
                    {
                        first = true;

                        Assert.AreEqual("Ivanov", entry.Value.Name);
                        Assert.AreEqual(30, entry.Value.Age);
                    }
                    else if (entry.Key == 2)
                    {
                        second = true;

                        Assert.AreEqual("Petrov", entry.Value.Name);
                        Assert.AreEqual(40, entry.Value.Age);
                    }
                    else if (entry.Key == 3)
                    {
                        third = true;

                        Assert.AreEqual("Sidorov", entry.Value.Name);
                        Assert.AreEqual(50, entry.Value.Age);
                    }
                    else
                    {
                        Assert.Fail("Unexpected value: " + entry);
                    }
                }

                Assert.IsTrue(first && second && third);
            }
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            var cfg = new IgniteConfiguration
            {
                BinaryConfiguration = new BinaryConfiguration(typeof(Person1))
            };

            IIgnite ignite = Ignition.Start(cfg);

            ICache <int, Person1> cache = ignite.GetOrCreateCache <int, Person1>(
                new CacheConfiguration("persons", typeof(Person1)));

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

            cache[1] = new Person1 {
                Name = "John Doe", Age = 27
            };
            cache[2] = new Person1 {
                Name = "Jane Moe", Age = 43
            };
            cache[3] = new Person1 {
                Name = "Sofia Romi", Age = 29
            };
            cache[4] = new Person1 {
                Name = "Abdul Kalam", Age = 33
            };

            var sqlQuery = new SqlQuery(typeof(Person1), "where age > ?", 30);
            IQueryCursor <ICacheEntry <int, Person1> > queryCursor = cache.Query(sqlQuery);

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

            Console.ReadKey();
        }
Exemplo n.º 18
0
 public DefaultEnumerator(IQueryCursor <IList> cursor, Func <System.Collections.IList, Tval> evaluator)
 {
     this.cursor    = cursor;
     this.evaluator = evaluator;
 }
Exemplo n.º 19
0
        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
                List <Person> lstData = new List <Person>();
                var           cfg     = new IgniteConfiguration
                {
                    BinaryConfiguration = new BinaryConfiguration(typeof(Person), typeof(PersonFilter)),
                };
                Ignition.ClientMode = true;
                using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration"))
                {
                    ICache <int, Person> personCache = ignite.GetOrCreateCache <int, Person>(new CacheConfiguration("SQL_DATA", typeof(Person), typeof(PersonFilter)));

                    //all record - working
                    List <ICacheEntry <int, Person> > lst1 = personCache.ToList <ICacheEntry <int, Person> >();
                    foreach (ICacheEntry <int, Person> p in lst1)
                    {
                        lstData.Add(new Person()
                        {
                            Age = p.Value.Age, Designation = p.Value.Designation, Id = p.Value.Id, Name = p.Value.Name, Salary = p.Value.Salary
                        });
                    }

                    dgCacheData.DataSource = lstData;
                    lstData.Clear();

                    ///SQL query
                    var sqlQuery = new SqlQuery(typeof(Person), "where age >= ?", txtAge.Text);
                    IQueryCursor <ICacheEntry <int, Person> > queryCursor = personCache.Query(sqlQuery);

                    int j = 0;
                    foreach (ICacheEntry <int, Person> p in queryCursor)
                    {
                        j++;
                        lstData.Add(new Person()
                        {
                            Age = p.Value.Age, Designation = p.Value.Designation, Id = p.Value.Id, Name = p.Value.Name, Salary = p.Value.Salary
                        });
                    }
                    txtMsg.Text = j.ToString() + " records found using sql query";

                    //LINQ - normal .. help URL :  https://apacheignite-sql.readme.io/docs/linq
                    IQueryable <ICacheEntry <int, Person> > persons = personCache.AsCacheQueryable();
                    IQueryable <ICacheEntry <int, Person> > qry     = persons.Where(d => d.Value.Age > Convert.ToInt32(txtAge.Text));
                    List <ICacheEntry <int, Person> >       lst2    = qry.ToList <ICacheEntry <int, Person> >();
                    var pers = qry.ToArray();

                    //LINQ - compiled
                    var compiledQuery = CompiledQuery.Compile((int age) => persons.Where(emp => emp.Value.Age > age));
                    IQueryCursor <ICacheEntry <int, Person> > cursor = compiledQuery(Convert.ToInt32(txtAge.Text));
                    var result = cursor.ToArray();

                    txtMsg.Text = txtMsg.Text + '\n' + "  and " + lst2.Count + " found using LINQ";
                }
                dgFilter.DataSource = lstData;
            }
            catch (Exception ex)
            {
                txtMsg.Text = ex.ToString();
            }
        }
Exemplo n.º 20
0
 public FieldQuerableWrap(IQueryCursor <System.Collections.IList> cursor, Func <System.Collections.IList, Tval> evaluator)
 {
     this.cursor    = cursor;
     this.evaluator = evaluator;
     innerEnu       = new DefaultEnumerator(cursor, evaluator);
 }
Exemplo n.º 21
0
        //load from cache
        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                List <Person> lstData = new List <Person>();
                var           ccfg    = new CacheConfiguration
                {
                    Name      = "SCAN_DATA",
                    CacheMode = CacheMode.Replicated
                };

                var cfg = new IgniteConfiguration
                {
                    BinaryConfiguration = new BinaryConfiguration(typeof(Person), typeof(PersonFilter)),
                };

                Ignition.ClientMode = true;
                using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration"))
                {
                    ICache <int, Person> persons = ignite.GetOrCreateCache <int, Person>(ccfg);

                    //getting single record-- working
                    //lstData.Add(persons.Get(1));

                    //all record coming - working
                    List <ICacheEntry <int, Person> > lst1 = persons.ToList <ICacheEntry <int, Person> >();
                    foreach (ICacheEntry <int, Person> p in lst1)
                    {
                        lstData.Add(new Person()
                        {
                            Age = p.Value.Age, Designation = p.Value.Designation, Id = p.Value.Id, Name = p.Value.Name, Salary = p.Value.Salary
                        });
                    }

                    dgCacheData.DataSource = lstData;
                    lstData.Clear();


                    //filter records
                    var scanQuery = new ScanQuery <int, Person>(new PersonFilter(Convert.ToInt32(txtAge.Text)));
                    IQueryCursor <ICacheEntry <int, Person> > queryCursor = persons.Query(scanQuery);

                    int j = 0;
                    foreach (ICacheEntry <int, Person> p in queryCursor)
                    {
                        j++;
                        lstData.Add(new Person()
                        {
                            Age = p.Value.Age, Designation = p.Value.Designation, Id = p.Value.Id, Name = p.Value.Name, Salary = p.Value.Salary
                        });
                    }
                    txtMsg.Text = j.ToString() + " records found";
                }

                dgFilter.DataSource = lstData;
            }
            catch (Exception ex)
            {
                txtMsg.Text = ex.ToString();
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="qry">Query.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="keepBinary">Keep binary flag.</param>
        /// <param name="createTargetCb">The initialization callback.</param>
        /// <param name="initialQry">The initial query.</param>
        public ContinuousQueryHandleImpl(ContinuousQuery <TK, TV> qry, Marshaller marsh, bool keepBinary,
                                         Func <Action <BinaryWriter>, IPlatformTargetInternal> createTargetCb, QueryBase initialQry)
        {
            _marsh      = marsh;
            _keepBinary = keepBinary;

            _lsnr   = qry.Listener;
            _filter = qry.Filter;

            // 1. Inject resources.
            ResourceProcessor.Inject(_lsnr, _marsh.Ignite);
            ResourceProcessor.Inject(_filter, _marsh.Ignite);

            try
            {
                // 2. Allocate handle.
                _hnd = _marsh.Ignite.HandleRegistry.Allocate(this);

                // 3. Call Java.
                _nativeQry = createTargetCb(writer =>
                {
                    writer.WriteLong(_hnd);
                    writer.WriteBoolean(qry.Local);
                    writer.WriteBoolean(_filter != null);

                    var javaFilter = _filter as PlatformJavaObjectFactoryProxy;

                    if (javaFilter != null)
                    {
                        writer.WriteObject(javaFilter.GetRawProxy());
                    }
                    else
                    {
                        var filterHolder = _filter == null || qry.Local
                            ? null
                            : new ContinuousQueryFilterHolder(_filter, _keepBinary);

                        writer.WriteObject(filterHolder);
                    }

                    writer.WriteInt(qry.BufferSize);
                    writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
                    writer.WriteBoolean(qry.AutoUnsubscribe);

                    if (initialQry != null)
                    {
                        writer.WriteInt((int)initialQry.OpId);

                        initialQry.Write(writer, _keepBinary);
                    }
                    else
                    {
                        writer.WriteInt(-1); // no initial query
                    }
                });

                // 4. Initial query.
                var nativeInitialQryCur = _nativeQry.OutObjectInternal(0);
                _initialQueryCursor = nativeInitialQryCur == null
                    ? null
                    : new QueryCursor <TK, TV>(nativeInitialQryCur, _keepBinary);
            }
            catch (Exception)
            {
                if (_hnd > 0)
                {
                    _marsh.Ignite.HandleRegistry.Release(_hnd);
                }

                if (_nativeQry != null)
                {
                    _nativeQry.Dispose();
                }

                if (_initialQueryCursor != null)
                {
                    _initialQueryCursor.Dispose();
                }

                throw;
            }
        }