use of org.apache.ignite.internal.sql.optimizer.affinity.PartitionClientContext in project ignite by apache.
the class JdbcThinConnection method updateAffinityCache.
/**
* Recreates affinity cache if affinity topology version was changed and adds partition result to sql cache.
*
* @param qryReq Query request.
* @param res Jdbc Response.
*/
private void updateAffinityCache(JdbcQueryExecuteRequest qryReq, JdbcResponse res) {
if (partitionAwareness) {
AffinityTopologyVersion resAffVer = res.affinityVersion();
if (resAffVer != null && (affinityCache == null || affinityCache.version().compareTo(resAffVer) < 0)) {
affinityCache = new AffinityCache(resAffVer, connProps.getPartitionAwarenessPartitionDistributionsCacheSize(), connProps.getPartitionAwarenessSqlCacheSize());
}
// Partition result was requested.
if (res.response() instanceof JdbcQueryExecuteResult && qryReq.partitionResponseRequest()) {
PartitionResult partRes = ((JdbcQueryExecuteResult) res.response()).partitionResult();
if (partRes == null || affinityCache.version().equals(partRes.topologyVersion())) {
int cacheId = (partRes != null && partRes.tree() != null) ? GridCacheUtils.cacheId(partRes.cacheName()) : -1;
PartitionClientContext partClientCtx = partRes != null ? new PartitionClientContext(partRes.partitionsCount()) : null;
QualifiedSQLQuery qry = new QualifiedSQLQuery(qryReq.schemaName(), qryReq.sqlQuery());
JdbcThinPartitionResultDescriptor partResDescr = new JdbcThinPartitionResultDescriptor(partRes, cacheId, partClientCtx);
affinityCache.addSqlQuery(qry, partResDescr);
}
}
}
}
Aggregations