/** * Close query cursor. */ public void close() { cur.close(); } }
/** * Set error caught during query execution. * * @param err Error caught during query execution. */ public void setError(Throwable err) { this.err = err; if (cur != null) cur.close(); }
/** {@inheritDoc} */ @Override public void close() { cursor.close(); }
/** * Closes and removes cursor. * * @param uuid Cursor UUID. */ static void remove(UUID uuid) { Cursor c = CURSORS.remove(uuid); if (c != null) c.cursor.close(); }
/** {@inheritDoc} */ @Override public boolean hasNext() { boolean hasNext = iter.hasNext(); if (!hasNext) cursor.close(); return hasNext; }
/** * @param uuid Cursor UUID. * @param c Cursor. * @return {@code true} If succeeded. */ private static boolean remove(UUID uuid, Cursor c) { boolean rmv = CURSORS.remove(uuid, c); if (rmv) c.cursor.close(); return rmv; }
/** {@inheritDoc} */ @Override protected void onClose() { cur.close(); ThreadLocalObjectPool<H2ConnectionWrapper>.Reusable conn0 = conn; if (conn0 != null) conn0.recycle(); }
/** * Closes the cursor. */ @Override public void close() { if (closeGuard.compareAndSet(false, true)) { cursor.close(); ctx.decrementCursors(); } }
/** {@inheritDoc} */ @Override public void close() { if (cur != null) cur.close(); if (cancel != null) cancel.cancel(); }
@Override public void run() { cursor.close(); } }, timeoutUnits, timeUnit);
/** * @param futId Cursor ID. * @param c Cursor. * @return {@code true} If succeeded. */ private boolean remove(UUID futId, Cursor c) { if (ignite.cluster().<UUID,Cursor>nodeLocalMap().remove(futId, c)) { c.cursor.close(); return true; } return false; }
/** * Internal close routine. */ private void close0() { if (ptr != 0) { long ptr0 = ptr; ptr = 0; if (cursor != null) cursor.close(); platformCtx.gateway().continuousQueryFilterRelease(ptr0); } }
/** * @param cur Cur. */ private void tryClose(QueryCursor<?> cur) { try { cur.close(); } catch (Throwable e) { if (e instanceof IgniteClientDisconnectedException) { IgniteClientDisconnectedException ex = (IgniteClientDisconnectedException)e; ex.reconnectFuture().get(); cur.close(); } else throw e; } }
/** * @param cur Cur. */ private void tryClose(QueryCursor<?> cur) { try { cur.close(); } catch (Throwable e) { if (e instanceof IgniteClientDisconnectedException) { IgniteClientDisconnectedException ex = (IgniteClientDisconnectedException)e; ex.reconnectFuture().get(); cur.close(); } else throw e; } }
/** * Tests that SQL queries involving actual network IO are executed in dedicated pool. * @throws Exception If failed. * @see GridCacheTwoStepQuery#isLocal() */ @Test public void testSqlQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME); // We do this in order to have 1 row in results of select - function is called once per each row of result. cache.put(1, 1); // We have to refer to a cache explicitly in the query in order for it to be executed // in non local distributed manner (yes, there's a "local distributed" manner too - see link above...) QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select currentPolicy() from Integer")); List<List<?>> result = cursor.getAll(); cursor.close(); assertEquals(1, result.size()); Byte plc = (Byte)result.get(0).get(0); assertNotNull(plc); assertEquals(GridIoPolicy.QUERY_POOL, (byte)plc); } }
/** * Tests that SPI queries are executed in dedicated pool * @throws Exception If failed. */ @Test public void testSpiQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache<Byte, Byte> cache = client.cache(CACHE_NAME); for (byte b = 0; b < Byte.MAX_VALUE; ++b) cache.put(b, b); QueryCursor<Cache.Entry<Byte, Byte>> cursor = cache.query(new SpiQuery<Byte, Byte>()); List<Cache.Entry<Byte, Byte>> all = cursor.getAll(); assertEquals(1, all.size()); assertEquals(GridIoPolicy.QUERY_POOL, (byte)all.get(0).getValue()); cursor.close(); } }
/** * Non local SQL Fields check nullification after close */ @Test public void testSqlFieldsQueryClose() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); QueryCursor<List<?>> qryCurs = cache().query(qry); qryCurs.iterator(); qryCurs.close(); H2ResultSetIterator h2It = extractGridIteratorInnerH2ResultSetIterator(qryCurs); checkIterator(h2It); }
/** * Tests that Scan queries are executed in dedicated pool * @throws Exception If failed. */ @Test public void testScanQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME); cache.put(0, 0); QueryCursor<Cache.Entry<Object, Object>> cursor = cache.query( new ScanQuery<>(new IgniteBiPredicate<Object, Object>() { @Override public boolean apply(Object o, Object o2) { return F.eq(GridIoManager.currentPolicy(), GridIoPolicy.QUERY_POOL); } })); assertEquals(1, cursor.getAll().size()); cursor.close(); } }
/** * Local SQL Fields check nullification after close */ @Test public void testSqlFieldsQueryLocalClose() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); qry.setLocal(true); QueryCursor<List<?>> qryCurs = cache().query(qry); qryCurs.iterator(); qryCurs.close(); H2ResultSetIterator h2It = extractGridIteratorInnerH2ResultSetIterator(qryCurs); checkIterator(h2It); }
/** * Check, that query results are not accumulated, when result set size is a multiple of a {@link Query#pageSize}. * * @throws Exception If failed. */ @Test public void testResultIsMultipleOfPage() throws Exception { IgniteEx srv = (IgniteEx)startGrid("server"); Ignite client = startGrid("client"); IgniteCache<Integer, Person> cache = startPeopleCache(client); int pages = 3; int pageSize = 1024; for (int i = 0; i < pages * pageSize; i++) { Person p = new Person("Person #" + i, 25); cache.put(i, p); } for (int i = 0; i < 100; i++) { Query<List<?>> qry = new SqlFieldsQuery("select * from people"); qry.setPageSize(pageSize); QueryCursor<List<?>> cursor = cache.query(qry); cursor.getAll(); cursor.close(); } assertTrue("MapNodeResults is not cleared on the map node.", isMapNodeResultsEmpty(srv)); }