You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/22 08:40:08 UTC

[22/28] ignite git commit: IGNITE-1513: Moved CPP.

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/cache.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/cache.h b/modules/platform/cpp/core/include/ignite/cache/cache.h
new file mode 100644
index 0000000..dcc837b
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/cache.h
@@ -0,0 +1,1153 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE
+#define _IGNITE_CACHE
+
+#include <map>
+#include <set>
+
+#include <ignite/common/common.h>
+#include <ignite/common/concurrent.h>
+
+#include "ignite/cache/cache_peek_mode.h"
+#include "ignite/cache/query/query_cursor.h"
+#include "ignite/cache/query/query_scan.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+#include "ignite/impl/cache/cache_impl.h"
+#include "ignite/impl/operations.h"
+#include "ignite/ignite_error.h"
+
+namespace ignite
+{
+    namespace cache
+    {
+        /**
+         * Main entry point for all Data Grid APIs.
+         */
+        template<typename K, typename V>
+        class IGNITE_IMPORT_EXPORT Cache
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            Cache(impl::cache::CacheImpl* impl) : impl(ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl>(impl))
+            {
+                // No-op.
+            }
+
+            /**
+             * Name of this cache (null for default cache).
+             */
+            char* GetName()
+            {
+                return impl.Get()->GetName();
+            }
+
+            /**
+             * Checks whether this cache contains no key-value mappings.
+             * Semantically equals to Cache.Size(IGNITE_PEEK_MODE_PRIMARY) == 0.
+             *
+             * @return True if cache is empty.
+             */
+            bool IsEmpty()
+            {
+                IgniteError err;
+
+                bool res = IsEmpty(err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Checks whether this cache contains no key-value mappings.
+             * Semantically equals to Cache.Size(IGNITE_PEEK_MODE_PRIMARY) == 0.
+             *
+             * @param err Error.
+             * @return True if cache is empty.
+             */
+            bool IsEmpty(IgniteError& err)
+            {
+                return impl.Get()->IsEmpty(&err);
+            }
+
+            /**
+             * Check if cache contains mapping for this key.
+             *
+             * @param key Key.
+             * @return True if cache contains mapping for this key.
+             */
+            bool ContainsKey(const K& key)
+            {
+                IgniteError err;
+
+                bool res = ContainsKey(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Check if cache contains mapping for this key.
+             *
+             * @param key Key.
+             * @param err Error.
+             * @return True if cache contains mapping for this key.
+             */
+            bool ContainsKey(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                return impl.Get()->ContainsKey(op, &err);
+            }
+
+            /**
+             * Check if cache contains mapping for these keys.
+             *
+             * @param keys Keys.
+             * @return True if cache contains mapping for all these keys.
+             */
+            bool ContainsKeys(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                bool res = ContainsKeys(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Check if cache contains mapping for these keys.
+             *
+             * @param keys Keys.
+             * @param err Error.
+             * @return True if cache contains mapping for all these keys.
+             */
+            bool ContainsKeys(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                return impl.Get()->ContainsKeys(op, &err);
+            }
+
+            /**
+             * Peeks at cached value using optional set of peek modes. This method will sequentially
+             * iterate over given peek modes, and try to peek at value using each peek mode. Once a
+             * non-null value is found, it will be immediately returned.
+             * This method does not participate in any transactions, however, it may peek at transactional
+             * value depending on the peek modes used.
+             *
+             * @param key Key.
+             * @param peekModes Peek modes.
+             * @return Value.
+             */
+            V LocalPeek(const K& key, int32_t peekModes)
+            {
+                IgniteError err;
+
+                V res = LocalPeek(key, peekModes, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Peeks at cached value using optional set of peek modes. This method will sequentially
+             * iterate over given peek modes, and try to peek at value using each peek mode. Once a
+             * non-null value is found, it will be immediately returned.
+             * This method does not participate in any transactions, however, it may peek at transactional
+             * value depending on the peek modes used.
+             *
+             * @param key Key.
+             * @param peekModes Peek modes.
+             * @param err Error.
+             * @return Value.
+             */
+            V LocalPeek(const K& key, int32_t peekModes, IgniteError& err)
+            {
+                impl::InCacheLocalPeekOperation<K> inOp(&key, peekModes);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->LocalPeek(inOp, outOp, peekModes, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Retrieves value mapped to the specified key from cache.
+             * If the value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key.
+             * @return Value.
+             */
+            V Get(const K& key)
+            {
+                IgniteError err;
+
+                V res = Get(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Retrieves value mapped to the specified key from cache.
+             * If the value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key.
+             * @param err Error.
+             * @return Value.
+             */
+            V Get(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> inOp(&key);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->Get(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Retrieves values mapped to the specified keys from cache.
+             * If some value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys.
+             * @return Map of key-value pairs.
+             */
+            std::map<K, V> GetAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                std::map<K, V> res = GetAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Retrieves values mapped to the specified keys from cache.
+             * If some value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys.
+             * @param err Error.
+             * @return Map of key-value pairs.
+             */
+            std::map<K, V> GetAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> inOp(&keys);
+                impl::OutMapOperation<K, V> outOp;
+
+                impl.Get()->GetAll(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Associates the specified value with the specified key in the cache.
+             * If the cache previously contained a mapping for the key,
+             * the old value is replaced by the specified value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             */
+            void Put(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                Put(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Associates the specified value with the specified key in the cache.
+             * If the cache previously contained a mapping for the key,
+             * the old value is replaced by the specified value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             */
+            void Put(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                impl.Get()->Put(op, &err);
+            }
+
+            /**
+             * Stores given key-value pairs in cache.
+             * If write-through is enabled, the stored values will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param vals Key-value pairs to store in cache.
+             */
+            void PutAll(const std::map<K, V>& vals)
+            {
+                IgniteError err;
+
+                PutAll(vals, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Stores given key-value pairs in cache.
+             * If write-through is enabled, the stored values will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param vals Key-value pairs to store in cache.
+             * @param err Error.
+             */
+            void PutAll(const std::map<K, V>& vals, IgniteError& err)
+            {
+                impl::InMapOperation<K, V> op(&vals);
+
+                impl.Get()->PutAll(op, &err);
+            }
+
+            /**
+             * Associates the specified value with the specified key in this cache,
+             * returning an existing value if one existed.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @return The value associated with the key at the start of the
+             *     operation or null if none was associated.
+             */
+            V GetAndPut(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                V res = GetAndPut(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Associates the specified value with the specified key in this cache,
+             * returning an existing value if one existed.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             * @return The value associated with the key at the start of the
+             *     operation or null if none was associated.
+             */
+            V GetAndPut(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> inOp(&key, &val);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndPut(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Atomically replaces the value for a given key if and only if there is
+             * a value currently mapped by the key.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @return The previous value associated with the specified key, or
+             *     null if there was no mapping for the key.
+             */
+            V GetAndReplace(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                V res = GetAndReplace(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Atomically replaces the value for a given key if and only if there is
+             * a value currently mapped by the key.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             * @return The previous value associated with the specified key, or
+             *     null if there was no mapping for the key.
+             */
+            V GetAndReplace(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> inOp(&key, &val);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndReplace(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Atomically removes the entry for a key only if currently mapped to some value.
+             *
+             * @param key Key with which the specified value is associated.
+             * @return The value if one existed or null if no mapping existed for this key.
+             */
+            V GetAndRemove(const K& key)
+            {
+                IgniteError err;
+
+                V res = GetAndRemove(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Atomically removes the entry for a key only if currently mapped to some value.
+             *
+             * @param key Key with which the specified value is associated.
+             * @param err Error.
+             * @return The value if one existed or null if no mapping existed for this key.
+             */
+            V GetAndRemove(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> inOp(&key);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndRemove(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Atomically associates the specified key with the given value if it is not
+             * already associated with a value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @return True if a value was set.
+             */
+            bool PutIfAbsent(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                bool res = PutIfAbsent(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Atomically associates the specified key with the given value if it is not
+             * already associated with a value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             * @return True if a value was set.
+             */
+            bool PutIfAbsent(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                return impl.Get()->PutIfAbsent(op, &err);
+            }
+
+            /**
+             * Stores given key-value pair in cache only if cache had no previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
+             * avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @return Previously contained value regardless of whether put happened or not
+             *     (null if there was no previous value).
+             */
+            V GetAndPutIfAbsent(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                V res = GetAndPutIfAbsent(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Stores given key-value pair in cache only if cache had no previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
+             * avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @param err Error.
+             * @return Previously contained value regardless of whether put happened or not
+             *     (null if there was no previous value).
+             */
+            V GetAndPutIfAbsent(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> inOp(&key, &val);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndPutIfAbsent(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Stores given key-value pair in cache only if there is a previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, rom the underlying persistent storage.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @return True if the value was replaced.
+             */
+            bool Replace(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                bool res = Replace(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Stores given key-value pair in cache only if there is a previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, rom the underlying persistent storage.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @param err Error.
+             * @return True if the value was replaced.
+             */
+            bool Replace(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                return impl.Get()->Replace(op, &err);
+            }
+
+            /**
+             * Stores given key-value pair in cache only if only if the previous value is equal to the
+             * old value passed as argument.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param oldVal Old value to match.
+             * @param newVal Value to be associated with the given key.
+             * @return True if replace happened, false otherwise.
+             */
+            bool Replace(const K& key, const V& oldVal, const V& newVal)
+            {
+                IgniteError err;
+
+                bool res = Replace(key, oldVal, newVal, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Stores given key-value pair in cache only if only if the previous value is equal to the
+             * old value passed as argument.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param oldVal Old value to match.
+             * @param newVal Value to be associated with the given key.
+             * @param err Error.
+             * @return True if replace happened, false otherwise.
+             */
+            bool Replace(const K& key, const V& oldVal, const V& newVal, IgniteError& err)
+            {
+                impl::In3Operation<K, V, V> op(&key, &oldVal, &newVal);
+
+                return impl.Get()->ReplaceIfEqual(op, &err);
+            }
+
+            /**
+             * Attempts to evict all entries associated with keys. Note, that entry will be evicted only
+             * if it's not used (not participating in any locks or transactions).
+             *
+             * @param keys Keys to evict from cache.
+             */
+            void LocalEvict(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                LocalEvict(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Attempts to evict all entries associated with keys. Note, that entry will be evicted only
+             * if it's not used (not participating in any locks or transactions).
+             *
+             * @param keys Keys to evict from cache.
+             * @param err Error.
+             */
+            void LocalEvict(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->LocalEvict(op, &err);
+            }
+
+            /**
+             * Clear cache.
+             */
+            void Clear()
+            {
+                IgniteError err;
+
+                Clear(err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear cache.
+             *
+             * @param err Error.
+             */
+            void Clear(IgniteError& err)
+            {
+                impl.Get()->Clear(&err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param key Key to clear.
+             */
+            void Clear(const K& key)
+            {
+                IgniteError err;
+
+                Clear(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param key Key to clear.
+             * @param err Error.
+             */
+            void Clear(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                impl.Get()->Clear(op, &err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param keys Keys to clear.
+             */
+            void ClearAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                ClearAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param keys Keys to clear.
+             * @param err Error.
+             */
+            void ClearAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->ClearAll(op, &err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears an entry from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param key Key to clear.
+             */
+            void LocalClear(const K& key)
+            {
+                IgniteError err;
+
+                LocalClear(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears an entry from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param key Key to clear.
+             * @param err Error.
+             */
+            void LocalClear(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                impl.Get()->LocalClear(op, &err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears entries from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param keys Keys to clear.
+             */
+            void LocalClearAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                LocalClearAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears entries from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param keys Keys to clear.
+             * @param err Error.
+             */
+            void LocalClearAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->LocalClearAll(op, &err);
+            }
+
+            /**
+             * Removes given key mapping from cache. If cache previously contained value for the given key,
+             * then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
+             * loaded from the primary node, which in its turn may load the value from the disk-based swap
+             * storage, and consecutively, if it's not in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method removex() should always be used instead of this
+             * one to avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @return False if there was no matching key.
+             */
+            bool Remove(const K& key)
+            {
+                IgniteError err;
+
+                bool res = Remove(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Removes given key mapping from cache. If cache previously contained value for the given key,
+             * then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
+             * loaded from the primary node, which in its turn may load the value from the disk-based swap
+             * storage, and consecutively, if it's not in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method removex() should always be used instead of this
+             * one to avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @param err Error.
+             * @return False if there was no matching key.
+             */
+            bool Remove(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                return impl.Get()->Remove(op, &err);
+            }
+
+            /**
+             * Removes given key mapping from cache if one exists and value is equal to the passed in value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @param val Value to match against currently cached value.
+             * @return True if entry was removed, false otherwise.
+             */
+            bool Remove(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                bool res = Remove(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Removes given key mapping from cache if one exists and value is equal to the passed in value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @param val Value to match against currently cached value.
+             * @param err Error.
+             * @return True if entry was removed, false otherwise.
+             */
+            bool Remove(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                return impl.Get()->RemoveIfEqual(op, &err);
+            }
+
+            /**
+             * Removes given key mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys whose mappings are to be removed from cache.
+             */
+            void RemoveAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                RemoveAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Removes given key mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys whose mappings are to be removed from cache.
+             * @param err Error.
+             */
+            void RemoveAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->RemoveAll(op, &err);
+            }
+
+            /**
+             * Removes all mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param err Error.
+             */
+            void RemoveAll()
+            {
+                IgniteError err;
+
+                RemoveAll(err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Removes all mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param err Error.
+             */
+            void RemoveAll(IgniteError& err)
+            {
+                return impl.Get()->RemoveAll(&err);
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize()
+            {
+                return LocalSize(IGNITE_PEEK_MODE_ALL);
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @param err Error.
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize(IgniteError& err)
+            {
+                return LocalSize(IGNITE_PEEK_MODE_ALL, err);
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @param Peek modes.
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize(int32_t peekModes)
+            {
+                IgniteError err;
+
+                int32_t res = LocalSize(peekModes, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @param Peek modes.
+             * @param err Error.
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize(int32_t peekModes, IgniteError& err)
+            {
+                return impl.Get()->LocalSize(peekModes, &err);
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @return Cache size across all nodes.
+             */
+            int32_t Size()
+            {
+                return Size(ignite::cache::IGNITE_PEEK_MODE_ALL);
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @param err Error.
+             * @return Cache size across all nodes.
+             */
+            int32_t Size(IgniteError& err)
+            {
+                return Size(ignite::cache::IGNITE_PEEK_MODE_ALL, err);
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @param Peek modes.
+             * @return Cache size across all nodes.
+             */
+            int32_t Size(int32_t peekModes)
+            {
+                IgniteError err;
+
+                int32_t res = Size(peekModes, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @param Peek modes.
+             * @param err Error.
+             * @return Cache size across all nodes.
+             */
+            int32_t Size(int32_t peekModes, IgniteError& err)
+            {
+                return impl.Get()->Size(peekModes, &err);
+            }
+
+            /**
+             * Perform SQL query.
+             *
+             * @param qry Query.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::SqlQuery& qry)
+            {
+                IgniteError err;
+
+                query::QueryCursor<K, V> res = Query(qry, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Perform SQL query.
+             *
+             * @param qry Query.
+             * @param err Error.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::SqlQuery& qry, IgniteError& err)
+            {
+                impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QuerySql(qry, &err);
+
+                return query::QueryCursor<K, V>(cursorImpl);
+            }
+
+            /*
+             * Perform text query.
+             *
+             * @param qry Query.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::TextQuery& qry)
+            {
+                IgniteError err;
+
+                query::QueryCursor<K, V> res = Query(qry, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /*
+             * Perform text query.
+             *
+             * @param qry Query.
+             * @param err Error.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::TextQuery& qry, IgniteError& err)
+            {
+                impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryText(qry, &err);
+
+                return query::QueryCursor<K, V>(cursorImpl);
+            }
+
+            /*
+             * Perform scan query.
+             *
+             * @param qry Query.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::ScanQuery& qry)
+            {
+                IgniteError err;
+
+                query::QueryCursor<K, V> res = Query(qry, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /*
+             * Perform scan query.
+             *
+             * @param qry Query.
+             * @param err Error.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::ScanQuery& qry, IgniteError& err)
+            {
+                impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryScan(qry, &err);
+
+                return query::QueryCursor<K, V>(cursorImpl);
+            }
+
+        private:
+            /** Implementation delegate. */
+            ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl> impl;
+        };
+    }
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/cache_entry.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/cache_entry.h b/modules/platform/cpp/core/include/ignite/cache/cache_entry.h
new file mode 100644
index 0000000..2b6c785
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/cache_entry.h
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_ENTRY
+#define _IGNITE_CACHE_ENTRY
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+    namespace cache
+    {
+        /**
+         * Cache entry.
+         */
+        template<typename K, typename V>
+        class IGNITE_IMPORT_EXPORT CacheEntry
+        {
+        public:
+            /**
+             * Default constructor.
+             */
+            CacheEntry() : key(K()), val(V())
+            {
+                // No-op.
+            }
+
+            /**
+             * Constructor.
+             *
+             * @param key Key.
+             * @param val Value.
+             */
+            CacheEntry(const K& key, const V& val) : key(key), val(val)
+            {
+                // No-op.
+            }
+
+            /**
+             * Copy constructor.
+             *
+             * @param other Other instance.
+             */
+            CacheEntry(const CacheEntry& other)
+            {
+                key = other.key;
+                val = other.val;
+            }
+
+            /**
+             * Assignment operator.
+             *
+             * @param other Other instance.
+             */
+            CacheEntry& operator=(const CacheEntry& other) 
+            {
+                if (this != &other)
+                {
+                    CacheEntry tmp(other);
+
+                    K& key0 = key;
+                    V& val0 = val;
+
+                    key = tmp.key;
+                    val = tmp.val;
+
+                    tmp.key = key0;
+                    tmp.val = val0;
+                }
+
+                return *this;
+            }
+
+            /**
+             * Get key.
+             * 
+             * @return Key.
+             */
+            K GetKey()
+            {
+                return key;
+            }
+
+            /**
+             * Get value.
+             *
+             * @return Value.
+             */
+            V GetValue()
+            {
+                return val;
+            }
+
+        private:
+            /** Key. */
+            K key; 
+
+            /** Value. */
+            V val; 
+        };
+    }
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/cache_peek_mode.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/cache_peek_mode.h b/modules/platform/cpp/core/include/ignite/cache/cache_peek_mode.h
new file mode 100644
index 0000000..be61887
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/cache_peek_mode.h
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_PEEK_MODE
+#define _IGNITE_CACHE_PEEK_MODE
+
+namespace ignite
+{
+    namespace cache
+    {
+        /**
+         * Enumeration of all supported cache peek modes.
+         */
+        enum CachePeekMode
+        {
+            /**
+             * Peeks into all available cache storages.
+             */
+            IGNITE_PEEK_MODE_ALL = 0x01,
+
+            /**
+             * Peek into near cache only (don't peek into partitioned cache).
+             * In case of LOCAL cache, behaves as IGNITE_PEEK_MODE_ALL mode.
+             */
+            IGNITE_PEEK_MODE_NEAR = 0x02,
+
+            /**
+             * Peek value from primary copy of partitioned cache only (skip near cache).
+             * In case of LOCAL cache, behaves as IGNITE_PEEK_MODE_ALL mode.
+             */
+            IGNITE_PEEK_MODE_PRIMARY = 0x04,
+
+            /**
+             * Peek value from backup copies of partitioned cache only (skip near cache).
+             * In case of LOCAL cache, behaves as IGNITE_PEEK_MODE_ALL mode.
+             */
+            IGNITE_PEEK_MODE_BACKUP = 0x08,
+
+            /**
+             * Peeks value from the on-heap storage only.
+             */
+            IGNITE_PEEK_MODE_ONHEAP = 0x10,
+
+            /**
+             * Peeks value from the off-heap storage only, without loading off-heap value into cache.
+             */
+            IGNITE_PEEK_MODE_OFFHEAP = 0x20,
+
+            /**
+             * Peeks value from the swap storage only, without loading swapped value into cache.
+             */
+            IGNITE_PEEK_MODE_SWAP = 0x40
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/query/query.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/query/query.h b/modules/platform/cpp/core/include/ignite/cache/query/query.h
new file mode 100644
index 0000000..f2d19cd
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/query/query.h
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_QUERY
+#define _IGNITE_QUERY
+
+#include "ignite/cache/query/query_argument.h"
+#include "ignite/cache/query/query_cursor.h"
+#include "ignite/cache/query/query_scan.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/query/query_argument.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/query/query_argument.h b/modules/platform/cpp/core/include/ignite/cache/query/query_argument.h
new file mode 100644
index 0000000..0f41c56
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/query/query_argument.h
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_ARGUMENT
+#define _IGNITE_CACHE_QUERY_ARGUMENT
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {            
+            /**
+             * Base class for all query arguments.
+             */
+            class QueryArgumentBase
+            {
+            public:
+                /**
+                 * Destructor.
+                 */
+                virtual ~QueryArgumentBase()
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Copy argument. 
+                 *
+                 * @return Copy.
+                 */
+                virtual QueryArgumentBase* Copy() = 0;
+
+                /**
+                 * Write argument.
+                 */
+                virtual void Write(ignite::portable::PortableRawWriter& writer) = 0;
+            };
+
+            /**
+             * Query argument.
+             */
+            template<typename T>
+            class QueryArgument : public QueryArgumentBase
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param val Value.
+                 */
+                QueryArgument(const T& val) : val(val)
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Copy constructor.
+                 *
+                 * @param other Other instance.
+                 */
+                QueryArgument(const QueryArgument& other)
+                {
+                    val = other.val;
+                }
+
+                /**
+                 * Assignment operator.
+                 *
+                 * @param other Other instance.
+                 */
+                QueryArgument& operator=(const QueryArgument& other) 
+                {
+                    if (this != &other)
+                    {
+                        QueryArgument tmp(other);
+
+                        T val0 = val;
+                        val = tmp.val;
+                        tmp.val = val0;
+                    }
+
+                    return *this;
+                }
+
+                ~QueryArgument()
+                {
+                    // No-op.
+                }
+
+                QueryArgumentBase* Copy()
+                {
+                    return new QueryArgument(val);
+                }
+
+                void Write(ignite::portable::PortableRawWriter& writer)
+                {
+                    writer.WriteObject<T>(val);
+                }
+
+            private:
+                /** Value. */
+                T val; 
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/query/query_cursor.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/query/query_cursor.h b/modules/platform/cpp/core/include/ignite/cache/query/query_cursor.h
new file mode 100644
index 0000000..23133e1
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/query/query_cursor.h
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_CURSOR
+#define _IGNITE_CACHE_QUERY_CURSOR
+
+#include <vector>
+
+#include <ignite/common/concurrent.h>
+
+#include "ignite/cache/cache_entry.h"
+#include "ignite/ignite_error.h"
+#include "ignite/impl/cache/query/query_impl.h"
+#include "ignite/impl/operations.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {            
+            /**
+             * Query cursor.
+             */
+            template<typename K, typename V>
+            class QueryCursor
+            {
+            public:
+                /**
+                 * Default constructor.
+                 */
+                QueryCursor() : impl(NULL)
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Constructor.
+                 *
+                 * @param impl Implementation.
+                 */
+                QueryCursor(impl::cache::query::QueryCursorImpl* impl) : 
+                    impl(ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl>(impl))
+                {
+                    // No-op.
+                }
+                
+                /**
+                 * Check whether next entry exists.
+                 *
+                 * @return True if next entry exists.
+                 */
+                bool HasNext()
+                {
+                    IgniteError err;
+
+                    bool res = HasNext(err);
+
+                    IgniteError::ThrowIfNeeded(err);
+
+                    return res;
+                }
+
+                /**
+                 * Check whether next entry exists.
+                 *
+                 * @param err Error.
+                 * @return True if next entry exists.
+                 */
+                bool HasNext(IgniteError& err)
+                {
+                    impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
+
+                    if (impl0)
+                        return impl0->HasNext(&err);
+                    else
+                    {
+                        err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, 
+                            "Instance is not usable (did you check for error?).");
+
+                        return false;
+                    }
+                }
+
+                /**
+                 * Get next entry.
+                 *
+                 * @return Next entry.
+                 */
+                CacheEntry<K, V> GetNext()
+                {
+                    IgniteError err;
+
+                    CacheEntry<K, V> res = GetNext(err);
+
+                    IgniteError::ThrowIfNeeded(err);
+
+                    return res;                        
+                }
+
+                /**
+                 * Get next entry.
+                 *
+                 * @param err Error.
+                 * @return Next entry.
+                 */
+                CacheEntry<K, V> GetNext(IgniteError& err)
+                {
+                    impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
+
+                    if (impl0) {
+                        impl::Out2Operation<K, V> outOp;
+
+                        impl0->GetNext(outOp, &err);
+
+                        if (err.GetCode() == IgniteError::IGNITE_SUCCESS) 
+                        {
+                            K& key = outOp.Get1();
+                            V& val = outOp.Get2();
+
+                            return CacheEntry<K, V>(key, val);
+                        }
+                        else 
+                            return CacheEntry<K, V>();
+                    }
+                    else
+                    {
+                        err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Instance is not usable (did you check for error?).");
+
+                        return CacheEntry<K, V>();
+                    }
+                }
+
+                /**
+                 * Get all entries.
+                 * 
+                 * @param Vector where query entries will be stored.
+                 */
+                void GetAll(std::vector<CacheEntry<K, V>>& res)
+                {
+                    IgniteError err;
+
+                    GetAll(res, err);
+
+                    IgniteError::ThrowIfNeeded(err);
+                }
+
+                /**
+                 * Get all entries.
+                 * 
+                 * @param Vector where query entries will be stored.
+                 * @param err Error.                 
+                 */
+                void GetAll(std::vector<CacheEntry<K, V>>& res, IgniteError& err)
+                {
+                    impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
+
+                    if (impl0) {
+                        impl::OutQueryGetAllOperation<K, V> outOp(&res);
+
+                        impl0->GetAll(outOp, &err);
+                    }
+                    else
+                        err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Instance is not usable (did you check for error?).");
+                }
+
+            private:
+                /** Implementation delegate. */
+                ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl> impl;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/query/query_scan.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/query/query_scan.h b/modules/platform/cpp/core/include/ignite/cache/query/query_scan.h
new file mode 100644
index 0000000..c3ec845
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/query/query_scan.h
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_SCAN
+#define _IGNITE_CACHE_QUERY_SCAN
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {         
+            /*
+             * Scab query.
+             */
+            class ScanQuery
+            {
+            public:
+                /* 
+                 * Constructor.
+                 */
+                ScanQuery() : part(-1), pageSize(1024), loc(false)
+                {
+                    // No-op.
+                }
+                
+                /*
+                 * Constructor.
+                 *
+                 * @param part Partition.
+                 */
+                ScanQuery(int32_t part) : part(part), pageSize(1024), loc(false)
+                {
+                    // No-op.
+                }
+                
+                /*
+                 * Get partition to scan.
+                 *
+                 * @return Partition to scan.
+                 */
+                int32_t GetPartition()
+                {
+                    return part;
+                }
+
+                /*
+                 * Set partition to scan.
+                 *
+                 * @param part Partition to scan.
+                 */
+                void SetPartition(int32_t part)
+                {
+                    this->part = part;
+                }
+
+                /*
+                 * Get page size.
+                 *
+                 * @return Page size.
+                 */
+                int32_t GetPageSize()
+                {
+                    return pageSize;
+                }
+
+                /*
+                 * Set page size.
+                 *
+                 * @param pageSize Page size.
+                 */
+                void SetPageSize(int32_t pageSize)
+                {
+                    this->pageSize = pageSize;
+                }
+
+                /*
+                 * Get local flag.
+                 *
+                 * @return Local flag.
+                 */
+                bool IsLocal()
+                {
+                    return loc;
+                }
+
+                /*
+                 * Set local flag.
+                 *
+                 * @param loc Local flag.
+                 */
+                void SetLocal(bool loc)
+                {
+                    this->loc = loc;
+                }
+                
+                /*
+                 * Write query info to the stream.
+                 *
+                 * @param writer Writer.
+                 */
+                void Write(portable::PortableRawWriter& writer) const
+                {
+                    writer.WriteBool(loc);
+                    writer.WriteInt32(pageSize);
+
+                    if (part < 0)
+                        writer.WriteBool(false);
+                    else
+                    {
+                        writer.WriteBool(true);
+                        writer.WriteInt32(part);
+                    }
+
+                    writer.WriteNull(); // Predicates are not supported yet.
+                }
+
+            private:
+                /* Partition. */
+                int32_t part;
+
+                /* Page size. */
+                int32_t pageSize;
+
+                /* Local flag. */
+                bool loc;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/query/query_sql.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/query/query_sql.h b/modules/platform/cpp/core/include/ignite/cache/query/query_sql.h
new file mode 100644
index 0000000..a2e0f33
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/query/query_sql.h
@@ -0,0 +1,253 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_SQL
+#define _IGNITE_CACHE_QUERY_SQL
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#include "ignite/cache/query/query_argument.h"
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {         
+            /**
+             * Sql query.
+             */
+            class SqlQuery
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param type Type name.
+                 * @param sql SQL string.
+                 */
+                SqlQuery(std::string type, std::string sql) : type(type), sql(sql), pageSize(1024), 
+                    loc(false), args(NULL)
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Copy constructor.
+                 *
+                 * @param other Other instance.
+                 */
+                SqlQuery(const SqlQuery& other)
+                {
+                    type = other.type;
+                    sql = other.sql;
+                    pageSize = other.pageSize;
+                    loc = other.loc;
+
+                    if (other.args)
+                    {
+                        args = new std::vector<QueryArgumentBase*>();
+
+                        for (std::vector<QueryArgumentBase*>::iterator it = other.args->begin();
+                            it != other.args->end(); ++it)
+                            args->push_back((*it)->Copy());
+                    }
+                    else
+                        args = NULL;
+                }
+
+                /**
+                 * Assignment operator.
+                 *
+                 * @param other Other instance.
+                 */
+                SqlQuery& operator=(const SqlQuery& other) 
+                {
+                    if (this != &other)
+                    {
+                        type = other.type;
+                        sql = other.sql;
+                        pageSize = other.pageSize;
+                        loc = other.loc;
+
+                        SqlQuery tmp(other);
+
+                        std::vector<QueryArgumentBase*>* args0 = args;
+
+                        args = tmp.args;
+
+                        tmp.args = args0; 
+                    }
+
+                    return *this;
+                }
+
+                /**
+                 * Destructor.
+                 */
+                ~SqlQuery()
+                {
+                    if (args) 
+                    {
+                        for (std::vector<QueryArgumentBase*>::iterator it = args->begin(); it != args->end(); ++it)
+                            delete (*it);
+
+                        delete args;
+                    }
+                }
+
+                /**
+                 * Get type name.
+                 *
+                 * @return Type name.
+                 */
+                std::string GetType()
+                {
+                    return type;
+                }
+
+                /**
+                 * Set type name.
+                 *
+                 * @param sql Type name.
+                 */
+                void SetType(std::string type)
+                {
+                    this->type = type;
+                }
+
+                /**
+                 * Get SQL string.
+                 *
+                 * @return SQL string.
+                 */
+                std::string GetSql()
+                {
+                    return sql;
+                }
+
+                /**
+                 * Set SQL string.
+                 *
+                 * @param sql SQL string.
+                 */
+                void SetSql(std::string sql)
+                {
+                    this->sql = sql;
+                }
+
+                /**
+                 * Get page size.
+                 *
+                 * @return Page size.
+                 */
+                int32_t GetPageSize()
+                {
+                    return pageSize;
+                }
+
+                /**
+                 * Set page size.
+                 *
+                 * @param pageSize Page size.
+                 */
+                void SetPageSize(int32_t pageSize)
+                {
+                    this->pageSize = pageSize;
+                }
+
+                /**
+                 * Get local flag.
+                 *
+                 * @return Local flag.
+                 */
+                bool IsLocal()
+                {
+                    return loc;
+                }
+
+                /**
+                 * Set local flag.
+                 *
+                 * @param loc Local flag.
+                 */
+                void SetLocal(bool loc)
+                {
+                    this->loc = loc;
+                }
+
+                /**
+                 * Add argument.
+                 *
+                 * @param arg Argument.
+                 */
+                template<typename T>
+                void AddArgument(const T& arg)
+                {
+                    if (!args)
+                        args = new std::vector<QueryArgumentBase*>();
+
+                    args->push_back(new QueryArgument<T>(arg));
+                }
+
+                /**
+                 * Write query info to the stream.
+                 *
+                 * @param writer Writer.
+                 */
+                void Write(portable::PortableRawWriter& writer) const
+                {
+                    writer.WriteBool(loc);
+                    writer.WriteString(sql);
+                    writer.WriteString(type);
+                    writer.WriteInt32(pageSize);
+
+                    if (args)
+                    {
+                        writer.WriteInt32(static_cast<int32_t>(args->size()));
+
+                        for (std::vector<QueryArgumentBase*>::iterator it = args->begin(); it != args->end(); ++it)
+                            (*it)->Write(writer);
+                    }
+                    else
+                        writer.WriteInt32(0);
+                }
+
+            private:
+                /** Type name. */
+                std::string type;
+
+                /** SQL string. */
+                std::string sql;
+
+                /** Page size. */
+                int32_t pageSize;
+
+                /** Local flag. */
+                bool loc;
+
+                /** Arguments. */
+                std::vector<QueryArgumentBase*>* args;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/cache/query/query_text.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/cache/query/query_text.h b/modules/platform/cpp/core/include/ignite/cache/query/query_text.h
new file mode 100644
index 0000000..67d3ecc
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/cache/query/query_text.h
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_TEXT
+#define _IGNITE_CACHE_QUERY_TEXT
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {         
+            /*
+             * Text query.
+             */
+            class TextQuery
+            {
+            public:
+                /*
+                 * Constructor.
+                 *
+                 * @param type Type name.
+                 * @param text Text string.
+                 */
+                TextQuery(std::string type, std::string text) : type(type), text(text), pageSize(1024), loc(false)
+                {
+                    // No-op.
+                }
+                
+                /*
+                 * Get type name.
+                 *
+                 * @return Type name.
+                 */
+                std::string GetType()
+                {
+                    return type;
+                }
+
+                /*
+                 * Set type name.
+                 *
+                 * @param sql Type name.
+                 */
+                void SetType(std::string type)
+                {
+                    this->type = type;
+                }
+
+                /*
+                 * Get text string.
+                 *
+                 * @return text string.
+                 */
+                std::string GetText()
+                {
+                    return text;
+                }
+
+                /*
+                 * Set text string.
+                 *
+                 * @param text Text string.
+                 */
+                void SetText(std::string text)
+                {
+                    this->text = text;
+                }
+
+                /*
+                 * Get page size.
+                 *
+                 * @return Page size.
+                 */
+                int32_t GetPageSize()
+                {
+                    return pageSize;
+                }
+
+                /*
+                 * Set page size.
+                 *
+                 * @param pageSize Page size.
+                 */
+                void SetPageSize(int32_t pageSize)
+                {
+                    this->pageSize = pageSize;
+                }
+
+                /*
+                 * Get local flag.
+                 *
+                 * @return Local flag.
+                 */
+                bool IsLocal()
+                {
+                    return loc;
+                }
+
+                /*
+                    * Set local flag.
+                    *
+                    * @param loc Local flag.
+                    */
+                void SetLocal(bool loc)
+                {
+                    this->loc = loc;
+                }
+                
+                /*
+                 * Write query info to the stream.
+                 *
+                 * @param writer Writer.
+                 */
+                void Write(portable::PortableRawWriter& writer) const
+                {
+                    writer.WriteBool(loc);
+                    writer.WriteString(text);
+                    writer.WriteString(type);
+                    writer.WriteInt32(pageSize);
+                }
+
+            private:
+                /* Type name. */
+                std::string type;
+
+                /* Text string. */
+                std::string text;
+
+                /* Page size. */
+                int32_t pageSize;
+
+                /* Local flag. */
+                bool loc;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/524f5653/modules/platform/cpp/core/include/ignite/guid.h
----------------------------------------------------------------------
diff --git a/modules/platform/cpp/core/include/ignite/guid.h b/modules/platform/cpp/core/include/ignite/guid.h
new file mode 100644
index 0000000..9469769
--- /dev/null
+++ b/modules/platform/cpp/core/include/ignite/guid.h
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_GUID
+#define _IGNITE_GUID
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+    /**
+     * Global universally unique identifier (GUID).
+     */
+    class IGNITE_IMPORT_EXPORT Guid
+    {
+    public:
+        /**
+         * Default constructor.
+         */
+        Guid();
+
+        /**
+         * Constructor.
+         *
+         * @param most Most significant bits.
+         * @param least Least significant bits.
+         */
+        Guid(int64_t most, int64_t least);
+
+        /**
+         * Returns the most significant 64 bits of this instance.
+         *
+         * @return The most significant 64 bits of this instance.
+         */
+        int64_t GetMostSignificantBits() const;
+
+        /**
+         * Returns the least significant 64 bits of this instance.
+         *  
+         * @return The least significant 64 bits of this instance.
+         */
+        int64_t GetLeastSignificantBits() const;
+
+        /**
+         * The version number associated with this instance.  The version
+         * number describes how this Guid was generated.
+         *
+         * The version number has the following meaning:
+         * 1    Time-based UUID;
+         * 2    DCE security UUID;
+         * 3    Name-based UUID;
+         * 4    Randomly generated UUID.
+         *
+         * @return The version number of this instance.
+         */
+        int32_t GetVersion() const;
+
+        /**
+         * The variant number associated with this instance. The variant
+         * number describes the layout of the Guid.
+         *
+         * The variant number has the following meaning:
+         * 0    Reserved for NCS backward compatibility;
+         * 2    IETF RFC 4122 (Leach-Salz), used by this class;
+         * 6    Reserved, Microsoft Corporation backward compatibility;
+         * 7    Reserved for future definition.
+         *
+         * @return The variant number of this instance.
+         */
+        int32_t GetVariant() const;
+
+        /**
+         * Get hash code of this instance (used in serialization).
+         *
+         * @return Hash code.
+         */
+        int32_t GetHashCode() const;
+
+        /**
+         * Comparison operator override.
+         *
+         * @param val1 First value.
+         * @param val2 Second value.
+         * @return True if equal.
+         */
+        friend bool IGNITE_IMPORT_EXPORT operator== (Guid& val1, Guid& val2);
+    private:
+        /** Most significant bits. */
+        int64_t most;  
+
+        /** Least significant bits. */
+        int64_t least; 
+    };
+}
+
+#endif
\ No newline at end of file