Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.CacheHint


        From from = new From();
        UnaryFromClause ufc = new UnaryFromClause();
        from.addClause(ufc);
        ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        query.setFrom(from);          
        query.setCacheHint(new CacheHint());
        TestParser.helpTest(sql, "/*+ cache */ SELECT * FROM t1", query);         //$NON-NLS-1$
    }
View Full Code Here


        From from = new From();
        UnaryFromClause ufc = new UnaryFromClause();
        from.addClause(ufc);
        ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        query.setFrom(from);          
        CacheHint hint = new CacheHint();
        hint.setScope("session");
        hint.setPrefersMemory(true);
        query.setCacheHint(hint);
        TestParser.helpTest(sql, "/*+ cache(pref_mem scope:session) */ SELECT * FROM t1", query);         //$NON-NLS-1$
    }
View Full Code Here

   
    @Test public void testCache1() {
        String sql = "/*+ cache */ execute foo()"; //$NON-NLS-1$
       
        StoredProcedure sp = new StoredProcedure();
        sp.setCacheHint(new CacheHint());
        sp.setProcedureName("foo"); //$NON-NLS-1$

        TestParser.helpTest(sql, "/*+ cache */ EXEC foo()", sp);         //$NON-NLS-1$
    }
View Full Code Here

        From from = new From();
        UnaryFromClause ufc = new UnaryFromClause();
        from.addClause(ufc);
        ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        query.setFrom(from);
        CacheHint hint = new CacheHint();
        hint.setPrefersMemory(true);
        hint.setTtl(Long.valueOf(2000));
        query.setCacheHint(hint);
        TestParser.helpTest(sql, "/*+ cache(pref_mem ttl:2000) */ SELECT * FROM t1", query);         //$NON-NLS-1$
    }
View Full Code Here

        from.addClause(ufc);
        ufc.setGroup(new GroupSymbol("t2")); //$NON-NLS-1$
        query1.setFrom(from);
       
        SetQuery sq = new SetQuery(Operation.UNION, false, query, query1);
        CacheHint hint = new CacheHint();
        hint.setPrefersMemory(true);
        sq.setCacheHint(hint);
        TestParser.helpTest(sql, "/*+ cache(pref_mem) */ SELECT * FROM t1 UNION SELECT * FROM t2", sq);         //$NON-NLS-1$
    }
View Full Code Here

        SPParameter param = new SPParameter(1, null);
        param.setParameterType(SPParameter.RETURN_VALUE);
        sp.setParameter(param);
        sp.setProcedureName("proc");
        sp.setCallableStatement(true);
        CacheHint hint = new CacheHint();
        sp.setCacheHint(hint);
        TestParser.helpTest(sql, "/*+ cache */ ? = EXEC proc()", sp);         //$NON-NLS-1$
    }
View Full Code Here

      return buffer.createIndexedTupleSource();
    }
    //construct a query with a no cache hint
    //note that it's safe to use the stringified form of the parameters because
    //it's not possible to use xml/clob/blob/object
    CacheHint hint = proc.getCacheHint();
    proc.setCacheHint(null);
    Option option = new Option();
    option.setNoCache(true);
    option.addNoCacheGroup(fullName);
    proc.setOption(option);
    Determinism determinismLevel = context.resetDeterminismLevel();
    QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(proc.toString(), fullName.toUpperCase(), context);
    qp.setNonBlocking(true);
    qp.getContext().setDataObjects(null);
    BatchCollector bc = qp.createBatchCollector();
    TupleBuffer tb = bc.collectTuples();
    CachedResults cr = new CachedResults();
    cr.setResults(tb, qp.getProcessorPlan());
    cr.setHint(hint);
    if (hint != null && hint.getDeterminism() != null) {
      LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hint.getDeterminism() }); //$NON-NLS-1$ //$NON-NLS-2$
      determinismLevel = hint.getDeterminism();
    }
    cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null);
    context.setDeterminismLevel(determinismLevel);
    return tb.createIndexedTupleSource();
  }
View Full Code Here

      List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk);
      create.getPrimaryKey().addAll(pkColumns);
    }
    TempTable table = globalStore.addTempTable(tableName, create, bufferManager, false);
    table.setUpdatable(false);
    CacheHint hint = table.getCacheHint();
    boolean updatable = false;
    if (hint != null) {
      table.setPreferMemory(hint.getPrefersMemory());
      if (hint.getTtl() != null) {
        info.setTtl(hint.getTtl());
      }
      if (pk != null) {
        updatable = hint.isUpdatable();
      }
    }
    int rowCount = -1;
    try {
      String fullName = metadata.getFullName(group.getMetadataID());
View Full Code Here

      if (id == null) {
        id = context.getGlobalTableStore().getMetadataStore().addTempGroup(matTableName, Arrays.asList(keyElement, returnElement), false, true);
        String queryString = Reserved.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + Reserved.FROM + ' ' + codeTableName; //$NON-NLS-1$
        id.setQueryNode(new QueryNode(queryString));
        id.setPrimaryKey(id.getElements().subList(0, 1));
        CacheHint hint = new CacheHint(true, null);
        id.setCacheHint(hint);
      }
      Query query = RelationalPlanner.createMatViewQuery(id, matTableName, Arrays.asList(returnElement), true);
      query.setCriteria(new CompareCriteria(keyElement, CompareCriteria.EQ, new Constant(keyValue)));
     
View Full Code Here

      QueryMetadataInterface metadata, GroupSymbol group,
      TempMetadataID id) throws TeiidComponentException,
      QueryMetadataException, QueryResolverException,
      QueryValidatorException {
    Command c = QueryResolver.resolveView(group, metadata.getVirtualPlan(viewId), SQLConstants.Reserved.SELECT, metadata).getCommand();
    CacheHint hint = c.getCacheHint();
    id.setCacheHint(hint);
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.CacheHint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.