You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/09/04 12:37:26 UTC
[44/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to
Ignite.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h
new file mode 100644
index 0000000..23133e1
--- /dev/null
+++ b/modules/platform/src/main/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/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h
new file mode 100644
index 0000000..c3ec845
--- /dev/null
+++ b/modules/platform/src/main/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/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h
new file mode 100644
index 0000000..a2e0f33
--- /dev/null
+++ b/modules/platform/src/main/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/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h
new file mode 100644
index 0000000..67d3ecc
--- /dev/null
+++ b/modules/platform/src/main/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/58a665aa/modules/platform/src/main/cpp/core/include/ignite/guid.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/guid.h b/modules/platform/src/main/cpp/core/include/ignite/guid.h
new file mode 100644
index 0000000..9469769
--- /dev/null
+++ b/modules/platform/src/main/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
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignite.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignite.h b/modules/platform/src/main/cpp/core/include/ignite/ignite.h
new file mode 100644
index 0000000..6c1263e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignite.h
@@ -0,0 +1,154 @@
+/*
+ * 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
+#define _IGNITE
+
+#include "ignite/cache/cache.h"
+#include "ignite/impl/ignite_impl.h"
+#include "ignite/ignite_configuration.h"
+
+namespace ignite
+{
+ /**
+ * Main interface to operate with Ignite.
+ */
+ class IGNITE_IMPORT_EXPORT Ignite
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Ignite();
+
+ /**
+ * Constructor.
+ */
+ Ignite(impl::IgniteImpl* impl);
+
+ /**
+ * Get Ignite instance name.
+ *
+ * @return Name.
+ */
+ char* GetName();
+
+ /**
+ * Get cache.
+ *
+ * @param name Cache name.
+ * @return Cache.
+ */
+ template<typename K, typename V>
+ cache::Cache<K, V> GetCache(const char* name)
+ {
+ IgniteError err;
+
+ cache::Cache<K, V> res = GetCache<K, V>(name, &err);
+
+ IgniteError::ThrowIfNeeded(err);
+
+ return res;
+ }
+
+ /**
+ * Get cache.
+ *
+ * @param name Cache name.
+ * @param err Error;
+ * @return Cache.
+ */
+ template<typename K, typename V>
+ cache::Cache<K, V> GetCache(const char* name, IgniteError* err)
+ {
+ impl::cache::CacheImpl* cacheImpl = impl.Get()->GetCache<K, V>(name, err);
+
+ return cache::Cache<K, V>(cacheImpl);
+ }
+
+ /**
+ * Get or create cache.
+ *
+ * @param name Cache name.
+ * @return Cache.
+ */
+ template<typename K, typename V>
+ cache::Cache<K, V> GetOrCreateCache(const char* name)
+ {
+ IgniteError err;
+
+ cache::Cache<K, V> res = GetOrCreateCache<K, V>(name, &err);
+
+ IgniteError::ThrowIfNeeded(err);
+
+ return res;
+ }
+
+ /**
+ * Get or create cache.
+ *
+ * @param name Cache name.
+ * @param err Error;
+ * @return Cache.
+ */
+ template<typename K, typename V>
+ cache::Cache<K, V> GetOrCreateCache(const char* name, IgniteError* err)
+ {
+ impl::cache::CacheImpl* cacheImpl = impl.Get()->GetOrCreateCache<K, V>(name, err);
+
+ return cache::Cache<K, V>(cacheImpl);
+ }
+
+ /**
+ * Create cache.
+ *
+ * @param name Cache name.
+ * @return Cache.
+ */
+ template<typename K, typename V>
+ cache::Cache<K, V> CreateCache(const char* name)
+ {
+ IgniteError err;
+
+ cache::Cache<K, V> res = CreateCache<K, V>(name, &err);
+
+ IgniteError::ThrowIfNeeded(err);
+
+ return res;
+ }
+
+ /**
+ * Create cache.
+ *
+ * @param name Cache name.
+ * @param err Error;
+ * @return Cache.
+ */
+ template<typename K, typename V>
+ cache::Cache<K, V> CreateCache(const char* name, IgniteError* err)
+ {
+ impl::cache::CacheImpl* cacheImpl = impl.Get()->CreateCache<K, V>(name, err);
+
+ return cache::Cache<K, V>(cacheImpl);
+ }
+ private:
+ /** Implementation delegate. */
+ ignite::common::concurrent::SharedPointer<impl::IgniteImpl> impl;
+ };
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h b/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h
new file mode 100644
index 0000000..ce2d730
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h
@@ -0,0 +1,92 @@
+/*
+ * 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_CONFIGURATION
+#define _IGNITE_CONFIGURATION
+
+#include <stdint.h>
+
+namespace ignite
+{
+ /**
+ * Single JVM option.
+ */
+ struct IgniteJvmOption
+ {
+ /** Option. */
+ char* opt;
+
+ /**
+ * Default constructor.
+ */
+ IgniteJvmOption() : opt(NULL)
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param opt Option.
+ */
+ IgniteJvmOption(char* opt) : opt(opt)
+ {
+ // No-op.
+ }
+ };
+
+ /**
+ * Ignite configuration.
+ */
+ struct IgniteConfiguration
+ {
+ /** Path to Ignite home. */
+ char* igniteHome;
+
+ /** Path to Spring configuration file. */
+ char* springCfgPath;
+
+ /** Path ot JVM libbrary. */
+ char* jvmLibPath;
+
+ /** JVM classpath. */
+ char* jvmClassPath;
+
+ /** Initial amount of JVM memory. */
+ int32_t jvmInitMem;
+
+ /** Maximum amount of JVM memory. */
+ int32_t jvmMaxMem;
+
+ /** Additional JVM options. */
+ IgniteJvmOption* jvmOpts;
+
+ /** Additional JVM options count. */
+ int32_t jvmOptsLen;
+
+ /**
+ * Constructor.
+ */
+ IgniteConfiguration() : igniteHome(NULL), springCfgPath(NULL), jvmLibPath(NULL), jvmClassPath(NULL),
+ jvmInitMem(512), jvmMaxMem(1024), jvmOpts(NULL), jvmOptsLen(0)
+ {
+ // No-op.
+ }
+ };
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h b/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h
new file mode 100644
index 0000000..4438a0e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h
@@ -0,0 +1,260 @@
+/*
+ * 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_ERROR
+#define _IGNITE_ERROR
+
+#include <sstream>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#define IGNITE_ERROR_1(code, part1) { \
+ std::stringstream stream; \
+ stream << (part1); \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_2(code, part1, part2) { \
+ std::stringstream stream; \
+ stream << (part1) << (part2); \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_3(code, part1, part2, part3) { \
+ std::stringstream stream; \
+ stream << (part1) << (part2) << (part3); \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \
+ std::stringstream stream; \
+ stream << msg << " [" << key1 << "=" << (val1) << "]"; \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
+ std::stringstream stream; \
+ stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
+ std::stringstream stream; \
+ stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
+ std::stringstream stream; \
+ stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
+ throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+namespace ignite
+{
+ /**
+ * Ignite error information.
+ */
+ class IGNITE_IMPORT_EXPORT IgniteError
+ {
+ public:
+ /** Success. */
+ static const int IGNITE_SUCCESS = 0;
+
+ /** Failed to initialize JVM. */
+ static const int IGNITE_ERR_JVM_INIT = 1;
+
+ /** Failed to attach to JVM. */
+ static const int IGNITE_ERR_JVM_ATTACH = 2;
+
+ /** JVM library is not found. */
+ static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3;
+
+ /** Failed to load JVM library. */
+ static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4;
+
+ /** JVM classpath is not provided. */
+ static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5;
+
+ /** JVM error: no class definition found. */
+ static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
+
+ /** JVM error: no such method. */
+ static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7;
+
+ /** Memory operation error. */
+ static const int IGNITE_ERR_MEMORY = 1001;
+
+ /** Portable error. */
+ static const int IGNITE_ERR_PORTABLE = 1002;
+
+ /** Generic Ignite error. */
+ static const int IGNITE_ERR_GENERIC = 2000;
+
+ /** Illegal argument passed. */
+ static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001;
+
+ /** Illegal state. */
+ static const int IGNITE_ERR_ILLEGAL_STATE = 2002;
+
+ /** Unsupported operation. */
+ static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003;
+
+ /** Thread has been interrup. */
+ static const int IGNITE_ERR_INTERRUPTED = 2004;
+
+ /** Cluster group is empty. */
+ static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005;
+
+ /** Cluster topology problem. */
+ static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006;
+
+ /** Compute execution rejected. */
+ static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
+
+ /** Compute job failover. */
+ static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008;
+
+ /** Compute task cancelled. */
+ static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009;
+
+ /** Compute task timeout. */
+ static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010;
+
+ /** Compute user undeclared exception. */
+ static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
+
+ /** Generic cache error. */
+ static const int IGNITE_ERR_CACHE = 2012;
+
+ /** Generic cache loader error. */
+ static const int IGNITE_ERR_CACHE_LOADER = 2013;
+
+ /** Generic cache writer error. */
+ static const int IGNITE_ERR_CACHE_WRITER = 2014;
+
+ /** Generic cache entry processor error. */
+ static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015;
+
+ /** Cache atomic update timeout. */
+ static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
+
+ /** Cache partial update. */
+ static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017;
+
+ /** Transaction optimisitc exception. */
+ static const int IGNITE_ERR_TX_OPTIMISTIC = 2018;
+
+ /** Transaction timeout. */
+ static const int IGNITE_ERR_TX_TIMEOUT = 2019;
+
+ /** Transaction rollback. */
+ static const int IGNITE_ERR_TX_ROLLBACK = 2020;
+
+ /** Transaction heuristic exception. */
+ static const int IGNITE_ERR_TX_HEURISTIC = 2021;
+
+ /** Authentication error. */
+ static const int IGNITE_ERR_AUTHENTICATION = 2022;
+
+ /** Security error. */
+ static const int IGNITE_ERR_SECURITY = 2023;
+
+ /** Unknown error. */
+ static const int IGNITE_ERR_UNKNOWN = -1;
+
+ /**
+ * Throw an error if code is not IGNITE_SUCCESS.
+ *
+ * @param err Error.
+ */
+ static void ThrowIfNeeded(IgniteError& err);
+
+ /**
+ * Create empty error.
+ */
+ IgniteError();
+
+ /**
+ * Create error with specific code.
+ *
+ * @param code Error code.
+ */
+ IgniteError(const int32_t code);
+
+ /**
+ * Create error with specific code and message.
+ *
+ * @param code Error code.
+ * @param msg Message.
+ */
+ IgniteError(const int32_t code, const char* msg);
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Other instance.
+ */
+ IgniteError(const IgniteError& other);
+
+ /**
+ * Assignment operator.
+ *
+ * @param other Other instance.
+ * @return Assignment result.
+ */
+ IgniteError& operator=(const IgniteError& other);
+
+ /**
+ * Destructor.
+ */
+ ~IgniteError();
+
+ /**
+ * Get error code.
+ *
+ * @return Error code.
+ */
+ int32_t GetCode();
+
+ /**
+ * Get error message.
+ *
+ * @return Error message.
+ */
+ const char* GetText();
+
+ /**
+ * Set error.
+ *
+ * @param jniCode Error code.
+ * @param jniCls Error class.
+ * @param jniMsg Error message.
+ * @param err Error.
+ */
+ static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err);
+ private:
+ /** Error code. */
+ int32_t code;
+
+ /** Error message. */
+ char* msg;
+ };
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignition.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignition.h b/modules/platform/src/main/cpp/core/include/ignite/ignition.h
new file mode 100644
index 0000000..8d32448
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignition.h
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+/**
+ * \mainpage Apache Ignite C++ Library
+ *
+ * The Apache Ignite is a proven software solution, which delivers unprecedented speed
+ * and unlimited scale to accelerate your business and time to insights. It enables high-performance transactions,
+ * real-time streaming and fast analytics in a single, comprehensive data access and processing layer. The In-Memory
+ * Data Fabric is designed to easily power both existing and new applications in a distributed, massively
+ * parallel architecture on affordable, industry-standard hardware.
+ * <p>
+ * The Apache Ignite provides a unified API that spans all key types of applications
+ * (Java, .NET, C++) and connects them with multiple data stores containing structured, semi-structured and
+ * unstructured data (SQL, NoSQL, Hadoop). It offers a secure, highly available and manageable data environment
+ * that allows companies to process full ACID transactions and generate valuable insights from real-time,
+ * interactive and batch queries.
+ * <p>
+ * The In-Memory Data Fabric offers a strategic approach to in-memory computing that delivers performance,
+ * scale and comprehensive capabilities far above and beyond what traditional in-memory databases,
+ * data grids or other in-memory-based point solutions can offer by themselves.
+ *
+ * \section ultimate_speed_and_scale Ultimate Speed and Scale
+ *
+ * The Apache Ignite accesses and processes data from distributed enterprise and
+ * cloud-based data stores orders of magnitudes faster, and shares them with today's most demanding transactional,
+ * analytical and hybrid applications. The In-Memory Data Fabric delivers unprecedented throughput
+ * and low latency performance in a virtually unlimited, global scale-out architecture for both new and
+ * existing applications.
+ *
+ * \section comprehensive_and_proven Comprehensive and Proven
+ *
+ * The Apache Ignite is the product of seven years of meticulous research and development,
+ * built from the ground up (i.e. no bolt-on's), and run successfully by hundreds of organizations worldwide.
+ * It is a comprehensive in-memory solution that includes a clustering and compute grid, a database-agnostic data grid,
+ * a real-time streaming engine as well as plug-and-play Hadoop acceleration. The In-Memory Data Fabric
+ * connects multiple data sources (relational, NoSQL, Hadoop) with Java, .NET and C++ applications, and offers
+ * a secure and highly available architecture; it also provides a fully-featured, graphical management interface.
+ * <p>
+ * The Apache Ignite is used today by Fortune 500 companies, top government agencies as well as
+ * innovative mobile and web companies in a broad range of business scenarios, such as automated trading systems,
+ * fraud detection, big data analytics, social networks, online gaming, and bioinformatics.
+ */
+
+#ifndef _IGNITE_IGNITION
+#define _IGNITE_IGNITION
+
+#include "ignite/ignite.h"
+#include "ignite/ignite_configuration.h"
+#include "ignite/ignite_error.h"
+
+namespace ignite
+{
+ /**
+ * This class defines a factory for the main Ignite API.
+ */
+ class IGNITE_IMPORT_EXPORT Ignition
+ {
+ public:
+ /**
+ * Start Ignite instance.
+ *
+ * @param cfg Configuration.
+ * @return Ignite instance or null in case of error.
+ */
+ static Ignite Start(const IgniteConfiguration& cfg);
+
+ /*
+ * Start Ignite instance.
+ *
+ * @param cfg Configuration.
+ * @param err Error.
+ * @return Ignite instance or null in case of error.
+ */
+ static Ignite Start(const IgniteConfiguration& cfg, IgniteError* err);
+
+ /**
+ * Start Ignite instance with specific name.
+ *
+ * @param cfg Configuration.
+ * @param name Ignite name.
+ * @return Ignite instance or null in case of error.
+ */
+ static Ignite Start(const IgniteConfiguration& cfg, const char* name);
+
+ /**
+ * Start Ignite instance with specific name.
+ *
+ * @param cfg Configuration.
+ * @param name Ignite name.
+ * @param err Error.
+ * @return Ignite instance or null in case of error.
+ */
+ static Ignite Start(const IgniteConfiguration& cfg, const char* name, IgniteError* err);
+
+ /**
+ * Get default Ignite instance.
+ *
+ * @return Default Ignite instance.
+ */
+ static Ignite Get();
+
+ /**
+ * Get default Ignite instance.
+ *
+ * @param err Error.
+ * @return Default Ignite instance.
+ */
+ static Ignite Get(IgniteError* err);
+
+ /**
+ * Get Ignite instance with the given name.
+ *
+ * @param name Ignite name.
+ * @return Ignite instance.
+ */
+ static Ignite Get(const char* name);
+
+ /**
+ * Get Ignite instance with the given name.
+ *
+ * @param name Ignite name.
+ * @param err Error.
+ * @return Ignite instance.
+ */
+ static Ignite Get(const char* name, IgniteError* err);
+
+ /**
+ * Stop default Ignite instance.
+ *
+ * @param cancel Cancel flag.
+ * @return True if default Ignite instance was stopped by this call.
+ */
+ static bool Stop(const bool cancel);
+
+ /**
+ * Stop default Ignite instance.
+ *
+ * @param cancel Cancel flag.
+ * @param err Error.
+ * @return True if Ignite instance was stopped by this call.
+ */
+ static bool Stop(const bool cancel, IgniteError* err);
+
+ /**
+ * Stop Ignite instance with the given name.
+ *
+ * @param name Ignite name.
+ * @param cancel Cancel flag.
+ * @return True if Ignite instance was stopped by this call.
+ */
+ static bool Stop(const char* name, const bool cancel);
+
+ /**
+ * Stop Ignite instance with the given name.
+ *
+ * @param name Ignite name.
+ * @param cancel Cancel flag.
+ * @param err Error.
+ * @return True if Ignite instance was stopped by this call.
+ */
+ static bool Stop(const char* name, const bool cancel, IgniteError* err);
+
+ /**
+ * Stop all running Ignite instances.
+ *
+ * @param cancel Cancel flag.
+ */
+ static void StopAll(const bool cancel);
+
+ /**
+ * Stop all running Ignite instances.
+ *
+ * @param cancel Cancel flag.
+ * @param err Error.
+ */
+ static void StopAll(const bool cancel, IgniteError* err);
+ };
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h
new file mode 100644
index 0000000..8c744e0
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h
@@ -0,0 +1,418 @@
+/*
+ * 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_IMPL
+#define _IGNITE_CACHE_IMPL
+
+#include "ignite/cache/query/query_scan.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/cache/query/query_impl.h"
+#include "ignite/impl/operations.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace cache
+ {
+ /**
+ * Cache implementation.
+ */
+ class IGNITE_IMPORT_EXPORT CacheImpl
+ {
+ public:
+ /**
+ * Constructor used to create new instance.
+ *
+ * @param name Name.
+ * @param env Environment.
+ * @param javaRef Reference to java object.
+ */
+ CacheImpl(char* name, ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+
+ /**
+ * Destructor.
+ */
+ ~CacheImpl();
+
+ /**
+ * Get name.
+ *
+ * @return Cache name.
+ */
+ char* GetName();
+
+ /**
+ * Perform IsEmpty.
+ *
+ * @param err Error.
+ * @return Result.
+ */
+ bool IsEmpty(IgniteError* err);
+
+ /**
+ * Perform ContainsKey.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result.
+ */
+ bool ContainsKey(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform ContainsKeys.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result.
+ */
+ bool ContainsKeys(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform LocalPeek.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param peekModes Peek modes.
+ * @param err Error.
+ */
+ void LocalPeek(InputOperation& inOp, OutputOperation& outOp,
+ int32_t peekModes, IgniteError* err);
+
+ /**
+ * Perform Get.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void Get(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+ /**
+ * Perform GetAll.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void GetAll(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+ /**
+ * Perform Put.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void Put(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform PutAll.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void PutAll(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform GetAndPut.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void GetAndPut(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+ /**
+ * Perform GetAndReplace.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void GetAndReplace(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+ /**
+ * Perform GetAndRemove.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void GetAndRemove(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+ /**
+ * Perform PutIfAbsent.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result
+ */
+ bool PutIfAbsent(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform GetAndPutIfAbsent.
+ *
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void GetAndPutIfAbsent(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+ /**
+ * Perform Replace(K, V).
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result
+ */
+ bool Replace(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform Replace(K, V, V).
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result
+ */
+ bool ReplaceIfEqual(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform LocalEvict.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void LocalEvict(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform Clear.
+ *
+ * @param err Error.
+ */
+ void Clear(IgniteError* err);
+
+ /**
+ * Perform Clear.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void Clear(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform ClearAll.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void ClearAll(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform LocalClear.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void LocalClear(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform LocalClearAll.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void LocalClearAll(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform Remove(K).
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result
+ */
+ bool Remove(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform Remove(K, V).
+ *
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result
+ */
+ bool RemoveIfEqual(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform RemoveAll.
+ *
+ * @param inOp Input.
+ * @param err Error.
+ */
+ void RemoveAll(InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Perform RemoveAll.
+ *
+ * @param err Error.
+ */
+ void RemoveAll(IgniteError* err);
+
+ /**
+ * Perform Size.
+ *
+ * @param peekModes Peek modes.
+ * @param err Error.
+ * @return Result.
+ */
+ int32_t Size(const int32_t peekModes, IgniteError* err);
+
+ /**
+ * Perform LocalSize.
+ *
+ * @param peekModes Peek modes.
+ * @param err Error.
+ * @return Result.
+ */
+ int32_t LocalSize(const int32_t peekModes, IgniteError* err);
+
+ /**
+ * Invoke query.
+ *
+ * @param qry Query.
+ * @param err Error.
+ * @return Query cursor.
+ */
+ query::QueryCursorImpl* QuerySql(const ignite::cache::query::SqlQuery& qry, IgniteError* err);
+
+ /*
+ * Invoke text query.
+ *
+ * @param qry Query.
+ * @param err Error.
+ * @return Query cursor.
+ */
+ query::QueryCursorImpl* QueryText(const ignite::cache::query::TextQuery& qry, IgniteError* err);
+
+ /*
+ * Invoke scan query.
+ *
+ * @param qry Query.
+ * @param err Error.
+ * @return Query cursor.
+ */
+ query::QueryCursorImpl* QueryScan(const ignite::cache::query::ScanQuery& qry, IgniteError* err);
+
+ private:
+ /** Name. */
+ char* name;
+
+ /** Environment. */
+ ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
+
+ /** Handle to Java object. */
+ jobject javaRef;
+
+ IGNITE_NO_COPY_ASSIGNMENT(CacheImpl)
+
+ /**
+ * Write data to memory.
+ *
+ * @param mem Memory.
+ * @param inOp Input opeartion.
+ * @param err Error.
+ * @return Memory pointer.
+ */
+ int64_t WriteTo(interop::InteropMemory* mem, InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Read data from memory.
+ *
+ * @param mem Memory.
+ * @param outOp Output operation.
+ */
+ void ReadFrom(interop::InteropMemory* mem, OutputOperation& outOp);
+
+ /**
+ * Internal cache size routine.
+ *
+ * @param peekModes Peek modes.
+ * @param loc Local flag.
+ * @param err Error.
+ * @return Size.
+ */
+ int SizeInternal(const int32_t peekModes, const bool loc, IgniteError* err);
+
+ /**
+ * Internal out operation.
+ *
+ * @param opType Operation type.
+ * @param inOp Input.
+ * @param err Error.
+ * @return Result.
+ */
+ bool OutOpInternal(const int32_t opType, InputOperation& inOp, IgniteError* err);
+
+ /**
+ * Internal out-in operation.
+ *
+ * @param opType Operation type.
+ * @param inOp Input.
+ * @param outOp Output.
+ * @param err Error.
+ */
+ void OutInOpInternal(const int32_t opType, InputOperation& inOp, OutputOperation& outOp,
+ IgniteError* err);
+
+ /**
+ * Internal query execution routine.
+ *
+ * @param qry Query.
+ * @param typ Query type.
+ * @param err Error.
+ */
+ template<typename T>
+ query::QueryCursorImpl* QueryInternal(const T& qry, int32_t typ, IgniteError* err)
+ {
+ ignite::common::java::JniErrorInfo jniErr;
+
+ ignite::common::concurrent::SharedPointer<interop::InteropMemory> mem = env.Get()->AllocateMemory();
+ interop::InteropMemory* mem0 = mem.Get();
+ interop::InteropOutputStream out(mem0);
+ portable::PortableWriterImpl writer(&out, env.Get()->GetMetadataManager());
+ ignite::portable::PortableRawWriter rawWriter(&writer);
+
+ qry.Write(rawWriter);
+
+ out.Synchronize();
+
+ jobject qryJavaRef = env.Get()->Context()->CacheOutOpQueryCursor(javaRef, typ, mem.Get()->PointerLong(),
+ &jniErr);
+
+ IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+ if (jniErr.code == ignite::common::java::IGNITE_JNI_ERR_SUCCESS)
+ return new query::QueryCursorImpl(env, qryJavaRef);
+ else
+ return NULL;
+ }
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h
new file mode 100644
index 0000000..e65eeb6
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h
@@ -0,0 +1,115 @@
+/*
+ * 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_IMPL
+#define _IGNITE_CACHE_QUERY_IMPL
+
+#include "ignite/ignite_error.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/operations.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace cache
+ {
+ namespace query
+ {
+ /**
+ * Query cursor implementation.
+ */
+ class IGNITE_IMPORT_EXPORT QueryCursorImpl
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param env Environment.
+ * @param javaRef Java reference.
+ */
+ QueryCursorImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+
+ /**
+ * Destructor.
+ */
+ ~QueryCursorImpl();
+
+ /**
+ * Check whether next result exists.
+ *
+ * @param err Error.
+ * @return True if exists.
+ */
+ bool HasNext(IgniteError* err);
+
+ /**
+ * Get next object.
+ *
+ * @param op Operation.
+ * @param err Error.
+ */
+ void GetNext(OutputOperation& op, IgniteError* err);
+
+ /**
+ * Get all cursor entries.
+ *
+ * @param op Operation.
+ * @param err Error.
+ */
+ void GetAll(OutputOperation& op, IgniteError* err);
+
+ private:
+ /** Environment. */
+ ignite::common::concurrent::SharedPointer<impl::IgniteEnvironment> env;
+
+ /** Handle to Java object. */
+ jobject javaRef;
+
+ /** Whether iteration methods were called. */
+ bool iterCalled;
+
+ /** Whether GetAll() method was called. */
+ bool getAllCalled;
+
+ /** Whether next entry is available. */
+ bool hasNext;
+
+ IGNITE_NO_COPY_ASSIGNMENT(QueryCursorImpl);
+
+ /**
+ * Create Java-side iterator if needed.
+ *
+ * @param err Error.
+ * @return True in case of success, false if an error is thrown.
+ */
+ bool CreateIteratorIfNeeded(IgniteError* err);
+
+ /**
+ * Check whether Java-side iterator has next element.
+ *
+ * @param err Error.
+ * @return True if the next element is available.
+ */
+ bool IteratorHasNext(IgniteError* err);
+ };
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h b/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h
new file mode 100644
index 0000000..5e1b60a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h
@@ -0,0 +1,202 @@
+/*
+ * 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_HANDLE_REGISTRY
+#define _IGNITE_HANDLE_REGISTRY
+
+#include <map>
+#include <stdint.h>
+
+#include <ignite/common/concurrent.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ /**
+ * Something what can be registered inside handle registry.
+ */
+ class IGNITE_IMPORT_EXPORT HandleRegistryEntry
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~HandleRegistryEntry();
+ };
+
+ /**
+ * Handle registry segment containing thread-specific data for slow-path access.
+ */
+ class IGNITE_IMPORT_EXPORT HandleRegistrySegment
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ HandleRegistrySegment();
+
+ /**
+ * Destructor.
+ */
+ ~HandleRegistrySegment();
+
+ /**
+ * Get entry from segment.
+ *
+ * @param hnd Handle.
+ * @return Associated entry or NULL if it doesn't exists.
+ */
+ ignite::common::concurrent::SharedPointer<HandleRegistryEntry> Get(int64_t hnd);
+
+ /**
+ * Put entry into segment.
+ *
+ * @param hnd Handle.
+ * @param entry Associated entry (cannot be NULL).
+ */
+ void Put(int64_t hnd, const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& entry);
+
+ /**
+ * Remove entry from the segment.
+ *
+ * @param hnd Handle.
+ */
+ void Remove(int64_t hnd);
+
+ /**
+ * Clear all entries from the segment.
+ */
+ void Clear();
+ private:
+ /** Map with data. */
+ std::map<int64_t, ignite::common::concurrent::SharedPointer<HandleRegistryEntry>>* map;
+
+ /** Mutex. */
+ ignite::common::concurrent::CriticalSection* mux;
+
+ IGNITE_NO_COPY_ASSIGNMENT(HandleRegistrySegment);
+ };
+
+ /**
+ * Handle registry.
+ */
+ class IGNITE_IMPORT_EXPORT HandleRegistry
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param fastCap Fast-path capacity.
+ * @param segmentCnt Slow-path segments count.
+ */
+ HandleRegistry(int32_t fastCap, int32_t slowSegmentCnt);
+
+ /**
+ * Destructor.
+ */
+ ~HandleRegistry();
+
+ /**
+ * Allocate handle.
+ *
+ * @param target Target.
+ * @return Handle.
+ */
+ int64_t Allocate(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+ /**
+ * Allocate handle in critical mode.
+ *
+ * @param target Target.
+ * @return Handle.
+ */
+ int64_t AllocateCritical(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+ /**
+ * Allocate handle in safe mode.
+ *
+ * @param target Target.
+ * @return Handle.
+ */
+ int64_t AllocateSafe(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+ /**
+ * Allocate handle in critical and safe modes.
+ *
+ * @param target Target.
+ * @return Handle.
+ */
+ int64_t AllocateCriticalSafe(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+ /**
+ * Release handle.
+ *
+ * @param hnd Handle.
+ */
+ void Release(int64_t hnd);
+
+ /**
+ * Get target.
+ *
+ * @param hnd Handle.
+ * @param Target.
+ */
+ ignite::common::concurrent::SharedPointer<HandleRegistryEntry> Get(int64_t hnd);
+
+ /**
+ * Close the registry.
+ */
+ void Close();
+ private:
+ /** Fast-path container capacity. */
+ int32_t fastCap;
+
+ /** Fast-path counter. */
+ int32_t fastCtr;
+
+ /** Fast-path container. */
+ ignite::common::concurrent::SharedPointer<HandleRegistryEntry>* fast;
+
+ /** Amount of slow-path segments. */
+ int32_t slowSegmentCnt;
+
+ /** Slow-path counter. */
+ int64_t slowCtr;
+
+ /** Slow-path segments. */
+ HandleRegistrySegment** slow;
+
+ /** Close flag. */
+ int32_t closed;
+
+ IGNITE_NO_COPY_ASSIGNMENT(HandleRegistry);
+
+ /**
+ * Internal allocation routine.
+ *
+ * @param target Target.
+ * @param Critical mode flag.
+ * @param Safe mode flag.
+ */
+ int64_t Allocate0(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target,
+ bool critical, bool safe);
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h
new file mode 100644
index 0000000..2f195b2
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h
@@ -0,0 +1,130 @@
+/*
+ * 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_ENVIRONMENT
+#define _IGNITE_ENVIRONMENT
+
+#include <ignite/common/concurrent.h>
+#include <ignite/common/java.h>
+
+#include "ignite/impl/interop/interop_memory.h"
+#include "portable/portable_metadata_manager.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ /**
+ * Defines environment in which Ignite operates.
+ */
+ class IGNITE_IMPORT_EXPORT IgniteEnvironment
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ IgniteEnvironment();
+
+ /**
+ * Destructor.
+ */
+ ~IgniteEnvironment();
+
+ /**
+ * Populate callback handlers.
+ *
+ * @param Target (current env wrapped into a shared pointer).
+ * @return JNI handlers.
+ */
+ ignite::common::java::JniHandlers GetJniHandlers(ignite::common::concurrent::SharedPointer<IgniteEnvironment>* target);
+
+ /**
+ * Perform initialization on successful start.
+ *
+ * @param ctx Context.
+ */
+ void Initialize(ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx);
+
+ /**
+ * Start callback.
+ *
+ * @param memPtr Memory pointer.
+ */
+ void OnStartCallback(long long memPtr);
+
+ /**
+ * Get name of Ignite instance.
+ *
+ * @return Name.
+ */
+ char* InstanceName();
+
+ /**
+ * Get JNI context.
+ *
+ * @return Context.
+ */
+ ignite::common::java::JniContext* Context();
+
+ /**
+ * Get memory for interop operations.
+ *
+ * @return Memory.
+ */
+ ignite::common::concurrent::SharedPointer<interop::InteropMemory> AllocateMemory();
+
+ /**
+ * Get memory chunk for interop operations with desired capacity.
+ *
+ * @param cap Capacity.
+ * @return Memory.
+ */
+ ignite::common::concurrent::SharedPointer<interop::InteropMemory> AllocateMemory(int32_t cap);
+
+ /**
+ * Get memory chunk located at the given pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @retrun Memory.
+ */
+ ignite::common::concurrent::SharedPointer<interop::InteropMemory> GetMemory(int64_t memPtr);
+
+ /**
+ * Get metadata manager.
+ *
+ * @param Metadata manager.
+ */
+ portable::PortableMetadataManager* GetMetadataManager();
+ private:
+ /** Context to access Java. */
+ ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx;
+
+ /** Startup latch. */
+ ignite::common::concurrent::SingleLatch* latch;
+
+ /** Ignite name. */
+ char* name;
+
+ /** Metadata manager. */
+ portable::PortableMetadataManager* metaMgr;
+
+ IGNITE_NO_COPY_ASSIGNMENT(IgniteEnvironment);
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h
new file mode 100644
index 0000000..52472c6
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h
@@ -0,0 +1,146 @@
+/*
+ * 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_IMPL
+#define _IGNITE_IMPL
+
+#include <ignite/common/concurrent.h>
+#include <ignite/common/java.h>
+
+#include "ignite/impl/cache/cache_impl.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/utils.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ /**
+ * Ignite implementation.
+ */
+ class IgniteImpl
+ {
+ friend class Ignite;
+ public:
+ /**
+ * Constructor used to create new instance.
+ *
+ * @param env Environment.
+ * @param javaRef Reference to java object.
+ */
+ IgniteImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+
+ /**
+ * Destructor.
+ */
+ ~IgniteImpl();
+
+ /**
+ * Get name of the Ignite.
+ *
+ * @param Name.
+ */
+ char* GetName();
+
+ /**
+ * Get cache.
+ *
+ * @param name Cache name.
+ * @param err Error.
+ */
+ template<typename K, typename V>
+ cache::CacheImpl* GetCache(const char* name, IgniteError* err)
+ {
+ ignite::common::java::JniErrorInfo jniErr;
+
+ jobject cacheJavaRef = env.Get()->Context()->ProcessorCache(javaRef, name, &jniErr);
+
+ if (!cacheJavaRef)
+ {
+ IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+ return NULL;
+ }
+
+ char* name0 = utils::CopyChars(name);
+
+ return new cache::CacheImpl(name0, env, cacheJavaRef);
+ }
+
+ /**
+ * Get or create cache.
+ *
+ * @param name Cache name.
+ * @param err Error.
+ */
+ template<typename K, typename V>
+ cache::CacheImpl* GetOrCreateCache(const char* name, IgniteError* err)
+ {
+ ignite::common::java::JniErrorInfo jniErr;
+
+ jobject cacheJavaRef = env.Get()->Context()->ProcessorGetOrCreateCache(javaRef, name, &jniErr);
+
+ if (!cacheJavaRef)
+ {
+ IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+ return NULL;
+ }
+
+ char* name0 = utils::CopyChars(name);
+
+ return new cache::CacheImpl(name0, env, cacheJavaRef);
+ }
+
+ /**
+ * Create cache.
+ *
+ * @param name Cache name.
+ * @param err Error.
+ */
+ template<typename K, typename V>
+ cache::CacheImpl* CreateCache(const char* name, IgniteError* err)
+ {
+ ignite::common::java::JniErrorInfo jniErr;
+
+ jobject cacheJavaRef = env.Get()->Context()->ProcessorCreateCache(javaRef, name, &jniErr);
+
+ if (!cacheJavaRef)
+ {
+ IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+ return NULL;
+ }
+
+ char* name0 = utils::CopyChars(name);
+
+ return new cache::CacheImpl(name0, env, cacheJavaRef);
+ }
+ private:
+ /** Environment. */
+ ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
+
+ /** Native Java counterpart. */
+ jobject javaRef;
+
+ IGNITE_NO_COPY_ASSIGNMENT(IgniteImpl)
+ };
+ }
+
+}
+
+#endif
\ No newline at end of file