/** * Test metrics for Sql queries. */ @Test public void testTextQueryMetrics() { TextQuery qry = new TextQuery<>("String", "1"); checkNoQueryMetrics(qry); }
/** * Reads text query. * * @param reader Binary reader. * @return Query. */ private Query readTextQuery(BinaryRawReader reader) { boolean loc = reader.readBoolean(); String txt = reader.readString(); String typ = reader.readString(); final int pageSize = reader.readInt(); return new TextQuery(typ, txt).setPageSize(pageSize).setLocal(loc); }
/** * Test metrics for Sql queries. * * @throws Exception In case of error. */ @Test public void testTextQueryHistoryNotFullyFetched() throws Exception { TextQuery qry = new TextQuery<>("String", "1"); qry.setPageSize(10); checkQueryNotFullyFetchedMetrics(qry, true); }
/** * @throws Exception If failed. */ @Test public void testFullTextLocalQuery() throws Exception { IgniteCache<Integer, String> cache = grid().getOrCreateCache(String.class.getSimpleName()); try { cache.query(new TextQuery<Integer, String>(String.class, "text").setLocal(true)).getAll(); assert false; } catch (CacheException e) { X.println("Caught expected exception: " + e); } catch (Exception ignored) { assert false; } }
TextQuery p = (TextQuery)filter; qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), isKeepBinary); fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.TEXT, p.getText(), ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() { @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() {
/** * Sets type for query. * * @param type Type. * @return {@code this} For chaining. */ public TextQuery<K, V> setType(Class<?> type) { return setType(QueryUtils.typeName(type)); }
/** * Test metrics for Sql queries. * * @throws Exception In case of error. */ @Test public void testTextQueryNotFullyFetchedMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); TextQuery qry = new TextQuery<>("String", "1"); qry.setPageSize(10); checkQueryNotFullyFetchedMetrics(cache, qry, true); }
/** * @param clause Query clause. * @param loc local query flag. * @param keepBinary keep binary flag. */ private void checkTextQuery(String clause, boolean loc, boolean keepBinary) throws Exception { final IgniteEx ignite = grid(0); if (F.isEmpty(clause)) clause = "1*"; // 1. Populate cache with data, calculating expected count in parallel. Set<Integer> exp = populateCache(ignite, loc, MAX_ITEM_COUNT, new IgnitePredicate<Integer>() { @Override public boolean apply(Integer x) { return String.valueOf(x).startsWith("1"); } }); // 2. Validate results. TextQuery qry = new TextQuery<>(Person.class, clause).setLocal(loc); validateQueryResults(ignite, qry, exp, keepBinary); clearCache(ignite); }
TextQuery p = (TextQuery)filter; qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), isKeepBinary); fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.TEXT, p.getText(), ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() { @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() {
/** * Sets type for query. * * @param type Type. * @return {@code this} For chaining. */ public TextQuery<K, V> setType(Class<?> type) { return setType(QueryUtils.typeName(type)); }
@Override public void applyx() throws IgniteCheckedException { while (!done.get()) { QueryCursor<Cache.Entry<UUID, PersonObj>> master = cache0.query(new TextQuery(PersonObj.class, "Master")); Collection<Cache.Entry<UUID, PersonObj>> entries = master.getAll(); checkResult(entries, p1, p2); long cnt = luceneCnt.incrementAndGet(); if (cnt % logMod == 0) info("Executed LUCENE queries: " + cnt); } } }, luceneThreads, "LUCENE-THREAD");
/** * Reads text query. * * @param reader Binary reader. * @return Query. */ private Query readTextQuery(BinaryRawReader reader) { boolean loc = reader.readBoolean(); String txt = reader.readString(); String typ = reader.readString(); final int pageSize = reader.readInt(); return new TextQuery(typ, txt).setPageSize(pageSize).setLocal(loc); }
/** * Test metrics for Sql queries. * * @throws Exception In case of error. */ @Test public void testTextQueryNotFullyFetchedMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); TextQuery qry = new TextQuery<>("String", "1"); qry.setPageSize(10); checkQueryNotFullyFetchedMetrics(cache, qry, true); }
@Override public Object call() throws IgniteCheckedException { return jcache().query(new TextQuery<>(String.class, "text")).getAll(); } }, "Indexing is disabled for cache: default");
/** * Clear cache with check. */ private static void clearCache(IgniteEx ignite) { IgniteCache<Integer, Person> cache = ignite.cache(PERSON_CACHE); cache.clear(); List all = cache.query(new TextQuery<>(Person.class, "1*")).getAll(); assertTrue(all.isEmpty()); }
/** * @throws Exception If failed. */ @Test public void testFullTextQuery() throws Exception { IgniteCache<Integer, String> cache = grid().getOrCreateCache(String.class.getSimpleName()); try { cache.query(new TextQuery<Integer, String>(String.class, "text")).getAll(); assert false; } catch (CacheException e) { X.println("Caught expected exception: " + e); } catch (Exception ignored) { assert false; } }