Hi All,
I don't have any model classes and i want to perform CRUD Operation through
sql query with write behind i will use SQL Server for insert or merge.
here is steps what i did so far.
1Add cache configuration template in Ignite and.
2.Used cacheName to GetOrCreateCache and.
3.Run SQLFieldQuery to create cache Table
4.Insert record into created table.
*steps 1,2,3:*
public async Task<string> CreateDMLCache(string cacheName,string
groupName,string query,string tableName)
{
/* {
"CacheName":"TENANT_76FD180C-4810-4545-A105-EBAD644F4FA2_PEOPLE",
"Query":"CREATE TABLE IF NOT EXISTS Person (id
varchar,city_id int,name varchar,age int,company varchar,PRIMARY KEY (id))
WITH \"template=TENANT_76FD180C-4810-4545-A105-EBAD644F4FA2_PEOPLE\"",
"GroupName":"TENANT_76FD180C-4810-4545-A105-EBAD644F4FA2",
"TableName":"PERSON"
}*/
var connectionString = "";
var templateName = cacheName.Remove(cacheName.Length - 1, 1) +
"*";
var cacheCfg = new CacheConfiguration(templateName)
{
Name = cacheName,
CacheStoreFactory = new TenantTestCacheStoreFactory(_logger,
connectionString),
KeepBinaryInStore = false, // Cache store works with
deserialized data.
ReadThrough = true,
WriteThrough = true,
WriteBehindEnabled = true,
WriteBehindFlushThreadCount = 2,
CacheMode = CacheMode.Partitioned,
Backups = 0,
DataRegionName = "IgniteDataRegion",
EvictionPolicy = new LruEvictionPolicy
{
MaxSize = 100000
},
EnableStatistics = true,
WriteSynchronizationMode =
CacheWriteSynchronizationMode.FullSync,
GroupName = groupName
};
Ignite.AddCacheConfiguration(cacheCfg);
var cache = Ignite.GetOrCreateCache<string,
IConstructionCacheStore>(cacheName);
SqlFieldsQuery sqlQuery = new SqlFieldsQuery(query);
var cursur = cache.Query(sqlQuery).GetAll();
foreach (var record in cursur)
{
}
return "Success";
}
*.NetCache Store class:*
public interface IConstructionCacheStore
{
}
public class TenantTestCacheStore: ICacheStore<string,
IConstructionCacheStore>
{
private readonly string _connectionString = null;
private readonly CommonProperties _common;
private readonly EventLogger _logger = null;
public TenantTestCacheStore(EventLogger logger, String
connectionString)
{
this._logger = logger;
this._connectionString = connectionString;
_common = new CommonProperties();
}
public void WriteAll(IEnumerable<KeyValuePair<string,
IConstructionCacheStore>> entries)
{
//throw new NotImplementedException();
try
{
List<KeyValuePair<string, IConstructionCacheStore>>
entityList = entries.ToList();
foreach (var recordEntry in entityList)
{
Console.WriteLine("WriteAll");
}
}
catch (Exception ex)
{
}
}
}
*Step4:*
var queryTest = "INSERT INTO PERSON2(ID,CITY_ID,NAME,AGE)
values('125',123456,'CP',26)";
SqlFieldsQuery query = new SqlFieldsQuery(queryTest);
var cursor = cache.Query(query).GetAll();
foreach(var record in cursor)
{
}
at this time of insert writeAll() throwing exception like
class org.apache.ignite.binary.BinaryObjectException: Unknown pair
[platformId=1, typeId=-1455665693]
at
org.apache.ignite.internal.processors.platform.binary.PlatformBinaryProcessor.processInStreamOutStream(PlatformBinaryProcessor.java:126)
at
org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl.inStreamOutStream(PlatformTargetProxyImpl.java:136)
at
org.apache.ignite.internal.processors.platform.callback.PlatformCallbackUtils.inLongOutLong(Native
Method)
at
org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway.cacheStoreInvoke(PlatformCallbackGateway.java:80)
at
org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore.doInvoke(PlatformDotNetCacheStore.java:480)
at
org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore.writeAll(PlatformDotNetCacheStore.java:277)
at
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore.updateStore(GridCacheWriteBehindStore.java:816)
at
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore.applyBatch(GridCacheWriteBehindStore.java:726)
at
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore.access$2400(GridCacheWriteBehindStore.java:76)
at
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$Flusher.flushCacheCoalescing(GridCacheWriteBehindStore.java:1147)
at
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$Flusher.body(GridCacheWriteBehindStore.java:1018)
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: Unknown pair [platformId=1,
typeId=-1455665693]
at
org.apache.ignite.internal.MarshallerContextImpl.getClassName(MarshallerContextImpl.java:394)
at
org.apache.ignite.internal.processors.platform.binary.PlatformBinaryProcessor.processInStreamOutStream(PlatformBinaryProcessor.java:121)
... 12 more
How to solve above error? And i have some queries like
1.If i am creating caches through create command what i should define Tk,TV
in ICacheStore<TK,TV> in store?
2.What is the other way to exceute create command query like currently
using sqlFieldsQuery and Cursor?
3.How to load bulk data in created table?
Please give me suggestion.
Thanks.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/