Predicate Illegal Argument Exception

369 views
Skip to first unread message

Aarti Jivrajani

unread,
Mar 24, 2017, 9:06:19 PM3/24/17
to Hazelcast
Hi,

I am using SQLPredicate in my application. My keys are strings and values are VersionedPortable Objects. 

int
mdns_hazelcast_map_init
(void *cache_ctx) {

   
HazelcastClient *hazelcastClient = (HazelcastClient *)cache_ctx;
   
IMap<std::string, MCIPortable> mci_serv_map =
        hazelcastClient
->getMap<std::string, MCIPortable>(MCI_SERVER_HASH);
   
IMap<std::string, FlowPortable> flow_map =
        hazelcastClient
->getMap<std::string, FlowPortable>(FLOW_HASH);
   
   
//add indices on the maps for items based on which frequent reads happen
   
mci_serv_map.addIndex("cust_id", true);

    flow_map
.addIndex("flow_id", true);
    flow_map
.addIndex("cust_id", true);

   
return MDNS_DB_OP_OK;

}

The highlighted line gives me the following error : 

terminate called after throwing an instance of 'hazelcast::client::exception::QueryException'
  what():  ExceptionMessage {Error code:42, Class name that generated the error:com.hazelcast.query.QueryException, java.lang.IllegalArgumentException: There is no suitable accessor for 'cust_id' on class 'class java.lang.String'
        ReflectionHelper.java line 176 :com.hazelcast.query.impl.getters.ReflectionHelper.createGetter
        Extractors.java line 125 :com.hazelcast.query.impl.getters.Extractors.instantiateGetter
        Extractors.java line 102 :com.hazelcast.query.impl.getters.Extractors.getGetter
        Extractors.java line 64 :com.hazelcast.query.impl.getters.Extractors.extract
        QueryableEntry.java line 144 :com.hazelcast.query.impl.QueryableEntry.extractAttributeValueFromTargetObject
        QueryableEntry.java line 82 :com.hazelcast.query.impl.QueryableEntry.extractAttributeValue
        QueryableEntry.java line 48 :com.hazelcast.query.impl.QueryableEntry.getAttributeValue
        QueryableEntry.java line 67 :com.hazelcast.query.impl.QueryableEntry.getConverter
        IndexImpl.java line 67 :com.hazelcast.query.impl.IndexImpl.saveEntryIndex
        AddIndexOperation.java line 75 :com.hazelcast.map.impl.operation.AddIndexOperation.run
        OperationRunnerImpl.java line 172 :com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run
        OperationThread.java line 198 :com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.processOperation
        OperationThread.java line 132 :com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.process
        OperationThread.java line 124 :com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.doRun
        OperationThread.java line 99 :com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.run

Cause error code:25
Caused by:java.lang.IllegalArgumentException
} at java.lang.IllegalArgumentException: There is no suitable accessor for 'cust_id' on class 'class java.lang.String'

Program received signal SIGABRT, Aborted.


MCIPortable class has cust_id defined as 
std::auto_ptr<std::string> cust_id;

Please help me out with this issue. 

Thanks, 
Aarti




Aarti Jivrajani

unread,
Mar 24, 2017, 9:10:10 PM3/24/17
to Hazelcast
I am using the predicate as follows : 

        hazelcast::util::snprintf(cid_buf, 64, "cust_id == %s", cust_id);
        hazelcast
::util::snprintf(bssid_buf, 64, "bssid == %s", bssid);
           
        std
::auto_ptr<query::Predicate> cust_id_pred = std::auto_ptr<query::Predicate>(new hazelcast::client::query::SqlPredicate(cid_buf));
        std
::auto_ptr<query::Predicate> bssid_pred = std::auto_ptr<query::Predicate>(new hazelcast::client::query::SqlPredicate(bssid_buf));
           
       
//returns a vector of MCIPortable obj for a particular cid and bssid
        std
::vector<MCIPortable> cid_bssid_required_values = cid_mci_map.values(query::AndPredicate().add(cust_id_pred).add(bssid_pred));


Peter Veentjer

unread,
Mar 24, 2017, 11:59:25 PM3/24/17
to haze...@googlegroups.com
You are trying to get a cust_id from a String class according to the error.

What is the content of that map? It appears to have strings in them and not customers.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+unsubscribe@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/f4c52533-f9e4-49ba-831b-822ebfe25d03%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Aarti Jivrajani

unread,
Mar 25, 2017, 12:01:51 AM3/25/17
to Hazelcast
String cust_id is one the private members of the VersionedPortbale class called MCIPortable.

So the map key is a string and the value is MCIPortable with data members cust_id and two other strings.

Reply all
Reply to author
Forward
0 new messages