Examples of CacheID


Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

     
      //create one for each session token
      helpPutPreparedPlans(cache, token, 1, 1);
      helpPutPreparedPlans(cache, token2, 1, 1);
      //should have one
      assertNotNull("Unable to get prepared plan from cache for token", cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
      cache.clearAll();
      //should not exist for token
      assertNull("Failed remove from cache", cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
      //should not exist for token2
      assertNull("Unable to get prepared plan from cache for token2", cache.get(new CacheID(token2, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

   
    @Test public void testMaxSize(){
        SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>(100);
        helpPutPreparedPlans(cache, token, 0, 101);
        //the first one should be gone because the max size is 100
        assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
       
        assertNotNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 12)));
        helpPutPreparedPlans(cache, token, 102, 50);
        //"sql12" should still be there based on lru  policy
        assertNotNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 12)));
       
        helpPutPreparedPlans(cache, token2, 0, 121);
        helpPutPreparedPlans(cache, token, 0, 50);
        assertTrue(cache.getTotalCacheEntries() <= 100);
    }
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

        SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>(0);
        assertEquals(0, cache.getSpaceAllowed());
       
        // Add 1 plan and verify it is not in the cache
        helpPutPreparedPlans(cache, token, 0, 1);
        assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
        assertEquals(0, cache.getTotalCacheEntries());
       
        // Add another plan and verify it is not in the cache
        helpPutPreparedPlans(cache, token, 1, 1);
        assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1)));
        assertEquals(0, cache.getTotalCacheEntries());       
    }
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

      try {
        dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + (start + i));
      } catch (QueryParserException e) {
        throw new RuntimeException(e);
      }
        CacheID id = new CacheID(session, pi, dummy.toString());

        PreparedPlan pPlan = new PreparedPlan();
        cache.put(id, Determinism.SESSION_DETERMINISTIC, pPlan, null);
        pPlan.setCommand(dummy);
        pPlan.setPlan(new RelationalPlan(new ProjectNode(i)), new CommandContext());
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

    //collapse the hash to single byte for the key to restrict the possible results to 256
    int hash = vals.hashCode();
    hash |= (hash >>> 16);
    hash |= (hash >>> 8);
    hash &= 0x000000ff;
    CacheID cid = new CacheID(new ParseInfo(), fullName + hash, context.getVdbName(),
        context.getVdbVersion(), context.getConnectionID(), context.getUserName());
    cid.setParameters(vals);
    CachedResults results = cache.get(cid);
    if (results != null) {
      TupleBuffer buffer = results.getResults();
      return buffer.createIndexedTupleSource();
    }
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

    }
    int rowCount = -1;
    try {
      String fullName = metadata.getFullName(group.getMetadataID());
      TupleSource ts = null;
      CacheID cid = null;
      if (distributedCache != null) {
        cid = new CacheID(new ParseInfo(), fullName, context.getVdbName(),
            context.getVdbVersion(), context.getConnectionID(), context.getUserName());
        CachedResults cr = this.distributedCache.get(cid);
        if (cr != null) {
          ts = cr.getResults().createIndexedTupleSource();
        }
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

  protected void processNew() throws TeiidProcessingException, TeiidComponentException {
    SessionAwareCache<CachedResults> rsCache = dqpCore.getRsCache();
       
    boolean cachable = false;
    CacheID cacheId = null;
    boolean canUseCached = (requestMsg.useResultSetCache() ||
        QueryParser.getQueryParser().parseCacheHint(requestMsg.getCommandString()) != null);
   
    if (rsCache != null) {
      if (!canUseCached) {
        LogManager.logDetail(LogConstants.CTX_DQP, requestID, "No cache directive"); //$NON-NLS-1$
      } else {
        ParseInfo pi = Request.createParseInfo(requestMsg);
        cacheId = new CacheID(this.dqpWorkContext, pi, requestMsg.getCommandString());
          cachable = cacheId.setParameters(requestMsg.getParameterValues());
        if (cachable) {
          CachedResults cr = rsCache.get(cacheId);
          if (cr != null) {
            this.resultsBuffer = cr.getResults();
            this.analysisRecord = cr.getAnalysisRecord();
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

        Command command = null;
       
        ParseInfo info = new ParseInfo();
        // Defect 19747 - the parser needs the following connection property to decide whether to treat double-quoted strings as variable names
        info.ansiQuotedIdentifiers = isDoubleQuotedVariablesAllowed;
        CacheID id = new CacheID(workContext, info, sql);
        PreparedPlan plan = planCache.get(id);
        if(plan != null) {
            command = plan.getCommand();
        } else {
          command = QueryParser.getQueryParser().parseCommand(sql, info);
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

     * @throws TeiidProcessingException
     * @see org.teiid.dqp.internal.process.Request#generatePlan()
     */
    protected void generatePlan() throws TeiidComponentException, TeiidProcessingException {
      String sqlQuery = requestMsg.getCommands()[0];
      CacheID id = new CacheID(this.workContext, Request.createParseInfo(this.requestMsg), sqlQuery);
        prepPlan = prepPlanCache.get(id);
        if (prepPlan == null) {
            //if prepared plan does not exist, create one
            prepPlan = new PreparedPlan();
            LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query does not exist in cache: ", sqlQuery}); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.dqp.internal.process.SessionAwareCache.CacheID

   
    public PreparedPlan getPlan(String key) {
      if (this.globalState.planCache == null) {
        return null;
      }
      CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(), getConnectionID(), getUserName());
      PreparedPlan pp = this.globalState.planCache.get(id);
      if (pp != null) {
        if (id.getSessionId() != null) {
          setDeterminismLevel(Determinism.USER_DETERMINISTIC);
        } else if (id.getUserName() != null) {
          setDeterminismLevel(Determinism.SESSION_DETERMINISTIC);
        }
          return pp;
      }
      return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.