Gangaiah - this will reproduce what I am seeing:
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <ignite/ignite_configuration.h>
#include <ignite/ignition.h>
#include <chrono>
#define CACHE_SIZE 100000
#define CHRONO_MS std::chrono::duration_cast<std::chrono::milliseconds>
struct DataObject
{
int64_t A, B, C;
ignite::Guid D;
};
namespace ignite::binary
{
template<>
struct BinaryType<DataObject> : BinaryTypeDefaultAll<DataObject>
{
static void GetTypeName(std::string &typeName) { typeName = "TEST";
}
static void Write(BinaryWriter& writer, const DataObject& obj)
{
writer.WriteInt64("A", obj.A);
writer.WriteInt64("B", obj.B);
writer.WriteInt64("C", obj.C);
writer.WriteGuid("D", obj.D);
}
static void Read(BinaryReader& reader, DataObject& obj)
{
obj.A = reader.ReadInt64("A");
obj.B = reader.ReadInt64("B");
obj.C = reader.ReadInt64("C");
obj.D = reader.ReadGuid("D");
}
};
}
int main(int arc, char* argv[])
{
ignite::IgniteConfiguration cfg;
cfg.springCfgPath = "/tmp/ignite.xml";
ignite::Ignition::Start(cfg);
ignite::cache::Cache<int64_t, DataObject> DataCache =
ignite::Ignition::Get().GetCache<int64_t, DataObject>("TEST");
DataObject dataOb;
auto time0 = std::chrono::high_resolution_clock::now();
for(int64_t x=1;x<=CACHE_SIZE;x++)
{
dataOb.A = x;
DataCache.Put(x, dataOb);
}
auto time1 = std::chrono::high_resolution_clock::now();
std::cout << "Put: " << CACHE_SIZE*1000/CHRONO_MS(time1 - time0).count()
<<" per sec" << std::endl;
for(int64_t x=1;x<=CACHE_SIZE;x++)
{
DataObject newDataOb = DataCache.Get(x);
assert(newDataOb.A == x);
}
auto time2 = std::chrono::high_resolution_clock::now();
std::cout << "Get: " << CACHE_SIZE*1000/CHRONO_MS(time2 - time1).count()
<<" per sec" << std::endl;
ignite::cache::query::SqlFieldsQuery query1("SELECT A, B, C, D FROM TEST
WHERE _key = ?");
for(int64_t x=1;x<=CACHE_SIZE;x++)
{
query1.AddArgument<int64_t>(x);
ignite::cache::query::QueryFieldsCursor cursor =
DataCache.Query(query1);
assert(cursor.IsValid() && cursor.HasNext());
query1.ClearArguments();
}
auto time3 = std::chrono::high_resolution_clock::now();
std::cout << "Select1: " << CACHE_SIZE*1000/CHRONO_MS(time3 -
time2).count() << " per sec" << std::endl;
ignite::cache::query::SqlFieldsQuery query2("SELECT A, B, C, D FROM TEST
WHERE A = ?");
for(int64_t x=1;x<=1000;x++)
{
query2.AddArgument<int64_t>(x);
ignite::cache::query::QueryFieldsCursor cursor =
DataCache.Query(query2);
assert(cursor.IsValid() && cursor.HasNext());
query2.ClearArguments();
}
auto time4 = std::chrono::high_resolution_clock::now();
std::cout << "Select2: " << 1000*1000/CHRONO_MS(time4 - time3).count()
<<" per sec" << std::endl;
ignite::Ignition::StopAll(false);
return 0;
}
The xml I use looks like this:
<property name="cacheConfiguration">
<list>
<bean
class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="TEST"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeSynchronizationMode"
value="FULL_SYNC"/>
<property name="queryEntities">
<list>
<bean
class="org.apache.ignite.cache.QueryEntity">
<property name="keyType"
value="java.lang.Long"/>
<property name="valueType" value="TEST"/>
<property name="fields">
<map>
<entry key="A"
value="java.lang.Long"/>
<entry key="B"
value="java.lang.Long"/>
<entry key="C"
value="java.lang.Long"/>
<entry key="D"
value="java.util.UUID"/>
</map>
</property>
<property name="indexes">
<list>
<bean
class="org.apache.ignite.cache.QueryIndex">
<property name="fields">
<map>
<entry key="A"
value="true"/>
</map>
</property>
<property name="indexType"
value="FULLTEXT"/>
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
</list>
</property>
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/