Search in sources :

Example 6 with GridCacheTwoStepQuery

use of org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery in project ignite by apache.

the class IgniteCachelessQueriesSelfTest method assertLocalTwoStepQuery.

/**
 * Check that local two-step query has happened.
 */
private void assertLocalTwoStepQuery() {
    GridCacheTwoStepQuery q = cachedTwoStepQuery();
    assertNotNull(q);
    assertTrue(q.isLocal());
}
Also used : GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery)

Example 7 with GridCacheTwoStepQuery

use of org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery in project ignite by apache.

the class IgniteCachelessQueriesSelfTest method assertDistributedQuery.

/**
 * Check that truly distributed query has happened.
 */
private void assertDistributedQuery() {
    GridCacheTwoStepQuery q = cachedTwoStepQuery();
    assertNotNull(q);
    assertFalse(q.isLocal());
}
Also used : GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery)

Example 8 with GridCacheTwoStepQuery

use of org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery in project ignite by apache.

the class IgniteH2Indexing method unregisterCache.

/** {@inheritDoc} */
@Override
public void unregisterCache(String cacheName) {
    String schemaName = schema(cacheName);
    boolean dflt = isDefaultSchema(schemaName);
    H2Schema schema = dflt ? schemas.get(schemaName) : schemas.remove(schemaName);
    if (schema != null) {
        mapQryExec.onCacheStop(cacheName);
        dmlProc.onCacheStop(cacheName);
        // Remove this mapping only after callback to DML proc - it needs that mapping internally
        cacheName2schema.remove(cacheName);
        // Drop tables.
        Collection<H2TableDescriptor> rmvTbls = new HashSet<>();
        for (H2TableDescriptor tbl : schema.tables()) {
            if (F.eq(tbl.cache().name(), cacheName)) {
                try {
                    dropTable(tbl);
                } catch (IgniteCheckedException e) {
                    U.error(log, "Failed to drop table on cache stop (will ignore): " + tbl.fullTableName(), e);
                }
                schema.drop(tbl);
                rmvTbls.add(tbl);
            }
        }
        if (!dflt) {
            try {
                dropSchema(schemaName);
            } catch (IgniteCheckedException e) {
                U.error(log, "Failed to drop schema on cache stop (will ignore): " + cacheName, e);
            }
        }
        for (H2TableDescriptor tbl : rmvTbls) {
            for (Index idx : tbl.table().getIndexes()) idx.close(null);
        }
        int cacheId = CU.cacheId(cacheName);
        for (Iterator<Map.Entry<H2TwoStepCachedQueryKey, H2TwoStepCachedQuery>> it = twoStepCache.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry<H2TwoStepCachedQueryKey, H2TwoStepCachedQuery> e = it.next();
            GridCacheTwoStepQuery qry = e.getValue().query();
            if (!F.isEmpty(qry.cacheIds()) && qry.cacheIds().contains(cacheId))
                it.remove();
        }
    }
}
Also used : GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery) Index(org.h2.index.Index) H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) H2PkHashIndex(org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex) IgniteSystemProperties.getString(org.apache.ignite.IgniteSystemProperties.getString) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) GridBoundedConcurrentLinkedHashMap(org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 9 with GridCacheTwoStepQuery

use of org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery in project ignite by apache.

the class IgniteCachelessQueriesSelfTest method assertLocalQuery.

/**
 * Check that no distributed query has happened.
 */
private void assertLocalQuery() {
    GridCacheTwoStepQuery q = cachedTwoStepQuery();
    assertNull(q);
}
Also used : GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery)

Example 10 with GridCacheTwoStepQuery

use of org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery in project ignite by apache.

the class IgniteH2Indexing method split.

/**
 * Split query into two-step query.
 * @param prepared JDBC prepared statement.
 * @param qry Original fields query.
 * @return Two-step query.
 * @throws IgniteCheckedException in case of error inside {@link GridSqlQuerySplitter}.
 * @throws SQLException in case of error inside {@link GridSqlQuerySplitter}.
 */
private GridCacheTwoStepQuery split(Prepared prepared, SqlFieldsQuery qry) throws IgniteCheckedException, SQLException {
    GridCacheTwoStepQuery res = GridSqlQuerySplitter.split(connectionForThread(qry.getSchema()), prepared, qry.getArgs(), qry.isCollocated(), qry.isDistributedJoins(), qry.isEnforceJoinOrder(), this);
    List<Integer> cacheIds = collectCacheIds(null, res);
    if (F.isEmpty(cacheIds))
        res.local(true);
    else {
        res.cacheIds(cacheIds);
        res.local(qry.isLocal());
    }
    res.pageSize(qry.getPageSize());
    return res;
}
Also used : BigInteger(java.math.BigInteger) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery)

Aggregations

GridCacheTwoStepQuery (org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery)12 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 IgniteSystemProperties.getString (org.apache.ignite.IgniteSystemProperties.getString)5 Prepared (org.h2.command.Prepared)5 PreparedStatement (java.sql.PreparedStatement)4 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)4 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 LinkedHashSet (java.util.LinkedHashSet)3 GridQueryFieldMetadata (org.apache.ignite.internal.processors.query.GridQueryFieldMetadata)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 IgniteSystemProperties.getInteger (org.apache.ignite.IgniteSystemProperties.getInteger)2 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)2 GridCacheSqlQuery (org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery)2