Hello
I have a case to loop through few million records and apply some
transformation, for that I knew I have to use scanquery. However, for printing
sample data I tried to use QueryCursor and got Data conversion error. Not sure
why.
Cache.get worked and scanquery also worked fine, just query cursor is throwing
error.
For testing purpose
created a simple POJO with 2 fields - 1 as integer and other as character
cache created with config properties setIndexedTypes, setSqlSchema
Issues - Two folds and would like help for both
DB conversion occurs when there are fields in POJO with character type and when
QueryCursor is used to get result and print. As work around, I was able to
change Character to String and get it printed. I want to know the fix for the
root cause.
BinaryMarshaller Issue - In the above case, as a remediation I change Character
field to String and that caused Marshaller error saying 2 different data types
for a field. Removing Work/Marshaller directory couldn't fix this. Changing the
class name fixed it. But, what is the permanent fix?
POJO
======
public class TestMarshaller implements Serializable {
@QuerySqlField(index = true)
public long recid;
@QuerySqlField
public Character testfield1;
public TestMarshaller(long recid, Character testfield1) {
this.recid = recid;
this.testfield1 = testfield1;
}
public TestMarshaller() {
}
public long getId() {
return recid;
}
public void setId(long recid) {
this.recid = recid;
}
public Character getTestfield1() {
return testfield1;
}
public void setTestfield1(Character testfield1) {
this.testfield1 = testfield1;
}
@Override
public String toString() {
return "TestMarshaller{" +
"recid=" + recid +
", testfield1=" + testfield1 +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TestMarshaller)) return false;
TestMarshaller that = (TestMarshaller) o;
return recid == that.recid &&
Objects.equals( getTestfield1(), that.getTestfield1() );
}
@Override
public int hashCode() {
return Objects.hash( recid, getTestfield1() );
}
}
Code for Cache creation, loading and printing
======================================
public class TestMarshallerChange {
private static final String TestMarsh = "TestMarshaller";
public static void main(String[] args) throws IOException {
Ignition.setClientMode( true );
IgniteConfiguration iconfig = IgniteConfig.getIgniteConfigClient(
"TESTINSTANCE" );
Ignite ignite = Ignition.start( iconfig );
try {
CacheConfiguration<Long, TestMarshaller> test_cfg = new
CacheConfiguration<>(TestMarsh);
test_cfg.setIndexedTypes( Long.class, TestMarshaller.class );
test_cfg.setSqlSchema("PUBLIC");
IgniteCache<Long, TestMarshaller> test_cache =
ignite.getOrCreateCache(test_cfg );
System.out.println( "============NOW LOADING CACHE
test_cache===========" );
for (long i = 0; i <= 10; i++) {
TestMarshaller dm = new TestMarshaller();
dm.recid = i;
test_cache.put( i, dm);
}
System.out.println( "============NOW PRINTING CACHE
test_cache===========" );
for (long i = 0; i <= 10; i++) {
System.out.println(test_cache.get(i).toString());
}
System.out.println( "==============NOW PRINTING test_cache with
Cursor=============" );
try (QueryCursor<List<?>> queryCursor = test_cache.query( new
SqlFieldsQuery( "select * from TestMarshaller" ) )) {
for (List<?> entry : queryCursor) {
System.out.println(entry.toString());
}
}
}
catch (Exception exp)
{}
}
}
Compile Error
=============
>>> +----------------------------------------------------------------------+
>>> Ignite ver. 2.6.0#20180710-sha1:669feacc5d3a4e60efcdd300dc8de99780f38eed
>>> +----------------------------------------------------------------------+
>>> OS name: Windows 10 10.0 amd64
>>> CPU(s): 4
>>> Heap: 1.8GB
>>> VM name: 5976@XXXXXXXXXX
>>> Ignite instance name: TESTINSTANCE
>>> Local node [ID=5512A195-01D1-4378-863A-74ADEAFA65AF, order=73,
>>> clientMode=true]
>>> Local node addresses: [XXXXXXXXXX.XXX.XXXX.com/0:0:0:0:0:0:0:1,
>>> /10.91.43.248, /127.0.0.1]
>>> Local ports: TCP:10801 TCP:47102
INFO | 2018-12-12 23:31:18 | [main] log4j2.Log4J2Logger
(Log4J2Logger.java:478) - Topology snapshot [ver=73, servers=1, clients=1,
CPUs=4, offheap=1.6GB, heap=3.5GB]
INFO | 2018-12-12 23:31:18 | [main] log4j2.Log4J2Logger
(Log4J2Logger.java:478) - ^-- Node [id=5512A195-01D1-4378-863A-74ADEAFA65AF,
clusterState=ACTIVE]
INFO | 2018-12-12 23:31:19 | [exchange-worker-#37%TESTINSTANCE%]
log4j2.Log4J2Logger (Log4J2Logger.java:478) - Started exchange init
[topVer=AffinityTopologyVersion [topVer=73, minorTopVer=1], crd=false,
evt=DISCOVERY_CUSTOM_EVT, evtNode=5512a195-01d1-4378-863a-74adeafa65af,
customEvt=DynamicCacheChangeBatch
[id=e99d246a761-71a40aa7-4c58-4d47-aa48-55795fcbb34a,
reqs=[DynamicCacheChangeRequest [cacheName=TestMarshaller, hasCfg=true,
nodeId=5512a195-01d1-4378-863a-74adeafa65af, clientStartOnly=false, stop=false,
destroy=false, disabledAfterStartfalse]], exchangeActions=ExchangeActions
[startCaches=[TestMarshaller], stopCaches=null, startGrps=[TestMarshaller],
stopGrps=[], resetParts=null, stateChangeRequest=null], startCaches=false],
allowMerge=false]
ERROR | 2018-12-12 23:31:19 | [exchange-worker-#37%TESTINSTANCE%]
log4j2.Log4J2Logger (Log4J2Logger.java:498) - Failed to reinitialize local
partitions (preloading will be stopped): GridDhtPartitionExchangeId
[topVer=AffinityTopologyVersion [topVer=73, minorTopVer=1],
discoEvt=DiscoveryCustomEvent [customMsg=DynamicCacheChangeBatch
[id=e99d246a761-71a40aa7-4c58-4d47-aa48-55795fcbb34a,
reqs=[DynamicCacheChangeRequest [cacheName=TestMarshaller, hasCfg=true,
nodeId=5512a195-01d1-4378-863a-74adeafa65af, clientStartOnly=false, stop=false,
destroy=false, disabledAfterStartfalse]], exchangeActions=ExchangeActions
[startCaches=[TestMarshaller], stopCaches=null, startGrps=[TestMarshaller],
stopGrps=[], resetParts=null, stateChangeRequest=null], startCaches=false],
affTopVer=AffinityTopologyVersion [topVer=73, minorTopVer=1],
super=DiscoveryEvent [evtNode=TcpDiscoveryNode
[id=5512a195-01d1-4378-863a-74adeafa65af, addrs=[0:0:0:0:0:0:0:1, 10.91.43.248,
127.0.0.1], sockAddrs=[/0:0:0:0:0:0:0:1:0, /127.0.0.1:0,
XXXXXXXXXX.XXX.XXXX.com/10.91.43.248:0], discPort=0, order=73, intOrder=0,
lastExchangeTime=1544682676028, loc=true, ver=2.6.0#20180710-sha1:669feacc,
isClient=true], topVer=73, nodeId8=5512a195, msg=null,
type=DISCOVERY_CUSTOM_EVT, tstamp=1544682679279]], nodeId=5512a195,
evt=DISCOVERY_CUSTOM_EVT]
org.h2.message.DbException: Data conversion error converting "char (not
supported)" [22018-195]
at org.h2.message.DbException.get(DbException.java:179)
~[h2-1.4.195.jar:1.4.195]
at org.h2.message.DbException.get(DbException.java:155)
~[h2-1.4.195.jar:1.4.195]
at org.h2.value.DataType.getTypeFromClass(DataType.java:951)
~[h2-1.4.195.jar:1.4.195]
at
org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor.refreshMetadataFromTypeDescriptor(GridH2RowDescriptor.java:136)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor.<init>(GridH2RowDescriptor.java:117)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.createTable(IgniteH2Indexing.java:2241)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.registerType(IgniteH2Indexing.java:2163)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.registerCache0(GridQueryProcessor.java:1625)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart0(GridQueryProcessor.java:799)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart(GridQueryProcessor.java:860)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.startCache(GridCacheProcessor.java:1212)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheStart(GridCacheProcessor.java:1964)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager.onCacheChangeRequest(CacheAffinitySharedManager.java:791)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.onCacheChangeRequest(GridDhtPartitionsExchangeFuture.java:987)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:646)
[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2419)
[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2299)
[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
[ignite-core-2.6.0.jar:2.6.0]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
Caused by: org.h2.jdbc.JdbcSQLException: Data conversion error converting "char
(not supported)" [22018-195]
at
org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
~[h2-1.4.195.jar:1.4.195]
... 19 more
INFO | 2018-12-12 23:31:20 | [exchange-worker-#37%TESTINSTANCE%]
log4j2.Log4J2Logger (Log4J2Logger.java:478) - Finish exchange future
[startVer=AffinityTopologyVersion [topVer=73, minorTopVer=1], resVer=null,
err=org.h2.message.DbException: Data conversion error converting "char (not
supported)" [22018-195]]
ERROR | 2018-12-12 23:31:20 | [exchange-worker-#37%TESTINSTANCE%]
log4j2.Log4J2Logger (Log4J2Logger.java:498) - Failed to wait for completion of
partition map exchange (preloading will not start):
GridDhtPartitionsExchangeFuture [firstDiscoEvt=DiscoveryCustomEvent
[customMsg=null, affTopVer=AffinityTopologyVersion [topVer=73, minorTopVer=1],
super=DiscoveryEvent [evtNode=TcpDiscoveryNode
[id=5512a195-01d1-4378-863a-74adeafa65af, addrs=[0:0:0:0:0:0:0:1, 10.91.43.248,
127.0.0.1], sockAddrs=[/0:0:0:0:0:0:0:1:0, /127.0.0.1:0,
XXXXXXXXXX.XXX.XXXX.com/10.91.43.248:0], discPort=0, order=73, intOrder=0,
lastExchangeTime=1544682676028, loc=true, ver=2.6.0#20180710-sha1:669feacc,
isClient=true], topVer=73, nodeId8=5512a195, msg=null,
type=DISCOVERY_CUSTOM_EVT, tstamp=1544682679279]], crd=TcpDiscoveryNode
[id=dba6ab9e-5c07-4b10-89db-a622a62f2cf2, addrs=[0:0:0:0:0:0:0:1, 10.91.43.248,
127.0.0.1], sockAddrs=[/0:0:0:0:0:0:0:1:47500, /127.0.0.1:47500,
XXXXXXXXXX.XXX.XXXX.com/10.91.43.248:47500], discPort=47500, order=72,
intOrder=37, lastExchangeTime=1544682676527, loc=false,
ver=2.6.0#20180710-sha1:669feacc, isClient=false],
exchId=GridDhtPartitionExchangeId [topVer=AffinityTopologyVersion [topVer=73,
minorTopVer=1], discoEvt=DiscoveryCustomEvent [customMsg=null,
affTopVer=AffinityTopologyVersion [topVer=73, minorTopVer=1],
super=DiscoveryEvent [evtNode=TcpDiscoveryNode
[id=5512a195-01d1-4378-863a-74adeafa65af, addrs=[0:0:0:0:0:0:0:1, 10.91.43.248,
127.0.0.1], sockAddrs=[/0:0:0:0:0:0:0:1:0, /127.0.0.1:0,
XXXXXXXXXX.XXX.XXXX.com/10.91.43.248:0], discPort=0, order=73, intOrder=0,
lastExchangeTime=1544682676028, loc=true, ver=2.6.0#20180710-sha1:669feacc,
isClient=true], topVer=73, nodeId8=5512a195, msg=null,
type=DISCOVERY_CUSTOM_EVT, tstamp=1544682679279]], nodeId=5512a195,
evt=DISCOVERY_CUSTOM_EVT], added=true, initFut=GridFutureAdapter
[ignoreInterrupts=false, state=DONE, res=false, hash=773635748], init=false,
lastVer=null, partReleaseFut=null, exchActions=null, affChangeMsg=null,
initTs=1544682679279, centralizedAff=false, forceAffReassignment=false,
changeGlobalStateE=null, done=true, state=CLIENT, evtLatch=0,
remaining=[dba6ab9e-5c07-4b10-89db-a622a62f2cf2], super=GridFutureAdapter
[ignoreInterrupts=false, state=DONE, res=org.h2.message.DbException: Data
conversion error converting "char (not supported)" [22018-195], hash=847596940]]
org.apache.ignite.IgniteCheckedException: Data conversion error converting
"char (not supported)" [22018-195]
at
org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:7307)
[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.util.future.GridFutureAdapter.resolve(GridFutureAdapter.java:259)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:207)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:159)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:151)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2433)
[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2299)
[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
[ignite-core-2.6.0.jar:2.6.0]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
Caused by: org.h2.message.DbException: Data conversion error converting "char
(not supported)" [22018-195]
at org.h2.message.DbException.get(DbException.java:179)
~[h2-1.4.195.jar:1.4.195]
at org.h2.message.DbException.get(DbException.java:155)
~[h2-1.4.195.jar:1.4.195]
at org.h2.value.DataType.getTypeFromClass(DataType.java:951)
~[h2-1.4.195.jar:1.4.195]
at
org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor.refreshMetadataFromTypeDescriptor(GridH2RowDescriptor.java:136)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor.<init>(GridH2RowDescriptor.java:117)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.createTable(IgniteH2Indexing.java:2241)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.registerType(IgniteH2Indexing.java:2163)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.registerCache0(GridQueryProcessor.java:1625)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart0(GridQueryProcessor.java:799)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart(GridQueryProcessor.java:860)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.startCache(GridCacheProcessor.java:1212)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheStart(GridCacheProcessor.java:1964)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager.onCacheChangeRequest(CacheAffinitySharedManager.java:791)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.onCacheChangeRequest(GridDhtPartitionsExchangeFuture.java:987)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:646)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2419)
~[ignite-core-2.6.0.jar:2.6.0]
... 3 more
Caused by: org.h2.jdbc.JdbcSQLException: Data conversion error converting "char
(not supported)" [22018-195]
at
org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
~[h2-1.4.195.jar:1.4.195]
at org.h2.message.DbException.get(DbException.java:179)
~[h2-1.4.195.jar:1.4.195]
at org.h2.message.DbException.get(DbException.java:155)
~[h2-1.4.195.jar:1.4.195]
at org.h2.value.DataType.getTypeFromClass(DataType.java:951)
~[h2-1.4.195.jar:1.4.195]
at
org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor.refreshMetadataFromTypeDescriptor(GridH2RowDescriptor.java:136)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor.<init>(GridH2RowDescriptor.java:117)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.createTable(IgniteH2Indexing.java:2241)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.registerType(IgniteH2Indexing.java:2163)
~[ignite-indexing-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.registerCache0(GridQueryProcessor.java:1625)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart0(GridQueryProcessor.java:799)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart(GridQueryProcessor.java:860)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.startCache(GridCacheProcessor.java:1212)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheStart(GridCacheProcessor.java:1964)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager.onCacheChangeRequest(CacheAffinitySharedManager.java:791)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.onCacheChangeRequest(GridDhtPartitionsExchangeFuture.java:987)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:646)
~[ignite-core-2.6.0.jar:2.6.0]
at
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2419)
~[ignite-core-2.6.0.jar:2.6.0]
... 3 more
INFO | 2018-12-12 23:32:27 | [ignite-update-notifier-timer]
log4j2.Log4J2Logger (Log4J2Logger.java:478) - Update status is not available.
Process finished with exit code -1
Regards
Elanthirayan Krishnasamy
American Express made the following annotations
"This message and any attachments are solely for the intended recipient and may
contain confidential or privileged information. If you are not the intended
recipient, any disclosure, copying, use, or distribution of the information
included in this message and any attachments is prohibited. If you have
received this communication in error, please notify us by reply e-mail and
immediately and permanently delete this message and any attachments. Thank
you."
American Express a ajouté le commentaire suivant le
Ce courrier et toute pièce jointe qu'il contient sont réservés au seul
destinataire indiqué et peuvent renfermer des renseignements confidentiels et
privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation,
duplication, utilisation ou distribution du courrier ou de toute pièce jointe
est interdite. Si vous avez reçu cette communication par erreur, veuillez nous
en aviser par courrier et détruire immédiatement le courrier et les pièces
jointes. Merci.